diff --git a/content/buffers.js b/content/buffers.js index 85320fff..958ac412 100644 --- a/content/buffers.js +++ b/content/buffers.js @@ -32,7 +32,7 @@ vimperator.Buffer = function() //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ // used for the "B" mapping to remember the last :buffer[!] command - var lastBufferSwitchArgs = ""; + var lastBufferSwitchArgs = ""; var lastBufferSwitchSpecial = true; var zoom_manager = ZoomManager.prototype.getInstance(); diff --git a/content/commands.js b/content/commands.js index c2067057..462a56d6 100644 --- a/content/commands.js +++ b/content/commands.js @@ -113,10 +113,14 @@ vimperator.Command.prototype.hasName = function(name) for (var i = 0; i < this.specs.length; i++) { if (this.specs[i] == name) // literal command name + { return true; + } else if (this.specs[i].match(/^(\w+|!)\[\w+\]$/)) // abbreviation spec + { if (matchAbbreviation(name, this.specs[i])) return true; + } } return false; } @@ -413,7 +417,7 @@ vimperator.Commands = function() //{{{ if (special && args) { vimperator.echoerr("E474: Invalid argument"); - return + return; } var matches; if (matches = args.match(/(?:(?:^|[^a-zA-Z0-9])-|-(?:$|[^a-zA-Z0-9])|[^a-zA-Z0-9 -]).*/)) @@ -467,7 +471,7 @@ vimperator.Commands = function() //{{{ if (special && args) { vimperator.echoerr("E474: Invalid argument"); - return + return; } if (special) @@ -788,7 +792,7 @@ vimperator.Commands = function() //{{{ return; } - var matches = args.match(/^([^\s]+)(?:\s+(.+))?$/) + var matches = args.match(/^([^\s]+)(?:\s+(.+))?$/); var [lhs, rhs] = [matches[1], matches[2]]; var leader_reg = //i; @@ -874,7 +878,7 @@ vimperator.Commands = function() //{{{ } var filter = args.replace(/[^a-zA-Z]/g, ''); - vimperator.marks.list(filter) + vimperator.marks.list(filter); }, { usage: ["marks [arg]"], @@ -884,20 +888,20 @@ vimperator.Commands = function() //{{{ )); addDefaultCommand(new vimperator.Command(["mkv[imperatorrc]"], function(args, special) - { + { var filename; - + // TODO: "E172: Only one file name allowed" if (args) filename = args; else filename = vimperator.io.expandPath(navigator.platform == "Win32" ? "~/_vimperatorrc" : "~/.vimperatorrc"); - + var file = vimperator.io.getFile(filename); if (file.exists() && !special) { vimperator.echoerr("E189: \".vimperatorrc\" exists (add ! to override)"); - return + return; } var line = "\" " + vimperator.version + "\n"; @@ -910,7 +914,7 @@ vimperator.Commands = function() //{{{ } for (var option in vimperator.options) - { + { // TODO: options should be queried for this info // TODO: string/list options might need escaping in future if (!/fullscreen|usermode/.test(option.name) && option.value != option.default_value) @@ -926,7 +930,7 @@ vimperator.Commands = function() //{{{ vimperator.io.writeFile(file, line); }, - { + { usage: ["mkv[imperatorrc] [file]"], short_help: "Write current keymappings and changed options to [file]", help: "If no [file] is specified then ~/.vimperatorrc is written unless this file already exists. " + @@ -1207,7 +1211,7 @@ vimperator.Commands = function() //{{{ var only_non_default = false; //used for :set to print non-default options if (!args) { - args = "all?" + args = "all?"; only_non_default = true; } @@ -1389,14 +1393,14 @@ vimperator.Commands = function() //{{{ // do nothing if the requested sidebar is already open if (document.getElementById("sidebar-title").value == args) return; - - var menu = document.getElementById("viewSidebarMenu") + + var menu = document.getElementById("viewSidebarMenu"); for (var i = 0; i < menu.childNodes.length; i++) { if (menu.childNodes[i].label == args) { - eval(menu.childNodes[i].getAttribute('oncommand')) + eval(menu.childNodes[i].getAttribute('oncommand')); break; } } @@ -1557,11 +1561,15 @@ vimperator.Commands = function() //{{{ var before_time = Date.now(); if (args && args[0] == ":") + { while (i--) vimperator.execute(args); + } else + { while (i--) eval(args); + } if (special) return; @@ -1700,7 +1708,7 @@ vimperator.Commands = function() //{{{ short_help: "Undo closing of all closed tabs", help: "Firefox stores up to 10 closed tabs, even after a browser restart." } - )), + )); addDefaultCommand(new vimperator.Command(["unl[et]"], function(args, special) { @@ -1780,7 +1788,7 @@ vimperator.Commands = function() //{{{ }, { usage: ["winc[ose] [url] [, url]"], - short_help: "Close window", + short_help: "Close window" } )); addDefaultCommand(new vimperator.Command(["wino[pen]", "wo[pen]", "wine[dit]"], @@ -1862,7 +1870,7 @@ vimperator.Commands = function() //{{{ args = args.replace(/(^|[^\\])!/g, "$1" + last_run_command); last_run_command = args; - var output = vimperator.system(args) + var output = vimperator.system(args); if (output) vimperator.echo(vimperator.util.escapeHTML(output)); }, @@ -1910,7 +1918,7 @@ String.prototype.toURLArray = function() // {{{ { var location = window.content.document.location; var tail = matches[1] ? matches[1] : ""; - urls[url] = location.protocol + "//" + location.host + "/" + tail + urls[url] = location.protocol + "//" + location.host + "/" + tail; continue; } @@ -1919,7 +1927,7 @@ String.prototype.toURLArray = function() // {{{ // or keyword bookmark if (/\s/.test(urls[url]) || !/[.:\/]/.test(urls[url])) { - matches = urls[url].match(/^(\S+)(?:\s+(.+))?$/) + matches = urls[url].match(/^(\S+)(?:\s+(.+))?$/); var alias = matches[1]; var text = matches[2] ? matches[2] : null; diff --git a/content/completion.js b/content/completion.js index 5121594d..9534900d 100644 --- a/content/completion.js +++ b/content/completion.js @@ -278,12 +278,7 @@ 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($_) { return [ @@ -292,7 +287,7 @@ vimperator.Completion = function() // {{{ ]; })); for (var map in vimperator.mappings) - help_array.push([map.names, map.short_help]) + help_array.push([map.names, map.short_help]); if (!filter) return help_array.map(function($_) { return [$_[0][0], $_[1]]; // unfiltered, use the first command @@ -304,7 +299,7 @@ vimperator.Completion = function() // {{{ get_command_completions: function(filter) //{{{ { g_substrings = []; - var completions = [] + var completions = []; if (!filter) { for (var command in vimperator.commands) @@ -333,7 +328,7 @@ vimperator.Completion = function() // {{{ { if (prefix && option.type != "boolean") continue; - options.push([option.names, option.short_help]) + options.push([option.names, option.short_help]); } return options; } @@ -345,7 +340,7 @@ vimperator.Completion = function() // {{{ { if (prefix && option.type != "boolean") continue; - options.push([prefix + option.name, option.short_help]) + options.push([prefix + option.name, option.short_help]); } return options; } @@ -447,7 +442,7 @@ vimperator.Completion = function() // {{{ var mapped = nodes.map(function(node) { return [[node[0]], node[1]]; }); - + return build_longest_common_substring(mapped, filter); }, //}}} @@ -489,7 +484,7 @@ vimperator.Completion = function() // {{{ } object = matches[1].substr(start+1) || "window"; - var completions = []; + var completions = []; try { completions = eval( @@ -513,7 +508,11 @@ vimperator.Completion = function() // {{{ " else {" + " comp.push([[i], type]); }" + "} comp;"); - } catch (e) { completions = []; }; + } + catch (e) + { + completions = []; + } return build_longest_starting_substring(completions, filter); }, // }}} diff --git a/content/events.js b/content/events.js index 3896f259..c00e00f3 100644 --- a/content/events.js +++ b/content/events.js @@ -40,7 +40,7 @@ vimperator.Events = function() //{{{ // any tab related events var tabcontainer = getBrowser().tabContainer; tabcontainer.addEventListener("TabMove", function(event) { - vimperator.statusline.updateTabCount() + vimperator.statusline.updateTabCount(); vimperator.buffer.updateBufferList(); }, false); tabcontainer.addEventListener("TabOpen", function(event) { @@ -48,7 +48,7 @@ vimperator.Events = function() //{{{ vimperator.buffer.updateBufferList(); }, false); tabcontainer.addEventListener("TabClose", function(event) { - vimperator.statusline.updateTabCount() + vimperator.statusline.updateTabCount(); vimperator.buffer.updateBufferList(); }, false); tabcontainer.addEventListener("TabSelect", function(event) { @@ -152,7 +152,7 @@ vimperator.Events = function() //{{{ [ KeyEvent.DOM_VK_F21, ["F21"] ], [ KeyEvent.DOM_VK_F22, ["F22"] ], [ KeyEvent.DOM_VK_F23, ["F23"] ], - [ KeyEvent.DOM_VK_F24, ["F24"] ], + [ KeyEvent.DOM_VK_F24, ["F24"] ] ]; function getKeyCode(str) @@ -372,13 +372,13 @@ vimperator.Events = function() //{{{ switch (event.button) { case 0: - key = "LeftMouse" + key = "LeftMouse"; break; case 1: - key = "MiddleMouse" + key = "MiddleMouse"; break; case 2: - key = "RightMouse" + key = "RightMouse"; break; } } @@ -774,9 +774,9 @@ vimperator.Events = function() //{{{ }, // stub functions for the interfaces - setJSStatus : function(status) { ; }, - setJSDefaultStatus : function(status) { ; }, - setDefaultStatus : function(status) { ; }, + setJSStatus: function(status) { ; }, + setJSDefaultStatus: function(status) { ; }, + setDefaultStatus: function(status) { ; }, onLinkIconAvailable: function() { ; } }; diff --git a/content/find.js b/content/find.js index fa51bd8a..712d8e91 100644 --- a/content/find.js +++ b/content/find.js @@ -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,10 +96,10 @@ 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') + pattern = pattern.replace(/\\(\\[cCuU])/g, '$1'); search_string = pattern; } @@ -246,8 +246,8 @@ vimperator.Search = function() //{{{ (function(win) { for (var i = 0; i < win.frames.length; i++) - arguments.callee(win.frames[i]) - var spans = vimperator.buffer.evaluateXPath('//span[@id="__firefox-findbar-search-id"]', win.document) + arguments.callee(win.frames[i]); + var spans = vimperator.buffer.evaluateXPath('//span[@id="__firefox-findbar-search-id"]', win.document); for (var i = 0; i < spans.snapshotLength; i++) spans.snapshotItem(i).setAttribute("style", vimperator.options["hlsearchstyle"]); })(window.content); diff --git a/content/help.js b/content/help.js index 45e054ac..c10fdf78 100644 --- a/content/help.js +++ b/content/help.js @@ -131,7 +131,7 @@ vimperator.help = function(section, easter) //{{{ return ret; } - var header = '

Vimperator

' + + var header = '

Vimperator

' + '

First there was a Navigator, then there was an Explorer.\n' + 'Later it was time for a Konqueror. Now it\'s time for an Imperator, the VIMperator :)

'; @@ -155,7 +155,7 @@ vimperator.help = function(section, easter) //{{{ '' + '' + - '

Of course as a believer in free open source software, only make a donation if you really like Vimperator and the money doesn\'t hurt - otherwise just use it, recommend it and like it :)

' + '

Of course as a believer in free open source software, only make a donation if you really like Vimperator and the money doesn\'t hurt - otherwise just use it, recommend it and like it :)

'; var initialization = 'initialization

Initialization

' + '

At startup Vimperator sources a user RC file, containing Ex commands, and any JavaScript files found in the plugin directory.

' + @@ -178,7 +178,7 @@ vimperator.help = function(section, easter) //{{{ var mappings = 'mappings

Mappings

' + '

The denotion of modifier keys is like in Vim, so C- means the Control key, M- the Meta key, A- the Alt key and S- the Shift key.

'+ - '' + '
'; mappings += makeHelpString(vimperator.mappings, "", "", null); mappings += '
'; if (section && section == 'holy-grail') diff --git a/content/hints.js b/content/hints.js index 2d4a625b..034cf83a 100644 --- a/content/hints.js +++ b/content/hints.js @@ -412,7 +412,7 @@ vimperator.Hints = function() //{{{ showHints(null, 0); return true; - }; + } /** * Disables the HaH-mode by hiding the hints and disabling the input mode diff --git a/content/io.js b/content/io.js index b861652a..54d58e27 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); diff --git a/content/mappings.js b/content/mappings.js index c6d48f84..4738adb6 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -143,7 +143,7 @@ vimperator.Mappings = function() //{{{ { if (names[j] == cmd) { - names.splice(j, 1) + names.splice(j, 1); if (names.length == 0) maps.splice(i, 1); @@ -260,7 +260,7 @@ vimperator.Mappings = function() //{{{ for (var j = 0; j < map.names.length; j++) { if (map.names[j].indexOf(cmd) == 0) - matches.push(map) + matches.push(map); } } @@ -284,7 +284,7 @@ vimperator.Mappings = function() //{{{ for (var j = 0; j < maps[i].names.length; j++) { list += ""; - list += " " + vimperator.util.escapeHTML(maps[i].names[j]) + "" + list += " " + vimperator.util.escapeHTML(maps[i].names[j]) + ""; if (maps[i].rhs) list += " " + vimperator.util.escapeHTML(maps[i].rhs) + "" list += ""; @@ -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}"], @@ -516,7 +516,7 @@ vimperator.Mappings = function() //{{{ // should probably reopen the closed tab when a 'deleted' // alternate is selected if (index == -1) - vimperator.echoerr("E86: Buffer does not exist") // TODO: This should read "Buffer N does not exist" + vimperator.echoerr("E86: Buffer does not exist"); // TODO: This should read "Buffer N does not exist" else vimperator.tabs.select(index); }, @@ -535,7 +535,7 @@ vimperator.Mappings = function() //{{{ return; } - vimperator.marks.add(arg) + vimperator.marks.add(arg); }, { short_help: "Set mark at the cursor position", @@ -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}"], @@ -562,7 +562,7 @@ vimperator.Mappings = function() //{{{ return; } - vimperator.quickmarks.add(arg, vimperator.buffer.URL) + vimperator.quickmarks.add(arg, vimperator.buffer.URL); }, { short_help: "Add new QuickMark for current URL", diff --git a/content/options.js b/content/options.js index 449af7bf..8005274f 100644 --- a/content/options.js +++ b/content/options.js @@ -439,7 +439,7 @@ vimperator.Options = function() //{{{ "" + "The order matters", default_value: "gm", - validator: function (value) { if (/[^gm]/.test(value) || value.length > 2 || + validator: function (value) { if (/[^gm]/.test(value) || value.length > 2 || value.length < 1) return false; else return true; } } )); diff --git a/content/tabs.js b/content/tabs.js index 220523d3..f2a85ead 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -256,7 +256,8 @@ vimperator.Tabs = function() //{{{ { this.reload(getBrowser().mTabs[i], bypass_cache) } - catch (e) { + catch (e) + { // FIXME: can we do anything useful here without stopping the // other tabs from reloading? } diff --git a/content/ui.js b/content/ui.js index 864999ac..a7ff62d0 100644 --- a/content/ui.js +++ b/content/ui.js @@ -93,7 +93,7 @@ vimperator.CommandLine = function() //{{{ // for the example command "open sometext| othertext" (| is the cursor pos): var completion_start_index = 0; // will be 5 because we want to complete arguments for the :open command - var completion_prefix = "" // will be: "open sometext" + var completion_prefix = ""; // will be: "open sometext" var completion_postfix = ""; // will be: " othertext" var wild_index = 0; // keep track how often we press in a row @@ -682,7 +682,7 @@ vimperator.CommandLine = function() //{{{ if (vimperator.options["more"] && isScrollable() && !atEnd()) win.scrollByLines(1); else - close_window = true;; // don't propagate the event for accept keys + close_window = true; // don't propagate the event for accept keys break; // up a line @@ -807,7 +807,7 @@ vimperator.CommandLine = function() //{{{ // close the window case "q": - close_window = true;; + close_window = true; break; // unmapped key diff --git a/content/util.js b/content/util.js index f095a95b..203543fd 100644 --- a/content/util.js +++ b/content/util.js @@ -28,7 +28,7 @@ the terms of any one of the MPL, the GPL or the LGPL. vimperator.util = { escapeHTML: function(str) - { + { var e = window.content.document.createElement("div"); e.appendChild(window.content.document.createTextNode(str)); return e.innerHTML; @@ -51,7 +51,7 @@ vimperator.util = { arg = '"' + vimperator.util.escapeHTML(arg.replace(/\n/, "\\n")) + '"'; return "" + arg + ""; - } + } else if (type == "boolean") { return "" + arg + ""; @@ -62,9 +62,9 @@ vimperator.util = { } else if (type == "object" || type == "function") { - // for java packages value.toString() would crash so badly + // for java packages value.toString() would crash so badly // that we cannot even try/catch it - if (/^\[JavaPackage.*\]$/.test(arg)) + if (/^\[JavaPackage.*\]$/.test(arg)) return "[JavaPackage]"; var str = arg.toString(); diff --git a/content/vimperator.js b/content/vimperator.js index 1debbba0..27f94a28 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -456,7 +456,7 @@ const vimperator = (function() //{{{ var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); whichwindow = wm.getMostRecentWindow("navigator:browser"); - whichwindow.loadURI(url, null, postdata) + whichwindow.loadURI(url, null, postdata); break; default: @@ -559,7 +559,7 @@ const vimperator = (function() //{{{ var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); process.init(file); - + var ec = process.run(blocking, args, args.length); return ec; }, @@ -801,16 +801,16 @@ const vimperator = (function() //{{{ sleep: function(ms) { - var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager); - var mainThread = threadManager.mainThread; + var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager); + var mainThread = threadManager.mainThread; - var then = new Date().getTime(), now = then; - for (; now - then < ms; now = new Date().getTime()) { - mainThread.processNextEvent(true); - } + var then = new Date().getTime(), now = then; + for (; now - then < ms; now = new Date().getTime()) { + mainThread.processNextEvent(true); + } }, - get windows() + get windows() { var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var wa = [];