mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 00:27:57 +01:00
big vimperator->liberator rename, expect some brakeage
This commit is contained in:
@@ -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 <tab> 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()) + "<br/>" +
|
||||
var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
||||
"<table><tr align=\"left\" class=\"hl-Title\"><th>title</th><th>URL</th></tr>";
|
||||
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 = "<span style=\"color: gray;\"> (keyword: <span style=\"color: red;\">" + vimperator.util.escapeHTML(keyword) + "</span>";
|
||||
extra = "<span style=\"color: gray;\"> (keyword: <span style=\"color: red;\">" + liberator.util.escapeHTML(keyword) + "</span>";
|
||||
if (tags)
|
||||
extra += " tags: <span style=\"color: blue;\">" + vimperator.util.escapeHTML(tags) + ")</span>";
|
||||
extra += " tags: <span style=\"color: blue;\">" + liberator.util.escapeHTML(tags) + ")</span>";
|
||||
else
|
||||
extra += ")</span>";
|
||||
}
|
||||
else if (tags)
|
||||
{
|
||||
extra = "<span style=\"color: gray;\"> (tags: <span style=\"color: blue;\">" + vimperator.util.escapeHTML(tags) + "</span>)</span>";
|
||||
extra = "<span style=\"color: gray;\"> (tags: <span style=\"color: blue;\">" + liberator.util.escapeHTML(tags) + "</span>)</span>";
|
||||
}
|
||||
|
||||
|
||||
@@ -473,14 +473,14 @@ vimperator.Bookmarks = function () //{{{
|
||||
}
|
||||
list += "</table>";
|
||||
|
||||
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,
|
||||
["<C-o>"], "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,
|
||||
["<C-i>"], "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", "<A-Left>", "<M-Left>"], "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", "<A-Right>", "<M-Right>"], "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()) + "<br/>" +
|
||||
var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
||||
"<table><tr align=\"left\" class=\"hl-Title\"><th>title</th><th>URL</th></tr>";
|
||||
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 += "<tr><td>" + title + "</td><td><a href=\"#\" class=\"hl-URL\">" + url + "</a></td></tr>";
|
||||
}
|
||||
list += "</table>";
|
||||
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()) + "<br/>" +
|
||||
var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
||||
"<table><tr align=\"left\" class=\"hl-Title\"><th>QuickMark</th><th>URL</th></tr>";
|
||||
for (var i = 0; i < marks.length; i++)
|
||||
{
|
||||
list += "<tr><td> " + marks[i][0] +
|
||||
"</td><td style=\"color: green;\">" + vimperator.util.escapeHTML(marks[i][1]) + "</td></tr>";
|
||||
"</td><td style=\"color: green;\">" + liberator.util.escapeHTML(marks[i][1]) + "</td></tr>";
|
||||
}
|
||||
list += "</table>";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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()) + "<br/>" +
|
||||
var str = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
||||
"<table><tr align=\"left\" class=\"hl-Title\"><th>Name</th><th>Args</th><th>Definition</th></tr>";
|
||||
for (var i = 0; i < cmdlist.length; i++)
|
||||
str += "<tr><td>" + cmdlist[i].name + "</td><td>" + "*" + "</td><td>" + cmdlist[i].isUserCommand + "</td></tr>";
|
||||
str += "</table>"
|
||||
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(); });
|
||||
|
||||
//}}}
|
||||
|
||||
|
||||
@@ -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 <tab>" or ":tab :he<tab>"
|
||||
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+/);
|
||||
|
||||
@@ -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", "<Up>"], 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,
|
||||
["<C-w>"], "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,
|
||||
["<C-u>"], "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,
|
||||
["<C-k>"], "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,
|
||||
["<C-a>", "<Home>"], "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,
|
||||
["<C-e>", "<End>"], "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,
|
||||
["<C-h>"], "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,
|
||||
["<C-d>"], "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,
|
||||
["<S-Insert>"], "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],
|
||||
["<C-i>"], "Edit text field with an external editor",
|
||||
function () { vimperator.editor.editWithExternalEditor(); });
|
||||
function () { liberator.editor.editWithExternalEditor(); });
|
||||
|
||||
// FIXME: <esc> does not work correctly
|
||||
vimperator.mappings.add([vimperator.modes.INSERT],
|
||||
liberator.mappings.add([liberator.modes.INSERT],
|
||||
["<C-t>"], "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],
|
||||
["<Space>", "<Return>"], "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],
|
||||
["<Tab>"], "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],
|
||||
["<C-]>", "<C-5>"], "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],
|
||||
["<C-r>"], "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("<Return>");
|
||||
liberator.editor.executeCommand("cmd_endLine", 1);
|
||||
liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA);
|
||||
liberator.events.feedkeys("<Return>");
|
||||
});
|
||||
|
||||
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("<Return>");
|
||||
vimperator.editor.executeCommand("cmd_linePrevious", 1);
|
||||
liberator.editor.executeCommand("cmd_beginLine", 1);
|
||||
liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA);
|
||||
liberator.events.feedkeys("<Return>");
|
||||
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 += "<tr>";
|
||||
list += "<td> " + abbrev[tmplhs][i][0] + "</td>";
|
||||
list += "<td> " + vimperator.util.escapeHTML(tmplhs) + "</td>";
|
||||
list += "<td> " + vimperator.util.escapeHTML(abbrev[tmplhs][i][1]) + "</td>";
|
||||
list += "<td> " + liberator.util.escapeHTML(tmplhs) + "</td>";
|
||||
list += "<td> " + liberator.util.escapeHTML(abbrev[tmplhs][i][1]) + "</td>";
|
||||
list += "</tr>";
|
||||
}
|
||||
}
|
||||
@@ -855,11 +855,11 @@ vimperator.Editor = function () //{{{
|
||||
|
||||
if (!flagFound)
|
||||
{
|
||||
vimperator.echoerr("No abbreviations found");
|
||||
liberator.echoerr("No abbreviations found");
|
||||
return;
|
||||
}
|
||||
list += "</table>";
|
||||
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;
|
||||
},
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
106
content/find.js
106
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
|
||||
|
||||
130
content/hints.js
130
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; // <tab>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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
126
content/mail.js
126
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, ["<Return>", "i"],
|
||||
liberator.mappings.add(modes, ["<Return>", "i"],
|
||||
"Inspect (focus) message",
|
||||
function () { content.focus(); });
|
||||
|
||||
vimperator.mappings.add(modes, ["d", "<Del>"],
|
||||
liberator.mappings.add(modes, ["d", "<Del>"],
|
||||
"Move mail to Trash folder",
|
||||
function () { goDoCommand("cmd_delete"); });
|
||||
|
||||
vimperator.mappings.add(modes, ["j", "<Right>"],
|
||||
liberator.mappings.add(modes, ["j", "<Right>"],
|
||||
"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", "<Tab>"],
|
||||
liberator.mappings.add(modes, ["J", "<Tab>"],
|
||||
"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", "<Left>"],
|
||||
liberator.mappings.add(modes, ["k", "<Left>"],
|
||||
"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, ["<C-i>"],
|
||||
liberator.mappings.add(modes, ["<C-i>"],
|
||||
"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, ["<C-o>"],
|
||||
liberator.mappings.add(modes, ["<C-o>"],
|
||||
"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, ["<C-t>"],
|
||||
liberator.mappings.add(modes, ["<C-t>"],
|
||||
"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();
|
||||
}
|
||||
};
|
||||
//}}}
|
||||
|
||||
@@ -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 = /<Leader>/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 += "<tr>";
|
||||
list += "<td> " + modeSign + " " + vimperator.util.escapeHTML(maps[i].names[j]) + "</td>";
|
||||
list += "<td> " + modeSign + " " + liberator.util.escapeHTML(maps[i].names[j]) + "</td>";
|
||||
if (maps[i].rhs)
|
||||
list += "<td> "+ (maps[i].noremap ? "*" : " ") + "</td>"
|
||||
+ "<td>" + vimperator.util.escapeHTML(maps[i].rhs) + "</td>";
|
||||
+ "<td>" + liberator.util.escapeHTML(maps[i].rhs) + "</td>";
|
||||
list += "</tr>";
|
||||
}
|
||||
}
|
||||
list += "</table>";
|
||||
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
},
|
||||
|
||||
|
||||
@@ -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); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,74 +63,74 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
<commandset id="onVimperatorFocus"
|
||||
commandupdater="true"
|
||||
events="focus"
|
||||
oncommandupdate="vimperator.events.onFocusChange(event);"/>
|
||||
oncommandupdate="liberator.events.onFocusChange(event);"/>
|
||||
<commandset id="onVimperatorSelect"
|
||||
commandupdater="true"
|
||||
events="select"
|
||||
oncommandupdate="vimperator.events.onSelectionChange(event);"/>
|
||||
oncommandupdate="liberator.events.onSelectionChange(event);"/>
|
||||
|
||||
<keyset id="mainKeyset">
|
||||
<key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':', '', vimperator.modes.EX);" modifiers=""/>
|
||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="vimperator.events.onEscape();"/>
|
||||
<!-- other keys are handled inside vimperator.js event loop -->
|
||||
<key id="key_open_vimbar" key=":" oncommand="liberator.commandline.open(':', '', liberator.modes.EX);" modifiers=""/>
|
||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="liberator.events.onEscape();"/>
|
||||
<!-- other keys are handled inside the event loop in events.js -->
|
||||
</keyset>
|
||||
|
||||
<statusbar id="status-bar" class="hl-StatusLine">
|
||||
<hbox insertafter="statusTextBox" id="vimperator-statusline" flex="1" height="10" hidden="false" align="center">
|
||||
<statusbarpanel class="plain" id="vimperator-statusline-field-url" readonly="false" flex="1" crop="end"/>
|
||||
<statusbarpanel class="plain" id="vimperator-statusline-field-inputbuffer" flex="0"/>
|
||||
<statusbarpanel class="plain" id="vimperator-statusline-field-progress" flex="0"/>
|
||||
<statusbarpanel class="plain" id="vimperator-statusline-field-tabcount" flex="0"/>
|
||||
<statusbarpanel class="plain" id="vimperator-statusline-field-bufferposition" flex="0"/>
|
||||
<hbox insertafter="statusTextBox" id="liberator-statusline" flex="1" height="10" hidden="false" align="center">
|
||||
<statusbarpanel class="plain" id="liberator-statusline-field-url" readonly="false" flex="1" crop="end"/>
|
||||
<statusbarpanel class="plain" id="liberator-statusline-field-inputbuffer" flex="0"/>
|
||||
<statusbarpanel class="plain" id="liberator-statusline-field-progress" flex="0"/>
|
||||
<statusbarpanel class="plain" id="liberator-statusline-field-tabcount" flex="0"/>
|
||||
<statusbarpanel class="plain" id="liberator-statusline-field-bufferposition" flex="0"/>
|
||||
</hbox>
|
||||
<!-- just hide them since other elements expect them -->
|
||||
<statusbarpanel id="statusText" hidden="true"/>
|
||||
<statusbarpanel id="statusbarpanel-progress" hidden="true"/>
|
||||
</statusbar>
|
||||
|
||||
<vbox id="vimperator-container" hidden="false">
|
||||
<listbox id="vimperator-bufferwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||
onclick= "vimperator.bufferwindow.onEvent(event);"
|
||||
ondblclick="vimperator.bufferwindow.onEvent(event);"
|
||||
onkeydown= "vimperator.bufferwindow.onEvent(event);">
|
||||
<vbox id="liberator-container" hidden="false">
|
||||
<listbox id="liberator-bufferwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||
onclick= "liberator.bufferwindow.onEvent(event);"
|
||||
ondblclick="liberator.bufferwindow.onEvent(event);"
|
||||
onkeydown= "liberator.bufferwindow.onEvent(event);">
|
||||
<listcols>
|
||||
<listcol flex="1" width="50%"/>
|
||||
<listcol flex="1" width="50%"/>
|
||||
</listcols>
|
||||
</listbox>
|
||||
|
||||
<listbox id="vimperator-previewwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||
onclick= "vimperator.previewwindow.onEvent(event);"
|
||||
ondblclick="vimperator.previewwindow.onEvent(event);"
|
||||
onkeydown= "vimperator.previewwindow.onEvent(event);">
|
||||
<listbox id="liberator-previewwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||
onclick= "liberator.previewwindow.onEvent(event);"
|
||||
ondblclick="liberator.previewwindow.onEvent(event);"
|
||||
onkeydown= "liberator.previewwindow.onEvent(event);">
|
||||
<listcols>
|
||||
<listcol flex="1" width="50%"/>
|
||||
<listcol flex="1" width="50%"/>
|
||||
</listcols>
|
||||
</listbox>
|
||||
|
||||
<iframe id="vimperator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
||||
onclick="vimperator.commandline.onMultilineOutputEvent(event)"/>
|
||||
<iframe id="liberator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
||||
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
||||
|
||||
<listbox id="vimperator-completion" class="plain" rows="1" flex="1" hidden="true">
|
||||
<listbox id="liberator-completion" class="plain" rows="1" flex="1" hidden="true">
|
||||
<listcols>
|
||||
<listcol flex="1" width="50%"/>
|
||||
<listcol flex="1" width="50%"/>
|
||||
</listcols>
|
||||
</listbox>
|
||||
|
||||
<hbox insertafter="status-bar" id="vimperator-commandline" hidden="false" class="hl-Normal">
|
||||
<label class="plain" id="vimperator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox class="plain" id="vimperator-commandline-command" flex="1" type="timed" timeout="100"
|
||||
oninput="vimperator.commandline.onEvent(event);"
|
||||
onfocus="vimperator.commandline.onEvent(event);"
|
||||
onblur="vimperator.commandline.onEvent(event);"/>
|
||||
<hbox insertafter="status-bar" id="liberator-commandline" hidden="false" class="hl-Normal">
|
||||
<label class="plain" id="liberator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox class="plain" id="liberator-commandline-command" flex="1" type="timed" timeout="100"
|
||||
oninput="liberator.commandline.onEvent(event);"
|
||||
onfocus="liberator.commandline.onEvent(event);"
|
||||
onblur="liberator.commandline.onEvent(event);"/>
|
||||
</hbox>
|
||||
|
||||
<textbox id="vimperator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
||||
onkeypress="vimperator.commandline.onMultilineInputEvent(event);"
|
||||
oninput="vimperator.commandline.onMultilineInputEvent(event);"
|
||||
onblur="vimperator.commandline.onMultilineInputEvent(event);"/>
|
||||
<textbox id="liberator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
||||
onkeypress="liberator.commandline.onMultilineInputEvent(event);"
|
||||
oninput="liberator.commandline.onMultilineInputEvent(event);"
|
||||
onblur="liberator.commandline.onMultilineInputEvent(event);"/>
|
||||
</vbox>
|
||||
</window>
|
||||
|
||||
|
||||
@@ -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.options.add() instead
|
||||
vimperator.Option = function (names, description, type, defaultValue, getter, setter, validator, completer)
|
||||
// liberator.options.add() instead
|
||||
liberator.Option = function (names, description, type, defaultValue, getter, setter, validator, completer)
|
||||
{
|
||||
if (!names || !type)
|
||||
return null;
|
||||
@@ -103,7 +103,7 @@ vimperator.Option = function (names, description, type, defaultValue, getter, se
|
||||
}; //}}}
|
||||
|
||||
|
||||
vimperator.Options = function () //{{{
|
||||
liberator.Options = function () //{{{
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
@@ -122,26 +122,26 @@ vimperator.Options = function () //{{{
|
||||
if (type == prefService.PREF_INVALID || type == prefService.PREF_STRING)
|
||||
prefService.setCharPref(name, value);
|
||||
else if (type == prefService.PREF_INT)
|
||||
vimperator.echoerr("E521: Number required after =: " + name + "=" + value);
|
||||
liberator.echoerr("E521: Number required after =: " + name + "=" + value);
|
||||
else
|
||||
vimperator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
||||
liberator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
||||
break;
|
||||
case "number":
|
||||
if (type == prefService.PREF_INVALID || type == prefService.PREF_INT)
|
||||
prefService.setIntPref(name, value);
|
||||
else
|
||||
vimperator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
||||
liberator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
||||
break;
|
||||
case "boolean":
|
||||
if (type == prefService.PREF_INVALID || type == prefService.PREF_BOOL)
|
||||
prefService.setBoolPref(name, value);
|
||||
else if (type == prefService.PREF_INT)
|
||||
vimperator.echoerr("E521: Number required after =: " + name + "=" + value);
|
||||
liberator.echoerr("E521: Number required after =: " + name + "=" + value);
|
||||
else
|
||||
vimperator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
||||
liberator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
||||
break;
|
||||
default:
|
||||
vimperator.echoerr("Unknown preference type: " + typeof value + " (" + name + "=" + value + ")");
|
||||
liberator.echoerr("Unknown preference type: " + typeof value + " (" + name + "=" + value + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,16 +200,16 @@ vimperator.Options = function () //{{{
|
||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
vimperator.commands.add(["let"],
|
||||
liberator.commands.add(["let"],
|
||||
"Set or list a variable",
|
||||
function (args)
|
||||
{
|
||||
if (!args)
|
||||
{
|
||||
var str = "";
|
||||
for (var i in vimperator.globalVariables)
|
||||
for (var i in liberator.globalVariables)
|
||||
{
|
||||
var value = vimperator.globalVariables[i];
|
||||
var value = liberator.globalVariables[i];
|
||||
if (typeof value == "number")
|
||||
var prefix = "#";
|
||||
else if (typeof value == "function")
|
||||
@@ -220,9 +220,9 @@ vimperator.Options = function () //{{{
|
||||
str += "<tr><td style=\"width: 200px;\">" + i + "</td><td>" + prefix + value + "</td>\n";
|
||||
}
|
||||
if (str)
|
||||
vimperator.echo("<table>" + str + "</table>", vimperator.commandline.FORCE_MULTILINE);
|
||||
liberator.echo("<table>" + str + "</table>", liberator.commandline.FORCE_MULTILINE);
|
||||
else
|
||||
vimperator.echo("No variables found");
|
||||
liberator.echo("No variables found");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -232,17 +232,17 @@ vimperator.Options = function () //{{{
|
||||
{
|
||||
if (!matches[1])
|
||||
{
|
||||
var reference = vimperator.variableReference(matches[2]);
|
||||
var reference = liberator.variableReference(matches[2]);
|
||||
if (!reference[0] && matches[3])
|
||||
{
|
||||
vimperator.echoerr("E121: Undefined variable: " + matches[2]);
|
||||
liberator.echoerr("E121: Undefined variable: " + matches[2]);
|
||||
return;
|
||||
}
|
||||
|
||||
var expr = vimperator.eval(matches[4]);
|
||||
var expr = liberator.eval(matches[4]);
|
||||
if (typeof expr === undefined)
|
||||
{
|
||||
vimperator.echoerr("E15: Invalid expression: " + matches[4]);
|
||||
liberator.echoerr("E15: Invalid expression: " + matches[4]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -250,7 +250,7 @@ vimperator.Options = function () //{{{
|
||||
if (!reference[0])
|
||||
{
|
||||
if (reference[2] == "g")
|
||||
reference[0] = vimperator.globalVariables;
|
||||
reference[0] = liberator.globalVariables;
|
||||
else
|
||||
return; // for now
|
||||
}
|
||||
@@ -272,10 +272,10 @@ vimperator.Options = function () //{{{
|
||||
// 1 - name
|
||||
else if (matches = args.match(/^\s*([\w:]+)\s*$/))
|
||||
{
|
||||
var reference = vimperator.variableReference(matches[1]);
|
||||
var reference = liberator.variableReference(matches[1]);
|
||||
if (!reference[0])
|
||||
{
|
||||
vimperator.echoerr("E121: Undefined variable: " + matches[1]);
|
||||
liberator.echoerr("E121: Undefined variable: " + matches[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -286,12 +286,12 @@ vimperator.Options = function () //{{{
|
||||
var prefix = "*";
|
||||
else
|
||||
var prefix = "";
|
||||
vimperator.echo(reference[1] + "\t\t" + prefix + value);
|
||||
liberator.echo(reference[1] + "\t\t" + prefix + value);
|
||||
}
|
||||
});
|
||||
|
||||
vimperator.commands.add(["pref[erences]", "prefs"],
|
||||
"Show " + vimperator.config.hostApplication + " Preferences",
|
||||
liberator.commands.add(["pref[erences]", "prefs"],
|
||||
"Show " + liberator.config.hostApplication + " Preferences",
|
||||
function (args, special, count, modifiers)
|
||||
{
|
||||
if (!args)
|
||||
@@ -299,25 +299,25 @@ vimperator.Options = function () //{{{
|
||||
// TODO: copy these snippets to more function which should work with :tab xxx
|
||||
if (modifiers && modifiers.inTab)
|
||||
{
|
||||
vimperator.open(special ? "about:config" :
|
||||
"chrome://browser/content/preferences/preferences.xul", vimperator.NEW_TAB);
|
||||
liberator.open(special ? "about:config" :
|
||||
"chrome://browser/content/preferences/preferences.xul", liberator.NEW_TAB);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (special) // open firefox settings gui dialog
|
||||
vimperator.open("about:config", vimperator.CURRENT_TAB);
|
||||
liberator.open("about:config", liberator.CURRENT_TAB);
|
||||
else
|
||||
openPreferences();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vimperator.echoerr("E488: Trailing characters");
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: support setting multiple options at once
|
||||
vimperator.commands.add(["se[t]"],
|
||||
liberator.commands.add(["se[t]"],
|
||||
"Set an option",
|
||||
function (args, special, count, modifiers)
|
||||
{
|
||||
@@ -341,13 +341,13 @@ vimperator.Options = function () //{{{
|
||||
invertBoolean = true;
|
||||
|
||||
if (name == "all" && reset)
|
||||
vimperator.echoerr("You can't reset all the firefox options, it could make your browser unusable.");
|
||||
liberator.echoerr("You can't reset all the firefox options, it could make your browser unusable.");
|
||||
else if (name == "all")
|
||||
vimperator.options.listPrefs(onlyNonDefault, "");
|
||||
liberator.options.listPrefs(onlyNonDefault, "");
|
||||
else if (reset)
|
||||
vimperator.options.resetPref(name);
|
||||
liberator.options.resetPref(name);
|
||||
else if (invertBoolean)
|
||||
vimperator.options.invertPref(name);
|
||||
liberator.options.invertPref(name);
|
||||
else if (matches[3])
|
||||
{
|
||||
var value = matches[5];
|
||||
@@ -367,11 +367,11 @@ vimperator.Options = function () //{{{
|
||||
if (!isNaN(valueInt))
|
||||
value = valueInt;
|
||||
}
|
||||
vimperator.options.setPref(name, value);
|
||||
liberator.options.setPref(name, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
vimperator.options.listPrefs(onlyNonDefault, name);
|
||||
liberator.options.listPrefs(onlyNonDefault, name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -387,7 +387,7 @@ vimperator.Options = function () //{{{
|
||||
var matches = args.match(/^\s*(no|inv)?([a-z]+)([?&!])?\s*(([+-^]?)=(.*))?\s*$/);
|
||||
if (!matches)
|
||||
{
|
||||
vimperator.echoerr("E518: Unknown option: " + args);
|
||||
liberator.echoerr("E518: Unknown option: " + args);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -400,10 +400,10 @@ vimperator.Options = function () //{{{
|
||||
if (name == "all")
|
||||
all = true;
|
||||
|
||||
var option = vimperator.options.get(name);
|
||||
var option = liberator.options.get(name);
|
||||
if (!option && !all)
|
||||
{
|
||||
vimperator.echoerr("E518: Unknown option: " + args);
|
||||
liberator.echoerr("E518: Unknown option: " + args);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ vimperator.Options = function () //{{{
|
||||
{
|
||||
if (all)
|
||||
{
|
||||
for (let option in vimperator.options)
|
||||
for (let option in liberator.options)
|
||||
option.reset();
|
||||
}
|
||||
else
|
||||
@@ -445,14 +445,14 @@ vimperator.Options = function () //{{{
|
||||
{
|
||||
if (all)
|
||||
{
|
||||
vimperator.options.list(onlyNonDefault);
|
||||
liberator.options.list(onlyNonDefault);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (option.type == "boolean")
|
||||
vimperator.echo((option.value ? " " : "no") + option.name);
|
||||
liberator.echo((option.value ? " " : "no") + option.name);
|
||||
else
|
||||
vimperator.echo(" " + option.name + "=" + option.value);
|
||||
liberator.echo(" " + option.name + "=" + option.value);
|
||||
}
|
||||
}
|
||||
// write access
|
||||
@@ -469,7 +469,7 @@ vimperator.Options = function () //{{{
|
||||
case "boolean":
|
||||
if (valueGiven)
|
||||
{
|
||||
vimperator.echoerr("E474: Invalid argument: " + args);
|
||||
liberator.echoerr("E474: Invalid argument: " + args);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ vimperator.Options = function () //{{{
|
||||
|
||||
if (isNaN(value))
|
||||
{
|
||||
vimperator.echoerr("E521: Number required after =: " + args);
|
||||
liberator.echoerr("E521: Number required after =: " + args);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -552,27 +552,27 @@ vimperator.Options = function () //{{{
|
||||
break;
|
||||
|
||||
default:
|
||||
vimperator.echoerr("E685: Internal error: option type `" + option.type + "' not supported");
|
||||
liberator.echoerr("E685: Internal error: option type `" + option.type + "' not supported");
|
||||
}
|
||||
|
||||
if (option.isValidValue(newValue))
|
||||
option.value = newValue;
|
||||
else
|
||||
// FIXME: need to be able to specify more specific errors
|
||||
vimperator.echoerr("E474: Invalid argument: " + args);
|
||||
liberator.echoerr("E474: Invalid argument: " + args);
|
||||
}
|
||||
},
|
||||
{
|
||||
completer: function (filter, special) { return vimperator.completion.option(filter, special); }
|
||||
completer: function (filter, special) { return liberator.completion.option(filter, special); }
|
||||
});
|
||||
|
||||
vimperator.commands.add(["unl[et]"],
|
||||
liberator.commands.add(["unl[et]"],
|
||||
"Delete a variable",
|
||||
function (args, special)
|
||||
{
|
||||
if (!args)
|
||||
{
|
||||
vimperator.echoerr("E471: Argument required");
|
||||
liberator.echoerr("E471: Argument required");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -581,11 +581,11 @@ vimperator.Options = function () //{{{
|
||||
var length = names.length;
|
||||
for (var i = 0, name = names[i]; i < length; name = names[++i])
|
||||
{
|
||||
var reference = vimperator.variableReference(name);
|
||||
var reference = liberator.variableReference(name);
|
||||
if (!reference[0])
|
||||
{
|
||||
if (!special)
|
||||
vimperator.echoerr("E108: No such variable: " + name);
|
||||
liberator.echoerr("E108: No such variable: " + name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -612,10 +612,10 @@ vimperator.Options = function () //{{{
|
||||
if (!extraInfo)
|
||||
extraInfo = {};
|
||||
|
||||
var option = new vimperator.Option(names, description, type, defaultValue,
|
||||
var option = new liberator.Option(names, description, type, defaultValue,
|
||||
extraInfo.getter, extraInfo.setter, extraInfo.validator);
|
||||
|
||||
// quickly access options with vimperator.options["wildmode"]:
|
||||
// quickly access options with liberator.options["wildmode"]:
|
||||
this.__defineGetter__(option.name, function () { return option.value; });
|
||||
this.__defineSetter__(option.name, function (value) { option.value = value; });
|
||||
|
||||
@@ -643,7 +643,7 @@ vimperator.Options = function () //{{{
|
||||
|
||||
list: function (onlyNonDefault)
|
||||
{
|
||||
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
|
||||
var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
||||
"<table><tr align=\"left\" class=\"hl-Title\"><th>--- Options ---</th></tr>";
|
||||
var name, value, def;
|
||||
|
||||
@@ -668,10 +668,10 @@ vimperator.Options = function () //{{{
|
||||
if (value != def)
|
||||
{
|
||||
name = "<span style=\"font-weight: bold\">" + name + "</span>";
|
||||
value = vimperator.util.colorize(value, false) + "<span style=\"color: gray\"> (default: " + def + ")</span>";
|
||||
value = liberator.util.colorize(value, false) + "<span style=\"color: gray\"> (default: " + def + ")</span>";
|
||||
}
|
||||
else
|
||||
value = vimperator.util.colorize(value, false);
|
||||
value = liberator.util.colorize(value, false);
|
||||
|
||||
list += "<tr><td>" + " " + name + "=" + value + "</td></tr>";
|
||||
}
|
||||
@@ -679,7 +679,7 @@ vimperator.Options = function () //{{{
|
||||
|
||||
list += "</table>";
|
||||
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
},
|
||||
|
||||
listPrefs: function (onlyNonDefault, filter)
|
||||
@@ -689,8 +689,8 @@ vimperator.Options = function () //{{{
|
||||
|
||||
var prefArray = prefService.getChildList("", {value: 0});
|
||||
prefArray.sort();
|
||||
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
|
||||
"<table><tr align=\"left\" class=\"hl-Title\"><th>--- " + vimperator.config.hostApplication +
|
||||
var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
||||
"<table><tr align=\"left\" class=\"hl-Title\"><th>--- " + liberator.config.hostApplication +
|
||||
" Options ---</th></tr>";
|
||||
var name, value, defaultValue;
|
||||
|
||||
@@ -704,7 +704,7 @@ vimperator.Options = function () //{{{
|
||||
if (typeof value == "string")
|
||||
value = value.substr(0, 100).replace(/\n/g, " ");
|
||||
|
||||
value = vimperator.util.colorize(value, true);
|
||||
value = liberator.util.colorize(value, true);
|
||||
defaultValue = loadPreference(name, null, true);
|
||||
|
||||
if (defaultValue == null)
|
||||
@@ -721,7 +721,7 @@ vimperator.Options = function () //{{{
|
||||
}
|
||||
}
|
||||
list += "</table>";
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
},
|
||||
|
||||
getPref: function (name, forcedDefault)
|
||||
@@ -745,7 +745,7 @@ vimperator.Options = function () //{{{
|
||||
if (prefService.getPrefType(name) == prefService.PREF_BOOL)
|
||||
this.setPref(name, !this.getPref(name));
|
||||
else
|
||||
vimperator.echoerr("E488: Trailing characters: " + name + "!");
|
||||
liberator.echoerr("E488: Trailing characters: " + name + "!");
|
||||
}
|
||||
};
|
||||
}; //}}}
|
||||
|
||||
236
content/tabs.js
236
content/tabs.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.Tabs = function () //{{{
|
||||
liberator.Tabs = function () //{{{
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
@@ -78,7 +78,7 @@ vimperator.Tabs = function () //{{{
|
||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
vimperator.options.add(["activate", "act"],
|
||||
liberator.options.add(["activate", "act"],
|
||||
"Define when tabs are automatically activated",
|
||||
"stringlist", "homepage,quickmark,tabopen,paste",
|
||||
{
|
||||
@@ -88,7 +88,7 @@ vimperator.Tabs = function () //{{{
|
||||
}
|
||||
});
|
||||
|
||||
vimperator.options.add(["popups", "pps"],
|
||||
liberator.options.add(["popups", "pps"],
|
||||
"Where to show requested popup windows",
|
||||
"number", 1,
|
||||
{
|
||||
@@ -98,13 +98,13 @@ vimperator.Tabs = function () //{{{
|
||||
[0, 3], // in a new tab
|
||||
[2, 3], // in a new window if it has specified sizes
|
||||
[1, 2]];// always in new window
|
||||
vimperator.options.setPref("browser.link.open_newwindow.restriction", values[value][0]);
|
||||
vimperator.options.setPref("browser.link.open_newwindow", values[value][1]);
|
||||
liberator.options.setPref("browser.link.open_newwindow.restriction", values[value][0]);
|
||||
liberator.options.setPref("browser.link.open_newwindow", values[value][1]);
|
||||
},
|
||||
validator: function (value) { return (value >= 0 && value <= 3); }
|
||||
});
|
||||
|
||||
vimperator.options.add(["showtabline", "stal"],
|
||||
liberator.options.add(["showtabline", "stal"],
|
||||
"Control when to show the tab bar of opened web pages",
|
||||
"number", 2,
|
||||
{
|
||||
@@ -120,12 +120,12 @@ vimperator.Tabs = function () //{{{
|
||||
}
|
||||
else if (value == 1)
|
||||
{
|
||||
vimperator.options.setPref("browser.tabs.autoHide", true);
|
||||
liberator.options.setPref("browser.tabs.autoHide", true);
|
||||
tabs.collapsed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
vimperator.options.setPref("browser.tabs.autoHide", false);
|
||||
liberator.options.setPref("browser.tabs.autoHide", false);
|
||||
tabs.collapsed = false;
|
||||
}
|
||||
},
|
||||
@@ -136,78 +136,78 @@ vimperator.Tabs = function () //{{{
|
||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["b"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["b"],
|
||||
"Open a prompt to switch buffers",
|
||||
function () { vimperator.commandline.open(":", "buffer! ", vimperator.modes.EX); });
|
||||
function () { liberator.commandline.open(":", "buffer! ", liberator.modes.EX); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["B"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["B"],
|
||||
"Show buffer list",
|
||||
function () { vimperator.tabs.list(false); });
|
||||
function () { liberator.tabs.list(false); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["d"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["d"],
|
||||
"Delete current buffer",
|
||||
function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); },
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
function (count) { liberator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["D"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["D"],
|
||||
"Delete current buffer, focus tab to the left",
|
||||
function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); },
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
function (count) { liberator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gb"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gb"],
|
||||
"Repeat last :buffer[!] command",
|
||||
function (count) { vimperator.tabs.switchTo(null, null, count, false); },
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
function (count) { liberator.tabs.switchTo(null, null, count, false); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gB"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gB"],
|
||||
"Repeat last :buffer[!] command in reverse direction",
|
||||
function (count) { vimperator.tabs.switchTo(null, null, count, true); },
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
function (count) { liberator.tabs.switchTo(null, null, count, true); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["g0", "g^"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["g0", "g^"],
|
||||
"Go to the first tab",
|
||||
function (count) { vimperator.tabs.select(0); });
|
||||
function (count) { liberator.tabs.select(0); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["g$"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["g$"],
|
||||
"Go to the last tab",
|
||||
function (count) { vimperator.tabs.select("$"); });
|
||||
function (count) { liberator.tabs.select("$"); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gt", "<C-n>", "<C-Tab>", "<C-PageDown>"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gt", "<C-n>", "<C-Tab>", "<C-PageDown>"],
|
||||
"Go to the next tab",
|
||||
function (count) { vimperator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); },
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
function (count) { liberator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gT", "<C-p>", "<C-S-Tab>", "<C-PageUp>"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gT", "<C-p>", "<C-S-Tab>", "<C-PageUp>"],
|
||||
"Go to previous tab",
|
||||
function (count) { vimperator.tabs.select("-" + (count < 1 ? 1 : count), true); },
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
function (count) { liberator.tabs.select("-" + (count < 1 ? 1 : count), true); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["u"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["u"],
|
||||
"Undo closing of a tab",
|
||||
function (count) { vimperator.commands.get("undo").execute("", false, count); },
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
function (count) { liberator.commands.get("undo").execute("", false, count); },
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["<C-^>", "<C-6>"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["<C-^>", "<C-6>"],
|
||||
"Select the alternate tab",
|
||||
function ()
|
||||
{
|
||||
if (vimperator.tabs.alternate == null || vimperator.tabs.getTab() == vimperator.tabs.alternate)
|
||||
if (liberator.tabs.alternate == null || liberator.tabs.getTab() == liberator.tabs.alternate)
|
||||
{
|
||||
vimperator.echoerr("E23: No alternate page");
|
||||
liberator.echoerr("E23: No alternate page");
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: this currently relies on v.tabs.index() returning the
|
||||
// currently selected tab index when passed null
|
||||
var index = vimperator.tabs.index(vimperator.tabs.alternate);
|
||||
var index = liberator.tabs.index(liberator.tabs.alternate);
|
||||
|
||||
// TODO: since a tab close is more like a bdelete for us we
|
||||
// should probably reopen the closed tab when a 'deleted'
|
||||
// alternate is selected
|
||||
if (index == -1)
|
||||
vimperator.echoerr("E86: Buffer does not exist"); // TODO: This should read "Buffer N does not exist"
|
||||
liberator.echoerr("E86: Buffer does not exist"); // TODO: This should read "Buffer N does not exist"
|
||||
else
|
||||
vimperator.tabs.select(index);
|
||||
liberator.tabs.select(index);
|
||||
});
|
||||
|
||||
|
||||
@@ -215,127 +215,127 @@ vimperator.Tabs = function () //{{{
|
||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
vimperator.commands.add(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
|
||||
liberator.commands.add(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
|
||||
"Delete current buffer",
|
||||
function (args, special, count)
|
||||
{
|
||||
vimperator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
|
||||
liberator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
|
||||
});
|
||||
|
||||
vimperator.commands.add(["b[uffer]"],
|
||||
liberator.commands.add(["b[uffer]"],
|
||||
"Switch to a buffer",
|
||||
function (args, special) { vimperator.tabs.switchTo(args, special); },
|
||||
{ completer: function (filter) { return vimperator.completion.buffer(filter); } });
|
||||
function (args, special) { liberator.tabs.switchTo(args, special); },
|
||||
{ completer: function (filter) { return liberator.completion.buffer(filter); } });
|
||||
|
||||
vimperator.commands.add(["buffers", "files", "ls", "tabs"],
|
||||
liberator.commands.add(["buffers", "files", "ls", "tabs"],
|
||||
"Show a list of all buffers",
|
||||
function (args, special)
|
||||
{
|
||||
if (args)
|
||||
{
|
||||
vimperator.echoerr("E488: Trailing characters");
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
return;
|
||||
}
|
||||
|
||||
vimperator.tabs.list(special);
|
||||
liberator.tabs.list(special);
|
||||
});
|
||||
|
||||
vimperator.commands.add(["quita[ll]", "qa[ll]"],
|
||||
"Quit " + vimperator.config.appName,
|
||||
function () { vimperator.quit(false); });
|
||||
liberator.commands.add(["quita[ll]", "qa[ll]"],
|
||||
"Quit " + liberator.config.appName,
|
||||
function () { liberator.quit(false); });
|
||||
|
||||
vimperator.commands.add(["reloada[ll]"],
|
||||
liberator.commands.add(["reloada[ll]"],
|
||||
"Reload all tab pages",
|
||||
function (args, special) { vimperator.tabs.reloadAll(special); });
|
||||
function (args, special) { liberator.tabs.reloadAll(special); });
|
||||
|
||||
vimperator.commands.add(["tab"],
|
||||
liberator.commands.add(["tab"],
|
||||
"Execute a command and tell it to output in a new tab",
|
||||
function (args) { vimperator.execute(args, { inTab: true }); },
|
||||
{ completer: function (filter) { return vimperator.completion.command(filter); } });
|
||||
function (args) { liberator.execute(args, { inTab: true }); },
|
||||
{ completer: function (filter) { return liberator.completion.command(filter); } });
|
||||
|
||||
vimperator.commands.add(["tabl[ast]"],
|
||||
liberator.commands.add(["tabl[ast]"],
|
||||
"Switch to the last tab",
|
||||
function () { vimperator.tabs.select("$", false); });
|
||||
function () { liberator.tabs.select("$", false); });
|
||||
|
||||
vimperator.commands.add(["tabm[ove]"],
|
||||
liberator.commands.add(["tabm[ove]"],
|
||||
"Move the current tab after tab N",
|
||||
function (args, special)
|
||||
{
|
||||
// FIXME: tabmove! N should probably produce an error
|
||||
if (!/^([+-]?\d+|)$/.test(args))
|
||||
{
|
||||
vimperator.echoerr("E488: Trailing characters");
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args)
|
||||
args = "$"; // if not specified, move to the last tab
|
||||
|
||||
vimperator.tabs.move(getBrowser().mCurrentTab, args, special);
|
||||
liberator.tabs.move(getBrowser().mCurrentTab, args, special);
|
||||
});
|
||||
|
||||
// TODO: count support
|
||||
vimperator.commands.add(["tabn[ext]", "tn[ext]"],
|
||||
liberator.commands.add(["tabn[ext]", "tn[ext]"],
|
||||
"Switch to the next or [count]th tab",
|
||||
function (args)
|
||||
{
|
||||
if (!args)
|
||||
{
|
||||
vimperator.tabs.select("+1", true);
|
||||
liberator.tabs.select("+1", true);
|
||||
}
|
||||
else if (/^\d+$/.test(args))
|
||||
{
|
||||
var index = parseInt(args, 10) - 1;
|
||||
if (index < vimperator.tabs.count)
|
||||
vimperator.tabs.select(index, true);
|
||||
if (index < liberator.tabs.count)
|
||||
liberator.tabs.select(index, true);
|
||||
else
|
||||
vimperator.beep();
|
||||
liberator.beep();
|
||||
}
|
||||
else
|
||||
{
|
||||
vimperator.echoerr("E488: Trailing characters");
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
vimperator.commands.add(["tabo[nly]"],
|
||||
liberator.commands.add(["tabo[nly]"],
|
||||
"Close all other tabs",
|
||||
function () { vimperator.tabs.keepOnly(getBrowser().mCurrentTab); });
|
||||
function () { liberator.tabs.keepOnly(getBrowser().mCurrentTab); });
|
||||
|
||||
vimperator.commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
|
||||
liberator.commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
|
||||
"Open one or more URLs in a new tab",
|
||||
function (args, special)
|
||||
{
|
||||
var where = special ? vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB;
|
||||
if (/\btabopen\b/.test(vimperator.options["activate"]))
|
||||
where = special ? vimperator.NEW_BACKGROUND_TAB : vimperator.NEW_TAB;
|
||||
var where = special ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
|
||||
if (/\btabopen\b/.test(liberator.options["activate"]))
|
||||
where = special ? liberator.NEW_BACKGROUND_TAB : liberator.NEW_TAB;
|
||||
|
||||
if (args)
|
||||
vimperator.open(args, where);
|
||||
liberator.open(args, where);
|
||||
else
|
||||
vimperator.open("about:blank", where);
|
||||
liberator.open("about:blank", where);
|
||||
},
|
||||
{ completer: function (filter) { return vimperator.completion.url(filter); } });
|
||||
{ completer: function (filter) { return liberator.completion.url(filter); } });
|
||||
|
||||
// TODO: count support
|
||||
vimperator.commands.add(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"],
|
||||
liberator.commands.add(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"],
|
||||
"Switch to the previous tab or go [count] tabs back",
|
||||
function (args)
|
||||
{
|
||||
if (!args)
|
||||
vimperator.tabs.select("-1", true);
|
||||
liberator.tabs.select("-1", true);
|
||||
else if (/^\d+$/.test(args))
|
||||
vimperator.tabs.select("-" + args, true); // FIXME: urgh!
|
||||
liberator.tabs.select("-" + args, true); // FIXME: urgh!
|
||||
else
|
||||
vimperator.echoerr("E488: Trailing characters");
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
});
|
||||
|
||||
vimperator.commands.add(["tabr[ewind]", "tabfir[st]"],
|
||||
liberator.commands.add(["tabr[ewind]", "tabfir[st]"],
|
||||
"Switch to the first tab",
|
||||
function () { vimperator.tabs.select(0, false); });
|
||||
function () { liberator.tabs.select(0, false); });
|
||||
|
||||
// TODO: extract common functionality of "undoall"
|
||||
vimperator.commands.add(["u[ndo]"],
|
||||
liberator.commands.add(["u[ndo]"],
|
||||
"Undo closing of a tab",
|
||||
function (args, special, count)
|
||||
{
|
||||
@@ -371,25 +371,25 @@ vimperator.Tabs = function () //{{{
|
||||
// undoItems[i].image is also available if needed for favicons
|
||||
var url = undoItems[i].state.entries[0].url;
|
||||
var title = undoItems[i].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(["undoa[ll]"],
|
||||
liberator.commands.add(["undoa[ll]"],
|
||||
"Undo closing of all closed tabs",
|
||||
function (args, special, count)
|
||||
{
|
||||
if (count > -1)
|
||||
{
|
||||
vimperator.echoerr("E481: No range allowed");
|
||||
liberator.echoerr("E481: No range allowed");
|
||||
return;
|
||||
}
|
||||
if (special)
|
||||
{
|
||||
vimperator.echoerr("E477: No ! allowed");
|
||||
liberator.echoerr("E477: No ! allowed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -400,11 +400,11 @@ vimperator.Tabs = function () //{{{
|
||||
undoCloseTab(); // doesn't work with i as the index to undoCloseTab
|
||||
});
|
||||
|
||||
if (vimperator.has("session"))
|
||||
if (liberator.has("session"))
|
||||
{
|
||||
vimperator.commands.add(["wqa[ll]", "wq", "xa[ll]"],
|
||||
liberator.commands.add(["wqa[ll]", "wq", "xa[ll]"],
|
||||
"Save the session and quit",
|
||||
function () { vimperator.quit(true); });
|
||||
function () { liberator.quit(true); });
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
@@ -463,37 +463,37 @@ vimperator.Tabs = function () //{{{
|
||||
if (fullmode)
|
||||
{
|
||||
// toggle the special buffer preview window
|
||||
if (vimperator.bufferwindow.visible())
|
||||
if (liberator.bufferwindow.visible())
|
||||
{
|
||||
vimperator.bufferwindow.hide();
|
||||
liberator.bufferwindow.hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: move this to vimperator.buffers.get()
|
||||
var items = vimperator.completion.buffer("")[1];
|
||||
// TODO: move this to liberator.buffers.get()
|
||||
var items = liberator.completion.buffer("")[1];
|
||||
var number, indicator, title, url;
|
||||
|
||||
var list = ":" + (vimperator.util.escapeHTML(vimperator.commandline.getCommand()) || "buffers") + "<br/>" + "<table>";
|
||||
var list = ":" + (liberator.util.escapeHTML(liberator.commandline.getCommand()) || "buffers") + "<br/>" + "<table>";
|
||||
for (var i = 0; i < items.length; i++)
|
||||
{
|
||||
if (i == vimperator.tabs.index())
|
||||
if (i == liberator.tabs.index())
|
||||
indicator = " <span style=\"color: blue\">%</span> ";
|
||||
else if (i == vimperator.tabs.index(vimperator.tabs.alternate))
|
||||
else if (i == liberator.tabs.index(liberator.tabs.alternate))
|
||||
indicator = " <span style=\"color: blue\">#</span> ";
|
||||
else
|
||||
indicator = " ";
|
||||
|
||||
[number, title] = items[i][0].split(/:\s+/, 2);
|
||||
url = items[i][1];
|
||||
url = vimperator.util.escapeHTML(url);
|
||||
title = vimperator.util.escapeHTML(title);
|
||||
url = liberator.util.escapeHTML(url);
|
||||
title = liberator.util.escapeHTML(title);
|
||||
|
||||
list += "<tr><td align=\"right\"> " + number + "</td><td>" + indicator +
|
||||
"</td><td style=\"width: 250px; max-width: 500px; overflow: hidden;\">" + title +
|
||||
@@ -501,7 +501,7 @@ vimperator.Tabs = function () //{{{
|
||||
}
|
||||
list += "</table>";
|
||||
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -523,14 +523,14 @@ vimperator.Tabs = function () //{{{
|
||||
getBrowser().removeTab(tab);
|
||||
else
|
||||
{
|
||||
if (vimperator.buffer.URL != "about:blank" ||
|
||||
if (liberator.buffer.URL != "about:blank" ||
|
||||
getWebNavigation().sessionHistory.count > 0)
|
||||
{
|
||||
vimperator.open("about:blank", vimperator.NEW_BACKGROUND_TAB);
|
||||
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
||||
getBrowser().removeTab(tab);
|
||||
}
|
||||
else
|
||||
vimperator.beep();
|
||||
liberator.beep();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,10 +539,10 @@ vimperator.Tabs = function () //{{{
|
||||
|
||||
if (quitOnLastTab >= 1 && getBrowser().mTabs.length <= count)
|
||||
{
|
||||
if (vimperator.windows.length > 1)
|
||||
if (liberator.windows.length > 1)
|
||||
window.close();
|
||||
else
|
||||
vimperator.quit(quitOnLastTab == 2);
|
||||
liberator.quit(quitOnLastTab == 2);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -580,7 +580,7 @@ vimperator.Tabs = function () //{{{
|
||||
// FIXME:
|
||||
if (index === -1)
|
||||
{
|
||||
vimperator.beep(); // XXX: move to ex-handling?
|
||||
liberator.beep(); // XXX: move to ex-handling?
|
||||
return;
|
||||
}
|
||||
getBrowser().mTabContainer.selectedIndex = index;
|
||||
@@ -652,13 +652,13 @@ vimperator.Tabs = function () //{{{
|
||||
var match;
|
||||
if (match = buffer.match(/^(\d+):?/))
|
||||
{
|
||||
vimperator.tabs.select(parseInt(match[1], 10) - 1, false); // make it zero-based
|
||||
liberator.tabs.select(parseInt(match[1], 10) - 1, false); // make it zero-based
|
||||
return;
|
||||
}
|
||||
|
||||
var matches = [];
|
||||
var lowerBuffer = buffer.toLowerCase();
|
||||
var first = vimperator.tabs.index() + (reverse ? 0 : 1);
|
||||
var first = liberator.tabs.index() + (reverse ? 0 : 1);
|
||||
for (var i = 0; i < getBrowser().browsers.length; i++)
|
||||
{
|
||||
var index = (i + first) % getBrowser().browsers.length;
|
||||
@@ -666,7 +666,7 @@ vimperator.Tabs = function () //{{{
|
||||
var title = getBrowser().getBrowserAtIndex(index).contentDocument.title.toLowerCase();
|
||||
if (url == buffer)
|
||||
{
|
||||
vimperator.tabs.select(index, false);
|
||||
liberator.tabs.select(index, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -674,9 +674,9 @@ vimperator.Tabs = function () //{{{
|
||||
matches.push(index);
|
||||
}
|
||||
if (matches.length == 0)
|
||||
vimperator.echoerr("E94: No matching buffer for " + buffer);
|
||||
liberator.echoerr("E94: No matching buffer for " + buffer);
|
||||
else if (matches.length > 1 && !allowNonUnique)
|
||||
vimperator.echoerr("E93: More than one match for " + buffer);
|
||||
liberator.echoerr("E93: More than one match for " + buffer);
|
||||
else
|
||||
{
|
||||
if (reverse)
|
||||
@@ -688,7 +688,7 @@ vimperator.Tabs = function () //{{{
|
||||
else
|
||||
index = (count - 1) % matches.length;
|
||||
|
||||
vimperator.tabs.select(matches[index], false);
|
||||
liberator.tabs.select(matches[index], false);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
260
content/ui.js
260
content/ui.js
@@ -32,7 +32,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
* it consists of a prompt and command field
|
||||
* be sure to only create objects of this class when the chrome is ready
|
||||
*/
|
||||
vimperator.CommandLine = function () //{{{
|
||||
liberator.CommandLine = function () //{{{
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
@@ -40,14 +40,14 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning
|
||||
|
||||
var completionlist = new vimperator.InformationList("vimperator-completion", { minItems: 2, maxItems: 10 });
|
||||
var completionlist = new liberator.InformationList("liberator-completion", { minItems: 2, maxItems: 10 });
|
||||
var completions = [];
|
||||
|
||||
// TODO: clean this up when it's not 3am...
|
||||
var history = {
|
||||
get size() { return vimperator.options["history"]; },
|
||||
get size() { return liberator.options["history"]; },
|
||||
|
||||
get mode() { return (vimperator.modes.extended == vimperator.modes.EX) ? "cmd" : "search"; },
|
||||
get mode() { return (liberator.modes.extended == liberator.modes.EX) ? "cmd" : "search"; },
|
||||
|
||||
cmd: null, // ex command history
|
||||
|
||||
@@ -60,14 +60,14 @@ vimperator.CommandLine = function () //{{{
|
||||
load: function ()
|
||||
{
|
||||
// TODO: move to storage module
|
||||
this.cmd = vimperator.options.getPref("extensions.vimperator.commandline_cmd_history", "").split("\n");
|
||||
this.search = vimperator.options.getPref("extensions.vimperator.commandline_search_history", "").split("\n");
|
||||
this.cmd = liberator.options.getPref("extensions.vimperator.commandline_cmd_history", "").split("\n");
|
||||
this.search = liberator.options.getPref("extensions.vimperator.commandline_search_history", "").split("\n");
|
||||
},
|
||||
|
||||
save: function ()
|
||||
{
|
||||
vimperator.options.setPref("extensions.vimperator.commandline_cmd_history", this.cmd.join("\n"));
|
||||
vimperator.options.setPref("extensions.vimperator.commandline_search_history", this.search.join("\n"));
|
||||
liberator.options.setPref("extensions.vimperator.commandline_cmd_history", this.cmd.join("\n"));
|
||||
liberator.options.setPref("extensions.vimperator.commandline_search_history", this.search.join("\n"));
|
||||
},
|
||||
|
||||
add: function (str)
|
||||
@@ -103,19 +103,19 @@ vimperator.CommandLine = function () //{{{
|
||||
var completionIndex = UNINITIALIZED;
|
||||
|
||||
// the containing box for the promptWidget and commandWidget
|
||||
var commandlineWidget = document.getElementById("vimperator-commandline");
|
||||
var commandlineWidget = document.getElementById("liberator-commandline");
|
||||
// the prompt for the current command, for example : or /. Can be blank
|
||||
var promptWidget = document.getElementById("vimperator-commandline-prompt");
|
||||
var promptWidget = document.getElementById("liberator-commandline-prompt");
|
||||
// the command bar which contains the current command
|
||||
var commandWidget = document.getElementById("vimperator-commandline-command");
|
||||
var commandWidget = document.getElementById("liberator-commandline-command");
|
||||
|
||||
// the widget used for multiline output
|
||||
var multilineOutputWidget = document.getElementById("vimperator-multiline-output");
|
||||
var multilineOutputWidget = document.getElementById("liberator-multiline-output");
|
||||
multilineOutputWidget.contentDocument.body.setAttribute("style", "margin: 0px; font-family: -moz-fixed;"); // get rid of the default border
|
||||
multilineOutputWidget.contentDocument.body.innerHTML = "";
|
||||
|
||||
// the widget used for multiline intput
|
||||
var multilineInputWidget = document.getElementById("vimperator-multiline-input");
|
||||
var multilineInputWidget = document.getElementById("liberator-multiline-input");
|
||||
|
||||
// we need to save the mode which were in before opening the command line
|
||||
// this is then used if we focus the command line again without the "official"
|
||||
@@ -180,16 +180,16 @@ vimperator.CommandLine = function () //{{{
|
||||
multilineOutputWidget.collapsed = true;
|
||||
}
|
||||
|
||||
var id = vimperator.config.mainWindowID || "main-window";
|
||||
var id = liberator.config.mainWindowID || "main-window";
|
||||
var fontSize = document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue("font-size");
|
||||
multilineOutputWidget.contentDocument.body.setAttribute("style", "font-size: " + fontSize);
|
||||
|
||||
multilineOutputWidget.contentDocument.body.innerHTML = output;
|
||||
multilineOutputWidget.contentDocument.body.id = "vimperator-multiline-output-content";
|
||||
multilineOutputWidget.contentDocument.body.id = "liberator-multiline-output-content";
|
||||
|
||||
var stylesheet = multilineOutputWidget.contentDocument.createElement("link");
|
||||
stylesheet.setAttribute("rel", "Stylesheet");
|
||||
stylesheet.setAttribute("href", "chrome://" + vimperator.config.name.toLowerCase() + "/skin/vimperator.css");
|
||||
stylesheet.setAttribute("href", "chrome://" + liberator.config.name.toLowerCase() + "/skin/vimperator.css");
|
||||
multilineOutputWidget.contentDocument.getElementsByTagName("head")[0].appendChild(stylesheet);
|
||||
|
||||
var availableHeight = getBrowser().mPanelContainer != undefined ?
|
||||
@@ -202,26 +202,26 @@ vimperator.CommandLine = function () //{{{
|
||||
multilineOutputWidget.height = height + "px";
|
||||
multilineOutputWidget.collapsed = false;
|
||||
|
||||
if (vimperator.options["more"] && multilineOutputWidget.contentWindow.scrollMaxY > 0)
|
||||
if (liberator.options["more"] && multilineOutputWidget.contentWindow.scrollMaxY > 0)
|
||||
{
|
||||
// start the last executed command's output at the top of the screen
|
||||
var elements = multilineOutputWidget.contentDocument.getElementsByClassName("ex-command-output");
|
||||
elements[elements.length - 1].scrollIntoView(true);
|
||||
|
||||
if (multilineOutputWidget.contentWindow.scrollY >= multilineOutputWidget.contentWindow.scrollMaxY)
|
||||
setLine("Press ENTER or type command to continue", vimperator.commandline.HL_QUESTION);
|
||||
setLine("Press ENTER or type command to continue", liberator.commandline.HL_QUESTION);
|
||||
else
|
||||
setLine("-- More --", vimperator.commandline.HL_QUESTION);
|
||||
setLine("-- More --", liberator.commandline.HL_QUESTION);
|
||||
}
|
||||
else
|
||||
{
|
||||
multilineOutputWidget.contentWindow.scrollTo(0, contentHeight);
|
||||
setLine("Press ENTER or type command to continue", vimperator.commandline.HL_QUESTION);
|
||||
setLine("Press ENTER or type command to continue", liberator.commandline.HL_QUESTION);
|
||||
}
|
||||
|
||||
multilineOutputWidget.contentWindow.focus();
|
||||
|
||||
vimperator.modes.set(vimperator.modes.COMMAND_LINE, vimperator.modes.OUTPUT_MULTILINE);
|
||||
liberator.modes.set(liberator.modes.COMMAND_LINE, liberator.modes.OUTPUT_MULTILINE);
|
||||
}
|
||||
|
||||
function autosizeMultilineInputWidget()
|
||||
@@ -248,20 +248,20 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
try
|
||||
{
|
||||
// TODO: move to vimperator.eval()?
|
||||
// with (vimperator) means, vimperator is the default namespace "inside" eval
|
||||
arg = eval("with(vimperator){" + arg + "}");
|
||||
// TODO: move to liberator.eval()?
|
||||
// with (liberator) means, liberator is the default namespace "inside" eval
|
||||
arg = eval("with(liberator){" + arg + "}");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
vimperator.echoerr(e.toString());
|
||||
liberator.echoerr(e.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof arg === "object")
|
||||
arg = vimperator.util.objectToString(arg, useColor);
|
||||
arg = liberator.util.objectToString(arg, useColor);
|
||||
else if (typeof arg === "function")
|
||||
arg = vimperator.util.escapeHTML(arg.toString());
|
||||
arg = liberator.util.escapeHTML(arg.toString());
|
||||
else if (typeof arg === "number" || typeof arg === "boolean")
|
||||
arg = "" + arg;
|
||||
else if (typeof arg === "undefined")
|
||||
@@ -274,26 +274,26 @@ vimperator.CommandLine = function () //{{{
|
||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
vimperator.options.add(["history", "hi"],
|
||||
liberator.options.add(["history", "hi"],
|
||||
"Number of Ex commands and search patterns to store in the commandline history",
|
||||
"number", 500);
|
||||
|
||||
vimperator.options.add(["more"],
|
||||
liberator.options.add(["more"],
|
||||
"Pause the message list window when more than one screen of listings is displayed",
|
||||
"boolean", true);
|
||||
|
||||
vimperator.options.add(["complete", "cpt"],
|
||||
liberator.options.add(["complete", "cpt"],
|
||||
"Items which are completed at the :[tab]open prompt",
|
||||
"charlist", "sfbh",
|
||||
{
|
||||
validator: function (value) { return !/[^sfbh]/.test(value); }
|
||||
});
|
||||
|
||||
vimperator.options.add(["showmode", "smd"],
|
||||
liberator.options.add(["showmode", "smd"],
|
||||
"Show the current mode in the command line",
|
||||
"boolean", true);
|
||||
|
||||
vimperator.options.add(["wildmode", "wim"],
|
||||
liberator.options.add(["wildmode", "wim"],
|
||||
"Define how command line completion works",
|
||||
"stringlist", "list:full",
|
||||
{
|
||||
@@ -303,7 +303,7 @@ vimperator.CommandLine = function () //{{{
|
||||
}
|
||||
});
|
||||
|
||||
vimperator.options.add(["wildoptions", "wop"],
|
||||
liberator.options.add(["wildoptions", "wop"],
|
||||
"Change how command line completion is done",
|
||||
"stringlist", "",
|
||||
{
|
||||
@@ -314,40 +314,40 @@ vimperator.CommandLine = function () //{{{
|
||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
var modes = [vimperator.modes.COMMAND_LINE];
|
||||
var modes = [liberator.modes.COMMAND_LINE];
|
||||
|
||||
vimperator.mappings.add(modes,
|
||||
liberator.mappings.add(modes,
|
||||
["<Space>"], "Expand command line abbreviation",
|
||||
function () { return vimperator.editor.expandAbbreviation("c"); },
|
||||
{ flags: vimperator.Mappings.flags.ALLOW_EVENT_ROUTING });
|
||||
function () { return liberator.editor.expandAbbreviation("c"); },
|
||||
{ flags: liberator.Mappings.flags.ALLOW_EVENT_ROUTING });
|
||||
|
||||
vimperator.mappings.add(modes,
|
||||
liberator.mappings.add(modes,
|
||||
["<C-]>", "<C-5>"], "Expand command line abbreviation",
|
||||
function () { vimperator.editor.expandAbbreviation("c"); });
|
||||
function () { liberator.editor.expandAbbreviation("c"); });
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
vimperator.commands.add(["ec[ho]"],
|
||||
liberator.commands.add(["ec[ho]"],
|
||||
"Display a string at the bottom of the window",
|
||||
function (args)
|
||||
{
|
||||
var res = echoArgumentToString(args, true);
|
||||
if (res != null)
|
||||
vimperator.echo(res);
|
||||
liberator.echo(res);
|
||||
},
|
||||
{ completer: function (filter) { return vimperator.completion.javascript(filter); } });
|
||||
{ completer: function (filter) { return liberator.completion.javascript(filter); } });
|
||||
|
||||
vimperator.commands.add(["echoe[rr]"],
|
||||
liberator.commands.add(["echoe[rr]"],
|
||||
"Display an error string at the bottom of the window",
|
||||
function (args)
|
||||
{
|
||||
var res = echoArgumentToString(args, false);
|
||||
if (res != null)
|
||||
vimperator.echoerr(res);
|
||||
liberator.echoerr(res);
|
||||
},
|
||||
{ completer: function (filter) { return vimperator.completion.javascript(filter); } });
|
||||
{ completer: function (filter) { return liberator.completion.javascript(filter); } });
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
@@ -387,9 +387,9 @@ vimperator.CommandLine = function () //{{{
|
||||
completionIndex = UNINITIALIZED;
|
||||
|
||||
// save the mode, because we need to restore it
|
||||
oldMode = vimperator.mode;
|
||||
oldExtendedMode = vimperator.mode.extended;
|
||||
vimperator.modes.set(vimperator.modes.COMMAND_LINE, currentExtendedMode);
|
||||
oldMode = liberator.mode;
|
||||
oldExtendedMode = liberator.mode.extended;
|
||||
liberator.modes.set(liberator.modes.COMMAND_LINE, currentExtendedMode);
|
||||
setHighlightGroup(this.HL_NORMAL);
|
||||
setPrompt(currentPrompt);
|
||||
setCommand(currentCommand);
|
||||
@@ -400,9 +400,9 @@ vimperator.CommandLine = function () //{{{
|
||||
// normally used when pressing esc, does not execute a command
|
||||
close: function ()
|
||||
{
|
||||
var res = vimperator.triggerCallback("cancel", currentExtendedMode);
|
||||
var res = liberator.triggerCallback("cancel", currentExtendedMode);
|
||||
history.add(this.getCommand());
|
||||
vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||
liberator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||
this.clear();
|
||||
},
|
||||
|
||||
@@ -416,7 +416,7 @@ vimperator.CommandLine = function () //{{{
|
||||
},
|
||||
|
||||
// TODO: add :messages entry
|
||||
// vimperator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst
|
||||
// liberator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst
|
||||
echo: function (str, highlightGroup, flags)
|
||||
{
|
||||
// if we are modifing the GUI while we are not in the main thread
|
||||
@@ -456,7 +456,7 @@ vimperator.CommandLine = function () //{{{
|
||||
},
|
||||
|
||||
// this will prompt the user for a string
|
||||
// vimperator.commandline.input("(s)ave or (o)pen the file?")
|
||||
// liberator.commandline.input("(s)ave or (o)pen the file?")
|
||||
input: function (str)
|
||||
{
|
||||
// TODO: unfinished, need to find out how/if we can block the execution of code
|
||||
@@ -471,9 +471,9 @@ vimperator.CommandLine = function () //{{{
|
||||
inputMultiline: function (untilRegexp, callbackFunc)
|
||||
{
|
||||
// save the mode, because we need to restore it
|
||||
oldMode = vimperator.mode;
|
||||
oldExtendedMode = vimperator.mode.extended;
|
||||
vimperator.modes.set(vimperator.modes.COMMAND_LINE, vimperator.modes.INPUT_MULTILINE);
|
||||
oldMode = liberator.mode;
|
||||
oldExtendedMode = liberator.mode.extended;
|
||||
liberator.modes.set(liberator.modes.COMMAND_LINE, liberator.modes.INPUT_MULTILINE);
|
||||
|
||||
// save the arguments, they are needed in the event handler onEvent
|
||||
multilineRegexp = untilRegexp;
|
||||
@@ -496,9 +496,9 @@ vimperator.CommandLine = function () //{{{
|
||||
{
|
||||
// prevent losing focus, there should be a better way, but it just didn't work otherwise
|
||||
setTimeout(function () {
|
||||
if (vimperator.mode == vimperator.modes.COMMAND_LINE &&
|
||||
!(vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE) &&
|
||||
!(vimperator.modes.extended & vimperator.modes.OUTPUT_MULTILINE))
|
||||
if (liberator.mode == liberator.modes.COMMAND_LINE &&
|
||||
!(liberator.modes.extended & liberator.modes.INPUT_MULTILINE) &&
|
||||
!(liberator.modes.extended & liberator.modes.OUTPUT_MULTILINE))
|
||||
commandWidget.inputField.focus();
|
||||
}, 0);
|
||||
}
|
||||
@@ -509,27 +509,27 @@ vimperator.CommandLine = function () //{{{
|
||||
}
|
||||
else if (event.type == "input")
|
||||
{
|
||||
vimperator.triggerCallback("change", currentExtendedMode, command);
|
||||
liberator.triggerCallback("change", currentExtendedMode, command);
|
||||
}
|
||||
else if (event.type == "keypress")
|
||||
{
|
||||
if (!currentExtendedMode)
|
||||
return true;
|
||||
|
||||
var key = vimperator.events.toString(event);
|
||||
//vimperator.log("command line handling key: " + key + "\n");
|
||||
var key = liberator.events.toString(event);
|
||||
//liberator.log("command line handling key: " + key + "\n");
|
||||
|
||||
// user pressed ENTER to carry out a command
|
||||
// user pressing ESCAPE is handled in the global onEscape
|
||||
if (vimperator.events.isAcceptKey(key))
|
||||
if (liberator.events.isAcceptKey(key))
|
||||
{
|
||||
var mode = currentExtendedMode; // save it here, as setMode() resets it
|
||||
history.add(command);
|
||||
vimperator.modes.reset(true); //FIXME: use mode stack
|
||||
liberator.modes.reset(true); //FIXME: use mode stack
|
||||
completionlist.hide();
|
||||
vimperator.focusContent(false);
|
||||
vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||
return vimperator.triggerCallback("submit", mode, command);
|
||||
liberator.focusContent(false);
|
||||
liberator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||
return liberator.triggerCallback("submit", mode, command);
|
||||
}
|
||||
|
||||
// user pressed UP or DOWN arrow to cycle history completion
|
||||
@@ -560,7 +560,7 @@ vimperator.CommandLine = function () //{{{
|
||||
if (historyIndex == lines.length)
|
||||
{
|
||||
setCommand(historyStart);
|
||||
vimperator.triggerCallback("change", currentExtendedMode, this.getCommand());
|
||||
liberator.triggerCallback("change", currentExtendedMode, this.getCommand());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -568,20 +568,20 @@ vimperator.CommandLine = function () //{{{
|
||||
if (historyIndex <= -1)
|
||||
{
|
||||
historyIndex = 0;
|
||||
vimperator.beep();
|
||||
liberator.beep();
|
||||
break;
|
||||
}
|
||||
else if (historyIndex >= lines.length + 1)
|
||||
{
|
||||
historyIndex = lines.length;
|
||||
vimperator.beep();
|
||||
liberator.beep();
|
||||
break;
|
||||
}
|
||||
|
||||
if (lines[historyIndex].indexOf(historyStart) == 0)
|
||||
{
|
||||
setCommand(lines[historyIndex]);
|
||||
vimperator.triggerCallback("change", currentExtendedMode, this.getCommand());
|
||||
liberator.triggerCallback("change", currentExtendedMode, this.getCommand());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -603,12 +603,12 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
completionPrefix = command.substring(0, commandWidget.selectionStart);
|
||||
completionPostfix = command.substring(commandWidget.selectionStart);
|
||||
var res = vimperator.triggerCallback("complete", currentExtendedMode, completionPrefix);
|
||||
var res = liberator.triggerCallback("complete", currentExtendedMode, completionPrefix);
|
||||
if (res)
|
||||
[completionStartIndex, completions] = res;
|
||||
|
||||
// sort the completion list
|
||||
if (/\bsort\b/.test(vimperator.options["wildoptions"]))
|
||||
if (/\bsort\b/.test(liberator.options["wildoptions"]))
|
||||
{
|
||||
completions.sort(function (a, b) {
|
||||
if (a[0] < b[0])
|
||||
@@ -623,12 +623,12 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
if (completions.length == 0)
|
||||
{
|
||||
vimperator.beep();
|
||||
liberator.beep();
|
||||
// prevent tab from moving to the next field:
|
||||
return false;
|
||||
}
|
||||
|
||||
var wim = vimperator.options["wildmode"].split(/,/);
|
||||
var wim = liberator.options["wildmode"].split(/,/);
|
||||
var hasList = false;
|
||||
var longest = false;
|
||||
var full = false;
|
||||
@@ -664,7 +664,7 @@ vimperator.CommandLine = function () //{{{
|
||||
completionIndex = -1;
|
||||
}
|
||||
|
||||
vimperator.statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.length);
|
||||
liberator.statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.length);
|
||||
// if the list is hidden, this function does nothing
|
||||
completionlist.selectItem(completionIndex);
|
||||
}
|
||||
@@ -680,7 +680,7 @@ vimperator.CommandLine = function () //{{{
|
||||
{
|
||||
var compl = null;
|
||||
if (longest && completions.length > 1)
|
||||
compl = vimperator.completion.getLongestSubstring();
|
||||
compl = liberator.completion.getLongestSubstring();
|
||||
else if (full)
|
||||
compl = completions[completionIndex][0];
|
||||
else if (completions.length == 1)
|
||||
@@ -711,8 +711,8 @@ vimperator.CommandLine = function () //{{{
|
||||
// and blur the command line if there is no text left
|
||||
if (command.length == 0)
|
||||
{
|
||||
vimperator.triggerCallback("cancel", currentExtendedMode);
|
||||
vimperator.modes.reset(); // FIXME: use mode stack
|
||||
liberator.triggerCallback("cancel", currentExtendedMode);
|
||||
liberator.modes.reset(); // FIXME: use mode stack
|
||||
}
|
||||
}
|
||||
else // any other key
|
||||
@@ -728,27 +728,27 @@ vimperator.CommandLine = function () //{{{
|
||||
{
|
||||
if (event.type == "keypress")
|
||||
{
|
||||
var key = vimperator.events.toString(event);
|
||||
if (vimperator.events.isAcceptKey(key))
|
||||
var key = liberator.events.toString(event);
|
||||
if (liberator.events.isAcceptKey(key))
|
||||
{
|
||||
var text = multilineInputWidget.value.substr(0, multilineInputWidget.selectionStart);
|
||||
if (text.match(multilineRegexp))
|
||||
{
|
||||
text = text.replace(multilineRegexp, "");
|
||||
vimperator.modes.set(oldMode, oldExtendedMode);
|
||||
liberator.modes.set(oldMode, oldExtendedMode);
|
||||
multilineInputWidget.collapsed = true;
|
||||
multilineCallback.call(this, text);
|
||||
}
|
||||
}
|
||||
else if (vimperator.events.isCancelKey(key))
|
||||
else if (liberator.events.isCancelKey(key))
|
||||
{
|
||||
vimperator.modes.set(oldMode, oldExtendedMode);
|
||||
liberator.modes.set(oldMode, oldExtendedMode);
|
||||
multilineInputWidget.collapsed = true;
|
||||
}
|
||||
}
|
||||
else if (event.type == "blur")
|
||||
{
|
||||
if (vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE)
|
||||
if (liberator.modes.extended & liberator.modes.INPUT_MULTILINE)
|
||||
setTimeout(function () { multilineInputWidget.inputField.focus(); }, 0);
|
||||
}
|
||||
else if (event.type == "input")
|
||||
@@ -773,7 +773,7 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
function atEnd() { return win.scrollY / win.scrollMaxY >= 1; }
|
||||
|
||||
var key = vimperator.events.toString(event);
|
||||
var key = liberator.events.toString(event);
|
||||
|
||||
switch (key)
|
||||
{
|
||||
@@ -782,13 +782,13 @@ vimperator.CommandLine = function () //{{{
|
||||
break; // handled globally in events.js:onEscape()
|
||||
|
||||
case ":":
|
||||
vimperator.commandline.open(":", "", vimperator.modes.EX);
|
||||
liberator.commandline.open(":", "", liberator.modes.EX);
|
||||
return;
|
||||
|
||||
// down a line
|
||||
case "j":
|
||||
case "<Down>":
|
||||
if (vimperator.options["more"] && isScrollable())
|
||||
if (liberator.options["more"] && isScrollable())
|
||||
win.scrollByLines(1);
|
||||
else
|
||||
passEvent = true;
|
||||
@@ -797,7 +797,7 @@ vimperator.CommandLine = function () //{{{
|
||||
case "<C-j>":
|
||||
case "<C-m>":
|
||||
case "<Return>":
|
||||
if (vimperator.options["more"] && isScrollable() && !atEnd())
|
||||
if (liberator.options["more"] && isScrollable() && !atEnd())
|
||||
win.scrollByLines(1);
|
||||
else
|
||||
closeWindow = true; // don't propagate the event for accept keys
|
||||
@@ -807,9 +807,9 @@ vimperator.CommandLine = function () //{{{
|
||||
case "k":
|
||||
case "<Up>":
|
||||
case "<BS>":
|
||||
if (vimperator.options["more"] && isScrollable())
|
||||
if (liberator.options["more"] && isScrollable())
|
||||
win.scrollByLines(-1);
|
||||
else if (vimperator.options["more"] && !isScrollable())
|
||||
else if (liberator.options["more"] && !isScrollable())
|
||||
showMorePrompt = true;
|
||||
else
|
||||
passEvent = true;
|
||||
@@ -817,7 +817,7 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
// half page down
|
||||
case "d":
|
||||
if (vimperator.options["more"] && isScrollable())
|
||||
if (liberator.options["more"] && isScrollable())
|
||||
win.scrollBy(0, win.innerHeight / 2);
|
||||
else
|
||||
passEvent = true;
|
||||
@@ -826,22 +826,22 @@ vimperator.CommandLine = function () //{{{
|
||||
case "<LeftMouse>":
|
||||
if (event.originalTarget.className == "hl-URL buffer-list")
|
||||
{
|
||||
vimperator.tabs.select(parseInt(event.originalTarget.parentNode.parentNode.firstChild.textContent, 10) - 1);
|
||||
liberator.tabs.select(parseInt(event.originalTarget.parentNode.parentNode.firstChild.textContent, 10) - 1);
|
||||
closeWindow = true;
|
||||
break;
|
||||
}
|
||||
else if (event.originalTarget.localName.toLowerCase() == "a")
|
||||
{
|
||||
vimperator.open(event.originalTarget.textContent);
|
||||
liberator.open(event.originalTarget.textContent);
|
||||
break;
|
||||
}
|
||||
case "<A-LeftMouse>": // for those not owning a 3-button mouse
|
||||
case "<MiddleMouse>":
|
||||
if (event.originalTarget.localName.toLowerCase() == "a")
|
||||
{
|
||||
var where = /\btabopen\b/.test(vimperator.options["activate"]) ?
|
||||
vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB;
|
||||
vimperator.open(event.originalTarget.textContent, where);
|
||||
var where = /\btabopen\b/.test(liberator.options["activate"]) ?
|
||||
liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
|
||||
liberator.open(event.originalTarget.textContent, where);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -860,7 +860,7 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
// page down
|
||||
case "f":
|
||||
if (vimperator.options["more"] && isScrollable())
|
||||
if (liberator.options["more"] && isScrollable())
|
||||
win.scrollByPages(1);
|
||||
else
|
||||
passEvent = true;
|
||||
@@ -868,7 +868,7 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
case "<Space>":
|
||||
case "<PageDown>":
|
||||
if (vimperator.options["more"] && isScrollable() && !atEnd())
|
||||
if (liberator.options["more"] && isScrollable() && !atEnd())
|
||||
win.scrollByPages(1);
|
||||
else
|
||||
passEvent = true;
|
||||
@@ -877,7 +877,7 @@ vimperator.CommandLine = function () //{{{
|
||||
// half page up
|
||||
case "u":
|
||||
// if (more and scrollable)
|
||||
if (vimperator.options["more"] && isScrollable())
|
||||
if (liberator.options["more"] && isScrollable())
|
||||
win.scrollBy(0, -(win.innerHeight / 2));
|
||||
else
|
||||
passEvent = true;
|
||||
@@ -885,16 +885,16 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
// page up
|
||||
case "b":
|
||||
if (vimperator.options["more"] && isScrollable())
|
||||
if (liberator.options["more"] && isScrollable())
|
||||
win.scrollByPages(-1);
|
||||
else if (vimperator.options["more"] && !isScrollable())
|
||||
else if (liberator.options["more"] && !isScrollable())
|
||||
showMorePrompt = true;
|
||||
else
|
||||
passEvent = true;
|
||||
break;
|
||||
|
||||
case "<PageUp>":
|
||||
if (vimperator.options["more"] && isScrollable())
|
||||
if (liberator.options["more"] && isScrollable())
|
||||
win.scrollByPages(-1);
|
||||
else
|
||||
passEvent = true;
|
||||
@@ -902,9 +902,9 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
// top of page
|
||||
case "g":
|
||||
if (vimperator.options["more"] && isScrollable())
|
||||
if (liberator.options["more"] && isScrollable())
|
||||
win.scrollTo(0, 0);
|
||||
else if (vimperator.options["more"] && !isScrollable())
|
||||
else if (liberator.options["more"] && !isScrollable())
|
||||
showMorePrompt = true;
|
||||
else
|
||||
passEvent = true;
|
||||
@@ -912,7 +912,7 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
// bottom of page
|
||||
case "G":
|
||||
if (vimperator.options["more"] && isScrollable() && !atEnd())
|
||||
if (liberator.options["more"] && isScrollable() && !atEnd())
|
||||
win.scrollTo(0, win.scrollMaxY);
|
||||
else
|
||||
passEvent = true;
|
||||
@@ -920,7 +920,7 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
// copy text to clipboard
|
||||
case "<C-y>":
|
||||
vimperator.copyToClipboard(win.getSelection());
|
||||
liberator.copyToClipboard(win.getSelection());
|
||||
break;
|
||||
|
||||
// close the window
|
||||
@@ -930,7 +930,7 @@ vimperator.CommandLine = function () //{{{
|
||||
|
||||
// unmapped key
|
||||
default:
|
||||
if (!vimperator.options["more"] || !isScrollable() || atEnd() || vimperator.events.isCancelKey(key))
|
||||
if (!liberator.options["more"] || !isScrollable() || atEnd() || liberator.events.isCancelKey(key))
|
||||
passEvent = true;
|
||||
else
|
||||
showMoreHelpPrompt = true;
|
||||
@@ -939,17 +939,17 @@ vimperator.CommandLine = function () //{{{
|
||||
if (passEvent || closeWindow)
|
||||
{
|
||||
// FIXME: use mode stack
|
||||
vimperator.modes.reset();
|
||||
liberator.modes.reset();
|
||||
this.clear();
|
||||
|
||||
if (passEvent)
|
||||
vimperator.events.onKeyPress(event);
|
||||
liberator.events.onKeyPress(event);
|
||||
}
|
||||
else // set update the prompt string
|
||||
{
|
||||
if (showMoreHelpPrompt)
|
||||
setLine("-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit", this.HL_MOREMSG);
|
||||
else if (showMorePrompt || (vimperator.options["more"] && isScrollable() && !atEnd()))
|
||||
else if (showMorePrompt || (liberator.options["more"] && isScrollable() && !atEnd()))
|
||||
setLine("-- More --", this.HL_MOREMSG);
|
||||
else
|
||||
setLine("Press ENTER or type command to continue", this.HL_QUESTION);
|
||||
@@ -972,7 +972,7 @@ vimperator.CommandLine = function () //{{{
|
||||
* @param id: the id of the the XUL widget which we want to fill
|
||||
* @param options: an optional hash which modifies the behavior of the list
|
||||
*/
|
||||
vimperator.InformationList = function (id, options) //{{{
|
||||
liberator.InformationList = function (id, options) //{{{
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
@@ -1076,7 +1076,7 @@ vimperator.InformationList = function (id, options) //{{{
|
||||
*/
|
||||
show: function (compl)
|
||||
{
|
||||
//maxItems = vimperator.options["previewheight"];
|
||||
//maxItems = liberator.options["previewheight"];
|
||||
|
||||
if (compl)
|
||||
{
|
||||
@@ -1168,9 +1168,9 @@ vimperator.InformationList = function (id, options) //{{{
|
||||
var index = (widget.selectedIndex * 2) + 0;
|
||||
var val = listcells[index].getAttribute("label");
|
||||
if (val && event.button == 0 && event.type == "dblclick") // left double click
|
||||
vimperator.open(val);
|
||||
liberator.open(val);
|
||||
else if (val && event.button == 1) // middle click
|
||||
vimperator.open(val, vimperator.NEW_TAB);
|
||||
liberator.open(val, liberator.NEW_TAB);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -1179,7 +1179,7 @@ vimperator.InformationList = function (id, options) //{{{
|
||||
//}}}
|
||||
}; //}}}
|
||||
|
||||
vimperator.StatusLine = function () //{{{
|
||||
liberator.StatusLine = function () //{{{
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
@@ -1189,18 +1189,18 @@ vimperator.StatusLine = function () //{{{
|
||||
statusBar.collapsed = true; // it is later restored unless the user sets laststatus=0
|
||||
|
||||
// our status bar fields
|
||||
var statuslineWidget = document.getElementById("vimperator-statusline");
|
||||
var urlWidget = document.getElementById("vimperator-statusline-field-url");
|
||||
var inputBufferWidget = document.getElementById("vimperator-statusline-field-inputbuffer");
|
||||
var progressWidget = document.getElementById("vimperator-statusline-field-progress");
|
||||
var tabCountWidget = document.getElementById("vimperator-statusline-field-tabcount");
|
||||
var bufferPositionWidget = document.getElementById("vimperator-statusline-field-bufferposition");
|
||||
var statuslineWidget = document.getElementById("liberator-statusline");
|
||||
var urlWidget = document.getElementById("liberator-statusline-field-url");
|
||||
var inputBufferWidget = document.getElementById("liberator-statusline-field-inputbuffer");
|
||||
var progressWidget = document.getElementById("liberator-statusline-field-progress");
|
||||
var tabCountWidget = document.getElementById("liberator-statusline-field-tabcount");
|
||||
var bufferPositionWidget = document.getElementById("liberator-statusline-field-bufferposition");
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
vimperator.options.add(["laststatus", "ls"],
|
||||
liberator.options.add(["laststatus", "ls"],
|
||||
"Show the status line",
|
||||
"number", 2,
|
||||
{
|
||||
@@ -1209,7 +1209,7 @@ vimperator.StatusLine = function () //{{{
|
||||
if (value == 0)
|
||||
document.getElementById("status-bar").collapsed = true;
|
||||
else if (value == 1)
|
||||
vimperator.echo("show status line only with > 1 window not implemented yet");
|
||||
liberator.echo("show status line only with > 1 window not implemented yet");
|
||||
else
|
||||
document.getElementById("status-bar").collapsed = false;
|
||||
},
|
||||
@@ -1261,12 +1261,12 @@ vimperator.StatusLine = function () //{{{
|
||||
return;
|
||||
}
|
||||
|
||||
url = vimperator.buffer.URL;
|
||||
url = liberator.buffer.URL;
|
||||
|
||||
// make it even more vim-like
|
||||
if (url == "about:blank")
|
||||
{
|
||||
var title = vimperator.buffer.title;
|
||||
var title = liberator.buffer.title;
|
||||
if (!title)
|
||||
url = "[No Name]";
|
||||
}
|
||||
@@ -1278,7 +1278,7 @@ vimperator.StatusLine = function () //{{{
|
||||
}
|
||||
|
||||
// when session information is available, add [+] when we can go backwards
|
||||
if (vimperator.config.name == "Vimperator")
|
||||
if (liberator.config.name == "Vimperator")
|
||||
{
|
||||
var sh = getWebNavigation().sessionHistory;
|
||||
var modified = "";
|
||||
@@ -1286,7 +1286,7 @@ vimperator.StatusLine = function () //{{{
|
||||
modified += "+";
|
||||
if (sh.index < sh.count -1)
|
||||
modified += "-";
|
||||
if (vimperator.bookmarks.isBookmarked(url))
|
||||
if (liberator.bookmarks.isBookmarked(url))
|
||||
modified += "\u2764"; // a heart symbol: ❤
|
||||
//modified += "\u2665"; // a heart symbol: ♥
|
||||
|
||||
@@ -1338,16 +1338,16 @@ vimperator.StatusLine = function () //{{{
|
||||
// you can omit either of the 2 arguments
|
||||
updateTabCount: function (currentIndex, totalTabs)
|
||||
{
|
||||
if (!vimperator.has("tabs"))
|
||||
if (!liberator.has("tabs"))
|
||||
{
|
||||
tabCountWidget = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currentIndex || typeof currentIndex != "number")
|
||||
currentIndex = vimperator.tabs.index() + 1;
|
||||
currentIndex = liberator.tabs.index() + 1;
|
||||
if (!totalTabs || typeof currentIndex != "number")
|
||||
totalTabs = vimperator.tabs.count;
|
||||
totalTabs = liberator.tabs.count;
|
||||
|
||||
tabCountWidget.value = "[" + currentIndex + "/" + totalTabs + "]";
|
||||
},
|
||||
|
||||
@@ -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.util = { //{{{
|
||||
liberator.util = { //{{{
|
||||
|
||||
// TODO: use :highlight color groups
|
||||
// if "processStrings" is true, any passed strings will be surrounded by " and
|
||||
@@ -45,7 +45,7 @@ vimperator.util = { //{{{
|
||||
else if (type == "string")
|
||||
{
|
||||
if (processStrings)
|
||||
arg = '"' + vimperator.util.escapeHTML(arg.replace(/\n/, "\\n")) + '"';
|
||||
arg = '"' + liberator.util.escapeHTML(arg.replace(/\n/, "\\n")) + '"';
|
||||
|
||||
return "<span style=\"color: green;\">" + arg + "</span>";
|
||||
}
|
||||
@@ -66,7 +66,7 @@ vimperator.util = { //{{{
|
||||
|
||||
var str = arg.toString();
|
||||
if (typeof str == "string") // can be "undefined"
|
||||
return vimperator.util.escapeHTML(str);
|
||||
return liberator.util.escapeHTML(str);
|
||||
else
|
||||
return "undefined";
|
||||
}
|
||||
@@ -127,9 +127,9 @@ vimperator.util = { //{{{
|
||||
generateHelp: function (command, extraHelp)
|
||||
{
|
||||
var start = "", end = "";
|
||||
if (command instanceof vimperator.Command)
|
||||
if (command instanceof liberator.Command)
|
||||
start = ":"
|
||||
else if (command instanceof vimperator.Option)
|
||||
else if (command instanceof liberator.Option)
|
||||
start = end = "'"
|
||||
|
||||
var ret = "";
|
||||
@@ -178,7 +178,7 @@ vimperator.util = { //{{{
|
||||
highlightURL: function (str, force)
|
||||
{
|
||||
if (force || /^[a-zA-Z]+:\/\//.test(str))
|
||||
return "<a class='hl-URL' href='#'>" + vimperator.util.escapeHTML(str) + "</a>";
|
||||
return "<a class='hl-URL' href='#'>" + liberator.util.escapeHTML(str) + "</a>";
|
||||
else
|
||||
return str;
|
||||
},
|
||||
@@ -248,7 +248,7 @@ vimperator.util = { //{{{
|
||||
urls[url] = urls[url].replace(/^\s+/, "").replace(/\s+$/, "");
|
||||
|
||||
// first check if it is an existing local file
|
||||
var file = vimperator.io.getFile(urls[url]);
|
||||
var file = liberator.io.getFile(urls[url]);
|
||||
if (file.exists() && file.isReadable())
|
||||
{
|
||||
urls[url] = file.path;
|
||||
@@ -258,7 +258,7 @@ vimperator.util = { //{{{
|
||||
// if the string doesn't look like a valid URL (i.e. contains a space
|
||||
// or does not contain any of: .:/) try opening it with a search engine
|
||||
// or keyword bookmark
|
||||
if (vimperator.has("bookmarks") && (/\s/.test(urls[url]) || !/[.:\/]/.test(urls[url])))
|
||||
if (liberator.has("bookmarks") && (/\s/.test(urls[url]) || !/[.:\/]/.test(urls[url])))
|
||||
{
|
||||
var matches = urls[url].match(/^(\S+)(?:\s+(.+))?$/);
|
||||
var alias = matches[1];
|
||||
@@ -271,7 +271,7 @@ vimperator.util = { //{{{
|
||||
// like the comments below ;-)
|
||||
|
||||
// check if the first word is a search engine
|
||||
var searchURL = vimperator.bookmarks.getSearchURL(text, alias);
|
||||
var searchURL = liberator.bookmarks.getSearchURL(text, alias);
|
||||
if (searchURL)
|
||||
{
|
||||
urls[url] = searchURL;
|
||||
@@ -279,7 +279,7 @@ vimperator.util = { //{{{
|
||||
}
|
||||
else // the first word was not a search engine, search for the whole string in the default engine
|
||||
{
|
||||
searchURL = vimperator.bookmarks.getSearchURL(urls[url], null);
|
||||
searchURL = liberator.bookmarks.getSearchURL(urls[url], null);
|
||||
if (searchURL)
|
||||
{
|
||||
urls[url] = searchURL;
|
||||
|
||||
336
content/vim.js
336
content/vim.js
@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
}}} ***** END LICENSE BLOCK *****/
|
||||
|
||||
const vimperator = (function () //{{{
|
||||
const liberator = (function () //{{{
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
@@ -36,13 +36,13 @@ const vimperator = (function () //{{{
|
||||
// Only general options are added here, which are valid for all vimperator like extensions
|
||||
function addOptions()
|
||||
{
|
||||
vimperator.options.add(["guioptions", "go"],
|
||||
liberator.options.add(["guioptions", "go"],
|
||||
"Show or hide certain GUI elements like the menu or toolbar",
|
||||
"charlist", "",
|
||||
{
|
||||
setter: function (value)
|
||||
{
|
||||
var guioptions = vimperator.config.guioptions || {};
|
||||
var guioptions = liberator.config.guioptions || {};
|
||||
for (let option in guioptions)
|
||||
{
|
||||
guioptions[option].forEach( function(elem)
|
||||
@@ -58,13 +58,13 @@ const vimperator = (function () //{{{
|
||||
validator: function (value)
|
||||
{
|
||||
var regex = "[^";
|
||||
for (let option in vimperator.config.guioptions)
|
||||
for (let option in liberator.config.guioptions)
|
||||
regex += option.toString();
|
||||
|
||||
return !(new RegExp(regex + "]").test(value));
|
||||
}
|
||||
});
|
||||
vimperator.options.add(["titlestring"], // TODO: broken for Thunderbird
|
||||
liberator.options.add(["titlestring"], // TODO: broken for Thunderbird
|
||||
"Change the title of the window",
|
||||
"string", "Vimperator",
|
||||
{
|
||||
@@ -72,7 +72,7 @@ const vimperator = (function () //{{{
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = vimperator.config.mainWindowID || "main-window";
|
||||
var id = liberator.config.mainWindowID || "main-window";
|
||||
document.getElementById(id).setAttribute("titlemodifier", value);
|
||||
if (window.content.document.title.length > 0)
|
||||
document.title = window.content.document.title + " - " + value;
|
||||
@@ -81,115 +81,115 @@ const vimperator = (function () //{{{
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
vimperator.log("Couldn't set titlestring", 1);
|
||||
liberator.log("Couldn't set titlestring", 1);
|
||||
}
|
||||
},
|
||||
});
|
||||
vimperator.options.add(["verbose", "vbs"],
|
||||
liberator.options.add(["verbose", "vbs"],
|
||||
"Define which type of messages are logged",
|
||||
"number", 0,
|
||||
{
|
||||
validator: function (value) { return (value >= 0 && value <= 9); }
|
||||
});
|
||||
vimperator.options.add(["visualbell", "vb"],
|
||||
liberator.options.add(["visualbell", "vb"],
|
||||
"Use visual bell instead of beeping on errors",
|
||||
"boolean", false,
|
||||
{
|
||||
setter: function (value) { vimperator.options.setPref("accessibility.typeaheadfind.enablesound", !value); },
|
||||
setter: function (value) { liberator.options.setPref("accessibility.typeaheadfind.enablesound", !value); },
|
||||
});
|
||||
}
|
||||
|
||||
function addMappings()
|
||||
{
|
||||
vimperator.mappings.add(vimperator.modes.all, ["<F1>"],
|
||||
liberator.mappings.add(liberator.modes.all, ["<F1>"],
|
||||
"Open help window",
|
||||
function () { vimperator.help(); });
|
||||
function () { liberator.help(); });
|
||||
|
||||
if (vimperator.has("session"))
|
||||
if (liberator.has("session"))
|
||||
{
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["ZQ"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["ZQ"],
|
||||
"Quit and don't save the session",
|
||||
function () { vimperator.quit(false); });
|
||||
function () { liberator.quit(false); });
|
||||
}
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["ZZ"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["ZZ"],
|
||||
"Quit and save the session",
|
||||
function () { vimperator.quit(true); });
|
||||
function () { liberator.quit(true); });
|
||||
}
|
||||
|
||||
function addCommands()
|
||||
{
|
||||
vimperator.commands.add(["addo[ns]"],
|
||||
liberator.commands.add(["addo[ns]"],
|
||||
"Manage available Extensions and Themes",
|
||||
function () { vimperator.open("chrome://mozapps/content/extensions/extensions.xul", vimperator.NEW_TAB); });
|
||||
function () { liberator.open("chrome://mozapps/content/extensions/extensions.xul", liberator.NEW_TAB); });
|
||||
|
||||
vimperator.commands.add(["beep"],
|
||||
liberator.commands.add(["beep"],
|
||||
"Play a system beep",
|
||||
function () { vimperator.beep(); });
|
||||
function () { liberator.beep(); });
|
||||
|
||||
vimperator.commands.add(["dia[log]"],
|
||||
"Open a " + vimperator.config.appName + " dialog",
|
||||
liberator.commands.add(["dia[log]"],
|
||||
"Open a " + liberator.config.appName + " dialog",
|
||||
function (args, special)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dialogs = vimperator.config.dialogs || [];
|
||||
var dialogs = liberator.config.dialogs || [];
|
||||
for (let i = 0; i < dialogs.length; i++)
|
||||
{
|
||||
if (dialogs[i][0] == args)
|
||||
return dialogs[i][2]();
|
||||
}
|
||||
vimperator.echoerr(args ? "Dialog \"" + args + "\" not available" : "E474: Invalid argument");
|
||||
liberator.echoerr(args ? "Dialog \"" + args + "\" not available" : "E474: Invalid argument");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
vimperator.echoerr("Error opening '" + args + "': " + e);
|
||||
liberator.echoerr("Error opening '" + args + "': " + e);
|
||||
}
|
||||
},
|
||||
{
|
||||
completer: function (filter) { return vimperator.completion.dialog(filter); }
|
||||
completer: function (filter) { return liberator.completion.dialog(filter); }
|
||||
});
|
||||
|
||||
vimperator.commands.add(["exe[cute]"],
|
||||
liberator.commands.add(["exe[cute]"],
|
||||
"Execute the argument as an Ex command",
|
||||
function (args) { vimperator.execute(args); });
|
||||
function (args) { liberator.execute(args); });
|
||||
|
||||
vimperator.commands.add(["exu[sage]"],
|
||||
liberator.commands.add(["exu[sage]"],
|
||||
"List all Ex commands with a short description",
|
||||
function ()
|
||||
{
|
||||
var usage = "<table>";
|
||||
for (let command in vimperator.commands)
|
||||
for (let command in liberator.commands)
|
||||
{
|
||||
usage += "<tr><td style='color: magenta; padding-right: 20px'> :" +
|
||||
vimperator.util.escapeHTML(command.name) + "</td><td>" +
|
||||
vimperator.util.escapeHTML(command.description) + "</td></tr>";
|
||||
liberator.util.escapeHTML(command.name) + "</td><td>" +
|
||||
liberator.util.escapeHTML(command.description) + "</td></tr>";
|
||||
}
|
||||
usage += "</table>";
|
||||
|
||||
vimperator.echo(usage, vimperator.commandline.FORCE_MULTILINE);
|
||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||
});
|
||||
|
||||
vimperator.commands.add(["h[elp]"],
|
||||
liberator.commands.add(["h[elp]"],
|
||||
"Display help",
|
||||
function (args) { vimperator.help(args); },
|
||||
function (args) { liberator.help(args); },
|
||||
{
|
||||
completer: function (filter) { return vimperator.completion.help(filter); }
|
||||
completer: function (filter) { return liberator.completion.help(filter); }
|
||||
});
|
||||
|
||||
vimperator.commands.add(["javas[cript]", "js"],
|
||||
liberator.commands.add(["javas[cript]", "js"],
|
||||
"Run a JavaScript command through eval()",
|
||||
function (args, special)
|
||||
{
|
||||
if (special) // open javascript console
|
||||
vimperator.open("chrome://global/content/console.xul", vimperator.NEW_TAB);
|
||||
liberator.open("chrome://global/content/console.xul", liberator.NEW_TAB);
|
||||
else
|
||||
{
|
||||
// check for a heredoc
|
||||
var matches = args.match(/(.*)<<\s*([^\s]+)$/);
|
||||
if (matches && matches[2])
|
||||
{
|
||||
vimperator.commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"),
|
||||
liberator.commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"),
|
||||
function (code)
|
||||
{
|
||||
try
|
||||
@@ -198,7 +198,7 @@ const vimperator = (function () //{{{
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
vimperator.echoerr(e.name + ": " + e.message);
|
||||
liberator.echoerr(e.name + ": " + e.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -206,47 +206,47 @@ const vimperator = (function () //{{{
|
||||
{
|
||||
try
|
||||
{
|
||||
eval("with(vimperator){" + args + "}");
|
||||
eval("with(liberator){" + args + "}");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
vimperator.echoerr(e.name + ": " + e.message);
|
||||
liberator.echoerr(e.name + ": " + e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
completer: function (filter) { return vimperator.completion.javascript(filter); }
|
||||
completer: function (filter) { return liberator.completion.javascript(filter); }
|
||||
});
|
||||
|
||||
vimperator.commands.add(["norm[al]"],
|
||||
liberator.commands.add(["norm[al]"],
|
||||
"Execute Normal mode commands",
|
||||
function (args, special)
|
||||
{
|
||||
if (!args)
|
||||
{
|
||||
vimperator.echoerr("E471: Argument required");
|
||||
liberator.echoerr("E471: Argument required");
|
||||
return;
|
||||
}
|
||||
|
||||
vimperator.events.feedkeys(args, special);
|
||||
liberator.events.feedkeys(args, special);
|
||||
});
|
||||
|
||||
vimperator.commands.add(["q[uit]"],
|
||||
vimperator.has("tabs") ? "Quit current tab" : "Quit application",
|
||||
liberator.commands.add(["q[uit]"],
|
||||
liberator.has("tabs") ? "Quit current tab" : "Quit application",
|
||||
function ()
|
||||
{
|
||||
if (vimperator.has("tabs"))
|
||||
vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
|
||||
if (liberator.has("tabs"))
|
||||
liberator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
|
||||
else
|
||||
vimperator.quit(false);
|
||||
liberator.quit(false);
|
||||
});
|
||||
|
||||
vimperator.commands.add(["res[tart]"],
|
||||
"Force " + vimperator.config.appName + " to restart",
|
||||
function () { vimperator.restart(); });
|
||||
liberator.commands.add(["res[tart]"],
|
||||
"Force " + liberator.config.appName + " to restart",
|
||||
function () { liberator.restart(); });
|
||||
|
||||
vimperator.commands.add(["time"],
|
||||
liberator.commands.add(["time"],
|
||||
"Profile a piece of code or run a command multiple times",
|
||||
function (args, special, count)
|
||||
{
|
||||
@@ -260,12 +260,12 @@ const vimperator = (function () //{{{
|
||||
if (args && args[0] == ":")
|
||||
{
|
||||
while (i--)
|
||||
vimperator.execute(args);
|
||||
liberator.execute(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (i--)
|
||||
eval("with(vimperator){" + args + "}");
|
||||
eval("with(liberator){" + args + "}");
|
||||
}
|
||||
|
||||
if (special)
|
||||
@@ -295,7 +295,7 @@ const vimperator = (function () //{{{
|
||||
var totalUnits = "msec";
|
||||
}
|
||||
|
||||
var str = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
|
||||
var str = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
||||
"<table>" +
|
||||
"<tr align=\"left\" class=\"hl-Title\"><th colspan=\"3\">Code execution summary</th></tr>" +
|
||||
"<tr><td> Executed:</td><td align=\"right\"><span style=\"color: green\">" + count + "</span></td><td>times</td></tr>" +
|
||||
@@ -303,15 +303,15 @@ const vimperator = (function () //{{{
|
||||
"<tr><td> Total time:</td><td align=\"right\"><span style=\"color: red\">" + total.toFixed(2) + "</span></td><td>" + totalUnits + "</td></tr>" +
|
||||
"</table>";
|
||||
|
||||
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
|
||||
{
|
||||
var beforeTime = Date.now();
|
||||
if (args && args[0] == ":")
|
||||
vimperator.execute(args);
|
||||
liberator.execute(args);
|
||||
else
|
||||
eval("with(vimperator){" + args + "}");
|
||||
eval("with(liberator){" + args + "}");
|
||||
|
||||
if (special)
|
||||
return;
|
||||
@@ -319,43 +319,43 @@ const vimperator = (function () //{{{
|
||||
var afterTime = Date.now();
|
||||
|
||||
if (afterTime - beforeTime >= 100)
|
||||
vimperator.echo("Total time: " + ((afterTime - beforeTime) / 1000.0).toFixed(2) + " sec");
|
||||
liberator.echo("Total time: " + ((afterTime - beforeTime) / 1000.0).toFixed(2) + " sec");
|
||||
else
|
||||
vimperator.echo("Total time: " + (afterTime - beforeTime) + " msec");
|
||||
liberator.echo("Total time: " + (afterTime - beforeTime) + " msec");
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
vimperator.echoerr(e);
|
||||
liberator.echoerr(e);
|
||||
}
|
||||
});
|
||||
|
||||
vimperator.commands.add(["ve[rsion]"],
|
||||
liberator.commands.add(["ve[rsion]"],
|
||||
"Show version information",
|
||||
function (args, special)
|
||||
{
|
||||
if (special)
|
||||
vimperator.open("about:");
|
||||
liberator.open("about:");
|
||||
else
|
||||
vimperator.echo(":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "\n" +
|
||||
vimperator.config.name + " " + vimperator.version +
|
||||
liberator.echo(":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "\n" +
|
||||
liberator.config.name + " " + liberator.version +
|
||||
" running on:\n" + navigator.userAgent);
|
||||
});
|
||||
|
||||
vimperator.commands.add(["viu[sage]"],
|
||||
liberator.commands.add(["viu[sage]"],
|
||||
"List all mappings with a short description",
|
||||
function (args, special, count, modifiers)
|
||||
{
|
||||
var usage = "<table>";
|
||||
for (let mapping in vimperator.mappings)
|
||||
for (let mapping in liberator.mappings)
|
||||
{
|
||||
usage += "<tr><td style='color: magenta; padding-right: 20px'> " +
|
||||
vimperator.util.escapeHTML(mapping.names[0]) + "</td><td>" +
|
||||
vimperator.util.escapeHTML(mapping.description) + "</td></tr>";
|
||||
liberator.util.escapeHTML(mapping.names[0]) + "</td><td>" +
|
||||
liberator.util.escapeHTML(mapping.description) + "</td></tr>";
|
||||
}
|
||||
usage += "</table>";
|
||||
|
||||
vimperator.echo(usage, vimperator.commandline.FORCE_MULTILINE);
|
||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ const vimperator = (function () //{{{
|
||||
// similar in his config
|
||||
function hideGUI()
|
||||
{
|
||||
var guioptions = vimperator.config.guioptions || {};
|
||||
var guioptions = liberator.config.guioptions || {};
|
||||
for (let option in guioptions)
|
||||
{
|
||||
guioptions[option].forEach( function(elem)
|
||||
@@ -376,7 +376,7 @@ const vimperator = (function () //{{{
|
||||
});
|
||||
}
|
||||
|
||||
// if (vimperator.has("tabs"))
|
||||
// if (liberator.has("tabs"))
|
||||
|
||||
}
|
||||
|
||||
@@ -386,8 +386,8 @@ const vimperator = (function () //{{{
|
||||
|
||||
return {
|
||||
|
||||
get mode() { return vimperator.modes.main; },
|
||||
set mode(value) { vimperator.modes.main = value; },
|
||||
get mode() { return liberator.modes.main; },
|
||||
set mode(value) { liberator.modes.main = value; },
|
||||
|
||||
// Global constants
|
||||
CURRENT_TAB: 1,
|
||||
@@ -432,10 +432,10 @@ const vimperator = (function () //{{{
|
||||
|
||||
beep: function ()
|
||||
{
|
||||
if (vimperator.options["visualbell"])
|
||||
if (liberator.options["visualbell"])
|
||||
{
|
||||
// flash the visual bell
|
||||
var popup = document.getElementById("vimperator-visualbell");
|
||||
var popup = document.getElementById("liberator-visualbell");
|
||||
var win = getBrowser().mPanelContainer;
|
||||
var box = document.getBoxObjectFor(win);
|
||||
|
||||
@@ -452,7 +452,7 @@ const vimperator = (function () //{{{
|
||||
}
|
||||
},
|
||||
|
||||
// XXX? move to vimperator.util?
|
||||
// XXX? move to liberator.util?
|
||||
copyToClipboard: function (str, verbose)
|
||||
{
|
||||
var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
|
||||
@@ -460,7 +460,7 @@ const vimperator = (function () //{{{
|
||||
clipboardHelper.copyString(str);
|
||||
|
||||
if (verbose)
|
||||
vimperator.echo("Yanked " + str, vimperator.commandline.FORCE_SINGLELINE);
|
||||
liberator.echo("Yanked " + str, liberator.commandline.FORCE_SINGLELINE);
|
||||
},
|
||||
|
||||
// Execute an ex command like str=":zoom 300"
|
||||
@@ -473,20 +473,20 @@ const vimperator = (function () //{{{
|
||||
if (!modifiers)
|
||||
modifiers = {};
|
||||
|
||||
var [count, cmd, special, args] = vimperator.commands.parseCommand(str.replace(/^'(.*)'$/, "$1"));
|
||||
var command = vimperator.commands.get(cmd);
|
||||
var [count, cmd, special, args] = liberator.commands.parseCommand(str.replace(/^'(.*)'$/, "$1"));
|
||||
var command = liberator.commands.get(cmd);
|
||||
|
||||
if (command === null)
|
||||
{
|
||||
vimperator.echoerr("E492: Not an editor command: " + str);
|
||||
vimperator.focusContent();
|
||||
liberator.echoerr("E492: Not an editor command: " + str);
|
||||
liberator.focusContent();
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: need to perform this test? -- djk
|
||||
if (command.action === null)
|
||||
{
|
||||
vimperator.echoerr("E666: Internal error: command.action === null");
|
||||
liberator.echoerr("E666: Internal error: command.action === null");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ const vimperator = (function () //{{{
|
||||
command.execute(args, special, count, modifiers);
|
||||
},
|
||||
|
||||
// TODO: move to vimperator.buffer.focus()?
|
||||
// TODO: move to liberator.buffer.focus()?
|
||||
// after pressing Escape, put focus on a non-input field of the browser document
|
||||
// if clearFocusedElement, also blur a focused link
|
||||
focusContent: function (clearFocusedElement)
|
||||
@@ -505,7 +505,7 @@ const vimperator = (function () //{{{
|
||||
if (window == ww.activeWindow && document.commandDispatcher.focusedElement && clearFocusedElement)
|
||||
document.commandDispatcher.focusedElement.blur();
|
||||
|
||||
var elem = vimperator.config.mainWidget || content;
|
||||
var elem = liberator.config.mainWidget || content;
|
||||
if (elem != document.commandDispatcher.focusedElement)
|
||||
elem.focus();
|
||||
},
|
||||
@@ -586,7 +586,7 @@ const vimperator = (function () //{{{
|
||||
// return true, if this VIM-like extension has a certain feature
|
||||
has: function (feature)
|
||||
{
|
||||
var features = vimperator.config.features || [];
|
||||
var features = liberator.config.features || [];
|
||||
return features.some (function(feat) { return feat == feature; });
|
||||
},
|
||||
|
||||
@@ -594,9 +594,9 @@ const vimperator = (function () //{{{
|
||||
{
|
||||
function jumpToTag(file, tag)
|
||||
{
|
||||
vimperator.open("chrome://" + vimperator.config.name.toLowerCase() + "/locale/" + file);
|
||||
liberator.open("chrome://" + liberator.config.name.toLowerCase() + "/locale/" + file);
|
||||
setTimeout(function() {
|
||||
var elem = vimperator.buffer.getElement('@class="tag" and text()="' + tag + '"');
|
||||
var elem = liberator.buffer.getElement('@class="tag" and text()="' + tag + '"');
|
||||
if (elem)
|
||||
window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context
|
||||
else
|
||||
@@ -606,11 +606,11 @@ const vimperator = (function () //{{{
|
||||
|
||||
if (!topic)
|
||||
{
|
||||
vimperator.open("chrome://" + vimperator.config.name.toLowerCase() + "/locale/intro.html");
|
||||
liberator.open("chrome://" + liberator.config.name.toLowerCase() + "/locale/intro.html");
|
||||
return;
|
||||
}
|
||||
|
||||
var [, items] = vimperator.completion.help(topic);
|
||||
var [, items] = liberator.completion.help(topic);
|
||||
var partialMatch = -1;
|
||||
for (var i = 0; i < items.length; i++)
|
||||
{
|
||||
@@ -628,16 +628,16 @@ const vimperator = (function () //{{{
|
||||
if (partialMatch > -1)
|
||||
jumpToTag(items[partialMatch][1], items[partialMatch][0]);
|
||||
else
|
||||
vimperator.echoerr("E149: Sorry, no help for " + topic);
|
||||
liberator.echoerr("E149: Sorry, no help for " + topic);
|
||||
},
|
||||
|
||||
// logs a message to the javascript error console
|
||||
// if msg is an object, it is beautified
|
||||
log: function (msg, level)
|
||||
{
|
||||
//if (vimperator.options.getPref("verbose") >= level) // FIXME: hangs vimperator, probably timing issue --mst
|
||||
//if (liberator.options.getPref("verbose") >= level) // FIXME: hangs liberator, probably timing issue --mst
|
||||
if (typeof msg == "object")
|
||||
msg = vimperator.util.objectToString(msg, false);
|
||||
msg = liberator.util.objectToString(msg, false);
|
||||
|
||||
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].
|
||||
getService(Components.interfaces.nsIConsoleService);
|
||||
@@ -657,15 +657,15 @@ const vimperator = (function () //{{{
|
||||
open: function (urls, where)
|
||||
{
|
||||
// convert the string to an array of converted URLs
|
||||
// -> see vimperator.util.stringToURLArray for more details
|
||||
// -> see liberator.util.stringToURLArray for more details
|
||||
if (typeof urls == "string")
|
||||
urls = vimperator.util.stringToURLArray(urls);
|
||||
urls = liberator.util.stringToURLArray(urls);
|
||||
|
||||
if (urls.length == 0)
|
||||
return false;
|
||||
|
||||
if (!where || !vimperator.has("tabs"))
|
||||
where = vimperator.CURRENT_TAB;
|
||||
if (!where || !liberator.has("tabs"))
|
||||
where = liberator.CURRENT_TAB;
|
||||
|
||||
var url = typeof urls[0] == "string" ? urls[0] : urls[0][0];
|
||||
var postdata = typeof urls[0] == "string" ? null : urls[0][1];
|
||||
@@ -674,20 +674,20 @@ const vimperator = (function () //{{{
|
||||
// decide where to load the first url
|
||||
switch (where)
|
||||
{
|
||||
case vimperator.CURRENT_TAB:
|
||||
case liberator.CURRENT_TAB:
|
||||
getBrowser().loadURIWithFlags(url, null, null, null, postdata);
|
||||
break;
|
||||
|
||||
case vimperator.NEW_TAB:
|
||||
case liberator.NEW_TAB:
|
||||
var firsttab = getBrowser().addTab(url, null, null, postdata);
|
||||
getBrowser().selectedTab = firsttab;
|
||||
break;
|
||||
|
||||
case vimperator.NEW_BACKGROUND_TAB:
|
||||
case liberator.NEW_BACKGROUND_TAB:
|
||||
getBrowser().addTab(url, null, null, postdata);
|
||||
break;
|
||||
|
||||
case vimperator.NEW_WINDOW:
|
||||
case liberator.NEW_WINDOW:
|
||||
window.open();
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
@@ -696,12 +696,12 @@ const vimperator = (function () //{{{
|
||||
break;
|
||||
|
||||
default:
|
||||
vimperator.echoerr("Exxx: Invalid 'where' directive in vimperator.open(...)");
|
||||
liberator.echoerr("Exxx: Invalid 'where' directive in liberator.open(...)");
|
||||
return false;
|
||||
}
|
||||
|
||||
// only load more than one url if we have tab support
|
||||
if (!vimperator.has("tabs"))
|
||||
if (!liberator.has("tabs"))
|
||||
return true;
|
||||
|
||||
// all other URLs are always loaded in background
|
||||
@@ -715,22 +715,22 @@ const vimperator = (function () //{{{
|
||||
return true;
|
||||
},
|
||||
|
||||
// quit vimperator, no matter how many tabs/windows are open
|
||||
// quit liberator, no matter how many tabs/windows are open
|
||||
quit: function (saveSession)
|
||||
{
|
||||
vimperator.autocommands.trigger("BrowserExit", "");
|
||||
liberator.autocommands.trigger("BrowserExit", "");
|
||||
|
||||
if (saveSession)
|
||||
vimperator.options.setPref("browser.startup.page", 3); // start with saved session
|
||||
liberator.options.setPref("browser.startup.page", 3); // start with saved session
|
||||
else
|
||||
vimperator.options.setPref("browser.startup.page", 1); // start with default homepage session
|
||||
liberator.options.setPref("browser.startup.page", 1); // start with default homepage session
|
||||
|
||||
goQuitApplication();
|
||||
},
|
||||
|
||||
restart: function ()
|
||||
{
|
||||
vimperator.autocommands.trigger("BrowserRestart", "");
|
||||
liberator.autocommands.trigger("BrowserRestart", "");
|
||||
|
||||
const nsIAppStartup = Components.interfaces.nsIAppStartup;
|
||||
|
||||
@@ -765,70 +765,70 @@ const vimperator = (function () //{{{
|
||||
// this function is called, when the chrome is ready
|
||||
startup: function ()
|
||||
{
|
||||
function log(module) { vimperator.log("Loading module " + module + "...", 3); };
|
||||
function log(module) { liberator.log("Loading module " + module + "...", 3); };
|
||||
|
||||
vimperator.log("Initializing vimperator object...", 1);
|
||||
liberator.log("Initializing vimperator object...", 1);
|
||||
// commands must always be the first module to be initialized
|
||||
log("commands"); vimperator.commands = vimperator.Commands(); addCommands();
|
||||
log("options"); vimperator.options = vimperator.Options(); addOptions();
|
||||
log("mappings"); vimperator.mappings = vimperator.Mappings(); addMappings();
|
||||
log("events"); vimperator.events = vimperator.Events();
|
||||
log("commandline"); vimperator.commandline = vimperator.CommandLine();
|
||||
log("search"); vimperator.search = vimperator.Search();
|
||||
log("preview window"); vimperator.previewwindow = vimperator.InformationList("vimperator-previewwindow", { incrementalFill: false, maxItems: 10 });
|
||||
log("buffer window"); vimperator.bufferwindow = vimperator.InformationList("vimperator-bufferwindow", { incrementalFill: false, maxItems: 10 });
|
||||
log("statusline"); vimperator.statusline = vimperator.StatusLine();
|
||||
log("buffer"); vimperator.buffer = vimperator.Buffer();
|
||||
log("editor"); vimperator.editor = vimperator.Editor();
|
||||
log("autocommands"); vimperator.autocommands = vimperator.AutoCommands();
|
||||
log("io"); vimperator.io = vimperator.IO();
|
||||
log("completion"); vimperator.completion = vimperator.Completion();
|
||||
log("commands"); liberator.commands = liberator.Commands(); addCommands();
|
||||
log("options"); liberator.options = liberator.Options(); addOptions();
|
||||
log("mappings"); liberator.mappings = liberator.Mappings(); addMappings();
|
||||
log("events"); liberator.events = liberator.Events();
|
||||
log("commandline"); liberator.commandline = liberator.CommandLine();
|
||||
log("search"); liberator.search = liberator.Search();
|
||||
log("preview window"); liberator.previewwindow = liberator.InformationList("liberator-previewwindow", { incrementalFill: false, maxItems: 10 });
|
||||
log("buffer window"); liberator.bufferwindow = liberator.InformationList("liberator-bufferwindow", { incrementalFill: false, maxItems: 10 });
|
||||
log("statusline"); liberator.statusline = liberator.StatusLine();
|
||||
log("buffer"); liberator.buffer = liberator.Buffer();
|
||||
log("editor"); liberator.editor = liberator.Editor();
|
||||
log("autocommands"); liberator.autocommands = liberator.AutoCommands();
|
||||
log("io"); liberator.io = liberator.IO();
|
||||
log("completion"); liberator.completion = liberator.Completion();
|
||||
|
||||
// optional modules
|
||||
if (vimperator.has("bookmarks")) { log("bookmarks"); vimperator.bookmarks = vimperator.Bookmarks(); }
|
||||
if (vimperator.has("history")) { log("history"); vimperator.history = vimperator.History(); }
|
||||
if (vimperator.has("mail")) { log("mail"); vimperator.mail = vimperator.Mail(); }
|
||||
if (vimperator.has("tabs")) { log("tabs"); vimperator.tabs = vimperator.Tabs(); }
|
||||
if (vimperator.has("marks")) { log("marks"); vimperator.marks = vimperator.Marks(); }
|
||||
if (vimperator.has("quickmarks")) { log("quickmarks"); vimperator.quickmarks = vimperator.QuickMarks(); }
|
||||
if (vimperator.has("hints")) { log("hints"); vimperator.hints = vimperator.Hints(); }
|
||||
if (liberator.has("bookmarks")) { log("bookmarks"); liberator.bookmarks = liberator.Bookmarks(); }
|
||||
if (liberator.has("history")) { log("history"); liberator.history = liberator.History(); }
|
||||
if (liberator.has("mail")) { log("mail"); liberator.mail = liberator.Mail(); }
|
||||
if (liberator.has("tabs")) { log("tabs"); liberator.tabs = liberator.Tabs(); }
|
||||
if (liberator.has("marks")) { log("marks"); liberator.marks = liberator.Marks(); }
|
||||
if (liberator.has("quickmarks")) { log("quickmarks"); liberator.quickmarks = liberator.QuickMarks(); }
|
||||
if (liberator.has("hints")) { log("hints"); liberator.hints = liberator.Hints(); }
|
||||
|
||||
vimperator.log("All modules loaded", 3);
|
||||
liberator.log("All modules loaded", 3);
|
||||
|
||||
// This adds options/mappings/commands which are only valid in this particular extension
|
||||
if (vimperator.config.init)
|
||||
if (liberator.config.init)
|
||||
{
|
||||
vimperator.config.init();
|
||||
// vimperator.log("Loaded additional mappings, etc. for " + vimperator.config.name, 3);
|
||||
liberator.config.init();
|
||||
// liberator.log("Loaded additional mappings, etc. for " + liberator.config.name, 3);
|
||||
}
|
||||
|
||||
// we define some shortcuts to functions which are used often
|
||||
vimperator.echo = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); };
|
||||
vimperator.echoerr = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_ERRORMSG, flags); };
|
||||
liberator.echo = function (str, flags) { liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, flags); };
|
||||
liberator.echoerr = function (str, flags) { liberator.commandline.echo(str, liberator.commandline.HL_ERRORMSG, flags); };
|
||||
|
||||
vimperator.globalVariables = {};
|
||||
liberator.globalVariables = {};
|
||||
|
||||
// namespace for plugins/scripts. Actually (only) the active plugin must/can set a
|
||||
// v.plugins.mode = <str> string to show on v.modes.CUSTOM
|
||||
// v.plugins.stop = <func> hooked on a v.modes.reset()
|
||||
// v.plugins.onEvent = <func> function triggered, on keypresses (unless <esc>) (see events.js)
|
||||
vimperator.plugins = {};
|
||||
liberator.plugins = {};
|
||||
|
||||
// TODO: move elsewhere
|
||||
vimperator.registerCallback("submit", vimperator.modes.EX, function (command) { vimperator.execute(command); });
|
||||
vimperator.registerCallback("complete", vimperator.modes.EX, function (str) { return vimperator.completion.exTabCompletion(str); });
|
||||
liberator.registerCallback("submit", liberator.modes.EX, function (command) { liberator.execute(command); });
|
||||
liberator.registerCallback("complete", liberator.modes.EX, function (str) { return liberator.completion.exTabCompletion(str); });
|
||||
|
||||
// first time intro message
|
||||
if (vimperator.options.getPref("extensions." + vimperator.config.name.toLowerCase() + ".firsttime", true))
|
||||
if (liberator.options.getPref("extensions." + liberator.config.name.toLowerCase() + ".firsttime", true))
|
||||
{
|
||||
setTimeout(function () {
|
||||
vimperator.help();
|
||||
vimperator.options.setPref("extensions." + vimperator.config.name.toLowerCase() + ".firsttime", false);
|
||||
liberator.help();
|
||||
liberator.options.setPref("extensions." + liberator.config.name.toLowerCase() + ".firsttime", false);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// always start in normal mode
|
||||
vimperator.modes.reset();
|
||||
liberator.modes.reset();
|
||||
|
||||
// TODO: we should have some class where all this guioptions stuff fits well
|
||||
hideGUI();
|
||||
@@ -837,59 +837,59 @@ const vimperator = (function () //{{{
|
||||
// make sourcing asynchronous, otherwise commands that open new tabs won't work
|
||||
setTimeout(function () {
|
||||
|
||||
var rcFile = vimperator.io.getRCFile();
|
||||
var rcFile = liberator.io.getRCFile();
|
||||
if (rcFile)
|
||||
vimperator.io.source(rcFile.path, true);
|
||||
liberator.io.source(rcFile.path, true);
|
||||
else
|
||||
vimperator.log("No user RC file found", 3);
|
||||
liberator.log("No user RC file found", 3);
|
||||
|
||||
// also source plugins in ~/.vimperator/plugin/
|
||||
try
|
||||
{
|
||||
var pluginDir = vimperator.io.getSpecialDirectory("plugin");
|
||||
var pluginDir = liberator.io.getSpecialDirectory("plugin");
|
||||
if (pluginDir)
|
||||
{
|
||||
var files = vimperator.io.readDirectory(pluginDir.path);
|
||||
vimperator.log("Sourcing plugin directory...", 3);
|
||||
var files = liberator.io.readDirectory(pluginDir.path);
|
||||
liberator.log("Sourcing plugin directory...", 3);
|
||||
files.forEach(function (file) {
|
||||
if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path))
|
||||
vimperator.io.source(file.path, false);
|
||||
liberator.io.source(file.path, false);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
vimperator.log("No user plugin directory found", 3);
|
||||
liberator.log("No user plugin directory found", 3);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
// thrown if directory does not exist
|
||||
//vimperator.log("Error sourcing plugin directory: " + e);
|
||||
//liberator.log("Error sourcing plugin directory: " + e);
|
||||
}
|
||||
|
||||
// after sourcing the initialization files, this function will set
|
||||
// all gui options to their default values, if they have not been
|
||||
// set before by any rc file
|
||||
for (let option in vimperator.options)
|
||||
for (let option in liberator.options)
|
||||
{
|
||||
if (option.setter && !option.hasChanged)
|
||||
option.reset();
|
||||
}
|
||||
}, 0);
|
||||
|
||||
vimperator.statusline.update();
|
||||
vimperator.log("Vimperator fully initialized", 1);
|
||||
liberator.statusline.update();
|
||||
liberator.log("Vimperator fully initialized", 1);
|
||||
},
|
||||
|
||||
shutdown: function ()
|
||||
{
|
||||
// save our preferences
|
||||
vimperator.commandline.destroy();
|
||||
vimperator.quickmarks.destroy();
|
||||
vimperator.options.destroy();
|
||||
vimperator.events.destroy();
|
||||
liberator.commandline.destroy();
|
||||
liberator.quickmarks.destroy();
|
||||
liberator.options.destroy();
|
||||
liberator.events.destroy();
|
||||
|
||||
window.dump("All vimperator modules destroyed\n");
|
||||
window.dump("All liberator modules destroyed\n");
|
||||
},
|
||||
|
||||
sleep: function (ms)
|
||||
@@ -949,7 +949,7 @@ const vimperator = (function () //{{{
|
||||
})(); //}}}
|
||||
|
||||
// called when the chrome is fully loaded and before the main window is shown
|
||||
window.addEventListener("load", vimperator.startup, false);
|
||||
window.addEventListener("unload", vimperator.shutdown, false);
|
||||
window.addEventListener("load", liberator.startup, false);
|
||||
window.addEventListener("unload", liberator.shutdown, false);
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -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: "Vimperator",
|
||||
hostApplication: "Firefox",
|
||||
@@ -83,20 +83,20 @@ 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()
|
||||
{
|
||||
function incrementURL(count)
|
||||
{
|
||||
var url = vimperator.buffer.URL;
|
||||
var url = liberator.buffer.URL;
|
||||
var regex = /(.*?)(-?\d+)(\D*)$/;
|
||||
|
||||
var matches = url.match(regex);
|
||||
if (!matches || !matches[2]) // no number to increment
|
||||
{
|
||||
vimperator.beep();
|
||||
liberator.beep();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,62 +108,62 @@ vimperator.config = {
|
||||
newNum += "0"; // keep leading zeros
|
||||
newNum += nums[2];
|
||||
|
||||
vimperator.open(matches[1] + newNum + matches[3]);
|
||||
liberator.open(matches[1] + newNum + matches[3]);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL],
|
||||
liberator.mappings.add([liberator.modes.NORMAL],
|
||||
["y"], "Yank current location to the clipboard",
|
||||
function () { vimperator.copyToClipboard(vimperator.buffer.URL, true); });
|
||||
function () { liberator.copyToClipboard(liberator.buffer.URL, true); });
|
||||
|
||||
// opening websites
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL],
|
||||
liberator.mappings.add([liberator.modes.NORMAL],
|
||||
["o"], "Open one or more URLs",
|
||||
function () { vimperator.commandline.open(":", "open ", vimperator.modes.EX); });
|
||||
function () { liberator.commandline.open(":", "open ", liberator.modes.EX); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["O"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["O"],
|
||||
"Open one or more URLs, based on current location",
|
||||
function () { vimperator.commandline.open(":", "open " + vimperator.buffer.URL, vimperator.modes.EX); });
|
||||
function () { liberator.commandline.open(":", "open " + liberator.buffer.URL, liberator.modes.EX); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["t"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["t"],
|
||||
"Open one or more URLs in a new tab",
|
||||
function () { vimperator.commandline.open(":", "tabopen ", vimperator.modes.EX); });
|
||||
function () { liberator.commandline.open(":", "tabopen ", liberator.modes.EX); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["T"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["T"],
|
||||
"Open one or more URLs in a new tab, based on current location",
|
||||
function () { vimperator.commandline.open(":", "tabopen " + vimperator.buffer.URL, vimperator.modes.EX); });
|
||||
function () { liberator.commandline.open(":", "tabopen " + liberator.buffer.URL, liberator.modes.EX); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL],
|
||||
liberator.mappings.add([liberator.modes.NORMAL],
|
||||
["<C-a>"], "Increment last number in URL",
|
||||
function (count) { incrementURL(count > 1 ? count : 1); },
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL],
|
||||
liberator.mappings.add([liberator.modes.NORMAL],
|
||||
["<C-x>"], "Decrement last number in URL",
|
||||
function (count) { incrementURL(-(count > 1 ? count : 1)); },
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["~"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["~"],
|
||||
"Open home directory",
|
||||
function () { vimperator.open("~"); });
|
||||
function () { liberator.open("~"); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gh"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gh"],
|
||||
"Open homepage",
|
||||
function() { BrowserHome(); });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gH"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gH"],
|
||||
"Open homepage in a new tab",
|
||||
function ()
|
||||
{
|
||||
var homepages = gHomeButton.getHomePage();
|
||||
vimperator.open(homepages, /\bhomepage\b/.test(vimperator.options["activate"]) ?
|
||||
vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB);
|
||||
liberator.open(homepages, /\bhomepage\b/.test(liberator.options["activate"]) ?
|
||||
liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB);
|
||||
});
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gu"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gu"],
|
||||
"Go to parent directory",
|
||||
function (count)
|
||||
{
|
||||
@@ -172,7 +172,7 @@ vimperator.config = {
|
||||
if (/^file:\/|^\//.test(url))
|
||||
{
|
||||
//var strippedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2");
|
||||
var file = vimperator.io.getFile(url);
|
||||
var file = liberator.io.getFile(url);
|
||||
if (!file.exists() || !file.isDirectory())
|
||||
return false;
|
||||
else
|
||||
@@ -186,7 +186,7 @@ vimperator.config = {
|
||||
if (count < 1)
|
||||
count = 1;
|
||||
|
||||
var url = vimperator.buffer.URL;
|
||||
var url = liberator.buffer.URL;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
if (isDirectory(url))
|
||||
@@ -196,47 +196,47 @@ vimperator.config = {
|
||||
}
|
||||
url = url.replace(/^(.*:\/+.*?)\/+$/, "$1/"); // get rid of more than 1 / at the end
|
||||
|
||||
if (url == vimperator.buffer.URL)
|
||||
if (url == liberator.buffer.URL)
|
||||
{
|
||||
vimperator.beep();
|
||||
liberator.beep();
|
||||
return;
|
||||
}
|
||||
vimperator.open(url);
|
||||
liberator.open(url);
|
||||
},
|
||||
{ flags: vimperator.Mappings.flags.COUNT });
|
||||
{ flags: liberator.Mappings.flags.COUNT });
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gU"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["gU"],
|
||||
"Go to the root of the website",
|
||||
function ()
|
||||
{
|
||||
var uri = content.document.location;
|
||||
if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now
|
||||
{
|
||||
vimperator.beep();
|
||||
liberator.beep();
|
||||
return;
|
||||
}
|
||||
vimperator.open(uri.protocol + "//" + (uri.host || "") + "/");
|
||||
liberator.open(uri.protocol + "//" + (uri.host || "") + "/");
|
||||
});
|
||||
|
||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["<C-l>"],
|
||||
liberator.mappings.add([liberator.modes.NORMAL], ["<C-l>"],
|
||||
"Redraw the screen",
|
||||
function () { vimperator.commands.redraw(); });
|
||||
function () { liberator.commands.redraw(); });
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
vimperator.commands.add(["downl[oads]", "dl"],
|
||||
liberator.commands.add(["downl[oads]", "dl"],
|
||||
"Show progress of current downloads",
|
||||
function () { vimperator.open("chrome://mozapps/content/downloads/downloads.xul", vimperator.NEW_TAB); });
|
||||
function () { liberator.open("chrome://mozapps/content/downloads/downloads.xul", liberator.NEW_TAB); });
|
||||
|
||||
vimperator.commands.add(["o[pen]", "e[dit]"],
|
||||
liberator.commands.add(["o[pen]", "e[dit]"],
|
||||
"Open one or more URLs in the current tab",
|
||||
function (args, special)
|
||||
{
|
||||
if (args)
|
||||
{
|
||||
vimperator.open(args);
|
||||
liberator.open(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -247,10 +247,10 @@ vimperator.config = {
|
||||
}
|
||||
},
|
||||
{
|
||||
completer: function (filter) { return vimperator.completion.url(filter); }
|
||||
completer: function (filter) { return liberator.completion.url(filter); }
|
||||
});
|
||||
|
||||
vimperator.commands.add(["redr[aw]"],
|
||||
liberator.commands.add(["redr[aw]"],
|
||||
"Redraw the screen",
|
||||
function ()
|
||||
{
|
||||
@@ -260,13 +260,13 @@ vimperator.config = {
|
||||
});
|
||||
|
||||
// TODO: move sidebar commands to ui.js?
|
||||
vimperator.commands.add(["sbcl[ose]"],
|
||||
liberator.commands.add(["sbcl[ose]"],
|
||||
"Close the sidebar window",
|
||||
function (args)
|
||||
{
|
||||
if (args)
|
||||
{
|
||||
vimperator.echoerr("E488: Trailing characters");
|
||||
liberator.echoerr("E488: Trailing characters");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -274,13 +274,13 @@ vimperator.config = {
|
||||
toggleSidebar();
|
||||
});
|
||||
|
||||
vimperator.commands.add(["sideb[ar]", "sb[ar]", "sbope[n]"],
|
||||
liberator.commands.add(["sideb[ar]", "sb[ar]", "sbope[n]"],
|
||||
"Open the sidebar window",
|
||||
function (args)
|
||||
{
|
||||
if (!args)
|
||||
{
|
||||
vimperator.echoerr("E471: Argument required");
|
||||
liberator.echoerr("E471: Argument required");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -303,24 +303,24 @@ vimperator.config = {
|
||||
}
|
||||
},
|
||||
{
|
||||
completer: function (filter) { return vimperator.completion.sidebar(filter); }
|
||||
completer: function (filter) { return liberator.completion.sidebar(filter); }
|
||||
});
|
||||
|
||||
vimperator.commands.add(["winc[lose]", "wc[lose]"],
|
||||
liberator.commands.add(["winc[lose]", "wc[lose]"],
|
||||
"Close window",
|
||||
function (args) { window.close(); });
|
||||
|
||||
vimperator.commands.add(["wino[pen]", "wo[pen]", "wine[dit]"],
|
||||
liberator.commands.add(["wino[pen]", "wo[pen]", "wine[dit]"],
|
||||
"Open one or more URLs in a new window",
|
||||
function (args)
|
||||
{
|
||||
if (args)
|
||||
vimperator.open(args, vimperator.NEW_WINDOW);
|
||||
liberator.open(args, liberator.NEW_WINDOW);
|
||||
else
|
||||
vimperator.open("about:blank", vimperator.NEW_WINDOW);
|
||||
liberator.open("about:blank", liberator.NEW_WINDOW);
|
||||
},
|
||||
{
|
||||
completer: function (filter) { return vimperator.completion.url(filter); }
|
||||
completer: function (filter) { return liberator.completion.url(filter); }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,78 +60,78 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
<window id="main-window">
|
||||
|
||||
<keyset id="mainKeyset">
|
||||
<key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':', '', vimperator.modes.EX);" modifiers=""/>
|
||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="vimperator.events.onEscape();"/>
|
||||
<!-- other keys are handled inside vimperator.js event loop -->
|
||||
<key id="key_open_vimbar" key=":" oncommand="liberator.commandline.open(':', '', liberator.modes.EX);" modifiers=""/>
|
||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="liberator.events.onEscape();"/>
|
||||
<!-- other keys are handled inside the event loop in events.js -->
|
||||
</keyset>
|
||||
|
||||
<panel id="vimperator-visualbell"/>
|
||||
<panel id="liberator-visualbell"/>
|
||||
|
||||
<!--this notifies us also of focus events in the XUL
|
||||
from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !-->
|
||||
<commandset id="onVimperatorFocus"
|
||||
commandupdater="true"
|
||||
events="focus"
|
||||
oncommandupdate="vimperator.events.onFocusChange(event);"/>
|
||||
oncommandupdate="liberator.events.onFocusChange(event);"/>
|
||||
<commandset id="onVimperatorSelect"
|
||||
commandupdater="true"
|
||||
events="select"
|
||||
oncommandupdate="vimperator.events.onSelectionChange(event);"/>
|
||||
oncommandupdate="liberator.events.onSelectionChange(event);"/>
|
||||
|
||||
<vbox id="vimperator-container" hidden="false">
|
||||
<listbox id="vimperator-bufferwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||
onclick= "vimperator.bufferwindow.onEvent(event);"
|
||||
ondblclick="vimperator.bufferwindow.onEvent(event);"
|
||||
onkeydown= "vimperator.bufferwindow.onEvent(event);">
|
||||
<vbox id="liberator-container" hidden="false">
|
||||
<listbox id="liberator-bufferwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||
onclick= "liberator.bufferwindow.onEvent(event);"
|
||||
ondblclick="liberator.bufferwindow.onEvent(event);"
|
||||
onkeydown= "liberator.bufferwindow.onEvent(event);">
|
||||
<listcols>
|
||||
<listcol flex="1" width="50%"/>
|
||||
<listcol flex="1" width="50%"/>
|
||||
</listcols>
|
||||
</listbox>
|
||||
|
||||
<listbox id="vimperator-previewwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||
onclick= "vimperator.previewwindow.onEvent(event);"
|
||||
ondblclick="vimperator.previewwindow.onEvent(event);"
|
||||
onkeydown= "vimperator.previewwindow.onEvent(event);">
|
||||
<listbox id="liberator-previewwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||
onclick= "liberator.previewwindow.onEvent(event);"
|
||||
ondblclick="liberator.previewwindow.onEvent(event);"
|
||||
onkeydown= "liberator.previewwindow.onEvent(event);">
|
||||
<listcols>
|
||||
<listcol flex="1" width="50%"/>
|
||||
<listcol flex="1" width="50%"/>
|
||||
</listcols>
|
||||
</listbox>
|
||||
|
||||
<iframe id="vimperator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
||||
onclick="vimperator.commandline.onMultilineOutputEvent(event)"/>
|
||||
<iframe id="liberator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
||||
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
||||
|
||||
<listbox id="vimperator-completion" class="plain" rows="1" flex="1" hidden="true">
|
||||
<listbox id="liberator-completion" class="plain" rows="1" flex="1" hidden="true">
|
||||
<listcols>
|
||||
<listcol flex="1" width="50%"/>
|
||||
<listcol flex="1" width="50%"/>
|
||||
</listcols>
|
||||
</listbox>
|
||||
|
||||
<hbox id="vimperator-commandline" hidden="false" class="hl-Normal">
|
||||
<label class="plain" id="vimperator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox class="plain" id="vimperator-commandline-command" flex="1" type="timed" timeout="100"
|
||||
oninput="vimperator.commandline.onEvent(event);"
|
||||
onfocus="vimperator.commandline.onEvent(event);"
|
||||
onblur="vimperator.commandline.onEvent(event);"/>
|
||||
<hbox id="liberator-commandline" hidden="false" class="hl-Normal">
|
||||
<label class="plain" id="liberator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox class="plain" id="liberator-commandline-command" flex="1" type="timed" timeout="100"
|
||||
oninput="liberator.commandline.onEvent(event);"
|
||||
onfocus="liberator.commandline.onEvent(event);"
|
||||
onblur="liberator.commandline.onEvent(event);"/>
|
||||
</hbox>
|
||||
|
||||
<textbox id="vimperator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
||||
onkeypress="vimperator.commandline.onMultilineInputEvent(event);"
|
||||
oninput="vimperator.commandline.onMultilineInputEvent(event);"
|
||||
onblur="vimperator.commandline.onMultilineInputEvent(event);"/>
|
||||
<textbox id="liberator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
||||
onkeypress="liberator.commandline.onMultilineInputEvent(event);"
|
||||
oninput="liberator.commandline.onMultilineInputEvent(event);"
|
||||
onblur="liberator.commandline.onMultilineInputEvent(event);"/>
|
||||
</vbox>
|
||||
|
||||
</window>
|
||||
|
||||
<statusbar id="status-bar" class="hl-StatusLine">
|
||||
<hbox insertbefore="statusbar-display" id="vimperator-statusline" flex="1" height="10" hidden="false" align="center">
|
||||
<textbox class="plain" id="vimperator-statusline-field-url" readonly="false" flex="1" crop="end"/>
|
||||
<label class="plain" id="vimperator-statusline-field-inputbuffer" flex="0"/>
|
||||
<label class="plain" id="vimperator-statusline-field-progress" flex="0"/>
|
||||
<label class="plain" id="vimperator-statusline-field-tabcount" flex="0"/>
|
||||
<label class="plain" id="vimperator-statusline-field-bufferposition" flex="0"/>
|
||||
<hbox insertbefore="statusbar-display" id="liberator-statusline" flex="1" height="10" hidden="false" align="center">
|
||||
<textbox class="plain" id="liberator-statusline-field-url" readonly="false" flex="1" crop="end"/>
|
||||
<label class="plain" id="liberator-statusline-field-inputbuffer" flex="0"/>
|
||||
<label class="plain" id="liberator-statusline-field-progress" flex="0"/>
|
||||
<label class="plain" id="liberator-statusline-field-tabcount" flex="0"/>
|
||||
<label class="plain" id="liberator-statusline-field-bufferposition" flex="0"/>
|
||||
</hbox>
|
||||
<!-- just hide them since other elements expect them -->
|
||||
<statusbarpanel id="statusbar-display" hidden="true"/>
|
||||
|
||||
@@ -26,11 +26,11 @@ the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
}}} ***** END LICENSE BLOCK *****/
|
||||
|
||||
#vimperator-container {
|
||||
#liberator-container {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#vimperator-bufferwindow, #vimperator-completion, #vimperator-previewwindow {
|
||||
#liberator-bufferwindow, #liberator-completion, #liberator-previewwindow {
|
||||
-moz-user-focus: ignore;
|
||||
overflow: -moz-scrollbars-none !important; /* does not seem to work fully */
|
||||
border-width: 0px !important;
|
||||
@@ -38,9 +38,9 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
}
|
||||
|
||||
/* the selected item in listboxes is hardly readable without this */
|
||||
#vimperator-completion > listitem[selected="true"] > listcell,
|
||||
#vimperator-bufferwindow > listitem[selected="true"] > listcell,
|
||||
#vimperator-previewwindow > listitem[selected="true"] > listcell {
|
||||
#liberator-completion > listitem[selected="true"] > listcell,
|
||||
#liberator-bufferwindow > listitem[selected="true"] > listcell,
|
||||
#liberator-previewwindow > listitem[selected="true"] > listcell {
|
||||
background-color: Highlight !important;
|
||||
color: HighlightText !important;
|
||||
}
|
||||
@@ -53,17 +53,17 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
font-weight: bold;
|
||||
font-family: monospace;
|
||||
}
|
||||
#vimperator-statusline {
|
||||
#liberator-statusline {
|
||||
font-family: monospace;
|
||||
margin: 0px;
|
||||
}
|
||||
#vimperator-statusline > label {
|
||||
#liberator-statusline > label {
|
||||
padding: 0px 0px 0px 8px;
|
||||
}
|
||||
#vimperator-statusline > label:first-child {
|
||||
#liberator-statusline > label:first-child {
|
||||
padding: 0px;
|
||||
}
|
||||
#vimperator-statusline-field-url {
|
||||
#liberator-statusline-field-url {
|
||||
background-color: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
@@ -76,19 +76,19 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
display: none;
|
||||
}
|
||||
|
||||
#vimperator-commandline {
|
||||
#liberator-commandline {
|
||||
padding: 1px;
|
||||
/*
|
||||
background-color: white;
|
||||
color: black;
|
||||
*/
|
||||
}
|
||||
#vimperator-commandline-prompt, #vimperator-commandline-command {
|
||||
#liberator-commandline-prompt, #liberator-commandline-command {
|
||||
background-color: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#vimperator-visualbell {
|
||||
#liberator-visualbell {
|
||||
border: none;
|
||||
background-color: black;
|
||||
}
|
||||
@@ -158,29 +158,29 @@ a.hl-URL:hover {
|
||||
|
||||
/* MOW */
|
||||
|
||||
#vimperator-multiline-output {
|
||||
#liberator-multiline-output {
|
||||
overflow: hidden;
|
||||
background-color: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
#vimperator-multiline-output-content {
|
||||
#liberator-multiline-output-content {
|
||||
white-space: pre; /* -moz-pre-wrap FIXME: Should lines wrap like Vim? */
|
||||
font-family: -moz-fixed;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#vimperator-multiline-output-content * {
|
||||
#liberator-multiline-output-content * {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
#vimperator-multiline-output-content table {
|
||||
#liberator-multiline-output-content table {
|
||||
white-space: inherit;
|
||||
border-spacing: 0px;
|
||||
}
|
||||
|
||||
#vimperator-multiline-output-content td,
|
||||
#vimperator-multiline-output-content th {
|
||||
#liberator-multiline-output-content td,
|
||||
#liberator-multiline-output-content th {
|
||||
padding: 0px 2px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user