diff --git a/AUTHORS b/AUTHORS index 9c608213..8990f859 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,7 @@ Inactive/former developers: * Viktor Kojouharov (Виктор Кожухаров) Patches (in no special order): + * Daniel Bainton (:viewsource) * Muthu Kannan (ctrl-v support) * Lars Kindler (:buffer(s) functionality) * Lee Hinman (:open ./.. support) diff --git a/NEWS b/NEWS index 231c0a42..fbf42e27 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,5 @@
-2007-xx-xx:
+2008-xx-xx:
 	* version 0.6
 	* THIS VERSION ONLY WORKS WITH FIREFOX 3.0 beta1 or newer
 	* IMPORTANT: options are no longer automatically stored - use the
@@ -9,12 +9,13 @@
 	  removed the following hint options: 'hintchars' 'maxhints'
 	  added the following hint options: 'hinttimeout'
 	* IMPORTANT: changed 'I' key to Ctrl-Q to also work in textboxes
-    * :au[tocmd] executes commands on events (only 'onPageLoad' actually) on websites
+    * :au[tocmd] executes commands on events (only 'PageLoad' actually) on websites
 	* @@ to repeat last macro
 	* new macro commands q[a-z0-9] and @[a-z0-9] to replay them (thanks Marco!)
 	* scroll commands like j/k/gg/etc. have a much better heuristic to find a scrollable frame
     * imap, inoremap, iunmap and imapclear added
 	* new g0 and g$ mappings to go to the first/last tab
+	* new gf and gF mappings and ;v and ;V hints mode to view the source code
 	* new 'history' option for specifying the number of Ex commands and
 	  search patterns to store in the commandline history
 	* new ctrl-x and ctrl-a mappings to increment the last number in the URL
diff --git a/TODO b/TODO
index 722ebd88..b1b092e9 100644
--- a/TODO
+++ b/TODO
@@ -30,7 +30,6 @@ FEATURES:
 6 use '' to jump between marks like vim
 6 pipe selected text/link/website to an external command
 6 macros (qq, @q, ...)
-6 gf = view source?
 6 :set wildoptions=auto mode, which would list completions on each keystroke (maybe performance problems)
 5 Use ctrl-w+j/k/w to switch between sidebar, content, preview window
 5 Favicons in completion windows and some other places?
diff --git a/content/commands.js b/content/commands.js
index 41650978..d4337119 100644
--- a/content/commands.js
+++ b/content/commands.js
@@ -2517,6 +2517,39 @@ vimperator.Commands = function () //{{{
             help: "You can show the Firefox version page with :version!."
         }
     ));
+    commandManager.add(new vimperator.Command(["vie[wsource]"],
+        function (args, special)
+        {
+            var url = args || vimperator.buffer.URL;
+            if (special) // internal editor
+            {
+                vimperator.open("view-source:" + url)
+            }
+            else
+            {
+                // TODO: make that a helper function
+                // TODO: save return value in v:shell_error
+                var newThread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0);
+                var editor = vimperator.options["editor"];
+                var args = editor.split(" "); // FIXME: too simple
+                if (args.length < 1)
+                {
+                    vimperator.open("view-source:" + url)
+                    vimperator.echoerr("no editor specified");
+                    return;
+                }
+
+                var prog = args.shift();
+                args.push(url)
+                vimperator.callFunctionInThread(newThread, vimperator.run, [prog, args, true]);
+            }
+        },
+        {
+            usage: ["vie[wsource][!] [url]"],
+            shortHelp: "View source code of current document",
+            help: "When ! is given, it is opened with the internal editor, otherwise with the external."
+        }
+    ));
     commandManager.add(new vimperator.Command(["viu[sage]"],
         function (args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); },
         {
diff --git a/content/editor.js b/content/editor.js
index d7d8c65d..be54452b 100644
--- a/content/editor.js
+++ b/content/editor.js
@@ -329,8 +329,7 @@ vimperator.Editor = function () //{{{
         {
             var textBox = document.commandDispatcher.focusedElement;
             var editor = vimperator.options["editor"];
-            var args = [];
-            args = editor.split(" ");
+            var args = editor.split(" ");
             if (args.length < 1)
             {
                 vimperator.echoerr("no editor specified");
diff --git a/content/hints.js b/content/hints.js
index b0721acb..c33d5700 100644
--- a/content/hints.js
+++ b/content/hints.js
@@ -440,6 +440,8 @@ vimperator.Hints = function () //{{{
             case "O": vimperator.commandline.open(":", "open " + loc, vimperator.modes.EX); break;
             case "t": openHint(vimperator.NEW_TAB); break;
             case "T": vimperator.commandline.open(":", "tabopen " + loc, vimperator.modes.EX); break;
+            case "v": vimperator.commands.viewsource(loc); break;
+            case "V": vimperator.commands.viewsource(loc, true); break;
             case "w": openHint(vimperator.NEW_WINDOW);  break;
             case "W": vimperator.commandline.open(":", "winopen " + loc, vimperator.modes.EX); break;
             case "y": yankHint(false); break;
@@ -491,7 +493,7 @@ vimperator.Hints = function () //{{{
         // TODO: implement framesets
         show: function (mode, minor, filter)
         {
-            if (mode == vimperator.modes.EXTENDED_HINT && !/^[;asoOtTwWyY]$/.test(minor))
+            if (mode == vimperator.modes.EXTENDED_HINT && !/^[;asoOtTvVwWyY]$/.test(minor))
             {
                 vimperator.beep();
                 return;
diff --git a/content/mappings.js b/content/mappings.js
index 906ee68d..00f2b99c 100644
--- a/content/mappings.js
+++ b/content/mappings.js
@@ -567,6 +567,22 @@ vimperator.Mappings = function () //{{{
             help: "You can also use the hints to create the probably fastest file browser on earth."
         }
     ));
+    addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gf"],
+        function () { vimperator.commands.viewsource(); },
+        {
+            shortHelp: "View source",
+            help: "Opens the source code of the current website with the external editor specified " +
+                  "by the 'editor' option. For now the external editor " +
+                  "must be able to download and open files from a remote URL."
+        }
+    ));
+    addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gF"],
+        function () { vimperator.commands.viewsource(null, true); },
+        {
+            shortHelp: "View source in current tab",
+            help: "Opens the source code of the current website with the internal editor."
+        }
+    ));
     addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gh"],
         BrowserHome,
         {
@@ -1244,6 +1260,7 @@ vimperator.Mappings = function () //{{{
                   "
  • t to open its location in a new tab
  • " + "
  • O to open its location in an :open query
  • " + "
  • T to open its location in a :tabopen query
  • " + + "
  • v to view its destination source
  • " + "
  • w to open its destination in a new window
  • " + "
  • W to open its location in a :winopen query
  • " + "
  • y to yank its location
  • " +