diff --git a/ChangeLog b/ChangeLog index a2a498fa..657b43c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,13 @@
 2007-07-02:
 	* version 0.5
+	* :winopen support (multiple windows still very very experimental)
+	* 'activate' option implemented
+	* search enginges which use POST instead of GET work now
 	* :javascript <" +
                   "Each token is analyzed and in this order:
" + @@ -824,7 +823,8 @@ function Commands() //{{{ var oper = matches[5]; var val = matches[6]; if (val === undefined) val = ""; - // reset a variable to its default value. + // reset a variable to its default value + // TODO: remove the value from about:config instea of setting it to the current default value if (reset) { option.value = option.default_value; @@ -836,7 +836,6 @@ function Commands() //{{{ vimperator.echo((option.value ? " " : "no") + option.name); else vimperator.echo(" " + option.name + "=" + option.value); - //vimperator.echo(" " + option.name + "=" + vimperator.options[option.name]); } // write access else @@ -968,13 +967,17 @@ function Commands() //{{{ addDefaultCommand(new Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"], function(args, special) { + var where = special ? vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB; + if (vimperator.options["activate"].search(/\bquickmark\b/) > -1) + where = special ? vimperator.NEW_BACKGROUND_TAB : vimperator.NEW_TAB; + if (args.length > 0) - vimperator.open(args, special ? vimperator.NEW_BACKGROUND_TAB : vimperator.NEW_TAB); + vimperator.open(args, where); else - vimperator.open("about:blank", vimperator.NEW_TAB); + vimperator.open("about:blank", where); }, { - usage: ["tabopen [url] [| url]"], + usage: ["tabopen [url] [, url]"], short_help: "Open one or more URLs in a new tab", help: "Like :open but open URLs in a new tab.
" + "If used with !, the 'tabopen' value of the 'activate' option is negated.", @@ -1083,11 +1086,11 @@ function Commands() //{{{ } )); addDefaultCommand(new Command(["wino[pen]", "w[open]", "wine[dit]"], - function() { vimperator.echo("winopen not implemented yet"); }, + function(args) { vimperator.open(args, vimperator.NEW_WINDOW); }, { - usage: ["wino[pen] [url] [| url]"], - short_help: "Open a URL in a new window", - help: "Not implemented yet." + usage: ["wino[pen] [url] [, url]"], + short_help: "Open one or more URLs in a new window", + help: "NOTE: Multiple windows are not really support by vimperator, use at your own risk!" } )); addDefaultCommand(new Command(["wqa[ll]", "wq", "xa[ll]"], diff --git a/chrome/content/vimperator/mappings.js b/chrome/content/vimperator/mappings.js index 7afda9e9..e0f9512c 100644 --- a/chrome/content/vimperator/mappings.js +++ b/chrome/content/vimperator/mappings.js @@ -376,26 +376,38 @@ function Mappings() //{{{ } )); addDefaultMap(new Map(vimperator.modes.NORMAL, ["go"], - function(mark) { vimperator.quickmarks.jumpTo(mark, false) }, + function(mark) { vimperator.quickmarks.jumpTo(mark, vimperator.CURRENT_TAB) }, { - short_help: "Jump to a QuickMark in the current buffer", + short_help: "Jump to a QuickMark in the current tab", usage: ["go{a-zA-Z0-9}"], - help: "Open any QuickMark in the current buffer. You can mark any URLs with M{a-zA-Z0-9}. " + + help: "Open any QuickMark in the current tab. You can mark any URLs with M{a-zA-Z0-9}. " + "These QuickMarks are persistent across browser session.", flags: Mappings.flags.ARGUMENT } )); addDefaultMap(new Map(vimperator.modes.NORMAL, ["gn"], - function(mark) { vimperator.quickmarks.jumpTo(mark, true) }, + function(mark) { - short_help: "Jump to a QuickMark in a new buffer", + vimperator.quickmarks.jumpTo(mark, + vimperator.options["activate"].search(/\bquickmark\b/) > -1 ? + vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB); + }, + { + short_help: "Jump to a QuickMark in a new tab", usage: ["gn{a-zA-Z0-9}"], - help: "Mnemonic: Go in a new buffer. gt would make more sense but is already taken.", + help: "Works like go{a-zA-Z0-9} but opens the QuickMark in a new tab. " + + "Whether the new tab is activated or not depends on the 'activate' option.
" + + "Mnemonic: Go in a new tab. gt would make more sense but is already taken.", flags: Mappings.flags.ARGUMENT } )); addDefaultMap(new Map(vimperator.modes.NORMAL, ["gP"], - function(count) { vimperator.open(readFromClipboard(), vimperator.NEW_BACKGROUND_TAB); }, + function(count) + { + vimperator.open(readFromClipboard(), + vimperator.options["activate"].search(/\bpaste\b/) > -1 ? + vimperator.NEW_BACKGROUND_TAB : vimperator.NEW_TAB); + }, { short_help: "Open (put) a URL based on the current clipboard contents in a new buffer", help: "Works like P, but inverts the 'activate' option." @@ -485,7 +497,12 @@ function Mappings() //{{{ } )); addDefaultMap(new Map(vimperator.modes.NORMAL, ["P"], - function(count) { vimperator.open(readFromClipboard(), vimperator.NEW_TAB); }, + function(count) + { + vimperator.open(readFromClipboard(), + vimperator.options["activate"].search(/\bpaste\b/) > -1 ? + vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB); + }, { short_help: "Open (put) a URL based on the current clipboard contents in a new buffer", help: "Works like p, but opens a new tab.
" + diff --git a/chrome/content/vimperator/options.js b/chrome/content/vimperator/options.js index ba158135..f991dec3 100644 --- a/chrome/content/vimperator/options.js +++ b/chrome/content/vimperator/options.js @@ -305,7 +305,12 @@ function Options() //{{{ addOption(new Option(["activate"], "stringlist", { short_help: "Define when tabs are automatically activated", - help: "Not implemented yet", + help: "Available items:
" + + "" + + "" + + "" + + "" + + "
quickmark:go and gn mappings
tabopen: :tabopen[!] command
paste: P and gP mappings
", default_value: "quickmark,tabopen,paste" } )); @@ -441,7 +446,7 @@ function Options() //{{{ "
  • 0: Never show tab bar
  • " + "
  • 1: Show tab bar only if more than one tab is open
  • " + "
  • 2: Always show tab bar
  • " + - "Not implemented yet.", + "NOTE: Not fully implemented yet and buggy with stal=0", setter: function(value) { Options.setPref("showtabline", value); setShowTabline(value); }, default_value: 2, validator: function (value) { if (value>=0 && value <=2) return true; else return false; } diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index f89f4cc1..e9a2f2bb 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -115,6 +115,7 @@ const vimperator = (function() //{{{ CURRENT_TAB: 1, NEW_TAB: 2, NEW_BACKGROUND_TAB: 3, + NEW_WINDOW: 4, //}, // ###VERSION### and ###DATE### are replaced by the Makefile @@ -274,24 +275,35 @@ const vimperator = (function() //{{{ var url = typeof urls[0] == "string" ? urls[0] : urls[0][0]; var postdata = typeof urls[0] == "string" ? null : urls[0][1]; - //alert(postdata); + var whichwindow = window; // decide where to load the first tab - if (where == vimperator.CURRENT_TAB) - /*getBrowser().*/loadURI(url, null, postdata); - else if (where == vimperator.NEW_TAB) + switch (where) { - var firsttab = getBrowser().addTab(url, null, null, postdata); - getBrowser().selectedTab = firsttab; - } - else if (where == vimperator.NEW_BACKGROUND_TAB) - { - getBrowser().addTab(url, null, null, postdata); - } - else - { - vimperator.echoerr("Exxx: Invalid where directive in vimperator.open(...)"); - return false; + case vimperator.CURRENT_TAB: + window.loadURI(url, null, postdata); // getBrowser.loadURI() did not work with postdata in my quick experiments --mst + break; + + case vimperator.NEW_TAB: + var firsttab = getBrowser().addTab(url, null, null, postdata); + getBrowser().selectedTab = firsttab; + break; + + case vimperator.NEW_BACKGROUND_TAB: + getBrowser().addTab(url, null, null, postdata); + break; + + case vimperator.NEW_WINDOW: + window.open(); + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + whichwindow = wm.getMostRecentWindow("navigator:browser"); + whichwindow.loadURI(url, null, postdata) + break; + + default: + vimperator.echoerr("Exxx: Invalid 'where' directive in vimperator.open(...)"); + return false; } // all other URLs are always loaded in background @@ -299,7 +311,7 @@ const vimperator = (function() //{{{ { url = typeof urls[i] == "string" ? urls[i] : urls[i][0]; postdata = typeof urls[i] == "string" ? null : urls[i][1]; - getBrowser().addTab(url, null, null, postdata); + whichwindow.getBrowser().addTab(url, null, null, postdata); } // TODO: register callbacks