diff --git a/content/bookmarks.js b/content/bookmarks.js index d17b594d..56f1a6a5 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 -function Bookmarks() //{{{ +vimperator.Bookmarks = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -328,7 +328,7 @@ function Bookmarks() //{{{ //}}} } //}}} -function History() //{{{ +vimperator.History = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -477,7 +477,7 @@ function History() //{{{ //}}} } //}}} -function Marks() //{{{ +vimperator.Marks = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -732,7 +732,7 @@ function Marks() //{{{ //}}} } //}}} -function QuickMarks() //{{{ +vimperator.QuickMarks = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// diff --git a/content/buffers.js b/content/buffers.js index b7730860..5502bba5 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 *****/ -function Buffer() //{{{ +vimperator.Buffer = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// diff --git a/content/commands.js b/content/commands.js index 8c3ca87e..9bc4d995 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 *****/ -function Command(specs, action, extra_info) //{{{ +vimperator.Command = function(specs, action, extra_info) //{{{ { if (!specs || !action) return null; @@ -90,14 +90,14 @@ function Command(specs, action, extra_info) //{{{ } -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) -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 @@ -123,7 +123,7 @@ Command.prototype.hasName = function(name) } //}}} -function Commands() //{{{ +vimperator.Commands = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -143,7 +143,7 @@ function Commands() //{{{ function addDefaultCommand(command) { ex_commands.push(command); - 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); } @@ -522,14 +522,14 @@ function Commands() //{{{ ////////////////////// DEFAULT COMMANDS //////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - addDefaultCommand(new Command(["addo[ns]"], + addDefaultCommand(new vimperator.Command(["addo[ns]"], 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 keybindings and changes Firefox's GUI." } )); - addDefaultCommand(new Command(["ba[ck]"], + addDefaultCommand(new vimperator.Command(["ba[ck]"], function(args, special, count) { if (special) @@ -572,7 +572,7 @@ function Commands() //{{{ } } )); - addDefaultCommand(new Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"], + addDefaultCommand(new vimperator.Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"], function(args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, special, 0); }, { usage: ["[count]bd[elete][!]"], @@ -581,13 +581,13 @@ function Commands() //{{{ "Do :bdelete! to select the tab to the left after removing the current tab." } )); - addDefaultCommand(new Command(["beep"], + addDefaultCommand(new vimperator.Command(["beep"], function() { vimperator.beep(); }, { short_help: "Play a system beep" } )); - addDefaultCommand(new Command(["bma[rk]"], + addDefaultCommand(new vimperator.Command(["bma[rk]"], function(args) { var res = parseArgs(args, this.args); @@ -620,7 +620,7 @@ function Commands() //{{{ [["-keyword", "-k"], OPTION_STRING, function(arg) { return /\w/.test(arg); } ]] } )); - addDefaultCommand(new Command(["bmarks"], + addDefaultCommand(new vimperator.Command(["bmarks"], function(args, special) { var res = parseArgs(args, this.args); @@ -641,7 +641,7 @@ function Commands() //{{{ args: [[["-tags", "-T"], OPTION_LIST]] } )); - addDefaultCommand(new Command(["b[uffer]"], + addDefaultCommand(new vimperator.Command(["b[uffer]"], function(args, special) { vimperator.buffer.switchTo(args, special); }, { usage: ["b[uffer][!] {url|index}"], @@ -654,7 +654,7 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.get_buffer_completions(filter); } } )); - addDefaultCommand(new Command(["buffers", "files", "ls", "tabs"], + addDefaultCommand(new vimperator.Command(["buffers", "files", "ls", "tabs"], function(args, special) { if (args) @@ -672,7 +672,7 @@ function Commands() //{{{ "Call the special version of this command again to close the window." } )); - addDefaultCommand(new Command(["delbm[arks]"], + addDefaultCommand(new vimperator.Command(["delbm[arks]"], function(args, special) { var url = args; @@ -693,7 +693,7 @@ function Commands() //{{{ completer: function(filter) { return vimperator.bookmarks.get(filter); } } )); - addDefaultCommand(new Command(["com[mand]"], + addDefaultCommand(new vimperator.Command(["com[mand]"], function(args) { var res = parseArgs(args, this.args); @@ -711,7 +711,7 @@ function Commands() //{{{ [["-bar"], OPTION_NOARG]] } )); - addDefaultCommand(new Command(["delm[arks]"], + addDefaultCommand(new vimperator.Command(["delm[arks]"], function(args, special) { if (!special && !args) @@ -764,7 +764,7 @@ function Commands() //{{{ } )); - addDefaultCommand(new Command(["delqm[arks]"], + addDefaultCommand(new vimperator.Command(["delqm[arks]"], function(args, special) { // TODO: finish arg parsing - we really need a proper way to do this. :) @@ -793,7 +793,7 @@ function Commands() //{{{ ":delqmarks! deletes all QuickMarks" } )); - addDefaultCommand(new Command(["downl[oads]", "dl"], + addDefaultCommand(new vimperator.Command(["downl[oads]", "dl"], function() { vimperator.open("chrome://mozapps/content/downloads/downloads.xul", vimperator.NEW_TAB); }, { short_help: "Show progress of current downloads", @@ -829,7 +829,7 @@ function Commands() //{{{ return arg; } - addDefaultCommand(new Command(["ec[ho]"], + addDefaultCommand(new vimperator.Command(["ec[ho]"], function(args) { var res = argToString(args, true); @@ -845,7 +845,7 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.javascript(filter); } } )); - addDefaultCommand(new Command(["echoe[rr]"], + addDefaultCommand(new vimperator.Command(["echoe[rr]"], function(args) { var res = argToString(args, false); @@ -859,7 +859,7 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.javascript(filter); } } )); - addDefaultCommand(new Command(["exe[cute]"], + addDefaultCommand(new vimperator.Command(["exe[cute]"], function(args) { // TODO: :exec has some difficult semantics -> later @@ -877,13 +877,13 @@ function Commands() //{{{ help: "Example: :execute echo test shows a message with the text "test".
" } )); - addDefaultCommand(new Command(["exu[sage]"], + addDefaultCommand(new vimperator.Command(["exu[sage]"], function(args, special, count, modifiers) { vimperator.help("commands", special, null, modifiers); }, { short_help: "Show help for Ex commands" } )); - addDefaultCommand(new Command(["fo[rward]", "fw"], + addDefaultCommand(new vimperator.Command(["fo[rward]", "fw"], function(args, special, count) { if (special) @@ -926,14 +926,14 @@ function Commands() //{{{ } } )); - addDefaultCommand(new Command(["ha[rdcopy]"], + addDefaultCommand(new vimperator.Command(["ha[rdcopy]"], 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 Command(["h[elp]"], + addDefaultCommand(new vimperator.Command(["h[elp]"], function(args, special, count, modifiers) { vimperator.help(args, special, null, modifiers); }, { usage: ["h[elp] {subject}"], @@ -949,7 +949,7 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.get_help_completions(filter); } } )); - addDefaultCommand(new Command(["hist[ory]", "hs"], + addDefaultCommand(new vimperator.Command(["hist[ory]", "hs"], function(args, special) { vimperator.history.list(args, special); }, { usage: ["hist[ory] [filter]", "history!"], @@ -959,7 +959,7 @@ function Commands() //{{{ completer: function(filter) { return vimperator.history.get(filter); } } )); - addDefaultCommand(new Command(["javas[cript]", "js"], + addDefaultCommand(new vimperator.Command(["javas[cript]", "js"], function(args, special) { if (special) // open javascript console @@ -1008,7 +1008,7 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.javascript(filter); } } )); - addDefaultCommand(new Command(["let"], + addDefaultCommand(new vimperator.Command(["let"], function(args) { if (!args) @@ -1095,7 +1095,7 @@ function Commands() //{{{ "Without arguments, displays a list of all variables." } )); - addDefaultCommand(new Command(["map"], + addDefaultCommand(new vimperator.Command(["map"], // 0 args -> list all maps // 1 arg -> list the maps starting with args // 2 args -> map arg1 to arg* @@ -1138,7 +1138,7 @@ function Commands() //{{{ "Mappings are NOT saved during sessions, make sure you put them in your vimperatorrc file!" } )); - addDefaultCommand(new Command(["mapc[lear]"], + addDefaultCommand(new vimperator.Command(["mapc[lear]"], function(args) { if (args) @@ -1155,7 +1155,7 @@ function Commands() //{{{ ":map or :noremap are cleared." } )); - addDefaultCommand(new Command(["ma[rk]"], + addDefaultCommand(new vimperator.Command(["ma[rk]"], function(args) { if (!args) @@ -1181,7 +1181,7 @@ function Commands() //{{{ short_help: "Mark current location within the web page" } )); - addDefaultCommand(new Command(["marks"], + addDefaultCommand(new vimperator.Command(["marks"], function(args) { // ignore invalid mark characters unless there are no valid mark chars @@ -1200,7 +1200,7 @@ function Commands() //{{{ help: "If [arg] is specified then limit the list to those marks mentioned." } )); - addDefaultCommand(new Command(["mkv[imperatorrc]"], + addDefaultCommand(new vimperator.Command(["mkv[imperatorrc]"], function(args, special) { var filename; @@ -1251,7 +1251,7 @@ function Commands() //{{{ "WARNING: this differs from Vim's behaviour which defaults to writing the file in the current directory." } )); - addDefaultCommand(new Command(["noh[lsearch]"], + addDefaultCommand(new vimperator.Command(["noh[lsearch]"], function(args) { vimperator.search.clear(); @@ -1262,7 +1262,7 @@ function Commands() //{{{ "'hlsearch' option is set." } )); - addDefaultCommand(new Command(["norm[al]"], + addDefaultCommand(new vimperator.Command(["norm[al]"], function(args) { if (!args) @@ -1280,7 +1280,7 @@ function Commands() //{{{ } )); // TODO: remove duplication in :map - addDefaultCommand(new Command(["no[remap]"], + addDefaultCommand(new vimperator.Command(["no[remap]"], // 0 args -> list all maps // 1 arg -> list the maps starting with args // 2 args -> map arg1 to arg* @@ -1333,7 +1333,7 @@ function Commands() //{{{ help: "No remapping of the {rhs} is performed.
NOTE: :noremap does not yet work as reliably as :map." } )); - addDefaultCommand(new Command(["o[pen]", "e[dit]"], + addDefaultCommand(new vimperator.Command(["o[pen]", "e[dit]"], function(args, special) { if (args) @@ -1376,13 +1376,13 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.get_url_completions(filter); } } )); - addDefaultCommand(new Command(["pc[lose]"], + addDefaultCommand(new vimperator.Command(["pc[lose]"], function() { vimperator.previewwindow.hide(); }, { short_help: "Close preview window on bottom of screen" } )); - addDefaultCommand(new Command(["pref[erences]", "prefs"], + addDefaultCommand(new vimperator.Command(["pref[erences]", "prefs"], function(args, special, count, modifiers) { if (!args) @@ -1414,7 +1414,7 @@ function Commands() //{{{ ":prefs! opens about:config in the current tab where you can change advanced Firefox preferences." } )); - addDefaultCommand(new Command(["qma[rk]"], + addDefaultCommand(new vimperator.Command(["qma[rk]"], function(args) { if (!args) @@ -1440,7 +1440,7 @@ function Commands() //{{{ ":qmark f http://forum1.com, http://forum2.com, imdb some artist" } )); - addDefaultCommand(new Command(["qmarks"], + addDefaultCommand(new vimperator.Command(["qmarks"], function(args) { // ignore invalid mark characters unless there are no valid mark chars @@ -1459,7 +1459,7 @@ function Commands() //{{{ help: "If [arg] is specified then limit the list to those QuickMarks mentioned." } )); - addDefaultCommand(new Command(["q[uit]"], + addDefaultCommand(new vimperator.Command(["q[uit]"], function() { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); }, { short_help: "Quit current tab", @@ -1467,14 +1467,14 @@ function Commands() //{{{ "last window, close Vimperator. When quitting Vimperator, the session is not stored." } )); - addDefaultCommand(new Command(["quita[ll]", "qa[ll]"], + addDefaultCommand(new vimperator.Command(["quita[ll]", "qa[ll]"], 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 Command(["redr[aw]"], + addDefaultCommand(new vimperator.Command(["redr[aw]"], function() { var wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). @@ -1486,7 +1486,7 @@ function Commands() //{{{ help: "Useful to update the screen halfway executing a script or function." } )); - addDefaultCommand(new Command(["re[load]"], + addDefaultCommand(new vimperator.Command(["re[load]"], function(args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); }, { usage: ["re[load][!]"], @@ -1494,7 +1494,7 @@ function Commands() //{{{ help: "Forces reloading of the current page. If ! is given, skip the cache." } )); - addDefaultCommand(new Command(["reloada[ll]"], + addDefaultCommand(new vimperator.Command(["reloada[ll]"], function(args, special) { vimperator.tabs.reloadAll(special); }, { usage: ["reloada[ll][!]"], @@ -1502,14 +1502,14 @@ function Commands() //{{{ help: "Forces reloading of all pages. If ! is given, skip the cache." } )); - addDefaultCommand(new Command(["res[tart]"], + addDefaultCommand(new vimperator.Command(["res[tart]"], function() { vimperator.restart(); }, { short_help: "Force the browser to restart", help: "Useful when installing extensions." } )); - addDefaultCommand(new Command(["sav[eas]", "w[rite]"], + addDefaultCommand(new vimperator.Command(["sav[eas]", "w[rite]"], function() { saveDocument(window.content.document); }, { short_help: "Save current web page to disk", @@ -1517,7 +1517,7 @@ function Commands() //{{{ "There, you can save the current web page to disk with various options." } )); - addDefaultCommand(new Command(["se[t]"], + addDefaultCommand(new vimperator.Command(["se[t]"], function(args, special, count, modifiers) { if (special) @@ -1682,7 +1682,7 @@ function Commands() //{{{ } )); // TODO: sclose instead? - addDefaultCommand(new Command(["sbcl[ose]"], + addDefaultCommand(new vimperator.Command(["sbcl[ose]"], function(args) { if (args) @@ -1700,7 +1700,7 @@ function Commands() //{{{ )); // TODO: sopen instead? Separate :sidebar from :sbopen and make them behave // more like :cw, :cope etc - addDefaultCommand(new Command(["sideb[ar]", "sb[ar]", "sbope[n]"], + addDefaultCommand(new vimperator.Command(["sideb[ar]", "sb[ar]", "sbope[n]"], function(args) { if (!args) @@ -1735,7 +1735,7 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.get_sidebar_completions(filter); } } )); - addDefaultCommand(new Command(["so[urce]"], + addDefaultCommand(new vimperator.Command(["so[urce]"], function(args) { // FIXME: implement proper filename quoting @@ -1762,14 +1762,14 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.get_file_completions(filter); } } )); - addDefaultCommand(new Command(["st[op]"], + addDefaultCommand(new vimperator.Command(["st[op]"], BrowserStop, { short_help: "Stop loading", help: "Stop loading current web page." } )); - addDefaultCommand(new Command(["tab"], + addDefaultCommand(new vimperator.Command(["tab"], function(args) { vimperator.execute(args, { inTab: true }); }, { usage: ["tab {cmd}"], @@ -1780,13 +1780,13 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.get_command_completions(filter); } } )); - addDefaultCommand(new Command(["tabl[ast]"], + addDefaultCommand(new vimperator.Command(["tabl[ast]"], function() { vimperator.tabs.select("$", false); }, { short_help: "Switch to the last tab" } )); - addDefaultCommand(new Command(["tabm[ove]"], + addDefaultCommand(new vimperator.Command(["tabm[ove]"], function(args, special) { vimperator.tabs.move(getBrowser().mCurrentTab, args, special); }, { usage: ["tabm[ove] [N]", "tabm[ove][!] +N | -N"], @@ -1795,20 +1795,20 @@ function Commands() //{{{ "N can also be prefixed with '+' or '-' to indicate a relative movement. If ! is specified the movement wraps around the start or end of the tab list." } )); - addDefaultCommand(new Command(["tabn[ext]", "tn[ext]"], + addDefaultCommand(new vimperator.Command(["tabn[ext]", "tn[ext]"], function() { vimperator.tabs.select("+1", true); }, { short_help: "Switch to the next tab", help: "Cycles to the first tab, when the last is selected." } )); - addDefaultCommand(new Command(["tabo[nly]"], + addDefaultCommand(new vimperator.Command(["tabo[nly]"], function() { vimperator.tabs.keepOnly(getBrowser().mCurrentTab); }, { short_help: "Close all other tabs" } )); - addDefaultCommand(new Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"], + addDefaultCommand(new vimperator.Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"], function(args, special) { var where = special ? vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB; @@ -1828,7 +1828,7 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.get_url_completions(filter); } } )); - addDefaultCommand(new Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"], + addDefaultCommand(new vimperator.Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"], function() { vimperator.tabs.select("-1", true); }, { usage: ["tabp[revious]", "tabN[ext]"], @@ -1836,14 +1836,14 @@ function Commands() //{{{ help: "Cycles to the last tab, when the first is selected." } )); - addDefaultCommand(new Command(["tabr[ewind]", "tabfir[st]"], + addDefaultCommand(new vimperator.Command(["tabr[ewind]", "tabfir[st]"], function() { vimperator.tabs.select(0, false); }, { usage: ["tabr[ewind]", "tabfir[st]"], short_help: "Switch to the first tab" } )); - addDefaultCommand(new Command(["time"], + addDefaultCommand(new vimperator.Command(["time"], function(args, special, count) { if (!count || count < 1) @@ -1928,7 +1928,7 @@ function Commands() //{{{ "Use the special version with [!] if you just want to run any command multiple times without showing profiling statistics." } )); - addDefaultCommand(new Command(["u[ndo]"], + addDefaultCommand(new vimperator.Command(["u[ndo]"], function(args, special, count) { if (count < 1) @@ -1972,7 +1972,7 @@ function Commands() //{{{ } } )); - addDefaultCommand(new Command(["undoa[ll]"], + addDefaultCommand(new vimperator.Command(["undoa[ll]"], function(args, special, count) { if (count || special) @@ -1988,7 +1988,7 @@ function Commands() //{{{ help: "Firefox stores up to 10 closed tabs, even after a browser restart." } )), - addDefaultCommand(new Command(["unl[et]"], + addDefaultCommand(new vimperator.Command(["unl[et]"], function(args, special) { if (!args) @@ -2017,7 +2017,7 @@ function Commands() //{{{ "Several variable names can be given." } )); - addDefaultCommand(new Command(["unm[ap]"], + addDefaultCommand(new vimperator.Command(["unm[ap]"], function(args) { if (!args) @@ -2039,7 +2039,7 @@ function Commands() //{{{ help: "" } )); - addDefaultCommand(new Command(["ve[rsion]"], + addDefaultCommand(new vimperator.Command(["ve[rsion]"], function(args, special) { if (special) @@ -2054,13 +2054,13 @@ function Commands() //{{{ help: "You can show the Firefox version page with :version!." } )); - addDefaultCommand(new Command(["viu[sage]"], + addDefaultCommand(new vimperator.Command(["viu[sage]"], function(args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); }, { short_help: "Show help for normal mode commands" } )); - addDefaultCommand(new Command(["winc[lose]", "wc[lose]"], + addDefaultCommand(new vimperator.Command(["winc[lose]", "wc[lose]"], function(args) { window.close(); @@ -2070,7 +2070,7 @@ function Commands() //{{{ short_help: "Close window", } )); - addDefaultCommand(new Command(["wino[pen]", "wo[pen]", "wine[dit]"], + addDefaultCommand(new vimperator.Command(["wino[pen]", "wo[pen]", "wine[dit]"], function(args) { if (args) @@ -2084,7 +2084,7 @@ function Commands() //{{{ help: "Like :open but open URLs in a new window.
" } )); - addDefaultCommand(new Command(["wqa[ll]", "wq", "xa[ll]"], + addDefaultCommand(new vimperator.Command(["wqa[ll]", "wq", "xa[ll]"], function() { vimperator.quit(true); }, { usage: ["wqa[ll]", "xa[ll]"], @@ -2093,7 +2093,7 @@ function Commands() //{{{ ":wq is different as in Vim, as it closes the window instead of just one tab by popular demand. Complain on the mailing list, if you want to change that." } )); - addDefaultCommand(new Command(["zo[om]"], + addDefaultCommand(new vimperator.Command(["zo[om]"], function(args, special) { var level; @@ -2138,7 +2138,7 @@ function Commands() //{{{ "Normally this command operates on the text zoom, if used with [!] it operates on full zoom." } )); - addDefaultCommand(new Command(["!", "run"], + addDefaultCommand(new vimperator.Command(["!", "run"], function(args, special) { // :!! needs to be treated specially as the command parser sets the special flag but removes the ! from args diff --git a/content/completion.js b/content/completion.js index 58bab467..0b7f0a8a 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 = []; @@ -612,6 +612,6 @@ vimperator.completion = (function() // {{{ } //}}} } -})(); // }}} +} // }}} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/content/editor.js b/content/editor.js index 8638ad03..808f8df9 100644 --- a/content/editor.js +++ b/content/editor.js @@ -17,7 +17,7 @@ // command names taken from: // http://developer.mozilla.org/en/docs/Editor_Embedding_Guide -function Editor() //{{{ +vimperator.Editor = function() //{{{ { // store our last search with f,F,t or T var last_findChar = null; diff --git a/content/events.js b/content/events.js index ed49fd8b..fa162951 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 *****/ -function Events() //{{{ +vimperator.Events = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// diff --git a/content/find.js b/content/find.js index 9a2ded79..cf00092d 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 -function Search() //{{{ +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 diff --git a/content/hints.js b/content/hints.js index 934888dd..d9822d10 100644 --- a/content/hints.js +++ b/content/hints.js @@ -22,7 +22,7 @@ * }}} ***** END LICENSE BLOCK *****/ -function Hints() //{{{ +vimperator.Hints = function() //{{{ { const HINT_PREFIX = 'hah_hint_'; // prefix for the hint id diff --git a/content/io.js b/content/io.js index 84fe8118..b861652a 100644 --- a/content/io.js +++ b/content/io.js @@ -27,13 +27,11 @@ 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); - vimperator.log("Loading vimperator.io"); - return { MODE_RDONLY: 0x01, @@ -237,6 +235,6 @@ vimperator.io = (function() ofstream.close(); } } -})(); +} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/content/options.js b/content/options.js index 31b72a9d..efe9d0ee 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 *****/ -function Option(names, type, extra_info) //{{{ +vimperator.Option = function(names, type, extra_info) //{{{ { if (!names || !type) return null; @@ -107,7 +107,7 @@ function Option(names, type, extra_info) //{{{ } } //}}} -function Options() //{{{ +vimperator.Options = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -118,13 +118,6 @@ function Options() //{{{ var vimperator_prefs = firefox_prefs.getBranch("extensions.vimperator."); var options = []; - function addOption(option) - { - Options.prototype.__defineGetter__(option.name, function() { return option.value; }); - Options.prototype.__defineSetter__(option.name, function(value) { option.value = value; }); - options.push(option); - } - function optionsIterator() { for (var i = 0; i < options.length; i++) @@ -311,6 +304,13 @@ function Options() //{{{ return null; } + this.add = function(option) + { + this.__defineGetter__(option.name, function() { return option.value; }); + this.__defineSetter__(option.name, function(value) { option.value = value; }); + options.push(option); + } + this.destroy = function() { // reset some modified firefox prefs @@ -392,7 +392,7 @@ function Options() //{{{ "//xhtml:*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | " + "//xhtml:input[not(@type='hidden')] | //xhtml:a | //xhtml:area | //xhtml:iframe | //xhtml:textarea | //xhtml:button | //xhtml:select" - addOption(new Option(["activate", "act"], "stringlist", + this.add(new vimperator.Option(["activate", "act"], "stringlist", { short_help: "Define when tabs are automatically activated", help: "Available items:
" + @@ -405,13 +405,13 @@ function Options() //{{{ default_value: "homepage,quickmark,tabopen,paste" } )); - addOption(new Option(["autohints", "ah"], "boolean", + this.add(new vimperator.Option(["autohints", "ah"], "boolean", { short_help: "Automatically show hints on every web page", default_value: false } )); - addOption(new Option(["complete", "cpt"], "charlist", + this.add(new vimperator.Option(["complete", "cpt"], "charlist", { short_help: "Items which are completed at the :[tab]open prompt", help: "Available items:
" + @@ -427,7 +427,7 @@ function Options() //{{{ validator: function (value) { if (/[^sfbh]/.test(value)) return false; else return true; } } )); - addOption(new Option(["defsearch", "ds"], "string", + this.add(new vimperator.Option(["defsearch", "ds"], "string", { short_help: "Set the default search engine", help: "The default search engine is used in the :[tab]open [arg] command " + @@ -436,7 +436,7 @@ function Options() //{{{ default_value: "google" } )); - addOption(new Option(["editor"], "string", + this.add(new vimperator.Option(["editor"], "string", { short_help: "Set the external text editor", help: "Sets the editor to run when <C-i> " + @@ -446,20 +446,20 @@ function Options() //{{{ default_value: "gvim -f" } )); - addOption(new Option(["extendedhinttags", "eht"], "string", + this.add(new vimperator.Option(["extendedhinttags", "eht"], "string", { short_help: "XPath string of hintable elements activated by ';'", default_value: DEFAULT_HINTTAGS } )); - addOption(new Option(["focusedhintstyle", "fhs"], "string", + this.add(new vimperator.Option(["focusedhintstyle", "fhs"], "string", { short_help: "CSS specification of focused hints", default_value: "z-index:5000; font-family:monospace; font-size:12px; color:ButtonText; background-color:ButtonShadow; " + "border-color:ButtonShadow; border-width:1px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;" } )); - addOption(new Option(["fullscreen", "fs"], "boolean", + this.add(new vimperator.Option(["fullscreen", "fs"], "boolean", { short_help: "Show the current window fullscreen", setter: function(value) { window.fullScreen = value; }, @@ -467,7 +467,7 @@ function Options() //{{{ default_value: false } )); - addOption(new Option(["guioptions", "go"], "charlist", + this.add(new vimperator.Option(["guioptions", "go"], "charlist", { short_help: "Show or hide the menu, toolbar and scrollbars", help: "Supported characters:
" + @@ -481,52 +481,52 @@ function Options() //{{{ validator: function (value) { if (/[^mTb]/.test(value)) return false; else return true; } } )); - addOption(new Option(["hintchars", "hc"], "charlist", + this.add(new vimperator.Option(["hintchars", "hc"], "charlist", { short_help: "String of single characters which can be used to follow hints", default_value: "hjklasdfgyuiopqwertnmzxcvb" } )); - addOption(new Option(["hintstyle", "hs"], "string", + this.add(new vimperator.Option(["hintstyle", "hs"], "string", { short_help: "CSS specification of unfocused hints", default_value: "z-index:5000; font-family:monospace; font-size:12px; color:white; background-color:red; " + "border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;" } )); - addOption(new Option(["hinttags", "ht"], "string", + this.add(new vimperator.Option(["hinttags", "ht"], "string", { short_help: "XPath string of hintable elements activated by 'f' and 'F'", default_value: DEFAULT_HINTTAGS } )); - addOption(new Option(["hlsearch", "hls"], "boolean", + 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(); }, default_value: false } )); - addOption(new Option(["hlsearchstyle", "hlss"], "string", + this.add(new vimperator.Option(["hlsearchstyle", "hlss"], "string", { short_help: "CSS specification of highlighted search items", default_value: "color: black; background-color: yellow; padding: 0; display: inline;" } )); - addOption(new Option(["ignorecase", "ic"], "boolean", + this.add(new vimperator.Option(["ignorecase", "ic"], "boolean", { short_help: "Ignore case in search patterns", default_value: true } )); - addOption(new Option(["incsearch", "is"], "boolean", + this.add(new vimperator.Option(["incsearch", "is"], "boolean", { short_help: "Show where the search pattern matches as it is typed", help: "NOTE: Incremental searching currently only works in the forward direction.", default_value: true } )); - addOption(new Option(["insertmode", "im"], "boolean", + this.add(new vimperator.Option(["insertmode", "im"], "boolean", { short_help: "Use Insert mode as the default for text areas", help: "Makes Vimperator work in a way that Insert mode is the default mode for text areas. " + @@ -534,7 +534,7 @@ function Options() //{{{ default_value: true } )); - addOption(new Option(["laststatus", "ls"], "number", + this.add(new vimperator.Option(["laststatus", "ls"], "number", { short_help: "Show the status line", help: "Determines when the last window will have a status line. " + @@ -550,20 +550,20 @@ function Options() //{{{ validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; } } )); - addOption(new Option(["linksearch", "lks"], "boolean", + this.add(new vimperator.Option(["linksearch", "lks"], "boolean", { short_help: "Limit the search to hyperlink text", help: "This includes (X)HTML elements with an \"href\" atrribute and XLink \"simple\" links.", default_value: false } )); - addOption(new Option(["more"], "boolean", + this.add(new vimperator.Option(["more"], "boolean", { short_help: "Pause the message list window when more than one screen of listings is displayed", default_value: true } )); - addOption(new Option(["maxhints", "mh"], "number", + this.add(new vimperator.Option(["maxhints", "mh"], "number", { short_help: "Maximum number of simultaneously shown hints", help: "If you want to speed up display of hints, choose a smaller value", @@ -571,7 +571,7 @@ function Options() //{{{ validator: function (value) { if (value >= 1 && value <= 1000) return true; else return false; } } )); - addOption(new Option(["popups", "pps"], "number", + this.add(new vimperator.Option(["popups", "pps"], "number", { short_help: "Where to show requested popup windows", help: "Define where to show requested popup windows. Does not apply to windows which are opened by middle clicking a link, they always open in a new tab. " + @@ -588,7 +588,7 @@ function Options() //{{{ validator: function (value) { if (value >= 0 && value <= 3) return true; else return false; } } )); - addOption(new Option(["preload"], "boolean", + this.add(new vimperator.Option(["preload"], "boolean", { short_help: "Speed up first time history/bookmark completion", help: "History access can be quite slow for a large history. Vimperator maintains a cache to speed it up significantly on subsequent access.
" + @@ -596,7 +596,7 @@ function Options() //{{{ default_value: true } )); - addOption(new Option(["previewheight", "pvh"], "number", + this.add(new vimperator.Option(["previewheight", "pvh"], "number", { short_help: "Default height for preview window", help: "Value must be between 1 and 50. If the value is too high, completions may cover the command-line. " + @@ -606,7 +606,7 @@ function Options() //{{{ validator: function (value) { if (value >= 1 && value <= 50) return true; else return false; } } )); - addOption(new Option(["scroll", "scr"], "number", + this.add(new vimperator.Option(["scroll", "scr"], "number", { short_help: "Number of lines to scroll with C-u and C-d commands", help: "The number of lines scrolled defaults to half the window size. " + @@ -616,13 +616,13 @@ function Options() //{{{ validator: function (value) { if (value >= 0) return true; else return false; } } )); - addOption(new Option(["showmode", "smd"], "boolean", + this.add(new vimperator.Option(["showmode", "smd"], "boolean", { short_help: "Show the current mode in the command line", default_value: true } )); - addOption(new Option(["showstatuslinks", "ssli"], "number", + this.add(new vimperator.Option(["showstatuslinks", "ssli"], "number", { short_help: "Show the destination of the link under the cursor in the status bar", help: "Also links which are focused by keyboard commands like <Tab> are shown. " + @@ -636,7 +636,7 @@ function Options() //{{{ validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; } } )); - addOption(new Option(["showtabline", "stal"], "number", + this.add(new vimperator.Option(["showtabline", "stal"], "number", { short_help: "Control when to show the tab bar of opened web pages", help: "Possible values:
" + @@ -650,14 +650,14 @@ function Options() //{{{ validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; } } )); - addOption(new Option(["smartcase", "scs"], "boolean", + this.add(new vimperator.Option(["smartcase", "scs"], "boolean", { short_help: "Override the 'ignorecase' option if the pattern contains uppercase characters", help: "This is only used if the 'ignorecase' option is set.", default_value: true } )); - addOption(new Option(["titlestring"], "string", + this.add(new vimperator.Option(["titlestring"], "string", { short_help: "Change the title of the browser window", help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " + @@ -667,7 +667,7 @@ function Options() //{{{ default_value: "Vimperator" } )); - addOption(new Option(["usermode", "um"], "boolean", + this.add(new vimperator.Option(["usermode", "um"], "boolean", { 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", @@ -676,7 +676,7 @@ function Options() //{{{ default_value: false } )); - addOption(new Option(["verbose", "vbs"], "number", + this.add(new vimperator.Option(["verbose", "vbs"], "number", { short_help: "Define which type of messages are logged", 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!.
" + @@ -685,14 +685,14 @@ function Options() //{{{ validator: function (value) { if (value >= 0 && value <= 9) return true; else return false; } } )); - addOption(new Option(["visualbell", "vb"], "boolean", + 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); }, default_value: false } )); - addOption(new Option(["wildmode", "wim"], "stringlist", + this.add(new vimperator.Option(["wildmode", "wim"], "stringlist", { short_help: "Define how command line completion works", help: "It is a comma-separated list of parts, where each part specifies " + @@ -719,7 +719,7 @@ function Options() //{{{ } } )); - addOption(new Option(["wildoptions", "wop"], "stringlist", + this.add(new vimperator.Option(["wildoptions", "wop"], "stringlist", { short_help: "Change how command line completion is done", help: "A list of words that change how command line completion is done.
" + diff --git a/content/tabs.js b/content/tabs.js index 95c84841..220523d3 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 */ -function Tabs() //{{{ +vimperator.Tabs = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// diff --git a/content/ui.js b/content/ui.js index 61abcaac..0aceb571 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 */ -function CommandLine() //{{{ +vimperator.CommandLine = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -40,7 +40,7 @@ function CommandLine() //{{{ const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning - var completionlist = new InformationList("vimperator-completion", { min_items: 2, max_items: 10 }); + var completionlist = new vimperator.InformationList("vimperator-completion", { min_items: 2, max_items: 10 }); var completions = []; // TODO: clean this up when it's not 3am... @@ -840,7 +840,7 @@ function CommandLine() //{{{ * @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 */ -function InformationList(id, options) //{{{ +vimperator.InformationList = function(id, options) //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -1043,7 +1043,7 @@ function InformationList(id, options) //{{{ //}}} } //}}} -function StatusLine() //{{{ +vimperator.StatusLine = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// diff --git a/content/vimperator.js b/content/vimperator.js index 4f43f6dd..f904848e 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -569,39 +569,43 @@ const vimperator = (function() //{{{ // these objects are created here only after the chrome is ready vimperator.log("Loading module options...", 3); - vimperator.options = new Options(); + vimperator.options = new vimperator.Options(); vimperator.log("Loading module events...", 3); - vimperator.events = new Events(); + vimperator.events = new vimperator.Events(); vimperator.log("Loading module commands...", 3); - vimperator.commands = new Commands(); + vimperator.commands = new vimperator.Commands(); vimperator.log("Loading module bookmarks...", 3); - vimperator.bookmarks = new Bookmarks(); + vimperator.bookmarks = new vimperator.Bookmarks(); vimperator.log("Loading module history...", 3); - vimperator.history = new History(); + vimperator.history = new vimperator.History(); vimperator.log("Loading module commandline...", 3); - vimperator.commandline = new CommandLine(); + vimperator.commandline = new vimperator.CommandLine(); vimperator.log("Loading module search...", 3); - vimperator.search = new Search(); + vimperator.search = new vimperator.Search(); vimperator.log("Loading module preview window...", 3); - vimperator.previewwindow = new InformationList("vimperator-previewwindow", { incremental_fill: false, max_items: 10 }); + vimperator.previewwindow = new vimperator.InformationList("vimperator-previewwindow", { incremental_fill: false, max_items: 10 }); vimperator.log("Loading module buffer window...", 3); - vimperator.bufferwindow = new InformationList("vimperator-bufferwindow", { incremental_fill: false, max_items: 10 }); + vimperator.bufferwindow = new vimperator.InformationList("vimperator-bufferwindow", { incremental_fill: false, max_items: 10 }); vimperator.log("Loading module mappings...", 3); vimperator.mappings = new Mappings(); vimperator.log("Loading module statusline...", 3); - vimperator.statusline = new StatusLine(); + vimperator.statusline = new vimperator.StatusLine(); vimperator.log("Loading module buffer...", 3); - vimperator.buffer = new Buffer(); + vimperator.buffer = new vimperator.Buffer(); vimperator.log("Loading module editor...", 3); - vimperator.editor = new Editor(); + vimperator.editor = new vimperator.Editor(); vimperator.log("Loading module tabs...", 3); - vimperator.tabs = new Tabs(); + vimperator.tabs = new vimperator.Tabs(); vimperator.log("Loading module marks...", 3); - vimperator.marks = new Marks(); + vimperator.marks = new vimperator.Marks(); vimperator.log("Loading module quickmarks...", 3); - vimperator.quickmarks = new QuickMarks(); + vimperator.quickmarks = new vimperator.QuickMarks(); vimperator.log("Loading module hints...", 3); - vimperator.hints = new Hints(); + vimperator.hints = new vimperator.Hints(); + vimperator.log("Loading module io...", 3); + vimperator.io = new vimperator.IO(); + vimperator.log("Loading module completion...", 3); + vimperator.completion = new vimperator.Completion(); vimperator.log("All modules loaded", 3); vimperator.echo = function(str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); }