1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 20:07:59 +01:00

winopen support

This commit is contained in:
Martin Stubenschrott
2007-08-01 01:17:45 +00:00
parent f12781220b
commit 0d8140cedc
6 changed files with 81 additions and 41 deletions

View File

@@ -1,10 +1,13 @@
<pre> <pre>
2007-07-02: 2007-07-02:
* version 0.5 * 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 <<EOF uses a better multiline input widget now * :javascript <<EOF uses a better multiline input widget now
* new :map, :noremap, :mapclear and :unmap commands * new :map, :noremap, :mapclear and :unmap commands
* :saveas finally works (by calmar) * :saveas finally works (by calmar)
* Shift-insert pastes the selection content in text fields now * Shift-insert pastes the X11 selection content in text fields now
* Changed "|" to ", " as a url seperator in :open * Changed "|" to ", " as a url seperator in :open
* Ctrl-^ mapping for selecting the alternate tab/buffer * Ctrl-^ mapping for selecting the alternate tab/buffer
* QuickMarks support (new commands :qmarks/:qmarkadd/:qmarkdel and * QuickMarks support (new commands :qmarks/:qmarkadd/:qmarkdel and

View File

@@ -747,11 +747,11 @@ function QuickMarks() //{{{
} }
} }
this.jumpTo = function(mark, newtab) this.jumpTo = function(mark, where)
{ {
var url = marks[mark]; var url = marks[mark];
if (url) if (url)
vimperator.open(url, newtab ? vimperator.NEW_TAB : vimperator.CURRENT_TAB); vimperator.open(url, where);
else else
vimperator.echoerr("E20: QuickMark not set"); vimperator.echoerr("E20: QuickMark not set");
} }

View File

@@ -627,8 +627,7 @@ function Commands() //{{{
}, },
{ {
usage: ["marks {arg}"], usage: ["marks {arg}"],
short_help: "Show all location marks of current web page", short_help: "Show all location marks of current web page"
help: "Not implemented yet."
} }
)); ));
// TODO: remove duplication in :map // TODO: remove duplication in :map
@@ -699,7 +698,7 @@ function Commands() //{{{
} }
}, },
{ {
usage: ["o[pen] [url] [| url]"], usage: ["o[pen] [url] [, url]"],
short_help: "Open one or more URLs in the current tab", short_help: "Open one or more URLs in the current tab",
help: "Multiple URLs can be separated with \", \". Note that the space after the comma is required.<br/>" + help: "Multiple URLs can be separated with \", \". Note that the space after the comma is required.<br/>" +
"Each token is analyzed and in this order:<br/>" + "Each token is analyzed and in this order:<br/>" +
@@ -824,7 +823,8 @@ function Commands() //{{{
var oper = matches[5]; var oper = matches[5];
var val = matches[6]; if (val === undefined) val = ""; 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) if (reset)
{ {
option.value = option.default_value; option.value = option.default_value;
@@ -836,7 +836,6 @@ function Commands() //{{{
vimperator.echo((option.value ? " " : "no") + option.name); vimperator.echo((option.value ? " " : "no") + option.name);
else else
vimperator.echo(" " + option.name + "=" + option.value); vimperator.echo(" " + option.name + "=" + option.value);
//vimperator.echo(" " + option.name + "=" + vimperator.options[option.name]);
} }
// write access // write access
else else
@@ -968,13 +967,17 @@ function Commands() //{{{
addDefaultCommand(new Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"], addDefaultCommand(new Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
function(args, special) 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) if (args.length > 0)
vimperator.open(args, special ? vimperator.NEW_BACKGROUND_TAB : vimperator.NEW_TAB); vimperator.open(args, where);
else 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", short_help: "Open one or more URLs in a new tab",
help: "Like <code class=\"command\">:open</code> but open URLs in a new tab.<br/>" + help: "Like <code class=\"command\">:open</code> but open URLs in a new tab.<br/>" +
"If used with <code class=\"command\">!</code>, the 'tabopen' value of the <code class=\"option\">'activate'</code> option is negated.", "If used with <code class=\"command\">!</code>, the 'tabopen' value of the <code class=\"option\">'activate'</code> option is negated.",
@@ -1083,11 +1086,11 @@ function Commands() //{{{
} }
)); ));
addDefaultCommand(new Command(["wino[pen]", "w[open]", "wine[dit]"], 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]"], usage: ["wino[pen] [url] [, url]"],
short_help: "Open a URL in a new window", short_help: "Open one or more URLs in a new window",
help: "Not implemented yet." help: "NOTE: Multiple windows are not really support by vimperator, use at your own risk!"
} }
)); ));
addDefaultCommand(new Command(["wqa[ll]", "wq", "xa[ll]"], addDefaultCommand(new Command(["wqa[ll]", "wq", "xa[ll]"],

View File

@@ -376,26 +376,38 @@ function Mappings() //{{{
} }
)); ));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["go"], 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}"], usage: ["go{a-zA-Z0-9}"],
help: "Open any QuickMark in the current buffer. You can mark any URLs with <code class=\"mapping\">M{a-zA-Z0-9}</code>. " + help: "Open any QuickMark in the current tab. You can mark any URLs with <code class=\"mapping\">M{a-zA-Z0-9}</code>. " +
"These QuickMarks are persistent across browser session.", "These QuickMarks are persistent across browser session.",
flags: Mappings.flags.ARGUMENT flags: Mappings.flags.ARGUMENT
} }
)); ));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gn"], 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}"], usage: ["gn{a-zA-Z0-9}"],
help: "Mnemonic: Go in a new buffer. <code class=\"mapping\">gt</code> would make more sense but is already taken.", help: "Works like <code class=\"mapping\">go{a-zA-Z0-9}</code> but opens the QuickMark in a new tab. " +
"Whether the new tab is activated or not depends on the <code class=\"option\">'activate'</code> option.<br/>" +
"Mnemonic: Go in a new tab. <code class=\"mapping\">gt</code> would make more sense but is already taken.",
flags: Mappings.flags.ARGUMENT flags: Mappings.flags.ARGUMENT
} }
)); ));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gP"], 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", short_help: "Open (put) a URL based on the current clipboard contents in a new buffer",
help: "Works like <code class=\"mapping\">P</code>, but inverts the <code class=\"option\">'activate'</code> option." help: "Works like <code class=\"mapping\">P</code>, but inverts the <code class=\"option\">'activate'</code> option."
@@ -485,7 +497,12 @@ function Mappings() //{{{
} }
)); ));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["P"], 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", short_help: "Open (put) a URL based on the current clipboard contents in a new buffer",
help: "Works like <code class=\"mapping\">p</code>, but opens a new tab.<br/>" + help: "Works like <code class=\"mapping\">p</code>, but opens a new tab.<br/>" +

View File

@@ -305,7 +305,12 @@ function Options() //{{{
addOption(new Option(["activate"], "stringlist", addOption(new Option(["activate"], "stringlist",
{ {
short_help: "Define when tabs are automatically activated", short_help: "Define when tabs are automatically activated",
help: "Not implemented yet", help: "Available items:<br/>" +
"<table>" +
"<tr><td><b>quickmark</b>:</td><td><code class=\"mapping\">go</code> and <code class=\"mapping\">gn</code> mappings</td>" +
"<tr><td><b>tabopen</b>: </td><td><code class=\"command\">:tabopen[!]</code> command</td>" +
"<tr><td><b>paste</b>: </td><td><code class=\"mapping\">P</code> and <code class=\"mapping\">gP</code> mappings</td>" +
"</table>",
default_value: "quickmark,tabopen,paste" default_value: "quickmark,tabopen,paste"
} }
)); ));
@@ -441,7 +446,7 @@ function Options() //{{{
"<li><b>0</b>: Never show tab bar</li>" + "<li><b>0</b>: Never show tab bar</li>" +
"<li><b>1</b>: Show tab bar only if more than one tab is open</li>" + "<li><b>1</b>: Show tab bar only if more than one tab is open</li>" +
"<li><b>2</b>: Always show tab bar</li></ul>" + "<li><b>2</b>: Always show tab bar</li></ul>" +
"Not implemented yet.", "NOTE: Not fully implemented yet and buggy with stal=0",
setter: function(value) { Options.setPref("showtabline", value); setShowTabline(value); }, setter: function(value) { Options.setPref("showtabline", value); setShowTabline(value); },
default_value: 2, default_value: 2,
validator: function (value) { if (value>=0 && value <=2) return true; else return false; } validator: function (value) { if (value>=0 && value <=2) return true; else return false; }

View File

@@ -115,6 +115,7 @@ const vimperator = (function() //{{{
CURRENT_TAB: 1, CURRENT_TAB: 1,
NEW_TAB: 2, NEW_TAB: 2,
NEW_BACKGROUND_TAB: 3, NEW_BACKGROUND_TAB: 3,
NEW_WINDOW: 4,
//}, //},
// ###VERSION### and ###DATE### are replaced by the Makefile // ###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 url = typeof urls[0] == "string" ? urls[0] : urls[0][0];
var postdata = typeof urls[0] == "string" ? null : urls[0][1]; var postdata = typeof urls[0] == "string" ? null : urls[0][1];
//alert(postdata); var whichwindow = window;
// decide where to load the first tab // decide where to load the first tab
if (where == vimperator.CURRENT_TAB) switch (where)
/*getBrowser().*/loadURI(url, null, postdata);
else if (where == vimperator.NEW_TAB)
{ {
var firsttab = getBrowser().addTab(url, null, null, postdata); case vimperator.CURRENT_TAB:
getBrowser().selectedTab = firsttab; window.loadURI(url, null, postdata); // getBrowser.loadURI() did not work with postdata in my quick experiments --mst
} break;
else if (where == vimperator.NEW_BACKGROUND_TAB)
{ case vimperator.NEW_TAB:
getBrowser().addTab(url, null, null, postdata); var firsttab = getBrowser().addTab(url, null, null, postdata);
} getBrowser().selectedTab = firsttab;
else break;
{
vimperator.echoerr("Exxx: Invalid where directive in vimperator.open(...)"); case vimperator.NEW_BACKGROUND_TAB:
return false; 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 // 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]; url = typeof urls[i] == "string" ? urls[i] : urls[i][0];
postdata = typeof urls[i] == "string" ? null : urls[i][1]; 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 // TODO: register callbacks