1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 09:27:59 +01:00

whitespace formatting fixes

This commit is contained in:
Doug Kearns
2007-11-10 15:06:07 +00:00
parent 7e59f88c96
commit 2c5655e182
17 changed files with 692 additions and 692 deletions

View File

@@ -27,7 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/
// also includes methods for dealing with keywords and search engines
vimperator.Bookmarks = function() //{{{
vimperator.Bookmarks = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -47,7 +47,7 @@ vimperator.Bookmarks = function() //{{{
var keywords = null;
if (vimperator.options["preload"])
setTimeout(function() { load(); } , 100);
setTimeout(function () { load(); } , 100);
function load()
{
@@ -102,7 +102,7 @@ vimperator.Bookmarks = function() //{{{
// if "bypass_cache" is true, it will force a reload of the bookmarks database
// on my PC, it takes about 1ms for each bookmark to load, so loading 1000 bookmarks
// takes about 1 sec
this.get = function(filter, tags, bypass_cache)
this.get = function (filter, tags, bypass_cache)
{
if (!bookmarks || bypass_cache)
load();
@@ -147,7 +147,7 @@ vimperator.Bookmarks = function() //{{{
}
// returns number of deleted bookmarks
this.remove = function(url)
this.remove = function (url)
{
if (!url)
return 0;
@@ -178,7 +178,7 @@ vimperator.Bookmarks = function() //{{{
// TODO: add filtering
// also ensures that each search engine has a Vimperator-friendly alias
this.getSearchEngines = function()
this.getSearchEngines = function ()
{
var search_engines = [];
var firefox_engines = search_service.getVisibleEngines({ });
@@ -194,7 +194,7 @@ vimperator.Bookmarks = function() //{{{
var newalias = alias;
for (var j = 1; j <= 10; j++) // <=10 is intentional
{
if (!search_engines.some(function(item) { return (item[0] == newalias); }))
if (!search_engines.some(function (item) { return (item[0] == newalias); }))
break;
newalias = alias + j;
@@ -212,7 +212,7 @@ vimperator.Bookmarks = function() //{{{
// TODO: add filtering
// format of returned array:
// [keyword, helptext, url]
this.getKeywords = function()
this.getKeywords = function ()
{
if (!keywords)
load();
@@ -223,7 +223,7 @@ vimperator.Bookmarks = function() //{{{
// if @param engine_name is null, it uses the default search engine
// @returns the url for the search string
// if the search also requires a postdata, [url, postdata] is returned
this.getSearchURL = function(text, engine_name)
this.getSearchURL = function (text, engine_name)
{
var url = null;
var postdata = null;
@@ -271,7 +271,7 @@ vimperator.Bookmarks = function() //{{{
return url; // can be null
}
this.list = function(filter, tags, fullmode)
this.list = function (filter, tags, fullmode)
{
if (fullmode)
{
@@ -328,7 +328,7 @@ vimperator.Bookmarks = function() //{{{
//}}}
} //}}}
vimperator.History = function() //{{{
vimperator.History = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -339,7 +339,7 @@ vimperator.History = function() //{{{
var history = null;
if (vimperator.options["preload"])
setTimeout(function() { load(); } , 100);
setTimeout(function () { load(); } , 100);
function load()
{
@@ -374,7 +374,7 @@ vimperator.History = function() //{{{
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
this.get = function(filter)
this.get = function (filter)
{
if (!history)
load();
@@ -389,7 +389,7 @@ vimperator.History = function() //{{{
if (!history)
load();
history = history.filter(function(elem) {
history = history.filter(function (elem) {
return elem[0] != url;
});
@@ -399,7 +399,7 @@ vimperator.History = function() //{{{
// TODO: better names?
// and move to vimperator.buffer.?
this.stepTo = function(steps)
this.stepTo = function (steps)
{
var index = getWebNavigation().sessionHistory.index + steps;
@@ -413,7 +413,7 @@ vimperator.History = function() //{{{
}
}
this.goToStart = function()
this.goToStart = function ()
{
var index = getWebNavigation().sessionHistory.index;
@@ -426,7 +426,7 @@ vimperator.History = function() //{{{
getWebNavigation().gotoIndex(0);
}
this.goToEnd = function()
this.goToEnd = function ()
{
var index = getWebNavigation().sessionHistory.index;
var max = getWebNavigation().sessionHistory.count - 1;
@@ -440,7 +440,7 @@ vimperator.History = function() //{{{
getWebNavigation().gotoIndex(max);
}
this.list = function(filter, fullmode)
this.list = function (filter, fullmode)
{
if (fullmode)
{
@@ -477,7 +477,7 @@ vimperator.History = function() //{{{
//}}}
} //}}}
vimperator.Marks = function() //{{{
vimperator.Marks = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -566,7 +566,7 @@ vimperator.Marks = function() //{{{
umarks.push([mark, url_marks[mark]]);
// FIXME: why does umarks.sort() cause a "Component is not available =
// NS_ERROR_NOT_AVAILABLE" exception when used here?
umarks.sort(function(a, b) {
umarks.sort(function (a, b) {
if (a[0] < b[0])
return -1;
else if (a[0] > b[0])
@@ -583,7 +583,7 @@ vimperator.Marks = function() //{{{
/////////////////////////////////////////////////////////////////////////////{{{
// TODO: add support for frameset pages
this.add = function(mark)
this.add = function (mark)
{
var win = window.content;
@@ -613,7 +613,7 @@ vimperator.Marks = function() //{{{
}
}
this.remove = function(filter, special)
this.remove = function (filter, special)
{
if (special)
{
@@ -637,7 +637,7 @@ vimperator.Marks = function() //{{{
}
}
this.jumpTo = function(mark)
this.jumpTo = function (mark)
{
var ok = false;
@@ -691,7 +691,7 @@ vimperator.Marks = function() //{{{
vimperator.echoerr("E20: Mark not set"); // FIXME: move up?
}
this.list = function(filter)
this.list = function (filter)
{
var marks = getSortedMarks();
@@ -703,7 +703,7 @@ vimperator.Marks = function() //{{{
if (filter.length > 0)
{
marks = marks.filter(function(mark) {
marks = marks.filter(function (mark) {
if (filter.indexOf(mark[0]) > -1)
return mark;
});
@@ -732,7 +732,7 @@ vimperator.Marks = function() //{{{
//}}}
} //}}}
vimperator.QuickMarks = function() //{{{
vimperator.QuickMarks = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -751,12 +751,12 @@ vimperator.QuickMarks = function() //{{{
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
this.add = function(qmark, location)
this.add = function (qmark, location)
{
qmarks[qmark] = location;
}
this.remove = function(filter)
this.remove = function (filter)
{
var pattern = new RegExp("[" + filter.replace(/\s+/g, "") + "]");
@@ -767,12 +767,12 @@ vimperator.QuickMarks = function() //{{{
}
}
this.removeAll = function()
this.removeAll = function ()
{
qmarks = {};
}
this.jumpTo = function(qmark, where)
this.jumpTo = function (qmark, where)
{
var url = qmarks[qmark];
@@ -782,7 +782,7 @@ vimperator.QuickMarks = function() //{{{
vimperator.echoerr("E20: QuickMark not set");
}
this.list = function(filter)
this.list = function (filter)
{
var marks = [];
@@ -799,7 +799,7 @@ vimperator.QuickMarks = function() //{{{
if (filter.length > 0)
{
marks = marks.filter(function(mark) {
marks = marks.filter(function (mark) {
if (filter.indexOf(mark[0]) > -1)
return mark;
});
@@ -822,7 +822,7 @@ vimperator.QuickMarks = function() //{{{
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
}
this.destroy = function()
this.destroy = function ()
{
// save the quickmarks
var saved_qmarks = "";

View File

@@ -26,7 +26,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.Buffer = function() //{{{
vimperator.Buffer = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -129,43 +129,43 @@ vimperator.Buffer = function() //{{{
this.lastInputField = null; // used to keep track of the right field for "gi"
this.__defineGetter__("URL", function()
this.__defineGetter__("URL", function ()
{
// TODO: .URL is not defined for XUL documents
//return window.content.document.URL;
return window.content.document.location.href;
});
this.__defineGetter__("pageHeight", function()
this.__defineGetter__("pageHeight", function ()
{
return window.content.innerHeight;
});
this.__defineGetter__("textZoom", function()
this.__defineGetter__("textZoom", function ()
{
return getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom * 100;
});
this.__defineSetter__("textZoom", function(value)
this.__defineSetter__("textZoom", function (value)
{
setZoom(value, false);
});
this.__defineGetter__("fullZoom", function()
this.__defineGetter__("fullZoom", function ()
{
return getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom * 100;
});
this.__defineSetter__("fullZoom", function(value)
this.__defineSetter__("fullZoom", function (value)
{
setZoom(value, true);
});
this.__defineGetter__("title", function()
this.__defineGetter__("title", function ()
{
return window.content.document.title;
});
// returns an XPathResult object
this.evaluateXPath = function(expression, doc, elem, asIterator)
this.evaluateXPath = function (expression, doc, elem, asIterator)
{
if (!doc)
doc = window.content.document;
@@ -191,7 +191,7 @@ vimperator.Buffer = function() //{{{
// in contrast to vim, returns the selection if one is made,
// otherwise tries to guess the current word unter the text cursor
// NOTE: might change the selection
this.getCurrentWord = function()
this.getCurrentWord = function ()
{
var selection = window.content.getSelection().toString();
@@ -211,7 +211,7 @@ vimperator.Buffer = function() //{{{
return selection;
}
this.list = function(fullmode)
this.list = function (fullmode)
{
if (fullmode)
{
@@ -258,12 +258,12 @@ vimperator.Buffer = function() //{{{
}
}
this.scrollBottom = function()
this.scrollBottom = function ()
{
scrollToPercentiles(-1, 100);
}
this.scrollColumns = function(cols)
this.scrollColumns = function (cols)
{
var win = window.document.commandDispatcher.focusedWindow;
const COL_WIDTH = 20;
@@ -274,42 +274,42 @@ vimperator.Buffer = function() //{{{
win.scrollBy(COL_WIDTH * cols, 0);
}
this.scrollEnd = function()
this.scrollEnd = function ()
{
scrollToPercentiles(100, -1);
}
this.scrollLines = function(lines)
this.scrollLines = function (lines)
{
var win = window.document.commandDispatcher.focusedWindow;
checkScrollYBounds(win, lines);
win.scrollByLines(lines);
}
this.scrollPages = function(pages)
this.scrollPages = function (pages)
{
var win = window.document.commandDispatcher.focusedWindow;
checkScrollYBounds(win, pages);
win.scrollByPages(pages);
}
this.scrollToPercentile = function(percentage)
this.scrollToPercentile = function (percentage)
{
scrollToPercentiles(-1, percentage);
}
this.scrollStart = function()
this.scrollStart = function ()
{
scrollToPercentiles(0, -1);
}
this.scrollTop = function()
this.scrollTop = function ()
{
scrollToPercentiles(-1, 0);
}
// TODO: allow callback for filtering out unwanted frames? User defined?
this.shiftFrameFocus = function(count, forward)
this.shiftFrameFocus = function (count, forward)
{
if (!window.content.document instanceof HTMLDocument)
return;
@@ -317,7 +317,7 @@ vimperator.Buffer = function() //{{{
var frames = [];
// find all frames - depth-first search
(function(frame)
(function (frame)
{
if (frame.document.body.localName.toLowerCase() == "body")
frames.push(frame);
@@ -331,7 +331,7 @@ vimperator.Buffer = function() //{{{
// remove all unfocusable frames
// TODO: find a better way to do this - walking the tree is too slow
var start = document.commandDispatcher.focusedWindow;
frames = frames.filter(function(frame) {
frames = frames.filter(function (frame) {
frame.focus();
if (document.commandDispatcher.focusedWindow == frame)
return frame;
@@ -404,11 +404,11 @@ vimperator.Buffer = function() //{{{
doc.body.appendChild(indicator);
// remove the frame indicator
setTimeout(function() { doc.body.removeChild(indicator); }, 500);
setTimeout(function () { doc.body.removeChild(indicator); }, 500);
}
// updates the buffer preview in place only if list is visible
this.updateBufferList = function()
this.updateBufferList = function ()
{
if (!vimperator.bufferwindow.visible())
return false;
@@ -421,7 +421,7 @@ vimperator.Buffer = function() //{{{
// XXX: should this be in v.buffers. or v.tabs.?
// "buffer" is a string which matches the URL or title of a buffer, if it
// is null, the last used string is used again
this.switchTo = function(buffer, allowNonUnique, count, reverse)
this.switchTo = function (buffer, allowNonUnique, count, reverse)
{
if (buffer != null)
{
@@ -472,23 +472,23 @@ vimperator.Buffer = function() //{{{
index += matches.length;
}
else
index = (count-1) % matches.length;
index = (count - 1) % matches.length;
vimperator.tabs.select(matches[index], false);
}
};
this.zoomIn = function(steps, full_zoom)
this.zoomIn = function (steps, full_zoom)
{
bumpZoomLevel(steps, full_zoom);
};
this.zoomOut = function(steps, full_zoom)
this.zoomOut = function (steps, full_zoom)
{
bumpZoomLevel(-steps, full_zoom);
};
this.pageInfo = function(verbose)
this.pageInfo = function (verbose)
{
// TODO: copied from firefox. Needs some review/work...
// const feedTypes = {

View File

@@ -26,7 +26,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.Command = function(specs, action, extra_info) //{{{
vimperator.Command = function (specs, action, extra_info) //{{{
{
if (!specs || !action)
return null;
@@ -34,7 +34,7 @@ vimperator.Command = function(specs, action, extra_info) //{{{
// convert command name abbreviation specs of the form
// 'shortname[optional-tail]' to short and long versions Eg. 'abc[def]' ->
// 'abc', 'abcdef'
var parseSpecs = function(specs)
var parseSpecs = function (specs)
{
var short_names = [];
var long_names = [];
@@ -90,14 +90,14 @@ vimperator.Command = function(specs, action, extra_info) //{{{
}
vimperator.Command.prototype.execute = function(args, special, count, modifiers)
vimperator.Command.prototype.execute = function (args, special, count, modifiers)
{
return this.action.call(this, args, special, count, modifiers);
}
// return true if the candidate name matches one of the command's aliases
// (including all acceptable abbreviations)
vimperator.Command.prototype.hasName = function(name)
vimperator.Command.prototype.hasName = function (name)
{
// match a candidate name against a command name abbreviation spec - returning
// true if the candidate matches unambiguously
@@ -127,7 +127,7 @@ vimperator.Command.prototype.hasName = function(name)
}
//}}}
vimperator.Commands = function() //{{{
vimperator.Commands = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -148,7 +148,7 @@ vimperator.Commands = function() //{{{
function addDefaultCommand(command)
{
ex_commands.push(command);
vimperator.Commands.prototype[command.name] = function(args, special, count, modifiers)
vimperator.Commands.prototype[command.name] = function (args, special, count, modifiers)
{
command.execute(args, special, count, modifiers);
}
@@ -452,12 +452,12 @@ vimperator.Commands = function() //{{{
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
this.__iterator__ = function()
this.__iterator__ = function ()
{
return commandsIterator();
}
this.add = function(command)
this.add = function (command)
{
if (!command)
return false;
@@ -467,7 +467,7 @@ vimperator.Commands = function() //{{{
return true;
}
this.get = function(name)
this.get = function (name)
{
for (var i = 0; i < ex_commands.length; i++)
{
@@ -482,7 +482,7 @@ vimperator.Commands = function() //{{{
// FIXME: doesn't really belong here...
// return [null, null, null, null, heredoc_tag || false];
// [count, cmd, special, args] = match;
this.parseCommand = function(str, tag)
this.parseCommand = function (str, tag)
{
// remove comments
str.replace(/\s*".*$/, "");
@@ -526,14 +526,14 @@ vimperator.Commands = function() //{{{
/////////////////////////////////////////////////////////////////////////////{{{
addDefaultCommand(new vimperator.Command(["addo[ns]"],
function() { vimperator.open("chrome://mozapps/content/extensions/extensions.xul", vimperator.NEW_TAB); },
function () { vimperator.open("chrome://mozapps/content/extensions/extensions.xul", vimperator.NEW_TAB); },
{
short_help: "Show available Browser Extensions and Themes",
help: "You can add/remove/disable browser extensions from this dialog.<br/>Be aware that not all Firefox extensions work, because Vimperator overrides some key bindings and changes Firefox's GUI."
}
));
addDefaultCommand(new vimperator.Command(["ba[ck]"],
function(args, special, count)
function (args, special, count)
{
if (special)
vimperator.history.goToStart();
@@ -559,7 +559,7 @@ vimperator.Commands = function() //{{{
short_help: "Go back in the browser history",
help: "Count is supported, <code class=\"command\">:3back</code> goes back 3 pages in the browser history.<br/>" +
"The special version <code class=\"command\">:back!</code> goes to the beginning of the browser history.",
completer: function(filter)
completer: function (filter)
{
var sh = getWebNavigation().sessionHistory;
var completions = [];
@@ -576,7 +576,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
function(args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0); },
function (args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0); },
{
usage: ["[count]bd[elete][!]"],
short_help: "Delete current buffer (=tab)",
@@ -585,13 +585,13 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["beep"],
function() { vimperator.beep(); },
function () { vimperator.beep(); },
{
short_help: "Play a system beep"
}
));
addDefaultCommand(new vimperator.Command(["bma[rk]"],
function(args)
function (args)
{
var res = parseArgs(args, this.args);
if (!res)
@@ -620,11 +620,11 @@ vimperator.Commands = function() //{{{
" -keyword=keyword<br/>",
args: [[["-title", "-t"], OPTION_STRING],
[["-tags", "-T"], OPTION_LIST],
[["-keyword", "-k"], OPTION_STRING, function(arg) { return /\w/.test(arg); } ]]
[["-keyword", "-k"], OPTION_STRING, function (arg) { return /\w/.test(arg); } ]]
}
));
addDefaultCommand(new vimperator.Command(["bmarks"],
function(args, special)
function (args, special)
{
var res = parseArgs(args, this.args);
if (!res)
@@ -640,12 +640,12 @@ vimperator.Commands = function() //{{{
"The special version <code class=\"command\">:bmarks!</code> opens the default Firefox bookmarks window.<br/>" +
"Filter can also contain the following options:<br/>" +
"-tags=comma,separated,tag,list<br/>",
completer: function(filter) { return vimperator.bookmarks.get(filter); },
completer: function (filter) { return vimperator.bookmarks.get(filter); },
args: [[["-tags", "-T"], OPTION_LIST]]
}
));
addDefaultCommand(new vimperator.Command(["b[uffer]"],
function(args, special) { vimperator.buffer.switchTo(args, special); },
function (args, special) { vimperator.buffer.switchTo(args, special); },
{
usage: ["b[uffer][!] {url|index}"],
short_help: "Go to buffer from buffer list",
@@ -654,11 +654,11 @@ vimperator.Commands = function() //{{{
"it is selected. With <code class=\"argument\">[!]</code> the next buffer matching the argument " +
"is selected, even if it cannot be identified uniquely.<br/>" +
"Use <code class=\"mapping\">b</code> as a shortcut to open this prompt.",
completer: function(filter) { return vimperator.completion.get_buffer_completions(filter); }
completer: function (filter) { return vimperator.completion.get_buffer_completions(filter); }
}
));
addDefaultCommand(new vimperator.Command(["buffers", "files", "ls", "tabs"],
function(args, special)
function (args, special)
{
if (args)
{
@@ -676,7 +676,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["delbm[arks]"],
function(args, special)
function (args, special)
{
var url = args;
if (!url)
@@ -693,11 +693,11 @@ vimperator.Commands = function() //{{{
"Use <code>&lt;Tab&gt;</code> key on a string to complete the URL which you want to delete.<br/>" +
"The following options WILL be interpreted in the future:<br/>" +
" [!] a special version to delete ALL bookmarks <br/>",
completer: function(filter) { return vimperator.bookmarks.get(filter); }
completer: function (filter) { return vimperator.bookmarks.get(filter); }
}
));
addDefaultCommand(new vimperator.Command(["com[mand]"],
function(args)
function (args)
{
var res = parseArgs(args, this.args);
if (!res)
@@ -709,13 +709,13 @@ vimperator.Commands = function() //{{{
usage: ["com[mand][!] [{attr}...] {cmd} {rep}"],
short_help: "Temporarily used for testing args parser",
help: "",
args: [[["-nargs"], OPTION_STRING, function(arg) { return /^(0|1|\*|\?|\+)$/.test(arg); } ],
args: [[["-nargs"], OPTION_STRING, function (arg) { return /^(0|1|\*|\?|\+)$/.test(arg); } ],
[["-bang"], OPTION_NOARG],
[["-bar"], OPTION_NOARG]]
}
));
addDefaultCommand(new vimperator.Command(["delm[arks]"],
function(args, special)
function (args, special)
{
if (!special && !args)
{
@@ -768,7 +768,7 @@ vimperator.Commands = function() //{{{
));
addDefaultCommand(new vimperator.Command(["delqm[arks]"],
function(args, special)
function (args, special)
{
// TODO: finish arg parsing - we really need a proper way to do this. :)
if (!special && !args)
@@ -797,7 +797,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["downl[oads]", "dl"],
function() { vimperator.open("chrome://mozapps/content/downloads/downloads.xul", vimperator.NEW_TAB); },
function () { vimperator.open("chrome://mozapps/content/downloads/downloads.xul", vimperator.NEW_TAB); },
{
short_help: "Show progress of current downloads",
help: "Open the original Firefox download dialog in a new tab.<br/>" +
@@ -833,7 +833,7 @@ vimperator.Commands = function() //{{{
return arg;
}
addDefaultCommand(new vimperator.Command(["ec[ho]"],
function(args)
function (args)
{
var res = argToString(args, true);
if (res != null)
@@ -845,11 +845,11 @@ vimperator.Commands = function() //{{{
help: "Useful for showing informational messages. Multiple lines can be separated by \\n.<br/>" +
"<code class=\"argument\">{expr}</code> can either be a quoted string, or any expression which can be fed to eval() like 4+5. " +
"You can also view the source code of objects and functions if the return value of <code class=\"argument\">{expr}</code> is an object or function.",
completer: function(filter) { return vimperator.completion.javascript(filter); }
completer: function (filter) { return vimperator.completion.javascript(filter); }
}
));
addDefaultCommand(new vimperator.Command(["echoe[rr]"],
function(args)
function (args)
{
var res = argToString(args, false);
if (res != null)
@@ -859,11 +859,11 @@ vimperator.Commands = function() //{{{
usage: ["echoe[rr] {expr}"],
short_help: "Display an error string at the bottom of the window",
help: "Just like <code class=\"command\">:ec[ho]</code>, but echoes the result highlighted in red. Useful for showing important messages.",
completer: function(filter) { return vimperator.completion.javascript(filter); }
completer: function (filter) { return vimperator.completion.javascript(filter); }
}
));
addDefaultCommand(new vimperator.Command(["exe[cute]"],
function(args)
function (args)
{
// TODO: :exec has some difficult semantics -> later
// var res = parseArgs(args, this.args);
@@ -881,13 +881,13 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["exu[sage]"],
function(args, special, count, modifiers) { vimperator.help("commands", special, null, modifiers); },
function (args, special, count, modifiers) { vimperator.help("commands", special, null, modifiers); },
{
short_help: "Show help for Ex commands"
}
));
addDefaultCommand(new vimperator.Command(["fo[rward]", "fw"],
function(args, special, count)
function (args, special, count)
{
if (special)
vimperator.history.goToEnd();
@@ -913,7 +913,7 @@ vimperator.Commands = function() //{{{
short_help: "Go forward in the browser history",
help: "Count is supported, <code class=\"command\">:3forward</code> goes forward 3 pages in the browser history.<br/>" +
"The special version <code class=\"command\">:forward!</code> goes to the end of the browser history.",
completer: function(filter)
completer: function (filter)
{
var sh = getWebNavigation().sessionHistory;
var completions = [];
@@ -930,14 +930,14 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["ha[rdcopy]"],
function() { getBrowser().contentWindow.print(); },
function () { getBrowser().contentWindow.print(); },
{
short_help: "Print current document",
help: "Open a GUI dialog where you can select the printer, number of copies, orientation, etc."
}
));
addDefaultCommand(new vimperator.Command(["h[elp]"],
function(args, special, count, modifiers) { vimperator.help(args, special, null, modifiers); },
function (args, special, count, modifiers) { vimperator.help(args, special, null, modifiers); },
{
usage: ["h[elp] {subject}"],
short_help: "Open the help window",
@@ -949,21 +949,21 @@ vimperator.Commands = function() //{{{
"<li><code class=\"command\">:help o</code> for mappings (no pre- or postfix)</li>" +
"</ul>" +
"You can however use partial stings in the tab completion, so <code class=\"command\">:help he&lt;Tab&gt;</code> completes <code class=\"command\">:help :help</code>.",
completer: function(filter) { return vimperator.completion.get_help_completions(filter); }
completer: function (filter) { return vimperator.completion.get_help_completions(filter); }
}
));
addDefaultCommand(new vimperator.Command(["hist[ory]", "hs"],
function(args, special) { vimperator.history.list(args, special); },
function (args, special) { vimperator.history.list(args, special); },
{
usage: ["hist[ory] [filter]", "history!"],
short_help: "Show recently visited URLs",
help: "Open the message window at the bottom of the screen with all history items which match <code class=\"argument\">[filter]</code> either in the title or URL.<br/>" +
"The special version <code class=\"command\">:history!</code> opens the default Firefox history window.",
completer: function(filter) { return vimperator.history.get(filter); }
completer: function (filter) { return vimperator.history.get(filter); }
}
));
addDefaultCommand(new vimperator.Command(["javas[cript]", "js"],
function(args, special)
function (args, special)
{
if (special) // open javascript console
vimperator.open("chrome://global/content/console.xul", vimperator.NEW_TAB);
@@ -974,7 +974,7 @@ vimperator.Commands = function() //{{{
if (matches && matches[2])
{
vimperator.commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"),
function(code) {
function (code) {
try
{
eval(matches[1] + "\n" + code);
@@ -1008,11 +1008,11 @@ vimperator.Commands = function() //{{{
"Rudimentary <code class=\"mapping\">&lt;Tab&gt;</code> completion is available for <code class=\"command\">:javascript {cmd}&lt;Tab&gt;</code> (but not yet for the " +
"<code class=\"command\">:js &lt;&lt;EOF</code> multiline widget). Be aware that Vimperator needs to run {cmd} through eval() " +
"to get the completions, which could have unwanted side effects.",
completer: function(filter) { return vimperator.completion.javascript(filter); }
completer: function (filter) { return vimperator.completion.javascript(filter); }
}
));
addDefaultCommand(new vimperator.Command(["let"],
function(args)
function (args)
{
if (!args)
{
@@ -1100,7 +1100,7 @@ vimperator.Commands = function() //{{{
));
// code for abbreviations
addDefaultCommand(new vimperator.Command(["ab[breviate]"],
function(args)
function (args)
{
if (!args)
{
@@ -1124,7 +1124,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["ca[bbrev]"],
function(args)
function (args)
{
if (!args)
{
@@ -1146,7 +1146,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["ia[bbrev]"],
function(args)
function (args)
{
if (!args)
{
@@ -1168,14 +1168,14 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["una[bbreviate]"],
function(args) { vimperator.editor.removeAbbreviation("!", args); },
function (args) { vimperator.editor.removeAbbreviation("!", args); },
{
usage: ["una[bbreviate] {lhs}"],
short_help: "Remove an abbreviation"
}
));
addDefaultCommand(new vimperator.Command(["cuna[bbrev]"],
function(args) { vimperator.editor.removeAbbreviation("c", args); },
function (args) { vimperator.editor.removeAbbreviation("c", args); },
{
usage: ["cuna[bbrev] {lhs}"],
short_help: "Remove an abbreviation for Command-line mode",
@@ -1183,7 +1183,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["iuna[bbrev]"],
function(args) { vimperator.editor.removeAbbreviation("i", args); },
function (args) { vimperator.editor.removeAbbreviation("i", args); },
{
usage: ["iuna[bbrev] {lhs}"],
short_help: "Remove an abbreviation for Insert mode",
@@ -1191,15 +1191,15 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["ab[clear]"],
function(args) { vimperator.editor.removeAllAbbreviations("!"); },
function (args) { vimperator.editor.removeAllAbbreviations("!"); },
{ short_help: "Remove all abbreviations" }
));
addDefaultCommand(new vimperator.Command(["cab[clear]"],
function(args) { vimperator.editor.removeAllAbbreviations("c"); },
function (args) { vimperator.editor.removeAllAbbreviations("c"); },
{ short_help: "Remove all abbreviations for Command-line mode" }
));
addDefaultCommand(new vimperator.Command(["iab[clear]"],
function(args) { vimperator.editor.removeAllAbbreviations("i"); },
function (args) { vimperator.editor.removeAllAbbreviations("i"); },
{ short_help: "Remove all abbreviations for Insert mode" }
));
// 0 args -> list all maps
@@ -1228,7 +1228,7 @@ vimperator.Commands = function() //{{{
if (rhs)
{
vimperator.mappings.add(new vimperator.Map([vimperator.modes.NORMAL], [lhs],
function(count) { vimperator.events.feedkeys((count > 1 ? count : "") + rhs, noremap); },
function (count) { vimperator.events.feedkeys((count > 1 ? count : "") + rhs, noremap); },
{ flags: vimperator.Mappings.flags.COUNT, rhs: rhs }
));
}
@@ -1239,7 +1239,7 @@ vimperator.Commands = function() //{{{
}
}
addDefaultCommand(new vimperator.Command(["map"],
function(args) { map(args, false) },
function (args) { map(args, false) },
{
usage: ["map {lhs} {rhs}", "map {lhs}", "map"],
short_help: "Map the key sequence {lhs} to {rhs}",
@@ -1248,7 +1248,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["mapc[lear]"],
function(args)
function (args)
{
if (args)
{
@@ -1265,7 +1265,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["ma[rk]"],
function(args)
function (args)
{
if (!args)
{
@@ -1291,7 +1291,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["marks"],
function(args)
function (args)
{
// ignore invalid mark characters unless there are no valid mark chars
if (args && !/[a-zA-Z]/.test(args))
@@ -1310,7 +1310,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["mkv[imperatorrc]"],
function(args, special)
function (args, special)
{
// TODO: "E172: Only one file name allowed"
var filename;
@@ -1369,7 +1369,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["noh[lsearch]"],
function(args)
function (args)
{
vimperator.search.clear();
},
@@ -1380,7 +1380,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["norm[al]"],
function(args)
function (args)
{
if (!args)
{
@@ -1398,7 +1398,7 @@ vimperator.Commands = function() //{{{
));
// TODO: remove duplication in :map
addDefaultCommand(new vimperator.Command(["no[remap]"],
function(args) { map(args, true) },
function (args) { map(args, true) },
{
usage: ["no[remap] {lhs} {rhs}", "no[remap] {lhs}", "no[remap]"],
short_help: "Map the key sequence {lhs} to {rhs}",
@@ -1406,7 +1406,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["o[pen]", "e[dit]"],
function(args, special)
function (args, special)
{
if (args)
{
@@ -1445,7 +1445,7 @@ vimperator.Commands = function() //{{{
"The items which are completed on <code class=\"mapping\">&lt;Tab&gt;</code> are specified in the <code class=\"option\">'complete'</code> option.<br/>" +
"Without argument, reloads the current page.<br/>" +
"Without argument but with <code class=\"command\">!</code>, reloads the current page skipping the cache.",
completer: function(filter) { return vimperator.completion.get_url_completions(filter); }
completer: function (filter) { return vimperator.completion.get_url_completions(filter); }
}
));
addDefaultCommand(new vimperator.Command(["pa[geinfo]"],
@@ -1456,13 +1456,13 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["pc[lose]"],
function() { vimperator.previewwindow.hide(); },
function () { vimperator.previewwindow.hide(); },
{
short_help: "Close preview window on bottom of screen"
}
));
addDefaultCommand(new vimperator.Command(["pref[erences]", "prefs"],
function(args, special, count, modifiers)
function (args, special, count, modifiers)
{
if (!args)
{
@@ -1494,7 +1494,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["qma[rk]"],
function(args)
function (args)
{
if (!args)
{
@@ -1518,7 +1518,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["qmarks"],
function(args)
function (args)
{
// ignore invalid mark characters unless there are no valid mark chars
if (args && !/[a-zA-Z0-9]/.test(args))
@@ -1537,7 +1537,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["q[uit]"],
function() { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); },
function () { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); },
{
short_help: "Quit current tab",
help: "If this is the last tab in the window, close the window. If this was the " +
@@ -1545,14 +1545,14 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["quita[ll]", "qa[ll]"],
function() { vimperator.quit(false); },
function () { vimperator.quit(false); },
{
short_help: "Quit Vimperator",
help: "Quit Vimperator, no matter how many tabs/windows are open. The session is not stored."
}
));
addDefaultCommand(new vimperator.Command(["redr[aw]"],
function()
function ()
{
var wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
@@ -1564,7 +1564,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["re[load]"],
function(args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); },
function (args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); },
{
usage: ["re[load][!]"],
short_help: "Reload current page",
@@ -1572,7 +1572,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["reloada[ll]"],
function(args, special) { vimperator.tabs.reloadAll(special); },
function (args, special) { vimperator.tabs.reloadAll(special); },
{
usage: ["reloada[ll][!]"],
short_help: "Reload all pages",
@@ -1580,14 +1580,14 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["res[tart]"],
function() { vimperator.restart(); },
function () { vimperator.restart(); },
{
short_help: "Force the browser to restart",
help: "Useful when installing extensions."
}
));
addDefaultCommand(new vimperator.Command(["sav[eas]", "w[rite]"],
function() { saveDocument(window.content.document); },
function () { saveDocument(window.content.document); },
{
short_help: "Save current web page to disk",
help: "Opens the original Firefox \"Save page as...\" dialog.<br/>" +
@@ -1596,7 +1596,7 @@ vimperator.Commands = function() //{{{
));
addDefaultCommand(new vimperator.Command(["se[t]"],
// TODO: support setting multiple options at once
function(args, special, count, modifiers)
function (args, special, count, modifiers)
{
if (special)
{
@@ -1805,12 +1805,12 @@ vimperator.Commands = function() //{{{
"<code class=\"command\">:set option+={value}</code>, <code class=\"command\">:set option^={value}</code> and <code class=\"command\">:set option-={value}</code> " +
"adds/multiplies/subtracts <code class=\"argument\">{value}</code> from a number option and appends/prepends/removes <code class=\"argument\">{value}</code> from a string option.<br/>" +
"<code class=\"command\">:set all</code> shows the current value of all options and <code class=\"command\">:set all&amp;</code> resets all options to their default values.<br/>",
completer: function(filter) { return vimperator.completion.get_options_completions(filter); }
completer: function (filter) { return vimperator.completion.get_options_completions(filter); }
}
));
// TODO: sclose instead?
addDefaultCommand(new vimperator.Command(["sbcl[ose]"],
function(args)
function (args)
{
if (args)
{
@@ -1828,7 +1828,7 @@ vimperator.Commands = function() //{{{
// TODO: sopen instead? Separate :sidebar from :sbopen and make them behave
// more like :cw, :cope etc
addDefaultCommand(new vimperator.Command(["sideb[ar]", "sb[ar]", "sbope[n]"],
function(args)
function (args)
{
if (!args)
{
@@ -1859,11 +1859,11 @@ vimperator.Commands = function() //{{{
short_help: "Open the sidebar window",
help: "<code class=\"argument\">{name}</code> is any of the menu items listed under the standard Firefox View->Sidebar " +
"menu. Add-ons, Preferences and Downloads are also available in the sidebar.",
completer: function(filter) { return vimperator.completion.get_sidebar_completions(filter); }
completer: function (filter) { return vimperator.completion.get_sidebar_completions(filter); }
}
));
addDefaultCommand(new vimperator.Command(["so[urce]"],
function(args, special)
function (args, special)
{
// FIXME: implement proper filename quoting
//if (/[^\\]\s/.test(args))
@@ -1879,14 +1879,14 @@ vimperator.Commands = function() //{{{
short_help: "Read Ex commands from {file}",
help: "You can either source files which mostly contain Ex commands like <code class=\"command\">map &lt; gt</code> " +
"and put JavaScript code within a:<br/><code class=\"code\">" +
"js &lt;&lt;EOF<br/>hello = function() {<br/>&nbsp;&nbsp;alert(\"Hello world\");<br/>}<br/>EOF<br/></code> section.<br/>" +
"js &lt;&lt;EOF<br/>hello = function () {<br/>&nbsp;&nbsp;alert(\"Hello world\");<br/>}<br/>EOF<br/></code> section.<br/>" +
"Or you can alternatively source a file which ends in .js, these files are automatically sourced as pure JavaScript files.<br/>" +
"NOTE: In both cases you must add functions to the global window object like shown above, functions written as:<br/>" +
"<code class=\"code\">function hello2() {<br/>&nbsp;&nbsp;alert(\"Hello world\");<br/>}<br/></code>are only available within the scope of the script. <br/><br/>" +
"The .vimperatorrc file in your home directory and any files in ~/.vimperator/plugin/ are always sourced at startup.<br/>" +
"~ is supported as a shortcut for the <var>$HOME</var> directory.<br/>" +
"If <code class=\"command\">!</code> is specified, errors are not printed.",
completer: function(filter) { return vimperator.completion.get_file_completions(filter); }
completer: function (filter) { return vimperator.completion.get_file_completions(filter); }
}
));
addDefaultCommand(new vimperator.Command(["st[op]"],
@@ -1897,24 +1897,24 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["tab"],
function(args) { vimperator.execute(args, { inTab: true }); },
function (args) { vimperator.execute(args, { inTab: true }); },
{
usage: ["tab {cmd}"],
short_help: "Execute {cmd} and tell it to output in a new tab",
help: "Works only for commands that support it, currently:" +
"<ul><li>:tab help</li>" +
"<li>:tab prefs[!]</li></ul>",
completer: function(filter) { return vimperator.completion.get_command_completions(filter); }
completer: function (filter) { return vimperator.completion.get_command_completions(filter); }
}
));
addDefaultCommand(new vimperator.Command(["tabl[ast]"],
function() { vimperator.tabs.select("$", false); },
function () { vimperator.tabs.select("$", false); },
{
short_help: "Switch to the last tab"
}
));
addDefaultCommand(new vimperator.Command(["tabm[ove]"],
function(args, special) { vimperator.tabs.move(getBrowser().mCurrentTab, args, special); },
function (args, special) { vimperator.tabs.move(getBrowser().mCurrentTab, args, special); },
{
usage: ["tabm[ove] [N]", "tabm[ove][!] +N | -N"],
short_help: "Move the current tab after tab N",
@@ -1924,7 +1924,7 @@ vimperator.Commands = function() //{{{
));
addDefaultCommand(new vimperator.Command(["tabn[ext]", "tn[ext]"],
// TODO: count support
function(args)
function (args)
{
if (!args)
{
@@ -1950,13 +1950,13 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["tabo[nly]"],
function() { vimperator.tabs.keepOnly(getBrowser().mCurrentTab); },
function () { vimperator.tabs.keepOnly(getBrowser().mCurrentTab); },
{
short_help: "Close all other tabs"
}
));
addDefaultCommand(new vimperator.Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
function(args, special)
function (args, special)
{
var where = special ? vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB;
if (/\btabopen\b/.test(vimperator.options["activate"]))
@@ -1972,12 +1972,12 @@ vimperator.Commands = function() //{{{
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/>" +
"If used with <code class=\"command\">!</code>, the 'tabopen' value of the <code class=\"option\">'activate'</code> option is negated.",
completer: function(filter) { return vimperator.completion.get_url_completions(filter); }
completer: function (filter) { return vimperator.completion.get_url_completions(filter); }
}
));
addDefaultCommand(new vimperator.Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"],
// TODO: count support
function(args)
function (args)
{
if (!args)
vimperator.tabs.select("-1", true);
@@ -1993,14 +1993,14 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["tabr[ewind]", "tabfir[st]"],
function() { vimperator.tabs.select(0, false); },
function () { vimperator.tabs.select(0, false); },
{
usage: ["tabr[ewind]", "tabfir[st]"],
short_help: "Switch to the first tab"
}
));
addDefaultCommand(new vimperator.Command(["time"],
function(args, special, count)
function (args, special, count)
{
try
{
@@ -2091,7 +2091,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["u[ndo]"],
function(args, special, count)
function (args, special, count)
{
if (count < 1)
count = 1;
@@ -2116,7 +2116,7 @@ vimperator.Commands = function() //{{{
short_help: "Undo closing of a tab",
help: "If a count is given, don't close the last but the <code class=\"argument\">[count]</code>th last tab. " +
"With <code class=\"argument\">[url]</code> restores the tab matching the url.",
completer: function(filter)
completer: function (filter)
{
// get closed-tabs from nsSessionStore
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
@@ -2135,7 +2135,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["undoa[ll]"],
function(args, special, count)
function (args, special, count)
{
if (count > -1)
{
@@ -2159,7 +2159,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["unl[et]"],
function(args, special)
function (args, special)
{
if (!args)
return vimperator.echoerr("E471: Argument required");
@@ -2188,7 +2188,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["unm[ap]"],
function(args)
function (args)
{
if (!args)
{
@@ -2210,7 +2210,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["ve[rsion]"],
function(args, special)
function (args, special)
{
if (special)
vimperator.open("about:");
@@ -2225,13 +2225,13 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["viu[sage]"],
function(args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); },
function (args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); },
{
short_help: "Show help for normal mode commands"
}
));
addDefaultCommand(new vimperator.Command(["winc[lose]", "wc[lose]"],
function(args)
function (args)
{
window.close();
},
@@ -2241,7 +2241,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["wino[pen]", "wo[pen]", "wine[dit]"],
function(args)
function (args)
{
if (args)
vimperator.open(args, vimperator.NEW_WINDOW);
@@ -2255,7 +2255,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["wqa[ll]", "wq", "xa[ll]"],
function() { vimperator.quit(true); },
function () { vimperator.quit(true); },
{
usage: ["wqa[ll]", "xa[ll]"],
short_help: "Save the session and quit",
@@ -2264,7 +2264,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["zo[om]"],
function(args, special)
function (args, special)
{
var level;
@@ -2309,7 +2309,7 @@ vimperator.Commands = function() //{{{
}
));
addDefaultCommand(new vimperator.Command(["!", "run"],
function(args, special)
function (args, special)
{
// :!! needs to be treated specially as the command parser sets the special flag but removes the ! from args
if (special)

View File

@@ -26,7 +26,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.Completion = function() // {{{
vimperator.Completion = function () // {{{
{
// The completion substrings, used for showing the longest common match
var g_substrings = [];
@@ -63,7 +63,7 @@ vimperator.Completion = function() // {{{
}
else
{
g_substrings = g_substrings.filter(function($_) {
g_substrings = g_substrings.filter(function ($_) {
return list[i][0][j].indexOf($_) >= 0;
});
}
@@ -93,7 +93,7 @@ vimperator.Completion = function() // {{{
}
else
{
g_substrings = g_substrings.filter(function($_) {
g_substrings = g_substrings.filter(function ($_) {
return list[i][0][j].indexOf($_) == 0;
});
}
@@ -109,7 +109,7 @@ vimperator.Completion = function() // {{{
* returns the longest common substring
* used for the 'longest' setting for wildmode
*/
get_longest_substring: function() //{{{
get_longest_substring: function () //{{{
{
if (g_substrings.length == 0)
return "";
@@ -130,7 +130,7 @@ vimperator.Completion = function() // {{{
* depending on the 'complete' option
* if the 'complete' argument is passed like "h", it temporarily overrides the complete option
*/
get_url_completions: function(filter, complete) //{{{
get_url_completions: function (filter, complete) //{{{
{
var completions = [];
g_substrings = [];
@@ -152,21 +152,21 @@ vimperator.Completion = function() // {{{
return completions;
}, //}}}
get_search_completions: function(filter) //{{{
get_search_completions: function (filter) //{{{
{
var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords());
if (!filter) return engines.map(function(engine) {
if (!filter) return engines.map(function (engine) {
return [engine[0], engine[1]];
});
var mapped = engines.map(function(engine) {
var mapped = engines.map(function (engine) {
return [[engine[0]], engine[1]];
});
return build_longest_common_substring(mapped, filter);
}, //}}}
// TODO: support file:// and \ or / path separators on both platforms
get_file_completions: function(filter)
get_file_completions: function (filter)
{
// this is now also used as part of the url completion, so the
// substrings shouldn't be cleared for that case
@@ -185,7 +185,7 @@ vimperator.Completion = function() // {{{
try
{
files = vimperator.io.readDirectory(dir);
mapped = files.map(function(file) {
mapped = files.map(function (file) {
return [[file.path], file.isDirectory() ? "Directory" : "File"];
});
}
@@ -198,7 +198,7 @@ vimperator.Completion = function() // {{{
return build_longest_starting_substring(mapped, filter);
},
get_help_completions: function(filter) //{{{
get_help_completions: function (filter) //{{{
{
var help_array = [[["introduction"], "Introductory text"],
[["initialization"], "Initialization and startup"],
@@ -207,25 +207,25 @@ vimperator.Completion = function() // {{{
[["options"], "Configuration options"]]; // TODO: hardcoded until we have proper 'pages'
g_substrings = [];
for (var command in vimperator.commands)
help_array.push([command.long_names.map(function($_) { return ":" + $_; }), command.short_help]);
help_array.push([command.long_names.map(function ($_) { return ":" + $_; }), command.short_help]);
options = this.get_options_completions(filter, true);
help_array = help_array.concat(options.map(function($_) {
help_array = help_array.concat(options.map(function ($_) {
return [
$_[0].map(function($_) { return "'" + $_ + "'"; }),
$_[0].map(function ($_) { return "'" + $_ + "'"; }),
$_[1]
];
}));
for (var map in vimperator.mappings)
help_array.push([map.names, map.short_help]);
if (!filter) return help_array.map(function($_) {
if (!filter) return help_array.map(function ($_) {
return [$_[0][0], $_[1]]; // unfiltered, use the first command
});
return build_longest_common_substring(help_array, filter);
}, //}}}
get_command_completions: function(filter) //{{{
get_command_completions: function (filter) //{{{
{
g_substrings = [];
var completions = [];
@@ -241,7 +241,7 @@ vimperator.Completion = function() // {{{
return build_longest_starting_substring(completions, filter);
}, //}}}
get_options_completions: function(filter, unfiltered) //{{{
get_options_completions: function (filter, unfiltered) //{{{
{
g_substrings = [];
var options_completions = [];
@@ -308,7 +308,7 @@ vimperator.Completion = function() // {{{
}
else
{
g_substrings = g_substrings.filter(function($_) {
g_substrings = g_substrings.filter(function ($_) {
return option.names[j].indexOf($_) == 0;
});
}
@@ -320,7 +320,7 @@ vimperator.Completion = function() // {{{
return options_completions;
}, //}}}
get_buffer_completions: function(filter) //{{{
get_buffer_completions: function (filter) //{{{
{
g_substrings = [];
var items = [];
@@ -350,13 +350,13 @@ vimperator.Completion = function() // {{{
items.push([[(i + 1) + ": " + title, (i + 1) + ": " + url], url]);
}
}
if (!filter) return items.map(function($_) {
if (!filter) return items.map(function ($_) {
return [$_[0][0], $_[1]];
});
return build_longest_common_substring(items, filter);
}, //}}}
get_sidebar_completions: function(filter) //{{{
get_sidebar_completions: function (filter) //{{{
{
g_substrings = [];
var menu = document.getElementById("viewSidebarMenu")
@@ -368,20 +368,20 @@ vimperator.Completion = function() // {{{
if (!filter)
return nodes;
var mapped = nodes.map(function(node) {
var mapped = nodes.map(function (node) {
return [[node[0]], node[1]];
});
return build_longest_common_substring(mapped, filter);
}, //}}}
javascript: function(str) // {{{
javascript: function (str) // {{{
{
g_substrings = [];
var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/);
var object = "window";
var filter = matches[3] || "";
var start = matches[1].length-1;
var start = matches[1].length - 1;
if (matches[2])
{
var brackets = 0, parentheses = 0;
@@ -449,7 +449,7 @@ vimperator.Completion = function() // {{{
// discard all entries in the 'urls' array, which don't match 'filter
// urls must be of type [["url", "title"], [...]] or optionally
// [["url", "title", keyword, [tags]], [...]]
filterURLArray: function(urls, filter, tags) //{{{
filterURLArray: function (urls, filter, tags) //{{{
{
var filtered = [];
// completions which don't match the url but just the description
@@ -474,7 +474,7 @@ vimperator.Completion = function() // {{{
if (ignorecase)
{
filter = filter.toLowerCase();
tags = tags.map(function(t) { return t.toLowerCase(); });
tags = tags.map(function (t) { return t.toLowerCase(); });
}
/*
@@ -493,7 +493,7 @@ vimperator.Completion = function() // {{{
{
url = url.toLowerCase();
title = title.toLowerCase();
tag = tag.map(function(t) { return t.toLowerCase(); });
tag = tag.map(function (t) { return t.toLowerCase(); });
}
// filter on tags
@@ -510,7 +510,7 @@ vimperator.Completion = function() // {{{
{
// no direct match of filter in the url, but still accept this item
// if _all_ tokens of filter match either the url or the title
if (filter.split(/\s+/).every(function(token) {
if (filter.split(/\s+/).every(function (token) {
return (url.indexOf(token) > -1 || title.indexOf(token) > -1);
}))
additional_completions.push(urls[i]);
@@ -534,7 +534,7 @@ vimperator.Completion = function() // {{{
}
else
{
g_substrings = g_substrings.filter(function($_) {
g_substrings = g_substrings.filter(function ($_) {
return url.indexOf($_) >= 0;
});
}
@@ -547,7 +547,7 @@ vimperator.Completion = function() // {{{
// generic helper function which checks if the given "items" array pass "filter"
// items must be an array of strings
match: function(items, filter, case_sensitive)
match: function (items, filter, case_sensitive)
{
if (typeof(filter) != "string" || !items)
return false;
@@ -559,13 +559,13 @@ vimperator.Completion = function() // {{{
items_str = items_str.toLowerCase();
}
if (filter.split(/\s+/).every(function(str) { return items_str.indexOf(str) > -1; }))
if (filter.split(/\s+/).every(function (str) { return items_str.indexOf(str) > -1; }))
return true;
return false;
},
exTabCompletion: function(str) //{{{
exTabCompletion: function (str) //{{{
{
var [count, cmd, special, args] = vimperator.commands.parseCommand(str);
var completions = [];

View File

@@ -29,7 +29,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
// command names taken from:
// http://developer.mozilla.org/en/docs/Editor_Embedding_Guide
vimperator.Editor = function() //{{{
vimperator.Editor = function () //{{{
{
// store our last search with f, F, t or T
var last_findChar = null;
@@ -50,7 +50,7 @@ vimperator.Editor = function() //{{{
return ed.controllers.getControllerForCommand("cmd_beginLine");
}
this.line = function()
this.line = function ()
{
var line = 1;
var text = editor().value;
@@ -60,7 +60,7 @@ vimperator.Editor = function() //{{{
return line;
}
this.col = function()
this.col = function ()
{
var col = 1;
var text = editor().value;
@@ -73,20 +73,20 @@ vimperator.Editor = function() //{{{
return col;
}
this.unselectText = function()
this.unselectText = function ()
{
var elt = window.document.commandDispatcher.focusedElement;
if (elt && elt.selectionEnd)
elt.selectionEnd = elt.selectionStart;
}
this.selectedText = function()
this.selectedText = function ()
{
var text = editor().value;
return text.substring(editor().selectionStart, editor().selectionEnd);
}
this.pasteClipboard = function()
this.pasteClipboard = function ()
{
var elt = window.document.commandDispatcher.focusedElement;
@@ -106,7 +106,7 @@ vimperator.Editor = function() //{{{
}
// count is optional, defaults to 1
this.executeCommand = function(cmd, count)
this.executeCommand = function (cmd, count)
{
var controller = getController();
if (!controller || !controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd))
@@ -142,7 +142,7 @@ vimperator.Editor = function() //{{{
// cmd = y, d, c
// motion = b, 0, gg, G, etc.
this.executeCommandWithMotion = function(cmd, motion, count)
this.executeCommandWithMotion = function (cmd, motion, count)
{
if (!typeof count == "number" || count < 1)
count = 1;
@@ -229,7 +229,7 @@ vimperator.Editor = function() //{{{
// Simple setSelectionRange() would be better, but we want to maintain the correct
// order of selectionStart/End (a firefox bug always makes selectionStart <= selectionEnd)
// Use only for small movements!
this.moveToPosition = function(pos, forward, select)
this.moveToPosition = function (pos, forward, select)
{
if (!select)
{
@@ -262,7 +262,7 @@ vimperator.Editor = function() //{{{
}
// returns the position of char
this.findCharForward = function(char, count)
this.findCharForward = function (char, count)
{
if (!editor())
return -1;
@@ -288,7 +288,7 @@ vimperator.Editor = function() //{{{
return -1;
}
// returns the position of char
this.findCharBackward = function(char, count)
this.findCharBackward = function (char, count)
{
if (!editor())
return -1;
@@ -314,7 +314,7 @@ vimperator.Editor = function() //{{{
return -1;
}
this.editWithExternalEditor = function()
this.editWithExternalEditor = function ()
{
var textBox = document.commandDispatcher.focusedElement;
var editor = vimperator.options["editor"];
@@ -380,11 +380,11 @@ vimperator.Editor = function() //{{{
// blink the textbox after returning
var timeout = 100;
textBox.style.backgroundColor = tmpBg;
setTimeout( function() {
setTimeout( function () {
textBox.style.backgroundColor = oldBg;
setTimeout( function() {
setTimeout( function () {
textBox.style.backgroundColor = tmpBg;
setTimeout( function() {
setTimeout( function () {
textBox.style.backgroundColor = oldBg;
}, timeout);
}, timeout);
@@ -410,7 +410,7 @@ vimperator.Editor = function() //{{{
}
// filter is i, c or "!" (insert or command abbreviations or both)
this.listAbbreviations = function(filter, lhs)
this.listAbbreviations = function (filter, lhs)
{
if (lhs) // list only that one
{
@@ -459,7 +459,7 @@ vimperator.Editor = function() //{{{
}
}
this.addAbbreviation = function(filter, lhs, rhs)
this.addAbbreviation = function (filter, lhs, rhs)
{
if (!abbrev[lhs])
{
@@ -543,7 +543,7 @@ vimperator.Editor = function() //{{{
//
}
this.removeAbbreviation = function(filter, lhs)
this.removeAbbreviation = function (filter, lhs)
{
if (!lhs)
{
@@ -589,7 +589,7 @@ vimperator.Editor = function() //{{{
return false;
}
this.removeAllAbbreviations = function(filter)
this.removeAllAbbreviations = function (filter)
{
if (filter == "!")
{
@@ -608,7 +608,7 @@ vimperator.Editor = function() //{{{
}
}
this.expandAbbreviation = function(filter) // try to find an candidate and replace accordingly
this.expandAbbreviation = function (filter) // try to find an candidate and replace accordingly
{
var textbox = editor();
var text = textbox.value;

View File

@@ -26,7 +26,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.Events = function() //{{{
vimperator.Events = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -35,23 +35,23 @@ vimperator.Events = function() //{{{
// this handler is for middle click only in the content
//window.addEventListener("mousedown", onVimperatorKeypress, true);
//content.mPanelContainer.addEventListener("mousedown", onVimperatorKeypress, true);
//document.getElementById("content").onclick = function(event) { alert("foo"); };
//document.getElementById("content").onclick = function (event) { alert("foo"); };
// any tab related events
var tabcontainer = getBrowser().tabContainer;
tabcontainer.addEventListener("TabMove", function(event) {
tabcontainer.addEventListener("TabMove", function (event) {
vimperator.statusline.updateTabCount();
vimperator.buffer.updateBufferList();
}, false);
tabcontainer.addEventListener("TabOpen", function(event) {
tabcontainer.addEventListener("TabOpen", function (event) {
vimperator.statusline.updateTabCount();
vimperator.buffer.updateBufferList();
}, false);
tabcontainer.addEventListener("TabClose", function(event) {
tabcontainer.addEventListener("TabClose", function (event) {
vimperator.statusline.updateTabCount();
vimperator.buffer.updateBufferList();
}, false);
tabcontainer.addEventListener("TabSelect", function(event) {
tabcontainer.addEventListener("TabSelect", function (event) {
if (vimperator.mode == vimperator.modes.HINTS)
vimperator.modes.reset();
@@ -61,7 +61,7 @@ vimperator.Events = function() //{{{
vimperator.buffer.updateBufferList();
vimperator.tabs.updateSelectionHistory();
setTimeout(function() { vimperator.focusContent(true); }, 10); // just make sure, that no widget has focus
setTimeout(function () { vimperator.focusContent(true); }, 10); // just make sure, that no widget has focus
}, false);
// this adds an event which is is called on each page load, even if the
@@ -107,7 +107,7 @@ vimperator.Events = function() //{{{
window.addEventListener("DOMMenuBarActive", enterMenuMode, true);
window.addEventListener("DOMMenuBarInactive", exitMenuMode, true);
// window.document.addEventListener("DOMTitleChanged", function(event)
// window.document.addEventListener("DOMTitleChanged", function (event)
// {
// vimperator.log("titlechanged");
// }, null);
@@ -231,7 +231,7 @@ vimperator.Events = function() //{{{
// // FIXME: this currently causes window map events which is _very_ annoying
// // we want to stay in command mode after a page has loaded
// //setTimeout(vimperator.focusContent, 10);
// // setTimeout(function() {
// // setTimeout(function () {
// // if (doc.commandDispatcher.focusedElement)
// // doc.commandDispatcher.focusedElement.blur();
// // alert(doc.commandDispatcher.focusedElement);
@@ -246,7 +246,7 @@ vimperator.Events = function() //{{{
/////////////////////////////////////////////////////////////////////////////{{{
this.wantsModeReset = true; // used in onFocusChange since Firefox is so buggy here
this.destroy = function()
this.destroy = function ()
{
// removeEventListeners() to avoid mem leaks
window.dump("TODO: remove all eventlisteners\n");
@@ -268,7 +268,7 @@ vimperator.Events = function() //{{{
//
// @param keys: a string like "2<C-f>" to pass
// if you want < to be taken literally, prepend it with a \\
this.feedkeys = function(keys, noremap)
this.feedkeys = function (keys, noremap)
{
var doc = window.document;
var view = window.document.defaultView;
@@ -332,7 +332,7 @@ vimperator.Events = function() //{{{
// a keycode which can be used in mappings
// e.g. pressing ctrl+n would result in the string "<C-n>"
// null if unknown key
this.toString = function(event) //{{{
this.toString = function (event) //{{{
{
if (!event)
return;
@@ -408,11 +408,11 @@ vimperator.Events = function() //{{{
} //}}}
this.isAcceptKey = function(key)
this.isAcceptKey = function (key)
{
return (key == "<Return>" || key == "<C-j>" || key == "<C-m>");
}
this.isCancelKey = function(key)
this.isCancelKey = function (key)
{
return (key == "<Esc>" || key == "<C-[>" || key == "<C-c>");
}
@@ -422,7 +422,7 @@ vimperator.Events = function() //{{{
//
// the ugly wantsModeReset is needed, because firefox generates a massive
// amount of focus changes for things like <C-v><C-k> (focusing the search field)
this.onFocusChange = function(event)
this.onFocusChange = function (event)
{
// command line has it's own focus change handler
if (vimperator.mode == vimperator.modes.COMMAND_LINE)
@@ -455,14 +455,14 @@ vimperator.Events = function() //{{{
vimperator.mode == vimperator.modes.VISUAL)
{
this.wantsModeReset = true;
setTimeout(function() {
setTimeout(function () {
if (vimperator.events.wantsModeReset)
vimperator.modes.reset();
}, 10);
}
}
this.onSelectionChange = function(event)
this.onSelectionChange = function (event)
{
var could_copy = false;
var controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
@@ -488,7 +488,7 @@ vimperator.Events = function() //{{{
}
// global escape handler, is called in ALL modes
this.onEscape = function()
this.onEscape = function ()
{
if (!vimperator.modes.passNextKey)
{
@@ -549,7 +549,7 @@ vimperator.Events = function() //{{{
// this keypress handler gets always called first, even if e.g.
// the commandline has focus
this.onKeyPress = function(event)
this.onKeyPress = function (event)
{
var key = vimperator.events.toString(event);
if (!key)
@@ -732,7 +732,7 @@ vimperator.Events = function() //{{{
window.addEventListener("keypress", this.onKeyPress, true);
// this is need for sites like msn.com which focus the input field on keydown
this.onKeyUpOrDown = function(event)
this.onKeyUpOrDown = function (event)
{
if (vimperator.modes.passNextKey ^ vimperator.modes.passAllKeys || isFormElemFocused())
return true;
@@ -745,7 +745,7 @@ vimperator.Events = function() //{{{
this.progressListener =
{
QueryInterface: function(aIID)
QueryInterface: function (aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsIXULBrowserWindow) || // for setOverLink();
@@ -756,7 +756,7 @@ vimperator.Events = function() //{{{
},
// XXX: function may later be needed to detect a canceled synchronous openURL()
onStateChange: function(webProgress, aRequest, flags, aStatus)
onStateChange: function (webProgress, aRequest, flags, aStatus)
{
// STATE_IS_DOCUMENT | STATE_IS_WINDOW is important, because we also
// receive statechange events for loading images and other parts of the web page
@@ -783,29 +783,29 @@ vimperator.Events = function() //{{{
else if (aState & nsIWebProgressListener.STATE_IS_SECURE)
vimperator.statusline.setClass("secure");
},
onStatusChange: function(webProgress, request, status, message)
onStatusChange: function (webProgress, request, status, message)
{
vimperator.statusline.updateUrl(message);
},
onProgressChange: function(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress)
onProgressChange: function (webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress)
{
vimperator.statusline.updateProgress(curTotalProgress/maxTotalProgress);
},
// happens when the users switches tabs
onLocationChange: function()
onLocationChange: function ()
{
vimperator.statusline.updateUrl();
vimperator.statusline.updateProgress();
// if this is not delayed we get the position of the old buffer
setTimeout(function() { vimperator.statusline.updateBufferPosition(); }, 100);
setTimeout(function () { vimperator.statusline.updateBufferPosition(); }, 100);
},
// called at the very end of a page load
asyncUpdateUI: function()
asyncUpdateUI: function ()
{
setTimeout(vimperator.statusline.updateUrl, 100);
},
setOverLink : function(link, b)
setOverLink : function (link, b)
{
var ssli = vimperator.options["showstatuslinks"];
if (link && ssli)
@@ -826,10 +826,10 @@ vimperator.Events = function() //{{{
},
// stub functions for the interfaces
setJSStatus: function(status) { ; },
setJSDefaultStatus: function(status) { ; },
setDefaultStatus: function(status) { ; },
onLinkIconAvailable: function() { ; }
setJSStatus: function (status) { ; },
setJSDefaultStatus: function (status) { ; },
setDefaultStatus: function (status) { ; },
onLinkIconAvailable: function () { ; }
};
window.XULBrowserWindow = this.progressListener;
@@ -844,7 +844,7 @@ vimperator.Events = function() //{{{
this.prefObserver =
{
register: function()
register: function ()
{
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
@@ -853,13 +853,13 @@ vimperator.Events = function() //{{{
this._branch.addObserver("", this, false);
},
unregister: function()
unregister: function ()
{
if (!this._branch) return;
this._branch.removeObserver("", this);
},
observe: function(aSubject, aTopic, aData)
observe: function (aSubject, aTopic, aData)
{
if (aTopic != "nsPref:changed") return;
// aSubject is the nsIPrefBranch we're observing (after appropriate QI)

View File

@@ -37,7 +37,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
// : incremental searches shouldn't permanently update search modifiers
// make sure you only create this object when the "vimperator" object is ready
vimperator.Search = function() //{{{
vimperator.Search = function () //{{{
{
var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback
var found = false; // true if the last search was successful
@@ -51,13 +51,13 @@ vimperator.Search = function() //{{{
var links_only = false; // search is limited to link text only
// Event handlers for search - closure is needed
vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function(command) { self.searchKeyPressed(command); });
vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function(command) { self.searchSubmitted(command); });
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function() { self.searchCanceled(); });
vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { self.searchKeyPressed(command); });
vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function (command) { self.searchSubmitted(command); });
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function () { self.searchCanceled(); });
// TODO: allow advanced modes in register/triggerCallback
vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function(command) { self.searchKeyPressed(command); });
vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function(command) { self.searchSubmitted(command); });
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function() { self.searchCanceled(); });
vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function (command) { self.searchKeyPressed(command); });
vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { self.searchSubmitted(command); });
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { self.searchCanceled(); });
// set search_string, search_pattern, case_sensitive, links_only
function processUserPattern(pattern)
@@ -81,7 +81,7 @@ vimperator.Search = function() //{{{
links_only = false;
// strip links-only modifiers
pattern = pattern.replace(/(\\)?\\[uU]/g, function($0, $1) { return $1 ? $0 : ""; });
pattern = pattern.replace(/(\\)?\\[uU]/g, function ($0, $1) { return $1 ? $0 : ""; });
// case sensitivity - \c wins if both modifiers specified
if (/\c/.test(pattern))
@@ -96,7 +96,7 @@ vimperator.Search = function() //{{{
case_sensitive = true;
// strip case-sensitive modifiers
pattern = pattern.replace(/(\\)?\\[cC]/g, function($0, $1) { return $1 ? $0 : ""; });
pattern = pattern.replace(/(\\)?\\[cC]/g, function ($0, $1) { return $1 ? $0 : ""; });
// remove any modifer escape \
pattern = pattern.replace(/\\(\\[cCuU])/g, "$1");
@@ -106,7 +106,7 @@ vimperator.Search = function() //{{{
// Called when the search dialog is asked for
// If you omit "mode", it will default to forward searching
this.openSearchDialog = function(mode)
this.openSearchDialog = function (mode)
{
if (mode == vimperator.modes.SEARCH_BACKWARD)
{
@@ -124,7 +124,7 @@ vimperator.Search = function() //{{{
// Finds text in a page
// TODO: backwards seems impossible i fear :(
this.find = function(str, backwards)
this.find = function (str, backwards)
{
var fastFind = getBrowser().fastFind;
@@ -140,7 +140,7 @@ vimperator.Search = function() //{{{
}
// Called when the current search needs to be repeated
this.findAgain = function(reverse)
this.findAgain = function (reverse)
{
// this hack is needed to make n/N work with the correct string, if
// we typed /foo<esc> after the original search. Since searchString is
@@ -159,7 +159,7 @@ vimperator.Search = function() //{{{
{
// hack needed, because wrapping causes a "scroll" event which clears
// our command line
setTimeout(function() {
setTimeout(function () {
if (up)
vimperator.commandline.echo("search hit TOP, continuing at BOTTOM", vimperator.commandline.HL_WARNING);
else
@@ -176,7 +176,7 @@ vimperator.Search = function() //{{{
}
// Called when the user types a key in the search dialog. Triggers a find attempt if 'incsearch' is set
this.searchKeyPressed = function(command)
this.searchKeyPressed = function (command)
{
if (vimperator.options["incsearch"])
this.find(command, backwards);
@@ -184,7 +184,7 @@ vimperator.Search = function() //{{{
// Called when the enter key is pressed to trigger a search
// use forced_direction if you call this function directly
this.searchSubmitted = function(command, forced_backward)
this.searchSubmitted = function (command, forced_backward)
{
if (typeof forced_backward === "boolean")
backwards = forced_backward;
@@ -203,7 +203,7 @@ vimperator.Search = function() //{{{
// TODO: move to find() when reverse incremental searching is kludged in
// need to find again for reverse searching
if (backwards)
setTimeout(function() { self.findAgain(false); }, 0);
setTimeout(function () { self.findAgain(false); }, 0);
if (vimperator.options["hlsearch"])
this.highlight(search_string);
@@ -213,14 +213,14 @@ vimperator.Search = function() //{{{
// Called when the search is canceled - for example if someone presses
// escape while typing a search
this.searchCanceled = function()
this.searchCanceled = function ()
{
this.clear();
// TODO: code to reposition the document to the place before search started
}
// this is not dependent on the value of 'hlsearch'
this.highlight = function(text)
this.highlight = function (text)
{
// already highlighted?
if (window.content.document.getElementsByClassName("__mozilla-findbar-search").length > 0)
@@ -233,7 +233,7 @@ vimperator.Search = function() //{{{
gFindBar._highlightDoc("white", "black", text);
// TODO: seems fast enough for now...just
(function(win)
(function (win)
{
for (var i = 0; i < win.frames.length; i++)
arguments.callee(win.frames[i]);
@@ -248,7 +248,7 @@ vimperator.Search = function() //{{{
// TODO: remove highlighting from non-link matches (HTML - A/AREA with href attribute; XML - Xlink [type="simple"])
}
this.clear = function()
this.clear = function ()
{
gFindBar._highlightDoc();
// need to manually collapse the selection if the document is not

View File

@@ -26,7 +26,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.help = function(section, easter) //{{{
vimperator.help = function (section, easter) //{{{
{
if (easter)
{
@@ -255,7 +255,7 @@ vimperator.help = function(section, easter) //{{{
}
// FIXME
setTimeout(function() {
setTimeout(function () {
if (section)
{
function findSectionElement(section)

View File

@@ -26,7 +26,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.Hints = function() //{{{
vimperator.Hints = function () //{{{
{
var submode = ""; // used for extended mode, can be "o", "t", "y", etc.
var hintString = ""; // the typed string part of the hint is in this string
@@ -383,13 +383,13 @@ vimperator.Hints = function() //{{{
// USE THIS FOR MAKING THE SELECTED ELEM RED
// firstElem.style.backgroundColor = "red";
// firstElem.style.color = "white";
// setTimeout(function() {
// setTimeout(function () {
// firstElem.style.backgroundColor = firstElemBgColor;
// firstElem.style.color = firstElemColor;
// }, 200);
// OR USE THIS FOR BLINKING:
// var counter = 0;
// var id = setInterval(function() {
// var id = setInterval(function () {
// firstElem.style.backgroundColor = "red";
// if (counter % 2 == 0)
// firstElem.style.backgroundColor = "yellow";
@@ -403,7 +403,7 @@ vimperator.Hints = function() //{{{
// clearTimeout(id);
// }
// }, 100);
setTimeout(function() {
setTimeout(function () {
firstElem.style.backgroundColor = firstElemBgColor;
firstElem.style.color = firstElemColor;
}, timeout);
@@ -427,7 +427,7 @@ vimperator.Hints = function() //{{{
var first_href = valid_hints[0].getAttribute("href") || null;
if (first_href)
{
if (valid_hints.some( function(e) { return e.getAttribute("href") != first_href; } ))
if (valid_hints.some( function (e) { return e.getAttribute("href") != first_href; } ))
return false;
}
else if (valid_hints.length > 1)
@@ -458,7 +458,7 @@ vimperator.Hints = function() //{{{
if (vimperator.modes.extended & vimperator.modes.ALWAYS_HINT)
{
setTimeout(function() {
setTimeout(function () {
canUpdate = true;
hintString = "";
hintNumber = 0;
@@ -467,7 +467,7 @@ vimperator.Hints = function() //{{{
}
else
{
setTimeout( function() {
setTimeout( function () {
if (vimperator.mode == vimperator.modes.HINTS)
vimperator.modes.reset(false);
}, timeout);
@@ -481,7 +481,7 @@ vimperator.Hints = function() //{{{
////////////////////////////////////////////////////////////////////////////////
// TODO: implement framesets
this.show = function(mode, minor, filter)
this.show = function (mode, minor, filter)
{
if (mode == vimperator.modes.EXTENDED_HINT && !/^[;asoOtTwWyY]$/.test(minor))
{
@@ -520,12 +520,12 @@ vimperator.Hints = function() //{{{
return true;
};
this.hide = function()
this.hide = function ()
{
removeHints(0);
};
this.onEvent = function(event)
this.onEvent = function (event)
{
var key = vimperator.events.toString(event);
var followFirst = false;
@@ -653,7 +653,7 @@ vimperator.Hints = function() //{{{
{
var timeout = vimperator.options["hinttimeout"];
if (timeout > 0)
activeTimeout = setTimeout(function() { processHints(true); }, timeout);
activeTimeout = setTimeout(function () { processHints(true); }, timeout);
return false;
}

View File

@@ -27,7 +27,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.IO = function()
vimperator.IO = function ()
{
var environment_service = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment);
@@ -43,7 +43,7 @@ vimperator.IO = function()
MODE_SYNC: 0x40,
MODE_EXCL: 0x80,
expandPath: function(path)
expandPath: function (path)
{
const WINDOWS = navigator.platform == "Win32";
@@ -84,7 +84,7 @@ vimperator.IO = function()
return path;
},
getPluginDir: function()
getPluginDir: function ()
{
var plugin_dir;
@@ -98,7 +98,7 @@ vimperator.IO = function()
return plugin_dir.exists() && plugin_dir.isDirectory() ? plugin_dir : null;
},
getRCFile: function()
getRCFile: function ()
{
var rc_file1 = this.getFile(this.expandPath("~/.vimperatorrc"));
var rc_file2 = this.getFile(this.expandPath("~/_vimperatorrc"));
@@ -116,7 +116,7 @@ vimperator.IO = function()
// return a nsILocalFile for path where you can call isDirectory(), etc. on
// caller must check with .exists() if the returned file really exists
getFile: function(path)
getFile: function (path)
{
var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
@@ -127,7 +127,7 @@ vimperator.IO = function()
// TODO: make secure
// returns a nsILocalFile or null if it could not be created
createTempFile: function()
createTempFile: function ()
{
var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
@@ -150,7 +150,7 @@ vimperator.IO = function()
},
// file is either a full pathname or an instance of file instanceof nsILocalFile
readDirectory: function(file)
readDirectory: function (file)
{
if (typeof file == "string")
file = this.getFile(file);
@@ -175,7 +175,7 @@ vimperator.IO = function()
// file is either a full pathname or an instance of file instanceof nsILocalFile
// reads a file in "text" mode and returns the string
readFile: function(file)
readFile: function (file)
{
var ifstream = Components.classes["@mozilla.org/network/file-input-stream;1"]
.createInstance(Components.interfaces.nsIFileInputStream);
@@ -206,7 +206,7 @@ vimperator.IO = function()
// file is either a full pathname or an instance of file instanceof nsILocalFile
// default permission = 0644, only used when creating a new file, does not change permissions if the file exists
// mode can be ">" or ">>" in addition to the normal MODE_* flags
writeFile: function(file, buf, mode, perms)
writeFile: function (file, buf, mode, perms)
{
var ofstream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);

File diff suppressed because it is too large Load Diff

View File

@@ -26,7 +26,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.modes = (function()
vimperator.modes = (function ()
{
var main = 1; // NORMAL
var extended = 0; // NONE
@@ -143,12 +143,12 @@ vimperator.modes = (function()
MENU: 1 << 18, // a popupmenu is active
LINE: 1 << 19, // linewise visual mode
reset: function(silent)
reset: function (silent)
{
this.set(vimperator.modes.NORMAL, vimperator.modes.NONE, silent);
},
show: function()
show: function ()
{
if (!vimperator.options["showmode"])
return;
@@ -166,7 +166,7 @@ vimperator.modes = (function()
// helper function to set both modes in one go
// if silent == true, you also need to take care of the mode handling changes yourself
set: function(main_mode, extended_mode, silent)
set: function (main_mode, extended_mode, silent)
{
// if a main mode is set, the extended is always cleared
if (typeof main_mode === "number")
@@ -187,12 +187,12 @@ vimperator.modes = (function()
},
// add/remove always work on the extended mode only
add: function(mode)
add: function (mode)
{
extended |= mode;
this.show();
},
remove: function(mode)
remove: function (mode)
{
extended = (extended | mode) ^ mode;
this.show();

View File

@@ -26,7 +26,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.Option = function(names, type, extra_info) //{{{
vimperator.Option = function (names, type, extra_info) //{{{
{
if (!names || !type)
return null;
@@ -77,7 +77,7 @@ vimperator.Option = function(names, type, extra_info) //{{{
// NOTE: forced defaults need to use vimperator.options.getPref
this.__defineGetter__("value",
function()
function ()
{
if (this.getter)
this.getter.call(this);
@@ -85,7 +85,7 @@ vimperator.Option = function(names, type, extra_info) //{{{
}
);
this.__defineSetter__("value",
function(new_value)
function (new_value)
{
value = new_value;
if (this.setter)
@@ -96,7 +96,7 @@ vimperator.Option = function(names, type, extra_info) //{{{
// TODO: add is[Type]() queries for use in set()?
// : add isValid() or just throw an exception?
this.hasName = function(name)
this.hasName = function (name)
{
for (var i = 0; i < this.names.length; i++)
{
@@ -106,7 +106,7 @@ vimperator.Option = function(names, type, extra_info) //{{{
return false;
}
this.isValidValue = function(value)
this.isValidValue = function (value)
{
if (this.validator)
return this.validator(value);
@@ -114,13 +114,13 @@ vimperator.Option = function(names, type, extra_info) //{{{
return true;
}
this.reset = function()
this.reset = function ()
{
this.value = this.default_value;
}
} //}}}
vimperator.Options = function() //{{{
vimperator.Options = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -312,12 +312,12 @@ vimperator.Options = function() //{{{
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
this.__iterator__ = function()
this.__iterator__ = function ()
{
return optionsIterator();
}
this.get = function(name)
this.get = function (name)
{
for (var i = 0; i < options.length; i++)
{
@@ -327,14 +327,14 @@ vimperator.Options = function() //{{{
return null;
}
this.add = function(option)
this.add = function (option)
{
this.__defineGetter__(option.name, function() { return option.value; });
this.__defineSetter__(option.name, function(value) { option.value = value; });
this.__defineGetter__(option.name, function () { return option.value; });
this.__defineSetter__(option.name, function (value) { option.value = value; });
options.push(option);
}
this.destroy = function()
this.destroy = function ()
{
// reset some modified firefox prefs
if (loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit")
@@ -342,7 +342,7 @@ vimperator.Options = function() //{{{
storePreference("dom.popup_allowed_events", popup_allowed_events);
}
this.list = function(only_non_default)
this.list = function (only_non_default)
{
// TODO: columns like Vim?
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
@@ -385,7 +385,7 @@ vimperator.Options = function() //{{{
}
// this hack is only needed, because we need to do asynchronous loading of the .vimperatorrc
this.setInitialGUI = function()
this.setInitialGUI = function ()
{
if (!guioptions_done)
this.get("guioptions").reset();
@@ -397,22 +397,22 @@ vimperator.Options = function() //{{{
// TODO: separate Preferences from Options? Would these utility functions
// be better placed in the 'core' vimperator namespace somewhere?
this.setPref = function(name, value)
this.setPref = function (name, value)
{
return storePreference(name, value, true);
}
this.getPref = function(name, forced_default)
this.getPref = function (name, forced_default)
{
return loadPreference(name, forced_default, true);
}
this.setFirefoxPref = function(name, value)
this.setFirefoxPref = function (name, value)
{
return storePreference(name, value);
}
this.getFirefoxPref = function(name, forced_default)
this.getFirefoxPref = function (name, forced_default)
{
return loadPreference(name, forced_default);
}
@@ -437,9 +437,9 @@ vimperator.Options = function() //{{{
"<li><b>paste</b>: <code class=\"mapping\">P</code> and <code class=\"mapping\">gP</code> mappings</li>" +
"</ul>",
default_value: "homepage,quickmark,tabopen,paste",
validator: function(value)
validator: function (value)
{
return value.split(",").every(function(item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); });
return value.split(",").every(function (item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); });
}
}
));
@@ -456,7 +456,7 @@ vimperator.Options = function() //{{{
"The order is important, so <code class=\"command\">:set complete=bs</code> would list bookmarks first, and then any available quick searches.<br/>" +
"Add <code class=\"option\">'sort'</code> to the <code class=\"option\">'wildoptions'</code> option if you want all entries sorted.",
default_value: "sfbh",
validator: function(value) { return !/[^sfbh]/.test(value); }
validator: function (value) { return !/[^sfbh]/.test(value); }
}
));
this.add(new vimperator.Option(["defsearch", "ds"], "string",
@@ -464,7 +464,7 @@ vimperator.Options = function() //{{{
short_help: "Set the default search engine",
help: "The default search engine is used in the <code class=\"command\">:[tab]open [arg]</code> command " +
"if [arg] neither looks like a URL or like a specified search engine/keyword.",
completer: function() { return [["foo", "bar"], ["shit", "blub"]]; },
completer: function () { return [["foo", "bar"], ["shit", "blub"]]; },
default_value: "google"
}
));
@@ -494,8 +494,8 @@ vimperator.Options = function() //{{{
this.add(new vimperator.Option(["fullscreen", "fs"], "boolean",
{
short_help: "Show the current window fullscreen",
setter: function(value) { window.fullScreen = value; },
getter: function() { return window.fullScreen; },
setter: function (value) { window.fullScreen = value; },
getter: function () { return window.fullScreen; },
default_value: false
}
));
@@ -508,9 +508,9 @@ vimperator.Options = function() //{{{
"<li><b>T</b>: toolbar</li>" +
"<li><b>b</b>: bookmark bar</li>" +
"</ul>",
setter: function(value) { setGuiOptions(value); },
setter: function (value) { setGuiOptions(value); },
default_value: "",
validator: function(value) { return !/[^mTb]/.test(value); }
validator: function (value) { return !/[^mTb]/.test(value); }
}
));
this.add(new vimperator.Option(["hinttimeout", "hto"], "number",
@@ -518,7 +518,7 @@ vimperator.Options = function() //{{{
short_help: "Automatically follow non unique numerical hint after {arg} ms",
help: "Set to 0 (the default) to only follow numeric hints after pressing &lt;Return&gt; or when the hint is unique.",
default_value: 0,
validator: function(value) { return value >= 0; }
validator: function (value) { return value >= 0; }
}
));
this.add(new vimperator.Option(["hintstyle", "hs"], "string",
@@ -537,7 +537,7 @@ vimperator.Options = function() //{{{
this.add(new vimperator.Option(["hlsearch", "hls"], "boolean",
{
short_help: "Highlight previous search pattern matches",
setter: function(value) { if (value) vimperator.search.highlight(); else vimperator.search.clear(); },
setter: function (value) { if (value) vimperator.search.highlight(); else vimperator.search.clear(); },
default_value: false
}
));
@@ -580,8 +580,8 @@ vimperator.Options = function() //{{{
"</ul>" +
"NOTE: laststatus=1 not implemented yet.",
default_value: 2,
setter: function(value) { setLastStatus(value); },
validator: function(value) { return (value >= 0 && value <= 2); }
setter: function (value) { setLastStatus(value); },
validator: function (value) { return (value >= 0 && value <= 2); }
}
));
this.add(new vimperator.Option(["linksearch", "lks"], "boolean",
@@ -624,8 +624,8 @@ vimperator.Options = function() //{{{
"</ul>" +
"NOTE: This option does not change the popup blocker of Firefox in any way.",
default_value: 1,
setter: function(value) { setPopups(value); },
validator: function(value) { return (value >= 0 && value <= 3); }
setter: function (value) { setPopups(value); },
validator: function (value) { return (value >= 0 && value <= 3); }
}
));
this.add(new vimperator.Option(["preload"], "boolean",
@@ -643,7 +643,7 @@ vimperator.Options = function() //{{{
"Close the preview window with <code class=\"command\">:pclose</code>.<br/>" +
"NOTE: Option currently disabled",
default_value: 10,
validator: function(value) { return (value >= 1 && value <= 50); }
validator: function (value) { return (value >= 1 && value <= 50); }
}
));
this.add(new vimperator.Option(["scroll", "scr"], "number",
@@ -653,7 +653,7 @@ vimperator.Options = function() //{{{
"When a <code class=\"argument\">{count}</code> is specified to the <code class=\"mapping\">&lt;C-u&gt;</code> or <code class=\"mapping\">&lt;C-d&gt;</code> commands this is used to set the value of <code class=\"option\">'scroll'</code> and also used for the current command. " +
"The value can be reset to half the window height with <code class=\"command\">:set scroll=0</code>.",
default_value: 0,
validator: function(value) { return value >= 0; }
validator: function (value) { return value >= 0; }
}
));
this.add(new vimperator.Option(["showmode", "smd"], "boolean",
@@ -673,7 +673,7 @@ vimperator.Options = function() //{{{
"<li><b>2</b>: Show the link in the command line</li>" +
"</ul>",
default_value: 1,
validator: function(value) { return (value >= 0 && value <= 2); }
validator: function (value) { return (value >= 0 && value <= 2); }
}
));
this.add(new vimperator.Option(["showtabline", "stal"], "number",
@@ -685,9 +685,9 @@ vimperator.Options = function() //{{{
"<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>",
setter: function(value) { setShowTabline(value); },
setter: function (value) { setShowTabline(value); },
default_value: 2,
validator: function(value) { return (value >= 0 && value <= 2); }
validator: function (value) { return (value >= 0 && value <= 2); }
}
));
this.add(new vimperator.Option(["smartcase", "scs"], "boolean",
@@ -703,7 +703,7 @@ vimperator.Options = function() //{{{
help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " +
"\"Title of web page - Vimperator\".<br/>If you don't like that, you can restore it with: " +
"<code class=\"command\">:set titlestring=Mozilla Firefox</code>.",
setter: function(value) { setTitleString(value); },
setter: function (value) { setTitleString(value); },
default_value: "Vimperator"
}
));
@@ -711,8 +711,8 @@ vimperator.Options = function() //{{{
{
short_help: "Show current website with a minimal style sheet to make it easily accessible",
help: "Note that this is a local option for now, later it may be split into a global and <code class=\"command\">:setlocal</code> part",
setter: function(value) { getMarkupDocumentViewer().authorStyleDisabled = value; },
getter: function() { return getMarkupDocumentViewer().authorStyleDisabled; },
setter: function (value) { getMarkupDocumentViewer().authorStyleDisabled = value; },
getter: function () { return getMarkupDocumentViewer().authorStyleDisabled; },
default_value: false
}
));
@@ -722,13 +722,13 @@ vimperator.Options = function() //{{{
help: "When bigger than zero, Vimperator will give messages about what it is doing. They are printed to the error console which can be shown with <code class=\"command\">:javascript!</code>.<br/>" +
"The highest value is 9, being the most verbose mode.",
default_value: 0,
validator: function(value) { return (value >= 0 && value <= 9); }
validator: function (value) { return (value >= 0 && value <= 9); }
}
));
this.add(new vimperator.Option(["visualbell", "vb"], "boolean",
{
short_help: "Use visual bell instead of beeping on errors",
setter: function(value) { vimperator.options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); },
setter: function (value) { vimperator.options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); },
default_value: false
}
));
@@ -750,9 +750,9 @@ vimperator.Options = function() //{{{
"</table>" +
"When there is only a single match, it is fully completed regardless of the case.",
default_value: "list:full",
validator: function(value)
validator: function (value)
{
return value.split(",").every(function(item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); });
return value.split(",").every(function (item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); });
}
}
));
@@ -765,7 +765,7 @@ vimperator.Options = function() //{{{
"<tr><td><b>sort</b></td><td>Always sorts completion list, overriding the <code class=\"option\">'complete'</code> option.</td></tr>" +
"</table>",
default_value: "",
validator: function(value) { return /^sort$/.test(value); }
validator: function (value) { return /^sort$/.test(value); }
}
));
//}}}

View File

@@ -32,7 +32,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
* Firefox 3.0, then this class should go away and their tab methods should be used
* @deprecated
*/
vimperator.Tabs = function() //{{{
vimperator.Tabs = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -87,7 +87,7 @@ vimperator.Tabs = function() //{{{
/////////////////////////////////////////////////////////////////////////////{{{
// @returns the index of the currently selected tab starting with 0
this.index = function(tab)
this.index = function (tab)
{
if (tab)
{
@@ -103,14 +103,14 @@ vimperator.Tabs = function() //{{{
return getBrowser().tabContainer.selectedIndex;
}
this.count = function()
this.count = function ()
{
return getBrowser().mTabs.length;
}
// TODO: implement filter
// @returns an array of tabs which match filter
this.get = function(filter)
this.get = function (filter)
{
var buffers = [];
var browsers = getBrowser().browsers;
@@ -124,7 +124,7 @@ vimperator.Tabs = function() //{{{
return buffers;
}
this.getTab = function(index)
this.getTab = function (index)
{
if (index)
return getBrowser().mTabs[index];
@@ -137,7 +137,7 @@ vimperator.Tabs = function() //{{{
* NOTE: position is a 0 based index
* FIXME: tabmove! N should probably produce an error
*/
this.move = function(tab, spec, wrap)
this.move = function (tab, spec, wrap)
{
if (spec === "")
spec = "$"; // if not specified, move to the last tab -> XXX: move to ex handling?
@@ -149,7 +149,7 @@ vimperator.Tabs = function() //{{{
/* quit_on_last_tab = 1: quit without saving session
* quit_on_last_tab = 2: quit and save session
*/
this.remove = function(tab, count, focus_left_tab, quit_on_last_tab)
this.remove = function (tab, count, focus_left_tab, quit_on_last_tab)
{
function removeOrBlankTab (tab)
{
@@ -203,12 +203,12 @@ vimperator.Tabs = function() //{{{
}
}
this.keepOnly = function(tab)
this.keepOnly = function (tab)
{
getBrowser().removeAllTabsBut(tab);
}
this.select = function(spec, wrap)
this.select = function (spec, wrap)
{
var index = indexFromSpec(spec, wrap);
if (index === false)
@@ -223,7 +223,7 @@ vimperator.Tabs = function() //{{{
// tab that was selected when the session was created. As a result the
// alternate after a restart is often incorrectly tab 1 when there
// shouldn't be one yet.
this.updateSelectionHistory = function()
this.updateSelectionHistory = function ()
{
alternates = [this.getTab(), alternates[0]];
this.alternate = alternates[1];
@@ -232,7 +232,7 @@ vimperator.Tabs = function() //{{{
// TODO: move to v.buffers
this.alternate = this.getTab();
this.reload = function(tab, bypass_cache)
this.reload = function (tab, bypass_cache)
{
if (bypass_cache)
{
@@ -246,7 +246,7 @@ vimperator.Tabs = function() //{{{
}
}
this.reloadAll = function(bypass_cache)
this.reloadAll = function (bypass_cache)
{
if (bypass_cache)
{

View File

@@ -32,7 +32,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
* it consists of a prompt and command field
* be sure to only create objects of this class when the chrome is ready
*/
vimperator.CommandLine = function() //{{{
vimperator.CommandLine = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -51,22 +51,22 @@ vimperator.CommandLine = function() //{{{
cmd: null, // ex command history
search: null, // text search history
get: function() { return this[this._mode]; },
set: function(lines) { this[this._mode] = lines; },
get: function () { return this[this._mode]; },
set: function (lines) { this[this._mode] = lines; },
load: function()
load: function ()
{
this.cmd = vimperator.options.getPref("commandline_cmd_history", "").split("\n");
this.search = vimperator.options.getPref("commandline_search_history", "").split("\n");
},
save: function()
save: function ()
{
vimperator.options.setPref("commandline_cmd_history", this.cmd.join("\n"));
vimperator.options.setPref("commandline_search_history", this.search.join("\n"));
},
add: function(str)
add: function (str)
{
if (!str)
return;
@@ -74,7 +74,7 @@ vimperator.CommandLine = function() //{{{
var lines = this.get();
// remove all old history lines which have this string
lines = lines.filter(function(line) {
lines = lines.filter(function (line) {
return line != str;
});
@@ -251,12 +251,12 @@ vimperator.CommandLine = function() //{{{
// FORCE_MULTILINE is given, FORCE_MULTILINE takes precedence
this.APPEND_TO_MESSAGES = 1 << 3; // will show the string in :messages
this.getCommand = function()
this.getCommand = function ()
{
return command_widget.value;
};
this.open = function(prompt, cmd, ext_mode)
this.open = function (prompt, cmd, ext_mode)
{
// save the current prompts, we need it later if the command widget
// receives focus without calling the this.open() method
@@ -279,7 +279,7 @@ vimperator.CommandLine = function() //{{{
};
// normally used when pressing esc, does not execute a command
this.close = function()
this.close = function ()
{
var res = vimperator.triggerCallback("cancel", cur_extended_mode);
history.add(this.getCommand());
@@ -287,7 +287,7 @@ vimperator.CommandLine = function() //{{{
this.clear();
}
this.clear = function()
this.clear = function ()
{
multiline_input_widget.collapsed = true;
multiline_output_widget.collapsed = true;
@@ -298,7 +298,7 @@ vimperator.CommandLine = function() //{{{
// TODO: add :messages entry
// vimperator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst
this.echo = function(str, highlight_group, flags)
this.echo = function (str, highlight_group, flags)
{
var focused = document.commandDispatcher.focusedElement;
if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField)
@@ -331,7 +331,7 @@ vimperator.CommandLine = function() //{{{
// this will prompt the user for a string
// vimperator.commandline.input("(s)ave or (o)pen the file?")
this.input = function(str)
this.input = function (str)
{
// TODO: unfinished, need to find out how/if we can block the execution of code
// to make this code synchronous or at least use a callback
@@ -342,7 +342,7 @@ vimperator.CommandLine = function() //{{{
// reads a multi line input and returns the string once the last line matches
// @param until_regexp
this.inputMultiline = function(until_regexp, callback_func)
this.inputMultiline = function (until_regexp, callback_func)
{
// save the mode, because we need to restore it
old_mode = vimperator.mode;
@@ -357,19 +357,19 @@ vimperator.CommandLine = function() //{{{
multiline_input_widget.value = "";
autosizeMultilineInputWidget();
setTimeout(function() {
setTimeout(function () {
multiline_input_widget.focus();
}, 10);
};
this.onEvent = function(event)
this.onEvent = function (event)
{
var command = this.getCommand();
if (event.type == "blur")
{
// prevent losing focus, there should be a better way, but it just didn't work otherwise
setTimeout(function() {
setTimeout(function () {
if (vimperator.mode == vimperator.modes.COMMAND_LINE &&
!(vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE) &&
!(vimperator.modes.extended & vimperator.modes.OUTPUT_MULTILINE))
@@ -484,7 +484,7 @@ vimperator.CommandLine = function() //{{{
// sort the completion list
if (vimperator.options["wildoptions"].search(/\bsort\b/) > -1)
{
completions.sort(function(a, b) {
completions.sort(function (a, b) {
if (a[0] < b[0])
return -1;
else if (a[0] > b[0])
@@ -598,7 +598,7 @@ vimperator.CommandLine = function() //{{{
}
}
this.onMultilineInputEvent = function(event)
this.onMultilineInputEvent = function (event)
{
if (event.type == "keypress")
{
@@ -623,7 +623,7 @@ vimperator.CommandLine = function() //{{{
else if (event.type == "blur")
{
if (vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE)
setTimeout(function() { multiline_input_widget.inputField.focus(); }, 0);
setTimeout(function () { multiline_input_widget.inputField.focus(); }, 0);
}
else if (event.type == "input")
{
@@ -633,7 +633,7 @@ vimperator.CommandLine = function() //{{{
// FIXME: if 'more' is set and the MOW is not scrollable we should still
// allow a down motion after an up rather than closing
this.onMultilineOutputEvent = function(event)
this.onMultilineOutputEvent = function (event)
{
var win = multiline_output_widget.contentWindow;
@@ -829,7 +829,7 @@ vimperator.CommandLine = function() //{{{
}
// it would be better if we had a destructor in javascript ...
this.destroy = function()
this.destroy = function ()
{
history.save();
}
@@ -842,7 +842,7 @@ vimperator.CommandLine = function() //{{{
* @param id: the id of the the XUL widget which we want to fill
* @param options: an optional hash which modifies the behavior of the list
*/
vimperator.InformationList = function(id, options) //{{{
vimperator.InformationList = function (id, options) //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -942,7 +942,7 @@ vimperator.InformationList = function(id, options) //{{{
* use entries of 'compl' to fill the list.
* Required format: [["left", "right"], ["another"], ["completion"]]
*/
this.show = function(compl)
this.show = function (compl)
{
//max_items = vimperator.options["previewheight"];
@@ -968,12 +968,12 @@ vimperator.InformationList = function(id, options) //{{{
}
}
this.hide = function()
this.hide = function ()
{
widget.hidden = true;
}
this.visible = function()
this.visible = function ()
{
return !widget.hidden;
}
@@ -981,7 +981,7 @@ vimperator.InformationList = function(id, options) //{{{
/**
* select index, refill list if necessary
*/
this.selectItem = function(index)
this.selectItem = function (index)
{
if (widget.hidden)
return;
@@ -1029,7 +1029,7 @@ vimperator.InformationList = function(id, options) //{{{
widget.selectedIndex = index - list_offset;
}
this.onEvent = function(event)
this.onEvent = function (event)
{
var listcells = document.getElementsByTagName("listcell");
// 2 columns for now, use the first column
@@ -1045,7 +1045,7 @@ vimperator.InformationList = function(id, options) //{{{
//}}}
} //}}}
vimperator.StatusLine = function() //{{{
vimperator.StatusLine = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -1065,7 +1065,7 @@ vimperator.StatusLine = function() //{{{
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
this.setClass = function(type)
this.setClass = function (type)
{
var highlight_group;
@@ -1086,7 +1086,7 @@ vimperator.StatusLine = function() //{{{
};
// update all fields of the statusline
this.update = function()
this.update = function ()
{
this.updateUrl();
this.updateInputBuffer();
@@ -1096,7 +1096,7 @@ vimperator.StatusLine = function() //{{{
}
// if "url" is ommited, build a usable string for the URL
this.updateUrl = function(url)
this.updateUrl = function (url)
{
if (typeof url == "string")
{
@@ -1130,7 +1130,7 @@ vimperator.StatusLine = function() //{{{
url_widget.value = url;
};
this.updateInputBuffer = function(buffer)
this.updateInputBuffer = function (buffer)
{
if (!buffer || typeof buffer != "string")
buffer = "";
@@ -1138,7 +1138,7 @@ vimperator.StatusLine = function() //{{{
inputbuffer_widget.value = buffer;
};
this.updateProgress = function(progress)
this.updateProgress = function (progress)
{
if (!progress)
progress = "";
@@ -1169,7 +1169,7 @@ vimperator.StatusLine = function() //{{{
};
// you can omit either of the 2 arguments
this.updateTabCount = function(cur_index, total_tabs)
this.updateTabCount = function (cur_index, total_tabs)
{
if (!cur_index || typeof cur_index != "number")
cur_index = vimperator.tabs.index() + 1;
@@ -1180,7 +1180,7 @@ vimperator.StatusLine = function() //{{{
};
// percent is given between 0 and 1
this.updateBufferPosition = function(percent)
this.updateBufferPosition = function (percent)
{
if (!percent || typeof percent != "number")
{
@@ -1189,7 +1189,7 @@ vimperator.StatusLine = function() //{{{
}
var bufferposition_str = "";
percent = Math.round(percent*100);
percent = Math.round(percent * 100);
if (percent < 0) bufferposition_str = "All";
else if (percent == 0) bufferposition_str = "Top";
else if (percent < 10) bufferposition_str = " " + percent + "%";

View File

@@ -27,7 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/
vimperator.util = {
escapeHTML: function(str)
escapeHTML: function (str)
{
// XXX: the following code is _much_ slower than a simple .replace()
// :history display went down from 2 to 1 second after changing
@@ -41,7 +41,7 @@ vimperator.util = {
// TODO: use :highlight color groups
// if "process_strings" is true, any passed strings will be surrounded by " and
// any line breaks are displayed as \n
colorize: function(arg, process_strings)
colorize: function (arg, process_strings)
{
var type = typeof(arg);
@@ -91,7 +91,7 @@ vimperator.util = {
// takes a string like 'google bla, www.osnews.com'
// and returns an array ['www.google.com/search?q=bla', 'www.osnews.com']
stringToURLArray: function(str)
stringToURLArray: function (str)
{
var urls = str.split(/\s*\,\s+/);
@@ -166,7 +166,7 @@ vimperator.util = {
return urls;
},
highlightURL: function(str, force)
highlightURL: function (str, force)
{
if (force || /^[a-zA-Z]+:\/\/.*\//.test(str))
return "<a class='hl-URL' href='" + str + "'>" + vimperator.util.escapeHTML(str) + "</a>";
@@ -174,7 +174,7 @@ vimperator.util = {
return str;
},
formatNumber: function(num)
formatNumber: function (num)
{
var strNum = (num + "").split(".", 2);

View File

@@ -26,7 +26,7 @@ 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.
}}} ***** END LICENSE BLOCK *****/
const vimperator = (function() //{{{
const vimperator = (function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -72,13 +72,13 @@ const vimperator = (function() //{{{
// "cancel"
// "complete"
// TODO: "zoom": if the zoom value of the current buffer changed
registerCallback: function(type, mode, func)
registerCallback: function (type, mode, func)
{
// TODO: check if callback is already registered
callbacks.push([type, mode, func]);
},
triggerCallback: function(type, mode, data)
triggerCallback: function (type, mode, data)
{
// dump("type: " + type + " mode: " + mode + "data: " + data + "\n");
for (var i in callbacks)
@@ -90,7 +90,7 @@ const vimperator = (function() //{{{
return false;
},
beep: function()
beep: function ()
{
if (vimperator.options["visualbell"])
{
@@ -102,7 +102,7 @@ const vimperator = (function() //{{{
popup.height = box.height;
popup.width = box.width;
popup.openPopup(win, "overlap", 0, 0, false, false);
setTimeout(function() { popup.hidePopup(); }, 50);
setTimeout(function () { popup.hidePopup(); }, 50);
}
else
{
@@ -110,14 +110,14 @@ const vimperator = (function() //{{{
}
},
copyToClipboard: function(str)
copyToClipboard: function (str)
{
var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
clipboardHelper.copyString(str);
},
execute: function(str, modifiers)
execute: function (str, modifiers)
{
// skip comments and blank lines
if (/^\s*("|$)/.test(str))
@@ -149,7 +149,7 @@ const vimperator = (function() //{{{
// after pressing Escape, put focus on a non-input field of the browser document
// if clearFocusedElement, also blur a focused link
focusContent: function(clearFocusedElement)
focusContent: function (clearFocusedElement)
{
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
getService(Components.interfaces.nsIWindowWatcher);
@@ -161,7 +161,7 @@ const vimperator = (function() //{{{
},
// partial sixth level expression evaluation
eval: function(string)
eval: function (string)
{
string = string.toString().replace(/^\s*/, "").replace(/\s*$/, "");
var match = string.match(/^&(\w+)/);
@@ -207,7 +207,7 @@ const vimperator = (function() //{{{
return;
},
variableReference: function(string)
variableReference: function (string)
{
if (!string)
return [null, null, null];
@@ -235,7 +235,7 @@ const vimperator = (function() //{{{
// TODO: move to vimp.util.? --mst
// if color = true it uses HTML markup to color certain items
objectToString: function(object, color)
objectToString: function (object, color)
{
if (object === null)
return "null";
@@ -286,7 +286,7 @@ const vimperator = (function() //{{{
// logs a message to the javascript error console
// if msg is an object, it is beautified
log: function(msg, level)
log: function (msg, level)
{
//if (vimperator.options.getPref("verbose") >= level) // FIXME: hangs vimperator, probably timing issue --mst
if (typeof msg == "object")
@@ -305,7 +305,7 @@ const vimperator = (function() //{{{
// @param callback: not implemented, will be allowed to specify a callback function
// which is called, when the page finished loading
// @returns true when load was initiated, or false on error
open: function(urls, where, callback)
open: function (urls, where, callback)
{
// convert the string to an array of converted URLs
// -> see vimperator.util.stringToURLArray for more details
@@ -365,7 +365,7 @@ const vimperator = (function() //{{{
},
// quit vimperator, no matter how many tabs/windows are open
quit: function(save_session)
quit: function (save_session)
{
if (save_session)
vimperator.options.setFirefoxPref("browser.startup.page", 3); // start with saved session
@@ -375,7 +375,7 @@ const vimperator = (function() //{{{
goQuitApplication();
},
restart: function()
restart: function ()
{
const nsIAppStartup = Components.interfaces.nsIAppStartup;
@@ -407,7 +407,7 @@ const vimperator = (function() //{{{
.quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
},
run: function(program, args, blocking)
run: function (program, args, blocking)
{
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
const WINDOWS = navigator.platform == "Win32";
@@ -487,15 +487,15 @@ const vimperator = (function() //{{{
filein.remove(false);
// if there is only one \n at the end, chop it off
if (output && output.indexOf("\n") == output.length-1)
output = output.substr(0, output.length-1);
if (output && output.indexOf("\n") == output.length - 1)
output = output.substr(0, output.length - 1);
return output;
},
// files which end in .js are sourced as pure javascript files,
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
source: function(filename, silent)
source: function (filename, silent)
{
filename = vimperator.io.expandPath(filename);
@@ -519,7 +519,7 @@ const vimperator = (function() //{{{
{
var heredoc = "";
var heredoc_end = null; // the string which ends the heredoc
str.split("\n").forEach(function(line)
str.split("\n").forEach(function (line)
{
if (heredoc_end) // we already are in a heredoc
{
@@ -571,7 +571,7 @@ const vimperator = (function() //{{{
}
},
startup: function()
startup: function ()
{
window.dump("Vimperator startup\n");
vimperator.log("Initializing vimperator object...", 1);
@@ -617,19 +617,19 @@ const vimperator = (function() //{{{
vimperator.completion = new vimperator.Completion();
vimperator.log("All modules loaded", 3);
vimperator.echo = function(str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); };
vimperator.echoerr = function(str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_ERRORMSG, flags); };
vimperator.echo = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); };
vimperator.echoerr = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_ERRORMSG, flags); };
vimperator.globalVariables = {};
// TODO: move elsewhere
vimperator.registerCallback("submit", vimperator.modes.EX, function(command) { vimperator.execute(command); } );
vimperator.registerCallback("complete", vimperator.modes.EX, function(str) { return vimperator.completion.exTabCompletion(str); } );
vimperator.registerCallback("submit", vimperator.modes.EX, function (command) { vimperator.execute(command); } );
vimperator.registerCallback("complete", vimperator.modes.EX, function (str) { return vimperator.completion.exTabCompletion(str); } );
// first time intro message
if (vimperator.options.getPref("firsttime", true))
{
setTimeout(function() {
setTimeout(function () {
vimperator.help(null, null, null, { inTab: true });
vimperator.options.setPref("firsttime", false);
}, 1000);
@@ -644,7 +644,7 @@ const vimperator = (function() //{{{
// finally, read a ~/.vimperatorrc
// make sourcing asynchronous, otherwise commands that open new tabs won't work
setTimeout(function() {
setTimeout(function () {
var rc_file = vimperator.io.getRCFile();
@@ -661,7 +661,7 @@ const vimperator = (function() //{{{
{
var files = vimperator.io.readDirectory(plugin_dir.path);
vimperator.log("Sourcing plugin directory...", 3);
files.forEach(function(file) {
files.forEach(function (file) {
if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path))
vimperator.source(file.path, false);
});
@@ -687,7 +687,7 @@ const vimperator = (function() //{{{
vimperator.log("Vimperator fully initialized", 1);
},
shutdown: function()
shutdown: function ()
{
window.dump("Vimperator shutdown\n");
@@ -700,7 +700,7 @@ const vimperator = (function() //{{{
window.dump("All vimperator modules destroyed\n");
},
sleep: function(ms)
sleep: function (ms)
{
var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
var mainThread = threadManager.mainThread;
@@ -723,15 +723,15 @@ const vimperator = (function() //{{{
},
// be sure to call GUI related methods like alert() or dump() ONLY in the main thread
callFunctionInThread: function(thread, func, args)
callFunctionInThread: function (thread, func, args)
{
function CallbackEvent (func, args)
function CallbackEvent(func, args)
{
if (!(args instanceof Array))
args = [];
return {
QueryInterface: function(iid)
QueryInterface: function (iid)
{
if (iid.equals(Components.interfaces.nsIRunnable) ||
iid.equals(Components.interfaces.nsISupports))
@@ -739,7 +739,7 @@ const vimperator = (function() //{{{
throw Components.results.NS_ERROR_NO_INTERFACE;
},
run: function()
run: function ()
{
func.apply(window, args);
}