mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 00:27:57 +01:00
begin moving commands from commands.js to where they belong
This commit is contained in:
@@ -108,6 +108,7 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL];
|
var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL];
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["a"],
|
vimperator.mappings.add(modes, ["a"],
|
||||||
@@ -124,6 +125,71 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
"Toggle bookmarked state of current URL",
|
"Toggle bookmarked state of current URL",
|
||||||
function () { vimperator.bookmarks.toggle(vimperator.buffer.URL); });
|
function () { vimperator.bookmarks.toggle(vimperator.buffer.URL); });
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
vimperator.commands.add(["bma[rk]"],
|
||||||
|
"Add a bookmark",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
var res = vimperator.commands.parseArgs(args, this.args);
|
||||||
|
if (!res)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var url = res.args.length == 0 ? vimperator.buffer.URL : res.args[0];
|
||||||
|
var title = vimperator.commands.getOption(res.opts, "-title", res.args.length == 0 ? vimperator.buffer.title : null);
|
||||||
|
if (!title)
|
||||||
|
title = url;
|
||||||
|
var keyword = vimperator.commands.getOption(res.opts, "-keyword", null);
|
||||||
|
var tags = vimperator.commands.getOption(res.opts, "-tags", []);
|
||||||
|
|
||||||
|
if (vimperator.bookmarks.add(false, title, url, keyword, tags))
|
||||||
|
{
|
||||||
|
var extra = "";
|
||||||
|
if (title != url)
|
||||||
|
extra = " (" + title + ")";
|
||||||
|
vimperator.echo("Added bookmark: " + url + extra, vimperator.commandline.FORCE_SINGLELINE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vimperator.echoerr("Exxx: Could not add bookmark `" + title + "'", vimperator.commandline.FORCE_SINGLELINE);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: [[["-title", "-t"], vimperator.commands.OPTION_STRING],
|
||||||
|
[["-tags", "-T"], vimperator.commands.OPTION_LIST],
|
||||||
|
[["-keyword", "-k"], vimperator.commands.OPTION_STRING, function (arg) { return /\w/.test(arg); }]]
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["bmarks"],
|
||||||
|
"List or open multiple bookmarks",
|
||||||
|
function (args, special)
|
||||||
|
{
|
||||||
|
var res = vimperator.commands.parseArgs(args, this.args);
|
||||||
|
if (!res)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var tags = vimperator.commands.getOption(res.opts, "-tags", []);
|
||||||
|
vimperator.bookmarks.list(res.args.join(" "), tags, special);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
completer: function (filter) { return [0, vimperator.bookmarks.get(filter)]; },
|
||||||
|
args: [[["-tags", "-T"], vimperator.commands.OPTION_LIST]]
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["delbm[arks]"],
|
||||||
|
"Delete a bookmark",
|
||||||
|
function (args, special)
|
||||||
|
{
|
||||||
|
var url = args;
|
||||||
|
if (!url)
|
||||||
|
url = vimperator.buffer.URL;
|
||||||
|
|
||||||
|
var deletedCount = vimperator.bookmarks.remove(url);
|
||||||
|
vimperator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", vimperator.commandline.FORCE_SINGLELINE);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
completer: function (filter) { return [0, vimperator.bookmarks.get(filter)]; }
|
||||||
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
@@ -460,6 +526,7 @@ vimperator.History = function () //{{{
|
|||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL];
|
var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL];
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
vimperator.mappings.add(modes,
|
||||||
@@ -483,6 +550,94 @@ vimperator.History = function () //{{{
|
|||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: vimperator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
vimperator.commands.add(["ba[ck]"],
|
||||||
|
"Go back in the browser history",
|
||||||
|
function (args, special, count)
|
||||||
|
{
|
||||||
|
if (special)
|
||||||
|
vimperator.history.goToStart();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (args)
|
||||||
|
{
|
||||||
|
var sh = getWebNavigation().sessionHistory;
|
||||||
|
for (var i = sh.index - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (sh.getEntryAtIndex(i, false).URI.spec == args)
|
||||||
|
{
|
||||||
|
getWebNavigation().gotoIndex(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vimperator.history.stepTo(count > 0 ? -1 * count : -1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
completer: function (filter)
|
||||||
|
{
|
||||||
|
var sh = getWebNavigation().sessionHistory;
|
||||||
|
var completions = [];
|
||||||
|
for (var i = sh.index - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var entry = sh.getEntryAtIndex(i, false);
|
||||||
|
var url = entry.URI.spec;
|
||||||
|
var title = entry.title;
|
||||||
|
if (vimperator.completion.match([url, title], filter, false))
|
||||||
|
completions.push([url, title]);
|
||||||
|
}
|
||||||
|
return [0, completions];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["fo[rward]", "fw"],
|
||||||
|
"Go forward in the browser history",
|
||||||
|
function (args, special, count)
|
||||||
|
{
|
||||||
|
if (special)
|
||||||
|
vimperator.history.goToEnd();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (args)
|
||||||
|
{
|
||||||
|
var sh = getWebNavigation().sessionHistory;
|
||||||
|
for (var i = sh.index + 1; i < sh.count; i++)
|
||||||
|
{
|
||||||
|
if (sh.getEntryAtIndex(i, false).URI.spec == args)
|
||||||
|
{
|
||||||
|
getWebNavigation().gotoIndex(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vimperator.history.stepTo(count > 0 ? count : 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
completer: function (filter)
|
||||||
|
{
|
||||||
|
var sh = getWebNavigation().sessionHistory;
|
||||||
|
var completions = [];
|
||||||
|
for (var i = sh.index + 1; i < sh.count; i++)
|
||||||
|
{
|
||||||
|
var entry = sh.getEntryAtIndex(i, false);
|
||||||
|
var url = entry.URI.spec;
|
||||||
|
var title = entry.title;
|
||||||
|
if (vimperator.completion.match([url, title], filter, false))
|
||||||
|
completions.push([url, title]);
|
||||||
|
}
|
||||||
|
return [0, completions];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["hist[ory]", "hs"],
|
||||||
|
"Show recently visited URLs",
|
||||||
|
function (args, special) { vimperator.history.list(args, special); },
|
||||||
|
{ completer: function (filter) { return [0, vimperator.history.get(filter)]; } });
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
@@ -652,6 +807,65 @@ vimperator.QuickMarks = function () //{{{
|
|||||||
{ flags: vimperator.Mappings.flags.ARGUMENT });
|
{ flags: vimperator.Mappings.flags.ARGUMENT });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
vimperator.commands.add(["delqm[arks]"],
|
||||||
|
"Delete the specified QuickMarks",
|
||||||
|
function (args, special)
|
||||||
|
{
|
||||||
|
// TODO: finish arg parsing - we really need a proper way to do this. :)
|
||||||
|
if (!special && !args)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E471: Argument required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (special && args)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E474: Invalid argument");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (special)
|
||||||
|
vimperator.quickmarks.removeAll();
|
||||||
|
else
|
||||||
|
vimperator.quickmarks.remove(args);
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["qma[rk]"],
|
||||||
|
"Mark a URL with a letter for quick access",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
if (!args)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E471: Argument required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var matches = args.match(/^([a-zA-Z0-9])(?:\s+(.+))?$/);
|
||||||
|
if (!matches)
|
||||||
|
vimperator.echoerr("E488: Trailing characters");
|
||||||
|
else if (!matches[2])
|
||||||
|
vimperator.quickmarks.add(matches[1], vimperator.buffer.URL);
|
||||||
|
else
|
||||||
|
vimperator.quickmarks.add(matches[1], matches[2]);
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["qmarks"],
|
||||||
|
"Show all QuickMarks",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
// ignore invalid mark characters unless there are no valid mark chars
|
||||||
|
if (args && !/[a-zA-Z0-9]/.test(args))
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E283: No QuickMarks matching \"" + args + "\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var filter = args.replace(/[^a-zA-Z0-9]/g, "");
|
||||||
|
vimperator.quickmarks.list(filter);
|
||||||
|
});
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
|||||||
@@ -408,20 +408,109 @@ vimperator.Buffer = function () //{{{
|
|||||||
function (count) { vimperator.buffer.showPageInfo(true); });
|
function (count) { vimperator.buffer.showPageInfo(true); });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.addUserCommand(new vimperator.Command(["test"],
|
vimperator.commands.add(["ha[rdcopy]"],
|
||||||
|
"Print current document",
|
||||||
|
function () { getBrowser().contentWindow.print(); });
|
||||||
|
|
||||||
|
vimperator.commands.add(["pa[geinfo]"],
|
||||||
|
"Show various page information",
|
||||||
|
function () { vimperator.buffer.showPageInfo(true); });
|
||||||
|
|
||||||
|
vimperator.commands.add(["re[load]"],
|
||||||
|
"Reload current page",
|
||||||
|
function (args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); });
|
||||||
|
|
||||||
|
vimperator.commands.add(["sav[eas]", "w[rite]"],
|
||||||
|
"Save current document to disk",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
alert(args)
|
var file = vimperator.io.getFile(args || "");
|
||||||
},
|
// we always want to save that link relative to the current working directory
|
||||||
|
vimperator.options.setPref("browser.download.lastDir", vimperator.io.getCurrentDirectory());
|
||||||
|
//if (args)
|
||||||
|
//{
|
||||||
|
// saveURL(vimperator.buffer.URL, args, null, true, special, // special == skipPrompt
|
||||||
|
// makeURI(vimperator.buffer.URL, content.document.characterSet));
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
saveDocument(window.content.document, special);
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["st[op]"],
|
||||||
|
"Stop loading",
|
||||||
|
function() { BrowserStop(); });
|
||||||
|
|
||||||
|
vimperator.commands.add(["vie[wsource]"],
|
||||||
|
"View source code of current document",
|
||||||
|
function (args, special)
|
||||||
{
|
{
|
||||||
shortHelp: "Test command"
|
var url = args || vimperator.buffer.URL;
|
||||||
}
|
if (special) // external editor
|
||||||
));
|
{
|
||||||
|
// 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.io.run, [prog, args, true]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vimperator.open("view-source:" + url)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["zo[om]"],
|
||||||
|
"Set zoom value of current web page",
|
||||||
|
function (args, special)
|
||||||
|
{
|
||||||
|
var level;
|
||||||
|
|
||||||
|
if (!args)
|
||||||
|
{
|
||||||
|
level = 100;
|
||||||
|
}
|
||||||
|
else if (/^\d+$/.test(args))
|
||||||
|
{
|
||||||
|
level = parseInt(args, 10);
|
||||||
|
}
|
||||||
|
else if (/^[+-]\d+$/.test(args))
|
||||||
|
{
|
||||||
|
if (special)
|
||||||
|
level = vimperator.buffer.fullZoom + parseInt(args, 10);
|
||||||
|
else
|
||||||
|
level = vimperator.buffer.textZoom + parseInt(args, 10);
|
||||||
|
|
||||||
|
// relative args shouldn't take us out of range
|
||||||
|
if (level < 1)
|
||||||
|
level = 1;
|
||||||
|
if (level > 2000)
|
||||||
|
level = 2000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E488: Trailing characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (special)
|
||||||
|
vimperator.buffer.fullZoom = level;
|
||||||
|
else
|
||||||
|
vimperator.buffer.textZoom = level;
|
||||||
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
@@ -1340,6 +1429,7 @@ vimperator.Marks = function () //{{{
|
|||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL];
|
var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL];
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
vimperator.mappings.add(modes,
|
||||||
@@ -1362,6 +1452,92 @@ vimperator.Marks = function () //{{{
|
|||||||
{ flags: vimperator.Mappings.flags.ARGUMENT });
|
{ flags: vimperator.Mappings.flags.ARGUMENT });
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
vimperator.commands.add(["delm[arks]"],
|
||||||
|
"Delete the specified marks",
|
||||||
|
function (args, special)
|
||||||
|
{
|
||||||
|
if (!special && !args)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E471: Argument required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (special && args)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E474: Invalid argument");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var matches;
|
||||||
|
if (matches = args.match(/(?:(?:^|[^a-zA-Z0-9])-|-(?:$|[^a-zA-Z0-9])|[^a-zA-Z0-9 -]).*/))
|
||||||
|
{
|
||||||
|
// NOTE: this currently differs from Vim's behavior which
|
||||||
|
// deletes any valid marks in the arg list, up to the first
|
||||||
|
// invalid arg, as well as giving the error message.
|
||||||
|
vimperator.echoerr("E475: Invalid argument: " + matches[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// check for illegal ranges - only allow a-z A-Z 0-9
|
||||||
|
if (matches = args.match(/[a-zA-Z0-9]-[a-zA-Z0-9]/g))
|
||||||
|
{
|
||||||
|
for (var i = 0; i < matches.length; i++)
|
||||||
|
{
|
||||||
|
var start = matches[i][0];
|
||||||
|
var end = matches[i][2];
|
||||||
|
if (/[a-z]/.test(start) != /[a-z]/.test(end) ||
|
||||||
|
/[A-Z]/.test(start) != /[A-Z]/.test(end) ||
|
||||||
|
/[0-9]/.test(start) != /[0-9]/.test(end) ||
|
||||||
|
start > end)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E475: Invalid argument: " + args.match(new RegExp(matches[i] + ".*"))[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vimperator.marks.remove(args, special);
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["ma[rk]"],
|
||||||
|
"Mark current location within the web page",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
if (!args)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E471: Argument required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E488: Trailing characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/[a-zA-Z]/.test(args))
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E191: Argument must be a letter or forward/backward quote");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vimperator.marks.add(args);
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["marks"],
|
||||||
|
"Show all location marks of current web page",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
// ignore invalid mark characters unless there are no valid mark chars
|
||||||
|
if (args && !/[a-zA-Z]/.test(args))
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E283: No marks matching \"" + args + "\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var filter = args.replace(/[^a-zA-Z]/g, "");
|
||||||
|
vimperator.marks.list(filter);
|
||||||
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|||||||
1405
content/commands.js
1405
content/commands.js
File diff suppressed because it is too large
Load Diff
@@ -26,12 +26,6 @@ the provisions above, a recipient may use your version of this file under
|
|||||||
the terms of any one of the MPL, the GPL or the LGPL.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
/**
|
|
||||||
* provides functions for working with tabs
|
|
||||||
* XXX: ATTENTION: We are planning to move to the FUEL API once we switch to
|
|
||||||
* Firefox 3.0, then this class should go away and their tab methods should be used
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
vimperator.Tabs = function () //{{{
|
vimperator.Tabs = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -139,6 +133,7 @@ vimperator.Tabs = function () //{{{
|
|||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["b"],
|
vimperator.mappings.add([vimperator.modes.NORMAL], ["b"],
|
||||||
"Open a prompt to switch buffers",
|
"Open a prompt to switch buffers",
|
||||||
function () { vimperator.commandline.open(":", "buffer! ", vimperator.modes.EX); });
|
function () { vimperator.commandline.open(":", "buffer! ", vimperator.modes.EX); });
|
||||||
@@ -213,9 +208,11 @@ vimperator.Tabs = function () //{{{
|
|||||||
vimperator.tabs.select(index);
|
vimperator.tabs.select(index);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
|
vimperator.commands.add(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
|
||||||
"Delete current buffer",
|
"Delete current buffer",
|
||||||
function (args, special, count)
|
function (args, special, count)
|
||||||
@@ -394,7 +391,6 @@ vimperator.Tabs = function () //{{{
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|||||||
@@ -238,6 +238,36 @@ vimperator.CommandLine = function () //{{{
|
|||||||
multilineInputWidget.setAttribute("rows", lines.toString());
|
multilineInputWidget.setAttribute("rows", lines.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used for the :echo[err] commands
|
||||||
|
function echoArgumentToString(arg, useColor)
|
||||||
|
{
|
||||||
|
if (!arg)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// TODO: move to vimperator.eval()?
|
||||||
|
// with (vimperator) means, vimperator is the default namespace "inside" eval
|
||||||
|
arg = eval("with(vimperator){" + arg + "}");
|
||||||
|
}
|
||||||
|
catch (e)
|
||||||
|
{
|
||||||
|
vimperator.echoerr(e.toString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof arg === "object")
|
||||||
|
arg = vimperator.util.objectToString(arg, useColor);
|
||||||
|
else if (typeof arg === "function")
|
||||||
|
arg = vimperator.util.escapeHTML(arg.toString());
|
||||||
|
else if (typeof arg === "number" || typeof arg === "boolean")
|
||||||
|
arg = "" + arg;
|
||||||
|
else if (typeof arg === "undefined")
|
||||||
|
arg = "undefined";
|
||||||
|
|
||||||
|
return arg;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
@@ -287,6 +317,29 @@ vimperator.CommandLine = function () //{{{
|
|||||||
["<C-]>", "<C-5>"], "Expand command line abbreviation",
|
["<C-]>", "<C-5>"], "Expand command line abbreviation",
|
||||||
function () { vimperator.editor.expandAbbreviation("c"); });
|
function () { vimperator.editor.expandAbbreviation("c"); });
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
vimperator.commands.add(["ec[ho]"],
|
||||||
|
"Display a string at the bottom of the window",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
var res = echoArgumentToString(args, true);
|
||||||
|
if (res != null)
|
||||||
|
vimperator.echo(res);
|
||||||
|
},
|
||||||
|
{ completer: function (filter) { return vimperator.completion.javascript(filter); } });
|
||||||
|
|
||||||
|
vimperator.commands.add(["echoe[rr]"],
|
||||||
|
"Display an error string at the bottom of the window",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
var res = echoArgumentToString(args, false);
|
||||||
|
if (res != null)
|
||||||
|
vimperator.echoerr(res);
|
||||||
|
},
|
||||||
|
{ completer: function (filter) { return vimperator.completion.javascript(filter); } });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
|
|||||||
@@ -114,6 +114,11 @@ const vimperator = (function () //{{{
|
|||||||
function () { vimperator.quit(true); });
|
function () { vimperator.quit(true); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addCommands()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// initially hide all GUI, it is later restored unless the user has :set go= or something
|
// initially hide all GUI, it is later restored unless the user has :set go= or something
|
||||||
// similar in his config
|
// similar in his config
|
||||||
function hideGUI()
|
function hideGUI()
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ vimperator.config = {
|
|||||||
hostApplication: "Firefox",
|
hostApplication: "Firefox",
|
||||||
|
|
||||||
/*** optional options, there are checked for existance and a fallback provided ***/
|
/*** optional options, there are checked for existance and a fallback provided ***/
|
||||||
features: ["bookmarks", "history", "marks", "quickmarks", "hints", "tabs"],
|
features: ["bookmarks", "history", "marks", "quickmarks", "hints", "tabs", "windows"],
|
||||||
dialogs: [],
|
dialogs: [],
|
||||||
guioptions: { m: ["toolbar-menubar"], T: ["nav-bar"], b: ["PersonalToolbar"] },
|
guioptions: { m: ["toolbar-menubar"], T: ["nav-bar"], b: ["PersonalToolbar"] },
|
||||||
|
|
||||||
@@ -61,6 +61,10 @@ vimperator.config = {
|
|||||||
vimperator.open(matches[1] + newNum + matches[3]);
|
vimperator.open(matches[1] + newNum + matches[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.NORMAL],
|
vimperator.mappings.add([vimperator.modes.NORMAL],
|
||||||
["y"], "Yank current location to the clipboard",
|
["y"], "Yank current location to the clipboard",
|
||||||
function () { vimperator.copyToClipboard(vimperator.buffer.URL, true); });
|
function () { vimperator.copyToClipboard(vimperator.buffer.URL, true); });
|
||||||
@@ -167,6 +171,69 @@ vimperator.config = {
|
|||||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["<C-l>"],
|
vimperator.mappings.add([vimperator.modes.NORMAL], ["<C-l>"],
|
||||||
"Redraw the screen",
|
"Redraw the screen",
|
||||||
function () { vimperator.commands.redraw(); });
|
function () { vimperator.commands.redraw(); });
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
vimperator.commands.add(["downl[oads]", "dl"],
|
||||||
|
"Show progress of current downloads",
|
||||||
|
function () { vimperator.open("chrome://mozapps/content/downloads/downloads.xul", vimperator.NEW_TAB); });
|
||||||
|
|
||||||
|
vimperator.commands.add(["redr[aw]"],
|
||||||
|
"Redraw the screen",
|
||||||
|
function ()
|
||||||
|
{
|
||||||
|
var wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||||
|
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||||
|
wu.redraw();
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: move sidebar commands to ui.js?
|
||||||
|
vimperator.commands.add(["sbcl[ose]"],
|
||||||
|
"Close the sidebar window",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
if (args)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E488: Trailing characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.getElementById("sidebar-box").hidden == false)
|
||||||
|
toggleSidebar();
|
||||||
|
});
|
||||||
|
|
||||||
|
vimperator.commands.add(["sideb[ar]", "sb[ar]", "sbope[n]"],
|
||||||
|
"Open the sidebar window",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
if (!args)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E471: Argument required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// do nothing if the requested sidebar is already open
|
||||||
|
if (document.getElementById("sidebar-title").value == args)
|
||||||
|
{
|
||||||
|
document.getElementById("sidebar-box").contentWindow.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var menu = document.getElementById("viewSidebarMenu");
|
||||||
|
|
||||||
|
for (var i = 0; i < menu.childNodes.length; i++)
|
||||||
|
{
|
||||||
|
if (menu.childNodes[i].label == args)
|
||||||
|
{
|
||||||
|
eval(menu.childNodes[i].getAttribute("oncommand"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ completer: function (filter) { return vimperator.completion.sidebar(filter); } });
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user