diff --git a/content/bookmarks.js b/content/bookmarks.js index fc287b5d..eff5ce20 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 () //{{{ +liberator.Bookmarks = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -47,7 +47,7 @@ vimperator.Bookmarks = function () //{{{ var bookmarks = null; var keywords = null; - if (vimperator.options["preload"]) + if (liberator.options["preload"]) setTimeout(function () { load(); }, 100); function load() @@ -98,10 +98,10 @@ vimperator.Bookmarks = function () //{{{ ////////////////////// OPTIONS ///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.options.add(["defsearch", "ds"], + liberator.options.add(["defsearch", "ds"], "Set the default search engine", "string", "google"); - vimperator.options.add(["preload"], + liberator.options.add(["preload"], "Speed up first time history/bookmark completion", "boolean", true); @@ -109,86 +109,86 @@ vimperator.Bookmarks = function () //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL]; + var modes = liberator.config.browserModes || [liberator.modes.NORMAL]; - vimperator.mappings.add(modes, ["a"], + liberator.mappings.add(modes, ["a"], "Open a prompt to bookmark the current URL", function () { var title = ""; - if (vimperator.buffer.title != vimperator.buffer.URL) - title = " -title=\"" + vimperator.buffer.title + "\""; - vimperator.commandline.open(":", "bmark " + vimperator.buffer.URL + title, vimperator.modes.EX); + if (liberator.buffer.title != liberator.buffer.URL) + title = " -title=\"" + liberator.buffer.title + "\""; + liberator.commandline.open(":", "bmark " + liberator.buffer.URL + title, liberator.modes.EX); }); - vimperator.mappings.add(modes, ["A"], + liberator.mappings.add(modes, ["A"], "Toggle bookmarked state of current URL", - function () { vimperator.bookmarks.toggle(vimperator.buffer.URL); }); + function () { liberator.bookmarks.toggle(liberator.buffer.URL); }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["bma[rk]"], + liberator.commands.add(["bma[rk]"], "Add a bookmark", function (args) { - var res = vimperator.commands.parseArgs(args, this.args); + var res = liberator.commands.parseArgs(args, this.args); if (!res) return; - var url = res.args.length == 0 ? vimperator.buffer.URL : res.args[0]; - var title = vimperator.commands.getOption(res.opts, "-title", res.args.length == 0 ? vimperator.buffer.title : null); + var url = res.args.length == 0 ? liberator.buffer.URL : res.args[0]; + var title = liberator.commands.getOption(res.opts, "-title", res.args.length == 0 ? liberator.buffer.title : null); if (!title) title = url; - var keyword = vimperator.commands.getOption(res.opts, "-keyword", null); - var tags = vimperator.commands.getOption(res.opts, "-tags", []); + var keyword = liberator.commands.getOption(res.opts, "-keyword", null); + var tags = liberator.commands.getOption(res.opts, "-tags", []); - if (vimperator.bookmarks.add(false, title, url, keyword, tags)) + if (liberator.bookmarks.add(false, title, url, keyword, tags)) { var extra = ""; if (title != url) extra = " (" + title + ")"; - vimperator.echo("Added bookmark: " + url + extra, vimperator.commandline.FORCE_SINGLELINE); + liberator.echo("Added bookmark: " + url + extra, liberator.commandline.FORCE_SINGLELINE); } else - vimperator.echoerr("Exxx: Could not add bookmark `" + title + "'", vimperator.commandline.FORCE_SINGLELINE); + liberator.echoerr("Exxx: Could not add bookmark `" + title + "'", liberator.commandline.FORCE_SINGLELINE); }, { - args: [[["-title", "-t"], vimperator.commands.OPTION_STRING], - [["-tags", "-T"], vimperator.commands.OPTION_LIST], - [["-keyword", "-k"], vimperator.commands.OPTION_STRING, function (arg) { return /\w/.test(arg); }]] + args: [[["-title", "-t"], liberator.commands.OPTION_STRING], + [["-tags", "-T"], liberator.commands.OPTION_LIST], + [["-keyword", "-k"], liberator.commands.OPTION_STRING, function (arg) { return /\w/.test(arg); }]] }); - vimperator.commands.add(["bmarks"], + liberator.commands.add(["bmarks"], "List or open multiple bookmarks", function (args, special) { - var res = vimperator.commands.parseArgs(args, this.args); + var res = liberator.commands.parseArgs(args, this.args); if (!res) return; - var tags = vimperator.commands.getOption(res.opts, "-tags", []); - vimperator.bookmarks.list(res.args.join(" "), tags, special); + var tags = liberator.commands.getOption(res.opts, "-tags", []); + liberator.bookmarks.list(res.args.join(" "), tags, special); }, { - completer: function (filter) { return [0, vimperator.bookmarks.get(filter)]; }, - args: [[["-tags", "-T"], vimperator.commands.OPTION_LIST]] + completer: function (filter) { return [0, liberator.bookmarks.get(filter)]; }, + args: [[["-tags", "-T"], liberator.commands.OPTION_LIST]] }); - vimperator.commands.add(["delbm[arks]"], + liberator.commands.add(["delbm[arks]"], "Delete a bookmark", function (args, special) { var url = args; if (!url) - url = vimperator.buffer.URL; + url = liberator.buffer.URL; - var deletedCount = vimperator.bookmarks.remove(url); - vimperator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", vimperator.commandline.FORCE_SINGLELINE); + var deletedCount = liberator.bookmarks.remove(url); + liberator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", liberator.commandline.FORCE_SINGLELINE); }, { - completer: function (filter) { return [0, vimperator.bookmarks.get(filter)]; } + completer: function (filter) { return [0, liberator.bookmarks.get(filter)]; } }); /////////////////////////////////////////////////////////////////////////////}}} @@ -205,7 +205,7 @@ vimperator.Bookmarks = function () //{{{ if (!bookmarks || bypassCache) load(); - return vimperator.completion.filterURLArray(bookmarks, filter, tags); + return liberator.completion.filterURLArray(bookmarks, filter, tags); }, // if starOnly = true it is saved in the unfiledBookmarksFolder, otherwise in the bookmarksMenuFolder @@ -239,12 +239,12 @@ vimperator.Bookmarks = function () //{{{ } catch (e) { - vimperator.log(e); + liberator.log(e); return false; } // update the display of our "bookmarked" symbol - vimperator.statusline.updateUrl(); + liberator.statusline.updateUrl(); //also update bookmark cache bookmarks.unshift([url, title, keyword, tags || []]); @@ -259,16 +259,16 @@ vimperator.Bookmarks = function () //{{{ var count = this.remove(url); if (count > 0) { - vimperator.commandline.echo("Removed bookmark: " + url, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_SINGLELINE); + liberator.commandline.echo("Removed bookmark: " + url, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_SINGLELINE); } else { - var title = vimperator.buffer.title || url; + var title = liberator.buffer.title || url; var extra = ""; if (title != url) extra = " (" + title + ")"; this.add(true, title, url); - vimperator.commandline.echo("Added bookmark: " + url + extra, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_SINGLELINE); + liberator.commandline.echo("Added bookmark: " + url + extra, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_SINGLELINE); } }, @@ -306,7 +306,7 @@ vimperator.Bookmarks = function () //{{{ } catch (e) { - vimperator.log(e); + liberator.log(e); return i; } @@ -316,7 +316,7 @@ vimperator.Bookmarks = function () //{{{ load(); // update the display of our "bookmarked" symbol - vimperator.statusline.updateUrl(); + liberator.statusline.updateUrl(); return count.value; }, @@ -373,7 +373,7 @@ vimperator.Bookmarks = function () //{{{ var url = null; var postData = null; if (!engineName) - engineName = vimperator.options["defsearch"]; + engineName = liberator.options["defsearch"]; // we need to make sure our custom alias have been set, even if the user // did not :open once before @@ -423,9 +423,9 @@ vimperator.Bookmarks = function () //{{{ if (items.length == 0) { if (filter.length > 0 || tags.length > 0) - vimperator.echoerr("E283: No bookmarks matching \"" + filter + "\""); + liberator.echoerr("E283: No bookmarks matching \"" + filter + "\""); else - vimperator.echoerr("No bookmarks set"); + liberator.echoerr("No bookmarks set"); return; } @@ -434,38 +434,38 @@ vimperator.Bookmarks = function () //{{{ { // FIXME: use yes/no question if (items.length > 50) - return vimperator.echoerr("For now, you can only open a hard limit of 50 items at once"); + return liberator.echoerr("For now, you can only open a hard limit of 50 items at once"); for (var i = 0; i < items.length; i++) - vimperator.open(items[i][0], vimperator.NEW_TAB); + liberator.open(items[i][0], liberator.NEW_TAB); return; } var title, url, tags, keyword, extra; - var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "
" + ""; for (var i = 0; i < items.length; i++) { - title = vimperator.util.escapeHTML(items[i][1]); + title = liberator.util.escapeHTML(items[i][1]); if (title.length > 50) title = title.substr(0, 47) + "..."; - url = vimperator.util.escapeHTML(items[i][0]); + url = liberator.util.escapeHTML(items[i][0]); keyword = items[i][2]; tags = items[i][3].join(", "); extra = ""; if (keyword) { - extra = " (keyword: " + vimperator.util.escapeHTML(keyword) + ""; + extra = " (keyword: " + liberator.util.escapeHTML(keyword) + ""; if (tags) - extra += " tags: " + vimperator.util.escapeHTML(tags) + ")"; + extra += " tags: " + liberator.util.escapeHTML(tags) + ")"; else extra += ")"; } else if (tags) { - extra = " (tags: " + vimperator.util.escapeHTML(tags) + ")"; + extra = " (tags: " + liberator.util.escapeHTML(tags) + ")"; } @@ -473,14 +473,14 @@ vimperator.Bookmarks = function () //{{{ } list += "
titleURL
"; - vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); + liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } }; //}}} }; //}}} -vimperator.History = function () //{{{ +liberator.History = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -491,7 +491,7 @@ vimperator.History = function () //{{{ var history = null; - if (vimperator.options["preload"]) + if (liberator.options["preload"]) setTimeout(function () { load(); }, 100); function load() @@ -527,38 +527,38 @@ vimperator.History = function () //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL]; + var modes = liberator.config.browserModes || [liberator.modes.NORMAL]; - vimperator.mappings.add(modes, + liberator.mappings.add(modes, [""], "Go to an older position in the jump list", - function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.history.stepTo(-(count > 1 ? count : 1)); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, [""], "Go to a newer position in the jump list", - function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.history.stepTo(count > 1 ? count : 1); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["H", "", ""], "Go back in the browser history", - function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.history.stepTo(-(count > 1 ? count : 1)); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["L", "", ""], "Go forward in the browser history", - function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.history.stepTo(count > 1 ? count : 1); }, + { flags: liberator.Mappings.flags.COUNT }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["ba[ck]"], + liberator.commands.add(["ba[ck]"], "Go back in the browser history", function (args, special, count) { if (special) - vimperator.history.goToStart(); + liberator.history.goToStart(); else { if (args) @@ -573,7 +573,7 @@ vimperator.History = function () //{{{ } } } - vimperator.history.stepTo(count > 0 ? -1 * count : -1); + liberator.history.stepTo(count > 0 ? -1 * count : -1); } }, { @@ -586,19 +586,19 @@ vimperator.History = function () //{{{ var entry = sh.getEntryAtIndex(i, false); var url = entry.URI.spec; var title = entry.title; - if (vimperator.completion.match([url, title], filter, false)) + if (liberator.completion.match([url, title], filter, false)) completions.push([url, title]); } return [0, completions]; } }); - vimperator.commands.add(["fo[rward]", "fw"], + liberator.commands.add(["fo[rward]", "fw"], "Go forward in the browser history", function (args, special, count) { if (special) - vimperator.history.goToEnd(); + liberator.history.goToEnd(); else { if (args) @@ -613,7 +613,7 @@ vimperator.History = function () //{{{ } } } - vimperator.history.stepTo(count > 0 ? count : 1); + liberator.history.stepTo(count > 0 ? count : 1); } }, { @@ -626,17 +626,17 @@ vimperator.History = function () //{{{ var entry = sh.getEntryAtIndex(i, false); var url = entry.URI.spec; var title = entry.title; - if (vimperator.completion.match([url, title], filter, false)) + if (liberator.completion.match([url, title], filter, false)) completions.push([url, title]); } return [0, completions]; } }); - vimperator.commands.add(["hist[ory]", "hs"], + liberator.commands.add(["hist[ory]", "hs"], "Show recently visited URLs", - function (args, special) { vimperator.history.list(args, special); }, - { completer: function (filter) { return [0, vimperator.history.get(filter)]; } }); + function (args, special) { liberator.history.list(args, special); }, + { completer: function (filter) { return [0, liberator.history.get(filter)]; } }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ @@ -648,7 +648,7 @@ vimperator.History = function () //{{{ if (!history) load(); - return vimperator.completion.filterURLArray(history, filter); + return liberator.completion.filterURLArray(history, filter); }, // the history is automatically added to the Places global history @@ -667,7 +667,7 @@ vimperator.History = function () //{{{ }, // TODO: better names? - // and move to vimperator.buffer.? + // and move to liberator.buffer.? stepTo: function (steps) { var index = getWebNavigation().sessionHistory.index + steps; @@ -678,7 +678,7 @@ vimperator.History = function () //{{{ } else { - vimperator.beep(); + liberator.beep(); } }, @@ -688,7 +688,7 @@ vimperator.History = function () //{{{ if (index == 0) { - vimperator.beep(); + liberator.beep(); return; } @@ -702,7 +702,7 @@ vimperator.History = function () //{{{ if (index == max) { - vimperator.beep(); + liberator.beep(); return; } @@ -716,9 +716,9 @@ vimperator.History = function () //{{{ if (items.length == 0) { if (filter.length > 0) - vimperator.echoerr("E283: No history matching \"" + filter + "\""); + liberator.echoerr("E283: No history matching \"" + filter + "\""); else - vimperator.echoerr("No history set"); + liberator.echoerr("No history set"); return; } @@ -727,28 +727,28 @@ vimperator.History = function () //{{{ { // FIXME: use yes/no question if (items.length > 50) - return vimperator.echoerr("For now, you can only open a hard limit of 50 items at once"); + return liberator.echoerr("For now, you can only open a hard limit of 50 items at once"); for (var i = 0; i < items.length; i++) - vimperator.open(items[i][0], vimperator.NEW_TAB); + liberator.open(items[i][0], liberator.NEW_TAB); return; } else { - var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "
" + ""; for (var i = 0; i < items.length; i++) { - var title = vimperator.util.escapeHTML(items[i][1]); + var title = liberator.util.escapeHTML(items[i][1]); if (title.length > 50) title = title.substr(0, 47) + "..."; - var url = vimperator.util.escapeHTML(items[i][0]); + var url = liberator.util.escapeHTML(items[i][0]); list += ""; } list += "
titleURL
" + title + "" + url + "
"; - vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); + liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } } @@ -756,7 +756,7 @@ vimperator.History = function () //{{{ //}}} }; //}}} -vimperator.QuickMarks = function () //{{{ +liberator.QuickMarks = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -764,7 +764,7 @@ vimperator.QuickMarks = function () //{{{ var qmarks = {}; // TODO: move to a storage module - var savedMarks = vimperator.options.getPref("extensions.vimperator.quickmarks", "").split("\n"); + var savedMarks = liberator.options.getPref("extensions.vimperator.quickmarks", "").split("\n"); // load the saved quickmarks -- TODO: change to sqlite for (var i = 0; i < savedMarks.length - 1; i += 2) @@ -775,95 +775,95 @@ vimperator.QuickMarks = function () //{{{ /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL]; + var modes = liberator.config.browserModes || [liberator.modes.NORMAL]; - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["go"], "Jump to a QuickMark", - function (arg) { vimperator.quickmarks.jumpTo(arg, vimperator.CURRENT_TAB); }, - { flags: vimperator.Mappings.flags.ARGUMENT }); + function (arg) { liberator.quickmarks.jumpTo(arg, liberator.CURRENT_TAB); }, + { flags: liberator.Mappings.flags.ARGUMENT }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["gn"], "Jump to a QuickMark in a new tab", function (arg) { - vimperator.quickmarks.jumpTo(arg, - /\bquickmark\b/.test(vimperator.options["activate"]) ? - vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB); + liberator.quickmarks.jumpTo(arg, + /\bquickmark\b/.test(liberator.options["activate"]) ? + liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB); }, - { flags: vimperator.Mappings.flags.ARGUMENT }); + { flags: liberator.Mappings.flags.ARGUMENT }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["M"], "Add new QuickMark for current URL", function (arg) { if (/[^a-zA-Z0-9]/.test(arg)) { - vimperator.beep(); + liberator.beep(); return; } - vimperator.quickmarks.add(arg, vimperator.buffer.URL); + liberator.quickmarks.add(arg, liberator.buffer.URL); }, - { flags: vimperator.Mappings.flags.ARGUMENT }); + { flags: liberator.Mappings.flags.ARGUMENT }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["delqm[arks]"], + liberator.commands.add(["delqm[arks]"], "Delete the specified QuickMarks", function (args, special) { // TODO: finish arg parsing - we really need a proper way to do this. :) if (!special && !args) { - vimperator.echoerr("E471: Argument required"); + liberator.echoerr("E471: Argument required"); return; } if (special && args) { - vimperator.echoerr("E474: Invalid argument"); + liberator.echoerr("E474: Invalid argument"); return; } if (special) - vimperator.quickmarks.removeAll(); + liberator.quickmarks.removeAll(); else - vimperator.quickmarks.remove(args); + liberator.quickmarks.remove(args); }); - vimperator.commands.add(["qma[rk]"], + liberator.commands.add(["qma[rk]"], "Mark a URL with a letter for quick access", function (args) { if (!args) { - vimperator.echoerr("E471: Argument required"); + liberator.echoerr("E471: Argument required"); return; } var matches = args.match(/^([a-zA-Z0-9])(?:\s+(.+))?$/); if (!matches) - vimperator.echoerr("E488: Trailing characters"); + liberator.echoerr("E488: Trailing characters"); else if (!matches[2]) - vimperator.quickmarks.add(matches[1], vimperator.buffer.URL); + liberator.quickmarks.add(matches[1], liberator.buffer.URL); else - vimperator.quickmarks.add(matches[1], matches[2]); + liberator.quickmarks.add(matches[1], matches[2]); }); - vimperator.commands.add(["qmarks"], + liberator.commands.add(["qmarks"], "Show all QuickMarks", function (args) { // ignore invalid mark characters unless there are no valid mark chars if (args && !/[a-zA-Z0-9]/.test(args)) { - vimperator.echoerr("E283: No QuickMarks matching \"" + args + "\""); + liberator.echoerr("E283: No QuickMarks matching \"" + args + "\""); return; } var filter = args.replace(/[^a-zA-Z0-9]/g, ""); - vimperator.quickmarks.list(filter); + liberator.quickmarks.list(filter); }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// @@ -897,9 +897,9 @@ vimperator.QuickMarks = function () //{{{ var url = qmarks[qmark]; if (url) - vimperator.open(url, where); + liberator.open(url, where); else - vimperator.echoerr("E20: QuickMark not set"); + liberator.echoerr("E20: QuickMark not set"); }, list: function (filter) @@ -913,7 +913,7 @@ vimperator.QuickMarks = function () //{{{ if (marks.length == 0) { - vimperator.echoerr("No QuickMarks set"); + liberator.echoerr("No QuickMarks set"); return; } @@ -925,21 +925,21 @@ vimperator.QuickMarks = function () //{{{ }); if (marks.length == 0) { - vimperator.echoerr("E283: No QuickMarks matching \"" + filter + "\""); + liberator.echoerr("E283: No QuickMarks matching \"" + filter + "\""); return; } } - var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "
" + ""; for (var i = 0; i < marks.length; i++) { list += ""; + ""; } list += "
QuickMarkURL
" + marks[i][0] + - "" + vimperator.util.escapeHTML(marks[i][1]) + "
" + liberator.util.escapeHTML(marks[i][1]) + "
"; - vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); + liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); }, destroy: function () @@ -953,7 +953,7 @@ vimperator.QuickMarks = function () //{{{ savedQuickMarks += qmarks[i] + "\n"; } - vimperator.options.setPref("extensions.vimperator.quickmarks", savedQuickMarks); + liberator.options.setPref("extensions.vimperator.quickmarks", savedQuickMarks); } }; diff --git a/content/buffer.js b/content/buffer.js index 3844661b..8fcf91d8 100644 --- a/content/buffer.js +++ b/content/buffer.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 () //{{{ +liberator.Buffer = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -39,7 +39,7 @@ vimperator.Buffer = function () //{{{ { if (value < 1 || value > 2000) { - vimperator.echoerr("Zoom value out of range (1-2000%)"); + liberator.echoerr("Zoom value out of range (1-2000%)"); return; } @@ -48,13 +48,13 @@ vimperator.Buffer = function () //{{{ else getBrowser().markupDocumentViewer.textZoom = value / 100.0; - vimperator.echo((fullZoom ? "Full zoom: " : "Text zoom: ") + value + "%"); + liberator.echo((fullZoom ? "Full zoom: " : "Text zoom: ") + value + "%"); // TODO: shouldn't this just recalculate hint coords, rather than // unsuccessfully attempt to reshow hints? i.e. isn't it just relying // on the recalculation side effect? -- djk // NOTE: we could really do with a zoom event... - // vimperator.hints.reshowHints(); + // liberator.hints.reshowHints(); } function bumpZoomLevel(steps, fullZoom) @@ -89,7 +89,7 @@ vimperator.Buffer = function () //{{{ } if (index < 0 || index >= zoomLevels.length) { - vimperator.beep(); + liberator.beep(); return; } setZoom(zoomLevels[index], fullZoom); @@ -99,7 +99,7 @@ vimperator.Buffer = function () //{{{ { // NOTE: it's possible to have scrollY > scrollMaxY - FF bug? if (direction > 0 && win.scrollY >= win.scrollMaxY || direction < 0 && win.scrollY == 0) - vimperator.beep(); + liberator.beep(); } function findScrollableWindow() @@ -145,26 +145,26 @@ vimperator.Buffer = function () //{{{ ////////////////////// OPTIONS ///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.options.add(["fullscreen", "fs"], "Show the current window fullscreen", "boolean", false, + liberator.options.add(["fullscreen", "fs"], "Show the current window fullscreen", "boolean", false, { setter: function (value) { window.fullScreen = value; }, getter: function () { return window.fullScreen; } }); - vimperator.options.add(["nextpattern",], + liberator.options.add(["nextpattern",], "Patterns to use when guessing the 'next' page in a document sequence", "stringlist", "\\bnext,^>$,^(>>|»)$,^(>|»),(>|»)$"); - vimperator.options.add(["previouspattern"], + liberator.options.add(["previouspattern"], "Patterns to use when guessing the 'previous' page in a document sequence", "stringlist", "\\bprev|previous\\b,^<$,^(<<|«)$,^(<|«),(<|«)$"); - vimperator.options.add(["pageinfo", "pa"], "Desired info on :pa[geinfo]", "charlist", "gfm", + liberator.options.add(["pageinfo", "pa"], "Desired info on :pa[geinfo]", "charlist", "gfm", { validator: function (value) { return !(/[^gfm]/.test(value) || value.length > 3 || value.length < 1); } }); - vimperator.options.add(["scroll", "scr"], + liberator.options.add(["scroll", "scr"], "Number of lines to scroll with and commands", "number", 0, { @@ -172,14 +172,14 @@ vimperator.Buffer = function () //{{{ } ); - vimperator.options.add(["showstatuslinks", "ssli"], + liberator.options.add(["showstatuslinks", "ssli"], "Show the destination of the link under the cursor in the status bar", "number", 1, { validator: function (value) { return (value >= 0 && value <= 2); } }); - vimperator.options.add(["usermode", "um"], + liberator.options.add(["usermode", "um"], "Show current website with a minimal style sheet to make it easily accessible", "boolean", false, { @@ -191,271 +191,271 @@ vimperator.Buffer = function () //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL]; + var modes = liberator.config.browserModes || [liberator.modes.NORMAL]; - vimperator.mappings.add(modes, ["i", ""], + liberator.mappings.add(modes, ["i", ""], "Start caret mode", function () { // setting this option triggers an observer which takes care of the mode setting - vimperator.options.setPref("accessibility.browsewithcaret", true); + liberator.options.setPref("accessibility.browsewithcaret", true); }); - vimperator.mappings.add(modes, [""], + liberator.mappings.add(modes, [""], "Stop loading", function() { BrowserStop(); }); // scrolling - vimperator.mappings.add(modes, ["j", "", ""], + liberator.mappings.add(modes, ["j", "", ""], "Scroll document down", - function (count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollLines(count > 1 ? count : 1); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["k", "", ""], + liberator.mappings.add(modes, ["k", "", ""], "Scroll document up", - function (count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollLines(-(count > 1 ? count : 1)); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["h", ""], + liberator.mappings.add(modes, ["h", ""], "Scroll document to the left", - function (count) { vimperator.buffer.scrollColumns(-(count > 1 ? count : 1)); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollColumns(-(count > 1 ? count : 1)); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["l", ""], + liberator.mappings.add(modes, ["l", ""], "Scroll document to the right", - function (count) { vimperator.buffer.scrollColumns(count > 1 ? count : 1); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollColumns(count > 1 ? count : 1); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["0", "^"], + liberator.mappings.add(modes, ["0", "^"], "Scroll to the absolute left of the document", - function () { vimperator.buffer.scrollStart(); }); + function () { liberator.buffer.scrollStart(); }); - vimperator.mappings.add(modes, ["$"], + liberator.mappings.add(modes, ["$"], "Scroll to the absolute right of the document", - function () { vimperator.buffer.scrollEnd(); }); + function () { liberator.buffer.scrollEnd(); }); - vimperator.mappings.add(modes, ["gg", ""], + liberator.mappings.add(modes, ["gg", ""], "Goto the top of the document", - function (count) { vimperator.buffer.scrollToPercentile(count > 0 ? count : 0); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollToPercentile(count > 0 ? count : 0); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["G", ""], + liberator.mappings.add(modes, ["G", ""], "Goto the end of the document", - function (count) { vimperator.buffer.scrollToPercentile(count >= 0 ? count : 100); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollToPercentile(count >= 0 ? count : 100); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, [""], + liberator.mappings.add(modes, [""], "Scroll window downwards in the buffer", - function (count) { vimperator.buffer.scrollByScrollSize(count, 1); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollByScrollSize(count, 1); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, [""], + liberator.mappings.add(modes, [""], "Scroll window upwards in the buffer", - function (count) { vimperator.buffer.scrollByScrollSize(count, -1); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollByScrollSize(count, -1); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["", "", ""], + liberator.mappings.add(modes, ["", "", ""], "Scroll up a full page", - function (count) { vimperator.buffer.scrollPages(-(count > 1 ? count : 1)); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollPages(-(count > 1 ? count : 1)); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["", "", ""], + liberator.mappings.add(modes, ["", "", ""], "Scroll down a full page", - function (count) { vimperator.buffer.scrollPages(count > 1 ? count : 1); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.scrollPages(count > 1 ? count : 1); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["]f"], + liberator.mappings.add(modes, ["]f"], "Focus next frame", - function (count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, true); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.shiftFrameFocus(count > 1 ? count : 1, true); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["[f"], + liberator.mappings.add(modes, ["[f"], "Focus previous frame", - function (count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, false); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.shiftFrameFocus(count > 1 ? count : 1, false); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["]]"], + liberator.mappings.add(modes, ["]]"], "Follow a link labeled to 'next' or '>' if it exists", - function (count) { vimperator.buffer.followDocumentRelationship("next"); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.followDocumentRelationship("next"); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["[["], + liberator.mappings.add(modes, ["[["], "Follow a link labeled to 'prev', 'previous' or '<' if it exists", - function (count) { vimperator.buffer.followDocumentRelationship("previous"); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.followDocumentRelationship("previous"); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["gf"], + liberator.mappings.add(modes, ["gf"], "View source", - function () { vimperator.buffer.viewSource(null, false); }); + function () { liberator.buffer.viewSource(null, false); }); - vimperator.mappings.add(modes, ["gF"], + liberator.mappings.add(modes, ["gF"], "View source with an external editor", - function () { vimperator.buffer.viewSource(null, true); }); + function () { liberator.buffer.viewSource(null, true); }); - vimperator.mappings.add(modes, ["gi"], + liberator.mappings.add(modes, ["gi"], "Focus last used input field", function () { - if (vimperator.buffer.lastInputField) - vimperator.buffer.lastInputField.focus(); + if (liberator.buffer.lastInputField) + liberator.buffer.lastInputField.focus(); else { - var first = vimperator.buffer.evaluateXPath( + var first = liberator.buffer.evaluateXPath( "//*[@type='text'] | //textarea | //xhtml:textarea").snapshotItem(0); if (first) first.focus(); else - vimperator.beep(); + liberator.beep(); } }); - vimperator.mappings.add(modes, ["gP"], + liberator.mappings.add(modes, ["gP"], "Open (put) a URL based on the current clipboard contents in a new buffer", function () { - vimperator.open(readFromClipboard(), - /\bpaste\b/.test(vimperator.options["activate"]) ? - vimperator.NEW_BACKGROUND_TAB : vimperator.NEW_TAB); + liberator.open(readFromClipboard(), + /\bpaste\b/.test(liberator.options["activate"]) ? + liberator.NEW_BACKGROUND_TAB : liberator.NEW_TAB); }); - vimperator.mappings.add(modes, ["p", ""], + liberator.mappings.add(modes, ["p", ""], "Open (put) a URL based on the current clipboard contents in the current buffer", - function () { vimperator.open(readFromClipboard()); }); + function () { liberator.open(readFromClipboard()); }); - vimperator.mappings.add(modes, ["P"], + liberator.mappings.add(modes, ["P"], "Open (put) a URL based on the current clipboard contents in a new buffer", function () { - vimperator.open(readFromClipboard(), - /\bpaste\b/.test(vimperator.options["activate"]) ? - vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB); + liberator.open(readFromClipboard(), + /\bpaste\b/.test(liberator.options["activate"]) ? + liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB); }); // reloading - vimperator.mappings.add(modes, ["r"], + liberator.mappings.add(modes, ["r"], "Reload current page", - function () { vimperator.tabs.reload(getBrowser().mCurrentTab, false); }); + function () { liberator.tabs.reload(getBrowser().mCurrentTab, false); }); - vimperator.mappings.add(modes, ["R"], + liberator.mappings.add(modes, ["R"], "Reload while skipping the cache", - function () { vimperator.tabs.reload(getBrowser().mCurrentTab, true); }); + function () { liberator.tabs.reload(getBrowser().mCurrentTab, true); }); // yanking - vimperator.mappings.add(modes, ["Y"], + liberator.mappings.add(modes, ["Y"], "Copy selected text or current word", function () { - var sel = vimperator.buffer.getCurrentWord(); + var sel = liberator.buffer.getCurrentWord(); if (sel) - vimperator.copyToClipboard(sel, true); + liberator.copyToClipboard(sel, true); else - vimperator.beep(); + liberator.beep(); }); // zooming - vimperator.mappings.add(modes, ["zi", "+"], + liberator.mappings.add(modes, ["zi", "+"], "Enlarge text zoom of current web page", - function (count) { vimperator.buffer.zoomIn(count > 1 ? count : 1, false); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.zoomIn(count > 1 ? count : 1, false); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["zm"], + liberator.mappings.add(modes, ["zm"], "Enlarge text zoom of current web page by a larger amount", - function (count) { vimperator.buffer.zoomIn((count > 1 ? count : 1) * 3, false); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.zoomIn((count > 1 ? count : 1) * 3, false); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["zo", "-"], + liberator.mappings.add(modes, ["zo", "-"], "Reduce text zoom of current web page", - function (count) { vimperator.buffer.zoomOut(count > 1 ? count : 1, false); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.zoomOut(count > 1 ? count : 1, false); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["zr"], + liberator.mappings.add(modes, ["zr"], "Reduce text zoom of current web page by a larger amount", - function (count) { vimperator.buffer.zoomOut((count > 1 ? count : 1) * 3, false); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.zoomOut((count > 1 ? count : 1) * 3, false); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["zz"], + liberator.mappings.add(modes, ["zz"], "Set text zoom value of current web page", - function (count) { vimperator.buffer.textZoom = count > 1 ? count : 100; }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.textZoom = count > 1 ? count : 100; }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["zI"], + liberator.mappings.add(modes, ["zI"], "Enlarge full zoom of current web page", - function (count) { vimperator.buffer.zoomIn(count > 1 ? count : 1, true); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.zoomIn(count > 1 ? count : 1, true); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["zM"], + liberator.mappings.add(modes, ["zM"], "Enlarge full zoom of current web page by a larger amount", - function (count) { vimperator.buffer.zoomIn((count > 1 ? count : 1) * 3, true); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.zoomIn((count > 1 ? count : 1) * 3, true); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["zO"], + liberator.mappings.add(modes, ["zO"], "Reduce full zoom of current web page", - function (count) { vimperator.buffer.zoomOut(count > 1 ? count : 1, true); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.zoomOut(count > 1 ? count : 1, true); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["zR"], + liberator.mappings.add(modes, ["zR"], "Reduce full zoom of current web page by a larger amount", - function (count) { vimperator.buffer.zoomOut((count > 1 ? count : 1) * 3, true); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.zoomOut((count > 1 ? count : 1) * 3, true); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["zZ"], + liberator.mappings.add(modes, ["zZ"], "Set full zoom value of current web page", - function (count) { vimperator.buffer.fullZoom = count > 1 ? count : 100; }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.fullZoom = count > 1 ? count : 100; }, + { flags: liberator.Mappings.flags.COUNT }); // page info - vimperator.mappings.add(modes, [""], + liberator.mappings.add(modes, [""], "Print the current file name", - function (count) { vimperator.buffer.showPageInfo(false); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.buffer.showPageInfo(false); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["g"], + liberator.mappings.add(modes, ["g"], "Print file information", - function (count) { vimperator.buffer.showPageInfo(true); }); + function (count) { liberator.buffer.showPageInfo(true); }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["ha[rdcopy]"], + liberator.commands.add(["ha[rdcopy]"], "Print current document", function () { getBrowser().contentWindow.print(); }); - vimperator.commands.add(["pa[geinfo]"], + liberator.commands.add(["pa[geinfo]"], "Show various page information", - function () { vimperator.buffer.showPageInfo(true); }); + function () { liberator.buffer.showPageInfo(true); }); - vimperator.commands.add(["re[load]"], + liberator.commands.add(["re[load]"], "Reload current page", - function (args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); }); + function (args, special) { liberator.tabs.reload(getBrowser().mCurrentTab, special); }); - vimperator.commands.add(["sav[eas]", "w[rite]"], + liberator.commands.add(["sav[eas]", "w[rite]"], "Save current document to disk", function (args, special) { - var file = vimperator.io.getFile(args || ""); + var file = liberator.io.getFile(args || ""); // we always want to save that link relative to the current working directory - vimperator.options.setPref("browser.download.lastDir", vimperator.io.getCurrentDirectory()); + liberator.options.setPref("browser.download.lastDir", liberator.io.getCurrentDirectory()); //if (args) //{ - // saveURL(vimperator.buffer.URL, args, null, true, special, // special == skipPrompt - // makeURI(vimperator.buffer.URL, content.document.characterSet)); + // saveURL(liberator.buffer.URL, args, null, true, special, // special == skipPrompt + // makeURI(liberator.buffer.URL, content.document.characterSet)); //} //else saveDocument(window.content.document, special); }); - vimperator.commands.add(["st[op]"], + liberator.commands.add(["st[op]"], "Stop loading", function () { BrowserStop(); }); - vimperator.commands.add(["vie[wsource]"], + liberator.commands.add(["vie[wsource]"], "View source code of current document", - function (args, special) { vimperator.buffer.viewSource(args, special) }); + function (args, special) { liberator.buffer.viewSource(args, special) }); - vimperator.commands.add(["zo[om]"], + liberator.commands.add(["zo[om]"], "Set zoom value of current web page", function (args, special) { @@ -472,9 +472,9 @@ vimperator.Buffer = function () //{{{ else if (/^[+-]\d+$/.test(args)) { if (special) - level = vimperator.buffer.fullZoom + parseInt(args, 10); + level = liberator.buffer.fullZoom + parseInt(args, 10); else - level = vimperator.buffer.textZoom + parseInt(args, 10); + level = liberator.buffer.textZoom + parseInt(args, 10); // relative args shouldn't take us out of range if (level < 1) @@ -484,14 +484,14 @@ vimperator.Buffer = function () //{{{ } else { - vimperator.echoerr("E488: Trailing characters"); + liberator.echoerr("E488: Trailing characters"); return; } if (special) - vimperator.buffer.fullZoom = level; + liberator.buffer.fullZoom = level; else - vimperator.buffer.textZoom = level; + liberator.buffer.textZoom = level; }); /////////////////////////////////////////////////////////////////////////////}}} @@ -591,7 +591,7 @@ vimperator.Buffer = function () //{{{ // argument "args" is something like: @id='myid' or @type='text' (don't forget the quotes around myid) getElement: function (args, index) { - return vimperator.buffer.evaluateXPath("//*[" + (args || "") + "]").snapshotItem(index || 0) + return liberator.buffer.evaluateXPath("//*[" + (args || "") + "]").snapshotItem(index || 0) }, // artificially "clicks" a link in order to open it @@ -618,15 +618,15 @@ vimperator.Buffer = function () //{{{ var newTab = false, newWindow = false; switch (where) { - case vimperator.NEW_TAB: - case vimperator.NEW_BACKGROUND_TAB: + case liberator.NEW_TAB: + case liberator.NEW_BACKGROUND_TAB: newTab = true; break; - case vimperator.NEW_WINDOW: + case liberator.NEW_WINDOW: newWindow = true; break; default: - vimperator.log("Invalid where argument for followLink()"); + liberator.log("Invalid where argument for followLink()"); } elem.focus(); @@ -680,12 +680,12 @@ vimperator.Buffer = function () //{{{ { urlSecurityCheck(url, doc.nodePrincipal); // we always want to save that link relative to the current working directory - vimperator.options.setPref("browser.download.lastDir", vimperator.io.getCurrentDirectory()); + liberator.options.setPref("browser.download.lastDir", liberator.io.getCurrentDirectory()); saveURL(url, text, null, true, skipPrompt, makeURI(url, doc.characterSet)); } catch (e) { - vimperator.echoerr(e); + liberator.echoerr(e); } }, @@ -723,7 +723,7 @@ vimperator.Buffer = function () //{{{ const COL_WIDTH = 20; if (cols > 0 && win.scrollX >= win.scrollMaxX || cols < 0 && win.scrollX == 0) - vimperator.beep(); + liberator.beep(); win.scrollBy(COL_WIDTH * cols, 0); }, @@ -750,13 +750,13 @@ vimperator.Buffer = function () //{{{ scrollByScrollSize: function (count, direction) { if (count > 0) - vimperator.options["scroll"] = count; + liberator.options["scroll"] = count; var win = findScrollableWindow(); checkScrollYBounds(win, direction); - if (vimperator.options["scroll"] > 0) - this.scrollLines(vimperator.options["scroll"] * direction); + if (liberator.options["scroll"] > 0) + this.scrollLines(liberator.options["scroll"] * direction); else // scroll half a page down in pixels win.scrollBy(0, win.innerHeight / 2 * direction); }, @@ -833,7 +833,7 @@ vimperator.Buffer = function () //{{{ if (next > frames.length - 1) { if (current == frames.length - 1) - vimperator.beep(); // still allow the frame indicator to be activated + liberator.beep(); // still allow the frame indicator to be activated next = frames.length - 1; } @@ -848,7 +848,7 @@ vimperator.Buffer = function () //{{{ if (next < 0) { if (current == 0) - vimperator.beep(); // still allow the frame indicator to be activated + liberator.beep(); // still allow the frame indicator to be activated next = 0; } @@ -864,7 +864,7 @@ vimperator.Buffer = function () //{{{ // document var doc = frames[next].document; var indicator = doc.createElement("div"); - indicator.id = "vimperator-frame-indicator"; + indicator.id = "liberator-frame-indicator"; // NOTE: need to set a high z-index - it's a crapshoot! var style = "background-color: red; opacity: 0.5; z-index: 999;" + "position: fixed; top: 0; bottom: 0; left: 0; right: 0;"; @@ -879,12 +879,12 @@ vimperator.Buffer = function () //{{{ // updates the buffer preview in place only if list is visible updateBufferList: function () { - if (!vimperator.bufferwindow.visible()) + if (!liberator.bufferwindow.visible()) return; - var items = vimperator.completion.buffer("")[1]; - vimperator.bufferwindow.show(items); - vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex); + var items = liberator.completion.buffer("")[1]; + liberator.bufferwindow.show(items); + liberator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex); }, zoomIn: function (steps, fullZoom) @@ -901,7 +901,7 @@ vimperator.Buffer = function () //{{{ // TODO: print more useful information, just like the DOM inspector showElementInfo: function (elem) { - vimperator.echo("Element:
" + vimperator.util.objectToString(elem), vimperator.commandline.FORCE_MULTILINE); + liberator.echo("Element:
" + liberator.util.objectToString(elem), liberator.commandline.FORCE_MULTILINE); }, showPageInfo: function (verbose) @@ -1001,8 +1001,8 @@ vimperator.Buffer = function () //{{{ var pageSize = []; // [0] bytes; [1] kbytes if (cacheEntryDescriptor) { - pageSize[0] = vimperator.util.formatBytes(cacheEntryDescriptor.dataSize, 0, false); - pageSize[1] = vimperator.util.formatBytes(cacheEntryDescriptor.dataSize, 2, true); + pageSize[0] = liberator.util.formatBytes(cacheEntryDescriptor.dataSize, 0, false); + pageSize[1] = liberator.util.formatBytes(cacheEntryDescriptor.dataSize, 2, true); if (pageSize[1] == pageSize[0]) pageSize[1] = null; // don't output "xx Bytes" twice } @@ -1030,7 +1030,7 @@ vimperator.Buffer = function () //{{{ if (isValidFeed(feed, window.content.document.nodePrincipal, rels.feed)) { var type = feedTypes[feed.type] || feedTypes["application/rss+xml"]; - pageFeeds.push([feed.title, vimperator.util.highlightURL(feed.href, true) + " (" + type + ")"]); + pageFeeds.push([feed.title, liberator.util.highlightURL(feed.href, true) + " (" + type + ")"]); } } } @@ -1061,22 +1061,22 @@ vimperator.Buffer = function () //{{{ if (countFeeds) info.push(countFeeds); - if (vimperator.bookmarks.isBookmarked(this.URL)) + if (liberator.bookmarks.isBookmarked(this.URL)) info.push("bookmarked"); var pageInfoText = '"' + file + '" [' + info.join(", ") + "] " + title; - vimperator.echo(pageInfoText, vimperator.commandline.FORCE_SINGLELINE); + liberator.echo(pageInfoText, liberator.commandline.FORCE_SINGLELINE); return; } // get general infos pageGeneral.push(["Title", window.content.document.title]); - pageGeneral.push(["URL", vimperator.util.highlightURL(window.content.document.location.toString(), true)]); + pageGeneral.push(["URL", liberator.util.highlightURL(window.content.document.location.toString(), true)]); var ref = "referrer" in window.content.document && window.content.document.referrer; if (ref) - pageGeneral.push(["Referrer", vimperator.util.highlightURL(ref, true)]); + pageGeneral.push(["Referrer", liberator.util.highlightURL(ref, true)]); if (pageSize[0]) { @@ -1111,7 +1111,7 @@ vimperator.Buffer = function () //{{{ // sort: ignore-case tmpSort.sort(function (a, b) { return a.toLowerCase() > b.toLowerCase() ? 1 : -1; }); for (var i = 0; i < tmpSort.length; i++) - pageMeta.push([tmpDict[tmpSort[i]][0], vimperator.util.highlightURL(tmpDict[tmpSort[i]][1], false)]); + pageMeta.push([tmpDict[tmpSort[i]][0], liberator.util.highlightURL(tmpDict[tmpSort[i]][1], false)]); } pageMeta.push(["Meta Tags", ""]); // add extra text to the end @@ -1119,7 +1119,7 @@ vimperator.Buffer = function () //{{{ pageFeeds.push(["Feeds", ""]); var pageInfoText = ""; - var option = vimperator.options["pageinfo"]; + var option = liberator.options["pageinfo"]; var br = ""; for (var z = 0; z < option.length; z++) @@ -1152,7 +1152,7 @@ vimperator.Buffer = function () //{{{ break; } } - vimperator.echo(pageInfoText, vimperator.commandline.FORCE_MULTILINE); + liberator.echo(pageInfoText, liberator.commandline.FORCE_MULTILINE); }, followDocumentRelationship: function (relationship) @@ -1166,16 +1166,16 @@ vimperator.Buffer = function () //{{{ switch (relationship) { case "next": - regexps = vimperator.options["nextpattern"].split(","); + regexps = liberator.options["nextpattern"].split(","); revString = "previous"; break; case "previous": // TODO: accept prev\%[ious] - regexps = vimperator.options["previouspattern"].split(","); + regexps = liberator.options["previouspattern"].split(","); revString = "next"; break; default: - vimperator.echoerr("Bad document relationship: " + relationship); + liberator.echoerr("Bad document relationship: " + relationship); } relText = new RegExp(relationship, "i"); @@ -1186,7 +1186,7 @@ vimperator.Buffer = function () //{{{ { if (relText.test(elems[i].rel) || revText.test(elems[i].rev)) { - vimperator.open(elems[i].href); + liberator.open(elems[i].href); return true; } } @@ -1197,7 +1197,7 @@ vimperator.Buffer = function () //{{{ { if (relText.test(elems[i].rel) || revText.test(elems[i].rev)) { - vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB); + liberator.buffer.followLink(elems[i], liberator.CURRENT_TAB); return true; } } @@ -1209,7 +1209,7 @@ vimperator.Buffer = function () //{{{ { if (patternText.test(elems[i].textContent)) { - vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB); + liberator.buffer.followLink(elems[i], liberator.CURRENT_TAB); return true; } else @@ -1220,7 +1220,7 @@ vimperator.Buffer = function () //{{{ { if (patternText.test(children[j].alt)) { - vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB); + liberator.buffer.followLink(elems[i], liberator.CURRENT_TAB); return true; } } @@ -1251,7 +1251,7 @@ vimperator.Buffer = function () //{{{ } if (!retVal) - vimperator.beep(); + liberator.beep(); }, viewSelectionSource: function () @@ -1277,27 +1277,27 @@ vimperator.Buffer = function () //{{{ // url is optional viewSource: function (url, useExternalEditor) { - var url = url || vimperator.buffer.URL; + var url = url || liberator.buffer.URL; if (useExternalEditor) { // TODO: make that a helper function // TODO: save return value in v:shell_error var newThread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0); - var editor = vimperator.options["editor"]; + var editor = liberator.options["editor"]; var args = editor.split(" "); // FIXME: too simple if (args.length < 1) { - vimperator.echoerr("no editor specified"); + liberator.echoerr("no editor specified"); return; } var prog = args.shift(); args.push(url) - vimperator.callFunctionInThread(newThread, vimperator.io.run, [prog, args, true]); + liberator.callFunctionInThread(newThread, liberator.io.run, [prog, args, true]); } else { - vimperator.open("view-source:" + url) + liberator.open("view-source:" + url) } } }; @@ -1306,7 +1306,7 @@ vimperator.Buffer = function () //{{{ -vimperator.Marks = function () //{{{ +liberator.Marks = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -1344,7 +1344,7 @@ vimperator.Marks = function () //{{{ { if (localMarks[mark][i].location == win.location.href) { - vimperator.log("Deleting local mark: " + mark + " | " + localMarks[mark][i].location + " | (" + localMarks[mark][i].position.x + ", " + localMarks[mark][i].position.y + ") | tab: " + vimperator.tabs.index(localMarks[mark][i].tab), 5); + liberator.log("Deleting local mark: " + mark + " | " + localMarks[mark][i].location + " | (" + localMarks[mark][i].position.x + ", " + localMarks[mark][i].position.y + ") | tab: " + liberator.tabs.index(localMarks[mark][i].tab), 5); localMarks[mark].splice(i, 1); if (localMarks[mark].length == 0) delete localMarks[mark]; @@ -1358,7 +1358,7 @@ vimperator.Marks = function () //{{{ { if (mark in urlMarks) { - vimperator.log("Deleting URL mark: " + mark + " | " + urlMarks[mark].location + " | (" + urlMarks[mark].position.x + ", " + urlMarks[mark].position.y + ") | tab: " + vimperator.tabs.index(urlMarks[mark].tab), 5); + liberator.log("Deleting URL mark: " + mark + " | " + urlMarks[mark].location + " | (" + urlMarks[mark].position.x + ", " + urlMarks[mark].position.y + ") | tab: " + liberator.tabs.index(urlMarks[mark].tab), 5); delete urlMarks[mark]; } } @@ -1411,44 +1411,44 @@ vimperator.Marks = function () //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL]; + var modes = liberator.config.browserModes || [liberator.modes.NORMAL]; - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["m"], "Set mark at the cursor position", function (arg) { if (/[^a-zA-Z]/.test(arg)) { - vimperator.beep(); + liberator.beep(); return; } - vimperator.marks.add(arg); + liberator.marks.add(arg); }, - { flags: vimperator.Mappings.flags.ARGUMENT }); + { flags: liberator.Mappings.flags.ARGUMENT }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["'", "`"], "Jump to the mark in the current buffer", - function (arg) { vimperator.marks.jumpTo(arg); }, - { flags: vimperator.Mappings.flags.ARGUMENT }); + function (arg) { liberator.marks.jumpTo(arg); }, + { flags: liberator.Mappings.flags.ARGUMENT }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["delm[arks]"], + liberator.commands.add(["delm[arks]"], "Delete the specified marks", function (args, special) { if (!special && !args) { - vimperator.echoerr("E471: Argument required"); + liberator.echoerr("E471: Argument required"); return; } if (special && args) { - vimperator.echoerr("E474: Invalid argument"); + liberator.echoerr("E474: Invalid argument"); return; } var matches; @@ -1457,7 +1457,7 @@ vimperator.Marks = function () //{{{ // NOTE: this currently differs from Vim's behavior which // deletes any valid marks in the arg list, up to the first // invalid arg, as well as giving the error message. - vimperator.echoerr("E475: Invalid argument: " + matches[0]); + liberator.echoerr("E475: Invalid argument: " + matches[0]); return; } // check for illegal ranges - only allow a-z A-Z 0-9 @@ -1472,51 +1472,51 @@ vimperator.Marks = function () //{{{ /[0-9]/.test(start) != /[0-9]/.test(end) || start > end) { - vimperator.echoerr("E475: Invalid argument: " + args.match(new RegExp(matches[i] + ".*"))[0]); + liberator.echoerr("E475: Invalid argument: " + args.match(new RegExp(matches[i] + ".*"))[0]); return; } } } - vimperator.marks.remove(args, special); + liberator.marks.remove(args, special); }); - vimperator.commands.add(["ma[rk]"], + liberator.commands.add(["ma[rk]"], "Mark current location within the web page", function (args) { if (!args) { - vimperator.echoerr("E471: Argument required"); + liberator.echoerr("E471: Argument required"); return; } if (args.length > 1) { - vimperator.echoerr("E488: Trailing characters"); + liberator.echoerr("E488: Trailing characters"); return; } if (!/[a-zA-Z]/.test(args)) { - vimperator.echoerr("E191: Argument must be a letter or forward/backward quote"); + liberator.echoerr("E191: Argument must be a letter or forward/backward quote"); return; } - vimperator.marks.add(args); + liberator.marks.add(args); }); - vimperator.commands.add(["marks"], + liberator.commands.add(["marks"], "Show all location marks of current web page", function (args) { // ignore invalid mark characters unless there are no valid mark chars if (args && !/[a-zA-Z]/.test(args)) { - vimperator.echoerr("E283: No marks matching \"" + args + "\""); + liberator.echoerr("E283: No marks matching \"" + args + "\""); return; } var filter = args.replace(/[^a-zA-Z]/g, ""); - vimperator.marks.list(filter); + liberator.marks.list(filter); }); /////////////////////////////////////////////////////////////////////////////}}} @@ -1532,7 +1532,7 @@ vimperator.Marks = function () //{{{ if (win.document.body.localName.toLowerCase() == "frameset") { - vimperator.echoerr("marks support for frameset pages not implemented yet"); + liberator.echoerr("marks support for frameset pages not implemented yet"); return; } @@ -1542,8 +1542,8 @@ vimperator.Marks = function () //{{{ if (isURLMark(mark)) { - vimperator.log("Adding URL mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ") | tab: " + vimperator.tabs.index(vimperator.tabs.getTab()), 5); - urlMarks[mark] = { location: win.location.href, position: position, tab: vimperator.tabs.getTab() }; + liberator.log("Adding URL mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ") | tab: " + liberator.tabs.index(liberator.tabs.getTab()), 5); + urlMarks[mark] = { location: win.location.href, position: position, tab: liberator.tabs.getTab() }; } else if (isLocalMark(mark)) { @@ -1551,7 +1551,7 @@ vimperator.Marks = function () //{{{ removeLocalMark(mark); if (!localMarks[mark]) localMarks[mark] = []; - vimperator.log("Adding local mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ")", 5); + liberator.log("Adding local mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ")", 5); localMarks[mark].push({ location: win.location.href, position: position }); } }, @@ -1593,14 +1593,14 @@ vimperator.Marks = function () //{{{ { pendingJumps.push(slice); // NOTE: this obviously won't work on generated pages using - // non-unique URLs, like Vimperator's help :( - vimperator.open(slice.location, vimperator.NEW_TAB); + // non-unique URLs, like liberator's help :( + liberator.open(slice.location, liberator.NEW_TAB); return; } - var index = vimperator.tabs.index(slice.tab); + var index = liberator.tabs.index(slice.tab); if (index != -1) { - vimperator.tabs.select(index); + liberator.tabs.select(index); var win = slice.tab.linkedBrowser.contentWindow; if (win.location.href != slice.location) { @@ -1608,7 +1608,7 @@ vimperator.Marks = function () //{{{ win.location.href = slice.location; return; } - vimperator.log("Jumping to URL mark: " + mark + " | " + slice.location + " | (" + slice.position.x + ", " + slice.position.y + ") | tab: " + vimperator.tabs.index(slice.tab), 5); + liberator.log("Jumping to URL mark: " + mark + " | " + slice.location + " | (" + slice.position.x + ", " + slice.position.y + ") | tab: " + liberator.tabs.index(slice.tab), 5); win.scrollTo(slice.position.x * win.scrollMaxX, slice.position.y * win.scrollMaxY); ok = true; } @@ -1623,7 +1623,7 @@ vimperator.Marks = function () //{{{ { if (win.location.href == slice[i].location) { - vimperator.log("Jumping to local mark: " + mark + " | " + slice[i].location + " | (" + slice[i].position.x + ", " + slice[i].position.y + ")", 5); + liberator.log("Jumping to local mark: " + mark + " | " + slice[i].location + " | (" + slice[i].position.x + ", " + slice[i].position.y + ")", 5); win.scrollTo(slice[i].position.x * win.scrollMaxX, slice[i].position.y * win.scrollMaxY); ok = true; } @@ -1631,7 +1631,7 @@ vimperator.Marks = function () //{{{ } if (!ok) - vimperator.echoerr("E20: Mark not set"); // FIXME: move up? + liberator.echoerr("E20: Mark not set"); // FIXME: move up? }, list: function (filter) @@ -1640,7 +1640,7 @@ vimperator.Marks = function () //{{{ if (marks.length == 0) { - vimperator.echoerr("No marks set"); + liberator.echoerr("No marks set"); return; } @@ -1652,12 +1652,12 @@ vimperator.Marks = function () //{{{ }); if (marks.length == 0) { - vimperator.echoerr("E283: No marks matching \"" + filter + "\""); + liberator.echoerr("E283: No marks matching \"" + filter + "\""); return; } } - var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "
" + ""; for (var i = 0; i < marks.length; i++) { @@ -1665,12 +1665,12 @@ vimperator.Marks = function () //{{{ "" + "" + "" + - "" + + "" + ""; } list += "
marklinecolfile
" + marks[i][0] + "" + Math.round(marks[i][1].position.y * 100) + "%" + Math.round(marks[i][1].position.x * 100) + "%" + vimperator.util.escapeHTML(marks[i][1].location) + "" + liberator.util.escapeHTML(marks[i][1].location) + "
"; - vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); + liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } }; diff --git a/content/commands.js b/content/commands.js index 4c121494..1d369c4e 100644 --- a/content/commands.js +++ b/content/commands.js @@ -27,8 +27,8 @@ the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ // Do NOT create instances of this class yourself, use the helper method -// vimperator.commands.add() instead -vimperator.Command = function (specs, description, action, extraInfo) //{{{ +// liberator.commands.add() instead +liberator.Command = function (specs, description, action, extraInfo) //{{{ { if (!specs || !action) return null; @@ -79,7 +79,7 @@ vimperator.Command = function (specs, description, action, extraInfo) //{{{ this.isUserCommand = extraInfo.isUserCommand || false; }; -vimperator.Command.prototype = { +liberator.Command.prototype = { execute: function (args, special, count, modifiers) { @@ -120,7 +120,7 @@ vimperator.Command.prototype = { }; //}}} -vimperator.Commands = function () //{{{ +liberator.Commands = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -284,7 +284,7 @@ vimperator.Commands = function () //{{{ [count, arg] = getNextArg(sub.substr(optname.length + 1)); if (count == -1) { - vimperator.echoerr("Invalid argument for option " + optname); + liberator.echoerr("Invalid argument for option " + optname); return null; } @@ -295,7 +295,7 @@ vimperator.Commands = function () //{{{ [count, arg] = getNextArg(sub.substr(optname.length + 1)); if (count == -1) { - vimperator.echoerr("Invalid argument for option " + optname); + liberator.echoerr("Invalid argument for option " + optname); return null; } @@ -318,7 +318,7 @@ vimperator.Commands = function () //{{{ case commandManager.OPTION_NOARG: if (arg != null) { - vimperator.echoerr("No argument allowed for option: " + optname); + liberator.echoerr("No argument allowed for option: " + optname); return null; } break; @@ -329,14 +329,14 @@ vimperator.Commands = function () //{{{ arg = false; else { - vimperator.echoerr("Invalid argument for boolean option: " + optname); + liberator.echoerr("Invalid argument for boolean option: " + optname); return null; } break; case commandManager.OPTION_STRING: if (arg == null) { - vimperator.echoerr("Argument required for string option: " + optname); + liberator.echoerr("Argument required for string option: " + optname); return null; } break; @@ -344,7 +344,7 @@ vimperator.Commands = function () //{{{ arg = parseInt(arg, 10); if (isNaN(arg)) { - vimperator.echoerr("Numeric argument required for integer option: " + optname); + liberator.echoerr("Numeric argument required for integer option: " + optname); return null; } break; @@ -352,14 +352,14 @@ vimperator.Commands = function () //{{{ arg = parseFloat(arg); if (isNaN(arg)) { - vimperator.echoerr("Numeric argument required for float option: " + optname); + liberator.echoerr("Numeric argument required for float option: " + optname); return null; } break; case commandManager.OPTION_LIST: if (arg == null) { - vimperator.echoerr("Argument required for list option: " + optname); + liberator.echoerr("Argument required for list option: " + optname); return null; } arg = arg.split(/\s*,\s*/); @@ -371,7 +371,7 @@ vimperator.Commands = function () //{{{ { if (options[opt][2].call(this, arg) == false) { - vimperator.echoerr("Invalid argument for option: " + optname); + liberator.echoerr("Invalid argument for option: " + optname); return null; } } @@ -389,7 +389,7 @@ vimperator.Commands = function () //{{{ var [count, arg] = getNextArg(sub); if (count == -1) { - vimperator.echoerr("Error parsing arguments: " + arg); + liberator.echoerr("Error parsing arguments: " + arg); return null; } @@ -468,7 +468,7 @@ vimperator.Commands = function () //{{{ add: function (names, description, action, extra) { - var command = new vimperator.Command(names, description, action, extra); + var command = new liberator.Command(names, description, action, extra); if (!command) return false; @@ -477,7 +477,7 @@ vimperator.Commands = function () //{{{ if (exCommands[i].name == command.name) { // never replace for now - vimperator.log("Warning: :" + names[0] + " already exists, NOT replacing existing command.", 2); + liberator.log("Warning: :" + names[0] + " already exists, NOT replacing existing command.", 2); return false; } } @@ -492,7 +492,7 @@ vimperator.Commands = function () //{{{ extra.isUserCommand = true; description = description || "User defined command"; - var command = new vimperator.Command(names, description, action, extra); + var command = new liberator.Command(names, description, action, extra); if (!command) return false; @@ -579,7 +579,7 @@ vimperator.Commands = function () //{{{ var res = args.match(/^(\w+)(?:\s+(.+))?$/); if (!res) { - vimperator.echoerr("E182: Invalid command name"); + liberator.echoerr("E182: Invalid command name"); return false; } var [cmd, rep] = [res[1], res[2]] @@ -587,12 +587,12 @@ vimperator.Commands = function () //{{{ if (rep) { - if (!vimperator.commands.addUserCommand([cmd], + if (!liberator.commands.addUserCommand([cmd], "User defined command", function (args, special, count, modifiers) { eval(rep) }), special); { - vimperator.echoerr("E174: Command already exists: add ! to replace it"); + liberator.echoerr("E174: Command already exists: add ! to replace it"); } } else @@ -600,15 +600,15 @@ vimperator.Commands = function () //{{{ var cmdlist = getUserCommands(cmd); if (cmdlist.length > 0) { - var str = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + var str = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "
" + ""; for (var i = 0; i < cmdlist.length; i++) str += ""; str += "
NameArgsDefinition
" + cmdlist[i].name + "" + "*" + "" + cmdlist[i].isUserCommand + "
" - vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); + liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } else - vimperator.echo("No user-defined commands found"); + liberator.echo("No user-defined commands found"); } }, { @@ -620,7 +620,7 @@ vimperator.Commands = function () //{{{ // TODO: remove preview window, or change it at least commandManager.add(["pc[lose]"], "Close preview window on bottom of screen", - function () { vimperator.previewwindow.hide(); }); + function () { liberator.previewwindow.hide(); }); //}}} diff --git a/content/completion.js b/content/completion.js index 356733da..ae28a722 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 () //{{{ +liberator.Completion = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -150,7 +150,7 @@ vimperator.Completion = function () //{{{ dialog: function (filter) { substrings = []; - var nodes = vimperator.config.dialogs || []; + var nodes = liberator.config.dialogs || []; if (!filter) return [0, nodes]; @@ -165,7 +165,7 @@ vimperator.Completion = function () //{{{ macros: function (filter) { var macros = []; - var tmp = vimperator.events.getMacros(); + var tmp = liberator.events.getMacros(); for (var item in tmp) macros.push([item, tmp[item]]); @@ -195,7 +195,7 @@ vimperator.Completion = function () //{{{ filter = skip[2]; } - var cpt = complete || vimperator.options["complete"]; + var cpt = complete || liberator.options["complete"]; // join all completion arrays together for (var i = 0; i < cpt.length; i++) { @@ -204,9 +204,9 @@ vimperator.Completion = function () //{{{ else if (cpt[i] == "f") completions = completions.concat(this.file(filter, false)[1]); else if (cpt[i] == "b") - completions = completions.concat(vimperator.bookmarks.get(filter)); + completions = completions.concat(liberator.bookmarks.get(filter)); else if (cpt[i] == "h") - completions = completions.concat(vimperator.history.get(filter)); + completions = completions.concat(liberator.history.get(filter)); } return [start, completions]; @@ -214,7 +214,7 @@ vimperator.Completion = function () //{{{ search: function (filter) { - var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords()); + var engines = liberator.bookmarks.getSearchEngines().concat(liberator.bookmarks.getKeywords()); if (!filter) return [0, engines]; @@ -246,7 +246,7 @@ vimperator.Completion = function () //{{{ try { - files = vimperator.io.readDirectory(dir); + files = liberator.io.readDirectory(dir); mapped = files.map(function (file) { return [[tail ? file.leafName : (dir + file.leafName)], file.isDirectory() ? "Directory" : "File"]; }); @@ -275,12 +275,12 @@ vimperator.Completion = function () //{{{ try { var xmlhttp = new XMLHttpRequest(); - xmlhttp.open("GET", "chrome://" + vimperator.config.name.toLowerCase() + "/locale/" + files[file], false); + xmlhttp.open("GET", "chrome://" + liberator.config.name.toLowerCase() + "/locale/" + files[file], false); xmlhttp.send(null); } catch (e) { - vimperator.log("Error opening chrome://" + vimperator.config.name.toLowerCase() + "/locale/" + files[file], 1); + liberator.log("Error opening chrome://" + liberator.config.name.toLowerCase() + "/locale/" + files[file], 1); continue; } var doc = xmlhttp.responseXML; @@ -305,12 +305,12 @@ vimperator.Completion = function () //{{{ if (!filter) { - for (var command in vimperator.commands) + for (var command in liberator.commands) completions.push([command.name, command.description]); return [0, completions]; } - for (var command in vimperator.commands) + for (var command in liberator.commands) completions.push([command.longNames, command.description]); return [0, buildLongestStartingSubstring(completions, filter)]; @@ -330,7 +330,7 @@ vimperator.Completion = function () //{{{ if (unfiltered) { var options = []; - for (var option in vimperator.options) + for (var option in liberator.options) { if (prefix && option.type != "boolean") continue; @@ -353,7 +353,7 @@ vimperator.Completion = function () //{{{ var name = prefArray[i]; if (name.match("^" + filter.substr(0, filter.length - 1) + "$" )) { - var value = vimperator.options.getPref(name) + ""; + var value = liberator.options.getPref(name) + ""; return [filter.length + 1, [[value, ""]]]; } } @@ -363,9 +363,9 @@ vimperator.Completion = function () //{{{ for (var i = 0; i < prefArray.length; i++) { if (!filter) - optionCompletions.push([prefArray[i], vimperator.options.getPref(prefArray[i])]); + optionCompletions.push([prefArray[i], liberator.options.getPref(prefArray[i])]); else - optionCompletions.push([[prefArray[i]], vimperator.options.getPref(prefArray[i])]); + optionCompletions.push([[prefArray[i]], liberator.options.getPref(prefArray[i])]); } @@ -378,7 +378,7 @@ vimperator.Completion = function () //{{{ if (!filter) { var options = []; - for (var option in vimperator.options) + for (var option in liberator.options) { if (prefix && option.type != "boolean") continue; @@ -390,7 +390,7 @@ vimperator.Completion = function () //{{{ else if (filter.length > 0 && filter.lastIndexOf("=") == filter.length - 1) { filter = filter.substr(0, filter.length - 1); - for (var option in vimperator.options) + for (var option in liberator.options) { if (option.hasName(filter)) return [filter.length + 1, [[option.value + "", ""]]]; @@ -400,7 +400,7 @@ vimperator.Completion = function () //{{{ // can't use b_l_s_s, since this has special requirements (the prefix) var filterLength = filter.length; - for (var option in vimperator.options) + for (var option in liberator.options) { if (prefix && option.type != "boolean") continue; @@ -533,7 +533,7 @@ vimperator.Completion = function () //{{{ } else { - objects.push("vimperator"); + objects.push("liberator"); objects.push("window"); } @@ -546,7 +546,7 @@ vimperator.Completion = function () //{{{ "var comp = [];" + "var type = '';" + "var value = '';" + - "var obj = eval('with(vimperator){" + objects[o] + "}');" + + "var obj = eval('with(liberator){" + objects[o] + "}');" + "for (var i in obj) {" + " try { type = typeof(obj[i]); } catch (e) { type = 'unknown type'; };" + " if (type == 'number' || type == 'string' || type == 'boolean') {" + @@ -687,7 +687,7 @@ vimperator.Completion = function () //{{{ // TODO: get completions for "nested" command lines like ":time :js " or ":tab :he" exTabCompletion: function (str) { - var [count, cmd, special, args] = vimperator.commands.parseCommand(str); + var [count, cmd, special, args] = liberator.commands.parseCommand(str); var completions = []; var start = 0; var exLength = 0; @@ -699,7 +699,7 @@ vimperator.Completion = function () //{{{ return [matches[1].length, this.command(cmd)[1]]; // dynamically get completions as specified with the command's completer function - var command = vimperator.commands.get(cmd); + var command = liberator.commands.get(cmd); if (command && command.completer) { matches = str.match(/^:*\d*\w+!?\s+/); diff --git a/content/editor.js b/content/editor.js index 4db491bf..567675cd 100644 --- a/content/editor.js +++ b/content/editor.js @@ -29,7 +29,7 @@ the terms of any one of the MPL, the GPL or the LGPL. // command names taken from: // http://developer.mozilla.org/en/docs/Editor_Embedding_Guide -vimperator.Editor = function () //{{{ +liberator.Editor = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -56,15 +56,15 @@ vimperator.Editor = function () //{{{ function selectPreviousLine() { - vimperator.editor.executeCommand("cmd_selectLinePrevious"); - if ((vimperator.modes.extended & vimperator.modes.LINE) && !vimperator.editor.selectedText()) - vimperator.editor.executeCommand("cmd_selectLinePrevious"); + liberator.editor.executeCommand("cmd_selectLinePrevious"); + if ((liberator.modes.extended & liberator.modes.LINE) && !liberator.editor.selectedText()) + liberator.editor.executeCommand("cmd_selectLinePrevious"); } function selectNextLine() { - vimperator.editor.executeCommand("cmd_selectLineNext"); - if ((vimperator.modes.extended & vimperator.modes.LINE) && !vimperator.editor.selectedText()) - vimperator.editor.executeCommand("cmd_selectLineNext"); + liberator.editor.executeCommand("cmd_selectLineNext"); + if ((liberator.modes.extended & liberator.modes.LINE) && !liberator.editor.selectedText()) + liberator.editor.executeCommand("cmd_selectLineNext"); } // add mappings for commands like h,j,k,l,etc. in CARET, VISUAL and TEXTAREA mode @@ -72,9 +72,9 @@ vimperator.Editor = function () //{{{ { var extraInfo = {}; if (hasCount) - extraInfo.flags = vimperator.Mappings.flags.COUNT; + extraInfo.flags = liberator.Mappings.flags.COUNT; - vimperator.mappings.add([vimperator.modes.CARET], keys, "", + liberator.mappings.add([liberator.modes.CARET], keys, "", function (count) { if (typeof count != "number" || count < 1) @@ -90,7 +90,7 @@ vimperator.Editor = function () //{{{ }, extraInfo); - vimperator.mappings.add([vimperator.modes.VISUAL], keys, "", + liberator.mappings.add([liberator.modes.VISUAL], keys, "", function (count) { if (typeof count != "number" || count < 1 || !hasCount) @@ -103,12 +103,12 @@ vimperator.Editor = function () //{{{ while (count--) { - if (vimperator.modes.extended & vimperator.modes.TEXTAREA) + if (liberator.modes.extended & liberator.modes.TEXTAREA) { if (typeof visualTextareaCommand == "function") visualTextareaCommand(); else - vimperator.editor.executeCommand(visualTextareaCommand); + liberator.editor.executeCommand(visualTextareaCommand); } else controller[caretModeMethod](caretModeArg, true); @@ -116,13 +116,13 @@ vimperator.Editor = function () //{{{ }, extraInfo); - vimperator.mappings.add([vimperator.modes.TEXTAREA], keys, "", + liberator.mappings.add([liberator.modes.TEXTAREA], keys, "", function (count) { if (typeof count != "number" || count < 1) count = 1; - vimperator.editor.executeCommand(textareaCommand, count); + liberator.editor.executeCommand(textareaCommand, count); }, extraInfo); } @@ -130,22 +130,22 @@ vimperator.Editor = function () //{{{ // add mappings for commands like i,a,s,c,etc. in TEXTAREA mode function addBeginInsertModeMap(keys, commands) { - vimperator.mappings.add([vimperator.modes.TEXTAREA], keys, "", + liberator.mappings.add([liberator.modes.TEXTAREA], keys, "", function (count) { for (let c = 0; c < commands.length; c++) - vimperator.editor.executeCommand(commands[c], 1); + liberator.editor.executeCommand(commands[c], 1); - vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA); + liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA); }); } function addMotionMap(key) { - vimperator.mappings.add([vimperator.modes.TEXTAREA], [key], + liberator.mappings.add([liberator.modes.TEXTAREA], [key], "Motion command", - function (motion, count) { vimperator.editor.executeCommandWithMotion(key, motion, count); }, - { flags: vimperator.Mappings.flags.MOTION | vimperator.Mappings.flags.COUNT }); + function (motion, count) { liberator.editor.executeCommandWithMotion(key, motion, count); }, + { flags: liberator.Mappings.flags.MOTION | liberator.Mappings.flags.COUNT }); } // mode = "i" -> add :iabbrev, :iabclear and :iunabbrev commands @@ -154,42 +154,42 @@ vimperator.Editor = function () //{{{ var modeDescription = modeDescription ? " in " + modeDescription + " mode" : ""; var mode = char || "!"; - vimperator.commands.add([char ? char + "a[bbrev]" : "ab[breviate]"], + liberator.commands.add([char ? char + "a[bbrev]" : "ab[breviate]"], "Abbreviate a key sequence" + modeDescription, function (args) { if (!args) { - vimperator.editor.listAbbreviations(mode, ""); + liberator.editor.listAbbreviations(mode, ""); return; } var matches = args.match(/^([^\s]+)(?:\s+(.+))?$/); var [lhs, rhs] = [matches[1], matches[2]]; if (rhs) - vimperator.editor.addAbbreviation(mode, lhs, rhs); + liberator.editor.addAbbreviation(mode, lhs, rhs); else - vimperator.editor.listAbbreviations(mode, lhs); + liberator.editor.listAbbreviations(mode, lhs); }); - vimperator.commands.add([char ? char + "una[bbrev]" : "una[bbreviate]"], + liberator.commands.add([char ? char + "una[bbrev]" : "una[bbreviate]"], "Remove an abbreviation" + modeDescription, - function (args) { vimperator.editor.removeAbbreviation(mode, args); }); + function (args) { liberator.editor.removeAbbreviation(mode, args); }); - vimperator.commands.add([char + "abc[lear]"], + liberator.commands.add([char + "abc[lear]"], "Remove all abbreviations" + modeDescription, - function (args) { vimperator.editor.removeAllAbbreviations(mode); }); + function (args) { liberator.editor.removeAllAbbreviations(mode); }); } /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// OPTIONS ///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.options.add(["editor"], + liberator.options.add(["editor"], "Set the external text editor", "string", "gvim -f"); - vimperator.options.add(["insertmode", "im"], + liberator.options.add(["insertmode", "im"], "Use Insert mode as the default for text areas", "boolean", true); @@ -197,7 +197,7 @@ vimperator.Editor = function () //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var modes = [vimperator.modes.INSERT, vimperator.modes.COMMAND_LINE]; + var modes = [liberator.modes.INSERT, liberator.modes.COMMAND_LINE]; /* KEYS COUNT CARET TEXTAREA VISUAL_TEXTAREA */ addMovementMap(["k", ""], true, "lineMove", false, "cmd_linePrevious", selectPreviousLine); @@ -226,218 +226,218 @@ vimperator.Editor = function () //{{{ addMotionMap("y"); // yank // insert mode mappings - vimperator.mappings.add(modes, + liberator.mappings.add(modes, [""], "Delete previous word", - function () { vimperator.editor.executeCommand("cmd_deleteWordBackward", 1); }); + function () { liberator.editor.executeCommand("cmd_deleteWordBackward", 1); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, [""], "Delete until beginning of current line", function () { // broken in FF3, deletes the whole line: - // vimperator.editor.executeCommand("cmd_deleteToBeginningOfLine", 1); - vimperator.editor.executeCommand("cmd_selectBeginLine", 1); - vimperator.editor.executeCommand("cmd_delete", 1); + // liberator.editor.executeCommand("cmd_deleteToBeginningOfLine", 1); + liberator.editor.executeCommand("cmd_selectBeginLine", 1); + liberator.editor.executeCommand("cmd_delete", 1); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, [""], "Delete until end of current line", - function () { vimperator.editor.executeCommand("cmd_deleteToEndOfLine", 1); }); + function () { liberator.editor.executeCommand("cmd_deleteToEndOfLine", 1); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["", ""], "Move cursor to beginning of current line", - function () { vimperator.editor.executeCommand("cmd_beginLine", 1); }); + function () { liberator.editor.executeCommand("cmd_beginLine", 1); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["", ""], "Move cursor to end of current line", - function () { vimperator.editor.executeCommand("cmd_endLine", 1); }); + function () { liberator.editor.executeCommand("cmd_endLine", 1); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, [""], "Delete character to the left", - function () { vimperator.editor.executeCommand("cmd_deleteCharBackward", 1); }); + function () { liberator.editor.executeCommand("cmd_deleteCharBackward", 1); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, [""], "Delete character to the right", - function () { vimperator.editor.executeCommand("cmd_deleteCharForward", 1); }); + function () { liberator.editor.executeCommand("cmd_deleteCharForward", 1); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, [""], "Insert clipboard/selection", - function () { vimperator.editor.pasteClipboard(); }); + function () { liberator.editor.pasteClipboard(); }); - vimperator.mappings.add([vimperator.modes.INSERT, vimperator.modes.TEXTAREA], + liberator.mappings.add([liberator.modes.INSERT, liberator.modes.TEXTAREA], [""], "Edit text field with an external editor", - function () { vimperator.editor.editWithExternalEditor(); }); + function () { liberator.editor.editWithExternalEditor(); }); // FIXME: does not work correctly - vimperator.mappings.add([vimperator.modes.INSERT], + liberator.mappings.add([liberator.modes.INSERT], [""], "Edit text field in vi mode", - function () { vimperator.mode = vimperator.modes.TEXTAREA; }); + function () { liberator.mode = liberator.modes.TEXTAREA; }); - vimperator.mappings.add([vimperator.modes.INSERT], + liberator.mappings.add([liberator.modes.INSERT], ["", ""], "Expand insert mode abbreviation", - function () { return vimperator.editor.expandAbbreviation("i"); }, - { flags: vimperator.Mappings.flags.ALLOW_EVENT_ROUTING }); + function () { return liberator.editor.expandAbbreviation("i"); }, + { flags: liberator.Mappings.flags.ALLOW_EVENT_ROUTING }); - vimperator.mappings.add([vimperator.modes.INSERT], + liberator.mappings.add([liberator.modes.INSERT], [""], "Expand insert mode abbreviation", - function () { vimperator.editor.expandAbbreviation("i"); document.commandDispatcher.advanceFocus(); }); + function () { liberator.editor.expandAbbreviation("i"); document.commandDispatcher.advanceFocus(); }); - vimperator.mappings.add([vimperator.modes.INSERT], + liberator.mappings.add([liberator.modes.INSERT], ["", ""], "Expand insert mode abbreviation", - function () { vimperator.editor.expandAbbreviation("i"); }); + function () { liberator.editor.expandAbbreviation("i"); }); // textarea mode - vimperator.mappings.add([vimperator.modes.TEXTAREA], + liberator.mappings.add([liberator.modes.TEXTAREA], ["u"], "Undo", function (count) { - vimperator.editor.executeCommand("cmd_undo", count); - vimperator.mode = vimperator.modes.TEXTAREA; + liberator.editor.executeCommand("cmd_undo", count); + liberator.mode = liberator.modes.TEXTAREA; }, - { flags: vimperator.Mappings.flags.COUNT }); + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add([vimperator.modes.TEXTAREA], + liberator.mappings.add([liberator.modes.TEXTAREA], [""], "Redo", function (count) { - vimperator.editor.executeCommand("cmd_redo", count); - vimperator.mode = vimperator.modes.TEXTAREA; + liberator.editor.executeCommand("cmd_redo", count); + liberator.mode = liberator.modes.TEXTAREA; }, - { flags: vimperator.Mappings.flags.COUNT }); + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add([vimperator.modes.TEXTAREA], + liberator.mappings.add([liberator.modes.TEXTAREA], ["o"], "Open line below current", function (count) { - vimperator.editor.executeCommand("cmd_endLine", 1); - vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA); - vimperator.events.feedkeys(""); + liberator.editor.executeCommand("cmd_endLine", 1); + liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA); + liberator.events.feedkeys(""); }); - vimperator.mappings.add([vimperator.modes.TEXTAREA], + liberator.mappings.add([liberator.modes.TEXTAREA], ["O"], "Open line above current", function (count) { - vimperator.editor.executeCommand("cmd_beginLine", 1); - vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA); - vimperator.events.feedkeys(""); - vimperator.editor.executeCommand("cmd_linePrevious", 1); + liberator.editor.executeCommand("cmd_beginLine", 1); + liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA); + liberator.events.feedkeys(""); + liberator.editor.executeCommand("cmd_linePrevious", 1); }); // visual mode - vimperator.mappings.add([vimperator.modes.CARET, vimperator.modes.TEXTAREA, vimperator.modes.VISUAL], + liberator.mappings.add([liberator.modes.CARET, liberator.modes.TEXTAREA, liberator.modes.VISUAL], ["v"], "Start visual mode", - function (count) { vimperator.modes.set(vimperator.modes.VISUAL, vimperator.mode); }); + function (count) { liberator.modes.set(liberator.modes.VISUAL, liberator.mode); }); - vimperator.mappings.add([vimperator.modes.TEXTAREA], + liberator.mappings.add([liberator.modes.TEXTAREA], ["V"], "Start visual line mode", function (count) { - vimperator.modes.set(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA | vimperator.modes.LINE); - vimperator.editor.executeCommand("cmd_beginLine", 1); - vimperator.editor.executeCommand("cmd_selectLineNext", 1); + liberator.modes.set(liberator.modes.VISUAL, liberator.modes.TEXTAREA | liberator.modes.LINE); + liberator.editor.executeCommand("cmd_beginLine", 1); + liberator.editor.executeCommand("cmd_selectLineNext", 1); }); - vimperator.mappings.add([vimperator.modes.VISUAL], + liberator.mappings.add([liberator.modes.VISUAL], ["c", "s"], "Change selected text", function (count) { - if (vimperator.modes.extended & vimperator.modes.TEXTAREA) + if (liberator.modes.extended & liberator.modes.TEXTAREA) { - vimperator.editor.executeCommand("cmd_cut"); - vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA); + liberator.editor.executeCommand("cmd_cut"); + liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA); } else - vimperator.beep(); + liberator.beep(); }); - vimperator.mappings.add([vimperator.modes.VISUAL], + liberator.mappings.add([liberator.modes.VISUAL], ["d"], "Delete selected text", function (count) { - if (vimperator.modes.extended & vimperator.modes.TEXTAREA) + if (liberator.modes.extended & liberator.modes.TEXTAREA) { - vimperator.editor.executeCommand("cmd_cut"); - vimperator.modes.set(vimperator.modes.TEXTAREA); + liberator.editor.executeCommand("cmd_cut"); + liberator.modes.set(liberator.modes.TEXTAREA); } else - vimperator.beep(); + liberator.beep(); }); - vimperator.mappings.add([vimperator.modes.VISUAL], + liberator.mappings.add([liberator.modes.VISUAL], ["y"], "Yank selected text", function (count) { - if (vimperator.modes.extended & vimperator.modes.TEXTAREA) + if (liberator.modes.extended & liberator.modes.TEXTAREA) { - vimperator.editor.executeCommand("cmd_copy"); - vimperator.modes.set(vimperator.modes.TEXTAREA); + liberator.editor.executeCommand("cmd_copy"); + liberator.modes.set(liberator.modes.TEXTAREA); } else { var sel = window.content.document.getSelection(); if (sel) - vimperator.copyToClipboard(sel, true); + liberator.copyToClipboard(sel, true); else - vimperator.beep(); + liberator.beep(); } }); - vimperator.mappings.add([vimperator.modes.VISUAL, vimperator.modes.TEXTAREA], + liberator.mappings.add([liberator.modes.VISUAL, liberator.modes.TEXTAREA], ["p"], "Paste clipboard contents", function (count) { - if (!(vimperator.modes.extended & vimperator.modes.CARET)) + if (!(liberator.modes.extended & liberator.modes.CARET)) { if (!count) count = 1; while (count--) - vimperator.editor.executeCommand("cmd_paste"); - vimperator.mode = vimperator.modes.TEXTAREA; + liberator.editor.executeCommand("cmd_paste"); + liberator.mode = liberator.modes.TEXTAREA; } else - vimperator.beep(); + liberator.beep(); }); // finding characters - vimperator.mappings.add([vimperator.modes.TEXTAREA, vimperator.modes.VISUAL], + liberator.mappings.add([liberator.modes.TEXTAREA, liberator.modes.VISUAL], ["f"], "Move to a character on the current line after the cursor", function (count, arg) { - var pos = vimperator.editor.findCharForward(arg, count); + var pos = liberator.editor.findCharForward(arg, count); if (pos >= 0) - vimperator.editor.moveToPosition(pos, true, vimperator.mode == vimperator.modes.VISUAL); + liberator.editor.moveToPosition(pos, true, liberator.mode == liberator.modes.VISUAL); }, - { flags: vimperator.Mappings.flags.ARGUMENT | vimperator.Mappings.flags.COUNT}); + { flags: liberator.Mappings.flags.ARGUMENT | liberator.Mappings.flags.COUNT}); - vimperator.mappings.add([vimperator.modes.TEXTAREA, vimperator.modes.VISUAL], + liberator.mappings.add([liberator.modes.TEXTAREA, liberator.modes.VISUAL], ["F"], "Move to a charater on the current line before the cursor", function (count, arg) { - var pos = vimperator.editor.findCharBackward(arg, count); + var pos = liberator.editor.findCharBackward(arg, count); if (pos >= 0) - vimperator.editor.moveToPosition(pos, false, vimperator.mode == vimperator.modes.VISUAL); + liberator.editor.moveToPosition(pos, false, liberator.mode == liberator.modes.VISUAL); }, - { flags: vimperator.Mappings.flags.ARGUMENT | vimperator.Mappings.flags.COUNT}); + { flags: liberator.Mappings.flags.ARGUMENT | liberator.Mappings.flags.COUNT}); - vimperator.mappings.add([vimperator.modes.TEXTAREA, vimperator.modes.VISUAL], + liberator.mappings.add([liberator.modes.TEXTAREA, liberator.modes.VISUAL], ["t"], "Move before a character on the current line", function (count, arg) { - var pos = vimperator.editor.findCharForward(arg, count); + var pos = liberator.editor.findCharForward(arg, count); if (pos >= 0) - vimperator.editor.moveToPosition(pos - 1, true, vimperator.mode == vimperator.modes.VISUAL); + liberator.editor.moveToPosition(pos - 1, true, liberator.mode == liberator.modes.VISUAL); }, - { flags: vimperator.Mappings.flags.ARGUMENT | vimperator.Mappings.flags.COUNT}); + { flags: liberator.Mappings.flags.ARGUMENT | liberator.Mappings.flags.COUNT}); - vimperator.mappings.add([vimperator.modes.TEXTAREA, vimperator.modes.VISUAL], + liberator.mappings.add([liberator.modes.TEXTAREA, liberator.modes.VISUAL], ["T"], "Move before a character on the current line, backwards", function (count, arg) { - var pos = vimperator.editor.findCharBackward(arg, count); + var pos = liberator.editor.findCharBackward(arg, count); if (pos >= 0) - vimperator.editor.moveToPosition(pos + 1, false, vimperator.mode == vimperator.modes.VISUAL); + liberator.editor.moveToPosition(pos + 1, false, liberator.mode == liberator.modes.VISUAL); }, - { flags: vimperator.Mappings.flags.ARGUMENT | vimperator.Mappings.flags.COUNT}); + { flags: liberator.Mappings.flags.ARGUMENT | liberator.Mappings.flags.COUNT}); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// @@ -514,7 +514,7 @@ vimperator.Editor = function () //{{{ var controller = getController(); if (!controller || !controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd)) { - vimperator.beep(); + liberator.beep(); return false; } @@ -535,7 +535,7 @@ vimperator.Editor = function () //{{{ catch (e) { if (!didCommand) - vimperator.beep(); + liberator.beep(); return false; } } @@ -556,7 +556,7 @@ vimperator.Editor = function () //{{{ count--; } - vimperator.modes.set(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA); + liberator.modes.set(liberator.modes.VISUAL, liberator.modes.TEXTAREA); switch (motion) { @@ -601,7 +601,7 @@ vimperator.Editor = function () //{{{ break; default: - vimperator.beep(); + liberator.beep(); return false; } @@ -610,11 +610,11 @@ vimperator.Editor = function () //{{{ case "d": this.executeCommand("cmd_delete", 1); // need to reset the mode as the visual selection changes it - vimperator.modes.main = vimperator.modes.TEXTAREA; + liberator.modes.main = liberator.modes.TEXTAREA; break; case "c": this.executeCommand("cmd_delete", 1); - vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA); + liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA); break; case "y": this.executeCommand("cmd_copy", 1); @@ -622,7 +622,7 @@ vimperator.Editor = function () //{{{ break; default: - vimperator.beep(); + liberator.beep(); return false; } return true; @@ -687,7 +687,7 @@ vimperator.Editor = function () //{{{ return i + 1; // always position the cursor after the char } - vimperator.beep(); + liberator.beep(); return -1; }, @@ -714,37 +714,37 @@ vimperator.Editor = function () //{{{ return i; } - vimperator.beep(); + liberator.beep(); return -1; }, editWithExternalEditor: function () { var textBox = document.commandDispatcher.focusedElement; - var editor = vimperator.options["editor"]; + var editor = liberator.options["editor"]; var args = editor.split(" "); if (args.length < 1) { - vimperator.echoerr("no editor specified"); + liberator.echoerr("no editor specified"); return; } try { - var tmpfile = vimperator.io.createTempFile(); + var tmpfile = liberator.io.createTempFile(); } catch (e) { - vimperator.echoerr("Could not create temporary file: " + e.message); + liberator.echoerr("Could not create temporary file: " + e.message); return; } try { - vimperator.io.writeFile(tmpfile, textBox.value); + liberator.io.writeFile(tmpfile, textBox.value); } catch (e) { - vimperator.echoerr("Could not write to temporary file " + tmpfile.path + ": " + e.message); + liberator.echoerr("Could not write to temporary file " + tmpfile.path + ": " + e.message); return; } @@ -757,26 +757,26 @@ vimperator.Editor = function () //{{{ textBox.style.backgroundColor = "#bbbbbb"; var newThread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0); // TODO: save return value in v:shell_error - vimperator.callFunctionInThread(newThread, vimperator.io.run, [prog, args, true]); + liberator.callFunctionInThread(newThread, liberator.io.run, [prog, args, true]); textBox.removeAttribute("readonly"); // if (v:shell_error != 0) // { // tmpBg = "red"; - // vimperator.echoerr("External editor returned with exit code " + retcode); + // liberator.echoerr("External editor returned with exit code " + retcode); // } // else // { try { - var val = vimperator.io.readFile(tmpfile); + var val = liberator.io.readFile(tmpfile); textBox.value = val; } catch (e) { tmpBg = "red"; - vimperator.echoerr("Could not read from temporary file " + tmpfile.path + ": " + e.message); + liberator.echoerr("Could not read from temporary file " + tmpfile.path + ": " + e.message); } // } @@ -823,11 +823,11 @@ vimperator.Editor = function () //{{{ for (var i = 0; i < abbrev[lhs].length; i++) { if (abbrev[lhs][i][0] == filter) - vimperator.echo(abbrev[lhs][i][0] + " " + lhs + " " + abbrev[lhs][i][1]); + liberator.echo(abbrev[lhs][i][0] + " " + lhs + " " + abbrev[lhs][i][1]); return true; } } - vimperator.echoerr("No abbreviations found"); + liberator.echoerr("No abbreviations found"); return false; } else // list all (for that filter {i,c,!}) @@ -846,8 +846,8 @@ vimperator.Editor = function () //{{{ list += ""; list += " " + abbrev[tmplhs][i][0] + ""; - list += " " + vimperator.util.escapeHTML(tmplhs) + ""; - list += " " + vimperator.util.escapeHTML(abbrev[tmplhs][i][1]) + ""; + list += " " + liberator.util.escapeHTML(tmplhs) + ""; + list += " " + liberator.util.escapeHTML(abbrev[tmplhs][i][1]) + ""; list += ""; } } @@ -855,11 +855,11 @@ vimperator.Editor = function () //{{{ if (!flagFound) { - vimperator.echoerr("No abbreviations found"); + liberator.echoerr("No abbreviations found"); return; } list += ""; - vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); + liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } }, @@ -949,7 +949,7 @@ vimperator.Editor = function () //{{{ { if (!lhs) { - vimperator.echoerr("E474: Invalid argument"); + liberator.echoerr("E474: Invalid argument"); return false; } @@ -987,7 +987,7 @@ vimperator.Editor = function () //{{{ } } - vimperator.echoerr("E24: No such abbreviation"); + liberator.echoerr("E24: No such abbreviation"); return false; }, diff --git a/content/events.js b/content/events.js index 9aa24993..24fbb7c5 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.AutoCommands = function() //{{{ +liberator.AutoCommands = function() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -46,16 +46,16 @@ vimperator.AutoCommands = function() //{{{ ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["au[tocmd]"], + liberator.commands.add(["au[tocmd]"], "Execute commands automatically on events", function (args, special) { if (!args) { if (special) // :au! - vimperator.autocommands.remove(null, null); + liberator.autocommands.remove(null, null); else // :au - vimperator.autocommands.list(null, null); + liberator.autocommands.list(null, null); } else { @@ -64,32 +64,32 @@ vimperator.AutoCommands = function() //{{{ if (cmds) { - vimperator.autocommands.add(auEvent, regex, cmds); + liberator.autocommands.add(auEvent, regex, cmds); } else if (regex) // e.g. no cmds provided { if (special) - vimperator.autocommands.remove(auEvent, regex); + liberator.autocommands.remove(auEvent, regex); else - vimperator.autocommands.list(auEvent, regex); + liberator.autocommands.list(auEvent, regex); } else if (auEvent) { if (asterix) if (special) - vimperator.autocommands.remove(null, auEvent); // ':au! * auEvent' + liberator.autocommands.remove(null, auEvent); // ':au! * auEvent' else - vimperator.autocommands.list(null, auEvent); + liberator.autocommands.list(null, auEvent); else if (special) - vimperator.autocommands.remove(auEvent, null); + liberator.autocommands.remove(auEvent, null); else - vimperator.autocommands.list(auEvent, null); + liberator.autocommands.list(auEvent, null); } } }, { - completer: function (filter) { return vimperator.completion.autocommands(filter); } + completer: function (filter) { return liberator.completion.autocommands(filter); } }); /////////////////////////////////////////////////////////////////////////////}}} @@ -187,13 +187,13 @@ vimperator.AutoCommands = function() //{{{ if (flag == true) { list += "" + - vimperator.util.escapeHTML(item) + ""; + liberator.util.escapeHTML(item) + ""; flag = false; } list += ""; - list += "   " + vimperator.util.escapeHTML(autoCommands[item][i][0]) + ""; - list += "" + vimperator.util.escapeHTML(autoCommands[item][i][1]) + ""; + list += "   " + liberator.util.escapeHTML(autoCommands[item][i][0]) + ""; + list += "" + liberator.util.escapeHTML(autoCommands[item][i][1]) + ""; list += ""; } } @@ -201,7 +201,7 @@ vimperator.AutoCommands = function() //{{{ } list += ""; - vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); + liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); }, trigger: function (auEvent, url) @@ -212,7 +212,7 @@ vimperator.AutoCommands = function() //{{{ { var regex = new RegExp(autoCommands[auEvent][i][0]); if (regex.test(url)) - vimperator.execute(autoCommands[auEvent][i][1]); + liberator.execute(autoCommands[auEvent][i][1]); } } } @@ -220,7 +220,7 @@ vimperator.AutoCommands = function() //{{{ //}}} } //}}} -vimperator.Events = function () //{{{ +liberator.Events = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -239,30 +239,30 @@ vimperator.Events = function () //{{{ { tabcontainer.addEventListener("TabMove", function (event) { - vimperator.statusline.updateTabCount(); - vimperator.buffer.updateBufferList(); + liberator.statusline.updateTabCount(); + liberator.buffer.updateBufferList(); }, false); tabcontainer.addEventListener("TabOpen", function (event) { - vimperator.statusline.updateTabCount(); - vimperator.buffer.updateBufferList(); + liberator.statusline.updateTabCount(); + liberator.buffer.updateBufferList(); }, false); tabcontainer.addEventListener("TabClose", function (event) { - vimperator.statusline.updateTabCount(); - vimperator.buffer.updateBufferList(); + liberator.statusline.updateTabCount(); + liberator.buffer.updateBufferList(); }, false); tabcontainer.addEventListener("TabSelect", function (event) { // TODO: is all of that necessary? - vimperator.modes.reset(); - vimperator.commandline.clear(); - vimperator.modes.show(); - vimperator.statusline.updateTabCount(); - vimperator.buffer.updateBufferList(); - vimperator.tabs.updateSelectionHistory(); + liberator.modes.reset(); + liberator.commandline.clear(); + liberator.modes.show(); + liberator.statusline.updateTabCount(); + liberator.buffer.updateBufferList(); + liberator.tabs.updateSelectionHistory(); - setTimeout(function () { vimperator.focusContent(true); }, 10); // just make sure, that no widget has focus + setTimeout(function () { liberator.focusContent(true); }, 10); // just make sure, that no widget has focus }, false); } @@ -273,15 +273,15 @@ vimperator.Events = function () //{{{ // called when the active document is scrolled getBrowser().addEventListener("scroll", function (event) { - vimperator.statusline.updateBufferPosition(); - vimperator.modes.show(); + liberator.statusline.updateBufferPosition(); + liberator.modes.show(); }, null); // getBrowser().addEventListener("submit", function (event) // { // // reset buffer loading state as early as possible, important for macros // dump("submit\n"); -// vimperator.buffer.loaded = 0; +// liberator.buffer.loaded = 0; // }, null); ///////////////////////////////////////////////////////// @@ -289,26 +289,26 @@ vimperator.Events = function () //{{{ var activeMenubar = false; function enterPopupMode(event) { - if (event.originalTarget.localName == "tooltip" || event.originalTarget.id == "vimperator-visualbell") + if (event.originalTarget.localName == "tooltip" || event.originalTarget.id == "liberator-visualbell") return; - vimperator.modes.add(vimperator.modes.MENU); + liberator.modes.add(liberator.modes.MENU); } function exitPopupMode() { // gContextMenu is set to NULL by firefox, when a context menu is closed if (!gContextMenu && !activeMenubar) - vimperator.modes.remove(vimperator.modes.MENU); + liberator.modes.remove(liberator.modes.MENU); } function enterMenuMode() { activeMenubar = true; - vimperator.modes.add(vimperator.modes.MENU); + liberator.modes.add(liberator.modes.MENU); } function exitMenuMode() { activeMenubar = false; - vimperator.modes.remove(vimperator.modes.MENU); + liberator.modes.remove(liberator.modes.MENU); } window.addEventListener("popupshown", enterPopupMode, true); window.addEventListener("popuphidden", exitPopupMode, true); @@ -317,12 +317,12 @@ vimperator.Events = function () //{{{ // window.document.addEventListener("DOMTitleChanged", function (event) // { - // vimperator.log("titlechanged"); + // liberator.log("titlechanged"); // }, null); // NOTE: the order of ["Esc", "Escape"] or ["Escape", "Esc"] // matters, so use that string as the first item, that you - // want to refer to within Vimperator's source code for + // want to refer to within liberator's source code for // comparisons like if (key == "") { ... } var keyTable = [ [ KeyEvent.DOM_VK_ESCAPE, ["Esc", "Escape"] ], @@ -420,23 +420,23 @@ vimperator.Events = function () //{{{ // hacky way to get rid of "Transfering data from ..." on sites with frames // when you click on a link inside a frameset, because asyncUpdateUI // is not triggered there (firefox bug?) - setTimeout(vimperator.statusline.updateUrl, 10); + setTimeout(liberator.statusline.updateUrl, 10); return; } // code which should happen for all (also background) newly loaded tabs goes here: - var url = vimperator.buffer.URL; - var title = vimperator.buffer.title; + var url = liberator.buffer.URL; + var title = liberator.buffer.title; //update history - if (vimperator.history) - vimperator.history.add(url, title); + if (liberator.history) + liberator.history.add(url, title); - vimperator.buffer.updateBufferList(); - vimperator.autocommands.trigger("PageLoad", url); + liberator.buffer.updateBufferList(); + liberator.autocommands.trigger("PageLoad", url); - // mark the buffer as loaded, we can't use vimperator.buffer.loaded + // mark the buffer as loaded, we can't use liberator.buffer.loaded // since that always refers to the current buffer, while doc can be // any buffer, even in a background tab doc.pageIsFullyLoaded = 1; @@ -458,13 +458,13 @@ vimperator.Events = function () //{{{ // return true when load successful, or false otherwise function waitForPageLoaded() { - dump("start waiting in loaded state: " + vimperator.buffer.loaded + "\n"); + dump("start waiting in loaded state: " + liberator.buffer.loaded + "\n"); var mainThread = Components.classes["@mozilla.org/thread-manager;1"]. getService(Components.interfaces.nsIThreadManager).mainThread; while (mainThread.hasPendingEvents()) // clear queue mainThread.processNextEvent(true); -// if (vimperator.buffer.loaded == 1) +// if (liberator.buffer.loaded == 1) // return true; var ms = 15000; // maximum time to wait - TODO: add option @@ -475,27 +475,27 @@ vimperator.Events = function () //{{{ if ((now - then) % 1000 < 10) dump("waited: " + (now - then) + " ms\n"); - if (vimperator.buffer.loaded > 0) + if (liberator.buffer.loaded > 0) break; else - vimperator.echo("Waiting for page to load..."); + liberator.echo("Waiting for page to load..."); } // TODO: allow macros to be continued when page does not fully load with an option - var ret = (vimperator.buffer.loaded == 1); + var ret = (liberator.buffer.loaded == 1); if (!ret) - vimperator.echoerr("Page did not load completely in " + ms + " milliseconds. Macro stopped."); + liberator.echoerr("Page did not load completely in " + ms + " milliseconds. Macro stopped."); dump("done waiting: " + ret + "\n"); return ret; } // load all macros inside ~/.vimperator/macros/ - // setTimeout needed since vimperator.io. is loaded after vimperator.events. + // setTimeout needed since liberator.io. is loaded after liberator.events. setTimeout (function() { try { - var files = vimperator.io.readDirectory(vimperator.io.getSpecialDirectory("macros")); + var files = liberator.io.readDirectory(liberator.io.getSpecialDirectory("macros")); for (var i = 0; i < files.length; i++) { var file = files[i]; @@ -504,13 +504,13 @@ vimperator.Events = function () //{{{ continue; var name = file.leafName.replace(/\.vimp$/i, ""); - macros[name] = vimperator.io.readFile(file).split(/\n/)[0]; - vimperator.log("Macro " + name + " added: " + macros[name], 8); + macros[name] = liberator.io.readFile(file).split(/\n/)[0]; + liberator.log("Macro " + name + " added: " + macros[name], 8); } } catch (e) { - vimperator.log("macro directory not found or error reading macro file"); + liberator.log("macro directory not found or error reading macro file"); } }, 100); @@ -518,92 +518,92 @@ vimperator.Events = function () //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.mappings.add(vimperator.modes.all, + liberator.mappings.add(liberator.modes.all, ["", ""], "Focus content", - function () { vimperator.events.onEscape(); }); + function () { liberator.events.onEscape(); }); // add the ":" mapping in all but insert mode mappings - vimperator.mappings.add([vimperator.modes.NORMAL, vimperator.modes.VISUAL, vimperator.modes.HINTS, vimperator.modes.MESSAGE, vimperator.modes.CARET, vimperator.modes.TEXTAREA], + liberator.mappings.add([liberator.modes.NORMAL, liberator.modes.VISUAL, liberator.modes.HINTS, liberator.modes.MESSAGE, liberator.modes.CARET, liberator.modes.TEXTAREA], [":"], "Enter command line mode", - function () { vimperator.commandline.open(":", "", vimperator.modes.EX); }); + function () { liberator.commandline.open(":", "", liberator.modes.EX); }); // focus events - vimperator.mappings.add([vimperator.modes.NORMAL, vimperator.modes.VISUAL, vimperator.modes.CARET], + liberator.mappings.add([liberator.modes.NORMAL, liberator.modes.VISUAL, liberator.modes.CARET], [""], "Advance keyboard focus", function () { document.commandDispatcher.advanceFocus(); }); - vimperator.mappings.add([vimperator.modes.NORMAL, vimperator.modes.VISUAL, vimperator.modes.CARET, vimperator.modes.INSERT, vimperator.modes.TEXTAREA], + liberator.mappings.add([liberator.modes.NORMAL, liberator.modes.VISUAL, liberator.modes.CARET, liberator.modes.INSERT, liberator.modes.TEXTAREA], [""], "Rewind keyboard focus", function () { document.commandDispatcher.rewindFocus(); }); - vimperator.mappings.add(vimperator.modes.all, - [""], "Temporarily quit Vimperator mode", - function () { vimperator.modes.passAllKeys = true; }); + liberator.mappings.add(liberator.modes.all, + [""], "Temporarily ignore all " + liberator.config.name + " key bindings", + function () { liberator.modes.passAllKeys = true; }); - vimperator.mappings.add(vimperator.modes.all, + liberator.mappings.add(liberator.modes.all, [""], "Pass through next key", - function () { vimperator.modes.passNextKey = true; }); + function () { liberator.modes.passNextKey = true; }); - vimperator.mappings.add(vimperator.modes.all, + liberator.mappings.add(liberator.modes.all, [""], "Do nothing", function () { return; }); // macros - vimperator.mappings.add([vimperator.modes.NORMAL, vimperator.modes.MESSAGE], + liberator.mappings.add([liberator.modes.NORMAL, liberator.modes.MESSAGE], ["q"], "Record a key sequence into a macro", - function (arg) { vimperator.events.startRecording(arg); }, - { flags: vimperator.Mappings.flags.ARGUMENT }); + function (arg) { liberator.events.startRecording(arg); }, + { flags: liberator.Mappings.flags.ARGUMENT }); - vimperator.mappings.add([vimperator.modes.NORMAL, vimperator.modes.MESSAGE], + liberator.mappings.add([liberator.modes.NORMAL, liberator.modes.MESSAGE], ["@"], "Play a macro", function (count, arg) { if (count < 1) count = 1; while (count--) - vimperator.events.playMacro(arg); + liberator.events.playMacro(arg); }, - { flags: vimperator.Mappings.flags.ARGUMENT | vimperator.Mappings.flags.COUNT }); + { flags: liberator.Mappings.flags.ARGUMENT | liberator.Mappings.flags.COUNT }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["delmac[ros]"], + liberator.commands.add(["delmac[ros]"], "Delete macros", function (arg) { if (!arg) - vimperator.echoerr("E474: Invalid argument"); + liberator.echoerr("E474: Invalid argument"); else - vimperator.events.deleteMacros(arg); + liberator.events.deleteMacros(arg); }); - vimperator.commands.add(["macros"], + liberator.commands.add(["macros"], "List all macros", function (arg) { var str = ""; - var macroRef = vimperator.events.getMacros(arg); + var macroRef = liberator.events.getMacros(arg); for (var item in macroRef) str += ""; + liberator.util.escapeHTML(macroRef[item]) + ""; str += "
" + item + "   " + - vimperator.util.escapeHTML(macroRef[item]) + "
"; - vimperator.echo(str, vimperator.commandline.FORCE_MULTILINE); + liberator.echo(str, liberator.commandline.FORCE_MULTILINE); }); - vimperator.commands.add(["pl[ay]"], + liberator.commands.add(["pl[ay]"], "Replay a recorded macro", function (arg) { if (!arg) - vimperator.echoerr("E474: Invalid argument"); + liberator.echoerr("E474: Invalid argument"); else - vimperator.events.playMacro(arg); + liberator.events.playMacro(arg); }, { - completer: function (filter) { return vimperator.completion.macros(filter); } + completer: function (filter) { return liberator.completion.macros(filter); } }); /////////////////////////////////////////////////////////////////////////////}}} @@ -634,10 +634,10 @@ vimperator.Events = function () //{{{ { if (!/[a-zA-Z0-9]/.test(macro)) { - vimperator.echoerr("Register must be [a-zA-z0-9]"); + liberator.echoerr("Register must be [a-zA-z0-9]"); return false; } - vimperator.modes.isRecording = true; + liberator.modes.isRecording = true; if (/[A-Z]/.test(macro)) // uppercase (append) { @@ -656,14 +656,14 @@ vimperator.Events = function () //{{{ { if (!/[a-zA-Z0-9@]/.test(macro) && macro.length == 1) { - vimperator.echoerr("Register must be [a-z0-9]"); + liberator.echoerr("Register must be [a-z0-9]"); return false; } if (macro == "@") // use lastMacro if it's set { if (!lastMacro) { - vimperator.echoerr("E748: No previously used register"); + liberator.echoerr("E748: No previously used register"); return false; } } @@ -677,14 +677,14 @@ vimperator.Events = function () //{{{ if (macros[lastMacro]) { - vimperator.modes.isReplaying = true; + liberator.modes.isReplaying = true; BrowserStop(); // make sure the page is stopped before starting to play the macro - vimperator.buffer.loaded = 1; // even if not a full page load, assume it did load correctly before starting the macro - vimperator.events.feedkeys(macros[lastMacro], true); // true -> noremap - vimperator.modes.isReplaying = false; + liberator.buffer.loaded = 1; // even if not a full page load, assume it did load correctly before starting the macro + liberator.events.feedkeys(macros[lastMacro], true); // true -> noremap + liberator.modes.isReplaying = false; } else - vimperator.echoerr("Register " + lastMacro + " not set"); + liberator.echoerr("Register " + lastMacro + " not set"); }, getMacros: function (filter) @@ -714,7 +714,7 @@ vimperator.Events = function () //{{{ } }, - // This method pushes keys into the event queue from vimperator + // This method pushes keys into the event queue from liberator // it is similar to vim's feedkeys() method, but cannot cope with // 2 partially feeded strings, you have to feed one parsable string // @@ -783,7 +783,7 @@ vimperator.Events = function () //{{{ evt.noremap = noremap; if (elem.dispatchEvent(evt)) // return true in onEvent to stop feeding keys { - vimperator.beep(); + liberator.beep(); return; } } @@ -880,7 +880,7 @@ vimperator.Events = function () //{{{ getMapLeader: function () { - var leaderRef = vimperator.variableReference("mapleader"); + var leaderRef = liberator.variableReference("mapleader"); return leaderRef[0] ? leaderRef[0][leaderRef[1]] : "\\"; }, @@ -892,7 +892,7 @@ vimperator.Events = function () //{{{ onFocusChange: function (event) { // command line has it's own focus change handler - if (vimperator.mode == vimperator.modes.COMMAND_LINE) + if (liberator.mode == liberator.modes.COMMAND_LINE) return; var win = window.document.commandDispatcher.focusedWindow; @@ -900,57 +900,57 @@ vimperator.Events = function () //{{{ if (elem && elem.readOnly) return; - // dump("=+++++++++=\n" + vimperator.util.objectToString(event.target) + "\n") + // dump("=+++++++++=\n" + liberator.util.objectToString(event.target) + "\n") // dump (elem + ": " + win + "\n");//" - target: " + event.target + " - origtarget: " + event.originalTarget + " - expltarget: " + event.explicitOriginalTarget + "\n"); if (elem && elem instanceof HTMLInputElement && (elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password")) { this.wantsModeReset = false; - vimperator.mode = vimperator.modes.INSERT; - vimperator.buffer.lastInputField = elem; + liberator.mode = liberator.modes.INSERT; + liberator.buffer.lastInputField = elem; return; } if (elem && elem instanceof HTMLTextAreaElement) { this.wantsModeReset = false; - if (vimperator.options["insertmode"]) - vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA); + if (liberator.options["insertmode"]) + liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA); else if (elem.selectionEnd - elem.selectionStart > 0) - vimperator.modes.set(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA); + liberator.modes.set(liberator.modes.VISUAL, liberator.modes.TEXTAREA); else - vimperator.modes.main = vimperator.modes.TEXTAREA; - vimperator.buffer.lastInputField = elem; + liberator.modes.main = liberator.modes.TEXTAREA; + liberator.buffer.lastInputField = elem; return; } - if (vimperator.config.name == "Muttator") + if (liberator.config.name == "Muttator") { // we switch to -- MESSAGE -- mode for muttator, when the main HTML widget gets focus if ((win && win.document && win.document instanceof HTMLDocument) || elem instanceof HTMLAnchorElement) { - if (vimperator.mode != vimperator.modes.MESSAGE) - vimperator.mode = vimperator.modes.MESSAGE; + if (liberator.mode != liberator.modes.MESSAGE) + liberator.mode = liberator.modes.MESSAGE; return; } } - if (vimperator.mode == vimperator.modes.INSERT || - vimperator.mode == vimperator.modes.TEXTAREA || - vimperator.mode == vimperator.modes.MESSAGE || - vimperator.mode == vimperator.modes.VISUAL) + if (liberator.mode == liberator.modes.INSERT || + liberator.mode == liberator.modes.TEXTAREA || + liberator.mode == liberator.modes.MESSAGE || + liberator.mode == liberator.modes.VISUAL) { // FIXME: currently this hack is disabled to make macros work // this.wantsModeReset = true; // setTimeout(function () // { - // dump("cur: " + vimperator.mode + "\n"); - // if (vimperator.events.wantsModeReset) + // dump("cur: " + liberator.mode + "\n"); + // if (liberator.events.wantsModeReset) // { - // vimperator.events.wantsModeReset = false; - vimperator.modes.reset(); + // liberator.events.wantsModeReset = false; + liberator.modes.reset(); // } // }, 0); } @@ -963,40 +963,40 @@ vimperator.Events = function () //{{{ if (controller && controller.isCommandEnabled("cmd_copy")) couldCopy = true; - if (vimperator.mode != vimperator.modes.VISUAL) + if (liberator.mode != liberator.modes.VISUAL) { if (couldCopy) { - if ((vimperator.mode == vimperator.modes.TEXTAREA || - (vimperator.modes.extended & vimperator.modes.TEXTAREA)) - && !vimperator.options["insertmode"]) - vimperator.modes.set(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA); - else if (vimperator.mode == vimperator.modes.CARET) - vimperator.modes.set(vimperator.modes.VISUAL, vimperator.modes.CARET); + if ((liberator.mode == liberator.modes.TEXTAREA || + (liberator.modes.extended & liberator.modes.TEXTAREA)) + && !liberator.options["insertmode"]) + liberator.modes.set(liberator.modes.VISUAL, liberator.modes.TEXTAREA); + else if (liberator.mode == liberator.modes.CARET) + liberator.modes.set(liberator.modes.VISUAL, liberator.modes.CARET); } } // XXX: disabled, as i think automatically starting visual caret mode does more harm than help // else // { - // if (!couldCopy && vimperator.modes.extended & vimperator.modes.CARET) - // vimperator.mode = vimperator.modes.CARET; + // if (!couldCopy && liberator.modes.extended & liberator.modes.CARET) + // liberator.mode = liberator.modes.CARET; // } }, // global escape handler, is called in ALL modes onEscape: function () { - if (!vimperator.modes.passNextKey) + if (!liberator.modes.passNextKey) { - if (vimperator.modes.passAllKeys) + if (liberator.modes.passAllKeys) { - vimperator.modes.passAllKeys = false; + liberator.modes.passAllKeys = false; return; } - switch (vimperator.mode) + switch (liberator.mode) { - case vimperator.modes.NORMAL: + case liberator.modes.NORMAL: // clear any selection made var selection = window.content.getSelection(); try @@ -1004,39 +1004,39 @@ vimperator.Events = function () //{{{ selection.collapseToStart(); } catch (e) { } - vimperator.commandline.clear(); + liberator.commandline.clear(); - vimperator.modes.reset(); - vimperator.focusContent(true); + liberator.modes.reset(); + liberator.focusContent(true); break; - case vimperator.modes.VISUAL: - if (vimperator.modes.extended & vimperator.modes.TEXTAREA) - vimperator.mode = vimperator.modes.TEXTAREA; - else if (vimperator.modes.extended & vimperator.modes.CARET) - vimperator.mode = vimperator.modes.CARET; + case liberator.modes.VISUAL: + if (liberator.modes.extended & liberator.modes.TEXTAREA) + liberator.mode = liberator.modes.TEXTAREA; + else if (liberator.modes.extended & liberator.modes.CARET) + liberator.mode = liberator.modes.CARET; break; - case vimperator.modes.CARET: + case liberator.modes.CARET: // setting this option will trigger an observer which will // care about all other details like setting the NORMAL mode - vimperator.options.setPref("accessibility.browsewithcaret", false); + liberator.options.setPref("accessibility.browsewithcaret", false); break; - case vimperator.modes.INSERT: - if ((vimperator.modes.extended & vimperator.modes.TEXTAREA) && !vimperator.options["insertmode"]) + case liberator.modes.INSERT: + if ((liberator.modes.extended & liberator.modes.TEXTAREA) && !liberator.options["insertmode"]) { - vimperator.mode = vimperator.modes.TEXTAREA; + liberator.mode = liberator.modes.TEXTAREA; } else { - vimperator.modes.reset(); - vimperator.focusContent(true); + liberator.modes.reset(); + liberator.focusContent(true); } break; default: // HINTS, CUSTOM or COMMAND_LINE - vimperator.modes.reset(); + liberator.modes.reset(); break; } } @@ -1046,23 +1046,23 @@ vimperator.Events = function () //{{{ // the commandline has focus onKeyPress: function (event) { - var key = vimperator.events.toString(event); + var key = liberator.events.toString(event); if (!key) return true; - // dump(key + " in mode: " + vimperator.mode + "\n"); + // dump(key + " in mode: " + liberator.mode + "\n"); - if (vimperator.modes.isRecording) + if (liberator.modes.isRecording) { if (key == "q") // TODO: should not be hardcoded { - vimperator.modes.isRecording = false; - vimperator.log("Recorded " + currentMacro + ": " + macros[currentMacro], 8); + liberator.modes.isRecording = false; + liberator.log("Recorded " + currentMacro + ": " + macros[currentMacro], 8); event.preventDefault(); event.stopPropagation(); return true; } - else if (!(vimperator.modes.extended & vimperator.modes.INACTIVE_HINT) && - !vimperator.mappings.hasMap(vimperator.mode, vimperator.input.buffer + key)) + else if (!(liberator.modes.extended & liberator.modes.INACTIVE_HINT) && + !liberator.mappings.hasMap(liberator.mode, liberator.input.buffer + key)) { macros[currentMacro] += key; } @@ -1075,20 +1075,20 @@ vimperator.Events = function () //{{{ return false; // menus have their own command handlers - if (vimperator.modes.extended & vimperator.modes.MENU) + if (liberator.modes.extended & liberator.modes.MENU) return false; // handle Escape-one-key mode (Ctrl-v) - if (vimperator.modes.passNextKey && !vimperator.modes.passAllKeys) + if (liberator.modes.passNextKey && !liberator.modes.passAllKeys) { - vimperator.modes.passNextKey = false; + liberator.modes.passNextKey = false; return false; } // handle Escape-all-keys mode (Ctrl-q) - if (vimperator.modes.passAllKeys) + if (liberator.modes.passAllKeys) { - if (vimperator.modes.passNextKey) - vimperator.modes.passNextKey = false; // and then let flow continue + if (liberator.modes.passNextKey) + liberator.modes.passNextKey = false; // and then let flow continue else if (key == "" || key == "" || key == "") ; // let flow continue to handle these keys to cancel escape-all-keys mode else @@ -1096,10 +1096,10 @@ vimperator.Events = function () //{{{ } // just forward event without checking any mappings when the MOW is open - if (vimperator.mode == vimperator.modes.COMMAND_LINE && - (vimperator.modes.extended & vimperator.modes.OUTPUT_MULTILINE)) + if (liberator.mode == liberator.modes.COMMAND_LINE && + (liberator.modes.extended & liberator.modes.OUTPUT_MULTILINE)) { - vimperator.commandline.onMultilineOutputEvent(event); + liberator.commandline.onMultilineOutputEvent(event); event.preventDefault(); event.stopPropagation(); return false; @@ -1108,15 +1108,15 @@ vimperator.Events = function () //{{{ // XXX: ugly hack for now pass certain keys to firefox as they are without beeping // also fixes key navigation in combo boxes, submitting forms, etc. // FIXME: breaks iabbr for now --mst - if ((vimperator.config.name == "Vimperator" && vimperator.mode == vimperator.modes.NORMAL) - || vimperator.mode == vimperator.modes.INSERT) + if ((liberator.config.name == "Vimperator" && liberator.mode == liberator.modes.NORMAL) + || liberator.mode == liberator.modes.INSERT) { if (key == "") { - if (vimperator.modes.isReplaying) + if (liberator.modes.isReplaying) { // TODO: how to really submit the correct form? - vimperator.modes.reset(); + liberator.modes.reset(); content.document.forms[0].submit(); waitForPageLoaded(); dump("before return\n"); @@ -1155,17 +1155,17 @@ vimperator.Events = function () //{{{ if (key != "" && key != "") { // custom mode... - if (vimperator.mode == vimperator.modes.CUSTOM) + if (liberator.mode == liberator.modes.CUSTOM) { - vimperator.plugins.onEvent(event); + liberator.plugins.onEvent(event); event.preventDefault(); event.stopPropagation(); return false; } // if Hit-a-hint mode is on, special handling of keys is required - if (vimperator.mode == vimperator.modes.HINTS) + if (liberator.mode == liberator.modes.HINTS) { - vimperator.hints.onEvent(event); + liberator.hints.onEvent(event); event.preventDefault(); event.stopPropagation(); return false; @@ -1179,103 +1179,103 @@ vimperator.Events = function () //{{{ // whatever reason). if that happens to be correct, well.. // XXX: why not just do that as well for HINTS mode actually? - if (vimperator.mode == vimperator.modes.CUSTOM) + if (liberator.mode == liberator.modes.CUSTOM) return true; - var countStr = vimperator.input.buffer.match(/^[0-9]*/)[0]; - var candidateCommand = (vimperator.input.buffer + key).replace(countStr, ""); + var countStr = liberator.input.buffer.match(/^[0-9]*/)[0]; + var candidateCommand = (liberator.input.buffer + key).replace(countStr, ""); var map; if (event.noremap) - map = vimperator.mappings.getDefault(vimperator.mode, candidateCommand); + map = liberator.mappings.getDefault(liberator.mode, candidateCommand); else - map = vimperator.mappings.get(vimperator.mode, candidateCommand); + map = liberator.mappings.get(liberator.mode, candidateCommand); // counts must be at the start of a complete mapping (10j -> go 10 lines down) - if (/^[1-9][0-9]*$/.test(vimperator.input.buffer + key)) + if (/^[1-9][0-9]*$/.test(liberator.input.buffer + key)) { // no count for insert mode mappings - if (vimperator.mode == vimperator.modes.INSERT || vimperator.mode == vimperator.modes.COMMAND_LINE) + if (liberator.mode == liberator.modes.INSERT || liberator.mode == liberator.modes.COMMAND_LINE) stop = false; else { - vimperator.input.buffer += key; + liberator.input.buffer += key; inputBufferLength++; } } - else if (vimperator.input.pendingArgMap) + else if (liberator.input.pendingArgMap) { - vimperator.input.buffer = ""; + liberator.input.buffer = ""; inputBufferLength = 0; - var tmp = vimperator.input.pendingArgMap; // must be set to null before .execute; if not - vimperator.input.pendingArgMap = null; // v.input.pendingArgMap is still 'true' also for new feeded keys + var tmp = liberator.input.pendingArgMap; // must be set to null before .execute; if not + liberator.input.pendingArgMap = null; // v.input.pendingArgMap is still 'true' also for new feeded keys if (key != "" && key != "") { - if (vimperator.modes.isReplaying && !waitForPageLoaded()) + if (liberator.modes.isReplaying && !waitForPageLoaded()) return true; - tmp.execute(null, vimperator.input.count, key); + tmp.execute(null, liberator.input.count, key); } } // only follow a map if there isn't a longer possible mapping // (allows you to do :map z yy, when zz is a longer mapping than z) // TODO: map.rhs is only defined for user defined commands, should add a "isDefault" property else if (map && !skipMap && (map.rhs || - vimperator.mappings.getCandidates(vimperator.mode, candidateCommand).length == 0)) + liberator.mappings.getCandidates(liberator.mode, candidateCommand).length == 0)) { - vimperator.input.count = parseInt(countStr, 10); - if (isNaN(vimperator.input.count)) - vimperator.input.count = -1; - if (map.flags & vimperator.Mappings.flags.ARGUMENT) + liberator.input.count = parseInt(countStr, 10); + if (isNaN(liberator.input.count)) + liberator.input.count = -1; + if (map.flags & liberator.Mappings.flags.ARGUMENT) { - vimperator.input.pendingArgMap = map; - vimperator.input.buffer += key; + liberator.input.pendingArgMap = map; + liberator.input.buffer += key; inputBufferLength++; } - else if (vimperator.input.pendingMotionMap) + else if (liberator.input.pendingMotionMap) { if (key != "" && key != "") { - vimperator.input.pendingMotionMap.execute(candidateCommand, vimperator.input.count, null); + liberator.input.pendingMotionMap.execute(candidateCommand, liberator.input.count, null); } - vimperator.input.pendingMotionMap = null; - vimperator.input.buffer = ""; + liberator.input.pendingMotionMap = null; + liberator.input.buffer = ""; inputBufferLength = 0; } // no count support for these commands yet - else if (map.flags & vimperator.Mappings.flags.MOTION) + else if (map.flags & liberator.Mappings.flags.MOTION) { - vimperator.input.pendingMotionMap = map; - vimperator.input.buffer = ""; + liberator.input.pendingMotionMap = map; + liberator.input.buffer = ""; inputBufferLength = 0; } else { - vimperator.input.buffer = ""; + liberator.input.buffer = ""; inputBufferLength = 0; - if (vimperator.modes.isReplaying && !waitForPageLoaded()) + if (liberator.modes.isReplaying && !waitForPageLoaded()) return true; - var ret = map.execute(null, vimperator.input.count); - if (map.flags & vimperator.Mappings.flags.ALLOW_EVENT_ROUTING && ret) + var ret = map.execute(null, liberator.input.count); + if (map.flags & liberator.Mappings.flags.ALLOW_EVENT_ROUTING && ret) stop = false; } } - else if (vimperator.mappings.getCandidates(vimperator.mode, candidateCommand).length > 0 && !skipMap) + else if (liberator.mappings.getCandidates(liberator.mode, candidateCommand).length > 0 && !skipMap) { - vimperator.input.buffer += key; + liberator.input.buffer += key; inputBufferLength++; } else // if the key is neither a mapping nor the start of one { // the mode checking is necessary so that things like g do not beep - if (vimperator.input.buffer != "" && !skipMap && (vimperator.mode == vimperator.modes.INSERT || - vimperator.mode == vimperator.modes.COMMAND_LINE || vimperator.mode == vimperator.modes.TEXTAREA)) + if (liberator.input.buffer != "" && !skipMap && (liberator.mode == liberator.modes.INSERT || + liberator.mode == liberator.modes.COMMAND_LINE || liberator.mode == liberator.modes.TEXTAREA)) { // no map found -> refeed stuff in v.input.buffer (only while in INSERT, CO... modes) skipMap = true; // ignore maps while doing so - vimperator.events.feedkeys(vimperator.input.buffer, true); + liberator.events.feedkeys(liberator.input.buffer, true); } if (skipMap) { @@ -1283,22 +1283,22 @@ vimperator.Events = function () //{{{ skipMap = false; // done... } - vimperator.input.buffer = ""; - vimperator.input.pendingArgMap = null; - vimperator.input.pendingMotionMap = null; + liberator.input.buffer = ""; + liberator.input.pendingArgMap = null; + liberator.input.pendingMotionMap = null; if (key != "" && key != "") { // allow key to be passed to firefox if we can't handle it stop = false; - if (vimperator.mode == vimperator.modes.COMMAND_LINE) + if (liberator.mode == liberator.modes.COMMAND_LINE) { - if (!(vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE)) - stop = !vimperator.commandline.onEvent(event); // reroute event in command line mode + if (!(liberator.modes.extended & liberator.modes.INPUT_MULTILINE)) + stop = !liberator.commandline.onEvent(event); // reroute event in command line mode } - else if (vimperator.mode != vimperator.modes.INSERT) - vimperator.beep(); + else if (liberator.mode != liberator.modes.INSERT) + liberator.beep(); } } @@ -1308,15 +1308,15 @@ vimperator.Events = function () //{{{ event.stopPropagation(); } - var motionMap = (vimperator.input.pendingMotionMap && vimperator.input.pendingMotionMap.names[0]) || ""; - vimperator.statusline.updateInputBuffer(motionMap + vimperator.input.buffer); + var motionMap = (liberator.input.pendingMotionMap && liberator.input.pendingMotionMap.names[0]) || ""; + liberator.statusline.updateInputBuffer(motionMap + liberator.input.buffer); return false; }, // this is need for sites like msn.com which focus the input field on keydown onKeyUpOrDown: function (event) { - if (vimperator.modes.passNextKey ^ vimperator.modes.passAllKeys || isFormElemFocused()) + if (liberator.modes.passNextKey ^ liberator.modes.passAllKeys || isFormElemFocused()) return true; event.stopPropagation(); @@ -1347,15 +1347,15 @@ vimperator.Events = function () //{{{ // only thrown for the current tab, not when another tab changes if (flags & Components.interfaces.nsIWebProgressListener.STATE_START) { - vimperator.buffer.loaded = 0; - vimperator.statusline.updateProgress(0); - setTimeout (function () { vimperator.modes.reset(false); }, - vimperator.mode == vimperator.modes.HINTS ? 500 : 0); + liberator.buffer.loaded = 0; + liberator.statusline.updateProgress(0); + setTimeout (function () { liberator.modes.reset(false); }, + liberator.mode == liberator.modes.HINTS ? 500 : 0); } else if (flags & Components.interfaces.nsIWebProgressListener.STATE_STOP) { - vimperator.buffer.loaded = (status == 0 ? 1 : 2); - vimperator.statusline.updateUrl(); + liberator.buffer.loaded = (status == 0 ? 1 : 2); + liberator.statusline.updateUrl(); } } }, @@ -1364,51 +1364,51 @@ vimperator.Events = function () //{{{ { const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; if (aState & nsIWebProgressListener.STATE_IS_INSECURE) - vimperator.statusline.setClass("insecure"); + liberator.statusline.setClass("insecure"); else if (aState & nsIWebProgressListener.STATE_IS_BROKEN) - vimperator.statusline.setClass("broken"); + liberator.statusline.setClass("broken"); else if (aState & nsIWebProgressListener.STATE_IS_SECURE) - vimperator.statusline.setClass("secure"); + liberator.statusline.setClass("secure"); }, onStatusChange: function (webProgress, request, status, message) { - vimperator.statusline.updateUrl(message); + liberator.statusline.updateUrl(message); }, onProgressChange: function (webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) { - vimperator.statusline.updateProgress(curTotalProgress/maxTotalProgress); + liberator.statusline.updateProgress(curTotalProgress/maxTotalProgress); }, // happens when the users switches tabs onLocationChange: function () { - vimperator.statusline.updateUrl(); - vimperator.statusline.updateProgress(); + liberator.statusline.updateUrl(); + liberator.statusline.updateProgress(); // if this is not delayed we get the position of the old buffer - setTimeout(function () { vimperator.statusline.updateBufferPosition(); }, 100); + setTimeout(function () { liberator.statusline.updateBufferPosition(); }, 100); }, // called at the very end of a page load asyncUpdateUI: function () { - setTimeout(vimperator.statusline.updateUrl, 100); + setTimeout(liberator.statusline.updateUrl, 100); }, setOverLink : function (link, b) { - var ssli = vimperator.options["showstatuslinks"]; + var ssli = liberator.options["showstatuslinks"]; if (link && ssli) { if (ssli == 1) - vimperator.statusline.updateUrl("Link: " + link); + liberator.statusline.updateUrl("Link: " + link); else if (ssli == 2) - vimperator.echo("Link: " + link, vimperator.commandline.DISALLOW_MULTILINE); + liberator.echo("Link: " + link, liberator.commandline.DISALLOW_MULTILINE); } if (link == "") { if (ssli == 1) - vimperator.statusline.updateUrl(); + liberator.statusline.updateUrl(); else if (ssli == 2) - vimperator.modes.show(); + liberator.modes.show(); } }, @@ -1446,8 +1446,8 @@ vimperator.Events = function () //{{{ switch (aData) { case "accessibility.browsewithcaret": - var value = vimperator.options.getPref("accessibility.browsewithcaret", false); - vimperator.mode = value ? vimperator.modes.CARET : vimperator.modes.NORMAL; + var value = liberator.options.getPref("accessibility.browsewithcaret", false); + liberator.mode = value ? liberator.modes.CARET : liberator.modes.NORMAL; break; } } diff --git a/content/find.js b/content/find.js index 7ac08653..ece8c8ba 100644 --- a/content/find.js +++ b/content/find.js @@ -36,15 +36,15 @@ the terms of any one of the MPL, the GPL or the LGPL. // : changing any search settings should also update the search state including highlighting // : incremental searches shouldn't permanently update search modifiers -// make sure you only create this object when the "vimperator" object is ready -vimperator.Search = function () //{{{ +// make sure you only create this object when the "liberator" object is ready +liberator.Search = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ // FIXME: - //var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback + //var self = this; // needed for callbacks since "this" is the "liberator" object in a callback var found = false; // true if the last search was successful var backwards = false; // currently searching backwards var searchString = ""; // current search string (without modifiers) @@ -56,13 +56,13 @@ vimperator.Search = function () //{{{ var linksOnly = false; // search is limited to link text only // Event handlers for search - closure is needed - vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchKeyPressed(command); }); - vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchSubmitted(command); }); - vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function () { vimperator.search.searchCanceled(); }); + liberator.registerCallback("change", liberator.modes.SEARCH_FORWARD, function (command) { liberator.search.searchKeyPressed(command); }); + liberator.registerCallback("submit", liberator.modes.SEARCH_FORWARD, function (command) { liberator.search.searchSubmitted(command); }); + liberator.registerCallback("cancel", liberator.modes.SEARCH_FORWARD, function () { liberator.search.searchCanceled(); }); // TODO: allow advanced modes in register/triggerCallback - vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchKeyPressed(command); }); - vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchSubmitted(command); }); - vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { vimperator.search.searchCanceled(); }); + liberator.registerCallback("change", liberator.modes.SEARCH_BACKWARD, function (command) { liberator.search.searchKeyPressed(command); }); + liberator.registerCallback("submit", liberator.modes.SEARCH_BACKWARD, function (command) { liberator.search.searchSubmitted(command); }); + liberator.registerCallback("cancel", liberator.modes.SEARCH_BACKWARD, function () { liberator.search.searchCanceled(); }); // set searchString, searchPattern, caseSensitive, linksOnly function processUserPattern(pattern) @@ -80,7 +80,7 @@ vimperator.Search = function () //{{{ linksOnly = false; else if (/\L/.test(pattern)) linksOnly = true; - else if (vimperator.options["linksearch"]) + else if (liberator.options["linksearch"]) linksOnly = true; else linksOnly = false; @@ -93,9 +93,9 @@ vimperator.Search = function () //{{{ caseSensitive = false; else if (/\C/.test(pattern)) caseSensitive = true; - else if (vimperator.options["ignorecase"] && vimperator.options["smartcase"] && /[A-Z]/.test(pattern)) + else if (liberator.options["ignorecase"] && liberator.options["smartcase"] && /[A-Z]/.test(pattern)) caseSensitive = true; - else if (vimperator.options["ignorecase"]) + else if (liberator.options["ignorecase"]) caseSensitive = false; else caseSensitive = true; @@ -113,36 +113,36 @@ vimperator.Search = function () //{{{ ////////////////////// OPTIONS ///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.options.add(["hlsearch", "hls"], + liberator.options.add(["hlsearch", "hls"], "Highlight previous search pattern matches", "boolean", "false", { setter: function (value) { if (value) - vimperator.search.highlight(); + liberator.search.highlight(); else - vimperator.search.clear(); + liberator.search.clear(); } }); - vimperator.options.add(["hlsearchstyle", "hlss"], + liberator.options.add(["hlsearchstyle", "hlss"], "CSS specification of highlighted search items", "string", "color: black; background-color: yellow; padding: 0; display: inline;"); - vimperator.options.add(["ignorecase", "ic"], + liberator.options.add(["ignorecase", "ic"], "Ignore case in search patterns", "boolean", true); - vimperator.options.add(["incsearch", "is"], + liberator.options.add(["incsearch", "is"], "Show where the search pattern matches as it is typed", "boolean", true); - vimperator.options.add(["linksearch", "lks"], + liberator.options.add(["linksearch", "lks"], "Limit the search to hyperlink text", "boolean", false); - vimperator.options.add(["smartcase", "scs"], + liberator.options.add(["smartcase", "scs"], "Override the 'ignorecase' option if the pattern contains uppercase characters", "boolean", true); @@ -150,48 +150,48 @@ vimperator.Search = function () //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL]; - modes = modes.concat([vimperator.modes.CARET]); + var modes = liberator.config.browserModes || [liberator.modes.NORMAL]; + modes = modes.concat([liberator.modes.CARET]); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["/"], "Search forward for a pattern", - function () { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_FORWARD); }); + function () { liberator.search.openSearchDialog(liberator.modes.SEARCH_FORWARD); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["?"], "Search backwards for a pattern", - function () { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_BACKWARD); }); + function () { liberator.search.openSearchDialog(liberator.modes.SEARCH_BACKWARD); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["n"], "Find next", - function () { vimperator.search.findAgain(false); }); + function () { liberator.search.findAgain(false); }); - vimperator.mappings.add(modes, + liberator.mappings.add(modes, ["N"], "Find previous", - function () { vimperator.search.findAgain(true); }); + function () { liberator.search.findAgain(true); }); - vimperator.mappings.add(modes.concat([vimperator.modes.CARET, vimperator.modes.TEXTAREA]), ["*"], + liberator.mappings.add(modes.concat([liberator.modes.CARET, liberator.modes.TEXTAREA]), ["*"], "Find word under cursor", function () { - vimperator.search.searchSubmitted(vimperator.buffer.getCurrentWord(), false); - vimperator.search.findAgain(); + liberator.search.searchSubmitted(liberator.buffer.getCurrentWord(), false); + liberator.search.findAgain(); }); - vimperator.mappings.add(modes.concat([vimperator.modes.CARET, vimperator.modes.TEXTAREA]), ["#"], + liberator.mappings.add(modes.concat([liberator.modes.CARET, liberator.modes.TEXTAREA]), ["#"], "Find word under cursor backwards", function () { - vimperator.search.searchSubmitted(vimperator.buffer.getCurrentWord(), true); - vimperator.search.findAgain(); + liberator.search.searchSubmitted(liberator.buffer.getCurrentWord(), true); + liberator.search.findAgain(); }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["noh[lsearch]"], + liberator.commands.add(["noh[lsearch]"], "Remove the search highlighting", - function (args) { vimperator.search.clear(); }); + function (args) { liberator.search.clear(); }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// @@ -203,14 +203,14 @@ vimperator.Search = function () //{{{ // If you omit "mode", it will default to forward searching openSearchDialog: function (mode) { - if (mode == vimperator.modes.SEARCH_BACKWARD) + if (mode == liberator.modes.SEARCH_BACKWARD) { - vimperator.commandline.open("?", "", vimperator.modes.SEARCH_BACKWARD); + liberator.commandline.open("?", "", liberator.modes.SEARCH_BACKWARD); backwards = true; } else { - vimperator.commandline.open("/", "", vimperator.modes.SEARCH_FORWARD); + liberator.commandline.open("/", "", liberator.modes.SEARCH_FORWARD); backwards = false; } @@ -229,7 +229,7 @@ vimperator.Search = function () //{{{ found = fastFind.find(searchString, linksOnly) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND; if (!found) - setTimeout(function () { vimperator.echoerr("E486: Pattern not found: " + searchPattern); }, 0); + setTimeout(function () { liberator.echoerr("E486: Pattern not found: " + searchPattern); }, 0); return found; }, @@ -248,7 +248,7 @@ vimperator.Search = function () //{{{ if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND) { - vimperator.echoerr("E486: Pattern not found: " + lastSearchPattern); + liberator.echoerr("E486: Pattern not found: " + lastSearchPattern); } else if (result == Components.interfaces.nsITypeAheadFind.FIND_WRAPPED) { @@ -256,16 +256,16 @@ vimperator.Search = function () //{{{ // our command line setTimeout(function () { if (up) - vimperator.commandline.echo("search hit TOP, continuing at BOTTOM", vimperator.commandline.HL_WARNING); + liberator.commandline.echo("search hit TOP, continuing at BOTTOM", liberator.commandline.HL_WARNING); else - vimperator.commandline.echo("search hit BOTTOM, continuing at TOP", vimperator.commandline.HL_WARNING); + liberator.commandline.echo("search hit BOTTOM, continuing at TOP", liberator.commandline.HL_WARNING); }, 0); } else { - vimperator.echo((up ? "?" : "/") + lastSearchPattern, null, vimperator.commandline.FORCE_SINGLELINE); + liberator.echo((up ? "?" : "/") + lastSearchPattern, null, liberator.commandline.FORCE_SINGLELINE); - if (vimperator.options["hlsearch"]) + if (liberator.options["hlsearch"]) this.highlight(lastSearchString); } }, @@ -273,7 +273,7 @@ vimperator.Search = function () //{{{ // Called when the user types a key in the search dialog. Triggers a find attempt if 'incsearch' is set searchKeyPressed: function (command) { - if (vimperator.options["incsearch"]) + if (liberator.options["incsearch"]) this.find(command, backwards); }, @@ -298,12 +298,12 @@ 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 () { vimperator.search.findAgain(false); }, 0); + setTimeout(function () { liberator.search.findAgain(false); }, 0); - if (vimperator.options["hlsearch"]) + if (liberator.options["hlsearch"]) this.highlight(searchString); - vimperator.modes.reset(); + liberator.modes.reset(); }, // Called when the search is canceled - for example if someone presses @@ -318,7 +318,7 @@ vimperator.Search = function () //{{{ // this is not dependent on the value of 'hlsearch' highlight: function (text) { - if (vimperator.config.name == "Muttator") + if (liberator.config.name == "Muttator") return; // already highlighted? @@ -338,7 +338,7 @@ vimperator.Search = function () //{{{ arguments.callee(win.frames[i]); var spans = window.content.document.getElementsByClassName("__mozilla-findbar-search"); for (var i = 0; i < spans.length; i++) - spans[i].setAttribute("style", vimperator.options["hlsearchstyle"]); + spans[i].setAttribute("style", liberator.options["hlsearchstyle"]); })(window.content); // recreate selection since _highlightDoc collapses the selection backwards diff --git a/content/hints.js b/content/hints.js index e90ba520..cc633eee 100644 --- a/content/hints.js +++ b/content/hints.js @@ -26,12 +26,12 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ -vimperator.Hints = function () //{{{ +liberator.Hints = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL]; + var modes = liberator.config.browserModes || [liberator.modes.NORMAL]; var submode = ""; // used for extended mode, can be "o", "t", "y", etc. var hintString = ""; // the typed string part of the hint is in this string @@ -53,7 +53,7 @@ vimperator.Hints = function () //{{{ // reset all important variables function reset() { - vimperator.statusline.updateInputBuffer(""); + liberator.statusline.updateInputBuffer(""); hintString = ""; hintNumber = 0; usedTabKey = false; @@ -70,7 +70,7 @@ vimperator.Hints = function () //{{{ function updateStatusline() { - vimperator.statusline.updateInputBuffer((escapeNumbers ? vimperator.events.getMapLeader() + " ": "") + // sign for escapeNumbers + liberator.statusline.updateInputBuffer((escapeNumbers ? liberator.events.getMapLeader() + " ": "") + // sign for escapeNumbers (hintString ? "\"" + hintString + "\"" : "") + (hintNumber > 0 ? " <" + hintNumber + ">" : "")); } @@ -98,11 +98,11 @@ vimperator.Hints = function () //{{{ baseNodeAbsolute.style.padding = "0px 1px 0px 0px"; baseNodeAbsolute.style.zIndex = "10000001"; baseNodeAbsolute.style.display = "none"; - baseNodeAbsolute.className = "vimperator-hint"; + baseNodeAbsolute.className = "liberator-hint"; var elem, tagname, text, span, rect; - var res = vimperator.buffer.evaluateXPath(vimperator.options["hinttags"], doc, null, true); - vimperator.log("evaluated XPath after: " + (Date.now() - startDate) + "ms"); + var res = liberator.buffer.evaluateXPath(liberator.options["hinttags"], doc, null, true); + liberator.log("evaluated XPath after: " + (Date.now() - startDate) + "ms"); var fragment = doc.createDocumentFragment(); var start = hints.length; @@ -146,7 +146,7 @@ vimperator.Hints = function () //{{{ for (var i = 0; i < win.frames.length; i++) generate(win.frames[i]); - vimperator.log("hints.generate() completed after: " + (Date.now() - startDate) + "ms for " + hints.length + " hints."); + liberator.log("hints.generate() completed after: " + (Date.now() - startDate) + "ms for " + hints.length + " hints."); return true; } @@ -169,7 +169,7 @@ vimperator.Hints = function () //{{{ var height = win.innerHeight; var width = win.innerWidth; - vimperator.log("Show hints matching: " + hintString, 7); + liberator.log("Show hints matching: " + hintString, 7); var elem, tagname, text, rect, span, imgspan; var hintnum = 1; @@ -224,7 +224,7 @@ vimperator.Hints = function () //{{{ imgspan.style.top = (rect.top + scrollY) + "px"; imgspan.style.width = (rect.right - rect.left) + "px"; imgspan.style.height = (rect.bottom - rect.top) + "px"; - imgspan.className = "vimperator-hint"; + imgspan.className = "liberator-hint"; hints[i][3] = imgspan; doc.body.appendChild(imgspan); } @@ -241,7 +241,7 @@ vimperator.Hints = function () //{{{ } } - vimperator.log("showHints() completed after: " + (Date.now() - startDate) + "ms"); + liberator.log("showHints() completed after: " + (Date.now() - startDate) + "ms"); return true; } @@ -311,7 +311,7 @@ vimperator.Hints = function () //{{{ } } - vimperator.log("removeHints() done"); + liberator.log("removeHints() done"); reset(); } @@ -319,7 +319,7 @@ vimperator.Hints = function () //{{{ { if (validHints.length == 0) { - vimperator.beep(); + liberator.beep(); return false; } @@ -342,49 +342,49 @@ vimperator.Hints = function () //{{{ switch (submode) { // TODO: move/rename those helper functions to a better place - case ";": vimperator.buffer.focusElement(elem); break; - case "?": vimperator.buffer.showElementInfo(elem); break; - case "a": vimperator.buffer.saveLink(elem, false); break; - case "s": vimperator.buffer.saveLink(elem, true); break; - case "o": vimperator.buffer.followLink(elem, vimperator.CURRENT_TAB); break; - case "O": vimperator.commandline.open(":", "open " + loc, vimperator.modes.EX); break; - case "t": vimperator.buffer.followLink(elem, vimperator.NEW_TAB); break; - case "T": vimperator.commandline.open(":", "tabopen " + loc, vimperator.modes.EX); break; - case "v": vimperator.buffer.viewSource(loc, false); break; - case "V": vimperator.buffer.viewSource(loc, true); break; - case "w": vimperator.buffer.followLink(elem, vimperator.NEW_WINDOW); break; - case "W": vimperator.commandline.open(":", "winopen " + loc, vimperator.modes.EX); break; - case "y": setTimeout(function(){vimperator.copyToClipboard(loc, true)}, timeout + 50); break; - case "Y": setTimeout(function(){vimperator.copyToClipboard(elem.textContent || "", true)}, timeout + 50); break; + case ";": liberator.buffer.focusElement(elem); break; + case "?": liberator.buffer.showElementInfo(elem); break; + case "a": liberator.buffer.saveLink(elem, false); break; + case "s": liberator.buffer.saveLink(elem, true); break; + case "o": liberator.buffer.followLink(elem, liberator.CURRENT_TAB); break; + case "O": liberator.commandline.open(":", "open " + loc, liberator.modes.EX); break; + case "t": liberator.buffer.followLink(elem, liberator.NEW_TAB); break; + case "T": liberator.commandline.open(":", "tabopen " + loc, liberator.modes.EX); break; + case "v": liberator.buffer.viewSource(loc, false); break; + case "V": liberator.buffer.viewSource(loc, true); break; + case "w": liberator.buffer.followLink(elem, liberator.NEW_WINDOW); break; + case "W": liberator.commandline.open(":", "winopen " + loc, liberator.modes.EX); break; + case "y": setTimeout(function(){liberator.copyToClipboard(loc, true)}, timeout + 50); break; + case "Y": setTimeout(function(){liberator.copyToClipboard(elem.textContent || "", true)}, timeout + 50); break; default: - vimperator.echoerr("INTERNAL ERROR: unknown submode: " + submode); + liberator.echoerr("INTERNAL ERROR: unknown submode: " + submode); } removeHints(timeout); - if (vimperator.modes.extended & vimperator.modes.ALWAYS_HINT) + if (liberator.modes.extended & liberator.modes.ALWAYS_HINT) { setTimeout(function () { canUpdate = true; hintString = ""; hintNumber = 0; - vimperator.statusline.updateInputBuffer(""); + liberator.statusline.updateInputBuffer(""); }, timeout); } else { - if (timeout == 0 || vimperator.modes.isReplaying) + if (timeout == 0 || liberator.modes.isReplaying) { // force a possible mode change, based on wheter an input field has focus - vimperator.events.onFocusChange(); - if (vimperator.mode == vimperator.modes.HINTS) - vimperator.modes.reset(false); + liberator.events.onFocusChange(); + if (liberator.mode == liberator.modes.HINTS) + liberator.modes.reset(false); } else { - vimperator.modes.add(vimperator.modes.INACTIVE_HINT); + liberator.modes.add(liberator.modes.INACTIVE_HINT); setTimeout(function () { - if (vimperator.mode == vimperator.modes.HINTS) - vimperator.modes.reset(false); + if (liberator.mode == liberator.modes.HINTS) + liberator.modes.reset(false); }, timeout); } } @@ -401,19 +401,19 @@ vimperator.Hints = function () //{{{ "//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"; - vimperator.options.add(["extendedhinttags", "eht"], + liberator.options.add(["extendedhinttags", "eht"], "XPath string of hintable elements activated by ';'", "string", DEFAULT_HINTTAGS); - vimperator.options.add(["focusedhintstyle", "fhs"], + liberator.options.add(["focusedhintstyle", "fhs"], "CSS specification of focused hints", "string", "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;"); - vimperator.options.add(["hintstyle", "hs"], + liberator.options.add(["hintstyle", "hs"], "CSS specification of unfocused hints", "string", "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;"); - vimperator.options.add(["hinttags", "ht"], + liberator.options.add(["hinttags", "ht"], "XPath string of hintable elements activated by 'f' and 'F'", "string", DEFAULT_HINTTAGS); - vimperator.options.add(["hinttimeout", "hto"], + liberator.options.add(["hinttimeout", "hto"], "Automatically follow non unique numerical hint", "number", 0, { @@ -424,26 +424,26 @@ vimperator.Hints = function () //{{{ ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.mappings.add(modes, ["f"], + liberator.mappings.add(modes, ["f"], "Start QuickHint mode", - function () { vimperator.hints.show(vimperator.modes.QUICK_HINT); }); + function () { liberator.hints.show(liberator.modes.QUICK_HINT); }); - vimperator.mappings.add(modes, ["F"], + liberator.mappings.add(modes, ["F"], "Start QuickHint mode, but open link in a new tab", - function () { vimperator.hints.show(vimperator.modes.QUICK_HINT, "t"); }); + function () { liberator.hints.show(liberator.modes.QUICK_HINT, "t"); }); - vimperator.mappings.add(modes, [";"], + liberator.mappings.add(modes, [";"], "Start an extended hint mode", function (arg) { if (arg == "f") - vimperator.hints.show(vimperator.modes.ALWAYS_HINT, "o"); + liberator.hints.show(liberator.modes.ALWAYS_HINT, "o"); else if (arg == "F") - vimperator.hints.show(vimperator.modes.ALWAYS_HINT, "t"); + liberator.hints.show(liberator.modes.ALWAYS_HINT, "t"); else - vimperator.hints.show(vimperator.modes.EXTENDED_HINT, arg); + liberator.hints.show(liberator.modes.EXTENDED_HINT, arg); }, - { flags: vimperator.Mappings.flags.ARGUMENT }); + { flags: liberator.Mappings.flags.ARGUMENT }); /////////////////////////////////////////////////////////////////////////////}}} @@ -455,13 +455,13 @@ vimperator.Hints = function () //{{{ // TODO: implement framesets show: function (mode, minor, filter) { - if (mode == vimperator.modes.EXTENDED_HINT && !/^[;?asoOtTvVwWyY]$/.test(minor)) + if (mode == liberator.modes.EXTENDED_HINT && !/^[;?asoOtTvVwWyY]$/.test(minor)) { - vimperator.beep(); + liberator.beep(); return; } - vimperator.modes.set(vimperator.modes.HINTS, mode); + liberator.modes.set(liberator.modes.HINTS, mode); submode = minor || "o"; // open is the default mode hintString = filter || ""; hintNumber = 0; @@ -479,8 +479,8 @@ vimperator.Hints = function () //{{{ if (validHints.length == 0) { - vimperator.beep(); - vimperator.modes.reset(); + liberator.beep(); + liberator.modes.reset(); return false; } else if (validHints.length == 1) @@ -499,7 +499,7 @@ vimperator.Hints = function () //{{{ onEvent: function (event) { - var key = vimperator.events.toString(event); + var key = liberator.events.toString(event); var followFirst = false; // clear any timeout which might be active after pressing a number @@ -555,7 +555,7 @@ vimperator.Hints = function () //{{{ { usedTabKey = false; hintNumber = 0; - vimperator.beep(); + liberator.beep(); return; } break; @@ -566,7 +566,7 @@ vimperator.Hints = function () //{{{ hintNumber = 0; break; - case vimperator.events.getMapLeader(): + case liberator.events.getMapLeader(): escapeNumbers = !escapeNumbers; if (escapeNumbers && usedTabKey) // hintNumber not used normally, but someone may wants to toggle hintNumber = 0; // s ? reset. Prevent to show numbers not entered. @@ -575,18 +575,18 @@ vimperator.Hints = function () //{{{ return; default: - // pass any special or ctrl- etc. prefixed key back to the main vimperator loop + // pass any special or ctrl- etc. prefixed key back to the main liberator loop if (/^<./.test(key) || key == ":") { var map = null; - if ((map = vimperator.mappings.get(vimperator.modes.NORMAL, key)) || - (map = vimperator.mappings.get(vimperator.modes.HINTS, key))) + if ((map = liberator.mappings.get(liberator.modes.NORMAL, key)) || + (map = liberator.mappings.get(liberator.modes.HINTS, key))) { map.execute(null, -1); return; } - vimperator.beep(); + liberator.beep(); return; } @@ -615,7 +615,7 @@ vimperator.Hints = function () //{{{ if (hintNumber == 0 || hintNumber > validHints.length) { - vimperator.beep(); + liberator.beep(); return; } @@ -623,7 +623,7 @@ vimperator.Hints = function () //{{{ // the hint after a timeout, as the user might have wanted to follow link 34 if (hintNumber > 0 && hintNumber * 10 <= validHints.length) { - var timeout = vimperator.options["hinttimeout"]; + var timeout = liberator.options["hinttimeout"]; if (timeout > 0) activeTimeout = setTimeout(function () { processHints(true); }, timeout); diff --git a/content/io.js b/content/io.js index bdce12b1..af5bfb49 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 () //{{{ +liberator.IO = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -38,39 +38,39 @@ vimperator.IO = function () //{{{ const WINDOWS = navigator.platform == "Win32"; var cwd = null, oldcwd = null; - var extname = vimperator.config.name.toLowerCase(); // "vimperator" or "muttator" + var extname = liberator.config.name.toLowerCase(); // "vimperator" or "muttator" var lastRunCommand = ""; // updated whenever the users runs a command with :! /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["cd", "chd[ir]"], + liberator.commands.add(["cd", "chd[ir]"], "Change the current directory", function (args) { if (!args) args = "~"; - if (vimperator.io.setCurrentDirectory(args)) - vimperator.echo(vimperator.io.getCurrentDirectory()); + if (liberator.io.setCurrentDirectory(args)) + liberator.echo(liberator.io.getCurrentDirectory()); }, { - completer: function (filter) { return vimperator.completion.file(filter, true); } + completer: function (filter) { return liberator.completion.file(filter, true); } }); - vimperator.commands.add(["pw[d]"], + liberator.commands.add(["pw[d]"], "Print the current directory name", function (args) { if (args) - vimperator.echoerr("E488: Trailing characters"); + liberator.echoerr("E488: Trailing characters"); else - vimperator.echo(vimperator.io.getCurrentDirectory()); + liberator.echo(liberator.io.getCurrentDirectory()); }); // mkv[imperatorrc] or mkm[uttatorrc] - vimperator.commands.add(["mk" + extname.substr(0,1) + "[" + extname.substr(1) + "rc]"], + liberator.commands.add(["mk" + extname.substr(0,1) + "[" + extname.substr(1) + "rc]"], "Write current key mappings and changed options to the config file", function (args, special) { @@ -84,27 +84,27 @@ vimperator.IO = function () //{{{ filename += extname+ "rc"; } - var file = vimperator.io.getFile(filename); + var file = liberator.io.getFile(filename); if (file.exists() && !special) { - vimperator.echoerr("E189: \"" + filename + "\" exists (add ! to override)"); + liberator.echoerr("E189: \"" + filename + "\" exists (add ! to override)"); return; } - var line = "\" " + vimperator.version + "\n"; + var line = "\" " + liberator.version + "\n"; line += "\" Mappings\n"; - var mode = [[[vimperator.modes.NORMAL], ""], [[vimperator.modes.COMMAND_LINE], "c"], - [[vimperator.modes.INSERT, vimperator.modes.TEXTAREA], "i"]]; + var mode = [[[liberator.modes.NORMAL], ""], [[liberator.modes.COMMAND_LINE], "c"], + [[liberator.modes.INSERT, liberator.modes.TEXTAREA], "i"]]; for (var y = 0; y < mode.length; y++) { // NOTE: names.length is always 1 on user maps. If that changes, also fix getUserIterator and v.m.list - for (var map in vimperator.mappings.getUserIterator(mode[y][0])) + for (var map in liberator.mappings.getUserIterator(mode[y][0])) line += mode[y][1] + (map.noremap ? "nore" : "") + "map " + map.names[0] + " " + map.rhs + "\n"; } line += "\n\" Options\n"; - for (var option in vimperator.options) + for (var option in liberator.options) { // TODO: options should be queried for this info // TODO: string/list options might need escaping in future @@ -119,41 +119,41 @@ vimperator.IO = function () //{{{ // :mkvimrc doesn't save autocommands, so we don't either - remove this code at some point // line += "\n\" Auto-Commands\n"; - // for (var item in vimperator.autocommands) + // for (var item in liberator.autocommands) // line += "autocmd " + item + "\n"; line += "\n\" Abbreviations\n"; - for (var abbrCmd in vimperator.editor.abbreviations) + for (var abbrCmd in liberator.editor.abbreviations) line += abbrCmd; - // if (vimperator.events.getMapLeader() != "\\") - // line += "\nlet mapleader = \"" + vimperator.events.getMapLeader() + "\"\n"; + // if (liberator.events.getMapLeader() != "\\") + // line += "\nlet mapleader = \"" + liberator.events.getMapLeader() + "\"\n"; // source a user .vimperatorrc file line += "\nsource! " + filename + ".local\n"; line += "\n\" vim: set ft=vimperator:"; - vimperator.io.writeFile(file, line); + liberator.io.writeFile(file, line); }); - vimperator.commands.add(["so[urce]"], + liberator.commands.add(["so[urce]"], "Read Ex commands from a file", function (args, special) { // FIXME: implement proper filename quoting //if (/[^\\]\s/.test(args)) //{ - // vimperator.echoerr("E172: Only one file name allowed"); + // liberator.echoerr("E172: Only one file name allowed"); // return; //} - vimperator.io.source(args, special); + liberator.io.source(args, special); }, { - completer: function (filter) { return vimperator.completion.file(filter, true); } + completer: function (filter) { return liberator.completion.file(filter, true); } }); - vimperator.commands.add(["!", "run"], + liberator.commands.add(["!", "run"], "Run a command", function (args, special) { @@ -166,9 +166,9 @@ vimperator.IO = function () //{{{ args = args.replace(/(^|[^\\])!/g, "$1" + lastRunCommand); lastRunCommand = args; - var output = vimperator.io.system(args); + var output = liberator.io.system(args); if (output) - vimperator.echo(vimperator.util.escapeHTML(output)); + liberator.echo(liberator.util.escapeHTML(output)); }); /////////////////////////////////////////////////////////////////////////////}}} @@ -274,7 +274,7 @@ vimperator.IO = function () //{{{ var file = ioManager.getFile(newdir); if (!file.exists() || !file.isDirectory()) { - vimperator.echoerr("E344: Can't find directory \"" + newdir + "\" in path"); + liberator.echoerr("E344: Can't find directory \"" + newdir + "\" in path"); return null; } [cwd, oldcwd] = [newdir, cwd]; @@ -287,9 +287,9 @@ vimperator.IO = function () //{{{ var pluginDir; if (WINDOWS) - pluginDir = "~/" + vimperator.config.name.toLowerCase() + "/" + directory; + pluginDir = "~/" + liberator.config.name.toLowerCase() + "/" + directory; else - pluginDir = "~/." + vimperator.config.name.toLowerCase() + "/" + directory; + pluginDir = "~/." + liberator.config.name.toLowerCase() + "/" + directory; pluginDir = ioManager.getFile(ioManager.expandPath(pluginDir)); @@ -298,8 +298,8 @@ vimperator.IO = function () //{{{ getRCFile: function () { - var rcFile1 = ioManager.getFile("~/." + vimperator.config.name.toLowerCase() + "rc"); - var rcFile2 = ioManager.getFile("~/_" + vimperator.config.name.toLowerCase() + "rc"); + var rcFile1 = ioManager.getFile("~/." + liberator.config.name.toLowerCase() + "rc"); + var rcFile2 = ioManager.getFile("~/_" + liberator.config.name.toLowerCase() + "rc"); if (WINDOWS) [rcFile1, rcFile2] = [rcFile2, rcFile1] @@ -475,7 +475,7 @@ vimperator.IO = function () //{{{ if (!file.exists()) { - vimperator.echoerr("command not found: " + program); + liberator.echoerr("command not found: " + program); return -1; } @@ -537,7 +537,7 @@ vimperator.IO = function () //{{{ if (!file.exists()) { if (!silent) - vimperator.echoerr("E484: Can't open file " + filename); + liberator.echoerr("E484: Can't open file " + filename); return false; } var str = ioManager.readFile(filename); @@ -545,7 +545,7 @@ vimperator.IO = function () //{{{ // handle pure javascript files specially if (/\.js$/.test(filename)) { - eval("with(vimperator){" + str + "}"); + eval("with(liberator){" + str + "}"); } else { @@ -557,7 +557,7 @@ vimperator.IO = function () //{{{ { if (heredocEnd.test(line)) { - eval("with(vimperator){" + heredoc + "}"); + eval("with(liberator){" + heredoc + "}"); heredoc = ""; heredocEnd = null; } @@ -569,8 +569,8 @@ vimperator.IO = function () //{{{ else { // check for a heredoc - var [count, cmd, special, args] = vimperator.commands.parseCommand(line); - var command = vimperator.commands.get(cmd); + var [count, cmd, special, args] = liberator.commands.parseCommand(line); + var command = liberator.commands.get(cmd); if (command && command.name == "javascript") { var matches = args.match(/(.*)<<\s*([^\s]+)$/); @@ -587,19 +587,19 @@ vimperator.IO = function () //{{{ } else { - // execute a normal vimperator command - vimperator.execute(line); + // execute a normal liberator command + liberator.execute(line); } } }); } - vimperator.log("Sourced: " + filename, 3); + liberator.log("Sourced: " + filename, 3); } catch (e) { if (!silent) - vimperator.echoerr(e); + liberator.echoerr(e); } } }; diff --git a/content/mail.js b/content/mail.js index f140bfbb..1e37cd21 100644 --- a/content/mail.js +++ b/content/mail.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.Mail = function () +liberator.Mail = function () { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -94,11 +94,11 @@ vimperator.Mail = function () ////////////////////// OPTIONS ///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ -// vimperator.options.add(["editor"], +// liberator.options.add(["editor"], // "Set the external text editor", // "string", "gvim -f"); - vimperator.options.add(["layout"], + liberator.options.add(["layout"], "Set the layout of the mail window", "string", "inherit", { @@ -119,108 +119,108 @@ vimperator.Mail = function () ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var modes = vimperator.config.mailModes || [vimperator.modes.NORMAL]; + var modes = liberator.config.mailModes || [liberator.modes.NORMAL]; - vimperator.mappings.add(modes, ["", "i"], + liberator.mappings.add(modes, ["", "i"], "Inspect (focus) message", function () { content.focus(); }); - vimperator.mappings.add(modes, ["d", ""], + liberator.mappings.add(modes, ["d", ""], "Move mail to Trash folder", function () { goDoCommand("cmd_delete"); }); - vimperator.mappings.add(modes, ["j", ""], + liberator.mappings.add(modes, ["j", ""], "Select next message", - function (count) { vimperator.mail.selectMessage(function (msg) { return true; }, false, false, count); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, false, count); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["J", ""], + liberator.mappings.add(modes, ["J", ""], "Select next unread message", - function (count) { vimperator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, false, count); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, false, count); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["k", ""], + liberator.mappings.add(modes, ["k", ""], "Select previous message", - function (count) { vimperator.mail.selectMessage(function (msg) { return true; }, false, true, count); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, true, count); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["K"], + liberator.mappings.add(modes, ["K"], "Select previous unread message", - function (count) { vimperator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, true, count); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, true, count); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["r"], + liberator.mappings.add(modes, ["r"], "Reply to sender", function () { goDoCommand("cmd_reply"); }); - vimperator.mappings.add(modes, ["gm"], + liberator.mappings.add(modes, ["gm"], "Get new messages", - function () { vimperator.mail.getNewMessages(); }); + function () { liberator.mail.getNewMessages(); }); - vimperator.mappings.add(modes, ["gM"], + liberator.mappings.add(modes, ["gM"], "Get new messages for current account only", - function () { vimperator.mail.getNewMessages(true); }); + function () { liberator.mail.getNewMessages(true); }); - vimperator.mappings.add([vimperator.modes.NORMAL], + liberator.mappings.add([liberator.modes.NORMAL], ["c"], "Change folders", - function () { vimperator.commandline.open(":", "goto ", vimperator.modes.EX); }); + function () { liberator.commandline.open(":", "goto ", liberator.modes.EX); }); - vimperator.mappings.add(modes, ["]s"], + liberator.mappings.add(modes, ["]s"], "Select next starred message", - function (count) { vimperator.mail.selectMessage(function(msg) { return msg.isFlagged; }, true, false, count); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.mail.selectMessage(function(msg) { return msg.isFlagged; }, true, false, count); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["[s"], + liberator.mappings.add(modes, ["[s"], "Select previous starred message", - function (count) { vimperator.mail.selectMessage(function(msg) { return msg.isFlagged; }, true, true, count); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.mail.selectMessage(function(msg) { return msg.isFlagged; }, true, true, count); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["]a"], + liberator.mappings.add(modes, ["]a"], "Select next message with an attachment", - function (count) { vimperator.mail.selectMessage(function(msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, false, count); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.mail.selectMessage(function(msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, false, count); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["[a"], + liberator.mappings.add(modes, ["[a"], "Select previous message with an attachment", - function (count) { vimperator.mail.selectMessage(function(msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, true, count); }, - { flags: vimperator.Mappings.flags.COUNT }); + function (count) { liberator.mail.selectMessage(function(msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, true, count); }, + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, [""], + liberator.mappings.add(modes, [""], "Get new messages", function (count) { if (count < 1) count = 1; while (count--) GoNextMessage(nsMsgNavigationType.forward, true); }, - { flags: vimperator.Mappings.flags.COUNT }); + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, [""], + liberator.mappings.add(modes, [""], "Get new messages", function (count) { if (count < 1) count = 1; while (count--) GoNextMessage(nsMsgNavigationType.back, true); }, - { flags: vimperator.Mappings.flags.COUNT }); + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["gg"], + liberator.mappings.add(modes, ["gg"], "Get new messages", function (count) { if (count < 1) count = 1; while (count--) GoNextMessage(nsMsgNavigationType.firstMessage, true); }, - { flags: vimperator.Mappings.flags.COUNT }); + { flags: liberator.Mappings.flags.COUNT }); - vimperator.mappings.add(modes, ["G"], + liberator.mappings.add(modes, ["G"], "Get new messages", function (count) { if (count < 1) count = 1; while (count--) GoNextMessage(nsMsgNavigationType.lastMessage, false); }, - { flags: vimperator.Mappings.flags.COUNT }); + { flags: liberator.Mappings.flags.COUNT }); // tagging messages - vimperator.mappings.add(modes, ["tr"], + liberator.mappings.add(modes, ["tr"], "Toggle selected messages read", function () { if (!GetSelectedMessages()) { - vimperator.beep(); + liberator.beep(); return; } MsgMarkMsgAsRead(); }); - vimperator.mappings.add(modes, ["tR"], + liberator.mappings.add(modes, ["tR"], "Tag thread as read", function () { @@ -230,37 +230,37 @@ vimperator.Mail = function () }); - vimperator.mappings.add(modes, ["ts"], + liberator.mappings.add(modes, ["ts"], "Toggle selected messages starred", function () { if (!GetSelectedMessages()) { - vimperator.beep(); + liberator.beep(); return; } MsgMarkMsgAsFlagged(); }); - vimperator.mappings.add(modes, ["T"], + liberator.mappings.add(modes, ["T"], "Mark current folder as read", function () { - if (vimperator.mail.currentFolder.isServer) + if (liberator.mail.currentFolder.isServer) { - vimperator.beep(); + liberator.beep(); return; } - vimperator.mail.currentFolder.markAllMessagesRead(); + liberator.mail.currentFolder.markAllMessagesRead(); }); - vimperator.mappings.add(modes, [""], + liberator.mappings.add(modes, [""], "Mark all messages as read", function () { - vimperator.mail.getFolders("", false).forEach(function(folder) { + liberator.mail.getFolders("", false).forEach(function(folder) { folder.markAllMessagesRead(); }); }); @@ -269,31 +269,31 @@ vimperator.Mail = function () ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.commands.add(["go[to]"], + liberator.commands.add(["go[to]"], "Select a folder", function (args, special, count) { args = args || "Inbox"; count = count > 0 ? (count - 1) : 0; - var folder = vimperator.mail.getFolders(args, true, true)[count]; + var folder = liberator.mail.getFolders(args, true, true)[count]; if (!folder) - vimperator.echoerr("Folder \"" + args + "\" does not exist"); + liberator.echoerr("Folder \"" + args + "\" does not exist"); else SelectFolder(folder.URI); }); - vimperator.commands.add(["get[messages]"], + liberator.commands.add(["get[messages]"], "Check for new messages", function (args, special) { if (args) { - vimperator.echoerr("E488: Trailing characters"); + liberator.echoerr("E488: Trailing characters"); return; } - vimperator.mail.getNewMessages(!special); + liberator.mail.getNewMessages(!special); }); /////////////////////////////////////////////////////////////////////////////}}} @@ -442,7 +442,7 @@ vimperator.Mail = function () // TODO: finally for the "rest" of the current folder - vimperator.beep(); + liberator.beep(); } }; //}}} diff --git a/content/mappings.js b/content/mappings.js index 0b632a36..bd0b64f3 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -27,8 +27,8 @@ the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ // Do NOT create instances of this class yourself, use the helper method -// vimperator.mappings.add() instead -vimperator.Map = function (modes, cmds, description, action, extraInfo) //{{{ +// liberator.mappings.add() instead +liberator.Map = function (modes, cmds, description, action, extraInfo) //{{{ { if (!modes || (!cmds || !cmds.length) || !action) return null; @@ -47,7 +47,7 @@ vimperator.Map = function (modes, cmds, description, action, extraInfo) //{{{ this.noremap = extraInfo.noremap || false; }; -vimperator.Map.prototype = { +liberator.Map.prototype = { hasName: function (name) { @@ -58,11 +58,11 @@ vimperator.Map.prototype = { { var args = []; - if (this.flags & vimperator.Mappings.flags.MOTION) + if (this.flags & liberator.Mappings.flags.MOTION) args.push(motion); - if (this.flags & vimperator.Mappings.flags.COUNT) + if (this.flags & liberator.Mappings.flags.COUNT) args.push(count); - if (this.flags & vimperator.Mappings.flags.ARGUMENT) + if (this.flags & liberator.Mappings.flags.ARGUMENT) args.push(argument); return this.action.apply(this, args); @@ -71,7 +71,7 @@ vimperator.Map.prototype = { }; //}}} -vimperator.Mappings = function () //{{{ +liberator.Mappings = function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -80,7 +80,7 @@ vimperator.Mappings = function () //{{{ var main = []; // default mappings var user = []; // user created mappings - for (var mode in vimperator.modes) + for (var mode in liberator.modes) { main[mode] = []; user[mode] = []; @@ -166,7 +166,7 @@ vimperator.Mappings = function () //{{{ { if (!args) { - vimperator.mappings.list(mode); + liberator.mappings.list(mode); return; } @@ -175,21 +175,21 @@ vimperator.Mappings = function () //{{{ var leaderRegexp = //i; if (leaderRegexp.test(lhs)) - lhs = lhs.replace(leaderRegexp, vimperator.events.getMapLeader()); + lhs = lhs.replace(leaderRegexp, liberator.events.getMapLeader()); if (!rhs) // list the mapping { - vimperator.mappings.list(mode, lhs); + liberator.mappings.list(mode, lhs); } else { for (var index = 0; index < mode.length; index++) { - vimperator.mappings.addUserMap([mode[index]], [lhs], + liberator.mappings.addUserMap([mode[index]], [lhs], "User defined mapping", - function (count) { vimperator.events.feedkeys((count > 1 ? count : "") + rhs, noremap); }, + function (count) { liberator.events.feedkeys((count > 1 ? count : "") + rhs, noremap); }, { - flags: vimperator.Mappings.flags.COUNT, + flags: liberator.Mappings.flags.COUNT, rhs: rhs, noremap: noremap }); @@ -199,49 +199,49 @@ vimperator.Mappings = function () //{{{ var modeDescription = modeDescription ? " in " + modeDescription + " mode" : ""; - vimperator.commands.add([char ? char + "m[ap]" : "map"], + liberator.commands.add([char ? char + "m[ap]" : "map"], "Map a key sequence" + modeDescription, function (args) { map(args, modes, false); }); - vimperator.commands.add([char + "no[remap]"], + liberator.commands.add([char + "no[remap]"], "Map a key sequence without remapping keys" + modeDescription, function (args) { map(args, modes, true); }); - vimperator.commands.add([char + "mapc[lear]"], + liberator.commands.add([char + "mapc[lear]"], "Remove all mappings" + modeDescription, function (args) { if (args) { - vimperator.echoerr("E474: Invalid argument"); + liberator.echoerr("E474: Invalid argument"); return; } for (let i = 0; i < modes.length; i++) - vimperator.mappings.removeAll(modes[i]); + liberator.mappings.removeAll(modes[i]); }); - vimperator.commands.add([char + "unm[ap]"], + liberator.commands.add([char + "unm[ap]"], "Remove a mapping" + modeDescription, function (args) { if (!args) { - vimperator.echoerr("E474: Invalid argument"); + liberator.echoerr("E474: Invalid argument"); return; } var flag = false; for (let i = 0; i < modes.length; i++) { - if (vimperator.mappings.hasMap(modes[i], args)) + if (liberator.mappings.hasMap(modes[i], args)) { - vimperator.mappings.remove(modes[i], args); + liberator.mappings.remove(modes[i], args); flag = true; } } if (!flag) - vimperator.echoerr("E31: No such mapping"); + liberator.echoerr("E31: No such mapping"); }); } @@ -249,18 +249,18 @@ vimperator.Mappings = function () //{{{ ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - addMapCommands("", [vimperator.modes.NORMAL], ""); - addMapCommands("c", [vimperator.modes.COMMAND_LINE], "command line"); - addMapCommands("i", [vimperator.modes.INSERT, vimperator.modes.TEXTAREA], "insert"); - if (vimperator.has("mail")) - addMapCommands("m", [vimperator.modes.MESSAGE], "message"); + addMapCommands("", [liberator.modes.NORMAL], ""); + addMapCommands("c", [liberator.modes.COMMAND_LINE], "command line"); + addMapCommands("i", [liberator.modes.INSERT, liberator.modes.TEXTAREA], "insert"); + if (liberator.has("mail")) + addMapCommands("m", [liberator.modes.MESSAGE], "message"); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ // FIXME: - vimperator.Mappings.flags = { + liberator.Mappings.flags = { ALLOW_EVENT_ROUTING: 1 << 0, // if set, return true inside the map command to pass the event further to firefox MOTION: 1 << 1, COUNT: 1 << 2, @@ -272,7 +272,7 @@ vimperator.Mappings = function () //{{{ // NOTE: just normal mode for now __iterator__: function () { - return mappingsIterator([vimperator.modes.NORMAL], main); + return mappingsIterator([liberator.modes.NORMAL], main); }, // used by :mkvimperatorrc to save mappings @@ -283,12 +283,12 @@ vimperator.Mappings = function () //{{{ add: function (modes, keys, description, action, extra) { - addMap (new vimperator.Map(modes, keys, description, action, extra), false); + addMap (new liberator.Map(modes, keys, description, action, extra), false); }, addUserMap: function (modes, keys, description, action, extra) { - var map = new vimperator.Map(modes, keys, description || "User defined mapping", action, extra); + var map = new liberator.Map(modes, keys, description || "User defined mapping", action, extra); // remove all old mappings to this key sequence for (var i = 0; i < map.names.length; i++) @@ -302,13 +302,13 @@ vimperator.Mappings = function () //{{{ get: function (mode, cmd) { - mode = mode || vimperator.modes.NORMAL; + mode = mode || liberator.modes.NORMAL; return getMap(mode, cmd, user) || getMap(mode, cmd, main); }, getDefault: function (mode, cmd) { - mode = mode || vimperator.modes.NORMAL; + mode = mode || liberator.modes.NORMAL; return getMap(mode, cmd, main); }, @@ -359,7 +359,7 @@ vimperator.Mappings = function () //{{{ if (!maps || maps.length == 0) { - vimperator.echo("No mappings found"); + liberator.echo("No mappings found"); return; } @@ -396,20 +396,20 @@ vimperator.Mappings = function () //{{{ if (!flag) { - vimperator.echo("No mappings found"); + liberator.echo("No mappings found"); return; } var modeSign = ""; for (var i = 0; i < modes.length; i++) { - if (modes[i] == vimperator.modes.NORMAL) + if (modes[i] == liberator.modes.NORMAL) modeSign += "n"; - if ((modes[i] == vimperator.modes.INSERT || modes[i] == vimperator.modes.TEXTAREA) && modeSign.indexOf("i") == -1) + if ((modes[i] == liberator.modes.INSERT || modes[i] == liberator.modes.TEXTAREA) && modeSign.indexOf("i") == -1) modeSign += "i"; - if (modes[i] == vimperator.modes.COMMAND_LINE) + if (modes[i] == liberator.modes.COMMAND_LINE) modeSign += "c"; - if (modes[i] == vimperator.modes.MESSAGRE) + if (modes[i] == liberator.modes.MESSAGRE) modeSign += "m"; } @@ -421,16 +421,16 @@ vimperator.Mappings = function () //{{{ for (var j = 0; j < maps[i].names.length; j++) { list += ""; - list += " " + modeSign + " " + vimperator.util.escapeHTML(maps[i].names[j]) + ""; + list += " " + modeSign + " " + liberator.util.escapeHTML(maps[i].names[j]) + ""; if (maps[i].rhs) list += " "+ (maps[i].noremap ? "*" : " ") + "" - + "" + vimperator.util.escapeHTML(maps[i].rhs) + ""; + + "" + liberator.util.escapeHTML(maps[i].rhs) + ""; list += ""; } } list += ""; - vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); + liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } }; diff --git a/content/modes.js b/content/modes.js index 80a02c01..d4e48884 100644 --- a/content/modes.js +++ b/content/modes.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.modes = (function () //{{{ +liberator.modes = (function () //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -48,41 +48,41 @@ vimperator.modes = (function () //{{{ return "-- PASS THROUGH --"; var ext = ""; - if (extended & vimperator.modes.QUICK_HINT) + if (extended & liberator.modes.QUICK_HINT) ext += " (quick)"; - if (extended & vimperator.modes.EXTENDED_HINT) + if (extended & liberator.modes.EXTENDED_HINT) ext += " (extended)"; - if (extended & vimperator.modes.ALWAYS_HINT) + if (extended & liberator.modes.ALWAYS_HINT) ext += " (always)"; - if (extended & vimperator.modes.INACTIVE_HINT) + if (extended & liberator.modes.INACTIVE_HINT) ext += " (inactive)"; - if (extended & vimperator.modes.MENU) // TODO: desirable? + if (extended & liberator.modes.MENU) // TODO: desirable? ext += " (menu)"; ext += " --"; // when recording a macro - if (vimperator.modes.isRecording) + if (liberator.modes.isRecording) ext += "recording"; switch (main) { - case vimperator.modes.INSERT: + case liberator.modes.INSERT: return "-- INSERT" + ext; - case vimperator.modes.VISUAL: - return (extended & vimperator.modes.LINE) ? "-- VISUAL LINE" + ext : "-- VISUAL" + ext; - case vimperator.modes.HINTS: + case liberator.modes.VISUAL: + return (extended & liberator.modes.LINE) ? "-- VISUAL LINE" + ext : "-- VISUAL" + ext; + case liberator.modes.HINTS: return "-- HINTS" + ext; - case vimperator.modes.CARET: + case liberator.modes.CARET: return "-- CARET" + ext; - case vimperator.modes.TEXTAREA: + case liberator.modes.TEXTAREA: return "-- TEXTAREA" + ext; - case vimperator.modes.MESSAGE: + case liberator.modes.MESSAGE: return "-- MESSAGE" + ext; - case vimperator.modes.CUSTOM: - return "-- " + vimperator.plugins.mode + ext; + case liberator.modes.CUSTOM: + return "-- " + liberator.plugins.mode + ext; default: // NORMAL mode - if (vimperator.modes.isRecording) + if (liberator.modes.isRecording) return "recording"; else return ""; @@ -91,23 +91,23 @@ vimperator.modes = (function () //{{{ // NOTE: Pay attention that you don't run into endless loops // Usually you should only indicate to leave a special mode linke HINTS - // by calling vimperator.modes.reset() and adding the stuff which is needed + // by calling liberator.modes.reset() and adding the stuff which is needed // for its cleanup here function handleModeChange(oldMode, newMode) { // TODO: fix v.log() to work with verbosity level - // vimperator.log("switching from mode " + oldMode + " to mode " + newMode, 7); + // liberator.log("switching from mode " + oldMode + " to mode " + newMode, 7); // dump("switching from mode " + oldMode + " to mode " + newMode + "\n"); switch (oldMode) { - case vimperator.modes.TEXTAREA: - case vimperator.modes.INSERT: - vimperator.editor.unselectText(); + case liberator.modes.TEXTAREA: + case liberator.modes.INSERT: + liberator.editor.unselectText(); break; - case vimperator.modes.VISUAL: - if (newMode == vimperator.modes.CARET) + case liberator.modes.VISUAL: + if (newMode == liberator.modes.CARET) { // clear any selection made var selection = window.content.getSelection(); @@ -118,31 +118,31 @@ vimperator.modes = (function () //{{{ catch (e) { } } else - vimperator.editor.unselectText(); + liberator.editor.unselectText(); break; - case vimperator.modes.CUSTOM: - vimperator.plugins.stop(); + case liberator.modes.CUSTOM: + liberator.plugins.stop(); break; - case vimperator.modes.HINTS: - vimperator.hints.hide(); + case liberator.modes.HINTS: + liberator.hints.hide(); break; - case vimperator.modes.COMMAND_LINE: - vimperator.commandline.close(); + case liberator.modes.COMMAND_LINE: + liberator.commandline.close(); break; } - if (newMode == vimperator.modes.NORMAL) + if (newMode == liberator.modes.NORMAL) { // disable caret mode when we want to switch to normal mode - var value = vimperator.options.getPref("accessibility.browsewithcaret", false); + var value = liberator.options.getPref("accessibility.browsewithcaret", false); if (value) - vimperator.options.setPref("accessibility.browsewithcaret", false); + liberator.options.setPref("accessibility.browsewithcaret", false); - vimperator.statusline.updateUrl(); - vimperator.focusContent(false); + liberator.statusline.updateUrl(); + liberator.focusContent(false); } } @@ -194,15 +194,15 @@ vimperator.modes = (function () //{{{ // show the current mode string in the command line show: function () { - if (!vimperator.options["showmode"]) + if (!liberator.options["showmode"]) return; // never show mode messages if we are in command line mode - if (main == vimperator.modes.COMMAND_LINE) + if (main == liberator.modes.COMMAND_LINE) return; - vimperator.commandline.echo(getModeMessage(), vimperator.commandline.HL_MODEMSG, - vimperator.commandline.DISALLOW_MULTILINE); + liberator.commandline.echo(getModeMessage(), liberator.commandline.HL_MODEMSG, + liberator.commandline.DISALLOW_MULTILINE); }, // add/remove always work on the extended mode only @@ -224,7 +224,7 @@ vimperator.modes = (function () //{{{ main = mainMode; if (!extendedMode) - extended = vimperator.modes.NONE; + extended = liberator.modes.NONE; } if (typeof extendedMode === "number") @@ -237,15 +237,15 @@ vimperator.modes = (function () //{{{ setCustomMode: function (modestr, oneventfunc, stopfunc) { // TODO this.plugin[id]... ('id' maybe submode or what..) - vimperator.plugins.mode = modestr; - vimperator.plugins.onEvent = oneventfunc; - vimperator.plugins.stop = stopfunc; + liberator.plugins.mode = modestr; + liberator.plugins.onEvent = oneventfunc; + liberator.plugins.stop = stopfunc; }, // keeps recording state reset: function (silent) { - this.set(vimperator.modes.NORMAL, vimperator.modes.NONE, silent); + this.set(liberator.modes.NORMAL, liberator.modes.NONE, silent); }, remove: function (mode) @@ -273,7 +273,7 @@ vimperator.modes = (function () //{{{ main = value; // setting the main mode always resets any extended mode - extended = vimperator.modes.NONE; + extended = liberator.modes.NONE; this.show(); }, diff --git a/content/muttator.js b/content/muttator.js index f6c47d8e..c8f8126a 100644 --- a/content/muttator.js +++ b/content/muttator.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.config = { +liberator.config = { /*** required options, no checks done if they really exist, so be careful ***/ name: "Muttator", hostApplication: "Thunderbird", // TODO: can this be found out otherwise? gBrandBundle.getString("brandShortName"); @@ -35,7 +35,7 @@ vimperator.config = { features: ["hints", "mail", "marks"], guioptions: { m: ["mail-toolbar-menubar2"], T: ["mail-bar2"], f: ["folderPaneBox", "folderpane_splitter"], F: ["folderPaneHeader"] }, - get browserModes() { return [vimperator.modes.MESSAGE]; }, + get browserModes() { return [liberator.modes.MESSAGE]; }, get mainWidget() { return GetThreadTree(); }, // focusContent() focuses this widget mainWindowID: "messengerWindow", // used for :set titlestring @@ -79,14 +79,14 @@ vimperator.config = { /*["searchengines", "Manage installed search engines", function() { openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }], ["selectionsource", "View selection source", - function() { vimperator.buffer.viewSelectionSource(); }]*/ + function() { liberator.buffer.viewSelectionSource(); }]*/ ], init: function() { - vimperator.mappings.add([vimperator.modes.NORMAL], + liberator.mappings.add([liberator.modes.NORMAL], ["o"], "Open a message", - function () { vimperator.commandline.open(":", "open ", vimperator.modes.EX); }); + function () { liberator.commandline.open(":", "open ", liberator.modes.EX); }); } } diff --git a/content/muttator.xul b/content/muttator.xul index b8d5831f..c5d1b02c 100644 --- a/content/muttator.xul +++ b/content/muttator.xul @@ -63,74 +63,74 @@ the terms of any one of the MPL, the GPL or the LGPL. + oncommandupdate="liberator.events.onFocusChange(event);"/> + oncommandupdate="liberator.events.onSelectionChange(event);"/> - - - + + + - -