From 1bd4543ea36b7022bc18ce7a62e49db1aa7ae4ab Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sun, 11 Nov 2007 03:21:27 +0000 Subject: [PATCH] whitespace formatting fixes --- content/bookmarks.js | 66 ++++++------ content/buffers.js | 56 +++++------ content/commands.js | 192 +++++++++++++++++------------------ content/completion.js | 60 +++++------ content/events.js | 54 +++++----- content/find.js | 42 ++++---- content/help.js | 6 +- content/hints.js | 30 +++--- content/io.js | 18 ++-- content/mappings.js | 228 +++++++++++++++++++++--------------------- content/options.js | 92 ++++++++--------- content/tabs.js | 24 ++--- content/test.js | 2 +- content/ui.js | 72 ++++++------- content/util.js | 10 +- content/vimperator.js | 73 +++++++------- 16 files changed, 514 insertions(+), 511 deletions(-) diff --git a/content/bookmarks.js b/content/bookmarks.js index 6c9cb994..9d473305 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -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 ///////////////////////////////////////// @@ -42,7 +42,7 @@ vimperator.Bookmarks = function() //{{{ var keywords = null; if (vimperator.options["preload"]) - setTimeout(function() { load(); } , 100); + setTimeout(function () { load(); } , 100); function load() { @@ -78,7 +78,7 @@ vimperator.Bookmarks = function() //{{{ // FIXME: add filtering here rather than having to calling // get_bookmark_completions() - this.get = function() + this.get = function () { if (!bookmarks) load(); @@ -105,7 +105,7 @@ vimperator.Bookmarks = function() //{{{ // NOTE: no idea what it does, it Just Works (TM) // returns number of deleted bookmarks - this.remove = function(url) + this.remove = function (url) { var deleted = 0; if (!url) @@ -157,7 +157,7 @@ vimperator.Bookmarks = function() //{{{ } // 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({ }); @@ -173,7 +173,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; @@ -190,7 +190,7 @@ vimperator.Bookmarks = function() //{{{ // format of returned array: // [keyword, helptext, url] - this.getKeywords = function() + this.getKeywords = function () { if (!keywords) load(); @@ -201,7 +201,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; @@ -249,7 +249,7 @@ vimperator.Bookmarks = function() //{{{ return url; // can be null } - this.list = function(filter, fullmode) + this.list = function (filter, fullmode) { if (fullmode) { @@ -290,7 +290,7 @@ vimperator.Bookmarks = function() //{{{ // res.title is the title or "" if no one was given // res.url is the url as a string // returns null, if parsing failed - this.parseBookmarkString = function(str) + this.parseBookmarkString = function (str) { var res = {}; res.tags = []; @@ -356,7 +356,7 @@ vimperator.Bookmarks = function() //{{{ //}}} } //}}} -vimperator.History = function() //{{{ +vimperator.History = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -370,7 +370,7 @@ vimperator.History = function() //{{{ var history = null; if (vimperator.options["preload"]) - setTimeout(function() { load(); } , 100); + setTimeout(function () { load(); } , 100); function load() { @@ -418,7 +418,7 @@ vimperator.History = function() //{{{ // FIXME: add filtering here rather than having to call // get_bookmark_completions() - this.get = function() + this.get = function () { if (!history) load(); @@ -431,7 +431,7 @@ vimperator.History = function() //{{{ if (!history) load(); - history = history.filter(function(elem) { + history = history.filter(function (elem) { return elem[0] != url; }); @@ -441,7 +441,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; @@ -455,7 +455,7 @@ vimperator.History = function() //{{{ } } - this.goToStart = function() + this.goToStart = function () { var index = getWebNavigation().sessionHistory.index; @@ -468,7 +468,7 @@ vimperator.History = function() //{{{ getWebNavigation().gotoIndex(0); } - this.goToEnd = function() + this.goToEnd = function () { var index = getWebNavigation().sessionHistory.index; var max = getWebNavigation().sessionHistory.count - 1; @@ -482,7 +482,7 @@ vimperator.History = function() //{{{ getWebNavigation().gotoIndex(max); } - this.list = function(filter, fullmode) + this.list = function (filter, fullmode) { if (fullmode) { @@ -519,7 +519,7 @@ vimperator.History = function() //{{{ //}}} } //}}} -vimperator.Marks = function() //{{{ +vimperator.Marks = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -608,7 +608,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]) @@ -625,7 +625,7 @@ vimperator.Marks = function() //{{{ /////////////////////////////////////////////////////////////////////////////{{{ // TODO: add support for frameset pages - this.add = function(mark) + this.add = function (mark) { var win = window.content; @@ -655,7 +655,7 @@ vimperator.Marks = function() //{{{ } } - this.remove = function(filter, special) + this.remove = function (filter, special) { if (special) { @@ -679,7 +679,7 @@ vimperator.Marks = function() //{{{ } } - this.jumpTo = function(mark) + this.jumpTo = function (mark) { var ok = false; @@ -733,7 +733,7 @@ vimperator.Marks = function() //{{{ vimperator.echoerr("E20: Mark not set"); // FIXME: move up? } - this.list = function(filter) + this.list = function (filter) { var marks = getSortedMarks(); @@ -745,7 +745,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; }); @@ -774,7 +774,7 @@ vimperator.Marks = function() //{{{ //}}} } //}}} -vimperator.QuickMarks = function() //{{{ +vimperator.QuickMarks = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -793,12 +793,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, "") + "]"); @@ -809,12 +809,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]; @@ -824,7 +824,7 @@ vimperator.QuickMarks = function() //{{{ vimperator.echoerr("E20: QuickMark not set"); } - this.list = function(filter) + this.list = function (filter) { var marks = []; @@ -841,7 +841,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; }); @@ -864,7 +864,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 = ""; diff --git a/content/buffers.js b/content/buffers.js index b7269632..f09331bf 100644 --- a/content/buffers.js +++ b/content/buffers.js @@ -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 ///////////////////////////////////////// @@ -116,35 +116,35 @@ vimperator.Buffer = function() //{{{ ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - 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 zoom_manager.textZoom; }); - this.__defineSetter__("textZoom", function(value) + this.__defineSetter__("textZoom", function (value) { setZoom(value); }); - this.__defineGetter__("title", function() + this.__defineGetter__("title", function () { return window.content.document.title; }); // returns an XPathResult object - this.evaluateXPath = function(expression, doc, elem, ordered) + this.evaluateXPath = function (expression, doc, elem, ordered) { if (!doc) doc = window.content.document; @@ -167,7 +167,7 @@ vimperator.Buffer = function() //{{{ return result; } - this.list = function(fullmode) + this.list = function (fullmode) { if (fullmode) { @@ -214,12 +214,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; @@ -230,42 +230,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; @@ -273,7 +273,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); @@ -287,7 +287,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; @@ -360,11 +360,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; @@ -377,7 +377,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) { @@ -428,23 +428,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) + this.zoomIn = function (steps) { bumpZoomLevel(steps); } - this.zoomOut = function(steps) + this.zoomOut = function (steps) { bumpZoomLevel(-steps); } - this.pageInfo = function(verbose) + this.pageInfo = function (verbose) { // TODO: copied from firefox. Needs some review/work... // const feedTypes = { @@ -481,7 +481,7 @@ vimperator.Buffer = function() //{{{ urlSecurityCheck(aData.href, aPrincipal, Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL); } - catch(ex) + catch (ex) { aIsFeed = false; } @@ -497,7 +497,7 @@ vimperator.Buffer = function() //{{{ function createTable(data) { var ret = ""; + data[data.length - 1][0] + ""; if (data.length - 1) { diff --git a/content/commands.js b/content/commands.js index 99140a66..1f1a6f9e 100644 --- a/content/commands.js +++ b/content/commands.js @@ -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 = []; @@ -89,14 +89,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) { 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 @@ -126,7 +126,7 @@ vimperator.Command.prototype.hasName = function(name) } //}}} -vimperator.Commands = function() //{{{ +vimperator.Commands = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -138,7 +138,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); } @@ -156,12 +156,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; @@ -171,7 +171,7 @@ vimperator.Commands = function() //{{{ return true; } - this.get = function(name) + this.get = function (name) { for (var i = 0; i < ex_commands.length; i++) { @@ -186,7 +186,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*".*$/, ""); @@ -230,14 +230,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.
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(); @@ -263,7 +263,7 @@ vimperator.Commands = function() //{{{ short_help: "Go back in the browser history", help: "Count is supported, :3back goes back 3 pages in the browser history.
" + "The special version :back! goes to the beginning of the browser history.", - completer: function(filter) + completer: function (filter) { var sh = getWebNavigation().sessionHistory; var completions = []; @@ -280,7 +280,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)", @@ -289,7 +289,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["beep"], - function() { vimperator.beep(); }, + function () { vimperator.beep(); }, { short_help: "Play a system beep" } @@ -297,7 +297,7 @@ vimperator.Commands = function() //{{{ addDefaultCommand(new vimperator.Command(["bma[rk]"], // takes: -t "foo" myurl // converts that string to a useful url and title, and calls addBookmark - function(args) + function (args) { var result = vimperator.bookmarks.parseBookmarkString(args); @@ -336,7 +336,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["bmarks"], - function(args, special) { vimperator.bookmarks.list(args, special); }, + function (args, special) { vimperator.bookmarks.list(args, special); }, { usage: ["bmarks [filter]", "bmarks!"], short_help: "Show bookmarks", @@ -344,11 +344,11 @@ vimperator.Commands = function() //{{{ "The special version :bmarks! opens the default Firefox bookmarks window.
" + "The following options WILL be interpreted in the future:
" + " -T comma,separated,tag,list
", - completer: function(filter) { return vimperator.completion.get_bookmark_completions(filter); } + completer: function (filter) { return vimperator.completion.get_bookmark_completions(filter); } } )); 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", @@ -357,11 +357,11 @@ vimperator.Commands = function() //{{{ "it is selected. With [!] the next buffer matching the argument " + "is selected, even if it cannot be identified uniquely.
" + "Use b 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) { @@ -379,7 +379,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["delbm[arks]"], - function(args, special) + function (args, special) { var result = vimperator.bookmarks.parseBookmarkString(args); @@ -403,11 +403,11 @@ vimperator.Commands = function() //{{{ "The following options WILL be interpreted in the future:
" + " [!] a special version to delete ALL bookmarks
" + " -T comma,separated,tag,list
", - completer: function(filter) { return vimperator.completion.get_bookmark_completions(filter); } + completer: function (filter) { return vimperator.completion.get_bookmark_completions(filter); } } )); addDefaultCommand(new vimperator.Command(["delm[arks]"], - function(args, special) + function (args, special) { if (!special && !args) { @@ -460,7 +460,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) @@ -489,7 +489,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.
" + @@ -525,7 +525,7 @@ vimperator.Commands = function() //{{{ return arg; } addDefaultCommand(new vimperator.Command(["ec[ho]"], - function(args) + function (args) { var res = argToString(args, true); if (res != null) @@ -537,11 +537,11 @@ vimperator.Commands = function() //{{{ help: "Useful for showing informational messages. Multiple lines can be separated by \\n.
" + "{expr} 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 {expr} 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) @@ -551,11 +551,11 @@ vimperator.Commands = function() //{{{ usage: ["echoe[rr] {expr}"], short_help: "Display an error string at the bottom of the window", help: "Just like :ec[ho], 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) { vimperator.execute(args) }, + function (args) { vimperator.execute(args) }, { usage: ["exe[cute] {expr1} [ ... ]"], short_help: "Execute the string that results from the evaluation of {expr1} as an Ex command.", @@ -563,13 +563,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(); @@ -595,7 +595,7 @@ vimperator.Commands = function() //{{{ short_help: "Go forward in the browser history", help: "Count is supported, :3forward goes forward 3 pages in the browser history.
" + "The special version :forward! goes to the end of the browser history.", - completer: function(filter) + completer: function (filter) { var sh = getWebNavigation().sessionHistory; var completions = []; @@ -612,14 +612,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", @@ -631,21 +631,21 @@ vimperator.Commands = function() //{{{ "
  • :help o for mappings (no pre- or postfix)
  • " + "" + "You can however use partial stings in the tab completion, so :help he<Tab> completes :help :help.", - 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 [filter] either in the title or URL.
    " + "The special version :history! opens the default Firefox history window.", - completer: function(filter) { return vimperator.completion.get_history_completions(filter); } + completer: function (filter) { return vimperator.completion.get_history_completions(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); @@ -656,7 +656,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); @@ -690,11 +690,11 @@ vimperator.Commands = function() //{{{ "Rudimentary <Tab> completion is available for :javascript {cmd}<Tab> (but not yet for the " + ":js <<EOF 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) { @@ -803,7 +803,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 } )); } @@ -814,7 +814,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}", @@ -823,7 +823,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["mapc[lear]"], - function(args) + function (args) { if (args) { @@ -840,7 +840,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["ma[rk]"], - function(args) + function (args) { if (!args) { @@ -866,7 +866,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)) @@ -885,7 +885,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["mkv[imperatorrc]"], - function(args, special) + function (args, special) { var filename; @@ -937,7 +937,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["noh[lsearch]"], - function(args) + function (args) { vimperator.search.clear(); }, @@ -948,7 +948,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["norm[al]"], - function(args, special) + function (args, special) { if (!args) { @@ -961,13 +961,13 @@ vimperator.Commands = function() //{{{ { usage: ["norm[al][!] {commands}"], short_help: "Execute Normal mode commands", - help: "Example: :normal 20j scrolls 20 lines down. " + + help: "Example: :normal 20j scrolls 20 lines down. " + "If the [!] is specified mappings will not be used." } )); // 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}", @@ -975,7 +975,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["o[pen]", "e[dit]"], - function(args, special) + function (args, special) { if (args) { @@ -1014,7 +1014,7 @@ vimperator.Commands = function() //{{{ "The items which are completed on <Tab> are specified in the 'complete' option.
    " + "Without argument, reloads the current page.
    " + "Without argument but with !, 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]"], @@ -1025,13 +1025,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) { @@ -1063,7 +1063,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["qma[rk]"], - function(args) + function (args) { if (!args) { @@ -1087,7 +1087,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)) @@ -1106,7 +1106,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 " + @@ -1114,14 +1114,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(["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", @@ -1129,7 +1129,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", @@ -1137,14 +1137,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.
    " + @@ -1153,7 +1153,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) { @@ -1362,12 +1362,12 @@ vimperator.Commands = function() //{{{ ":set option+={value}, :set option^={value} and :set option-={value} " + "adds/multiplies/subtracts {value} from a number option and appends/prepends/removes {value} from a string option.
    " + ":set all shows the current value of all options and :set all& resets all options to their default values.
    ", - 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) { @@ -1385,7 +1385,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) { @@ -1413,11 +1413,11 @@ vimperator.Commands = function() //{{{ short_help: "Open the sidebar window", help: "{name} 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) + function (args) { // FIXME: implement proper filename quoting //if (/[^\\]\s/.test(args)) @@ -1433,14 +1433,14 @@ vimperator.Commands = function() //{{{ short_help: "Read Ex commands from {file}", help: "You can either source files which mostly contain Ex commands like map < gt " + "and put JavaScript code within a:
    " + - "js <<EOF
    hello = function() {
      alert(\"Hello world\");
    }
    EOF
    section.
    " + + "js <<EOF
    hello = function () {
      alert(\"Hello world\");
    }
    EOF
    section.
    " + "Or you can alternatively source a file which ends in .js, these files are automatically sourced as pure JavaScript files.
    " + "NOTE: In both cases you must add functions to the global window object like shown above, functions written as:
    " + "function hello2() {
      alert(\"Hello world\");
    }
    are only available within the scope of the script.

    " + "The .vimperatorrc file in your home directory and any files in ~/.vimperator/plugin/ are always sourced at startup.
    " + "~ is supported as a shortcut for the $HOME directory.
    " + "If ! 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]"], @@ -1451,24 +1451,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:" + "", - 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", @@ -1478,7 +1478,7 @@ vimperator.Commands = function() //{{{ )); addDefaultCommand(new vimperator.Command(["tabn[ext]", "tn[ext]"], // TODO: count support - function(args) + function (args) { if (!args) { @@ -1504,13 +1504,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"])) @@ -1526,12 +1526,12 @@ vimperator.Commands = function() //{{{ short_help: "Open one or more URLs in a new tab", help: "Like :open but open URLs in a new tab.
    " + "If used with !, the 'tabopen' value of the 'activate' option is negated.", - 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); @@ -1547,14 +1547,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 { @@ -1645,7 +1645,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["u[ndo]"], - function(args, special, count) + function (args, special, count) { if (count < 1) count = 1; @@ -1670,7 +1670,7 @@ vimperator.Commands = function() //{{{ short_help: "Undo closing of a tab", help: "If a count is given, don't close the last but the [count]th last tab. " + "With [url] 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); @@ -1689,7 +1689,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["undoa[ll]"], - function(args, special, count) + function (args, special, count) { if (count > -1) { @@ -1713,7 +1713,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["unl[et]"], - function(args, special) + function (args, special) { if (!args) return vimperator.echoerr("E471: Argument required"); @@ -1742,7 +1742,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["unm[ap]"], - function(args) + function (args) { if (!args) { @@ -1764,7 +1764,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["ve[rsion]"], - function(args, special) + function (args, special) { if (special) vimperator.open("about:"); @@ -1779,13 +1779,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(); }, @@ -1795,7 +1795,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); @@ -1809,7 +1809,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", @@ -1818,7 +1818,7 @@ vimperator.Commands = function() //{{{ } )); addDefaultCommand(new vimperator.Command(["zo[om]"], - function(args) + function (args) { var level; @@ -1863,7 +1863,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) diff --git a/content/completion.js b/content/completion.js index 384ea1cd..7e49f4fd 100644 --- a/content/completion.js +++ b/content/completion.js @@ -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; }); } @@ -112,7 +112,7 @@ vimperator.Completion = function() // {{{ // list them add the end of the array var additional_completions = []; - if (!filter) return urls.map(function($_) { + if (!filter) return urls.map(function ($_) { return [$_[0], $_[1]] }); @@ -153,7 +153,7 @@ vimperator.Completion = function() // {{{ } else { - g_substrings = g_substrings.filter(function($_) { + g_substrings = g_substrings.filter(function ($_) { return url.indexOf($_) >= 0; }); } @@ -168,7 +168,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 ""; @@ -189,7 +189,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 = []; @@ -211,33 +211,33 @@ 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); }, //}}} - get_history_completions: function(filter) //{{{ + get_history_completions: function (filter) //{{{ { var items = vimperator.history.get(); return filter_url_array(items, filter); }, //}}} - get_bookmark_completions: function(filter) //{{{ + get_bookmark_completions: function (filter) //{{{ { var bookmarks = vimperator.bookmarks.get(); return filter_url_array(bookmarks, 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 @@ -256,7 +256,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"]; }); } @@ -269,7 +269,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"], @@ -278,25 +278,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 = []; @@ -312,7 +312,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 = []; @@ -379,7 +379,7 @@ vimperator.Completion = function() // {{{ } else { - g_substrings = g_substrings.filter(function($_) { + g_substrings = g_substrings.filter(function ($_) { return option.names[j].indexOf($_) == 0; }); } @@ -391,7 +391,7 @@ vimperator.Completion = function() // {{{ return options_completions; }, //}}} - get_buffer_completions: function(filter) //{{{ + get_buffer_completions: function (filter) //{{{ { g_substrings = []; var items = []; @@ -421,13 +421,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") @@ -439,20 +439,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; @@ -520,7 +520,7 @@ vimperator.Completion = function() // {{{ // helper function which checks if the given arguments pass "filter" // items must be an array of strings // if case_sensitive == true, be sure to pass filter already in lowercased version - match: function(filter, items, case_sensitive) + match: function (filter, items, case_sensitive) { if (typeof(filter) != "string" || !items) return false; @@ -544,7 +544,7 @@ vimperator.Completion = function() // {{{ return false; }, - exTabCompletion: function(str) //{{{ + exTabCompletion: function (str) //{{{ { var [count, cmd, special, args] = vimperator.commands.parseCommand(str); var completions = []; diff --git a/content/events.js b/content/events.js index 9c0c4101..bf1a7d3c 100644 --- a/content/events.js +++ b/content/events.js @@ -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) { vimperator.commandline.clear(); vimperator.setMode(); // trick to reshow the mode in the command line vimperator.statusline.updateTabCount(); @@ -103,7 +103,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); @@ -234,7 +234,7 @@ vimperator.Events = function() //{{{ ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - this.destroy = function() + this.destroy = function () { // removeEventListeners() to avoid mem leaks window.dump("TODO: remove all eventlisteners\n"); @@ -256,7 +256,7 @@ vimperator.Events = function() //{{{ // // @param keys: a string like "2" 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; @@ -320,7 +320,7 @@ vimperator.Events = function() //{{{ // a keycode which can be used in mappings // e.g. pressing ctrl+n would result in the string "" // null if unknown key - this.toString = function(event) //{{{ + this.toString = function (event) //{{{ { if (!event) return; @@ -396,17 +396,17 @@ vimperator.Events = function() //{{{ } //}}} - this.isAcceptKey = function(key) + this.isAcceptKey = function (key) { return (key == "" || key == "" || key == ""); } - this.isCancelKey = function(key) + this.isCancelKey = function (key) { return (key == "" || key == "" || key == ""); } // global escape handler, is called in ALL modes - this.onEscape = function() + this.onEscape = function () { if (!vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY)) { @@ -426,7 +426,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) @@ -690,7 +690,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.hasMode(vimperator.modes.ESCAPE_ONE_KEY) || vimperator.hasMode(vimperator.modes.ESCAPE_ALL_KEYS) || isFormElemFocused()) return true; @@ -703,7 +703,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(); @@ -714,7 +714,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 @@ -741,29 +741,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) @@ -784,10 +784,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; diff --git a/content/find.js b/content/find.js index 4cebdf33..67ec7ce3 100644 --- a/content/find.js +++ b/content/find.js @@ -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; @@ -134,13 +134,13 @@ vimperator.Search = function() //{{{ found = fastFind.find(search_string, links_only) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND; if (!found) - setTimeout(function() { vimperator.echoerr("E486: Pattern not found: " + search_pattern); }, 0); + setTimeout(function () { vimperator.echoerr("E486: Pattern not found: " + search_pattern); }, 0); return found; } // 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 after the original search. Since searchString is @@ -164,7 +164,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 @@ -181,7 +181,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); @@ -189,7 +189,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; @@ -208,7 +208,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); @@ -219,14 +219,14 @@ vimperator.Search = function() //{{{ // Called when the search is cancelled - for example if someone presses // escape while typing a search - this.searchCanceled = function() + this.searchCanceled = function () { //removeMode(MODE_SEARCH); vimperator.setMode(vimperator.modes.NORMAL); vimperator.focusContent(); } - this.highlight = function(text) + this.highlight = function (text) { // already highlighted? if (window.content.document.getElementById("__firefox-findbar-search-id")) @@ -243,7 +243,7 @@ vimperator.Search = function() //{{{ // TODO: seems fast enough for now...just // NOTE: FF2 highlighting spans all have the same id rather than a class attribute - (function(win) + (function (win) { for (var i = 0; i < win.frames.length; i++) arguments.callee(win.frames[i]); @@ -258,7 +258,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 diff --git a/content/help.js b/content/help.js index 30650b02..e5aa4e67 100644 --- a/content/help.js +++ b/content/help.js @@ -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) { @@ -220,7 +220,7 @@ vimperator.help = function(section, easter) //{{{ { doc.open(); } - catch(e) + catch (e) { // FIXME: what's this all about then, eh? Works the same for if it's removed. -- djk // when the url is "about:" or any other xhtml page the doc is not open @@ -255,7 +255,7 @@ vimperator.help = function(section, easter) //{{{ } // FIXME - setTimeout(function() { + setTimeout(function () { if (section) { function findSectionElement(section) diff --git a/content/hints.js b/content/hints.js index d6dc04c3..bc887304 100644 --- a/content/hints.js +++ b/content/hints.js @@ -22,13 +22,13 @@ * }}} ***** END LICENSE BLOCK *****/ -vimperator.Hints = function() //{{{ +vimperator.Hints = function () //{{{ { const HINT_PREFIX = "hah_hint_"; // prefix for the hint id - this.hintedElements = function() { return hintedElems; }; - this.currentState = function() { return state;}; - this.setCurrentState = function(s) { state = s;}; + this.hintedElements = function () { return hintedElems; }; + this.currentState = function () { return state;}; + this.setCurrentState = function (s) { state = s;}; var isHahModeEnabled = false; // is typing mode on var hintedElems = []; @@ -68,7 +68,7 @@ vimperator.Hints = function() //{{{ win.coordLoaderId = window.setTimeout("vimperator.hints.loadCoord(" + win.winId + ", 0);", 1); } - this.loadCoord = function(winId, i) + this.loadCoord = function (winId, i) { win = wins[winId]; @@ -400,7 +400,7 @@ vimperator.Hints = function() //{{{ * @return -1 if already enabled */ //function enableHahMode(event, mode) - this.enableHahMode = function(mode) + this.enableHahMode = function (mode) { vimperator.setMode(vimperator.modes.HINTS, mode); state = 0; @@ -424,7 +424,7 @@ vimperator.Hints = function() //{{{ * @return -1 if already disabled */ //function disableHahMode(event) - this.disableHahMode = function(win) + this.disableHahMode = function (win) { if (!isHahModeEnabled) return; @@ -438,7 +438,7 @@ vimperator.Hints = function() //{{{ return 0; }; - this.resetHintedElements = function() + this.resetHintedElements = function () { linkNumString = ""; state = 0; @@ -454,7 +454,7 @@ vimperator.Hints = function() //{{{ }; - this.reshowHints = function() + this.reshowHints = function () { onResize(null); @@ -471,7 +471,7 @@ vimperator.Hints = function() //{{{ // this function 'click' an element, which also works // for javascript links - this.openHints = function(new_tab, new_window) + this.openHints = function (new_tab, new_window) { var x = 0, y = 0; @@ -517,7 +517,7 @@ vimperator.Hints = function() //{{{ return 0; }; - this.yankUrlHints = function() + this.yankUrlHints = function () { var loc = ""; var elems = this.hintedElements(); @@ -540,7 +540,7 @@ vimperator.Hints = function() //{{{ vimperator.echo("Yanked " + loc); }; - this.yankTextHints = function() + this.yankTextHints = function () { var loc = ""; var elems = this.hintedElements(); @@ -563,7 +563,7 @@ vimperator.Hints = function() //{{{ vimperator.echo("Yanked " + loc); }; - this.saveHints = function(skip_prompt) + this.saveHints = function (skip_prompt) { var elems = this.hintedElements(); @@ -622,7 +622,7 @@ vimperator.Hints = function() //{{{ // returns nr. of fully parsed links when a new hint has been found, // otherwise 0 if current state is part of a hint, or -1 if an error occured // (like we have typed keys which never can become a hint - this.processEvent = function(event) + this.processEvent = function (event) { if (!isHahModeEnabled) return -1; @@ -706,7 +706,7 @@ vimperator.Hints = function() //{{{ linkNumString = ""; isHahModeEnabled = true; - setTimeout( function() { + setTimeout( function () { createHints(); showHints(null, 0); }, 100); diff --git a/content/io.js b/content/io.js index 9161155e..3c641a74 100644 --- a/content/io.js +++ b/content/io.js @@ -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); diff --git a/content/mappings.js b/content/mappings.js index 1a50321d..d46f4bce 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -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.Map = function(mode, cmds, action, extra_info) //{{{ +vimperator.Map = function (mode, cmds, action, extra_info) //{{{ { if (!mode || (!cmds || !cmds.length) || !action) return null; @@ -65,7 +65,7 @@ vimperator.Map = function(mode, cmds, action, extra_info) //{{{ } } -vimperator.Map.prototype.hasName = function(name) +vimperator.Map.prototype.hasName = function (name) { for (var i = 0; i < this.names.length; i++) { @@ -78,7 +78,7 @@ vimperator.Map.prototype.hasName = function(name) // Since we will add many Map-objects, we add some functions as prototypes // this will ensure we only have one copy of each function, not one for each object -vimperator.Map.prototype.execute = function(motion, count, argument) +vimperator.Map.prototype.execute = function (motion, count, argument) { var args = []; if (this.flags & vimperator.Mappings.flags.MOTION) @@ -91,7 +91,7 @@ vimperator.Map.prototype.execute = function(motion, count, argument) } //}}} -vimperator.Mappings = function() //{{{ +vimperator.Mappings = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -178,24 +178,24 @@ vimperator.Mappings = function() //{{{ }; // NOTE: just normal mode for now - this.__iterator__ = function() + this.__iterator__ = function () { return mappingsIterator(vimperator.modes.NORMAL, main); } // FIXME - this.getIterator = function(mode) + this.getIterator = function (mode) { return mappingsIterator(mode, main); } // FIXME - this.getUserIterator = function(mode) + this.getUserIterator = function (mode) { return mappingsIterator(mode, user); } - this.hasMap = function(mode, cmd) + this.hasMap = function (mode, cmd) { var user_maps = user[mode]; @@ -208,29 +208,29 @@ vimperator.Mappings = function() //{{{ return false; } - this.add = function(map) + this.add = function (map) { for (var i = 0; i < map.names.length; i++) { // only store keysyms with uppercase modifier strings - map.names[i] = map.names[i].replace(/[casm]-/g, function($0) { return $0.toUpperCase(); }); + map.names[i] = map.names[i].replace(/[casm]-/g, function ($0) { return $0.toUpperCase(); }); removeMap(map.mode, map.names[i]); } user[map.mode].push(map); } - this.remove = function(mode, cmd) + this.remove = function (mode, cmd) { removeMap(mode, cmd); } - this.removeAll = function(mode) + this.removeAll = function (mode) { user[mode] = []; } - this.get = function(mode, cmd) + this.get = function (mode, cmd) { var map = getMap(mode, cmd, user); @@ -241,13 +241,13 @@ vimperator.Mappings = function() //{{{ } // TODO: move default maps to their own v.normal namespace - this.getDefaultMap = function(mode, cmd) + this.getDefaultMap = function (mode, cmd) { return getMap(mode, cmd, main); } // returns an array of mappings with names which start with "cmd" - this.getCandidates = function(mode, cmd) + this.getCandidates = function (mode, cmd) { var mappings = []; var matches = []; @@ -268,7 +268,7 @@ vimperator.Mappings = function() //{{{ } // TODO: implement filtering - this.list = function(mode, filter) + this.list = function (mode, filter) { var maps = user[mode]; @@ -304,21 +304,21 @@ vimperator.Mappings = function() //{{{ // {{{ // vimperator management addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [""], - function() { vimperator.help(null); }, + function () { vimperator.help(null); }, { short_help: "Open help window", help: "The default section is shown, if you need help for a specific topic, try :help <F1>." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [":"], - function() { vimperator.commandline.open(":", "", vimperator.modes.EX); }, + function () { vimperator.commandline.open(":", "", vimperator.modes.EX); }, { short_help: "Start command line mode", help: "In command line mode, you can perform extended commands, which may require arguments." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["I"], - function() { vimperator.addMode(null, vimperator.modes.ESCAPE_ALL_KEYS); }, + function () { vimperator.addMode(null, vimperator.modes.ESCAPE_ALL_KEYS); }, { short_help: "Disable Vimperator keys", help: "Starts an 'ignorekeys' mode, where all keys except <Esc> are passed to the next event handler.
    " + @@ -328,7 +328,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [""], - function() { vimperator.addMode(null, vimperator.modes.ESCAPE_ONE_KEY); }, + function () { vimperator.addMode(null, vimperator.modes.ESCAPE_ONE_KEY); }, { short_help: "Escape next key", help: "If you need to pass a certain key to a JavaScript form field or another extension prefix the key with <C-v>.
    " + @@ -344,7 +344,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [""], - function() { return; }, + function () { return; }, { short_help: "Do nothing", help: "This command is useful for disabling a specific mapping. " + @@ -361,7 +361,7 @@ vimperator.Mappings = function() //{{{ )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["]f"], - function(count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, true); }, + function (count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, true); }, { short_help: "Focus next frame", help: "Transfers keyboard focus to the [count]th next frame in order. The newly focused frame is briefly colored red. Does not wrap.", @@ -369,7 +369,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["[f"], - function(count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, false); }, + function (count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, false); }, { short_help: "Focus previous frame", help: "Transfers keyboard focus to the [count]th previous frame in order. The newly focused frame is briefly colored red. Does not wrap.", @@ -377,14 +377,14 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["b"], - function() { vimperator.commandline.open(":", "buffer! ", vimperator.modes.EX); }, + function () { vimperator.commandline.open(":", "buffer! ", vimperator.modes.EX); }, { short_help: "Open a prompt to switch buffers", help: "Typing the corresponding number switches to this buffer." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["B"], - function() { vimperator.buffer.list(true); }, + function () { vimperator.buffer.list(true); }, { short_help: "Toggle buffer list", help: "Toggles the display of the buffer list which shows all opened tabs.
    " + @@ -392,7 +392,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gb"], - function(count) { vimperator.buffer.switchTo(null, null, count, false); }, + function (count) { vimperator.buffer.switchTo(null, null, count, false); }, { short_help: "Repeat last :buffer[!] command", help: "This is useful to quickly jump between buffers which have a similar URL or title.", @@ -400,7 +400,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gB"], - function(count) { vimperator.buffer.switchTo(null, null, count, true); }, + function (count) { vimperator.buffer.switchTo(null, null, count, true); }, { short_help: "Repeat last :buffer[!] command in reverse direction", help: "Just like gb but in the other direction.", @@ -408,7 +408,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["d"], - function(count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); }, + function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); }, { short_help: "Delete current buffer (=tab)", help: "Count is supported, 2d removes the current and next tab and the one to the right is selected. " + @@ -417,7 +417,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["D"], - function(count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); }, + function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); }, { short_help: "Delete current buffer (=tab)", help: "Count is supported, 2D removes the current and previous tab and the one to the left is selected. " + @@ -433,7 +433,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gH"], - function() + function () { var homepages = gHomeButton.getHomePage(); vimperator.open(homepages, /\bhomepage\b/.test(vimperator.options["activate"]) ? @@ -446,7 +446,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["go"], - function(arg) { vimperator.quickmarks.jumpTo(arg, vimperator.CURRENT_TAB); }, + function (arg) { vimperator.quickmarks.jumpTo(arg, vimperator.CURRENT_TAB); }, { short_help: "Jump to a QuickMark in the current tab", usage: ["go{a-zA-Z0-9}"], @@ -456,7 +456,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gn"], - function(arg) + function (arg) { vimperator.quickmarks.jumpTo(arg, /\bquickmark\b/.test(vimperator.options["activate"]) ? @@ -472,7 +472,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gP"], - function() + function () { vimperator.open(readFromClipboard(), /\bpaste\b/.test(vimperator.options["activate"]) ? @@ -484,7 +484,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gt", "", "", ""], - function(count) { vimperator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); }, + function (count) { vimperator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); }, { short_help: "Go to the next tab", help: "Cycles to the first tab, when the last is selected.
    Count is supported: 3gt goes to the third tab.", @@ -492,7 +492,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gT", "", "", ""], - function(count) { vimperator.tabs.select("-" + (count < 1 ? 1 : count), true); }, + function (count) { vimperator.tabs.select("-" + (count < 1 ? 1 : count), true); }, { short_help: "Go {count} pages back", help: "Wraps around from the first tab to the last tab.
    Count is supported: 3gT goes three tabs back.", @@ -500,7 +500,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["", ""], - function() + function () { if (vimperator.tabs.getTab() == vimperator.tabs.alternate) { @@ -527,7 +527,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["m"], - function(arg) + function (arg) { if (/[^a-zA-Z]/.test(arg)) { @@ -545,7 +545,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["'", "`"], - function(arg) { vimperator.marks.jumpTo(arg); }, + function (arg) { vimperator.marks.jumpTo(arg); }, { short_help: "Jump to the mark in the current buffer", usage: ["'{a-zA-Z}"], @@ -554,7 +554,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["M"], - function(arg) + function (arg) { if (/[^a-zA-Z0-9]/.test(arg)) { @@ -573,28 +573,28 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["o"], - function() { vimperator.commandline.open(":", "open ", vimperator.modes.EX); }, + function () { vimperator.commandline.open(":", "open ", vimperator.modes.EX); }, { short_help: "Open one or more URLs in the current tab", help: "See :open for more details." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["O"], - function() { vimperator.commandline.open(":", "open " + vimperator.buffer.URL, vimperator.modes.EX); }, + function () { vimperator.commandline.open(":", "open " + vimperator.buffer.URL, vimperator.modes.EX); }, { short_help: "Open one or more URLs in the current tab, based on current location", help: "Works like o, but preselects current URL in the :open query." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["p", ""], - function() { vimperator.open(readFromClipboard()); }, + function () { vimperator.open(readFromClipboard()); }, { short_help: "Open (put) a URL based on the current clipboard contents in the current buffer", help: "You can also just select (for non-X11 users: copy) some non-URL text, and search for it with the default search engine or keyword (specified by the 'defsearch' option) with p." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["P"], - function() + function () { vimperator.open(readFromClipboard(), /\bpaste\b/.test(vimperator.options["activate"]) ? @@ -607,21 +607,21 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["r"], - function() { vimperator.tabs.reload(getBrowser().mCurrentTab, false); }, + function () { vimperator.tabs.reload(getBrowser().mCurrentTab, false); }, { short_help: "Reload", help: "Forces reloading of the current page." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["R"], - function() { vimperator.tabs.reload(getBrowser().mCurrentTab, true); }, + function () { vimperator.tabs.reload(getBrowser().mCurrentTab, true); }, { short_help: "Reload while skipping the cache", help: "Forces reloading of the current page skipping the cache." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["t"], - function() { vimperator.commandline.open(":", "tabopen ", vimperator.modes.EX); }, + function () { vimperator.commandline.open(":", "tabopen ", vimperator.modes.EX); }, { short_help: "Open one or more URLs in a new tab", help: "Like o but open URLs in a new tab.
    " + @@ -629,14 +629,14 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["T"], - function() { vimperator.commandline.open(":", "tabopen " + vimperator.buffer.URL, vimperator.modes.EX); }, + function () { vimperator.commandline.open(":", "tabopen " + vimperator.buffer.URL, vimperator.modes.EX); }, { short_help: "Open one or more URLs in a new tab, based on current location", help: "Works like t, but preselects current URL in the :tabopen query." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["u"], - function(count) { vimperator.commands.undo("", false, count); }, + function (count) { vimperator.commands.undo("", false, count); }, { short_help: "Undo closing of a tab", help: "If a count is given, don't close the last but the [count]th last tab.", @@ -644,7 +644,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["y"], - function() + function () { var url = vimperator.buffer.URL; vimperator.copyToClipboard(url); @@ -656,7 +656,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["Y"], - function() + function () { var sel = window.content.document.getSelection(); vimperator.copyToClipboard(sel); @@ -667,35 +667,35 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["zi", "+"], - function(count) { vimperator.buffer.zoomIn(count > 1 ? count : 1); }, + function (count) { vimperator.buffer.zoomIn(count > 1 ? count : 1); }, { short_help: "Zoom in current web page by 25%", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["zI"], - function(count) { vimperator.buffer.zoomIn((count > 1 ? count : 1) * 4); }, + function (count) { vimperator.buffer.zoomIn((count > 1 ? count : 1) * 4); }, { short_help: "Zoom in current web page by 100%", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["zo", "-"], - function(count) { vimperator.buffer.zoomOut(count > 1 ? count : 1); }, + function (count) { vimperator.buffer.zoomOut(count > 1 ? count : 1); }, { short_help: "Zoom out current web page by 25%", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["zO"], - function(count) { vimperator.buffer.zoomOut((count > 1 ? count : 1) * 4); }, + function (count) { vimperator.buffer.zoomOut((count > 1 ? count : 1) * 4); }, { short_help: "Zoom out current web page by 100%", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["zz"], - function(count) { vimperator.buffer.textZoom = count > 1 ? count : 100; }, + function (count) { vimperator.buffer.textZoom = count > 1 ? count : 100; }, { short_help: "Set zoom value of the web page", help: "Zoom value can be between 1 and 2000%. If it is omitted, zoom is reset to 100%.", @@ -703,14 +703,14 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["ZQ"], - function() { vimperator.quit(false); }, + function () { vimperator.quit(false); }, { short_help: "Quit and don't save the session", help: "Works like :qall." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["ZZ"], - function() { vimperator.quit(true); }, + function () { vimperator.quit(true); }, { short_help: "Quit and save the session", help: "Quit Vimperator, no matter how many tabs/windows are open. The session is stored.
    " + @@ -720,20 +720,20 @@ vimperator.Mappings = function() //{{{ // scrolling commands addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["0", "^"], - function() { vimperator.buffer.scrollStart(); }, + function () { vimperator.buffer.scrollStart(); }, { short_help: "Scroll to the absolute left of the document", help: "Unlike in Vim, 0 and ^ work exactly the same way." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["$"], - function() { vimperator.buffer.scrollEnd(); }, + function () { vimperator.buffer.scrollEnd(); }, { short_help: "Scroll to the absolute right of the document" } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gg", ""], - function(count) { vimperator.buffer.scrollToPercentile(count > 0 ? count : 0); }, + function (count) { vimperator.buffer.scrollToPercentile(count > 0 ? count : 0); }, { short_help: "Goto the top of the document", help: "When used with [count] like in 35gg, it scrolls to 35% of the document.", @@ -741,7 +741,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["G", ""], - function(count) { vimperator.buffer.scrollToPercentile(count >= 0 ? count : 100); }, + function (count) { vimperator.buffer.scrollToPercentile(count >= 0 ? count : 100); }, { short_help: "Goto the end of the document", help: "When used with [count] like in 35G, it scrolls to 35% of the document.", @@ -749,7 +749,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["h", ""], - function(count) { vimperator.buffer.scrollColumns(-(count > 1 ? count : 1)); }, + function (count) { vimperator.buffer.scrollColumns(-(count > 1 ? count : 1)); }, { short_help: "Scroll document to the left", help: "Count is supported: 10h will move 10 times as much to the left.
    " + @@ -758,7 +758,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["j", "", ""], - function(count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, + function (count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, { short_help: "Scroll document down", help: "Count is supported: 10j will move 10 times as much down.
    " + @@ -767,7 +767,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["k", "", ""], - function(count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, + function (count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, { short_help: "Scroll document up", help: "Count is supported: 10k will move 10 times as much up.
    " + @@ -792,7 +792,7 @@ vimperator.Mappings = function() //{{{ } } addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [""], - function(count) { scrollByScrollSize(count, 1); }, + function (count) { scrollByScrollSize(count, 1); }, { short_help: "Scroll window downwards in the buffer", help: "The number of lines is set by the 'scroll' option which defaults to half a page. " + @@ -801,7 +801,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [""], - function(count) { scrollByScrollSize(count, -1); }, + function (count) { scrollByScrollSize(count, -1); }, { short_help: "Scroll window upwards in the buffer", help: "The number of lines is set by the 'scroll' option which defaults to half a page. " + @@ -810,7 +810,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["l", ""], - function(count) { vimperator.buffer.scrollColumns(count > 1 ? count : 1); }, + function (count) { vimperator.buffer.scrollColumns(count > 1 ? count : 1); }, { short_help: "Scroll document to the right", help: "Count is supported: 10l will move 10 times as much to the right.
    " + @@ -819,7 +819,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["", "", ""], - function(count) { vimperator.buffer.scrollPages(-(count > 1 ? count : 1)); }, + function (count) { vimperator.buffer.scrollPages(-(count > 1 ? count : 1)); }, { short_help: "Scroll up a full page", help: "Scroll window [count] pages Backwards (upwards) in the buffer.", @@ -827,7 +827,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["", "", ""], - function(count) { vimperator.buffer.scrollPages(count > 1 ? count : 1); }, + function (count) { vimperator.buffer.scrollPages(count > 1 ? count : 1); }, { short_help: "Scroll down a full page", help: "Scroll window [count] pages Forwards (downwards) in the buffer.", @@ -837,7 +837,7 @@ vimperator.Mappings = function() //{{{ // page info addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], - function(count) { vimperator.buffer.pageInfo(false); }, + function (count) { vimperator.buffer.pageInfo(false); }, { short_help: "Print the current file name", help: "Also shows some additional file information like file size or the last modified date. " + @@ -846,7 +846,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["g"], - function(count) { vimperator.buffer.pageInfo(true); }, + function (count) { vimperator.buffer.pageInfo(true); }, { short_help: "Print file information", help: "Same as :pa[geinfo]." @@ -856,7 +856,7 @@ vimperator.Mappings = function() //{{{ // history manipulation and jumplist addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [""], - function(count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, + function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, { short_help: "Go to an older position in the jump list", help: "The jump list is just the browser history for now.", @@ -864,7 +864,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [""], - function(count) { vimperator.history.stepTo(count > 1 ? count : 1); }, + function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, { short_help: "Go to a newer position in the jump list", help: "The jump list is just the browser history for now.", @@ -872,7 +872,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["H", "", ""], - function(count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, + function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, { short_help: "Go back in the browser history", help: "Count is supported: 3H goes back 3 steps.", @@ -880,7 +880,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["L", "", ""], - function(count) { vimperator.history.stepTo(count > 1 ? count : 1); }, + function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, { short_help: "Go forward in the browser history", help: "Count is supported: 3L goes forward 3 steps.", @@ -905,7 +905,7 @@ vimperator.Mappings = function() //{{{ return false; } addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gu", ""], - function(count) + function (count) { var gocmd = ""; if (isDirectory(vimperator.buffer.URL)) @@ -928,7 +928,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gU", ""], - function() { vimperator.open("..."); }, + function () { vimperator.open("..."); }, { short_help: "Go to the root of the website", help: "gU on http://www.example.com/dir1/dir2/file.htm opens http://www.example.com/.
    " + @@ -938,7 +938,7 @@ vimperator.Mappings = function() //{{{ // hint managment addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["f"], - function() { vimperator.hints.enableHahMode(vimperator.modes.QUICK_HINT); }, + function () { vimperator.hints.enableHahMode(vimperator.modes.QUICK_HINT); }, { short_help: "Start QuickHint mode", help: "In QuickHint mode, every hintable item (according to the 'hinttags' XPath query) is assigned a label.
    " + @@ -947,7 +947,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["F"], - function() { vimperator.hints.enableHahMode(vimperator.modes.ALWAYS_HINT); }, + function () { vimperator.hints.enableHahMode(vimperator.modes.ALWAYS_HINT); }, { short_help: "Start AlwaysHint mode", help: "In AlwaysHint mode, every hintable item (according to the 'hinttags' XPath query) is assigned a label.
    " + @@ -957,7 +957,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [";"], - function() { vimperator.hints.enableHahMode(vimperator.modes.EXTENDED_HINT); }, + function () { vimperator.hints.enableHahMode(vimperator.modes.EXTENDED_HINT); }, { short_help: "Start ExtendedHint mode", help: "ExtendedHint mode is useful, since in this mode you can yank link locations, or open them in a new window.
    " + @@ -982,7 +982,7 @@ vimperator.Mappings = function() //{{{ // search management addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["/"], - function() { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_FORWARD); }, + function () { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_FORWARD); }, { short_help: "Search forward for a pattern", usage: ["/{pattern}[/]"], @@ -994,7 +994,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["?"], - function() { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_BACKWARD); }, + function () { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_BACKWARD); }, { short_help: "Search backwards for a pattern", usage: ["?{pattern}[?]"], @@ -1007,14 +1007,14 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["n"], - function() { vimperator.search.findAgain(false); }, + function () { vimperator.search.findAgain(false); }, { short_help: "Find next", help: "Repeat the last search 1 time (until count is supported)." } )); addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["N"], - function() { vimperator.search.findAgain(true); }, + function () { vimperator.search.findAgain(true); }, { short_help: "Find previous", help: "Repeat the last search 1 time (until count is supported) in the opposite direction." @@ -1028,63 +1028,63 @@ vimperator.Mappings = function() //{{{ // action keys addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["o"], - function() { vimperator.hints.openHints(false, false); }, + function () { vimperator.hints.openHints(false, false); }, { cancel_mode: true, always_active: false } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["t"], - function() { vimperator.hints.openHints(true, false); }, + function () { vimperator.hints.openHints(true, false); }, { cancel_mode: true, always_active: false } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.hints.openHints(false, true ); }, + function () { vimperator.hints.openHints(false, true ); }, { cancel_mode: true, always_active: false } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["s"], - function() { vimperator.hints.saveHints(true); }, + function () { vimperator.hints.saveHints(true); }, { cancel_mode: true, always_active: false } )); addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], ["a"], - function() { vimperator.hints.saveHints(false); }, + function () { vimperator.hints.saveHints(false); }, { cancel_mode: true, always_active: false } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["y"], - function() { vimperator.hints.yankUrlHints(); }, + function () { vimperator.hints.yankUrlHints(); }, { cancel_mode: true, always_active: false } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["Y"], - function() { vimperator.hints.yankTextHints(); }, + function () { vimperator.hints.yankTextHints(); }, { cancel_mode: true, always_active: false } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [","], - function() { vimperator.input.buffer += ","; vimperator.hints.setCurrentState(0); }, + function () { vimperator.input.buffer += ","; vimperator.hints.setCurrentState(0); }, { cancel_mode: false, always_active: true } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [":"], - function() { vimperator.commandline.open(":", "", vimperator.modes.EX); }, + function () { vimperator.commandline.open(":", "", vimperator.modes.EX); }, { cancel_mode: false, always_active: true @@ -1093,7 +1093,7 @@ vimperator.Mappings = function() //{{{ // movement keys addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function(count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, + function (count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, { cancel_mode: false, always_active: true, @@ -1101,7 +1101,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function(count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, + function (count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, { cancel_mode: false, always_active: true, @@ -1109,21 +1109,21 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.buffer.scrollTop(); }, + function () { vimperator.buffer.scrollTop(); }, { cancel_mode: false, always_active: true } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.buffer.scrollBottom(); }, + function () { vimperator.buffer.scrollBottom(); }, { cancel_mode: false, always_active: true } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["", ""], - function(count) { vimperator.buffer.scrollPages(-(count > 1 ? count : 1)); }, + function (count) { vimperator.buffer.scrollPages(-(count > 1 ? count : 1)); }, { cancel_mode: false, always_active: true, @@ -1131,7 +1131,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["", ""], - function(count) { vimperator.buffer.scrollPages(count > 1 ? count : 1); }, + function (count) { vimperator.buffer.scrollPages(count > 1 ? count : 1); }, { cancel_mode: false, always_active: true, @@ -1139,7 +1139,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.buffer.scrollColumns(-(count > 1 ? count : 1)); }, + function () { vimperator.buffer.scrollColumns(-(count > 1 ? count : 1)); }, { cancel_mode: false, always_active: true, @@ -1147,7 +1147,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, + function () { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, { cancel_mode: false, always_active: true, @@ -1155,7 +1155,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, + function () { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, { cancel_mode: false, always_active: true, @@ -1163,7 +1163,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.buffer.scrollColumns(count > 1 ? count : 1); }, + function () { vimperator.buffer.scrollColumns(count > 1 ? count : 1); }, { cancel_mode: false, always_active: true, @@ -1173,14 +1173,14 @@ vimperator.Mappings = function() //{{{ // tab management addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.tabs.select("+1", true); }, + function () { vimperator.tabs.select("+1", true); }, { cancel_mode: true, always_active: true } )); // same as gt, but no count supported addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.tabs.select("-1", true); }, + function () { vimperator.tabs.select("-1", true); }, { cancel_mode: true, always_active: true @@ -1189,7 +1189,7 @@ vimperator.Mappings = function() //{{{ // navigation addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function(count) { vimperator.history.stepTo(count > 0 ? -count : -1); }, + function (count) { vimperator.history.stepTo(count > 0 ? -count : -1); }, { cancel_mode: false, always_active: true, @@ -1197,7 +1197,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function(count) { vimperator.history.stepTo(count > 1 ? count : 1); }, + function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, { cancel_mode: false, always_active: true, @@ -1205,7 +1205,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function(count) { vimperator.history.stepTo(count > 0 ? -count : -1); }, + function (count) { vimperator.history.stepTo(count > 0 ? -count : -1); }, { cancel_mode: false, always_active: true, @@ -1213,7 +1213,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function(count) { vimperator.history.stepTo(count > 1 ? count : 1); }, + function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, { cancel_mode: false, always_active: true, @@ -1221,7 +1221,7 @@ vimperator.Mappings = function() //{{{ } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { vimperator.tabs.remove(getBrowser().mCurrentTab, vimperator.input.count, false, 0); }, + function () { vimperator.tabs.remove(getBrowser().mCurrentTab, vimperator.input.count, false, 0); }, { cancel_mode: true, always_active: true @@ -1230,28 +1230,28 @@ vimperator.Mappings = function() //{{{ // cancel_mode hint mode keys addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { ; }, + function () { ; }, { cancel_mode: true, always_active: true } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { ; }, + function () { ; }, { cancel_mode: true, always_active: true } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { ; }, + function () { ; }, { cancel_mode: true, always_active: true } )); addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, [""], - function() { ; }, + function () { ; }, { cancel_mode: true, always_active: true diff --git a/content/options.js b/content/options.js index d9226b02..de441c41 100644 --- a/content/options.js +++ b/content/options.js @@ -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()) + "
    " + @@ -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() //{{{ "
  • paste: P and gP mappings
  • " + "", 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 :set complete=bs would list bookmarks first, and then any available quick searches.
    " + "Add 'sort' to the 'wildoptions' 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 :[tab]open [arg] 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" } )); @@ -484,8 +484,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 } )); @@ -498,9 +498,9 @@ vimperator.Options = function() //{{{ "
  • T: toolbar
  • " + "
  • b: bookmark bar
  • " + "", - 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(["hintchars", "hc"], "charlist", @@ -525,7 +525,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 } )); @@ -560,8 +560,8 @@ vimperator.Options = function() //{{{ "" + "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", @@ -612,8 +612,8 @@ vimperator.Options = function() //{{{ "" + "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", @@ -631,7 +631,7 @@ vimperator.Options = function() //{{{ "Close the preview window with :pclose.
    " + "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", @@ -641,7 +641,7 @@ vimperator.Options = function() //{{{ "When a {count} is specified to the <C-u> or <C-d> commands this is used to set the value of 'scroll' and also used for the current command. " + "The value can be reset to half the window height with :set scroll=0.", default_value: 0, - validator: function(value) { return value >= 0; } + validator: function (value) { return value >= 0; } } )); this.add(new vimperator.Option(["showmode", "smd"], "boolean", @@ -661,7 +661,7 @@ vimperator.Options = function() //{{{ "
  • 2: Show the link in the command line
  • " + "", 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", @@ -673,9 +673,9 @@ vimperator.Options = function() //{{{ "
  • 1: Show tab bar only if more than one tab is open
  • " + "
  • 2: Always show tab bar
  • " + "", - 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", @@ -691,7 +691,7 @@ vimperator.Options = function() //{{{ help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " + "\"Title of web page - Vimperator\".
    If you don't like that, you can restore it with: " + ":set titlestring=Mozilla Firefox.", - setter: function(value) { setTitleString(value); }, + setter: function (value) { setTitleString(value); }, default_value: "Vimperator" } )); @@ -699,8 +699,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 :setlocal 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 } )); @@ -710,13 +710,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 :javascript!.
    " + "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 } )); @@ -724,7 +724,7 @@ vimperator.Options = function() //{{{ { short_help: "CSS specification of the visual bell", help: "To hide the visual bell use a value of \"display: none;\" or unset it with :set t_vb=", - setter: function(value) { if (!value) value = "display: none;"; }, + setter: function (value) { if (!value) value = "display: none;"; }, default_value: "background-color: black; color: black;" } )); @@ -746,9 +746,9 @@ vimperator.Options = function() //{{{ "
    " + - data[data.length -1][0] + "
    " + "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); }); } } )); @@ -761,7 +761,7 @@ vimperator.Options = function() //{{{ "sortAlways sorts completion list, overriding the 'complete' option." + "", default_value: "", - validator: function(value) { return /^sort$/.test(value); } + validator: function (value) { return /^sort$/.test(value); } } )); //}}} diff --git a/content/tabs.js b/content/tabs.js index 8016fb8a..3e761fae 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -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) { diff --git a/content/test.js b/content/test.js index a09ce39e..80f6fc61 100755 --- a/content/test.js +++ b/content/test.js @@ -4,7 +4,7 @@ var assert = mozlab.mozunit.assertions; var tc = new TestCase('testcase description here'); tc.tests = { - 'First test is successful': function() { + 'First test is successful': function () { var vimperator = new Vimperator(); assert.isDefined(vimperator); assert.isTrue(true); diff --git a/content/ui.js b/content/ui.js index 0f7d49e0..993e2c7b 100644 --- a/content/ui.js +++ b/content/ui.js @@ -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 ///////////////////////////////////////// @@ -52,22 +52,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; @@ -75,7 +75,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; }); @@ -254,12 +254,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 @@ -281,7 +281,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()); @@ -292,7 +292,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) @@ -325,7 +325,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 @@ -336,7 +336,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 on blur() [old_mode, old_extended_mode] = vimperator.getMode(); @@ -350,12 +350,12 @@ vimperator.CommandLine = function() //{{{ multiline_input_widget.value = ""; autosizeMultilineInputWidget(); - setTimeout(function() { + setTimeout(function () { multiline_input_widget.focus(); }, 10); }; - this.clear = function() + this.clear = function () { multiline_input_widget.collapsed = true; multiline_output_widget.collapsed = true; @@ -364,14 +364,14 @@ vimperator.CommandLine = function() //{{{ setLine("", this.HL_NORMAL); }; - 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.hasMode(vimperator.modes.COMMAND_LINE) && !vimperator.hasMode(vimperator.modes.READ_MULTILINE) && !vimperator.hasMode(vimperator.modes.WRITE_MULTILINE)) @@ -495,7 +495,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]) @@ -611,7 +611,7 @@ vimperator.CommandLine = function() //{{{ } } - this.onMultilineInputEvent = function(event) + this.onMultilineInputEvent = function (event) { if (event.type == "keypress") { @@ -636,7 +636,7 @@ vimperator.CommandLine = function() //{{{ else if (event.type == "blur") { if (vimperator.hasMode(vimperator.modes.READ_MULTILINE)) - setTimeout(function() { multiline_input_widget.inputField.focus(); }, 0); + setTimeout(function () { multiline_input_widget.inputField.focus(); }, 0); } else if (event.type == "input") { @@ -646,7 +646,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; @@ -839,7 +839,7 @@ vimperator.CommandLine = function() //{{{ } // it would be better if we had a destructor in javascript ... - this.destroy = function() + this.destroy = function () { history.save(); } @@ -852,7 +852,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 ///////////////////////////////////////// @@ -952,7 +952,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"]; @@ -978,12 +978,12 @@ vimperator.InformationList = function(id, options) //{{{ } } - this.hide = function() + this.hide = function () { widget.hidden = true; } - this.visible = function() + this.visible = function () { return !widget.hidden; } @@ -991,7 +991,7 @@ vimperator.InformationList = function(id, options) //{{{ /** * select index, refill list if necessary */ - this.selectItem = function(index) + this.selectItem = function (index) { if (widget.hidden) return; @@ -1039,7 +1039,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 @@ -1055,7 +1055,7 @@ vimperator.InformationList = function(id, options) //{{{ //}}} } //}}} -vimperator.StatusLine = function() //{{{ +vimperator.StatusLine = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -1075,7 +1075,7 @@ vimperator.StatusLine = function() //{{{ ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - this.setClass = function(type) + this.setClass = function (type) { var highlight_group; @@ -1096,7 +1096,7 @@ vimperator.StatusLine = function() //{{{ }; // update all fields of the statusline - this.update = function() + this.update = function () { this.updateUrl(); this.updateInputBuffer(); @@ -1106,7 +1106,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") { @@ -1140,7 +1140,7 @@ vimperator.StatusLine = function() //{{{ url_widget.value = url; }; - this.updateInputBuffer = function(buffer) + this.updateInputBuffer = function (buffer) { if (!buffer || typeof buffer != "string") buffer = ""; @@ -1148,7 +1148,7 @@ vimperator.StatusLine = function() //{{{ inputbuffer_widget.value = buffer; }; - this.updateProgress = function(progress) + this.updateProgress = function (progress) { if (!progress) progress = ""; @@ -1179,7 +1179,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; @@ -1190,7 +1190,7 @@ vimperator.StatusLine = function() //{{{ }; // percent is given between 0 and 1 - this.updateBufferPosition = function(percent) + this.updateBufferPosition = function (percent) { if (!percent || typeof percent != "number") { diff --git a/content/util.js b/content/util.js index c81fb159..f67f5c5f 100644 --- a/content/util.js +++ b/content/util.js @@ -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); @@ -83,7 +83,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+/); @@ -158,7 +158,7 @@ vimperator.util = { return urls; }, - highlightURL: function(str, force) + highlightURL: function (str, force) { if (force || /^[a-zA-Z]+:\/\/.*\//.test(str)) return "" + vimperator.util.escapeHTML(str) + ""; @@ -166,7 +166,7 @@ vimperator.util = { return str; }, - formatNumber: function(num) + formatNumber: function (num) { var strNum = (num + "").split(".", 2); diff --git a/content/vimperator.js b/content/vimperator.js index bd32f6cd..d28d5d9e 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -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 ///////////////////////////////////////// @@ -135,13 +135,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) { for (var i in callbacks) { @@ -152,14 +152,14 @@ const vimperator = (function() //{{{ return false; }, - getMode: function() + getMode: function () { return [mode, extended_mode]; }, // set current mode // use "null" if you only want to set one of those modes - setMode: function(main, extended, silent) + setMode: function (main, extended, silent) { // if a main mode is set, the extended is always cleared if (main) @@ -176,12 +176,12 @@ const vimperator = (function() //{{{ // returns true if "whichmode" is found in either the main or // extended mode - hasMode: function(whichmode) + hasMode: function (whichmode) { return ((mode & whichmode) || (extended_mode & whichmode) > 0) ? true : false; }, - addMode: function(main, extended) + addMode: function (main, extended) { if (main) mode |= main; @@ -192,7 +192,7 @@ const vimperator = (function() //{{{ }, // always show the new mode in the statusline - removeMode: function(main, extended) + removeMode: function (main, extended) { if (main) mode = (mode | main) ^ main; @@ -202,7 +202,7 @@ const vimperator = (function() //{{{ showMode(); }, - beep: function() + beep: function () { if (vimperator.options["visualbell"]) { @@ -219,7 +219,7 @@ const vimperator = (function() //{{{ vbell.hidden = false - setTimeout(function() { vbell.hidden = true; }, 50); // may as well be 0 ;-) + setTimeout(function () { vbell.hidden = true; }, 50); // may as well be 0 ;-) } else { @@ -227,14 +227,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)) @@ -265,7 +265,7 @@ const vimperator = (function() //{{{ }, // after pressing Escape, put focus on a non-input field of the browser document - focusContent: function() + focusContent: function () { var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]. getService(Components.interfaces.nsIWindowWatcher); @@ -277,7 +277,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+)/); @@ -323,7 +323,7 @@ const vimperator = (function() //{{{ return; }, - variableReference: function(string) + variableReference: function (string) { if (!string) return [null, null, null]; @@ -351,7 +351,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"; @@ -361,9 +361,12 @@ const vimperator = (function() //{{{ var string = ""; var obj = ""; - try { // for window.JSON + try + { // for window.JSON obj = object.toString(); - } catch (e) { + } + catch (e) + { obj = "<Object>"; } @@ -400,7 +403,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") @@ -419,7 +422,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 @@ -479,7 +482,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 @@ -489,7 +492,7 @@ const vimperator = (function() //{{{ goQuitApplication(); }, - restart: function() + restart: function () { const nsIAppStartup = Components.interfaces.nsIAppStartup; @@ -521,7 +524,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"; @@ -609,7 +612,7 @@ const vimperator = (function() //{{{ // files which end in .js are sourced as pure javascript files, // no need (actually forbidden) to add: js <