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 *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
// also includes methods for dealing with keywords and search engines
|
// also includes methods for dealing with keywords and search engines
|
||||||
vimperator.Bookmarks = function () //{{{
|
liberator.Bookmarks = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -47,7 +47,7 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
var bookmarks = null;
|
var bookmarks = null;
|
||||||
var keywords = null;
|
var keywords = null;
|
||||||
|
|
||||||
if (vimperator.options["preload"])
|
if (liberator.options["preload"])
|
||||||
setTimeout(function () { load(); }, 100);
|
setTimeout(function () { load(); }, 100);
|
||||||
|
|
||||||
function load()
|
function load()
|
||||||
@@ -98,10 +98,10 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.options.add(["defsearch", "ds"],
|
liberator.options.add(["defsearch", "ds"],
|
||||||
"Set the default search engine",
|
"Set the default search engine",
|
||||||
"string", "google");
|
"string", "google");
|
||||||
vimperator.options.add(["preload"],
|
liberator.options.add(["preload"],
|
||||||
"Speed up first time history/bookmark completion",
|
"Speed up first time history/bookmark completion",
|
||||||
"boolean", true);
|
"boolean", true);
|
||||||
|
|
||||||
@@ -109,86 +109,86 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// 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",
|
"Open a prompt to bookmark the current URL",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
var title = "";
|
var title = "";
|
||||||
if (vimperator.buffer.title != vimperator.buffer.URL)
|
if (liberator.buffer.title != liberator.buffer.URL)
|
||||||
title = " -title=\"" + vimperator.buffer.title + "\"";
|
title = " -title=\"" + liberator.buffer.title + "\"";
|
||||||
vimperator.commandline.open(":", "bmark " + vimperator.buffer.URL + title, vimperator.modes.EX);
|
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",
|
"Toggle bookmarked state of current URL",
|
||||||
function () { vimperator.bookmarks.toggle(vimperator.buffer.URL); });
|
function () { liberator.bookmarks.toggle(liberator.buffer.URL); });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["bma[rk]"],
|
liberator.commands.add(["bma[rk]"],
|
||||||
"Add a bookmark",
|
"Add a bookmark",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
var res = vimperator.commands.parseArgs(args, this.args);
|
var res = liberator.commands.parseArgs(args, this.args);
|
||||||
if (!res)
|
if (!res)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var url = res.args.length == 0 ? vimperator.buffer.URL : res.args[0];
|
var url = res.args.length == 0 ? liberator.buffer.URL : res.args[0];
|
||||||
var title = vimperator.commands.getOption(res.opts, "-title", res.args.length == 0 ? vimperator.buffer.title : null);
|
var title = liberator.commands.getOption(res.opts, "-title", res.args.length == 0 ? liberator.buffer.title : null);
|
||||||
if (!title)
|
if (!title)
|
||||||
title = url;
|
title = url;
|
||||||
var keyword = vimperator.commands.getOption(res.opts, "-keyword", null);
|
var keyword = liberator.commands.getOption(res.opts, "-keyword", null);
|
||||||
var tags = vimperator.commands.getOption(res.opts, "-tags", []);
|
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 = "";
|
var extra = "";
|
||||||
if (title != url)
|
if (title != url)
|
||||||
extra = " (" + title + ")";
|
extra = " (" + title + ")";
|
||||||
vimperator.echo("Added bookmark: " + url + extra, vimperator.commandline.FORCE_SINGLELINE);
|
liberator.echo("Added bookmark: " + url + extra, liberator.commandline.FORCE_SINGLELINE);
|
||||||
}
|
}
|
||||||
else
|
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],
|
args: [[["-title", "-t"], liberator.commands.OPTION_STRING],
|
||||||
[["-tags", "-T"], vimperator.commands.OPTION_LIST],
|
[["-tags", "-T"], liberator.commands.OPTION_LIST],
|
||||||
[["-keyword", "-k"], vimperator.commands.OPTION_STRING, function (arg) { return /\w/.test(arg); }]]
|
[["-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",
|
"List or open multiple bookmarks",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
var res = vimperator.commands.parseArgs(args, this.args);
|
var res = liberator.commands.parseArgs(args, this.args);
|
||||||
if (!res)
|
if (!res)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var tags = vimperator.commands.getOption(res.opts, "-tags", []);
|
var tags = liberator.commands.getOption(res.opts, "-tags", []);
|
||||||
vimperator.bookmarks.list(res.args.join(" "), tags, special);
|
liberator.bookmarks.list(res.args.join(" "), tags, special);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
completer: function (filter) { return [0, vimperator.bookmarks.get(filter)]; },
|
completer: function (filter) { return [0, liberator.bookmarks.get(filter)]; },
|
||||||
args: [[["-tags", "-T"], vimperator.commands.OPTION_LIST]]
|
args: [[["-tags", "-T"], liberator.commands.OPTION_LIST]]
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["delbm[arks]"],
|
liberator.commands.add(["delbm[arks]"],
|
||||||
"Delete a bookmark",
|
"Delete a bookmark",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
var url = args;
|
var url = args;
|
||||||
if (!url)
|
if (!url)
|
||||||
url = vimperator.buffer.URL;
|
url = liberator.buffer.URL;
|
||||||
|
|
||||||
var deletedCount = vimperator.bookmarks.remove(url);
|
var deletedCount = liberator.bookmarks.remove(url);
|
||||||
vimperator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", vimperator.commandline.FORCE_SINGLELINE);
|
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)
|
if (!bookmarks || bypassCache)
|
||||||
load();
|
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
|
// if starOnly = true it is saved in the unfiledBookmarksFolder, otherwise in the bookmarksMenuFolder
|
||||||
@@ -239,12 +239,12 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
vimperator.log(e);
|
liberator.log(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the display of our "bookmarked" symbol
|
// update the display of our "bookmarked" symbol
|
||||||
vimperator.statusline.updateUrl();
|
liberator.statusline.updateUrl();
|
||||||
|
|
||||||
//also update bookmark cache
|
//also update bookmark cache
|
||||||
bookmarks.unshift([url, title, keyword, tags || []]);
|
bookmarks.unshift([url, title, keyword, tags || []]);
|
||||||
@@ -259,16 +259,16 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
var count = this.remove(url);
|
var count = this.remove(url);
|
||||||
if (count > 0)
|
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
|
else
|
||||||
{
|
{
|
||||||
var title = vimperator.buffer.title || url;
|
var title = liberator.buffer.title || url;
|
||||||
var extra = "";
|
var extra = "";
|
||||||
if (title != url)
|
if (title != url)
|
||||||
extra = " (" + title + ")";
|
extra = " (" + title + ")";
|
||||||
this.add(true, title, url);
|
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)
|
catch (e)
|
||||||
{
|
{
|
||||||
vimperator.log(e);
|
liberator.log(e);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
load();
|
load();
|
||||||
|
|
||||||
// update the display of our "bookmarked" symbol
|
// update the display of our "bookmarked" symbol
|
||||||
vimperator.statusline.updateUrl();
|
liberator.statusline.updateUrl();
|
||||||
|
|
||||||
return count.value;
|
return count.value;
|
||||||
},
|
},
|
||||||
@@ -373,7 +373,7 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
var url = null;
|
var url = null;
|
||||||
var postData = null;
|
var postData = null;
|
||||||
if (!engineName)
|
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
|
// we need to make sure our custom alias have been set, even if the user
|
||||||
// did not :open <tab> once before
|
// did not :open <tab> once before
|
||||||
@@ -423,9 +423,9 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
if (items.length == 0)
|
if (items.length == 0)
|
||||||
{
|
{
|
||||||
if (filter.length > 0 || tags.length > 0)
|
if (filter.length > 0 || tags.length > 0)
|
||||||
vimperator.echoerr("E283: No bookmarks matching \"" + filter + "\"");
|
liberator.echoerr("E283: No bookmarks matching \"" + filter + "\"");
|
||||||
else
|
else
|
||||||
vimperator.echoerr("No bookmarks set");
|
liberator.echoerr("No bookmarks set");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -434,38 +434,38 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
{
|
{
|
||||||
// FIXME: use yes/no question
|
// FIXME: use yes/no question
|
||||||
if (items.length > 50)
|
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++)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var title, url, tags, keyword, extra;
|
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>";
|
"<table><tr align=\"left\" class=\"hl-Title\"><th>title</th><th>URL</th></tr>";
|
||||||
for (var i = 0; i < items.length; i++)
|
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)
|
if (title.length > 50)
|
||||||
title = title.substr(0, 47) + "...";
|
title = title.substr(0, 47) + "...";
|
||||||
url = vimperator.util.escapeHTML(items[i][0]);
|
url = liberator.util.escapeHTML(items[i][0]);
|
||||||
keyword = items[i][2];
|
keyword = items[i][2];
|
||||||
tags = items[i][3].join(", ");
|
tags = items[i][3].join(", ");
|
||||||
|
|
||||||
extra = "";
|
extra = "";
|
||||||
if (keyword)
|
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)
|
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
|
else
|
||||||
extra += ")</span>";
|
extra += ")</span>";
|
||||||
}
|
}
|
||||||
else if (tags)
|
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>";
|
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 /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -491,7 +491,7 @@ vimperator.History = function () //{{{
|
|||||||
|
|
||||||
var history = null;
|
var history = null;
|
||||||
|
|
||||||
if (vimperator.options["preload"])
|
if (liberator.options["preload"])
|
||||||
setTimeout(function () { load(); }, 100);
|
setTimeout(function () { load(); }, 100);
|
||||||
|
|
||||||
function load()
|
function load()
|
||||||
@@ -527,38 +527,38 @@ vimperator.History = function () //{{{
|
|||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// 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",
|
["<C-o>"], "Go to an older position in the jump list",
|
||||||
function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); },
|
function (count) { liberator.history.stepTo(-(count > 1 ? count : 1)); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
liberator.mappings.add(modes,
|
||||||
["<C-i>"], "Go to a newer position in the jump list",
|
["<C-i>"], "Go to a newer position in the jump list",
|
||||||
function (count) { vimperator.history.stepTo(count > 1 ? count : 1); },
|
function (count) { liberator.history.stepTo(count > 1 ? count : 1); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
liberator.mappings.add(modes,
|
||||||
["H", "<A-Left>", "<M-Left>"], "Go back in the browser history",
|
["H", "<A-Left>", "<M-Left>"], "Go back in the browser history",
|
||||||
function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); },
|
function (count) { liberator.history.stepTo(-(count > 1 ? count : 1)); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
liberator.mappings.add(modes,
|
||||||
["L", "<A-Right>", "<M-Right>"], "Go forward in the browser history",
|
["L", "<A-Right>", "<M-Right>"], "Go forward in the browser history",
|
||||||
function (count) { vimperator.history.stepTo(count > 1 ? count : 1); },
|
function (count) { liberator.history.stepTo(count > 1 ? count : 1); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["ba[ck]"],
|
liberator.commands.add(["ba[ck]"],
|
||||||
"Go back in the browser history",
|
"Go back in the browser history",
|
||||||
function (args, special, count)
|
function (args, special, count)
|
||||||
{
|
{
|
||||||
if (special)
|
if (special)
|
||||||
vimperator.history.goToStart();
|
liberator.history.goToStart();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (args)
|
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 entry = sh.getEntryAtIndex(i, false);
|
||||||
var url = entry.URI.spec;
|
var url = entry.URI.spec;
|
||||||
var title = entry.title;
|
var title = entry.title;
|
||||||
if (vimperator.completion.match([url, title], filter, false))
|
if (liberator.completion.match([url, title], filter, false))
|
||||||
completions.push([url, title]);
|
completions.push([url, title]);
|
||||||
}
|
}
|
||||||
return [0, completions];
|
return [0, completions];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["fo[rward]", "fw"],
|
liberator.commands.add(["fo[rward]", "fw"],
|
||||||
"Go forward in the browser history",
|
"Go forward in the browser history",
|
||||||
function (args, special, count)
|
function (args, special, count)
|
||||||
{
|
{
|
||||||
if (special)
|
if (special)
|
||||||
vimperator.history.goToEnd();
|
liberator.history.goToEnd();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (args)
|
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 entry = sh.getEntryAtIndex(i, false);
|
||||||
var url = entry.URI.spec;
|
var url = entry.URI.spec;
|
||||||
var title = entry.title;
|
var title = entry.title;
|
||||||
if (vimperator.completion.match([url, title], filter, false))
|
if (liberator.completion.match([url, title], filter, false))
|
||||||
completions.push([url, title]);
|
completions.push([url, title]);
|
||||||
}
|
}
|
||||||
return [0, completions];
|
return [0, completions];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["hist[ory]", "hs"],
|
liberator.commands.add(["hist[ory]", "hs"],
|
||||||
"Show recently visited URLs",
|
"Show recently visited URLs",
|
||||||
function (args, special) { vimperator.history.list(args, special); },
|
function (args, special) { liberator.history.list(args, special); },
|
||||||
{ completer: function (filter) { return [0, vimperator.history.get(filter)]; } });
|
{ completer: function (filter) { return [0, liberator.history.get(filter)]; } });
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
@@ -648,7 +648,7 @@ vimperator.History = function () //{{{
|
|||||||
if (!history)
|
if (!history)
|
||||||
load();
|
load();
|
||||||
|
|
||||||
return vimperator.completion.filterURLArray(history, filter);
|
return liberator.completion.filterURLArray(history, filter);
|
||||||
},
|
},
|
||||||
|
|
||||||
// the history is automatically added to the Places global history
|
// the history is automatically added to the Places global history
|
||||||
@@ -667,7 +667,7 @@ vimperator.History = function () //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// TODO: better names?
|
// TODO: better names?
|
||||||
// and move to vimperator.buffer.?
|
// and move to liberator.buffer.?
|
||||||
stepTo: function (steps)
|
stepTo: function (steps)
|
||||||
{
|
{
|
||||||
var index = getWebNavigation().sessionHistory.index + steps;
|
var index = getWebNavigation().sessionHistory.index + steps;
|
||||||
@@ -678,7 +678,7 @@ vimperator.History = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -688,7 +688,7 @@ vimperator.History = function () //{{{
|
|||||||
|
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,7 +702,7 @@ vimperator.History = function () //{{{
|
|||||||
|
|
||||||
if (index == max)
|
if (index == max)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,9 +716,9 @@ vimperator.History = function () //{{{
|
|||||||
if (items.length == 0)
|
if (items.length == 0)
|
||||||
{
|
{
|
||||||
if (filter.length > 0)
|
if (filter.length > 0)
|
||||||
vimperator.echoerr("E283: No history matching \"" + filter + "\"");
|
liberator.echoerr("E283: No history matching \"" + filter + "\"");
|
||||||
else
|
else
|
||||||
vimperator.echoerr("No history set");
|
liberator.echoerr("No history set");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -727,28 +727,28 @@ vimperator.History = function () //{{{
|
|||||||
{
|
{
|
||||||
// FIXME: use yes/no question
|
// FIXME: use yes/no question
|
||||||
if (items.length > 50)
|
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++)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
else
|
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>";
|
"<table><tr align=\"left\" class=\"hl-Title\"><th>title</th><th>URL</th></tr>";
|
||||||
for (var i = 0; i < items.length; i++)
|
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)
|
if (title.length > 50)
|
||||||
title = title.substr(0, 47) + "...";
|
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 += "<tr><td>" + title + "</td><td><a href=\"#\" class=\"hl-URL\">" + url + "</a></td></tr>";
|
||||||
}
|
}
|
||||||
list += "</table>";
|
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 /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -764,7 +764,7 @@ vimperator.QuickMarks = function () //{{{
|
|||||||
|
|
||||||
var qmarks = {};
|
var qmarks = {};
|
||||||
// TODO: move to a storage module
|
// 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
|
// load the saved quickmarks -- TODO: change to sqlite
|
||||||
for (var i = 0; i < savedMarks.length - 1; i += 2)
|
for (var i = 0; i < savedMarks.length - 1; i += 2)
|
||||||
@@ -775,95 +775,95 @@ vimperator.QuickMarks = function () //{{{
|
|||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// 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",
|
["go"], "Jump to a QuickMark",
|
||||||
function (arg) { vimperator.quickmarks.jumpTo(arg, vimperator.CURRENT_TAB); },
|
function (arg) { liberator.quickmarks.jumpTo(arg, liberator.CURRENT_TAB); },
|
||||||
{ flags: vimperator.Mappings.flags.ARGUMENT });
|
{ flags: liberator.Mappings.flags.ARGUMENT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
liberator.mappings.add(modes,
|
||||||
["gn"], "Jump to a QuickMark in a new tab",
|
["gn"], "Jump to a QuickMark in a new tab",
|
||||||
function (arg)
|
function (arg)
|
||||||
{
|
{
|
||||||
vimperator.quickmarks.jumpTo(arg,
|
liberator.quickmarks.jumpTo(arg,
|
||||||
/\bquickmark\b/.test(vimperator.options["activate"]) ?
|
/\bquickmark\b/.test(liberator.options["activate"]) ?
|
||||||
vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB);
|
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",
|
["M"], "Add new QuickMark for current URL",
|
||||||
function (arg)
|
function (arg)
|
||||||
{
|
{
|
||||||
if (/[^a-zA-Z0-9]/.test(arg))
|
if (/[^a-zA-Z0-9]/.test(arg))
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
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 ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["delqm[arks]"],
|
liberator.commands.add(["delqm[arks]"],
|
||||||
"Delete the specified QuickMarks",
|
"Delete the specified QuickMarks",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
// TODO: finish arg parsing - we really need a proper way to do this. :)
|
// TODO: finish arg parsing - we really need a proper way to do this. :)
|
||||||
if (!special && !args)
|
if (!special && !args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E471: Argument required");
|
liberator.echoerr("E471: Argument required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (special && args)
|
if (special && args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E474: Invalid argument");
|
liberator.echoerr("E474: Invalid argument");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (special)
|
if (special)
|
||||||
vimperator.quickmarks.removeAll();
|
liberator.quickmarks.removeAll();
|
||||||
else
|
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",
|
"Mark a URL with a letter for quick access",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E471: Argument required");
|
liberator.echoerr("E471: Argument required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches = args.match(/^([a-zA-Z0-9])(?:\s+(.+))?$/);
|
var matches = args.match(/^([a-zA-Z0-9])(?:\s+(.+))?$/);
|
||||||
if (!matches)
|
if (!matches)
|
||||||
vimperator.echoerr("E488: Trailing characters");
|
liberator.echoerr("E488: Trailing characters");
|
||||||
else if (!matches[2])
|
else if (!matches[2])
|
||||||
vimperator.quickmarks.add(matches[1], vimperator.buffer.URL);
|
liberator.quickmarks.add(matches[1], liberator.buffer.URL);
|
||||||
else
|
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",
|
"Show all QuickMarks",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
// ignore invalid mark characters unless there are no valid mark chars
|
// ignore invalid mark characters unless there are no valid mark chars
|
||||||
if (args && !/[a-zA-Z0-9]/.test(args))
|
if (args && !/[a-zA-Z0-9]/.test(args))
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E283: No QuickMarks matching \"" + args + "\"");
|
liberator.echoerr("E283: No QuickMarks matching \"" + args + "\"");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var filter = args.replace(/[^a-zA-Z0-9]/g, "");
|
var filter = args.replace(/[^a-zA-Z0-9]/g, "");
|
||||||
vimperator.quickmarks.list(filter);
|
liberator.quickmarks.list(filter);
|
||||||
});
|
});
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
@@ -897,9 +897,9 @@ vimperator.QuickMarks = function () //{{{
|
|||||||
var url = qmarks[qmark];
|
var url = qmarks[qmark];
|
||||||
|
|
||||||
if (url)
|
if (url)
|
||||||
vimperator.open(url, where);
|
liberator.open(url, where);
|
||||||
else
|
else
|
||||||
vimperator.echoerr("E20: QuickMark not set");
|
liberator.echoerr("E20: QuickMark not set");
|
||||||
},
|
},
|
||||||
|
|
||||||
list: function (filter)
|
list: function (filter)
|
||||||
@@ -913,7 +913,7 @@ vimperator.QuickMarks = function () //{{{
|
|||||||
|
|
||||||
if (marks.length == 0)
|
if (marks.length == 0)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("No QuickMarks set");
|
liberator.echoerr("No QuickMarks set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -925,21 +925,21 @@ vimperator.QuickMarks = function () //{{{
|
|||||||
});
|
});
|
||||||
if (marks.length == 0)
|
if (marks.length == 0)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E283: No QuickMarks matching \"" + filter + "\"");
|
liberator.echoerr("E283: No QuickMarks matching \"" + filter + "\"");
|
||||||
return;
|
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>";
|
"<table><tr align=\"left\" class=\"hl-Title\"><th>QuickMark</th><th>URL</th></tr>";
|
||||||
for (var i = 0; i < marks.length; i++)
|
for (var i = 0; i < marks.length; i++)
|
||||||
{
|
{
|
||||||
list += "<tr><td> " + marks[i][0] +
|
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>";
|
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 ()
|
destroy: function ()
|
||||||
@@ -953,7 +953,7 @@ vimperator.QuickMarks = function () //{{{
|
|||||||
savedQuickMarks += qmarks[i] + "\n";
|
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 *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
// Do NOT create instances of this class yourself, use the helper method
|
// Do NOT create instances of this class yourself, use the helper method
|
||||||
// vimperator.commands.add() instead
|
// liberator.commands.add() instead
|
||||||
vimperator.Command = function (specs, description, action, extraInfo) //{{{
|
liberator.Command = function (specs, description, action, extraInfo) //{{{
|
||||||
{
|
{
|
||||||
if (!specs || !action)
|
if (!specs || !action)
|
||||||
return null;
|
return null;
|
||||||
@@ -79,7 +79,7 @@ vimperator.Command = function (specs, description, action, extraInfo) //{{{
|
|||||||
this.isUserCommand = extraInfo.isUserCommand || false;
|
this.isUserCommand = extraInfo.isUserCommand || false;
|
||||||
};
|
};
|
||||||
|
|
||||||
vimperator.Command.prototype = {
|
liberator.Command.prototype = {
|
||||||
|
|
||||||
execute: function (args, special, count, modifiers)
|
execute: function (args, special, count, modifiers)
|
||||||
{
|
{
|
||||||
@@ -120,7 +120,7 @@ vimperator.Command.prototype = {
|
|||||||
};
|
};
|
||||||
//}}}
|
//}}}
|
||||||
|
|
||||||
vimperator.Commands = function () //{{{
|
liberator.Commands = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -284,7 +284,7 @@ vimperator.Commands = function () //{{{
|
|||||||
[count, arg] = getNextArg(sub.substr(optname.length + 1));
|
[count, arg] = getNextArg(sub.substr(optname.length + 1));
|
||||||
if (count == -1)
|
if (count == -1)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Invalid argument for option " + optname);
|
liberator.echoerr("Invalid argument for option " + optname);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ vimperator.Commands = function () //{{{
|
|||||||
[count, arg] = getNextArg(sub.substr(optname.length + 1));
|
[count, arg] = getNextArg(sub.substr(optname.length + 1));
|
||||||
if (count == -1)
|
if (count == -1)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Invalid argument for option " + optname);
|
liberator.echoerr("Invalid argument for option " + optname);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ vimperator.Commands = function () //{{{
|
|||||||
case commandManager.OPTION_NOARG:
|
case commandManager.OPTION_NOARG:
|
||||||
if (arg != null)
|
if (arg != null)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("No argument allowed for option: " + optname);
|
liberator.echoerr("No argument allowed for option: " + optname);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -329,14 +329,14 @@ vimperator.Commands = function () //{{{
|
|||||||
arg = false;
|
arg = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Invalid argument for boolean option: " + optname);
|
liberator.echoerr("Invalid argument for boolean option: " + optname);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case commandManager.OPTION_STRING:
|
case commandManager.OPTION_STRING:
|
||||||
if (arg == null)
|
if (arg == null)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Argument required for string option: " + optname);
|
liberator.echoerr("Argument required for string option: " + optname);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -344,7 +344,7 @@ vimperator.Commands = function () //{{{
|
|||||||
arg = parseInt(arg, 10);
|
arg = parseInt(arg, 10);
|
||||||
if (isNaN(arg))
|
if (isNaN(arg))
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Numeric argument required for integer option: " + optname);
|
liberator.echoerr("Numeric argument required for integer option: " + optname);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -352,14 +352,14 @@ vimperator.Commands = function () //{{{
|
|||||||
arg = parseFloat(arg);
|
arg = parseFloat(arg);
|
||||||
if (isNaN(arg))
|
if (isNaN(arg))
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Numeric argument required for float option: " + optname);
|
liberator.echoerr("Numeric argument required for float option: " + optname);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case commandManager.OPTION_LIST:
|
case commandManager.OPTION_LIST:
|
||||||
if (arg == null)
|
if (arg == null)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Argument required for list option: " + optname);
|
liberator.echoerr("Argument required for list option: " + optname);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
arg = arg.split(/\s*,\s*/);
|
arg = arg.split(/\s*,\s*/);
|
||||||
@@ -371,7 +371,7 @@ vimperator.Commands = function () //{{{
|
|||||||
{
|
{
|
||||||
if (options[opt][2].call(this, arg) == false)
|
if (options[opt][2].call(this, arg) == false)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Invalid argument for option: " + optname);
|
liberator.echoerr("Invalid argument for option: " + optname);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,7 @@ vimperator.Commands = function () //{{{
|
|||||||
var [count, arg] = getNextArg(sub);
|
var [count, arg] = getNextArg(sub);
|
||||||
if (count == -1)
|
if (count == -1)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Error parsing arguments: " + arg);
|
liberator.echoerr("Error parsing arguments: " + arg);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,7 +468,7 @@ vimperator.Commands = function () //{{{
|
|||||||
|
|
||||||
add: function (names, description, action, extra)
|
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)
|
if (!command)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ vimperator.Commands = function () //{{{
|
|||||||
if (exCommands[i].name == command.name)
|
if (exCommands[i].name == command.name)
|
||||||
{
|
{
|
||||||
// never replace for now
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -492,7 +492,7 @@ vimperator.Commands = function () //{{{
|
|||||||
extra.isUserCommand = true;
|
extra.isUserCommand = true;
|
||||||
description = description || "User defined command";
|
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)
|
if (!command)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -579,7 +579,7 @@ vimperator.Commands = function () //{{{
|
|||||||
var res = args.match(/^(\w+)(?:\s+(.+))?$/);
|
var res = args.match(/^(\w+)(?:\s+(.+))?$/);
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E182: Invalid command name");
|
liberator.echoerr("E182: Invalid command name");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var [cmd, rep] = [res[1], res[2]]
|
var [cmd, rep] = [res[1], res[2]]
|
||||||
@@ -587,12 +587,12 @@ vimperator.Commands = function () //{{{
|
|||||||
|
|
||||||
if (rep)
|
if (rep)
|
||||||
{
|
{
|
||||||
if (!vimperator.commands.addUserCommand([cmd],
|
if (!liberator.commands.addUserCommand([cmd],
|
||||||
"User defined command",
|
"User defined command",
|
||||||
function (args, special, count, modifiers) { eval(rep) }),
|
function (args, special, count, modifiers) { eval(rep) }),
|
||||||
special);
|
special);
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E174: Command already exists: add ! to replace it");
|
liberator.echoerr("E174: Command already exists: add ! to replace it");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -600,15 +600,15 @@ vimperator.Commands = function () //{{{
|
|||||||
var cmdlist = getUserCommands(cmd);
|
var cmdlist = getUserCommands(cmd);
|
||||||
if (cmdlist.length > 0)
|
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>";
|
"<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++)
|
for (var i = 0; i < cmdlist.length; i++)
|
||||||
str += "<tr><td>" + cmdlist[i].name + "</td><td>" + "*" + "</td><td>" + cmdlist[i].isUserCommand + "</td></tr>";
|
str += "<tr><td>" + cmdlist[i].name + "</td><td>" + "*" + "</td><td>" + cmdlist[i].isUserCommand + "</td></tr>";
|
||||||
str += "</table>"
|
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
|
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
|
// TODO: remove preview window, or change it at least
|
||||||
commandManager.add(["pc[lose]"],
|
commandManager.add(["pc[lose]"],
|
||||||
"Close preview window on bottom of screen",
|
"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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.Completion = function () //{{{
|
liberator.Completion = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -150,7 +150,7 @@ vimperator.Completion = function () //{{{
|
|||||||
dialog: function (filter)
|
dialog: function (filter)
|
||||||
{
|
{
|
||||||
substrings = [];
|
substrings = [];
|
||||||
var nodes = vimperator.config.dialogs || [];
|
var nodes = liberator.config.dialogs || [];
|
||||||
|
|
||||||
if (!filter)
|
if (!filter)
|
||||||
return [0, nodes];
|
return [0, nodes];
|
||||||
@@ -165,7 +165,7 @@ vimperator.Completion = function () //{{{
|
|||||||
macros: function (filter)
|
macros: function (filter)
|
||||||
{
|
{
|
||||||
var macros = [];
|
var macros = [];
|
||||||
var tmp = vimperator.events.getMacros();
|
var tmp = liberator.events.getMacros();
|
||||||
for (var item in tmp)
|
for (var item in tmp)
|
||||||
macros.push([item, tmp[item]]);
|
macros.push([item, tmp[item]]);
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ vimperator.Completion = function () //{{{
|
|||||||
filter = skip[2];
|
filter = skip[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
var cpt = complete || vimperator.options["complete"];
|
var cpt = complete || liberator.options["complete"];
|
||||||
// join all completion arrays together
|
// join all completion arrays together
|
||||||
for (var i = 0; i < cpt.length; i++)
|
for (var i = 0; i < cpt.length; i++)
|
||||||
{
|
{
|
||||||
@@ -204,9 +204,9 @@ vimperator.Completion = function () //{{{
|
|||||||
else if (cpt[i] == "f")
|
else if (cpt[i] == "f")
|
||||||
completions = completions.concat(this.file(filter, false)[1]);
|
completions = completions.concat(this.file(filter, false)[1]);
|
||||||
else if (cpt[i] == "b")
|
else if (cpt[i] == "b")
|
||||||
completions = completions.concat(vimperator.bookmarks.get(filter));
|
completions = completions.concat(liberator.bookmarks.get(filter));
|
||||||
else if (cpt[i] == "h")
|
else if (cpt[i] == "h")
|
||||||
completions = completions.concat(vimperator.history.get(filter));
|
completions = completions.concat(liberator.history.get(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [start, completions];
|
return [start, completions];
|
||||||
@@ -214,7 +214,7 @@ vimperator.Completion = function () //{{{
|
|||||||
|
|
||||||
search: function (filter)
|
search: function (filter)
|
||||||
{
|
{
|
||||||
var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords());
|
var engines = liberator.bookmarks.getSearchEngines().concat(liberator.bookmarks.getKeywords());
|
||||||
|
|
||||||
if (!filter)
|
if (!filter)
|
||||||
return [0, engines];
|
return [0, engines];
|
||||||
@@ -246,7 +246,7 @@ vimperator.Completion = function () //{{{
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
files = vimperator.io.readDirectory(dir);
|
files = liberator.io.readDirectory(dir);
|
||||||
mapped = files.map(function (file) {
|
mapped = files.map(function (file) {
|
||||||
return [[tail ? file.leafName : (dir + file.leafName)], file.isDirectory() ? "Directory" : "File"];
|
return [[tail ? file.leafName : (dir + file.leafName)], file.isDirectory() ? "Directory" : "File"];
|
||||||
});
|
});
|
||||||
@@ -275,12 +275,12 @@ vimperator.Completion = function () //{{{
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var xmlhttp = new XMLHttpRequest();
|
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);
|
xmlhttp.send(null);
|
||||||
}
|
}
|
||||||
catch (e)
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
var doc = xmlhttp.responseXML;
|
var doc = xmlhttp.responseXML;
|
||||||
@@ -305,12 +305,12 @@ vimperator.Completion = function () //{{{
|
|||||||
|
|
||||||
if (!filter)
|
if (!filter)
|
||||||
{
|
{
|
||||||
for (var command in vimperator.commands)
|
for (var command in liberator.commands)
|
||||||
completions.push([command.name, command.description]);
|
completions.push([command.name, command.description]);
|
||||||
return [0, completions];
|
return [0, completions];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var command in vimperator.commands)
|
for (var command in liberator.commands)
|
||||||
completions.push([command.longNames, command.description]);
|
completions.push([command.longNames, command.description]);
|
||||||
|
|
||||||
return [0, buildLongestStartingSubstring(completions, filter)];
|
return [0, buildLongestStartingSubstring(completions, filter)];
|
||||||
@@ -330,7 +330,7 @@ vimperator.Completion = function () //{{{
|
|||||||
if (unfiltered)
|
if (unfiltered)
|
||||||
{
|
{
|
||||||
var options = [];
|
var options = [];
|
||||||
for (var option in vimperator.options)
|
for (var option in liberator.options)
|
||||||
{
|
{
|
||||||
if (prefix && option.type != "boolean")
|
if (prefix && option.type != "boolean")
|
||||||
continue;
|
continue;
|
||||||
@@ -353,7 +353,7 @@ vimperator.Completion = function () //{{{
|
|||||||
var name = prefArray[i];
|
var name = prefArray[i];
|
||||||
if (name.match("^" + filter.substr(0, filter.length - 1) + "$" ))
|
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, ""]]];
|
return [filter.length + 1, [[value, ""]]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -363,9 +363,9 @@ vimperator.Completion = function () //{{{
|
|||||||
for (var i = 0; i < prefArray.length; i++)
|
for (var i = 0; i < prefArray.length; i++)
|
||||||
{
|
{
|
||||||
if (!filter)
|
if (!filter)
|
||||||
optionCompletions.push([prefArray[i], vimperator.options.getPref(prefArray[i])]);
|
optionCompletions.push([prefArray[i], liberator.options.getPref(prefArray[i])]);
|
||||||
else
|
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)
|
if (!filter)
|
||||||
{
|
{
|
||||||
var options = [];
|
var options = [];
|
||||||
for (var option in vimperator.options)
|
for (var option in liberator.options)
|
||||||
{
|
{
|
||||||
if (prefix && option.type != "boolean")
|
if (prefix && option.type != "boolean")
|
||||||
continue;
|
continue;
|
||||||
@@ -390,7 +390,7 @@ vimperator.Completion = function () //{{{
|
|||||||
else if (filter.length > 0 && filter.lastIndexOf("=") == filter.length - 1)
|
else if (filter.length > 0 && filter.lastIndexOf("=") == filter.length - 1)
|
||||||
{
|
{
|
||||||
filter = filter.substr(0, 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))
|
if (option.hasName(filter))
|
||||||
return [filter.length + 1, [[option.value + "", ""]]];
|
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)
|
// can't use b_l_s_s, since this has special requirements (the prefix)
|
||||||
var filterLength = filter.length;
|
var filterLength = filter.length;
|
||||||
for (var option in vimperator.options)
|
for (var option in liberator.options)
|
||||||
{
|
{
|
||||||
if (prefix && option.type != "boolean")
|
if (prefix && option.type != "boolean")
|
||||||
continue;
|
continue;
|
||||||
@@ -533,7 +533,7 @@ vimperator.Completion = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
objects.push("vimperator");
|
objects.push("liberator");
|
||||||
objects.push("window");
|
objects.push("window");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,7 +546,7 @@ vimperator.Completion = function () //{{{
|
|||||||
"var comp = [];" +
|
"var comp = [];" +
|
||||||
"var type = '';" +
|
"var type = '';" +
|
||||||
"var value = '';" +
|
"var value = '';" +
|
||||||
"var obj = eval('with(vimperator){" + objects[o] + "}');" +
|
"var obj = eval('with(liberator){" + objects[o] + "}');" +
|
||||||
"for (var i in obj) {" +
|
"for (var i in obj) {" +
|
||||||
" try { type = typeof(obj[i]); } catch (e) { type = 'unknown type'; };" +
|
" try { type = typeof(obj[i]); } catch (e) { type = 'unknown type'; };" +
|
||||||
" if (type == 'number' || type == 'string' || type == 'boolean') {" +
|
" 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>"
|
// TODO: get completions for "nested" command lines like ":time :js <tab>" or ":tab :he<tab>"
|
||||||
exTabCompletion: function (str)
|
exTabCompletion: function (str)
|
||||||
{
|
{
|
||||||
var [count, cmd, special, args] = vimperator.commands.parseCommand(str);
|
var [count, cmd, special, args] = liberator.commands.parseCommand(str);
|
||||||
var completions = [];
|
var completions = [];
|
||||||
var start = 0;
|
var start = 0;
|
||||||
var exLength = 0;
|
var exLength = 0;
|
||||||
@@ -699,7 +699,7 @@ vimperator.Completion = function () //{{{
|
|||||||
return [matches[1].length, this.command(cmd)[1]];
|
return [matches[1].length, this.command(cmd)[1]];
|
||||||
|
|
||||||
// dynamically get completions as specified with the command's completer function
|
// 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)
|
if (command && command.completer)
|
||||||
{
|
{
|
||||||
matches = str.match(/^:*\d*\w+!?\s+/);
|
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:
|
// command names taken from:
|
||||||
// http://developer.mozilla.org/en/docs/Editor_Embedding_Guide
|
// http://developer.mozilla.org/en/docs/Editor_Embedding_Guide
|
||||||
|
|
||||||
vimperator.Editor = function () //{{{
|
liberator.Editor = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -56,15 +56,15 @@ vimperator.Editor = function () //{{{
|
|||||||
|
|
||||||
function selectPreviousLine()
|
function selectPreviousLine()
|
||||||
{
|
{
|
||||||
vimperator.editor.executeCommand("cmd_selectLinePrevious");
|
liberator.editor.executeCommand("cmd_selectLinePrevious");
|
||||||
if ((vimperator.modes.extended & vimperator.modes.LINE) && !vimperator.editor.selectedText())
|
if ((liberator.modes.extended & liberator.modes.LINE) && !liberator.editor.selectedText())
|
||||||
vimperator.editor.executeCommand("cmd_selectLinePrevious");
|
liberator.editor.executeCommand("cmd_selectLinePrevious");
|
||||||
}
|
}
|
||||||
function selectNextLine()
|
function selectNextLine()
|
||||||
{
|
{
|
||||||
vimperator.editor.executeCommand("cmd_selectLineNext");
|
liberator.editor.executeCommand("cmd_selectLineNext");
|
||||||
if ((vimperator.modes.extended & vimperator.modes.LINE) && !vimperator.editor.selectedText())
|
if ((liberator.modes.extended & liberator.modes.LINE) && !liberator.editor.selectedText())
|
||||||
vimperator.editor.executeCommand("cmd_selectLineNext");
|
liberator.editor.executeCommand("cmd_selectLineNext");
|
||||||
}
|
}
|
||||||
|
|
||||||
// add mappings for commands like h,j,k,l,etc. in CARET, VISUAL and TEXTAREA mode
|
// 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 = {};
|
var extraInfo = {};
|
||||||
if (hasCount)
|
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)
|
function (count)
|
||||||
{
|
{
|
||||||
if (typeof count != "number" || count < 1)
|
if (typeof count != "number" || count < 1)
|
||||||
@@ -90,7 +90,7 @@ vimperator.Editor = function () //{{{
|
|||||||
},
|
},
|
||||||
extraInfo);
|
extraInfo);
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.VISUAL], keys, "",
|
liberator.mappings.add([liberator.modes.VISUAL], keys, "",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
if (typeof count != "number" || count < 1 || !hasCount)
|
if (typeof count != "number" || count < 1 || !hasCount)
|
||||||
@@ -103,12 +103,12 @@ vimperator.Editor = function () //{{{
|
|||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
if (vimperator.modes.extended & vimperator.modes.TEXTAREA)
|
if (liberator.modes.extended & liberator.modes.TEXTAREA)
|
||||||
{
|
{
|
||||||
if (typeof visualTextareaCommand == "function")
|
if (typeof visualTextareaCommand == "function")
|
||||||
visualTextareaCommand();
|
visualTextareaCommand();
|
||||||
else
|
else
|
||||||
vimperator.editor.executeCommand(visualTextareaCommand);
|
liberator.editor.executeCommand(visualTextareaCommand);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
controller[caretModeMethod](caretModeArg, true);
|
controller[caretModeMethod](caretModeArg, true);
|
||||||
@@ -116,13 +116,13 @@ vimperator.Editor = function () //{{{
|
|||||||
},
|
},
|
||||||
extraInfo);
|
extraInfo);
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.TEXTAREA], keys, "",
|
liberator.mappings.add([liberator.modes.TEXTAREA], keys, "",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
if (typeof count != "number" || count < 1)
|
if (typeof count != "number" || count < 1)
|
||||||
count = 1;
|
count = 1;
|
||||||
|
|
||||||
vimperator.editor.executeCommand(textareaCommand, count);
|
liberator.editor.executeCommand(textareaCommand, count);
|
||||||
},
|
},
|
||||||
extraInfo);
|
extraInfo);
|
||||||
}
|
}
|
||||||
@@ -130,22 +130,22 @@ vimperator.Editor = function () //{{{
|
|||||||
// add mappings for commands like i,a,s,c,etc. in TEXTAREA mode
|
// add mappings for commands like i,a,s,c,etc. in TEXTAREA mode
|
||||||
function addBeginInsertModeMap(keys, commands)
|
function addBeginInsertModeMap(keys, commands)
|
||||||
{
|
{
|
||||||
vimperator.mappings.add([vimperator.modes.TEXTAREA], keys, "",
|
liberator.mappings.add([liberator.modes.TEXTAREA], keys, "",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
for (let c = 0; c < commands.length; c++)
|
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)
|
function addMotionMap(key)
|
||||||
{
|
{
|
||||||
vimperator.mappings.add([vimperator.modes.TEXTAREA], [key],
|
liberator.mappings.add([liberator.modes.TEXTAREA], [key],
|
||||||
"Motion command",
|
"Motion command",
|
||||||
function (motion, count) { vimperator.editor.executeCommandWithMotion(key, motion, count); },
|
function (motion, count) { liberator.editor.executeCommandWithMotion(key, motion, count); },
|
||||||
{ flags: vimperator.Mappings.flags.MOTION | vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.MOTION | liberator.Mappings.flags.COUNT });
|
||||||
}
|
}
|
||||||
|
|
||||||
// mode = "i" -> add :iabbrev, :iabclear and :iunabbrev commands
|
// mode = "i" -> add :iabbrev, :iabclear and :iunabbrev commands
|
||||||
@@ -154,42 +154,42 @@ vimperator.Editor = function () //{{{
|
|||||||
var modeDescription = modeDescription ? " in " + modeDescription + " mode" : "";
|
var modeDescription = modeDescription ? " in " + modeDescription + " mode" : "";
|
||||||
var mode = char || "!";
|
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,
|
"Abbreviate a key sequence" + modeDescription,
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
vimperator.editor.listAbbreviations(mode, "");
|
liberator.editor.listAbbreviations(mode, "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches = args.match(/^([^\s]+)(?:\s+(.+))?$/);
|
var matches = args.match(/^([^\s]+)(?:\s+(.+))?$/);
|
||||||
var [lhs, rhs] = [matches[1], matches[2]];
|
var [lhs, rhs] = [matches[1], matches[2]];
|
||||||
if (rhs)
|
if (rhs)
|
||||||
vimperator.editor.addAbbreviation(mode, lhs, rhs);
|
liberator.editor.addAbbreviation(mode, lhs, rhs);
|
||||||
else
|
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,
|
"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,
|
"Remove all abbreviations" + modeDescription,
|
||||||
function (args) { vimperator.editor.removeAllAbbreviations(mode); });
|
function (args) { liberator.editor.removeAllAbbreviations(mode); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.options.add(["editor"],
|
liberator.options.add(["editor"],
|
||||||
"Set the external text editor",
|
"Set the external text editor",
|
||||||
"string", "gvim -f");
|
"string", "gvim -f");
|
||||||
|
|
||||||
vimperator.options.add(["insertmode", "im"],
|
liberator.options.add(["insertmode", "im"],
|
||||||
"Use Insert mode as the default for text areas",
|
"Use Insert mode as the default for text areas",
|
||||||
"boolean", true);
|
"boolean", true);
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ vimperator.Editor = function () //{{{
|
|||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// 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 */
|
/* KEYS COUNT CARET TEXTAREA VISUAL_TEXTAREA */
|
||||||
addMovementMap(["k", "<Up>"], true, "lineMove", false, "cmd_linePrevious", selectPreviousLine);
|
addMovementMap(["k", "<Up>"], true, "lineMove", false, "cmd_linePrevious", selectPreviousLine);
|
||||||
@@ -226,218 +226,218 @@ vimperator.Editor = function () //{{{
|
|||||||
addMotionMap("y"); // yank
|
addMotionMap("y"); // yank
|
||||||
|
|
||||||
// insert mode mappings
|
// insert mode mappings
|
||||||
vimperator.mappings.add(modes,
|
liberator.mappings.add(modes,
|
||||||
["<C-w>"], "Delete previous word",
|
["<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",
|
["<C-u>"], "Delete until beginning of current line",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
// broken in FF3, deletes the whole line:
|
// broken in FF3, deletes the whole line:
|
||||||
// vimperator.editor.executeCommand("cmd_deleteToBeginningOfLine", 1);
|
// liberator.editor.executeCommand("cmd_deleteToBeginningOfLine", 1);
|
||||||
vimperator.editor.executeCommand("cmd_selectBeginLine", 1);
|
liberator.editor.executeCommand("cmd_selectBeginLine", 1);
|
||||||
vimperator.editor.executeCommand("cmd_delete", 1);
|
liberator.editor.executeCommand("cmd_delete", 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
liberator.mappings.add(modes,
|
||||||
["<C-k>"], "Delete until end of current line",
|
["<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",
|
["<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",
|
["<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",
|
["<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",
|
["<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",
|
["<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",
|
["<C-i>"], "Edit text field with an external editor",
|
||||||
function () { vimperator.editor.editWithExternalEditor(); });
|
function () { liberator.editor.editWithExternalEditor(); });
|
||||||
|
|
||||||
// FIXME: <esc> does not work correctly
|
// 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",
|
["<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",
|
["<Space>", "<Return>"], "Expand insert mode abbreviation",
|
||||||
function () { return vimperator.editor.expandAbbreviation("i"); },
|
function () { return liberator.editor.expandAbbreviation("i"); },
|
||||||
{ flags: vimperator.Mappings.flags.ALLOW_EVENT_ROUTING });
|
{ flags: liberator.Mappings.flags.ALLOW_EVENT_ROUTING });
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.INSERT],
|
liberator.mappings.add([liberator.modes.INSERT],
|
||||||
["<Tab>"], "Expand insert mode abbreviation",
|
["<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",
|
["<C-]>", "<C-5>"], "Expand insert mode abbreviation",
|
||||||
function () { vimperator.editor.expandAbbreviation("i"); });
|
function () { liberator.editor.expandAbbreviation("i"); });
|
||||||
|
|
||||||
// textarea mode
|
// textarea mode
|
||||||
vimperator.mappings.add([vimperator.modes.TEXTAREA],
|
liberator.mappings.add([liberator.modes.TEXTAREA],
|
||||||
["u"], "Undo",
|
["u"], "Undo",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
vimperator.editor.executeCommand("cmd_undo", count);
|
liberator.editor.executeCommand("cmd_undo", count);
|
||||||
vimperator.mode = vimperator.modes.TEXTAREA;
|
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",
|
["<C-r>"], "Redo",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
vimperator.editor.executeCommand("cmd_redo", count);
|
liberator.editor.executeCommand("cmd_redo", count);
|
||||||
vimperator.mode = vimperator.modes.TEXTAREA;
|
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",
|
["o"], "Open line below current",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
vimperator.editor.executeCommand("cmd_endLine", 1);
|
liberator.editor.executeCommand("cmd_endLine", 1);
|
||||||
vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA);
|
liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA);
|
||||||
vimperator.events.feedkeys("<Return>");
|
liberator.events.feedkeys("<Return>");
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.TEXTAREA],
|
liberator.mappings.add([liberator.modes.TEXTAREA],
|
||||||
["O"], "Open line above current",
|
["O"], "Open line above current",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
vimperator.editor.executeCommand("cmd_beginLine", 1);
|
liberator.editor.executeCommand("cmd_beginLine", 1);
|
||||||
vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA);
|
liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA);
|
||||||
vimperator.events.feedkeys("<Return>");
|
liberator.events.feedkeys("<Return>");
|
||||||
vimperator.editor.executeCommand("cmd_linePrevious", 1);
|
liberator.editor.executeCommand("cmd_linePrevious", 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// visual mode
|
// 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",
|
["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",
|
["V"], "Start visual line mode",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
vimperator.modes.set(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA | vimperator.modes.LINE);
|
liberator.modes.set(liberator.modes.VISUAL, liberator.modes.TEXTAREA | liberator.modes.LINE);
|
||||||
vimperator.editor.executeCommand("cmd_beginLine", 1);
|
liberator.editor.executeCommand("cmd_beginLine", 1);
|
||||||
vimperator.editor.executeCommand("cmd_selectLineNext", 1);
|
liberator.editor.executeCommand("cmd_selectLineNext", 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.VISUAL],
|
liberator.mappings.add([liberator.modes.VISUAL],
|
||||||
["c", "s"], "Change selected text",
|
["c", "s"], "Change selected text",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
if (vimperator.modes.extended & vimperator.modes.TEXTAREA)
|
if (liberator.modes.extended & liberator.modes.TEXTAREA)
|
||||||
{
|
{
|
||||||
vimperator.editor.executeCommand("cmd_cut");
|
liberator.editor.executeCommand("cmd_cut");
|
||||||
vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA);
|
liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.VISUAL],
|
liberator.mappings.add([liberator.modes.VISUAL],
|
||||||
["d"], "Delete selected text",
|
["d"], "Delete selected text",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
if (vimperator.modes.extended & vimperator.modes.TEXTAREA)
|
if (liberator.modes.extended & liberator.modes.TEXTAREA)
|
||||||
{
|
{
|
||||||
vimperator.editor.executeCommand("cmd_cut");
|
liberator.editor.executeCommand("cmd_cut");
|
||||||
vimperator.modes.set(vimperator.modes.TEXTAREA);
|
liberator.modes.set(liberator.modes.TEXTAREA);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.VISUAL],
|
liberator.mappings.add([liberator.modes.VISUAL],
|
||||||
["y"], "Yank selected text",
|
["y"], "Yank selected text",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
if (vimperator.modes.extended & vimperator.modes.TEXTAREA)
|
if (liberator.modes.extended & liberator.modes.TEXTAREA)
|
||||||
{
|
{
|
||||||
vimperator.editor.executeCommand("cmd_copy");
|
liberator.editor.executeCommand("cmd_copy");
|
||||||
vimperator.modes.set(vimperator.modes.TEXTAREA);
|
liberator.modes.set(liberator.modes.TEXTAREA);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var sel = window.content.document.getSelection();
|
var sel = window.content.document.getSelection();
|
||||||
if (sel)
|
if (sel)
|
||||||
vimperator.copyToClipboard(sel, true);
|
liberator.copyToClipboard(sel, true);
|
||||||
else
|
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",
|
["p"], "Paste clipboard contents",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
if (!(vimperator.modes.extended & vimperator.modes.CARET))
|
if (!(liberator.modes.extended & liberator.modes.CARET))
|
||||||
{
|
{
|
||||||
if (!count) count = 1;
|
if (!count) count = 1;
|
||||||
while (count--)
|
while (count--)
|
||||||
vimperator.editor.executeCommand("cmd_paste");
|
liberator.editor.executeCommand("cmd_paste");
|
||||||
vimperator.mode = vimperator.modes.TEXTAREA;
|
liberator.mode = liberator.modes.TEXTAREA;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
});
|
});
|
||||||
|
|
||||||
// finding characters
|
// 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",
|
["f"], "Move to a character on the current line after the cursor",
|
||||||
function (count, arg)
|
function (count, arg)
|
||||||
{
|
{
|
||||||
var pos = vimperator.editor.findCharForward(arg, count);
|
var pos = liberator.editor.findCharForward(arg, count);
|
||||||
if (pos >= 0)
|
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",
|
["F"], "Move to a charater on the current line before the cursor",
|
||||||
function (count, arg)
|
function (count, arg)
|
||||||
{
|
{
|
||||||
var pos = vimperator.editor.findCharBackward(arg, count);
|
var pos = liberator.editor.findCharBackward(arg, count);
|
||||||
if (pos >= 0)
|
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",
|
["t"], "Move before a character on the current line",
|
||||||
function (count, arg)
|
function (count, arg)
|
||||||
{
|
{
|
||||||
var pos = vimperator.editor.findCharForward(arg, count);
|
var pos = liberator.editor.findCharForward(arg, count);
|
||||||
if (pos >= 0)
|
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",
|
["T"], "Move before a character on the current line, backwards",
|
||||||
function (count, arg)
|
function (count, arg)
|
||||||
{
|
{
|
||||||
var pos = vimperator.editor.findCharBackward(arg, count);
|
var pos = liberator.editor.findCharBackward(arg, count);
|
||||||
if (pos >= 0)
|
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 ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
@@ -514,7 +514,7 @@ vimperator.Editor = function () //{{{
|
|||||||
var controller = getController();
|
var controller = getController();
|
||||||
if (!controller || !controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd))
|
if (!controller || !controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd))
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ vimperator.Editor = function () //{{{
|
|||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
if (!didCommand)
|
if (!didCommand)
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -556,7 +556,7 @@ vimperator.Editor = function () //{{{
|
|||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.modes.set(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA);
|
liberator.modes.set(liberator.modes.VISUAL, liberator.modes.TEXTAREA);
|
||||||
|
|
||||||
switch (motion)
|
switch (motion)
|
||||||
{
|
{
|
||||||
@@ -601,7 +601,7 @@ vimperator.Editor = function () //{{{
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,11 +610,11 @@ vimperator.Editor = function () //{{{
|
|||||||
case "d":
|
case "d":
|
||||||
this.executeCommand("cmd_delete", 1);
|
this.executeCommand("cmd_delete", 1);
|
||||||
// need to reset the mode as the visual selection changes it
|
// need to reset the mode as the visual selection changes it
|
||||||
vimperator.modes.main = vimperator.modes.TEXTAREA;
|
liberator.modes.main = liberator.modes.TEXTAREA;
|
||||||
break;
|
break;
|
||||||
case "c":
|
case "c":
|
||||||
this.executeCommand("cmd_delete", 1);
|
this.executeCommand("cmd_delete", 1);
|
||||||
vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA);
|
liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA);
|
||||||
break;
|
break;
|
||||||
case "y":
|
case "y":
|
||||||
this.executeCommand("cmd_copy", 1);
|
this.executeCommand("cmd_copy", 1);
|
||||||
@@ -622,7 +622,7 @@ vimperator.Editor = function () //{{{
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -687,7 +687,7 @@ vimperator.Editor = function () //{{{
|
|||||||
return i + 1; // always position the cursor after the char
|
return i + 1; // always position the cursor after the char
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return -1;
|
return -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -714,37 +714,37 @@ vimperator.Editor = function () //{{{
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return -1;
|
return -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
editWithExternalEditor: function ()
|
editWithExternalEditor: function ()
|
||||||
{
|
{
|
||||||
var textBox = document.commandDispatcher.focusedElement;
|
var textBox = document.commandDispatcher.focusedElement;
|
||||||
var editor = vimperator.options["editor"];
|
var editor = liberator.options["editor"];
|
||||||
var args = editor.split(" ");
|
var args = editor.split(" ");
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("no editor specified");
|
liberator.echoerr("no editor specified");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var tmpfile = vimperator.io.createTempFile();
|
var tmpfile = liberator.io.createTempFile();
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("Could not create temporary file: " + e.message);
|
liberator.echoerr("Could not create temporary file: " + e.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
vimperator.io.writeFile(tmpfile, textBox.value);
|
liberator.io.writeFile(tmpfile, textBox.value);
|
||||||
}
|
}
|
||||||
catch (e)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,26 +757,26 @@ vimperator.Editor = function () //{{{
|
|||||||
textBox.style.backgroundColor = "#bbbbbb";
|
textBox.style.backgroundColor = "#bbbbbb";
|
||||||
var newThread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0);
|
var newThread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0);
|
||||||
// TODO: save return value in v:shell_error
|
// 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");
|
textBox.removeAttribute("readonly");
|
||||||
|
|
||||||
|
|
||||||
// if (v:shell_error != 0)
|
// if (v:shell_error != 0)
|
||||||
// {
|
// {
|
||||||
// tmpBg = "red";
|
// tmpBg = "red";
|
||||||
// vimperator.echoerr("External editor returned with exit code " + retcode);
|
// liberator.echoerr("External editor returned with exit code " + retcode);
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var val = vimperator.io.readFile(tmpfile);
|
var val = liberator.io.readFile(tmpfile);
|
||||||
textBox.value = val;
|
textBox.value = val;
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
tmpBg = "red";
|
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++)
|
for (var i = 0; i < abbrev[lhs].length; i++)
|
||||||
{
|
{
|
||||||
if (abbrev[lhs][i][0] == filter)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vimperator.echoerr("No abbreviations found");
|
liberator.echoerr("No abbreviations found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else // list all (for that filter {i,c,!})
|
else // list all (for that filter {i,c,!})
|
||||||
@@ -846,8 +846,8 @@ vimperator.Editor = function () //{{{
|
|||||||
|
|
||||||
list += "<tr>";
|
list += "<tr>";
|
||||||
list += "<td> " + abbrev[tmplhs][i][0] + "</td>";
|
list += "<td> " + abbrev[tmplhs][i][0] + "</td>";
|
||||||
list += "<td> " + vimperator.util.escapeHTML(tmplhs) + "</td>";
|
list += "<td> " + liberator.util.escapeHTML(tmplhs) + "</td>";
|
||||||
list += "<td> " + vimperator.util.escapeHTML(abbrev[tmplhs][i][1]) + "</td>";
|
list += "<td> " + liberator.util.escapeHTML(abbrev[tmplhs][i][1]) + "</td>";
|
||||||
list += "</tr>";
|
list += "</tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -855,11 +855,11 @@ vimperator.Editor = function () //{{{
|
|||||||
|
|
||||||
if (!flagFound)
|
if (!flagFound)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("No abbreviations found");
|
liberator.echoerr("No abbreviations found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
list += "</table>";
|
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)
|
if (!lhs)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E474: Invalid argument");
|
liberator.echoerr("E474: Invalid argument");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -987,7 +987,7 @@ vimperator.Editor = function () //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.echoerr("E24: No such abbreviation");
|
liberator.echoerr("E24: No such abbreviation");
|
||||||
return false;
|
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
|
// : changing any search settings should also update the search state including highlighting
|
||||||
// : incremental searches shouldn't permanently update search modifiers
|
// : incremental searches shouldn't permanently update search modifiers
|
||||||
|
|
||||||
// make sure you only create this object when the "vimperator" object is ready
|
// make sure you only create this object when the "liberator" object is ready
|
||||||
vimperator.Search = function () //{{{
|
liberator.Search = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
// FIXME:
|
// 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 found = false; // true if the last search was successful
|
||||||
var backwards = false; // currently searching backwards
|
var backwards = false; // currently searching backwards
|
||||||
var searchString = ""; // current search string (without modifiers)
|
var searchString = ""; // current search string (without modifiers)
|
||||||
@@ -56,13 +56,13 @@ vimperator.Search = function () //{{{
|
|||||||
var linksOnly = false; // search is limited to link text only
|
var linksOnly = false; // search is limited to link text only
|
||||||
|
|
||||||
// Event handlers for search - closure is needed
|
// Event handlers for search - closure is needed
|
||||||
vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchKeyPressed(command); });
|
liberator.registerCallback("change", liberator.modes.SEARCH_FORWARD, function (command) { liberator.search.searchKeyPressed(command); });
|
||||||
vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchSubmitted(command); });
|
liberator.registerCallback("submit", liberator.modes.SEARCH_FORWARD, function (command) { liberator.search.searchSubmitted(command); });
|
||||||
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function () { vimperator.search.searchCanceled(); });
|
liberator.registerCallback("cancel", liberator.modes.SEARCH_FORWARD, function () { liberator.search.searchCanceled(); });
|
||||||
// TODO: allow advanced modes in register/triggerCallback
|
// TODO: allow advanced modes in register/triggerCallback
|
||||||
vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchKeyPressed(command); });
|
liberator.registerCallback("change", liberator.modes.SEARCH_BACKWARD, function (command) { liberator.search.searchKeyPressed(command); });
|
||||||
vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchSubmitted(command); });
|
liberator.registerCallback("submit", liberator.modes.SEARCH_BACKWARD, function (command) { liberator.search.searchSubmitted(command); });
|
||||||
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { vimperator.search.searchCanceled(); });
|
liberator.registerCallback("cancel", liberator.modes.SEARCH_BACKWARD, function () { liberator.search.searchCanceled(); });
|
||||||
|
|
||||||
// set searchString, searchPattern, caseSensitive, linksOnly
|
// set searchString, searchPattern, caseSensitive, linksOnly
|
||||||
function processUserPattern(pattern)
|
function processUserPattern(pattern)
|
||||||
@@ -80,7 +80,7 @@ vimperator.Search = function () //{{{
|
|||||||
linksOnly = false;
|
linksOnly = false;
|
||||||
else if (/\L/.test(pattern))
|
else if (/\L/.test(pattern))
|
||||||
linksOnly = true;
|
linksOnly = true;
|
||||||
else if (vimperator.options["linksearch"])
|
else if (liberator.options["linksearch"])
|
||||||
linksOnly = true;
|
linksOnly = true;
|
||||||
else
|
else
|
||||||
linksOnly = false;
|
linksOnly = false;
|
||||||
@@ -93,9 +93,9 @@ vimperator.Search = function () //{{{
|
|||||||
caseSensitive = false;
|
caseSensitive = false;
|
||||||
else if (/\C/.test(pattern))
|
else if (/\C/.test(pattern))
|
||||||
caseSensitive = true;
|
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;
|
caseSensitive = true;
|
||||||
else if (vimperator.options["ignorecase"])
|
else if (liberator.options["ignorecase"])
|
||||||
caseSensitive = false;
|
caseSensitive = false;
|
||||||
else
|
else
|
||||||
caseSensitive = true;
|
caseSensitive = true;
|
||||||
@@ -113,36 +113,36 @@ vimperator.Search = function () //{{{
|
|||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.options.add(["hlsearch", "hls"],
|
liberator.options.add(["hlsearch", "hls"],
|
||||||
"Highlight previous search pattern matches",
|
"Highlight previous search pattern matches",
|
||||||
"boolean", "false",
|
"boolean", "false",
|
||||||
{
|
{
|
||||||
setter: function (value)
|
setter: function (value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
vimperator.search.highlight();
|
liberator.search.highlight();
|
||||||
else
|
else
|
||||||
vimperator.search.clear();
|
liberator.search.clear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.options.add(["hlsearchstyle", "hlss"],
|
liberator.options.add(["hlsearchstyle", "hlss"],
|
||||||
"CSS specification of highlighted search items",
|
"CSS specification of highlighted search items",
|
||||||
"string", "color: black; background-color: yellow; padding: 0; display: inline;");
|
"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",
|
"Ignore case in search patterns",
|
||||||
"boolean", true);
|
"boolean", true);
|
||||||
|
|
||||||
vimperator.options.add(["incsearch", "is"],
|
liberator.options.add(["incsearch", "is"],
|
||||||
"Show where the search pattern matches as it is typed",
|
"Show where the search pattern matches as it is typed",
|
||||||
"boolean", true);
|
"boolean", true);
|
||||||
|
|
||||||
vimperator.options.add(["linksearch", "lks"],
|
liberator.options.add(["linksearch", "lks"],
|
||||||
"Limit the search to hyperlink text",
|
"Limit the search to hyperlink text",
|
||||||
"boolean", false);
|
"boolean", false);
|
||||||
|
|
||||||
vimperator.options.add(["smartcase", "scs"],
|
liberator.options.add(["smartcase", "scs"],
|
||||||
"Override the 'ignorecase' option if the pattern contains uppercase characters",
|
"Override the 'ignorecase' option if the pattern contains uppercase characters",
|
||||||
"boolean", true);
|
"boolean", true);
|
||||||
|
|
||||||
@@ -150,48 +150,48 @@ vimperator.Search = function () //{{{
|
|||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var modes = vimperator.config.browserModes || [vimperator.modes.NORMAL];
|
var modes = liberator.config.browserModes || [liberator.modes.NORMAL];
|
||||||
modes = modes.concat([vimperator.modes.CARET]);
|
modes = modes.concat([liberator.modes.CARET]);
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
liberator.mappings.add(modes,
|
||||||
["/"], "Search forward for a pattern",
|
["/"], "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",
|
["?"], "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",
|
["n"], "Find next",
|
||||||
function () { vimperator.search.findAgain(false); });
|
function () { liberator.search.findAgain(false); });
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
liberator.mappings.add(modes,
|
||||||
["N"], "Find previous",
|
["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",
|
"Find word under cursor",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
vimperator.search.searchSubmitted(vimperator.buffer.getCurrentWord(), false);
|
liberator.search.searchSubmitted(liberator.buffer.getCurrentWord(), false);
|
||||||
vimperator.search.findAgain();
|
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",
|
"Find word under cursor backwards",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
vimperator.search.searchSubmitted(vimperator.buffer.getCurrentWord(), true);
|
liberator.search.searchSubmitted(liberator.buffer.getCurrentWord(), true);
|
||||||
vimperator.search.findAgain();
|
liberator.search.findAgain();
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["noh[lsearch]"],
|
liberator.commands.add(["noh[lsearch]"],
|
||||||
"Remove the search highlighting",
|
"Remove the search highlighting",
|
||||||
function (args) { vimperator.search.clear(); });
|
function (args) { liberator.search.clear(); });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
@@ -203,14 +203,14 @@ vimperator.Search = function () //{{{
|
|||||||
// If you omit "mode", it will default to forward searching
|
// If you omit "mode", it will default to forward searching
|
||||||
openSearchDialog: function (mode)
|
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;
|
backwards = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vimperator.commandline.open("/", "", vimperator.modes.SEARCH_FORWARD);
|
liberator.commandline.open("/", "", liberator.modes.SEARCH_FORWARD);
|
||||||
backwards = false;
|
backwards = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ vimperator.Search = function () //{{{
|
|||||||
found = fastFind.find(searchString, linksOnly) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND;
|
found = fastFind.find(searchString, linksOnly) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND;
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
setTimeout(function () { vimperator.echoerr("E486: Pattern not found: " + searchPattern); }, 0);
|
setTimeout(function () { liberator.echoerr("E486: Pattern not found: " + searchPattern); }, 0);
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
},
|
},
|
||||||
@@ -248,7 +248,7 @@ vimperator.Search = function () //{{{
|
|||||||
|
|
||||||
if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND)
|
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)
|
else if (result == Components.interfaces.nsITypeAheadFind.FIND_WRAPPED)
|
||||||
{
|
{
|
||||||
@@ -256,16 +256,16 @@ vimperator.Search = function () //{{{
|
|||||||
// our command line
|
// our command line
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (up)
|
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
|
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);
|
}, 0);
|
||||||
}
|
}
|
||||||
else
|
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);
|
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
|
// Called when the user types a key in the search dialog. Triggers a find attempt if 'incsearch' is set
|
||||||
searchKeyPressed: function (command)
|
searchKeyPressed: function (command)
|
||||||
{
|
{
|
||||||
if (vimperator.options["incsearch"])
|
if (liberator.options["incsearch"])
|
||||||
this.find(command, backwards);
|
this.find(command, backwards);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -298,12 +298,12 @@ vimperator.Search = function () //{{{
|
|||||||
// TODO: move to find() when reverse incremental searching is kludged in
|
// TODO: move to find() when reverse incremental searching is kludged in
|
||||||
// need to find again for reverse searching
|
// need to find again for reverse searching
|
||||||
if (backwards)
|
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);
|
this.highlight(searchString);
|
||||||
|
|
||||||
vimperator.modes.reset();
|
liberator.modes.reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
// Called when the search is canceled - for example if someone presses
|
// 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'
|
// this is not dependent on the value of 'hlsearch'
|
||||||
highlight: function (text)
|
highlight: function (text)
|
||||||
{
|
{
|
||||||
if (vimperator.config.name == "Muttator")
|
if (liberator.config.name == "Muttator")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// already highlighted?
|
// already highlighted?
|
||||||
@@ -338,7 +338,7 @@ vimperator.Search = function () //{{{
|
|||||||
arguments.callee(win.frames[i]);
|
arguments.callee(win.frames[i]);
|
||||||
var spans = window.content.document.getElementsByClassName("__mozilla-findbar-search");
|
var spans = window.content.document.getElementsByClassName("__mozilla-findbar-search");
|
||||||
for (var i = 0; i < spans.length; i++)
|
for (var i = 0; i < spans.length; i++)
|
||||||
spans[i].setAttribute("style", vimperator.options["hlsearchstyle"]);
|
spans[i].setAttribute("style", liberator.options["hlsearchstyle"]);
|
||||||
})(window.content);
|
})(window.content);
|
||||||
|
|
||||||
// recreate selection since _highlightDoc collapses the selection backwards
|
// 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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.Hints = function () //{{{
|
liberator.Hints = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// 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 submode = ""; // used for extended mode, can be "o", "t", "y", etc.
|
||||||
var hintString = ""; // the typed string part of the hint is in this string
|
var hintString = ""; // the typed string part of the hint is in this string
|
||||||
@@ -53,7 +53,7 @@ vimperator.Hints = function () //{{{
|
|||||||
// reset all important variables
|
// reset all important variables
|
||||||
function reset()
|
function reset()
|
||||||
{
|
{
|
||||||
vimperator.statusline.updateInputBuffer("");
|
liberator.statusline.updateInputBuffer("");
|
||||||
hintString = "";
|
hintString = "";
|
||||||
hintNumber = 0;
|
hintNumber = 0;
|
||||||
usedTabKey = false;
|
usedTabKey = false;
|
||||||
@@ -70,7 +70,7 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
function updateStatusline()
|
function updateStatusline()
|
||||||
{
|
{
|
||||||
vimperator.statusline.updateInputBuffer((escapeNumbers ? vimperator.events.getMapLeader() + " ": "") + // sign for escapeNumbers
|
liberator.statusline.updateInputBuffer((escapeNumbers ? liberator.events.getMapLeader() + " ": "") + // sign for escapeNumbers
|
||||||
(hintString ? "\"" + hintString + "\"" : "") +
|
(hintString ? "\"" + hintString + "\"" : "") +
|
||||||
(hintNumber > 0 ? " <" + hintNumber + ">" : ""));
|
(hintNumber > 0 ? " <" + hintNumber + ">" : ""));
|
||||||
}
|
}
|
||||||
@@ -98,11 +98,11 @@ vimperator.Hints = function () //{{{
|
|||||||
baseNodeAbsolute.style.padding = "0px 1px 0px 0px";
|
baseNodeAbsolute.style.padding = "0px 1px 0px 0px";
|
||||||
baseNodeAbsolute.style.zIndex = "10000001";
|
baseNodeAbsolute.style.zIndex = "10000001";
|
||||||
baseNodeAbsolute.style.display = "none";
|
baseNodeAbsolute.style.display = "none";
|
||||||
baseNodeAbsolute.className = "vimperator-hint";
|
baseNodeAbsolute.className = "liberator-hint";
|
||||||
|
|
||||||
var elem, tagname, text, span, rect;
|
var elem, tagname, text, span, rect;
|
||||||
var res = vimperator.buffer.evaluateXPath(vimperator.options["hinttags"], doc, null, true);
|
var res = liberator.buffer.evaluateXPath(liberator.options["hinttags"], doc, null, true);
|
||||||
vimperator.log("evaluated XPath after: " + (Date.now() - startDate) + "ms");
|
liberator.log("evaluated XPath after: " + (Date.now() - startDate) + "ms");
|
||||||
|
|
||||||
var fragment = doc.createDocumentFragment();
|
var fragment = doc.createDocumentFragment();
|
||||||
var start = hints.length;
|
var start = hints.length;
|
||||||
@@ -146,7 +146,7 @@ vimperator.Hints = function () //{{{
|
|||||||
for (var i = 0; i < win.frames.length; i++)
|
for (var i = 0; i < win.frames.length; i++)
|
||||||
generate(win.frames[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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ vimperator.Hints = function () //{{{
|
|||||||
var height = win.innerHeight;
|
var height = win.innerHeight;
|
||||||
var width = win.innerWidth;
|
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 elem, tagname, text, rect, span, imgspan;
|
||||||
var hintnum = 1;
|
var hintnum = 1;
|
||||||
@@ -224,7 +224,7 @@ vimperator.Hints = function () //{{{
|
|||||||
imgspan.style.top = (rect.top + scrollY) + "px";
|
imgspan.style.top = (rect.top + scrollY) + "px";
|
||||||
imgspan.style.width = (rect.right - rect.left) + "px";
|
imgspan.style.width = (rect.right - rect.left) + "px";
|
||||||
imgspan.style.height = (rect.bottom - rect.top) + "px";
|
imgspan.style.height = (rect.bottom - rect.top) + "px";
|
||||||
imgspan.className = "vimperator-hint";
|
imgspan.className = "liberator-hint";
|
||||||
hints[i][3] = imgspan;
|
hints[i][3] = imgspan;
|
||||||
doc.body.appendChild(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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ vimperator.Hints = function () //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.log("removeHints() done");
|
liberator.log("removeHints() done");
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ vimperator.Hints = function () //{{{
|
|||||||
{
|
{
|
||||||
if (validHints.length == 0)
|
if (validHints.length == 0)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,49 +342,49 @@ vimperator.Hints = function () //{{{
|
|||||||
switch (submode)
|
switch (submode)
|
||||||
{
|
{
|
||||||
// TODO: move/rename those helper functions to a better place
|
// TODO: move/rename those helper functions to a better place
|
||||||
case ";": vimperator.buffer.focusElement(elem); break;
|
case ";": liberator.buffer.focusElement(elem); break;
|
||||||
case "?": vimperator.buffer.showElementInfo(elem); break;
|
case "?": liberator.buffer.showElementInfo(elem); break;
|
||||||
case "a": vimperator.buffer.saveLink(elem, false); break;
|
case "a": liberator.buffer.saveLink(elem, false); break;
|
||||||
case "s": vimperator.buffer.saveLink(elem, true); break;
|
case "s": liberator.buffer.saveLink(elem, true); break;
|
||||||
case "o": vimperator.buffer.followLink(elem, vimperator.CURRENT_TAB); break;
|
case "o": liberator.buffer.followLink(elem, liberator.CURRENT_TAB); break;
|
||||||
case "O": vimperator.commandline.open(":", "open " + loc, vimperator.modes.EX); break;
|
case "O": liberator.commandline.open(":", "open " + loc, liberator.modes.EX); break;
|
||||||
case "t": vimperator.buffer.followLink(elem, vimperator.NEW_TAB); break;
|
case "t": liberator.buffer.followLink(elem, liberator.NEW_TAB); break;
|
||||||
case "T": vimperator.commandline.open(":", "tabopen " + loc, vimperator.modes.EX); break;
|
case "T": liberator.commandline.open(":", "tabopen " + loc, liberator.modes.EX); break;
|
||||||
case "v": vimperator.buffer.viewSource(loc, false); break;
|
case "v": liberator.buffer.viewSource(loc, false); break;
|
||||||
case "V": vimperator.buffer.viewSource(loc, true); break;
|
case "V": liberator.buffer.viewSource(loc, true); break;
|
||||||
case "w": vimperator.buffer.followLink(elem, vimperator.NEW_WINDOW); break;
|
case "w": liberator.buffer.followLink(elem, liberator.NEW_WINDOW); break;
|
||||||
case "W": vimperator.commandline.open(":", "winopen " + loc, vimperator.modes.EX); break;
|
case "W": liberator.commandline.open(":", "winopen " + loc, liberator.modes.EX); break;
|
||||||
case "y": setTimeout(function(){vimperator.copyToClipboard(loc, true)}, timeout + 50); break;
|
case "y": setTimeout(function(){liberator.copyToClipboard(loc, true)}, timeout + 50); break;
|
||||||
case "Y": setTimeout(function(){vimperator.copyToClipboard(elem.textContent || "", true)}, timeout + 50); break;
|
case "Y": setTimeout(function(){liberator.copyToClipboard(elem.textContent || "", true)}, timeout + 50); break;
|
||||||
default:
|
default:
|
||||||
vimperator.echoerr("INTERNAL ERROR: unknown submode: " + submode);
|
liberator.echoerr("INTERNAL ERROR: unknown submode: " + submode);
|
||||||
}
|
}
|
||||||
removeHints(timeout);
|
removeHints(timeout);
|
||||||
|
|
||||||
if (vimperator.modes.extended & vimperator.modes.ALWAYS_HINT)
|
if (liberator.modes.extended & liberator.modes.ALWAYS_HINT)
|
||||||
{
|
{
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
canUpdate = true;
|
canUpdate = true;
|
||||||
hintString = "";
|
hintString = "";
|
||||||
hintNumber = 0;
|
hintNumber = 0;
|
||||||
vimperator.statusline.updateInputBuffer("");
|
liberator.statusline.updateInputBuffer("");
|
||||||
}, timeout);
|
}, timeout);
|
||||||
}
|
}
|
||||||
else
|
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
|
// force a possible mode change, based on wheter an input field has focus
|
||||||
vimperator.events.onFocusChange();
|
liberator.events.onFocusChange();
|
||||||
if (vimperator.mode == vimperator.modes.HINTS)
|
if (liberator.mode == liberator.modes.HINTS)
|
||||||
vimperator.modes.reset(false);
|
liberator.modes.reset(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vimperator.modes.add(vimperator.modes.INACTIVE_HINT);
|
liberator.modes.add(liberator.modes.INACTIVE_HINT);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (vimperator.mode == vimperator.modes.HINTS)
|
if (liberator.mode == liberator.modes.HINTS)
|
||||||
vimperator.modes.reset(false);
|
liberator.modes.reset(false);
|
||||||
}, timeout);
|
}, 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:*[@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";
|
"//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 ';'",
|
"XPath string of hintable elements activated by ';'",
|
||||||
"string", DEFAULT_HINTTAGS);
|
"string", DEFAULT_HINTTAGS);
|
||||||
vimperator.options.add(["focusedhintstyle", "fhs"],
|
liberator.options.add(["focusedhintstyle", "fhs"],
|
||||||
"CSS specification of focused hints",
|
"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;");
|
"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",
|
"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;");
|
"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'",
|
"XPath string of hintable elements activated by 'f' and 'F'",
|
||||||
"string", DEFAULT_HINTTAGS);
|
"string", DEFAULT_HINTTAGS);
|
||||||
vimperator.options.add(["hinttimeout", "hto"],
|
liberator.options.add(["hinttimeout", "hto"],
|
||||||
"Automatically follow non unique numerical hint",
|
"Automatically follow non unique numerical hint",
|
||||||
"number", 0,
|
"number", 0,
|
||||||
{
|
{
|
||||||
@@ -424,26 +424,26 @@ vimperator.Hints = function () //{{{
|
|||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["f"],
|
liberator.mappings.add(modes, ["f"],
|
||||||
"Start QuickHint mode",
|
"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",
|
"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",
|
"Start an extended hint mode",
|
||||||
function (arg)
|
function (arg)
|
||||||
{
|
{
|
||||||
if (arg == "f")
|
if (arg == "f")
|
||||||
vimperator.hints.show(vimperator.modes.ALWAYS_HINT, "o");
|
liberator.hints.show(liberator.modes.ALWAYS_HINT, "o");
|
||||||
else if (arg == "F")
|
else if (arg == "F")
|
||||||
vimperator.hints.show(vimperator.modes.ALWAYS_HINT, "t");
|
liberator.hints.show(liberator.modes.ALWAYS_HINT, "t");
|
||||||
else
|
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
|
// TODO: implement framesets
|
||||||
show: function (mode, minor, filter)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.modes.set(vimperator.modes.HINTS, mode);
|
liberator.modes.set(liberator.modes.HINTS, mode);
|
||||||
submode = minor || "o"; // open is the default mode
|
submode = minor || "o"; // open is the default mode
|
||||||
hintString = filter || "";
|
hintString = filter || "";
|
||||||
hintNumber = 0;
|
hintNumber = 0;
|
||||||
@@ -479,8 +479,8 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
if (validHints.length == 0)
|
if (validHints.length == 0)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
vimperator.modes.reset();
|
liberator.modes.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (validHints.length == 1)
|
else if (validHints.length == 1)
|
||||||
@@ -499,7 +499,7 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
onEvent: function (event)
|
onEvent: function (event)
|
||||||
{
|
{
|
||||||
var key = vimperator.events.toString(event);
|
var key = liberator.events.toString(event);
|
||||||
var followFirst = false;
|
var followFirst = false;
|
||||||
|
|
||||||
// clear any timeout which might be active after pressing a number
|
// clear any timeout which might be active after pressing a number
|
||||||
@@ -555,7 +555,7 @@ vimperator.Hints = function () //{{{
|
|||||||
{
|
{
|
||||||
usedTabKey = false;
|
usedTabKey = false;
|
||||||
hintNumber = 0;
|
hintNumber = 0;
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -566,7 +566,7 @@ vimperator.Hints = function () //{{{
|
|||||||
hintNumber = 0;
|
hintNumber = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vimperator.events.getMapLeader():
|
case liberator.events.getMapLeader():
|
||||||
escapeNumbers = !escapeNumbers;
|
escapeNumbers = !escapeNumbers;
|
||||||
if (escapeNumbers && usedTabKey) // hintNumber not used normally, but someone may wants to toggle
|
if (escapeNumbers && usedTabKey) // hintNumber not used normally, but someone may wants to toggle
|
||||||
hintNumber = 0; // <tab>s ? reset. Prevent to show numbers not entered.
|
hintNumber = 0; // <tab>s ? reset. Prevent to show numbers not entered.
|
||||||
@@ -575,18 +575,18 @@ vimperator.Hints = function () //{{{
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
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 == ":")
|
if (/^<./.test(key) || key == ":")
|
||||||
{
|
{
|
||||||
var map = null;
|
var map = null;
|
||||||
if ((map = vimperator.mappings.get(vimperator.modes.NORMAL, key)) ||
|
if ((map = liberator.mappings.get(liberator.modes.NORMAL, key)) ||
|
||||||
(map = vimperator.mappings.get(vimperator.modes.HINTS, key)))
|
(map = liberator.mappings.get(liberator.modes.HINTS, key)))
|
||||||
{
|
{
|
||||||
map.execute(null, -1);
|
map.execute(null, -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,7 +615,7 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
if (hintNumber == 0 || hintNumber > validHints.length)
|
if (hintNumber == 0 || hintNumber > validHints.length)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,7 +623,7 @@ vimperator.Hints = function () //{{{
|
|||||||
// the hint after a timeout, as the user might have wanted to follow link 34
|
// the hint after a timeout, as the user might have wanted to follow link 34
|
||||||
if (hintNumber > 0 && hintNumber * 10 <= validHints.length)
|
if (hintNumber > 0 && hintNumber * 10 <= validHints.length)
|
||||||
{
|
{
|
||||||
var timeout = vimperator.options["hinttimeout"];
|
var timeout = liberator.options["hinttimeout"];
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
activeTimeout = setTimeout(function () { processHints(true); }, timeout);
|
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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.IO = function () //{{{
|
liberator.IO = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -38,39 +38,39 @@ vimperator.IO = function () //{{{
|
|||||||
|
|
||||||
const WINDOWS = navigator.platform == "Win32";
|
const WINDOWS = navigator.platform == "Win32";
|
||||||
var cwd = null, oldcwd = null;
|
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 :!
|
var lastRunCommand = ""; // updated whenever the users runs a command with :!
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["cd", "chd[ir]"],
|
liberator.commands.add(["cd", "chd[ir]"],
|
||||||
"Change the current directory",
|
"Change the current directory",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
args = "~";
|
args = "~";
|
||||||
|
|
||||||
if (vimperator.io.setCurrentDirectory(args))
|
if (liberator.io.setCurrentDirectory(args))
|
||||||
vimperator.echo(vimperator.io.getCurrentDirectory());
|
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",
|
"Print the current directory name",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
vimperator.echoerr("E488: Trailing characters");
|
liberator.echoerr("E488: Trailing characters");
|
||||||
else
|
else
|
||||||
vimperator.echo(vimperator.io.getCurrentDirectory());
|
liberator.echo(liberator.io.getCurrentDirectory());
|
||||||
});
|
});
|
||||||
|
|
||||||
// mkv[imperatorrc] or mkm[uttatorrc]
|
// 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",
|
"Write current key mappings and changed options to the config file",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
@@ -84,27 +84,27 @@ vimperator.IO = function () //{{{
|
|||||||
filename += extname+ "rc";
|
filename += extname+ "rc";
|
||||||
}
|
}
|
||||||
|
|
||||||
var file = vimperator.io.getFile(filename);
|
var file = liberator.io.getFile(filename);
|
||||||
if (file.exists() && !special)
|
if (file.exists() && !special)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E189: \"" + filename + "\" exists (add ! to override)");
|
liberator.echoerr("E189: \"" + filename + "\" exists (add ! to override)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var line = "\" " + vimperator.version + "\n";
|
var line = "\" " + liberator.version + "\n";
|
||||||
line += "\" Mappings\n";
|
line += "\" Mappings\n";
|
||||||
|
|
||||||
var mode = [[[vimperator.modes.NORMAL], ""], [[vimperator.modes.COMMAND_LINE], "c"],
|
var mode = [[[liberator.modes.NORMAL], ""], [[liberator.modes.COMMAND_LINE], "c"],
|
||||||
[[vimperator.modes.INSERT, vimperator.modes.TEXTAREA], "i"]];
|
[[liberator.modes.INSERT, liberator.modes.TEXTAREA], "i"]];
|
||||||
for (var y = 0; y < mode.length; y++)
|
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
|
// 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 += mode[y][1] + (map.noremap ? "nore" : "") + "map " + map.names[0] + " " + map.rhs + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
line += "\n\" Options\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: options should be queried for this info
|
||||||
// TODO: string/list options might need escaping in future
|
// 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
|
// :mkvimrc doesn't save autocommands, so we don't either - remove this code at some point
|
||||||
// line += "\n\" Auto-Commands\n";
|
// line += "\n\" Auto-Commands\n";
|
||||||
// for (var item in vimperator.autocommands)
|
// for (var item in liberator.autocommands)
|
||||||
// line += "autocmd " + item + "\n";
|
// line += "autocmd " + item + "\n";
|
||||||
|
|
||||||
line += "\n\" Abbreviations\n";
|
line += "\n\" Abbreviations\n";
|
||||||
for (var abbrCmd in vimperator.editor.abbreviations)
|
for (var abbrCmd in liberator.editor.abbreviations)
|
||||||
line += abbrCmd;
|
line += abbrCmd;
|
||||||
|
|
||||||
// if (vimperator.events.getMapLeader() != "\\")
|
// if (liberator.events.getMapLeader() != "\\")
|
||||||
// line += "\nlet mapleader = \"" + vimperator.events.getMapLeader() + "\"\n";
|
// line += "\nlet mapleader = \"" + liberator.events.getMapLeader() + "\"\n";
|
||||||
|
|
||||||
// source a user .vimperatorrc file
|
// source a user .vimperatorrc file
|
||||||
line += "\nsource! " + filename + ".local\n";
|
line += "\nsource! " + filename + ".local\n";
|
||||||
line += "\n\" vim: set ft=vimperator:";
|
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",
|
"Read Ex commands from a file",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
// FIXME: implement proper filename quoting
|
// FIXME: implement proper filename quoting
|
||||||
//if (/[^\\]\s/.test(args))
|
//if (/[^\\]\s/.test(args))
|
||||||
//{
|
//{
|
||||||
// vimperator.echoerr("E172: Only one file name allowed");
|
// liberator.echoerr("E172: Only one file name allowed");
|
||||||
// return;
|
// 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",
|
"Run a command",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
@@ -166,9 +166,9 @@ vimperator.IO = function () //{{{
|
|||||||
args = args.replace(/(^|[^\\])!/g, "$1" + lastRunCommand);
|
args = args.replace(/(^|[^\\])!/g, "$1" + lastRunCommand);
|
||||||
lastRunCommand = args;
|
lastRunCommand = args;
|
||||||
|
|
||||||
var output = vimperator.io.system(args);
|
var output = liberator.io.system(args);
|
||||||
if (output)
|
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);
|
var file = ioManager.getFile(newdir);
|
||||||
if (!file.exists() || !file.isDirectory())
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
[cwd, oldcwd] = [newdir, cwd];
|
[cwd, oldcwd] = [newdir, cwd];
|
||||||
@@ -287,9 +287,9 @@ vimperator.IO = function () //{{{
|
|||||||
var pluginDir;
|
var pluginDir;
|
||||||
|
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
pluginDir = "~/" + vimperator.config.name.toLowerCase() + "/" + directory;
|
pluginDir = "~/" + liberator.config.name.toLowerCase() + "/" + directory;
|
||||||
else
|
else
|
||||||
pluginDir = "~/." + vimperator.config.name.toLowerCase() + "/" + directory;
|
pluginDir = "~/." + liberator.config.name.toLowerCase() + "/" + directory;
|
||||||
|
|
||||||
pluginDir = ioManager.getFile(ioManager.expandPath(pluginDir));
|
pluginDir = ioManager.getFile(ioManager.expandPath(pluginDir));
|
||||||
|
|
||||||
@@ -298,8 +298,8 @@ vimperator.IO = function () //{{{
|
|||||||
|
|
||||||
getRCFile: function ()
|
getRCFile: function ()
|
||||||
{
|
{
|
||||||
var rcFile1 = ioManager.getFile("~/." + vimperator.config.name.toLowerCase() + "rc");
|
var rcFile1 = ioManager.getFile("~/." + liberator.config.name.toLowerCase() + "rc");
|
||||||
var rcFile2 = ioManager.getFile("~/_" + vimperator.config.name.toLowerCase() + "rc");
|
var rcFile2 = ioManager.getFile("~/_" + liberator.config.name.toLowerCase() + "rc");
|
||||||
|
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
[rcFile1, rcFile2] = [rcFile2, rcFile1]
|
[rcFile1, rcFile2] = [rcFile2, rcFile1]
|
||||||
@@ -475,7 +475,7 @@ vimperator.IO = function () //{{{
|
|||||||
|
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
vimperator.echoerr("command not found: " + program);
|
liberator.echoerr("command not found: " + program);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +537,7 @@ vimperator.IO = function () //{{{
|
|||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
vimperator.echoerr("E484: Can't open file " + filename);
|
liberator.echoerr("E484: Can't open file " + filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var str = ioManager.readFile(filename);
|
var str = ioManager.readFile(filename);
|
||||||
@@ -545,7 +545,7 @@ vimperator.IO = function () //{{{
|
|||||||
// handle pure javascript files specially
|
// handle pure javascript files specially
|
||||||
if (/\.js$/.test(filename))
|
if (/\.js$/.test(filename))
|
||||||
{
|
{
|
||||||
eval("with(vimperator){" + str + "}");
|
eval("with(liberator){" + str + "}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -557,7 +557,7 @@ vimperator.IO = function () //{{{
|
|||||||
{
|
{
|
||||||
if (heredocEnd.test(line))
|
if (heredocEnd.test(line))
|
||||||
{
|
{
|
||||||
eval("with(vimperator){" + heredoc + "}");
|
eval("with(liberator){" + heredoc + "}");
|
||||||
heredoc = "";
|
heredoc = "";
|
||||||
heredocEnd = null;
|
heredocEnd = null;
|
||||||
}
|
}
|
||||||
@@ -569,8 +569,8 @@ vimperator.IO = function () //{{{
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check for a heredoc
|
// check for a heredoc
|
||||||
var [count, cmd, special, args] = vimperator.commands.parseCommand(line);
|
var [count, cmd, special, args] = liberator.commands.parseCommand(line);
|
||||||
var command = vimperator.commands.get(cmd);
|
var command = liberator.commands.get(cmd);
|
||||||
if (command && command.name == "javascript")
|
if (command && command.name == "javascript")
|
||||||
{
|
{
|
||||||
var matches = args.match(/(.*)<<\s*([^\s]+)$/);
|
var matches = args.match(/(.*)<<\s*([^\s]+)$/);
|
||||||
@@ -587,19 +587,19 @@ vimperator.IO = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// execute a normal vimperator command
|
// execute a normal liberator command
|
||||||
vimperator.execute(line);
|
liberator.execute(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.log("Sourced: " + filename, 3);
|
liberator.log("Sourced: " + filename, 3);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
if (!silent)
|
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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.Mail = function ()
|
liberator.Mail = function ()
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -94,11 +94,11 @@ vimperator.Mail = function ()
|
|||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
// vimperator.options.add(["editor"],
|
// liberator.options.add(["editor"],
|
||||||
// "Set the external text editor",
|
// "Set the external text editor",
|
||||||
// "string", "gvim -f");
|
// "string", "gvim -f");
|
||||||
|
|
||||||
vimperator.options.add(["layout"],
|
liberator.options.add(["layout"],
|
||||||
"Set the layout of the mail window",
|
"Set the layout of the mail window",
|
||||||
"string", "inherit",
|
"string", "inherit",
|
||||||
{
|
{
|
||||||
@@ -119,108 +119,108 @@ vimperator.Mail = function ()
|
|||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// 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",
|
"Inspect (focus) message",
|
||||||
function () { content.focus(); });
|
function () { content.focus(); });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["d", "<Del>"],
|
liberator.mappings.add(modes, ["d", "<Del>"],
|
||||||
"Move mail to Trash folder",
|
"Move mail to Trash folder",
|
||||||
function () { goDoCommand("cmd_delete"); });
|
function () { goDoCommand("cmd_delete"); });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["j", "<Right>"],
|
liberator.mappings.add(modes, ["j", "<Right>"],
|
||||||
"Select next message",
|
"Select next message",
|
||||||
function (count) { vimperator.mail.selectMessage(function (msg) { return true; }, false, false, count); },
|
function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, false, count); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["J", "<Tab>"],
|
liberator.mappings.add(modes, ["J", "<Tab>"],
|
||||||
"Select next unread message",
|
"Select next unread message",
|
||||||
function (count) { vimperator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, false, count); },
|
function (count) { liberator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, false, count); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["k", "<Left>"],
|
liberator.mappings.add(modes, ["k", "<Left>"],
|
||||||
"Select previous message",
|
"Select previous message",
|
||||||
function (count) { vimperator.mail.selectMessage(function (msg) { return true; }, false, true, count); },
|
function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, true, count); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["K"],
|
liberator.mappings.add(modes, ["K"],
|
||||||
"Select previous unread message",
|
"Select previous unread message",
|
||||||
function (count) { vimperator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, true, count); },
|
function (count) { liberator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, true, count); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["r"],
|
liberator.mappings.add(modes, ["r"],
|
||||||
"Reply to sender",
|
"Reply to sender",
|
||||||
function () { goDoCommand("cmd_reply"); });
|
function () { goDoCommand("cmd_reply"); });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["gm"],
|
liberator.mappings.add(modes, ["gm"],
|
||||||
"Get new messages",
|
"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",
|
"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",
|
["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",
|
"Select next starred message",
|
||||||
function (count) { vimperator.mail.selectMessage(function(msg) { return msg.isFlagged; }, true, false, count); },
|
function (count) { liberator.mail.selectMessage(function(msg) { return msg.isFlagged; }, true, false, count); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["[s"],
|
liberator.mappings.add(modes, ["[s"],
|
||||||
"Select previous starred message",
|
"Select previous starred message",
|
||||||
function (count) { vimperator.mail.selectMessage(function(msg) { return msg.isFlagged; }, true, true, count); },
|
function (count) { liberator.mail.selectMessage(function(msg) { return msg.isFlagged; }, true, true, count); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["]a"],
|
liberator.mappings.add(modes, ["]a"],
|
||||||
"Select next message with an attachment",
|
"Select next message with an attachment",
|
||||||
function (count) { vimperator.mail.selectMessage(function(msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, false, count); },
|
function (count) { liberator.mail.selectMessage(function(msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, false, count); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["[a"],
|
liberator.mappings.add(modes, ["[a"],
|
||||||
"Select previous message with an attachment",
|
"Select previous message with an attachment",
|
||||||
function (count) { vimperator.mail.selectMessage(function(msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, true, count); },
|
function (count) { liberator.mail.selectMessage(function(msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, true, count); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["<C-i>"],
|
liberator.mappings.add(modes, ["<C-i>"],
|
||||||
"Get new messages",
|
"Get new messages",
|
||||||
function (count) { if (count < 1) count = 1; while (count--) GoNextMessage(nsMsgNavigationType.forward, true); },
|
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",
|
"Get new messages",
|
||||||
function (count) { if (count < 1) count = 1; while (count--) GoNextMessage(nsMsgNavigationType.back, true); },
|
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",
|
"Get new messages",
|
||||||
function (count) { if (count < 1) count = 1; while (count--) GoNextMessage(nsMsgNavigationType.firstMessage, true); },
|
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",
|
"Get new messages",
|
||||||
function (count) { if (count < 1) count = 1; while (count--) GoNextMessage(nsMsgNavigationType.lastMessage, false); },
|
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
|
// tagging messages
|
||||||
vimperator.mappings.add(modes, ["tr"],
|
liberator.mappings.add(modes, ["tr"],
|
||||||
"Toggle selected messages read",
|
"Toggle selected messages read",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
if (!GetSelectedMessages())
|
if (!GetSelectedMessages())
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgMarkMsgAsRead();
|
MsgMarkMsgAsRead();
|
||||||
});
|
});
|
||||||
vimperator.mappings.add(modes, ["tR"],
|
liberator.mappings.add(modes, ["tR"],
|
||||||
"Tag thread as read",
|
"Tag thread as read",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
@@ -230,37 +230,37 @@ vimperator.Mail = function ()
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["ts"],
|
liberator.mappings.add(modes, ["ts"],
|
||||||
"Toggle selected messages starred",
|
"Toggle selected messages starred",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
if (!GetSelectedMessages())
|
if (!GetSelectedMessages())
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgMarkMsgAsFlagged();
|
MsgMarkMsgAsFlagged();
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.mappings.add(modes, ["T"],
|
liberator.mappings.add(modes, ["T"],
|
||||||
"Mark current folder as read",
|
"Mark current folder as read",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
if (vimperator.mail.currentFolder.isServer)
|
if (liberator.mail.currentFolder.isServer)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
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",
|
"Mark all messages as read",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
vimperator.mail.getFolders("", false).forEach(function(folder) {
|
liberator.mail.getFolders("", false).forEach(function(folder) {
|
||||||
folder.markAllMessagesRead();
|
folder.markAllMessagesRead();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -269,31 +269,31 @@ vimperator.Mail = function ()
|
|||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["go[to]"],
|
liberator.commands.add(["go[to]"],
|
||||||
"Select a folder",
|
"Select a folder",
|
||||||
function (args, special, count)
|
function (args, special, count)
|
||||||
{
|
{
|
||||||
args = args || "Inbox";
|
args = args || "Inbox";
|
||||||
count = count > 0 ? (count - 1) : 0;
|
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)
|
if (!folder)
|
||||||
vimperator.echoerr("Folder \"" + args + "\" does not exist");
|
liberator.echoerr("Folder \"" + args + "\" does not exist");
|
||||||
else
|
else
|
||||||
SelectFolder(folder.URI);
|
SelectFolder(folder.URI);
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["get[messages]"],
|
liberator.commands.add(["get[messages]"],
|
||||||
"Check for new messages",
|
"Check for new messages",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E488: Trailing characters");
|
liberator.echoerr("E488: Trailing characters");
|
||||||
return;
|
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
|
// 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 *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
// Do NOT create instances of this class yourself, use the helper method
|
// Do NOT create instances of this class yourself, use the helper method
|
||||||
// vimperator.mappings.add() instead
|
// liberator.mappings.add() instead
|
||||||
vimperator.Map = function (modes, cmds, description, action, extraInfo) //{{{
|
liberator.Map = function (modes, cmds, description, action, extraInfo) //{{{
|
||||||
{
|
{
|
||||||
if (!modes || (!cmds || !cmds.length) || !action)
|
if (!modes || (!cmds || !cmds.length) || !action)
|
||||||
return null;
|
return null;
|
||||||
@@ -47,7 +47,7 @@ vimperator.Map = function (modes, cmds, description, action, extraInfo) //{{{
|
|||||||
this.noremap = extraInfo.noremap || false;
|
this.noremap = extraInfo.noremap || false;
|
||||||
};
|
};
|
||||||
|
|
||||||
vimperator.Map.prototype = {
|
liberator.Map.prototype = {
|
||||||
|
|
||||||
hasName: function (name)
|
hasName: function (name)
|
||||||
{
|
{
|
||||||
@@ -58,11 +58,11 @@ vimperator.Map.prototype = {
|
|||||||
{
|
{
|
||||||
var args = [];
|
var args = [];
|
||||||
|
|
||||||
if (this.flags & vimperator.Mappings.flags.MOTION)
|
if (this.flags & liberator.Mappings.flags.MOTION)
|
||||||
args.push(motion);
|
args.push(motion);
|
||||||
if (this.flags & vimperator.Mappings.flags.COUNT)
|
if (this.flags & liberator.Mappings.flags.COUNT)
|
||||||
args.push(count);
|
args.push(count);
|
||||||
if (this.flags & vimperator.Mappings.flags.ARGUMENT)
|
if (this.flags & liberator.Mappings.flags.ARGUMENT)
|
||||||
args.push(argument);
|
args.push(argument);
|
||||||
|
|
||||||
return this.action.apply(this, args);
|
return this.action.apply(this, args);
|
||||||
@@ -71,7 +71,7 @@ vimperator.Map.prototype = {
|
|||||||
};
|
};
|
||||||
//}}}
|
//}}}
|
||||||
|
|
||||||
vimperator.Mappings = function () //{{{
|
liberator.Mappings = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -80,7 +80,7 @@ vimperator.Mappings = function () //{{{
|
|||||||
var main = []; // default mappings
|
var main = []; // default mappings
|
||||||
var user = []; // user created mappings
|
var user = []; // user created mappings
|
||||||
|
|
||||||
for (var mode in vimperator.modes)
|
for (var mode in liberator.modes)
|
||||||
{
|
{
|
||||||
main[mode] = [];
|
main[mode] = [];
|
||||||
user[mode] = [];
|
user[mode] = [];
|
||||||
@@ -166,7 +166,7 @@ vimperator.Mappings = function () //{{{
|
|||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
vimperator.mappings.list(mode);
|
liberator.mappings.list(mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,21 +175,21 @@ vimperator.Mappings = function () //{{{
|
|||||||
var leaderRegexp = /<Leader>/i;
|
var leaderRegexp = /<Leader>/i;
|
||||||
|
|
||||||
if (leaderRegexp.test(lhs))
|
if (leaderRegexp.test(lhs))
|
||||||
lhs = lhs.replace(leaderRegexp, vimperator.events.getMapLeader());
|
lhs = lhs.replace(leaderRegexp, liberator.events.getMapLeader());
|
||||||
|
|
||||||
if (!rhs) // list the mapping
|
if (!rhs) // list the mapping
|
||||||
{
|
{
|
||||||
vimperator.mappings.list(mode, lhs);
|
liberator.mappings.list(mode, lhs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (var index = 0; index < mode.length; index++)
|
for (var index = 0; index < mode.length; index++)
|
||||||
{
|
{
|
||||||
vimperator.mappings.addUserMap([mode[index]], [lhs],
|
liberator.mappings.addUserMap([mode[index]], [lhs],
|
||||||
"User defined mapping",
|
"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,
|
rhs: rhs,
|
||||||
noremap: noremap
|
noremap: noremap
|
||||||
});
|
});
|
||||||
@@ -199,49 +199,49 @@ vimperator.Mappings = function () //{{{
|
|||||||
|
|
||||||
var modeDescription = modeDescription ? " in " + modeDescription + " mode" : "";
|
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,
|
"Map a key sequence" + modeDescription,
|
||||||
function (args) { map(args, modes, false); });
|
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,
|
"Map a key sequence without remapping keys" + modeDescription,
|
||||||
function (args) { map(args, modes, true); });
|
function (args) { map(args, modes, true); });
|
||||||
|
|
||||||
vimperator.commands.add([char + "mapc[lear]"],
|
liberator.commands.add([char + "mapc[lear]"],
|
||||||
"Remove all mappings" + modeDescription,
|
"Remove all mappings" + modeDescription,
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E474: Invalid argument");
|
liberator.echoerr("E474: Invalid argument");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < modes.length; i++)
|
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,
|
"Remove a mapping" + modeDescription,
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E474: Invalid argument");
|
liberator.echoerr("E474: Invalid argument");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var flag = false;
|
var flag = false;
|
||||||
for (let i = 0; i < modes.length; i++)
|
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;
|
flag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!flag)
|
if (!flag)
|
||||||
vimperator.echoerr("E31: No such mapping");
|
liberator.echoerr("E31: No such mapping");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,18 +249,18 @@ vimperator.Mappings = function () //{{{
|
|||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
addMapCommands("", [vimperator.modes.NORMAL], "");
|
addMapCommands("", [liberator.modes.NORMAL], "");
|
||||||
addMapCommands("c", [vimperator.modes.COMMAND_LINE], "command line");
|
addMapCommands("c", [liberator.modes.COMMAND_LINE], "command line");
|
||||||
addMapCommands("i", [vimperator.modes.INSERT, vimperator.modes.TEXTAREA], "insert");
|
addMapCommands("i", [liberator.modes.INSERT, liberator.modes.TEXTAREA], "insert");
|
||||||
if (vimperator.has("mail"))
|
if (liberator.has("mail"))
|
||||||
addMapCommands("m", [vimperator.modes.MESSAGE], "message");
|
addMapCommands("m", [liberator.modes.MESSAGE], "message");
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
// FIXME:
|
// 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
|
ALLOW_EVENT_ROUTING: 1 << 0, // if set, return true inside the map command to pass the event further to firefox
|
||||||
MOTION: 1 << 1,
|
MOTION: 1 << 1,
|
||||||
COUNT: 1 << 2,
|
COUNT: 1 << 2,
|
||||||
@@ -272,7 +272,7 @@ vimperator.Mappings = function () //{{{
|
|||||||
// NOTE: just normal mode for now
|
// NOTE: just normal mode for now
|
||||||
__iterator__: function ()
|
__iterator__: function ()
|
||||||
{
|
{
|
||||||
return mappingsIterator([vimperator.modes.NORMAL], main);
|
return mappingsIterator([liberator.modes.NORMAL], main);
|
||||||
},
|
},
|
||||||
|
|
||||||
// used by :mkvimperatorrc to save mappings
|
// used by :mkvimperatorrc to save mappings
|
||||||
@@ -283,12 +283,12 @@ vimperator.Mappings = function () //{{{
|
|||||||
|
|
||||||
add: function (modes, keys, description, action, extra)
|
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)
|
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
|
// remove all old mappings to this key sequence
|
||||||
for (var i = 0; i < map.names.length; i++)
|
for (var i = 0; i < map.names.length; i++)
|
||||||
@@ -302,13 +302,13 @@ vimperator.Mappings = function () //{{{
|
|||||||
|
|
||||||
get: function (mode, cmd)
|
get: function (mode, cmd)
|
||||||
{
|
{
|
||||||
mode = mode || vimperator.modes.NORMAL;
|
mode = mode || liberator.modes.NORMAL;
|
||||||
return getMap(mode, cmd, user) || getMap(mode, cmd, main);
|
return getMap(mode, cmd, user) || getMap(mode, cmd, main);
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefault: function (mode, cmd)
|
getDefault: function (mode, cmd)
|
||||||
{
|
{
|
||||||
mode = mode || vimperator.modes.NORMAL;
|
mode = mode || liberator.modes.NORMAL;
|
||||||
return getMap(mode, cmd, main);
|
return getMap(mode, cmd, main);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ vimperator.Mappings = function () //{{{
|
|||||||
|
|
||||||
if (!maps || maps.length == 0)
|
if (!maps || maps.length == 0)
|
||||||
{
|
{
|
||||||
vimperator.echo("No mappings found");
|
liberator.echo("No mappings found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,20 +396,20 @@ vimperator.Mappings = function () //{{{
|
|||||||
|
|
||||||
if (!flag)
|
if (!flag)
|
||||||
{
|
{
|
||||||
vimperator.echo("No mappings found");
|
liberator.echo("No mappings found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var modeSign = "";
|
var modeSign = "";
|
||||||
for (var i = 0; i < modes.length; i++)
|
for (var i = 0; i < modes.length; i++)
|
||||||
{
|
{
|
||||||
if (modes[i] == vimperator.modes.NORMAL)
|
if (modes[i] == liberator.modes.NORMAL)
|
||||||
modeSign += "n";
|
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";
|
modeSign += "i";
|
||||||
if (modes[i] == vimperator.modes.COMMAND_LINE)
|
if (modes[i] == liberator.modes.COMMAND_LINE)
|
||||||
modeSign += "c";
|
modeSign += "c";
|
||||||
if (modes[i] == vimperator.modes.MESSAGRE)
|
if (modes[i] == liberator.modes.MESSAGRE)
|
||||||
modeSign += "m";
|
modeSign += "m";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,16 +421,16 @@ vimperator.Mappings = function () //{{{
|
|||||||
for (var j = 0; j < maps[i].names.length; j++)
|
for (var j = 0; j < maps[i].names.length; j++)
|
||||||
{
|
{
|
||||||
list += "<tr>";
|
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)
|
if (maps[i].rhs)
|
||||||
list += "<td> "+ (maps[i].noremap ? "*" : " ") + "</td>"
|
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 += "</tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list += "</table>";
|
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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.modes = (function () //{{{
|
liberator.modes = (function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -48,41 +48,41 @@ vimperator.modes = (function () //{{{
|
|||||||
return "-- PASS THROUGH --";
|
return "-- PASS THROUGH --";
|
||||||
|
|
||||||
var ext = "";
|
var ext = "";
|
||||||
if (extended & vimperator.modes.QUICK_HINT)
|
if (extended & liberator.modes.QUICK_HINT)
|
||||||
ext += " (quick)";
|
ext += " (quick)";
|
||||||
if (extended & vimperator.modes.EXTENDED_HINT)
|
if (extended & liberator.modes.EXTENDED_HINT)
|
||||||
ext += " (extended)";
|
ext += " (extended)";
|
||||||
if (extended & vimperator.modes.ALWAYS_HINT)
|
if (extended & liberator.modes.ALWAYS_HINT)
|
||||||
ext += " (always)";
|
ext += " (always)";
|
||||||
if (extended & vimperator.modes.INACTIVE_HINT)
|
if (extended & liberator.modes.INACTIVE_HINT)
|
||||||
ext += " (inactive)";
|
ext += " (inactive)";
|
||||||
if (extended & vimperator.modes.MENU) // TODO: desirable?
|
if (extended & liberator.modes.MENU) // TODO: desirable?
|
||||||
ext += " (menu)";
|
ext += " (menu)";
|
||||||
|
|
||||||
ext += " --";
|
ext += " --";
|
||||||
|
|
||||||
// when recording a macro
|
// when recording a macro
|
||||||
if (vimperator.modes.isRecording)
|
if (liberator.modes.isRecording)
|
||||||
ext += "recording";
|
ext += "recording";
|
||||||
|
|
||||||
switch (main)
|
switch (main)
|
||||||
{
|
{
|
||||||
case vimperator.modes.INSERT:
|
case liberator.modes.INSERT:
|
||||||
return "-- INSERT" + ext;
|
return "-- INSERT" + ext;
|
||||||
case vimperator.modes.VISUAL:
|
case liberator.modes.VISUAL:
|
||||||
return (extended & vimperator.modes.LINE) ? "-- VISUAL LINE" + ext : "-- VISUAL" + ext;
|
return (extended & liberator.modes.LINE) ? "-- VISUAL LINE" + ext : "-- VISUAL" + ext;
|
||||||
case vimperator.modes.HINTS:
|
case liberator.modes.HINTS:
|
||||||
return "-- HINTS" + ext;
|
return "-- HINTS" + ext;
|
||||||
case vimperator.modes.CARET:
|
case liberator.modes.CARET:
|
||||||
return "-- CARET" + ext;
|
return "-- CARET" + ext;
|
||||||
case vimperator.modes.TEXTAREA:
|
case liberator.modes.TEXTAREA:
|
||||||
return "-- TEXTAREA" + ext;
|
return "-- TEXTAREA" + ext;
|
||||||
case vimperator.modes.MESSAGE:
|
case liberator.modes.MESSAGE:
|
||||||
return "-- MESSAGE" + ext;
|
return "-- MESSAGE" + ext;
|
||||||
case vimperator.modes.CUSTOM:
|
case liberator.modes.CUSTOM:
|
||||||
return "-- " + vimperator.plugins.mode + ext;
|
return "-- " + liberator.plugins.mode + ext;
|
||||||
default: // NORMAL mode
|
default: // NORMAL mode
|
||||||
if (vimperator.modes.isRecording)
|
if (liberator.modes.isRecording)
|
||||||
return "recording";
|
return "recording";
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
@@ -91,23 +91,23 @@ vimperator.modes = (function () //{{{
|
|||||||
|
|
||||||
// NOTE: Pay attention that you don't run into endless loops
|
// NOTE: Pay attention that you don't run into endless loops
|
||||||
// Usually you should only indicate to leave a special mode linke HINTS
|
// 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
|
// for its cleanup here
|
||||||
function handleModeChange(oldMode, newMode)
|
function handleModeChange(oldMode, newMode)
|
||||||
{
|
{
|
||||||
// TODO: fix v.log() to work with verbosity level
|
// 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");
|
// dump("switching from mode " + oldMode + " to mode " + newMode + "\n");
|
||||||
|
|
||||||
switch (oldMode)
|
switch (oldMode)
|
||||||
{
|
{
|
||||||
case vimperator.modes.TEXTAREA:
|
case liberator.modes.TEXTAREA:
|
||||||
case vimperator.modes.INSERT:
|
case liberator.modes.INSERT:
|
||||||
vimperator.editor.unselectText();
|
liberator.editor.unselectText();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vimperator.modes.VISUAL:
|
case liberator.modes.VISUAL:
|
||||||
if (newMode == vimperator.modes.CARET)
|
if (newMode == liberator.modes.CARET)
|
||||||
{
|
{
|
||||||
// clear any selection made
|
// clear any selection made
|
||||||
var selection = window.content.getSelection();
|
var selection = window.content.getSelection();
|
||||||
@@ -118,31 +118,31 @@ vimperator.modes = (function () //{{{
|
|||||||
catch (e) { }
|
catch (e) { }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vimperator.editor.unselectText();
|
liberator.editor.unselectText();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vimperator.modes.CUSTOM:
|
case liberator.modes.CUSTOM:
|
||||||
vimperator.plugins.stop();
|
liberator.plugins.stop();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vimperator.modes.HINTS:
|
case liberator.modes.HINTS:
|
||||||
vimperator.hints.hide();
|
liberator.hints.hide();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vimperator.modes.COMMAND_LINE:
|
case liberator.modes.COMMAND_LINE:
|
||||||
vimperator.commandline.close();
|
liberator.commandline.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newMode == vimperator.modes.NORMAL)
|
if (newMode == liberator.modes.NORMAL)
|
||||||
{
|
{
|
||||||
// disable caret mode when we want to switch to normal mode
|
// 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)
|
if (value)
|
||||||
vimperator.options.setPref("accessibility.browsewithcaret", false);
|
liberator.options.setPref("accessibility.browsewithcaret", false);
|
||||||
|
|
||||||
vimperator.statusline.updateUrl();
|
liberator.statusline.updateUrl();
|
||||||
vimperator.focusContent(false);
|
liberator.focusContent(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,15 +194,15 @@ vimperator.modes = (function () //{{{
|
|||||||
// show the current mode string in the command line
|
// show the current mode string in the command line
|
||||||
show: function ()
|
show: function ()
|
||||||
{
|
{
|
||||||
if (!vimperator.options["showmode"])
|
if (!liberator.options["showmode"])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// never show mode messages if we are in command line mode
|
// never show mode messages if we are in command line mode
|
||||||
if (main == vimperator.modes.COMMAND_LINE)
|
if (main == liberator.modes.COMMAND_LINE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vimperator.commandline.echo(getModeMessage(), vimperator.commandline.HL_MODEMSG,
|
liberator.commandline.echo(getModeMessage(), liberator.commandline.HL_MODEMSG,
|
||||||
vimperator.commandline.DISALLOW_MULTILINE);
|
liberator.commandline.DISALLOW_MULTILINE);
|
||||||
},
|
},
|
||||||
|
|
||||||
// add/remove always work on the extended mode only
|
// add/remove always work on the extended mode only
|
||||||
@@ -224,7 +224,7 @@ vimperator.modes = (function () //{{{
|
|||||||
|
|
||||||
main = mainMode;
|
main = mainMode;
|
||||||
if (!extendedMode)
|
if (!extendedMode)
|
||||||
extended = vimperator.modes.NONE;
|
extended = liberator.modes.NONE;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (typeof extendedMode === "number")
|
if (typeof extendedMode === "number")
|
||||||
@@ -237,15 +237,15 @@ vimperator.modes = (function () //{{{
|
|||||||
setCustomMode: function (modestr, oneventfunc, stopfunc)
|
setCustomMode: function (modestr, oneventfunc, stopfunc)
|
||||||
{
|
{
|
||||||
// TODO this.plugin[id]... ('id' maybe submode or what..)
|
// TODO this.plugin[id]... ('id' maybe submode or what..)
|
||||||
vimperator.plugins.mode = modestr;
|
liberator.plugins.mode = modestr;
|
||||||
vimperator.plugins.onEvent = oneventfunc;
|
liberator.plugins.onEvent = oneventfunc;
|
||||||
vimperator.plugins.stop = stopfunc;
|
liberator.plugins.stop = stopfunc;
|
||||||
},
|
},
|
||||||
|
|
||||||
// keeps recording state
|
// keeps recording state
|
||||||
reset: function (silent)
|
reset: function (silent)
|
||||||
{
|
{
|
||||||
this.set(vimperator.modes.NORMAL, vimperator.modes.NONE, silent);
|
this.set(liberator.modes.NORMAL, liberator.modes.NONE, silent);
|
||||||
},
|
},
|
||||||
|
|
||||||
remove: function (mode)
|
remove: function (mode)
|
||||||
@@ -273,7 +273,7 @@ vimperator.modes = (function () //{{{
|
|||||||
|
|
||||||
main = value;
|
main = value;
|
||||||
// setting the main mode always resets any extended mode
|
// setting the main mode always resets any extended mode
|
||||||
extended = vimperator.modes.NONE;
|
extended = liberator.modes.NONE;
|
||||||
this.show();
|
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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.config = {
|
liberator.config = {
|
||||||
/*** required options, no checks done if they really exist, so be careful ***/
|
/*** required options, no checks done if they really exist, so be careful ***/
|
||||||
name: "Muttator",
|
name: "Muttator",
|
||||||
hostApplication: "Thunderbird", // TODO: can this be found out otherwise? gBrandBundle.getString("brandShortName");
|
hostApplication: "Thunderbird", // TODO: can this be found out otherwise? gBrandBundle.getString("brandShortName");
|
||||||
@@ -35,7 +35,7 @@ vimperator.config = {
|
|||||||
features: ["hints", "mail", "marks"],
|
features: ["hints", "mail", "marks"],
|
||||||
guioptions: { m: ["mail-toolbar-menubar2"], T: ["mail-bar2"], f: ["folderPaneBox", "folderpane_splitter"], F: ["folderPaneHeader"] },
|
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
|
get mainWidget() { return GetThreadTree(); }, // focusContent() focuses this widget
|
||||||
mainWindowID: "messengerWindow", // used for :set titlestring
|
mainWindowID: "messengerWindow", // used for :set titlestring
|
||||||
|
|
||||||
@@ -79,14 +79,14 @@ vimperator.config = {
|
|||||||
/*["searchengines", "Manage installed search engines",
|
/*["searchengines", "Manage installed search engines",
|
||||||
function() { openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
function() { openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
||||||
["selectionsource", "View selection source",
|
["selectionsource", "View selection source",
|
||||||
function() { vimperator.buffer.viewSelectionSource(); }]*/
|
function() { liberator.buffer.viewSelectionSource(); }]*/
|
||||||
],
|
],
|
||||||
|
|
||||||
init: function()
|
init: function()
|
||||||
{
|
{
|
||||||
vimperator.mappings.add([vimperator.modes.NORMAL],
|
liberator.mappings.add([liberator.modes.NORMAL],
|
||||||
["o"], "Open a message",
|
["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"
|
<commandset id="onVimperatorFocus"
|
||||||
commandupdater="true"
|
commandupdater="true"
|
||||||
events="focus"
|
events="focus"
|
||||||
oncommandupdate="vimperator.events.onFocusChange(event);"/>
|
oncommandupdate="liberator.events.onFocusChange(event);"/>
|
||||||
<commandset id="onVimperatorSelect"
|
<commandset id="onVimperatorSelect"
|
||||||
commandupdater="true"
|
commandupdater="true"
|
||||||
events="select"
|
events="select"
|
||||||
oncommandupdate="vimperator.events.onSelectionChange(event);"/>
|
oncommandupdate="liberator.events.onSelectionChange(event);"/>
|
||||||
|
|
||||||
<keyset id="mainKeyset">
|
<keyset id="mainKeyset">
|
||||||
<key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':', '', vimperator.modes.EX);" modifiers=""/>
|
<key id="key_open_vimbar" key=":" oncommand="liberator.commandline.open(':', '', liberator.modes.EX);" modifiers=""/>
|
||||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="vimperator.events.onEscape();"/>
|
<key id="key_stop" keycode="VK_ESCAPE" oncommand="liberator.events.onEscape();"/>
|
||||||
<!-- other keys are handled inside vimperator.js event loop -->
|
<!-- other keys are handled inside the event loop in events.js -->
|
||||||
</keyset>
|
</keyset>
|
||||||
|
|
||||||
<statusbar id="status-bar" class="hl-StatusLine">
|
<statusbar id="status-bar" class="hl-StatusLine">
|
||||||
<hbox insertafter="statusTextBox" id="vimperator-statusline" flex="1" height="10" hidden="false" align="center">
|
<hbox insertafter="statusTextBox" id="liberator-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="liberator-statusline-field-url" readonly="false" flex="1" crop="end"/>
|
||||||
<statusbarpanel class="plain" id="vimperator-statusline-field-inputbuffer" flex="0"/>
|
<statusbarpanel class="plain" id="liberator-statusline-field-inputbuffer" flex="0"/>
|
||||||
<statusbarpanel class="plain" id="vimperator-statusline-field-progress" flex="0"/>
|
<statusbarpanel class="plain" id="liberator-statusline-field-progress" flex="0"/>
|
||||||
<statusbarpanel class="plain" id="vimperator-statusline-field-tabcount" flex="0"/>
|
<statusbarpanel class="plain" id="liberator-statusline-field-tabcount" flex="0"/>
|
||||||
<statusbarpanel class="plain" id="vimperator-statusline-field-bufferposition" flex="0"/>
|
<statusbarpanel class="plain" id="liberator-statusline-field-bufferposition" flex="0"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
<!-- just hide them since other elements expect them -->
|
<!-- just hide them since other elements expect them -->
|
||||||
<statusbarpanel id="statusText" hidden="true"/>
|
<statusbarpanel id="statusText" hidden="true"/>
|
||||||
<statusbarpanel id="statusbarpanel-progress" hidden="true"/>
|
<statusbarpanel id="statusbarpanel-progress" hidden="true"/>
|
||||||
</statusbar>
|
</statusbar>
|
||||||
|
|
||||||
<vbox id="vimperator-container" hidden="false">
|
<vbox id="liberator-container" hidden="false">
|
||||||
<listbox id="vimperator-bufferwindow" class="plain" rows="10" flex="1" hidden="true"
|
<listbox id="liberator-bufferwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||||
onclick= "vimperator.bufferwindow.onEvent(event);"
|
onclick= "liberator.bufferwindow.onEvent(event);"
|
||||||
ondblclick="vimperator.bufferwindow.onEvent(event);"
|
ondblclick="liberator.bufferwindow.onEvent(event);"
|
||||||
onkeydown= "vimperator.bufferwindow.onEvent(event);">
|
onkeydown= "liberator.bufferwindow.onEvent(event);">
|
||||||
<listcols>
|
<listcols>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
</listcols>
|
</listcols>
|
||||||
</listbox>
|
</listbox>
|
||||||
|
|
||||||
<listbox id="vimperator-previewwindow" class="plain" rows="10" flex="1" hidden="true"
|
<listbox id="liberator-previewwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||||
onclick= "vimperator.previewwindow.onEvent(event);"
|
onclick= "liberator.previewwindow.onEvent(event);"
|
||||||
ondblclick="vimperator.previewwindow.onEvent(event);"
|
ondblclick="liberator.previewwindow.onEvent(event);"
|
||||||
onkeydown= "vimperator.previewwindow.onEvent(event);">
|
onkeydown= "liberator.previewwindow.onEvent(event);">
|
||||||
<listcols>
|
<listcols>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
</listcols>
|
</listcols>
|
||||||
</listbox>
|
</listbox>
|
||||||
|
|
||||||
<iframe id="vimperator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
<iframe id="liberator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
||||||
onclick="vimperator.commandline.onMultilineOutputEvent(event)"/>
|
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>
|
<listcols>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
</listcols>
|
</listcols>
|
||||||
</listbox>
|
</listbox>
|
||||||
|
|
||||||
<hbox insertafter="status-bar" id="vimperator-commandline" hidden="false" class="hl-Normal">
|
<hbox insertafter="status-bar" id="liberator-commandline" hidden="false" class="hl-Normal">
|
||||||
<label class="plain" id="vimperator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
<label class="plain" id="liberator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||||
<textbox class="plain" id="vimperator-commandline-command" flex="1" type="timed" timeout="100"
|
<textbox class="plain" id="liberator-commandline-command" flex="1" type="timed" timeout="100"
|
||||||
oninput="vimperator.commandline.onEvent(event);"
|
oninput="liberator.commandline.onEvent(event);"
|
||||||
onfocus="vimperator.commandline.onEvent(event);"
|
onfocus="liberator.commandline.onEvent(event);"
|
||||||
onblur="vimperator.commandline.onEvent(event);"/>
|
onblur="liberator.commandline.onEvent(event);"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<textbox id="vimperator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
<textbox id="liberator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
||||||
onkeypress="vimperator.commandline.onMultilineInputEvent(event);"
|
onkeypress="liberator.commandline.onMultilineInputEvent(event);"
|
||||||
oninput="vimperator.commandline.onMultilineInputEvent(event);"
|
oninput="liberator.commandline.onMultilineInputEvent(event);"
|
||||||
onblur="vimperator.commandline.onMultilineInputEvent(event);"/>
|
onblur="liberator.commandline.onMultilineInputEvent(event);"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
</window>
|
</window>
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
// Do NOT create instances of this class yourself, use the helper method
|
// Do NOT create instances of this class yourself, use the helper method
|
||||||
// vimperator.options.add() instead
|
// liberator.options.add() instead
|
||||||
vimperator.Option = function (names, description, type, defaultValue, getter, setter, validator, completer)
|
liberator.Option = function (names, description, type, defaultValue, getter, setter, validator, completer)
|
||||||
{
|
{
|
||||||
if (!names || !type)
|
if (!names || !type)
|
||||||
return null;
|
return null;
|
||||||
@@ -103,7 +103,7 @@ vimperator.Option = function (names, description, type, defaultValue, getter, se
|
|||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
|
|
||||||
vimperator.Options = function () //{{{
|
liberator.Options = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -122,26 +122,26 @@ vimperator.Options = function () //{{{
|
|||||||
if (type == prefService.PREF_INVALID || type == prefService.PREF_STRING)
|
if (type == prefService.PREF_INVALID || type == prefService.PREF_STRING)
|
||||||
prefService.setCharPref(name, value);
|
prefService.setCharPref(name, value);
|
||||||
else if (type == prefService.PREF_INT)
|
else if (type == prefService.PREF_INT)
|
||||||
vimperator.echoerr("E521: Number required after =: " + name + "=" + value);
|
liberator.echoerr("E521: Number required after =: " + name + "=" + value);
|
||||||
else
|
else
|
||||||
vimperator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
liberator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
||||||
break;
|
break;
|
||||||
case "number":
|
case "number":
|
||||||
if (type == prefService.PREF_INVALID || type == prefService.PREF_INT)
|
if (type == prefService.PREF_INVALID || type == prefService.PREF_INT)
|
||||||
prefService.setIntPref(name, value);
|
prefService.setIntPref(name, value);
|
||||||
else
|
else
|
||||||
vimperator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
liberator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
||||||
break;
|
break;
|
||||||
case "boolean":
|
case "boolean":
|
||||||
if (type == prefService.PREF_INVALID || type == prefService.PREF_BOOL)
|
if (type == prefService.PREF_INVALID || type == prefService.PREF_BOOL)
|
||||||
prefService.setBoolPref(name, value);
|
prefService.setBoolPref(name, value);
|
||||||
else if (type == prefService.PREF_INT)
|
else if (type == prefService.PREF_INT)
|
||||||
vimperator.echoerr("E521: Number required after =: " + name + "=" + value);
|
liberator.echoerr("E521: Number required after =: " + name + "=" + value);
|
||||||
else
|
else
|
||||||
vimperator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
liberator.echoerr("E474: Invalid argument: " + name + "=" + value);
|
||||||
break;
|
break;
|
||||||
default:
|
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 ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["let"],
|
liberator.commands.add(["let"],
|
||||||
"Set or list a variable",
|
"Set or list a variable",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
var str = "";
|
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")
|
if (typeof value == "number")
|
||||||
var prefix = "#";
|
var prefix = "#";
|
||||||
else if (typeof value == "function")
|
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";
|
str += "<tr><td style=\"width: 200px;\">" + i + "</td><td>" + prefix + value + "</td>\n";
|
||||||
}
|
}
|
||||||
if (str)
|
if (str)
|
||||||
vimperator.echo("<table>" + str + "</table>", vimperator.commandline.FORCE_MULTILINE);
|
liberator.echo("<table>" + str + "</table>", liberator.commandline.FORCE_MULTILINE);
|
||||||
else
|
else
|
||||||
vimperator.echo("No variables found");
|
liberator.echo("No variables found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,17 +232,17 @@ vimperator.Options = function () //{{{
|
|||||||
{
|
{
|
||||||
if (!matches[1])
|
if (!matches[1])
|
||||||
{
|
{
|
||||||
var reference = vimperator.variableReference(matches[2]);
|
var reference = liberator.variableReference(matches[2]);
|
||||||
if (!reference[0] && matches[3])
|
if (!reference[0] && matches[3])
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E121: Undefined variable: " + matches[2]);
|
liberator.echoerr("E121: Undefined variable: " + matches[2]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var expr = vimperator.eval(matches[4]);
|
var expr = liberator.eval(matches[4]);
|
||||||
if (typeof expr === undefined)
|
if (typeof expr === undefined)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E15: Invalid expression: " + matches[4]);
|
liberator.echoerr("E15: Invalid expression: " + matches[4]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -250,7 +250,7 @@ vimperator.Options = function () //{{{
|
|||||||
if (!reference[0])
|
if (!reference[0])
|
||||||
{
|
{
|
||||||
if (reference[2] == "g")
|
if (reference[2] == "g")
|
||||||
reference[0] = vimperator.globalVariables;
|
reference[0] = liberator.globalVariables;
|
||||||
else
|
else
|
||||||
return; // for now
|
return; // for now
|
||||||
}
|
}
|
||||||
@@ -272,10 +272,10 @@ vimperator.Options = function () //{{{
|
|||||||
// 1 - name
|
// 1 - name
|
||||||
else if (matches = args.match(/^\s*([\w:]+)\s*$/))
|
else if (matches = args.match(/^\s*([\w:]+)\s*$/))
|
||||||
{
|
{
|
||||||
var reference = vimperator.variableReference(matches[1]);
|
var reference = liberator.variableReference(matches[1]);
|
||||||
if (!reference[0])
|
if (!reference[0])
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E121: Undefined variable: " + matches[1]);
|
liberator.echoerr("E121: Undefined variable: " + matches[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,12 +286,12 @@ vimperator.Options = function () //{{{
|
|||||||
var prefix = "*";
|
var prefix = "*";
|
||||||
else
|
else
|
||||||
var prefix = "";
|
var prefix = "";
|
||||||
vimperator.echo(reference[1] + "\t\t" + prefix + value);
|
liberator.echo(reference[1] + "\t\t" + prefix + value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["pref[erences]", "prefs"],
|
liberator.commands.add(["pref[erences]", "prefs"],
|
||||||
"Show " + vimperator.config.hostApplication + " Preferences",
|
"Show " + liberator.config.hostApplication + " Preferences",
|
||||||
function (args, special, count, modifiers)
|
function (args, special, count, modifiers)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
@@ -299,25 +299,25 @@ vimperator.Options = function () //{{{
|
|||||||
// TODO: copy these snippets to more function which should work with :tab xxx
|
// TODO: copy these snippets to more function which should work with :tab xxx
|
||||||
if (modifiers && modifiers.inTab)
|
if (modifiers && modifiers.inTab)
|
||||||
{
|
{
|
||||||
vimperator.open(special ? "about:config" :
|
liberator.open(special ? "about:config" :
|
||||||
"chrome://browser/content/preferences/preferences.xul", vimperator.NEW_TAB);
|
"chrome://browser/content/preferences/preferences.xul", liberator.NEW_TAB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (special) // open firefox settings gui dialog
|
if (special) // open firefox settings gui dialog
|
||||||
vimperator.open("about:config", vimperator.CURRENT_TAB);
|
liberator.open("about:config", liberator.CURRENT_TAB);
|
||||||
else
|
else
|
||||||
openPreferences();
|
openPreferences();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E488: Trailing characters");
|
liberator.echoerr("E488: Trailing characters");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: support setting multiple options at once
|
// TODO: support setting multiple options at once
|
||||||
vimperator.commands.add(["se[t]"],
|
liberator.commands.add(["se[t]"],
|
||||||
"Set an option",
|
"Set an option",
|
||||||
function (args, special, count, modifiers)
|
function (args, special, count, modifiers)
|
||||||
{
|
{
|
||||||
@@ -341,13 +341,13 @@ vimperator.Options = function () //{{{
|
|||||||
invertBoolean = true;
|
invertBoolean = true;
|
||||||
|
|
||||||
if (name == "all" && reset)
|
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")
|
else if (name == "all")
|
||||||
vimperator.options.listPrefs(onlyNonDefault, "");
|
liberator.options.listPrefs(onlyNonDefault, "");
|
||||||
else if (reset)
|
else if (reset)
|
||||||
vimperator.options.resetPref(name);
|
liberator.options.resetPref(name);
|
||||||
else if (invertBoolean)
|
else if (invertBoolean)
|
||||||
vimperator.options.invertPref(name);
|
liberator.options.invertPref(name);
|
||||||
else if (matches[3])
|
else if (matches[3])
|
||||||
{
|
{
|
||||||
var value = matches[5];
|
var value = matches[5];
|
||||||
@@ -367,11 +367,11 @@ vimperator.Options = function () //{{{
|
|||||||
if (!isNaN(valueInt))
|
if (!isNaN(valueInt))
|
||||||
value = valueInt;
|
value = valueInt;
|
||||||
}
|
}
|
||||||
vimperator.options.setPref(name, value);
|
liberator.options.setPref(name, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vimperator.options.listPrefs(onlyNonDefault, name);
|
liberator.options.listPrefs(onlyNonDefault, name);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -387,7 +387,7 @@ vimperator.Options = function () //{{{
|
|||||||
var matches = args.match(/^\s*(no|inv)?([a-z]+)([?&!])?\s*(([+-^]?)=(.*))?\s*$/);
|
var matches = args.match(/^\s*(no|inv)?([a-z]+)([?&!])?\s*(([+-^]?)=(.*))?\s*$/);
|
||||||
if (!matches)
|
if (!matches)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E518: Unknown option: " + args);
|
liberator.echoerr("E518: Unknown option: " + args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,10 +400,10 @@ vimperator.Options = function () //{{{
|
|||||||
if (name == "all")
|
if (name == "all")
|
||||||
all = true;
|
all = true;
|
||||||
|
|
||||||
var option = vimperator.options.get(name);
|
var option = liberator.options.get(name);
|
||||||
if (!option && !all)
|
if (!option && !all)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E518: Unknown option: " + args);
|
liberator.echoerr("E518: Unknown option: " + args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +432,7 @@ vimperator.Options = function () //{{{
|
|||||||
{
|
{
|
||||||
if (all)
|
if (all)
|
||||||
{
|
{
|
||||||
for (let option in vimperator.options)
|
for (let option in liberator.options)
|
||||||
option.reset();
|
option.reset();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -445,14 +445,14 @@ vimperator.Options = function () //{{{
|
|||||||
{
|
{
|
||||||
if (all)
|
if (all)
|
||||||
{
|
{
|
||||||
vimperator.options.list(onlyNonDefault);
|
liberator.options.list(onlyNonDefault);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (option.type == "boolean")
|
if (option.type == "boolean")
|
||||||
vimperator.echo((option.value ? " " : "no") + option.name);
|
liberator.echo((option.value ? " " : "no") + option.name);
|
||||||
else
|
else
|
||||||
vimperator.echo(" " + option.name + "=" + option.value);
|
liberator.echo(" " + option.name + "=" + option.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// write access
|
// write access
|
||||||
@@ -469,7 +469,7 @@ vimperator.Options = function () //{{{
|
|||||||
case "boolean":
|
case "boolean":
|
||||||
if (valueGiven)
|
if (valueGiven)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E474: Invalid argument: " + args);
|
liberator.echoerr("E474: Invalid argument: " + args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ vimperator.Options = function () //{{{
|
|||||||
|
|
||||||
if (isNaN(value))
|
if (isNaN(value))
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E521: Number required after =: " + args);
|
liberator.echoerr("E521: Number required after =: " + args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,27 +552,27 @@ vimperator.Options = function () //{{{
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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))
|
if (option.isValidValue(newValue))
|
||||||
option.value = newValue;
|
option.value = newValue;
|
||||||
else
|
else
|
||||||
// FIXME: need to be able to specify more specific errors
|
// 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",
|
"Delete a variable",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E471: Argument required");
|
liberator.echoerr("E471: Argument required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,11 +581,11 @@ vimperator.Options = function () //{{{
|
|||||||
var length = names.length;
|
var length = names.length;
|
||||||
for (var i = 0, name = names[i]; i < length; name = names[++i])
|
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 (!reference[0])
|
||||||
{
|
{
|
||||||
if (!special)
|
if (!special)
|
||||||
vimperator.echoerr("E108: No such variable: " + name);
|
liberator.echoerr("E108: No such variable: " + name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,10 +612,10 @@ vimperator.Options = function () //{{{
|
|||||||
if (!extraInfo)
|
if (!extraInfo)
|
||||||
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);
|
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.__defineGetter__(option.name, function () { return option.value; });
|
||||||
this.__defineSetter__(option.name, function (value) { option.value = value; });
|
this.__defineSetter__(option.name, function (value) { option.value = value; });
|
||||||
|
|
||||||
@@ -643,7 +643,7 @@ vimperator.Options = function () //{{{
|
|||||||
|
|
||||||
list: function (onlyNonDefault)
|
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>";
|
"<table><tr align=\"left\" class=\"hl-Title\"><th>--- Options ---</th></tr>";
|
||||||
var name, value, def;
|
var name, value, def;
|
||||||
|
|
||||||
@@ -668,10 +668,10 @@ vimperator.Options = function () //{{{
|
|||||||
if (value != def)
|
if (value != def)
|
||||||
{
|
{
|
||||||
name = "<span style=\"font-weight: bold\">" + name + "</span>";
|
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
|
else
|
||||||
value = vimperator.util.colorize(value, false);
|
value = liberator.util.colorize(value, false);
|
||||||
|
|
||||||
list += "<tr><td>" + " " + name + "=" + value + "</td></tr>";
|
list += "<tr><td>" + " " + name + "=" + value + "</td></tr>";
|
||||||
}
|
}
|
||||||
@@ -679,7 +679,7 @@ vimperator.Options = function () //{{{
|
|||||||
|
|
||||||
list += "</table>";
|
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)
|
listPrefs: function (onlyNonDefault, filter)
|
||||||
@@ -689,8 +689,8 @@ vimperator.Options = function () //{{{
|
|||||||
|
|
||||||
var prefArray = prefService.getChildList("", {value: 0});
|
var prefArray = prefService.getChildList("", {value: 0});
|
||||||
prefArray.sort();
|
prefArray.sort();
|
||||||
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>--- " + vimperator.config.hostApplication +
|
"<table><tr align=\"left\" class=\"hl-Title\"><th>--- " + liberator.config.hostApplication +
|
||||||
" Options ---</th></tr>";
|
" Options ---</th></tr>";
|
||||||
var name, value, defaultValue;
|
var name, value, defaultValue;
|
||||||
|
|
||||||
@@ -704,7 +704,7 @@ vimperator.Options = function () //{{{
|
|||||||
if (typeof value == "string")
|
if (typeof value == "string")
|
||||||
value = value.substr(0, 100).replace(/\n/g, " ");
|
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);
|
defaultValue = loadPreference(name, null, true);
|
||||||
|
|
||||||
if (defaultValue == null)
|
if (defaultValue == null)
|
||||||
@@ -721,7 +721,7 @@ vimperator.Options = function () //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
list += "</table>";
|
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)
|
getPref: function (name, forcedDefault)
|
||||||
@@ -745,7 +745,7 @@ vimperator.Options = function () //{{{
|
|||||||
if (prefService.getPrefType(name) == prefService.PREF_BOOL)
|
if (prefService.getPrefType(name) == prefService.PREF_BOOL)
|
||||||
this.setPref(name, !this.getPref(name));
|
this.setPref(name, !this.getPref(name));
|
||||||
else
|
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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.Tabs = function () //{{{
|
liberator.Tabs = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -78,7 +78,7 @@ vimperator.Tabs = function () //{{{
|
|||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.options.add(["activate", "act"],
|
liberator.options.add(["activate", "act"],
|
||||||
"Define when tabs are automatically activated",
|
"Define when tabs are automatically activated",
|
||||||
"stringlist", "homepage,quickmark,tabopen,paste",
|
"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",
|
"Where to show requested popup windows",
|
||||||
"number", 1,
|
"number", 1,
|
||||||
{
|
{
|
||||||
@@ -98,13 +98,13 @@ vimperator.Tabs = function () //{{{
|
|||||||
[0, 3], // in a new tab
|
[0, 3], // in a new tab
|
||||||
[2, 3], // in a new window if it has specified sizes
|
[2, 3], // in a new window if it has specified sizes
|
||||||
[1, 2]];// always in new window
|
[1, 2]];// always in new window
|
||||||
vimperator.options.setPref("browser.link.open_newwindow.restriction", values[value][0]);
|
liberator.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", values[value][1]);
|
||||||
},
|
},
|
||||||
validator: function (value) { return (value >= 0 && value <= 3); }
|
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",
|
"Control when to show the tab bar of opened web pages",
|
||||||
"number", 2,
|
"number", 2,
|
||||||
{
|
{
|
||||||
@@ -120,12 +120,12 @@ vimperator.Tabs = function () //{{{
|
|||||||
}
|
}
|
||||||
else if (value == 1)
|
else if (value == 1)
|
||||||
{
|
{
|
||||||
vimperator.options.setPref("browser.tabs.autoHide", true);
|
liberator.options.setPref("browser.tabs.autoHide", true);
|
||||||
tabs.collapsed = false;
|
tabs.collapsed = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vimperator.options.setPref("browser.tabs.autoHide", false);
|
liberator.options.setPref("browser.tabs.autoHide", false);
|
||||||
tabs.collapsed = false;
|
tabs.collapsed = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -136,78 +136,78 @@ vimperator.Tabs = function () //{{{
|
|||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["b"],
|
liberator.mappings.add([liberator.modes.NORMAL], ["b"],
|
||||||
"Open a prompt to switch buffers",
|
"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",
|
"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",
|
"Delete current buffer",
|
||||||
function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); },
|
function (count) { liberator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ 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",
|
"Delete current buffer, focus tab to the left",
|
||||||
function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); },
|
function (count) { liberator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gb"],
|
liberator.mappings.add([liberator.modes.NORMAL], ["gb"],
|
||||||
"Repeat last :buffer[!] command",
|
"Repeat last :buffer[!] command",
|
||||||
function (count) { vimperator.tabs.switchTo(null, null, count, false); },
|
function (count) { liberator.tabs.switchTo(null, null, count, false); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ 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",
|
"Repeat last :buffer[!] command in reverse direction",
|
||||||
function (count) { vimperator.tabs.switchTo(null, null, count, true); },
|
function (count) { liberator.tabs.switchTo(null, null, count, true); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ 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",
|
"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",
|
"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",
|
"Go to the next tab",
|
||||||
function (count) { vimperator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); },
|
function (count) { liberator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ 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",
|
"Go to previous tab",
|
||||||
function (count) { vimperator.tabs.select("-" + (count < 1 ? 1 : count), true); },
|
function (count) { liberator.tabs.select("-" + (count < 1 ? 1 : count), true); },
|
||||||
{ flags: vimperator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["u"],
|
liberator.mappings.add([liberator.modes.NORMAL], ["u"],
|
||||||
"Undo closing of a tab",
|
"Undo closing of a tab",
|
||||||
function (count) { vimperator.commands.get("undo").execute("", false, count); },
|
function (count) { liberator.commands.get("undo").execute("", false, count); },
|
||||||
{ flags: vimperator.Mappings.flags.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",
|
"Select the alternate tab",
|
||||||
function ()
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: this currently relies on v.tabs.index() returning the
|
// NOTE: this currently relies on v.tabs.index() returning the
|
||||||
// currently selected tab index when passed null
|
// 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
|
// TODO: since a tab close is more like a bdelete for us we
|
||||||
// should probably reopen the closed tab when a 'deleted'
|
// should probably reopen the closed tab when a 'deleted'
|
||||||
// alternate is selected
|
// alternate is selected
|
||||||
if (index == -1)
|
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
|
else
|
||||||
vimperator.tabs.select(index);
|
liberator.tabs.select(index);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -215,127 +215,127 @@ vimperator.Tabs = function () //{{{
|
|||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// 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",
|
"Delete current buffer",
|
||||||
function (args, special, count)
|
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",
|
"Switch to a buffer",
|
||||||
function (args, special) { vimperator.tabs.switchTo(args, special); },
|
function (args, special) { liberator.tabs.switchTo(args, special); },
|
||||||
{ completer: function (filter) { return vimperator.completion.buffer(filter); } });
|
{ 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",
|
"Show a list of all buffers",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E488: Trailing characters");
|
liberator.echoerr("E488: Trailing characters");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.tabs.list(special);
|
liberator.tabs.list(special);
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["quita[ll]", "qa[ll]"],
|
liberator.commands.add(["quita[ll]", "qa[ll]"],
|
||||||
"Quit " + vimperator.config.appName,
|
"Quit " + liberator.config.appName,
|
||||||
function () { vimperator.quit(false); });
|
function () { liberator.quit(false); });
|
||||||
|
|
||||||
vimperator.commands.add(["reloada[ll]"],
|
liberator.commands.add(["reloada[ll]"],
|
||||||
"Reload all tab pages",
|
"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",
|
"Execute a command and tell it to output in a new tab",
|
||||||
function (args) { vimperator.execute(args, { inTab: true }); },
|
function (args) { liberator.execute(args, { inTab: true }); },
|
||||||
{ completer: function (filter) { return vimperator.completion.command(filter); } });
|
{ completer: function (filter) { return liberator.completion.command(filter); } });
|
||||||
|
|
||||||
vimperator.commands.add(["tabl[ast]"],
|
liberator.commands.add(["tabl[ast]"],
|
||||||
"Switch to the last tab",
|
"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",
|
"Move the current tab after tab N",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
// FIXME: tabmove! N should probably produce an error
|
// FIXME: tabmove! N should probably produce an error
|
||||||
if (!/^([+-]?\d+|)$/.test(args))
|
if (!/^([+-]?\d+|)$/.test(args))
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E488: Trailing characters");
|
liberator.echoerr("E488: Trailing characters");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args)
|
if (!args)
|
||||||
args = "$"; // if not specified, move to the last tab
|
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
|
// 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",
|
"Switch to the next or [count]th tab",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
vimperator.tabs.select("+1", true);
|
liberator.tabs.select("+1", true);
|
||||||
}
|
}
|
||||||
else if (/^\d+$/.test(args))
|
else if (/^\d+$/.test(args))
|
||||||
{
|
{
|
||||||
var index = parseInt(args, 10) - 1;
|
var index = parseInt(args, 10) - 1;
|
||||||
if (index < vimperator.tabs.count)
|
if (index < liberator.tabs.count)
|
||||||
vimperator.tabs.select(index, true);
|
liberator.tabs.select(index, true);
|
||||||
else
|
else
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
}
|
}
|
||||||
else
|
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",
|
"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",
|
"Open one or more URLs in a new tab",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
var where = special ? vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB;
|
var where = special ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
|
||||||
if (/\btabopen\b/.test(vimperator.options["activate"]))
|
if (/\btabopen\b/.test(liberator.options["activate"]))
|
||||||
where = special ? vimperator.NEW_BACKGROUND_TAB : vimperator.NEW_TAB;
|
where = special ? liberator.NEW_BACKGROUND_TAB : liberator.NEW_TAB;
|
||||||
|
|
||||||
if (args)
|
if (args)
|
||||||
vimperator.open(args, where);
|
liberator.open(args, where);
|
||||||
else
|
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
|
// 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",
|
"Switch to the previous tab or go [count] tabs back",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
vimperator.tabs.select("-1", true);
|
liberator.tabs.select("-1", true);
|
||||||
else if (/^\d+$/.test(args))
|
else if (/^\d+$/.test(args))
|
||||||
vimperator.tabs.select("-" + args, true); // FIXME: urgh!
|
liberator.tabs.select("-" + args, true); // FIXME: urgh!
|
||||||
else
|
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",
|
"Switch to the first tab",
|
||||||
function () { vimperator.tabs.select(0, false); });
|
function () { liberator.tabs.select(0, false); });
|
||||||
|
|
||||||
// TODO: extract common functionality of "undoall"
|
// TODO: extract common functionality of "undoall"
|
||||||
vimperator.commands.add(["u[ndo]"],
|
liberator.commands.add(["u[ndo]"],
|
||||||
"Undo closing of a tab",
|
"Undo closing of a tab",
|
||||||
function (args, special, count)
|
function (args, special, count)
|
||||||
{
|
{
|
||||||
@@ -371,25 +371,25 @@ vimperator.Tabs = function () //{{{
|
|||||||
// undoItems[i].image is also available if needed for favicons
|
// undoItems[i].image is also available if needed for favicons
|
||||||
var url = undoItems[i].state.entries[0].url;
|
var url = undoItems[i].state.entries[0].url;
|
||||||
var title = undoItems[i].title;
|
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]);
|
completions.push([url, title]);
|
||||||
}
|
}
|
||||||
return [0, completions];
|
return [0, completions];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["undoa[ll]"],
|
liberator.commands.add(["undoa[ll]"],
|
||||||
"Undo closing of all closed tabs",
|
"Undo closing of all closed tabs",
|
||||||
function (args, special, count)
|
function (args, special, count)
|
||||||
{
|
{
|
||||||
if (count > -1)
|
if (count > -1)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E481: No range allowed");
|
liberator.echoerr("E481: No range allowed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (special)
|
if (special)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E477: No ! allowed");
|
liberator.echoerr("E477: No ! allowed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,11 +400,11 @@ vimperator.Tabs = function () //{{{
|
|||||||
undoCloseTab(); // doesn't work with i as the index to undoCloseTab
|
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",
|
"Save the session and quit",
|
||||||
function () { vimperator.quit(true); });
|
function () { liberator.quit(true); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -463,37 +463,37 @@ vimperator.Tabs = function () //{{{
|
|||||||
if (fullmode)
|
if (fullmode)
|
||||||
{
|
{
|
||||||
// toggle the special buffer preview window
|
// toggle the special buffer preview window
|
||||||
if (vimperator.bufferwindow.visible())
|
if (liberator.bufferwindow.visible())
|
||||||
{
|
{
|
||||||
vimperator.bufferwindow.hide();
|
liberator.bufferwindow.hide();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var items = vimperator.completion.buffer("")[1];
|
var items = liberator.completion.buffer("")[1];
|
||||||
vimperator.bufferwindow.show(items);
|
liberator.bufferwindow.show(items);
|
||||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
liberator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: move this to vimperator.buffers.get()
|
// TODO: move this to liberator.buffers.get()
|
||||||
var items = vimperator.completion.buffer("")[1];
|
var items = liberator.completion.buffer("")[1];
|
||||||
var number, indicator, title, url;
|
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++)
|
for (var i = 0; i < items.length; i++)
|
||||||
{
|
{
|
||||||
if (i == vimperator.tabs.index())
|
if (i == liberator.tabs.index())
|
||||||
indicator = " <span style=\"color: blue\">%</span> ";
|
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> ";
|
indicator = " <span style=\"color: blue\">#</span> ";
|
||||||
else
|
else
|
||||||
indicator = " ";
|
indicator = " ";
|
||||||
|
|
||||||
[number, title] = items[i][0].split(/:\s+/, 2);
|
[number, title] = items[i][0].split(/:\s+/, 2);
|
||||||
url = items[i][1];
|
url = items[i][1];
|
||||||
url = vimperator.util.escapeHTML(url);
|
url = liberator.util.escapeHTML(url);
|
||||||
title = vimperator.util.escapeHTML(title);
|
title = liberator.util.escapeHTML(title);
|
||||||
|
|
||||||
list += "<tr><td align=\"right\"> " + number + "</td><td>" + indicator +
|
list += "<tr><td align=\"right\"> " + number + "</td><td>" + indicator +
|
||||||
"</td><td style=\"width: 250px; max-width: 500px; overflow: hidden;\">" + title +
|
"</td><td style=\"width: 250px; max-width: 500px; overflow: hidden;\">" + title +
|
||||||
@@ -501,7 +501,7 @@ vimperator.Tabs = function () //{{{
|
|||||||
}
|
}
|
||||||
list += "</table>";
|
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);
|
getBrowser().removeTab(tab);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (vimperator.buffer.URL != "about:blank" ||
|
if (liberator.buffer.URL != "about:blank" ||
|
||||||
getWebNavigation().sessionHistory.count > 0)
|
getWebNavigation().sessionHistory.count > 0)
|
||||||
{
|
{
|
||||||
vimperator.open("about:blank", vimperator.NEW_BACKGROUND_TAB);
|
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
||||||
getBrowser().removeTab(tab);
|
getBrowser().removeTab(tab);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,10 +539,10 @@ vimperator.Tabs = function () //{{{
|
|||||||
|
|
||||||
if (quitOnLastTab >= 1 && getBrowser().mTabs.length <= count)
|
if (quitOnLastTab >= 1 && getBrowser().mTabs.length <= count)
|
||||||
{
|
{
|
||||||
if (vimperator.windows.length > 1)
|
if (liberator.windows.length > 1)
|
||||||
window.close();
|
window.close();
|
||||||
else
|
else
|
||||||
vimperator.quit(quitOnLastTab == 2);
|
liberator.quit(quitOnLastTab == 2);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -580,7 +580,7 @@ vimperator.Tabs = function () //{{{
|
|||||||
// FIXME:
|
// FIXME:
|
||||||
if (index === -1)
|
if (index === -1)
|
||||||
{
|
{
|
||||||
vimperator.beep(); // XXX: move to ex-handling?
|
liberator.beep(); // XXX: move to ex-handling?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getBrowser().mTabContainer.selectedIndex = index;
|
getBrowser().mTabContainer.selectedIndex = index;
|
||||||
@@ -652,13 +652,13 @@ vimperator.Tabs = function () //{{{
|
|||||||
var match;
|
var match;
|
||||||
if (match = buffer.match(/^(\d+):?/))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches = [];
|
var matches = [];
|
||||||
var lowerBuffer = buffer.toLowerCase();
|
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++)
|
for (var i = 0; i < getBrowser().browsers.length; i++)
|
||||||
{
|
{
|
||||||
var index = (i + first) % getBrowser().browsers.length;
|
var index = (i + first) % getBrowser().browsers.length;
|
||||||
@@ -666,7 +666,7 @@ vimperator.Tabs = function () //{{{
|
|||||||
var title = getBrowser().getBrowserAtIndex(index).contentDocument.title.toLowerCase();
|
var title = getBrowser().getBrowserAtIndex(index).contentDocument.title.toLowerCase();
|
||||||
if (url == buffer)
|
if (url == buffer)
|
||||||
{
|
{
|
||||||
vimperator.tabs.select(index, false);
|
liberator.tabs.select(index, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,9 +674,9 @@ vimperator.Tabs = function () //{{{
|
|||||||
matches.push(index);
|
matches.push(index);
|
||||||
}
|
}
|
||||||
if (matches.length == 0)
|
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)
|
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
|
else
|
||||||
{
|
{
|
||||||
if (reverse)
|
if (reverse)
|
||||||
@@ -688,7 +688,7 @@ vimperator.Tabs = function () //{{{
|
|||||||
else
|
else
|
||||||
index = (count - 1) % matches.length;
|
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
|
* it consists of a prompt and command field
|
||||||
* be sure to only create objects of this class when the chrome is ready
|
* be sure to only create objects of this class when the chrome is ready
|
||||||
*/
|
*/
|
||||||
vimperator.CommandLine = function () //{{{
|
liberator.CommandLine = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// 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
|
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 = [];
|
var completions = [];
|
||||||
|
|
||||||
// TODO: clean this up when it's not 3am...
|
// TODO: clean this up when it's not 3am...
|
||||||
var history = {
|
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
|
cmd: null, // ex command history
|
||||||
|
|
||||||
@@ -60,14 +60,14 @@ vimperator.CommandLine = function () //{{{
|
|||||||
load: function ()
|
load: function ()
|
||||||
{
|
{
|
||||||
// TODO: move to storage module
|
// TODO: move to storage module
|
||||||
this.cmd = vimperator.options.getPref("extensions.vimperator.commandline_cmd_history", "").split("\n");
|
this.cmd = liberator.options.getPref("extensions.vimperator.commandline_cmd_history", "").split("\n");
|
||||||
this.search = vimperator.options.getPref("extensions.vimperator.commandline_search_history", "").split("\n");
|
this.search = liberator.options.getPref("extensions.vimperator.commandline_search_history", "").split("\n");
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function ()
|
save: function ()
|
||||||
{
|
{
|
||||||
vimperator.options.setPref("extensions.vimperator.commandline_cmd_history", this.cmd.join("\n"));
|
liberator.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_search_history", this.search.join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
add: function (str)
|
add: function (str)
|
||||||
@@ -103,19 +103,19 @@ vimperator.CommandLine = function () //{{{
|
|||||||
var completionIndex = UNINITIALIZED;
|
var completionIndex = UNINITIALIZED;
|
||||||
|
|
||||||
// the containing box for the promptWidget and commandWidget
|
// 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
|
// 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
|
// 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
|
// 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.setAttribute("style", "margin: 0px; font-family: -moz-fixed;"); // get rid of the default border
|
||||||
multilineOutputWidget.contentDocument.body.innerHTML = "";
|
multilineOutputWidget.contentDocument.body.innerHTML = "";
|
||||||
|
|
||||||
// the widget used for multiline intput
|
// 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
|
// 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"
|
// this is then used if we focus the command line again without the "official"
|
||||||
@@ -180,16 +180,16 @@ vimperator.CommandLine = function () //{{{
|
|||||||
multilineOutputWidget.collapsed = true;
|
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");
|
var fontSize = document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue("font-size");
|
||||||
multilineOutputWidget.contentDocument.body.setAttribute("style", "font-size: " + fontSize);
|
multilineOutputWidget.contentDocument.body.setAttribute("style", "font-size: " + fontSize);
|
||||||
|
|
||||||
multilineOutputWidget.contentDocument.body.innerHTML = output;
|
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");
|
var stylesheet = multilineOutputWidget.contentDocument.createElement("link");
|
||||||
stylesheet.setAttribute("rel", "Stylesheet");
|
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);
|
multilineOutputWidget.contentDocument.getElementsByTagName("head")[0].appendChild(stylesheet);
|
||||||
|
|
||||||
var availableHeight = getBrowser().mPanelContainer != undefined ?
|
var availableHeight = getBrowser().mPanelContainer != undefined ?
|
||||||
@@ -202,26 +202,26 @@ vimperator.CommandLine = function () //{{{
|
|||||||
multilineOutputWidget.height = height + "px";
|
multilineOutputWidget.height = height + "px";
|
||||||
multilineOutputWidget.collapsed = false;
|
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
|
// start the last executed command's output at the top of the screen
|
||||||
var elements = multilineOutputWidget.contentDocument.getElementsByClassName("ex-command-output");
|
var elements = multilineOutputWidget.contentDocument.getElementsByClassName("ex-command-output");
|
||||||
elements[elements.length - 1].scrollIntoView(true);
|
elements[elements.length - 1].scrollIntoView(true);
|
||||||
|
|
||||||
if (multilineOutputWidget.contentWindow.scrollY >= multilineOutputWidget.contentWindow.scrollMaxY)
|
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
|
else
|
||||||
setLine("-- More --", vimperator.commandline.HL_QUESTION);
|
setLine("-- More --", liberator.commandline.HL_QUESTION);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
multilineOutputWidget.contentWindow.scrollTo(0, contentHeight);
|
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();
|
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()
|
function autosizeMultilineInputWidget()
|
||||||
@@ -248,20 +248,20 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// TODO: move to vimperator.eval()?
|
// TODO: move to liberator.eval()?
|
||||||
// with (vimperator) means, vimperator is the default namespace "inside" eval
|
// with (liberator) means, liberator is the default namespace "inside" eval
|
||||||
arg = eval("with(vimperator){" + arg + "}");
|
arg = eval("with(liberator){" + arg + "}");
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
vimperator.echoerr(e.toString());
|
liberator.echoerr(e.toString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof arg === "object")
|
if (typeof arg === "object")
|
||||||
arg = vimperator.util.objectToString(arg, useColor);
|
arg = liberator.util.objectToString(arg, useColor);
|
||||||
else if (typeof arg === "function")
|
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")
|
else if (typeof arg === "number" || typeof arg === "boolean")
|
||||||
arg = "" + arg;
|
arg = "" + arg;
|
||||||
else if (typeof arg === "undefined")
|
else if (typeof arg === "undefined")
|
||||||
@@ -274,26 +274,26 @@ vimperator.CommandLine = function () //{{{
|
|||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// 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 of Ex commands and search patterns to store in the commandline history",
|
||||||
"number", 500);
|
"number", 500);
|
||||||
|
|
||||||
vimperator.options.add(["more"],
|
liberator.options.add(["more"],
|
||||||
"Pause the message list window when more than one screen of listings is displayed",
|
"Pause the message list window when more than one screen of listings is displayed",
|
||||||
"boolean", true);
|
"boolean", true);
|
||||||
|
|
||||||
vimperator.options.add(["complete", "cpt"],
|
liberator.options.add(["complete", "cpt"],
|
||||||
"Items which are completed at the :[tab]open prompt",
|
"Items which are completed at the :[tab]open prompt",
|
||||||
"charlist", "sfbh",
|
"charlist", "sfbh",
|
||||||
{
|
{
|
||||||
validator: function (value) { return !/[^sfbh]/.test(value); }
|
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",
|
"Show the current mode in the command line",
|
||||||
"boolean", true);
|
"boolean", true);
|
||||||
|
|
||||||
vimperator.options.add(["wildmode", "wim"],
|
liberator.options.add(["wildmode", "wim"],
|
||||||
"Define how command line completion works",
|
"Define how command line completion works",
|
||||||
"stringlist", "list:full",
|
"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",
|
"Change how command line completion is done",
|
||||||
"stringlist", "",
|
"stringlist", "",
|
||||||
{
|
{
|
||||||
@@ -314,40 +314,40 @@ vimperator.CommandLine = function () //{{{
|
|||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// 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",
|
["<Space>"], "Expand command line abbreviation",
|
||||||
function () { return vimperator.editor.expandAbbreviation("c"); },
|
function () { return liberator.editor.expandAbbreviation("c"); },
|
||||||
{ flags: vimperator.Mappings.flags.ALLOW_EVENT_ROUTING });
|
{ flags: liberator.Mappings.flags.ALLOW_EVENT_ROUTING });
|
||||||
|
|
||||||
vimperator.mappings.add(modes,
|
liberator.mappings.add(modes,
|
||||||
["<C-]>", "<C-5>"], "Expand command line abbreviation",
|
["<C-]>", "<C-5>"], "Expand command line abbreviation",
|
||||||
function () { vimperator.editor.expandAbbreviation("c"); });
|
function () { liberator.editor.expandAbbreviation("c"); });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["ec[ho]"],
|
liberator.commands.add(["ec[ho]"],
|
||||||
"Display a string at the bottom of the window",
|
"Display a string at the bottom of the window",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
var res = echoArgumentToString(args, true);
|
var res = echoArgumentToString(args, true);
|
||||||
if (res != null)
|
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",
|
"Display an error string at the bottom of the window",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
var res = echoArgumentToString(args, false);
|
var res = echoArgumentToString(args, false);
|
||||||
if (res != null)
|
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 //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
@@ -387,9 +387,9 @@ vimperator.CommandLine = function () //{{{
|
|||||||
completionIndex = UNINITIALIZED;
|
completionIndex = UNINITIALIZED;
|
||||||
|
|
||||||
// save the mode, because we need to restore it
|
// save the mode, because we need to restore it
|
||||||
oldMode = vimperator.mode;
|
oldMode = liberator.mode;
|
||||||
oldExtendedMode = vimperator.mode.extended;
|
oldExtendedMode = liberator.mode.extended;
|
||||||
vimperator.modes.set(vimperator.modes.COMMAND_LINE, currentExtendedMode);
|
liberator.modes.set(liberator.modes.COMMAND_LINE, currentExtendedMode);
|
||||||
setHighlightGroup(this.HL_NORMAL);
|
setHighlightGroup(this.HL_NORMAL);
|
||||||
setPrompt(currentPrompt);
|
setPrompt(currentPrompt);
|
||||||
setCommand(currentCommand);
|
setCommand(currentCommand);
|
||||||
@@ -400,9 +400,9 @@ vimperator.CommandLine = function () //{{{
|
|||||||
// normally used when pressing esc, does not execute a command
|
// normally used when pressing esc, does not execute a command
|
||||||
close: function ()
|
close: function ()
|
||||||
{
|
{
|
||||||
var res = vimperator.triggerCallback("cancel", currentExtendedMode);
|
var res = liberator.triggerCallback("cancel", currentExtendedMode);
|
||||||
history.add(this.getCommand());
|
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();
|
this.clear();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// TODO: add :messages entry
|
// 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)
|
echo: function (str, highlightGroup, flags)
|
||||||
{
|
{
|
||||||
// if we are modifing the GUI while we are not in the main thread
|
// 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
|
// 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)
|
input: function (str)
|
||||||
{
|
{
|
||||||
// TODO: unfinished, need to find out how/if we can block the execution of code
|
// 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)
|
inputMultiline: function (untilRegexp, callbackFunc)
|
||||||
{
|
{
|
||||||
// save the mode, because we need to restore it
|
// save the mode, because we need to restore it
|
||||||
oldMode = vimperator.mode;
|
oldMode = liberator.mode;
|
||||||
oldExtendedMode = vimperator.mode.extended;
|
oldExtendedMode = liberator.mode.extended;
|
||||||
vimperator.modes.set(vimperator.modes.COMMAND_LINE, vimperator.modes.INPUT_MULTILINE);
|
liberator.modes.set(liberator.modes.COMMAND_LINE, liberator.modes.INPUT_MULTILINE);
|
||||||
|
|
||||||
// save the arguments, they are needed in the event handler onEvent
|
// save the arguments, they are needed in the event handler onEvent
|
||||||
multilineRegexp = untilRegexp;
|
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
|
// prevent losing focus, there should be a better way, but it just didn't work otherwise
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (vimperator.mode == vimperator.modes.COMMAND_LINE &&
|
if (liberator.mode == liberator.modes.COMMAND_LINE &&
|
||||||
!(vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE) &&
|
!(liberator.modes.extended & liberator.modes.INPUT_MULTILINE) &&
|
||||||
!(vimperator.modes.extended & vimperator.modes.OUTPUT_MULTILINE))
|
!(liberator.modes.extended & liberator.modes.OUTPUT_MULTILINE))
|
||||||
commandWidget.inputField.focus();
|
commandWidget.inputField.focus();
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
@@ -509,27 +509,27 @@ vimperator.CommandLine = function () //{{{
|
|||||||
}
|
}
|
||||||
else if (event.type == "input")
|
else if (event.type == "input")
|
||||||
{
|
{
|
||||||
vimperator.triggerCallback("change", currentExtendedMode, command);
|
liberator.triggerCallback("change", currentExtendedMode, command);
|
||||||
}
|
}
|
||||||
else if (event.type == "keypress")
|
else if (event.type == "keypress")
|
||||||
{
|
{
|
||||||
if (!currentExtendedMode)
|
if (!currentExtendedMode)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var key = vimperator.events.toString(event);
|
var key = liberator.events.toString(event);
|
||||||
//vimperator.log("command line handling key: " + key + "\n");
|
//liberator.log("command line handling key: " + key + "\n");
|
||||||
|
|
||||||
// user pressed ENTER to carry out a command
|
// user pressed ENTER to carry out a command
|
||||||
// user pressing ESCAPE is handled in the global onEscape
|
// 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
|
var mode = currentExtendedMode; // save it here, as setMode() resets it
|
||||||
history.add(command);
|
history.add(command);
|
||||||
vimperator.modes.reset(true); //FIXME: use mode stack
|
liberator.modes.reset(true); //FIXME: use mode stack
|
||||||
completionlist.hide();
|
completionlist.hide();
|
||||||
vimperator.focusContent(false);
|
liberator.focusContent(false);
|
||||||
vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
liberator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||||
return vimperator.triggerCallback("submit", mode, command);
|
return liberator.triggerCallback("submit", mode, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
// user pressed UP or DOWN arrow to cycle history completion
|
// user pressed UP or DOWN arrow to cycle history completion
|
||||||
@@ -560,7 +560,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
if (historyIndex == lines.length)
|
if (historyIndex == lines.length)
|
||||||
{
|
{
|
||||||
setCommand(historyStart);
|
setCommand(historyStart);
|
||||||
vimperator.triggerCallback("change", currentExtendedMode, this.getCommand());
|
liberator.triggerCallback("change", currentExtendedMode, this.getCommand());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,20 +568,20 @@ vimperator.CommandLine = function () //{{{
|
|||||||
if (historyIndex <= -1)
|
if (historyIndex <= -1)
|
||||||
{
|
{
|
||||||
historyIndex = 0;
|
historyIndex = 0;
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (historyIndex >= lines.length + 1)
|
else if (historyIndex >= lines.length + 1)
|
||||||
{
|
{
|
||||||
historyIndex = lines.length;
|
historyIndex = lines.length;
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines[historyIndex].indexOf(historyStart) == 0)
|
if (lines[historyIndex].indexOf(historyStart) == 0)
|
||||||
{
|
{
|
||||||
setCommand(lines[historyIndex]);
|
setCommand(lines[historyIndex]);
|
||||||
vimperator.triggerCallback("change", currentExtendedMode, this.getCommand());
|
liberator.triggerCallback("change", currentExtendedMode, this.getCommand());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -603,12 +603,12 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
completionPrefix = command.substring(0, commandWidget.selectionStart);
|
completionPrefix = command.substring(0, commandWidget.selectionStart);
|
||||||
completionPostfix = command.substring(commandWidget.selectionStart);
|
completionPostfix = command.substring(commandWidget.selectionStart);
|
||||||
var res = vimperator.triggerCallback("complete", currentExtendedMode, completionPrefix);
|
var res = liberator.triggerCallback("complete", currentExtendedMode, completionPrefix);
|
||||||
if (res)
|
if (res)
|
||||||
[completionStartIndex, completions] = res;
|
[completionStartIndex, completions] = res;
|
||||||
|
|
||||||
// sort the completion list
|
// sort the completion list
|
||||||
if (/\bsort\b/.test(vimperator.options["wildoptions"]))
|
if (/\bsort\b/.test(liberator.options["wildoptions"]))
|
||||||
{
|
{
|
||||||
completions.sort(function (a, b) {
|
completions.sort(function (a, b) {
|
||||||
if (a[0] < b[0])
|
if (a[0] < b[0])
|
||||||
@@ -623,12 +623,12 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
if (completions.length == 0)
|
if (completions.length == 0)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
// prevent tab from moving to the next field:
|
// prevent tab from moving to the next field:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var wim = vimperator.options["wildmode"].split(/,/);
|
var wim = liberator.options["wildmode"].split(/,/);
|
||||||
var hasList = false;
|
var hasList = false;
|
||||||
var longest = false;
|
var longest = false;
|
||||||
var full = false;
|
var full = false;
|
||||||
@@ -664,7 +664,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
completionIndex = -1;
|
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
|
// if the list is hidden, this function does nothing
|
||||||
completionlist.selectItem(completionIndex);
|
completionlist.selectItem(completionIndex);
|
||||||
}
|
}
|
||||||
@@ -680,7 +680,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
{
|
{
|
||||||
var compl = null;
|
var compl = null;
|
||||||
if (longest && completions.length > 1)
|
if (longest && completions.length > 1)
|
||||||
compl = vimperator.completion.getLongestSubstring();
|
compl = liberator.completion.getLongestSubstring();
|
||||||
else if (full)
|
else if (full)
|
||||||
compl = completions[completionIndex][0];
|
compl = completions[completionIndex][0];
|
||||||
else if (completions.length == 1)
|
else if (completions.length == 1)
|
||||||
@@ -711,8 +711,8 @@ vimperator.CommandLine = function () //{{{
|
|||||||
// and blur the command line if there is no text left
|
// and blur the command line if there is no text left
|
||||||
if (command.length == 0)
|
if (command.length == 0)
|
||||||
{
|
{
|
||||||
vimperator.triggerCallback("cancel", currentExtendedMode);
|
liberator.triggerCallback("cancel", currentExtendedMode);
|
||||||
vimperator.modes.reset(); // FIXME: use mode stack
|
liberator.modes.reset(); // FIXME: use mode stack
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // any other key
|
else // any other key
|
||||||
@@ -728,27 +728,27 @@ vimperator.CommandLine = function () //{{{
|
|||||||
{
|
{
|
||||||
if (event.type == "keypress")
|
if (event.type == "keypress")
|
||||||
{
|
{
|
||||||
var key = vimperator.events.toString(event);
|
var key = liberator.events.toString(event);
|
||||||
if (vimperator.events.isAcceptKey(key))
|
if (liberator.events.isAcceptKey(key))
|
||||||
{
|
{
|
||||||
var text = multilineInputWidget.value.substr(0, multilineInputWidget.selectionStart);
|
var text = multilineInputWidget.value.substr(0, multilineInputWidget.selectionStart);
|
||||||
if (text.match(multilineRegexp))
|
if (text.match(multilineRegexp))
|
||||||
{
|
{
|
||||||
text = text.replace(multilineRegexp, "");
|
text = text.replace(multilineRegexp, "");
|
||||||
vimperator.modes.set(oldMode, oldExtendedMode);
|
liberator.modes.set(oldMode, oldExtendedMode);
|
||||||
multilineInputWidget.collapsed = true;
|
multilineInputWidget.collapsed = true;
|
||||||
multilineCallback.call(this, text);
|
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;
|
multilineInputWidget.collapsed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event.type == "blur")
|
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);
|
setTimeout(function () { multilineInputWidget.inputField.focus(); }, 0);
|
||||||
}
|
}
|
||||||
else if (event.type == "input")
|
else if (event.type == "input")
|
||||||
@@ -773,7 +773,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
function atEnd() { return win.scrollY / win.scrollMaxY >= 1; }
|
function atEnd() { return win.scrollY / win.scrollMaxY >= 1; }
|
||||||
|
|
||||||
var key = vimperator.events.toString(event);
|
var key = liberator.events.toString(event);
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
@@ -782,13 +782,13 @@ vimperator.CommandLine = function () //{{{
|
|||||||
break; // handled globally in events.js:onEscape()
|
break; // handled globally in events.js:onEscape()
|
||||||
|
|
||||||
case ":":
|
case ":":
|
||||||
vimperator.commandline.open(":", "", vimperator.modes.EX);
|
liberator.commandline.open(":", "", liberator.modes.EX);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// down a line
|
// down a line
|
||||||
case "j":
|
case "j":
|
||||||
case "<Down>":
|
case "<Down>":
|
||||||
if (vimperator.options["more"] && isScrollable())
|
if (liberator.options["more"] && isScrollable())
|
||||||
win.scrollByLines(1);
|
win.scrollByLines(1);
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
@@ -797,7 +797,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
case "<C-j>":
|
case "<C-j>":
|
||||||
case "<C-m>":
|
case "<C-m>":
|
||||||
case "<Return>":
|
case "<Return>":
|
||||||
if (vimperator.options["more"] && isScrollable() && !atEnd())
|
if (liberator.options["more"] && isScrollable() && !atEnd())
|
||||||
win.scrollByLines(1);
|
win.scrollByLines(1);
|
||||||
else
|
else
|
||||||
closeWindow = true; // don't propagate the event for accept keys
|
closeWindow = true; // don't propagate the event for accept keys
|
||||||
@@ -807,9 +807,9 @@ vimperator.CommandLine = function () //{{{
|
|||||||
case "k":
|
case "k":
|
||||||
case "<Up>":
|
case "<Up>":
|
||||||
case "<BS>":
|
case "<BS>":
|
||||||
if (vimperator.options["more"] && isScrollable())
|
if (liberator.options["more"] && isScrollable())
|
||||||
win.scrollByLines(-1);
|
win.scrollByLines(-1);
|
||||||
else if (vimperator.options["more"] && !isScrollable())
|
else if (liberator.options["more"] && !isScrollable())
|
||||||
showMorePrompt = true;
|
showMorePrompt = true;
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
@@ -817,7 +817,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
// half page down
|
// half page down
|
||||||
case "d":
|
case "d":
|
||||||
if (vimperator.options["more"] && isScrollable())
|
if (liberator.options["more"] && isScrollable())
|
||||||
win.scrollBy(0, win.innerHeight / 2);
|
win.scrollBy(0, win.innerHeight / 2);
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
@@ -826,22 +826,22 @@ vimperator.CommandLine = function () //{{{
|
|||||||
case "<LeftMouse>":
|
case "<LeftMouse>":
|
||||||
if (event.originalTarget.className == "hl-URL buffer-list")
|
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;
|
closeWindow = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (event.originalTarget.localName.toLowerCase() == "a")
|
else if (event.originalTarget.localName.toLowerCase() == "a")
|
||||||
{
|
{
|
||||||
vimperator.open(event.originalTarget.textContent);
|
liberator.open(event.originalTarget.textContent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "<A-LeftMouse>": // for those not owning a 3-button mouse
|
case "<A-LeftMouse>": // for those not owning a 3-button mouse
|
||||||
case "<MiddleMouse>":
|
case "<MiddleMouse>":
|
||||||
if (event.originalTarget.localName.toLowerCase() == "a")
|
if (event.originalTarget.localName.toLowerCase() == "a")
|
||||||
{
|
{
|
||||||
var where = /\btabopen\b/.test(vimperator.options["activate"]) ?
|
var where = /\btabopen\b/.test(liberator.options["activate"]) ?
|
||||||
vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB;
|
liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
|
||||||
vimperator.open(event.originalTarget.textContent, where);
|
liberator.open(event.originalTarget.textContent, where);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -860,7 +860,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
// page down
|
// page down
|
||||||
case "f":
|
case "f":
|
||||||
if (vimperator.options["more"] && isScrollable())
|
if (liberator.options["more"] && isScrollable())
|
||||||
win.scrollByPages(1);
|
win.scrollByPages(1);
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
@@ -868,7 +868,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
case "<Space>":
|
case "<Space>":
|
||||||
case "<PageDown>":
|
case "<PageDown>":
|
||||||
if (vimperator.options["more"] && isScrollable() && !atEnd())
|
if (liberator.options["more"] && isScrollable() && !atEnd())
|
||||||
win.scrollByPages(1);
|
win.scrollByPages(1);
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
@@ -877,7 +877,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
// half page up
|
// half page up
|
||||||
case "u":
|
case "u":
|
||||||
// if (more and scrollable)
|
// if (more and scrollable)
|
||||||
if (vimperator.options["more"] && isScrollable())
|
if (liberator.options["more"] && isScrollable())
|
||||||
win.scrollBy(0, -(win.innerHeight / 2));
|
win.scrollBy(0, -(win.innerHeight / 2));
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
@@ -885,16 +885,16 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
// page up
|
// page up
|
||||||
case "b":
|
case "b":
|
||||||
if (vimperator.options["more"] && isScrollable())
|
if (liberator.options["more"] && isScrollable())
|
||||||
win.scrollByPages(-1);
|
win.scrollByPages(-1);
|
||||||
else if (vimperator.options["more"] && !isScrollable())
|
else if (liberator.options["more"] && !isScrollable())
|
||||||
showMorePrompt = true;
|
showMorePrompt = true;
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "<PageUp>":
|
case "<PageUp>":
|
||||||
if (vimperator.options["more"] && isScrollable())
|
if (liberator.options["more"] && isScrollable())
|
||||||
win.scrollByPages(-1);
|
win.scrollByPages(-1);
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
@@ -902,9 +902,9 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
// top of page
|
// top of page
|
||||||
case "g":
|
case "g":
|
||||||
if (vimperator.options["more"] && isScrollable())
|
if (liberator.options["more"] && isScrollable())
|
||||||
win.scrollTo(0, 0);
|
win.scrollTo(0, 0);
|
||||||
else if (vimperator.options["more"] && !isScrollable())
|
else if (liberator.options["more"] && !isScrollable())
|
||||||
showMorePrompt = true;
|
showMorePrompt = true;
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
@@ -912,7 +912,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
// bottom of page
|
// bottom of page
|
||||||
case "G":
|
case "G":
|
||||||
if (vimperator.options["more"] && isScrollable() && !atEnd())
|
if (liberator.options["more"] && isScrollable() && !atEnd())
|
||||||
win.scrollTo(0, win.scrollMaxY);
|
win.scrollTo(0, win.scrollMaxY);
|
||||||
else
|
else
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
@@ -920,7 +920,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
// copy text to clipboard
|
// copy text to clipboard
|
||||||
case "<C-y>":
|
case "<C-y>":
|
||||||
vimperator.copyToClipboard(win.getSelection());
|
liberator.copyToClipboard(win.getSelection());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// close the window
|
// close the window
|
||||||
@@ -930,7 +930,7 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
// unmapped key
|
// unmapped key
|
||||||
default:
|
default:
|
||||||
if (!vimperator.options["more"] || !isScrollable() || atEnd() || vimperator.events.isCancelKey(key))
|
if (!liberator.options["more"] || !isScrollable() || atEnd() || liberator.events.isCancelKey(key))
|
||||||
passEvent = true;
|
passEvent = true;
|
||||||
else
|
else
|
||||||
showMoreHelpPrompt = true;
|
showMoreHelpPrompt = true;
|
||||||
@@ -939,17 +939,17 @@ vimperator.CommandLine = function () //{{{
|
|||||||
if (passEvent || closeWindow)
|
if (passEvent || closeWindow)
|
||||||
{
|
{
|
||||||
// FIXME: use mode stack
|
// FIXME: use mode stack
|
||||||
vimperator.modes.reset();
|
liberator.modes.reset();
|
||||||
this.clear();
|
this.clear();
|
||||||
|
|
||||||
if (passEvent)
|
if (passEvent)
|
||||||
vimperator.events.onKeyPress(event);
|
liberator.events.onKeyPress(event);
|
||||||
}
|
}
|
||||||
else // set update the prompt string
|
else // set update the prompt string
|
||||||
{
|
{
|
||||||
if (showMoreHelpPrompt)
|
if (showMoreHelpPrompt)
|
||||||
setLine("-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit", this.HL_MOREMSG);
|
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);
|
setLine("-- More --", this.HL_MOREMSG);
|
||||||
else
|
else
|
||||||
setLine("Press ENTER or type command to continue", this.HL_QUESTION);
|
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 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
|
* @param options: an optional hash which modifies the behavior of the list
|
||||||
*/
|
*/
|
||||||
vimperator.InformationList = function (id, options) //{{{
|
liberator.InformationList = function (id, options) //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -1076,7 +1076,7 @@ vimperator.InformationList = function (id, options) //{{{
|
|||||||
*/
|
*/
|
||||||
show: function (compl)
|
show: function (compl)
|
||||||
{
|
{
|
||||||
//maxItems = vimperator.options["previewheight"];
|
//maxItems = liberator.options["previewheight"];
|
||||||
|
|
||||||
if (compl)
|
if (compl)
|
||||||
{
|
{
|
||||||
@@ -1168,9 +1168,9 @@ vimperator.InformationList = function (id, options) //{{{
|
|||||||
var index = (widget.selectedIndex * 2) + 0;
|
var index = (widget.selectedIndex * 2) + 0;
|
||||||
var val = listcells[index].getAttribute("label");
|
var val = listcells[index].getAttribute("label");
|
||||||
if (val && event.button == 0 && event.type == "dblclick") // left double click
|
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
|
else if (val && event.button == 1) // middle click
|
||||||
vimperator.open(val, vimperator.NEW_TAB);
|
liberator.open(val, liberator.NEW_TAB);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1179,7 +1179,7 @@ vimperator.InformationList = function (id, options) //{{{
|
|||||||
//}}}
|
//}}}
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
vimperator.StatusLine = function () //{{{
|
liberator.StatusLine = function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -1189,18 +1189,18 @@ vimperator.StatusLine = function () //{{{
|
|||||||
statusBar.collapsed = true; // it is later restored unless the user sets laststatus=0
|
statusBar.collapsed = true; // it is later restored unless the user sets laststatus=0
|
||||||
|
|
||||||
// our status bar fields
|
// our status bar fields
|
||||||
var statuslineWidget = document.getElementById("vimperator-statusline");
|
var statuslineWidget = document.getElementById("liberator-statusline");
|
||||||
var urlWidget = document.getElementById("vimperator-statusline-field-url");
|
var urlWidget = document.getElementById("liberator-statusline-field-url");
|
||||||
var inputBufferWidget = document.getElementById("vimperator-statusline-field-inputbuffer");
|
var inputBufferWidget = document.getElementById("liberator-statusline-field-inputbuffer");
|
||||||
var progressWidget = document.getElementById("vimperator-statusline-field-progress");
|
var progressWidget = document.getElementById("liberator-statusline-field-progress");
|
||||||
var tabCountWidget = document.getElementById("vimperator-statusline-field-tabcount");
|
var tabCountWidget = document.getElementById("liberator-statusline-field-tabcount");
|
||||||
var bufferPositionWidget = document.getElementById("vimperator-statusline-field-bufferposition");
|
var bufferPositionWidget = document.getElementById("liberator-statusline-field-bufferposition");
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// OPTIONS /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.options.add(["laststatus", "ls"],
|
liberator.options.add(["laststatus", "ls"],
|
||||||
"Show the status line",
|
"Show the status line",
|
||||||
"number", 2,
|
"number", 2,
|
||||||
{
|
{
|
||||||
@@ -1209,7 +1209,7 @@ vimperator.StatusLine = function () //{{{
|
|||||||
if (value == 0)
|
if (value == 0)
|
||||||
document.getElementById("status-bar").collapsed = true;
|
document.getElementById("status-bar").collapsed = true;
|
||||||
else if (value == 1)
|
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
|
else
|
||||||
document.getElementById("status-bar").collapsed = false;
|
document.getElementById("status-bar").collapsed = false;
|
||||||
},
|
},
|
||||||
@@ -1261,12 +1261,12 @@ vimperator.StatusLine = function () //{{{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = vimperator.buffer.URL;
|
url = liberator.buffer.URL;
|
||||||
|
|
||||||
// make it even more vim-like
|
// make it even more vim-like
|
||||||
if (url == "about:blank")
|
if (url == "about:blank")
|
||||||
{
|
{
|
||||||
var title = vimperator.buffer.title;
|
var title = liberator.buffer.title;
|
||||||
if (!title)
|
if (!title)
|
||||||
url = "[No Name]";
|
url = "[No Name]";
|
||||||
}
|
}
|
||||||
@@ -1278,7 +1278,7 @@ vimperator.StatusLine = function () //{{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when session information is available, add [+] when we can go backwards
|
// 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 sh = getWebNavigation().sessionHistory;
|
||||||
var modified = "";
|
var modified = "";
|
||||||
@@ -1286,7 +1286,7 @@ vimperator.StatusLine = function () //{{{
|
|||||||
modified += "+";
|
modified += "+";
|
||||||
if (sh.index < sh.count -1)
|
if (sh.index < sh.count -1)
|
||||||
modified += "-";
|
modified += "-";
|
||||||
if (vimperator.bookmarks.isBookmarked(url))
|
if (liberator.bookmarks.isBookmarked(url))
|
||||||
modified += "\u2764"; // a heart symbol: ❤
|
modified += "\u2764"; // a heart symbol: ❤
|
||||||
//modified += "\u2665"; // a heart symbol: ♥
|
//modified += "\u2665"; // a heart symbol: ♥
|
||||||
|
|
||||||
@@ -1338,16 +1338,16 @@ vimperator.StatusLine = function () //{{{
|
|||||||
// you can omit either of the 2 arguments
|
// you can omit either of the 2 arguments
|
||||||
updateTabCount: function (currentIndex, totalTabs)
|
updateTabCount: function (currentIndex, totalTabs)
|
||||||
{
|
{
|
||||||
if (!vimperator.has("tabs"))
|
if (!liberator.has("tabs"))
|
||||||
{
|
{
|
||||||
tabCountWidget = "";
|
tabCountWidget = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentIndex || typeof currentIndex != "number")
|
if (!currentIndex || typeof currentIndex != "number")
|
||||||
currentIndex = vimperator.tabs.index() + 1;
|
currentIndex = liberator.tabs.index() + 1;
|
||||||
if (!totalTabs || typeof currentIndex != "number")
|
if (!totalTabs || typeof currentIndex != "number")
|
||||||
totalTabs = vimperator.tabs.count;
|
totalTabs = liberator.tabs.count;
|
||||||
|
|
||||||
tabCountWidget.value = "[" + currentIndex + "/" + totalTabs + "]";
|
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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.util = { //{{{
|
liberator.util = { //{{{
|
||||||
|
|
||||||
// TODO: use :highlight color groups
|
// TODO: use :highlight color groups
|
||||||
// if "processStrings" is true, any passed strings will be surrounded by " and
|
// if "processStrings" is true, any passed strings will be surrounded by " and
|
||||||
@@ -45,7 +45,7 @@ vimperator.util = { //{{{
|
|||||||
else if (type == "string")
|
else if (type == "string")
|
||||||
{
|
{
|
||||||
if (processStrings)
|
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>";
|
return "<span style=\"color: green;\">" + arg + "</span>";
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ vimperator.util = { //{{{
|
|||||||
|
|
||||||
var str = arg.toString();
|
var str = arg.toString();
|
||||||
if (typeof str == "string") // can be "undefined"
|
if (typeof str == "string") // can be "undefined"
|
||||||
return vimperator.util.escapeHTML(str);
|
return liberator.util.escapeHTML(str);
|
||||||
else
|
else
|
||||||
return "undefined";
|
return "undefined";
|
||||||
}
|
}
|
||||||
@@ -127,9 +127,9 @@ vimperator.util = { //{{{
|
|||||||
generateHelp: function (command, extraHelp)
|
generateHelp: function (command, extraHelp)
|
||||||
{
|
{
|
||||||
var start = "", end = "";
|
var start = "", end = "";
|
||||||
if (command instanceof vimperator.Command)
|
if (command instanceof liberator.Command)
|
||||||
start = ":"
|
start = ":"
|
||||||
else if (command instanceof vimperator.Option)
|
else if (command instanceof liberator.Option)
|
||||||
start = end = "'"
|
start = end = "'"
|
||||||
|
|
||||||
var ret = "";
|
var ret = "";
|
||||||
@@ -178,7 +178,7 @@ vimperator.util = { //{{{
|
|||||||
highlightURL: function (str, force)
|
highlightURL: function (str, force)
|
||||||
{
|
{
|
||||||
if (force || /^[a-zA-Z]+:\/\//.test(str))
|
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
|
else
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
@@ -248,7 +248,7 @@ vimperator.util = { //{{{
|
|||||||
urls[url] = urls[url].replace(/^\s+/, "").replace(/\s+$/, "");
|
urls[url] = urls[url].replace(/^\s+/, "").replace(/\s+$/, "");
|
||||||
|
|
||||||
// first check if it is an existing local file
|
// 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())
|
if (file.exists() && file.isReadable())
|
||||||
{
|
{
|
||||||
urls[url] = file.path;
|
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
|
// 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 does not contain any of: .:/) try opening it with a search engine
|
||||||
// or keyword bookmark
|
// 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 matches = urls[url].match(/^(\S+)(?:\s+(.+))?$/);
|
||||||
var alias = matches[1];
|
var alias = matches[1];
|
||||||
@@ -271,7 +271,7 @@ vimperator.util = { //{{{
|
|||||||
// like the comments below ;-)
|
// like the comments below ;-)
|
||||||
|
|
||||||
// check if the first word is a search engine
|
// 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)
|
if (searchURL)
|
||||||
{
|
{
|
||||||
urls[url] = 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
|
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)
|
if (searchURL)
|
||||||
{
|
{
|
||||||
urls[url] = 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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
const vimperator = (function () //{{{
|
const liberator = (function () //{{{
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
@@ -36,13 +36,13 @@ const vimperator = (function () //{{{
|
|||||||
// Only general options are added here, which are valid for all vimperator like extensions
|
// Only general options are added here, which are valid for all vimperator like extensions
|
||||||
function addOptions()
|
function addOptions()
|
||||||
{
|
{
|
||||||
vimperator.options.add(["guioptions", "go"],
|
liberator.options.add(["guioptions", "go"],
|
||||||
"Show or hide certain GUI elements like the menu or toolbar",
|
"Show or hide certain GUI elements like the menu or toolbar",
|
||||||
"charlist", "",
|
"charlist", "",
|
||||||
{
|
{
|
||||||
setter: function (value)
|
setter: function (value)
|
||||||
{
|
{
|
||||||
var guioptions = vimperator.config.guioptions || {};
|
var guioptions = liberator.config.guioptions || {};
|
||||||
for (let option in guioptions)
|
for (let option in guioptions)
|
||||||
{
|
{
|
||||||
guioptions[option].forEach( function(elem)
|
guioptions[option].forEach( function(elem)
|
||||||
@@ -58,13 +58,13 @@ const vimperator = (function () //{{{
|
|||||||
validator: function (value)
|
validator: function (value)
|
||||||
{
|
{
|
||||||
var regex = "[^";
|
var regex = "[^";
|
||||||
for (let option in vimperator.config.guioptions)
|
for (let option in liberator.config.guioptions)
|
||||||
regex += option.toString();
|
regex += option.toString();
|
||||||
|
|
||||||
return !(new RegExp(regex + "]").test(value));
|
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",
|
"Change the title of the window",
|
||||||
"string", "Vimperator",
|
"string", "Vimperator",
|
||||||
{
|
{
|
||||||
@@ -72,7 +72,7 @@ const vimperator = (function () //{{{
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var id = vimperator.config.mainWindowID || "main-window";
|
var id = liberator.config.mainWindowID || "main-window";
|
||||||
document.getElementById(id).setAttribute("titlemodifier", value);
|
document.getElementById(id).setAttribute("titlemodifier", value);
|
||||||
if (window.content.document.title.length > 0)
|
if (window.content.document.title.length > 0)
|
||||||
document.title = window.content.document.title + " - " + value;
|
document.title = window.content.document.title + " - " + value;
|
||||||
@@ -81,115 +81,115 @@ const vimperator = (function () //{{{
|
|||||||
}
|
}
|
||||||
catch (e)
|
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",
|
"Define which type of messages are logged",
|
||||||
"number", 0,
|
"number", 0,
|
||||||
{
|
{
|
||||||
validator: function (value) { return (value >= 0 && value <= 9); }
|
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",
|
"Use visual bell instead of beeping on errors",
|
||||||
"boolean", false,
|
"boolean", false,
|
||||||
{
|
{
|
||||||
setter: function (value) { vimperator.options.setPref("accessibility.typeaheadfind.enablesound", !value); },
|
setter: function (value) { liberator.options.setPref("accessibility.typeaheadfind.enablesound", !value); },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMappings()
|
function addMappings()
|
||||||
{
|
{
|
||||||
vimperator.mappings.add(vimperator.modes.all, ["<F1>"],
|
liberator.mappings.add(liberator.modes.all, ["<F1>"],
|
||||||
"Open help window",
|
"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",
|
"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",
|
"Quit and save the session",
|
||||||
function () { vimperator.quit(true); });
|
function () { liberator.quit(true); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function addCommands()
|
function addCommands()
|
||||||
{
|
{
|
||||||
vimperator.commands.add(["addo[ns]"],
|
liberator.commands.add(["addo[ns]"],
|
||||||
"Manage available Extensions and Themes",
|
"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",
|
"Play a system beep",
|
||||||
function () { vimperator.beep(); });
|
function () { liberator.beep(); });
|
||||||
|
|
||||||
vimperator.commands.add(["dia[log]"],
|
liberator.commands.add(["dia[log]"],
|
||||||
"Open a " + vimperator.config.appName + " dialog",
|
"Open a " + liberator.config.appName + " dialog",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dialogs = vimperator.config.dialogs || [];
|
var dialogs = liberator.config.dialogs || [];
|
||||||
for (let i = 0; i < dialogs.length; i++)
|
for (let i = 0; i < dialogs.length; i++)
|
||||||
{
|
{
|
||||||
if (dialogs[i][0] == args)
|
if (dialogs[i][0] == args)
|
||||||
return dialogs[i][2]();
|
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)
|
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",
|
"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",
|
"List all Ex commands with a short description",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
var usage = "<table>";
|
var usage = "<table>";
|
||||||
for (let command in vimperator.commands)
|
for (let command in liberator.commands)
|
||||||
{
|
{
|
||||||
usage += "<tr><td style='color: magenta; padding-right: 20px'> :" +
|
usage += "<tr><td style='color: magenta; padding-right: 20px'> :" +
|
||||||
vimperator.util.escapeHTML(command.name) + "</td><td>" +
|
liberator.util.escapeHTML(command.name) + "</td><td>" +
|
||||||
vimperator.util.escapeHTML(command.description) + "</td></tr>";
|
liberator.util.escapeHTML(command.description) + "</td></tr>";
|
||||||
}
|
}
|
||||||
usage += "</table>";
|
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",
|
"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()",
|
"Run a JavaScript command through eval()",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
if (special) // open javascript console
|
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
|
else
|
||||||
{
|
{
|
||||||
// check for a heredoc
|
// check for a heredoc
|
||||||
var matches = args.match(/(.*)<<\s*([^\s]+)$/);
|
var matches = args.match(/(.*)<<\s*([^\s]+)$/);
|
||||||
if (matches && matches[2])
|
if (matches && matches[2])
|
||||||
{
|
{
|
||||||
vimperator.commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"),
|
liberator.commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"),
|
||||||
function (code)
|
function (code)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -198,7 +198,7 @@ const vimperator = (function () //{{{
|
|||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
vimperator.echoerr(e.name + ": " + e.message);
|
liberator.echoerr(e.name + ": " + e.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -206,47 +206,47 @@ const vimperator = (function () //{{{
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
eval("with(vimperator){" + args + "}");
|
eval("with(liberator){" + args + "}");
|
||||||
}
|
}
|
||||||
catch (e)
|
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",
|
"Execute Normal mode commands",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E471: Argument required");
|
liberator.echoerr("E471: Argument required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.events.feedkeys(args, special);
|
liberator.events.feedkeys(args, special);
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["q[uit]"],
|
liberator.commands.add(["q[uit]"],
|
||||||
vimperator.has("tabs") ? "Quit current tab" : "Quit application",
|
liberator.has("tabs") ? "Quit current tab" : "Quit application",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
if (vimperator.has("tabs"))
|
if (liberator.has("tabs"))
|
||||||
vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
|
liberator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
|
||||||
else
|
else
|
||||||
vimperator.quit(false);
|
liberator.quit(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["res[tart]"],
|
liberator.commands.add(["res[tart]"],
|
||||||
"Force " + vimperator.config.appName + " to restart",
|
"Force " + liberator.config.appName + " to restart",
|
||||||
function () { vimperator.restart(); });
|
function () { liberator.restart(); });
|
||||||
|
|
||||||
vimperator.commands.add(["time"],
|
liberator.commands.add(["time"],
|
||||||
"Profile a piece of code or run a command multiple times",
|
"Profile a piece of code or run a command multiple times",
|
||||||
function (args, special, count)
|
function (args, special, count)
|
||||||
{
|
{
|
||||||
@@ -260,12 +260,12 @@ const vimperator = (function () //{{{
|
|||||||
if (args && args[0] == ":")
|
if (args && args[0] == ":")
|
||||||
{
|
{
|
||||||
while (i--)
|
while (i--)
|
||||||
vimperator.execute(args);
|
liberator.execute(args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (i--)
|
while (i--)
|
||||||
eval("with(vimperator){" + args + "}");
|
eval("with(liberator){" + args + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (special)
|
if (special)
|
||||||
@@ -295,7 +295,7 @@ const vimperator = (function () //{{{
|
|||||||
var totalUnits = "msec";
|
var totalUnits = "msec";
|
||||||
}
|
}
|
||||||
|
|
||||||
var str = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
|
var str = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
|
||||||
"<table>" +
|
"<table>" +
|
||||||
"<tr align=\"left\" class=\"hl-Title\"><th colspan=\"3\">Code execution summary</th></tr>" +
|
"<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>" +
|
"<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>" +
|
"<tr><td> Total time:</td><td align=\"right\"><span style=\"color: red\">" + total.toFixed(2) + "</span></td><td>" + totalUnits + "</td></tr>" +
|
||||||
"</table>";
|
"</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
|
else
|
||||||
{
|
{
|
||||||
var beforeTime = Date.now();
|
var beforeTime = Date.now();
|
||||||
if (args && args[0] == ":")
|
if (args && args[0] == ":")
|
||||||
vimperator.execute(args);
|
liberator.execute(args);
|
||||||
else
|
else
|
||||||
eval("with(vimperator){" + args + "}");
|
eval("with(liberator){" + args + "}");
|
||||||
|
|
||||||
if (special)
|
if (special)
|
||||||
return;
|
return;
|
||||||
@@ -319,43 +319,43 @@ const vimperator = (function () //{{{
|
|||||||
var afterTime = Date.now();
|
var afterTime = Date.now();
|
||||||
|
|
||||||
if (afterTime - beforeTime >= 100)
|
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
|
else
|
||||||
vimperator.echo("Total time: " + (afterTime - beforeTime) + " msec");
|
liberator.echo("Total time: " + (afterTime - beforeTime) + " msec");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
vimperator.echoerr(e);
|
liberator.echoerr(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["ve[rsion]"],
|
liberator.commands.add(["ve[rsion]"],
|
||||||
"Show version information",
|
"Show version information",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
if (special)
|
if (special)
|
||||||
vimperator.open("about:");
|
liberator.open("about:");
|
||||||
else
|
else
|
||||||
vimperator.echo(":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "\n" +
|
liberator.echo(":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "\n" +
|
||||||
vimperator.config.name + " " + vimperator.version +
|
liberator.config.name + " " + liberator.version +
|
||||||
" running on:\n" + navigator.userAgent);
|
" running on:\n" + navigator.userAgent);
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["viu[sage]"],
|
liberator.commands.add(["viu[sage]"],
|
||||||
"List all mappings with a short description",
|
"List all mappings with a short description",
|
||||||
function (args, special, count, modifiers)
|
function (args, special, count, modifiers)
|
||||||
{
|
{
|
||||||
var usage = "<table>";
|
var usage = "<table>";
|
||||||
for (let mapping in vimperator.mappings)
|
for (let mapping in liberator.mappings)
|
||||||
{
|
{
|
||||||
usage += "<tr><td style='color: magenta; padding-right: 20px'> " +
|
usage += "<tr><td style='color: magenta; padding-right: 20px'> " +
|
||||||
vimperator.util.escapeHTML(mapping.names[0]) + "</td><td>" +
|
liberator.util.escapeHTML(mapping.names[0]) + "</td><td>" +
|
||||||
vimperator.util.escapeHTML(mapping.description) + "</td></tr>";
|
liberator.util.escapeHTML(mapping.description) + "</td></tr>";
|
||||||
}
|
}
|
||||||
usage += "</table>";
|
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
|
// similar in his config
|
||||||
function hideGUI()
|
function hideGUI()
|
||||||
{
|
{
|
||||||
var guioptions = vimperator.config.guioptions || {};
|
var guioptions = liberator.config.guioptions || {};
|
||||||
for (let option in guioptions)
|
for (let option in guioptions)
|
||||||
{
|
{
|
||||||
guioptions[option].forEach( function(elem)
|
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 {
|
return {
|
||||||
|
|
||||||
get mode() { return vimperator.modes.main; },
|
get mode() { return liberator.modes.main; },
|
||||||
set mode(value) { vimperator.modes.main = value; },
|
set mode(value) { liberator.modes.main = value; },
|
||||||
|
|
||||||
// Global constants
|
// Global constants
|
||||||
CURRENT_TAB: 1,
|
CURRENT_TAB: 1,
|
||||||
@@ -432,10 +432,10 @@ const vimperator = (function () //{{{
|
|||||||
|
|
||||||
beep: function ()
|
beep: function ()
|
||||||
{
|
{
|
||||||
if (vimperator.options["visualbell"])
|
if (liberator.options["visualbell"])
|
||||||
{
|
{
|
||||||
// flash the visual bell
|
// flash the visual bell
|
||||||
var popup = document.getElementById("vimperator-visualbell");
|
var popup = document.getElementById("liberator-visualbell");
|
||||||
var win = getBrowser().mPanelContainer;
|
var win = getBrowser().mPanelContainer;
|
||||||
var box = document.getBoxObjectFor(win);
|
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)
|
copyToClipboard: function (str, verbose)
|
||||||
{
|
{
|
||||||
var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
|
var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
|
||||||
@@ -460,7 +460,7 @@ const vimperator = (function () //{{{
|
|||||||
clipboardHelper.copyString(str);
|
clipboardHelper.copyString(str);
|
||||||
|
|
||||||
if (verbose)
|
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"
|
// Execute an ex command like str=":zoom 300"
|
||||||
@@ -473,20 +473,20 @@ const vimperator = (function () //{{{
|
|||||||
if (!modifiers)
|
if (!modifiers)
|
||||||
modifiers = {};
|
modifiers = {};
|
||||||
|
|
||||||
var [count, cmd, special, args] = vimperator.commands.parseCommand(str.replace(/^'(.*)'$/, "$1"));
|
var [count, cmd, special, args] = liberator.commands.parseCommand(str.replace(/^'(.*)'$/, "$1"));
|
||||||
var command = vimperator.commands.get(cmd);
|
var command = liberator.commands.get(cmd);
|
||||||
|
|
||||||
if (command === null)
|
if (command === null)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E492: Not an editor command: " + str);
|
liberator.echoerr("E492: Not an editor command: " + str);
|
||||||
vimperator.focusContent();
|
liberator.focusContent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: need to perform this test? -- djk
|
// TODO: need to perform this test? -- djk
|
||||||
if (command.action === null)
|
if (command.action === null)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E666: Internal error: command.action === null");
|
liberator.echoerr("E666: Internal error: command.action === null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,7 +494,7 @@ const vimperator = (function () //{{{
|
|||||||
command.execute(args, special, count, modifiers);
|
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
|
// after pressing Escape, put focus on a non-input field of the browser document
|
||||||
// if clearFocusedElement, also blur a focused link
|
// if clearFocusedElement, also blur a focused link
|
||||||
focusContent: function (clearFocusedElement)
|
focusContent: function (clearFocusedElement)
|
||||||
@@ -505,7 +505,7 @@ const vimperator = (function () //{{{
|
|||||||
if (window == ww.activeWindow && document.commandDispatcher.focusedElement && clearFocusedElement)
|
if (window == ww.activeWindow && document.commandDispatcher.focusedElement && clearFocusedElement)
|
||||||
document.commandDispatcher.focusedElement.blur();
|
document.commandDispatcher.focusedElement.blur();
|
||||||
|
|
||||||
var elem = vimperator.config.mainWidget || content;
|
var elem = liberator.config.mainWidget || content;
|
||||||
if (elem != document.commandDispatcher.focusedElement)
|
if (elem != document.commandDispatcher.focusedElement)
|
||||||
elem.focus();
|
elem.focus();
|
||||||
},
|
},
|
||||||
@@ -586,7 +586,7 @@ const vimperator = (function () //{{{
|
|||||||
// return true, if this VIM-like extension has a certain feature
|
// return true, if this VIM-like extension has a certain feature
|
||||||
has: function (feature)
|
has: function (feature)
|
||||||
{
|
{
|
||||||
var features = vimperator.config.features || [];
|
var features = liberator.config.features || [];
|
||||||
return features.some (function(feat) { return feat == feature; });
|
return features.some (function(feat) { return feat == feature; });
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -594,9 +594,9 @@ const vimperator = (function () //{{{
|
|||||||
{
|
{
|
||||||
function jumpToTag(file, tag)
|
function jumpToTag(file, tag)
|
||||||
{
|
{
|
||||||
vimperator.open("chrome://" + vimperator.config.name.toLowerCase() + "/locale/" + file);
|
liberator.open("chrome://" + liberator.config.name.toLowerCase() + "/locale/" + file);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var elem = vimperator.buffer.getElement('@class="tag" and text()="' + tag + '"');
|
var elem = liberator.buffer.getElement('@class="tag" and text()="' + tag + '"');
|
||||||
if (elem)
|
if (elem)
|
||||||
window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context
|
window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context
|
||||||
else
|
else
|
||||||
@@ -606,11 +606,11 @@ const vimperator = (function () //{{{
|
|||||||
|
|
||||||
if (!topic)
|
if (!topic)
|
||||||
{
|
{
|
||||||
vimperator.open("chrome://" + vimperator.config.name.toLowerCase() + "/locale/intro.html");
|
liberator.open("chrome://" + liberator.config.name.toLowerCase() + "/locale/intro.html");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var [, items] = vimperator.completion.help(topic);
|
var [, items] = liberator.completion.help(topic);
|
||||||
var partialMatch = -1;
|
var partialMatch = -1;
|
||||||
for (var i = 0; i < items.length; i++)
|
for (var i = 0; i < items.length; i++)
|
||||||
{
|
{
|
||||||
@@ -628,16 +628,16 @@ const vimperator = (function () //{{{
|
|||||||
if (partialMatch > -1)
|
if (partialMatch > -1)
|
||||||
jumpToTag(items[partialMatch][1], items[partialMatch][0]);
|
jumpToTag(items[partialMatch][1], items[partialMatch][0]);
|
||||||
else
|
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
|
// logs a message to the javascript error console
|
||||||
// if msg is an object, it is beautified
|
// if msg is an object, it is beautified
|
||||||
log: function (msg, level)
|
log: function (msg, level)
|
||||||
{
|
{
|
||||||
//if (vimperator.options.getPref("verbose") >= level) // FIXME: hangs vimperator, probably timing issue --mst
|
//if (liberator.options.getPref("verbose") >= level) // FIXME: hangs liberator, probably timing issue --mst
|
||||||
if (typeof msg == "object")
|
if (typeof msg == "object")
|
||||||
msg = vimperator.util.objectToString(msg, false);
|
msg = liberator.util.objectToString(msg, false);
|
||||||
|
|
||||||
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].
|
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].
|
||||||
getService(Components.interfaces.nsIConsoleService);
|
getService(Components.interfaces.nsIConsoleService);
|
||||||
@@ -657,15 +657,15 @@ const vimperator = (function () //{{{
|
|||||||
open: function (urls, where)
|
open: function (urls, where)
|
||||||
{
|
{
|
||||||
// convert the string to an array of converted URLs
|
// 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")
|
if (typeof urls == "string")
|
||||||
urls = vimperator.util.stringToURLArray(urls);
|
urls = liberator.util.stringToURLArray(urls);
|
||||||
|
|
||||||
if (urls.length == 0)
|
if (urls.length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!where || !vimperator.has("tabs"))
|
if (!where || !liberator.has("tabs"))
|
||||||
where = vimperator.CURRENT_TAB;
|
where = liberator.CURRENT_TAB;
|
||||||
|
|
||||||
var url = typeof urls[0] == "string" ? urls[0] : urls[0][0];
|
var url = typeof urls[0] == "string" ? urls[0] : urls[0][0];
|
||||||
var postdata = typeof urls[0] == "string" ? null : urls[0][1];
|
var postdata = typeof urls[0] == "string" ? null : urls[0][1];
|
||||||
@@ -674,20 +674,20 @@ const vimperator = (function () //{{{
|
|||||||
// decide where to load the first url
|
// decide where to load the first url
|
||||||
switch (where)
|
switch (where)
|
||||||
{
|
{
|
||||||
case vimperator.CURRENT_TAB:
|
case liberator.CURRENT_TAB:
|
||||||
getBrowser().loadURIWithFlags(url, null, null, null, postdata);
|
getBrowser().loadURIWithFlags(url, null, null, null, postdata);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vimperator.NEW_TAB:
|
case liberator.NEW_TAB:
|
||||||
var firsttab = getBrowser().addTab(url, null, null, postdata);
|
var firsttab = getBrowser().addTab(url, null, null, postdata);
|
||||||
getBrowser().selectedTab = firsttab;
|
getBrowser().selectedTab = firsttab;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vimperator.NEW_BACKGROUND_TAB:
|
case liberator.NEW_BACKGROUND_TAB:
|
||||||
getBrowser().addTab(url, null, null, postdata);
|
getBrowser().addTab(url, null, null, postdata);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vimperator.NEW_WINDOW:
|
case liberator.NEW_WINDOW:
|
||||||
window.open();
|
window.open();
|
||||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||||
.getService(Components.interfaces.nsIWindowMediator);
|
.getService(Components.interfaces.nsIWindowMediator);
|
||||||
@@ -696,12 +696,12 @@ const vimperator = (function () //{{{
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
vimperator.echoerr("Exxx: Invalid 'where' directive in vimperator.open(...)");
|
liberator.echoerr("Exxx: Invalid 'where' directive in liberator.open(...)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// only load more than one url if we have tab support
|
// only load more than one url if we have tab support
|
||||||
if (!vimperator.has("tabs"))
|
if (!liberator.has("tabs"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// all other URLs are always loaded in background
|
// all other URLs are always loaded in background
|
||||||
@@ -715,22 +715,22 @@ const vimperator = (function () //{{{
|
|||||||
return true;
|
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)
|
quit: function (saveSession)
|
||||||
{
|
{
|
||||||
vimperator.autocommands.trigger("BrowserExit", "");
|
liberator.autocommands.trigger("BrowserExit", "");
|
||||||
|
|
||||||
if (saveSession)
|
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
|
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();
|
goQuitApplication();
|
||||||
},
|
},
|
||||||
|
|
||||||
restart: function ()
|
restart: function ()
|
||||||
{
|
{
|
||||||
vimperator.autocommands.trigger("BrowserRestart", "");
|
liberator.autocommands.trigger("BrowserRestart", "");
|
||||||
|
|
||||||
const nsIAppStartup = Components.interfaces.nsIAppStartup;
|
const nsIAppStartup = Components.interfaces.nsIAppStartup;
|
||||||
|
|
||||||
@@ -765,70 +765,70 @@ const vimperator = (function () //{{{
|
|||||||
// this function is called, when the chrome is ready
|
// this function is called, when the chrome is ready
|
||||||
startup: function ()
|
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
|
// commands must always be the first module to be initialized
|
||||||
log("commands"); vimperator.commands = vimperator.Commands(); addCommands();
|
log("commands"); liberator.commands = liberator.Commands(); addCommands();
|
||||||
log("options"); vimperator.options = vimperator.Options(); addOptions();
|
log("options"); liberator.options = liberator.Options(); addOptions();
|
||||||
log("mappings"); vimperator.mappings = vimperator.Mappings(); addMappings();
|
log("mappings"); liberator.mappings = liberator.Mappings(); addMappings();
|
||||||
log("events"); vimperator.events = vimperator.Events();
|
log("events"); liberator.events = liberator.Events();
|
||||||
log("commandline"); vimperator.commandline = vimperator.CommandLine();
|
log("commandline"); liberator.commandline = liberator.CommandLine();
|
||||||
log("search"); vimperator.search = vimperator.Search();
|
log("search"); liberator.search = liberator.Search();
|
||||||
log("preview window"); vimperator.previewwindow = vimperator.InformationList("vimperator-previewwindow", { incrementalFill: false, maxItems: 10 });
|
log("preview window"); liberator.previewwindow = liberator.InformationList("liberator-previewwindow", { incrementalFill: false, maxItems: 10 });
|
||||||
log("buffer window"); vimperator.bufferwindow = vimperator.InformationList("vimperator-bufferwindow", { incrementalFill: false, maxItems: 10 });
|
log("buffer window"); liberator.bufferwindow = liberator.InformationList("liberator-bufferwindow", { incrementalFill: false, maxItems: 10 });
|
||||||
log("statusline"); vimperator.statusline = vimperator.StatusLine();
|
log("statusline"); liberator.statusline = liberator.StatusLine();
|
||||||
log("buffer"); vimperator.buffer = vimperator.Buffer();
|
log("buffer"); liberator.buffer = liberator.Buffer();
|
||||||
log("editor"); vimperator.editor = vimperator.Editor();
|
log("editor"); liberator.editor = liberator.Editor();
|
||||||
log("autocommands"); vimperator.autocommands = vimperator.AutoCommands();
|
log("autocommands"); liberator.autocommands = liberator.AutoCommands();
|
||||||
log("io"); vimperator.io = vimperator.IO();
|
log("io"); liberator.io = liberator.IO();
|
||||||
log("completion"); vimperator.completion = vimperator.Completion();
|
log("completion"); liberator.completion = liberator.Completion();
|
||||||
|
|
||||||
// optional modules
|
// optional modules
|
||||||
if (vimperator.has("bookmarks")) { log("bookmarks"); vimperator.bookmarks = vimperator.Bookmarks(); }
|
if (liberator.has("bookmarks")) { log("bookmarks"); liberator.bookmarks = liberator.Bookmarks(); }
|
||||||
if (vimperator.has("history")) { log("history"); vimperator.history = vimperator.History(); }
|
if (liberator.has("history")) { log("history"); liberator.history = liberator.History(); }
|
||||||
if (vimperator.has("mail")) { log("mail"); vimperator.mail = vimperator.Mail(); }
|
if (liberator.has("mail")) { log("mail"); liberator.mail = liberator.Mail(); }
|
||||||
if (vimperator.has("tabs")) { log("tabs"); vimperator.tabs = vimperator.Tabs(); }
|
if (liberator.has("tabs")) { log("tabs"); liberator.tabs = liberator.Tabs(); }
|
||||||
if (vimperator.has("marks")) { log("marks"); vimperator.marks = vimperator.Marks(); }
|
if (liberator.has("marks")) { log("marks"); liberator.marks = liberator.Marks(); }
|
||||||
if (vimperator.has("quickmarks")) { log("quickmarks"); vimperator.quickmarks = vimperator.QuickMarks(); }
|
if (liberator.has("quickmarks")) { log("quickmarks"); liberator.quickmarks = liberator.QuickMarks(); }
|
||||||
if (vimperator.has("hints")) { log("hints"); vimperator.hints = vimperator.Hints(); }
|
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
|
// This adds options/mappings/commands which are only valid in this particular extension
|
||||||
if (vimperator.config.init)
|
if (liberator.config.init)
|
||||||
{
|
{
|
||||||
vimperator.config.init();
|
liberator.config.init();
|
||||||
// vimperator.log("Loaded additional mappings, etc. for " + vimperator.config.name, 3);
|
// liberator.log("Loaded additional mappings, etc. for " + liberator.config.name, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we define some shortcuts to functions which are used often
|
// we define some shortcuts to functions which are used often
|
||||||
vimperator.echo = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); };
|
liberator.echo = function (str, flags) { liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, flags); };
|
||||||
vimperator.echoerr = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_ERRORMSG, 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
|
// 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.mode = <str> string to show on v.modes.CUSTOM
|
||||||
// v.plugins.stop = <func> hooked on a v.modes.reset()
|
// v.plugins.stop = <func> hooked on a v.modes.reset()
|
||||||
// v.plugins.onEvent = <func> function triggered, on keypresses (unless <esc>) (see events.js)
|
// v.plugins.onEvent = <func> function triggered, on keypresses (unless <esc>) (see events.js)
|
||||||
vimperator.plugins = {};
|
liberator.plugins = {};
|
||||||
|
|
||||||
// TODO: move elsewhere
|
// TODO: move elsewhere
|
||||||
vimperator.registerCallback("submit", vimperator.modes.EX, function (command) { vimperator.execute(command); });
|
liberator.registerCallback("submit", liberator.modes.EX, function (command) { liberator.execute(command); });
|
||||||
vimperator.registerCallback("complete", vimperator.modes.EX, function (str) { return vimperator.completion.exTabCompletion(str); });
|
liberator.registerCallback("complete", liberator.modes.EX, function (str) { return liberator.completion.exTabCompletion(str); });
|
||||||
|
|
||||||
// first time intro message
|
// 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 () {
|
setTimeout(function () {
|
||||||
vimperator.help();
|
liberator.help();
|
||||||
vimperator.options.setPref("extensions." + vimperator.config.name.toLowerCase() + ".firsttime", false);
|
liberator.options.setPref("extensions." + liberator.config.name.toLowerCase() + ".firsttime", false);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// always start in normal mode
|
// always start in normal mode
|
||||||
vimperator.modes.reset();
|
liberator.modes.reset();
|
||||||
|
|
||||||
// TODO: we should have some class where all this guioptions stuff fits well
|
// TODO: we should have some class where all this guioptions stuff fits well
|
||||||
hideGUI();
|
hideGUI();
|
||||||
@@ -837,59 +837,59 @@ const vimperator = (function () //{{{
|
|||||||
// make sourcing asynchronous, otherwise commands that open new tabs won't work
|
// make sourcing asynchronous, otherwise commands that open new tabs won't work
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
||||||
var rcFile = vimperator.io.getRCFile();
|
var rcFile = liberator.io.getRCFile();
|
||||||
if (rcFile)
|
if (rcFile)
|
||||||
vimperator.io.source(rcFile.path, true);
|
liberator.io.source(rcFile.path, true);
|
||||||
else
|
else
|
||||||
vimperator.log("No user RC file found", 3);
|
liberator.log("No user RC file found", 3);
|
||||||
|
|
||||||
// also source plugins in ~/.vimperator/plugin/
|
// also source plugins in ~/.vimperator/plugin/
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pluginDir = vimperator.io.getSpecialDirectory("plugin");
|
var pluginDir = liberator.io.getSpecialDirectory("plugin");
|
||||||
if (pluginDir)
|
if (pluginDir)
|
||||||
{
|
{
|
||||||
var files = vimperator.io.readDirectory(pluginDir.path);
|
var files = liberator.io.readDirectory(pluginDir.path);
|
||||||
vimperator.log("Sourcing plugin directory...", 3);
|
liberator.log("Sourcing plugin directory...", 3);
|
||||||
files.forEach(function (file) {
|
files.forEach(function (file) {
|
||||||
if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path))
|
if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path))
|
||||||
vimperator.io.source(file.path, false);
|
liberator.io.source(file.path, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vimperator.log("No user plugin directory found", 3);
|
liberator.log("No user plugin directory found", 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
// thrown if directory does not exist
|
// 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
|
// after sourcing the initialization files, this function will set
|
||||||
// all gui options to their default values, if they have not been
|
// all gui options to their default values, if they have not been
|
||||||
// set before by any rc file
|
// set before by any rc file
|
||||||
for (let option in vimperator.options)
|
for (let option in liberator.options)
|
||||||
{
|
{
|
||||||
if (option.setter && !option.hasChanged)
|
if (option.setter && !option.hasChanged)
|
||||||
option.reset();
|
option.reset();
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
vimperator.statusline.update();
|
liberator.statusline.update();
|
||||||
vimperator.log("Vimperator fully initialized", 1);
|
liberator.log("Vimperator fully initialized", 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
shutdown: function ()
|
shutdown: function ()
|
||||||
{
|
{
|
||||||
// save our preferences
|
// save our preferences
|
||||||
vimperator.commandline.destroy();
|
liberator.commandline.destroy();
|
||||||
vimperator.quickmarks.destroy();
|
liberator.quickmarks.destroy();
|
||||||
vimperator.options.destroy();
|
liberator.options.destroy();
|
||||||
vimperator.events.destroy();
|
liberator.events.destroy();
|
||||||
|
|
||||||
window.dump("All vimperator modules destroyed\n");
|
window.dump("All liberator modules destroyed\n");
|
||||||
},
|
},
|
||||||
|
|
||||||
sleep: function (ms)
|
sleep: function (ms)
|
||||||
@@ -949,7 +949,7 @@ const vimperator = (function () //{{{
|
|||||||
})(); //}}}
|
})(); //}}}
|
||||||
|
|
||||||
// called when the chrome is fully loaded and before the main window is shown
|
// called when the chrome is fully loaded and before the main window is shown
|
||||||
window.addEventListener("load", vimperator.startup, false);
|
window.addEventListener("load", liberator.startup, false);
|
||||||
window.addEventListener("unload", vimperator.shutdown, false);
|
window.addEventListener("unload", liberator.shutdown, false);
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// 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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.config = {
|
liberator.config = {
|
||||||
/*** required options, no checks done if they really exist, so be careful ***/
|
/*** required options, no checks done if they really exist, so be careful ***/
|
||||||
name: "Vimperator",
|
name: "Vimperator",
|
||||||
hostApplication: "Firefox",
|
hostApplication: "Firefox",
|
||||||
@@ -83,20 +83,20 @@ vimperator.config = {
|
|||||||
["searchengines", "Manage installed search engines",
|
["searchengines", "Manage installed search engines",
|
||||||
function() { openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
function() { openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
||||||
["selectionsource", "View selection source",
|
["selectionsource", "View selection source",
|
||||||
function() { vimperator.buffer.viewSelectionSource(); }]
|
function() { liberator.buffer.viewSelectionSource(); }]
|
||||||
],
|
],
|
||||||
|
|
||||||
init: function()
|
init: function()
|
||||||
{
|
{
|
||||||
function incrementURL(count)
|
function incrementURL(count)
|
||||||
{
|
{
|
||||||
var url = vimperator.buffer.URL;
|
var url = liberator.buffer.URL;
|
||||||
var regex = /(.*?)(-?\d+)(\D*)$/;
|
var regex = /(.*?)(-?\d+)(\D*)$/;
|
||||||
|
|
||||||
var matches = url.match(regex);
|
var matches = url.match(regex);
|
||||||
if (!matches || !matches[2]) // no number to increment
|
if (!matches || !matches[2]) // no number to increment
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,62 +108,62 @@ vimperator.config = {
|
|||||||
newNum += "0"; // keep leading zeros
|
newNum += "0"; // keep leading zeros
|
||||||
newNum += nums[2];
|
newNum += nums[2];
|
||||||
|
|
||||||
vimperator.open(matches[1] + newNum + matches[3]);
|
liberator.open(matches[1] + newNum + matches[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.NORMAL],
|
liberator.mappings.add([liberator.modes.NORMAL],
|
||||||
["y"], "Yank current location to the clipboard",
|
["y"], "Yank current location to the clipboard",
|
||||||
function () { vimperator.copyToClipboard(vimperator.buffer.URL, true); });
|
function () { liberator.copyToClipboard(liberator.buffer.URL, true); });
|
||||||
|
|
||||||
// opening websites
|
// opening websites
|
||||||
vimperator.mappings.add([vimperator.modes.NORMAL],
|
liberator.mappings.add([liberator.modes.NORMAL],
|
||||||
["o"], "Open one or more URLs",
|
["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",
|
"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",
|
"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",
|
"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",
|
["<C-a>"], "Increment last number in URL",
|
||||||
function (count) { incrementURL(count > 1 ? count : 1); },
|
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",
|
["<C-x>"], "Decrement last number in URL",
|
||||||
function (count) { incrementURL(-(count > 1 ? count : 1)); },
|
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",
|
"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",
|
"Open homepage",
|
||||||
function() { BrowserHome(); });
|
function() { BrowserHome(); });
|
||||||
|
|
||||||
vimperator.mappings.add([vimperator.modes.NORMAL], ["gH"],
|
liberator.mappings.add([liberator.modes.NORMAL], ["gH"],
|
||||||
"Open homepage in a new tab",
|
"Open homepage in a new tab",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
var homepages = gHomeButton.getHomePage();
|
var homepages = gHomeButton.getHomePage();
|
||||||
vimperator.open(homepages, /\bhomepage\b/.test(vimperator.options["activate"]) ?
|
liberator.open(homepages, /\bhomepage\b/.test(liberator.options["activate"]) ?
|
||||||
vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB);
|
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",
|
"Go to parent directory",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
@@ -172,7 +172,7 @@ vimperator.config = {
|
|||||||
if (/^file:\/|^\//.test(url))
|
if (/^file:\/|^\//.test(url))
|
||||||
{
|
{
|
||||||
//var strippedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2");
|
//var strippedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2");
|
||||||
var file = vimperator.io.getFile(url);
|
var file = liberator.io.getFile(url);
|
||||||
if (!file.exists() || !file.isDirectory())
|
if (!file.exists() || !file.isDirectory())
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
@@ -186,7 +186,7 @@ vimperator.config = {
|
|||||||
if (count < 1)
|
if (count < 1)
|
||||||
count = 1;
|
count = 1;
|
||||||
|
|
||||||
var url = vimperator.buffer.URL;
|
var url = liberator.buffer.URL;
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (isDirectory(url))
|
if (isDirectory(url))
|
||||||
@@ -196,47 +196,47 @@ vimperator.config = {
|
|||||||
}
|
}
|
||||||
url = url.replace(/^(.*:\/+.*?)\/+$/, "$1/"); // get rid of more than 1 / at the end
|
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;
|
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",
|
"Go to the root of the website",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
var uri = content.document.location;
|
var uri = content.document.location;
|
||||||
if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now
|
if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
liberator.beep();
|
||||||
return;
|
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",
|
"Redraw the screen",
|
||||||
function () { vimperator.commands.redraw(); });
|
function () { liberator.commands.redraw(); });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
vimperator.commands.add(["downl[oads]", "dl"],
|
liberator.commands.add(["downl[oads]", "dl"],
|
||||||
"Show progress of current downloads",
|
"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",
|
"Open one or more URLs in the current tab",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
vimperator.open(args);
|
liberator.open(args);
|
||||||
}
|
}
|
||||||
else
|
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",
|
"Redraw the screen",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
@@ -260,13 +260,13 @@ vimperator.config = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO: move sidebar commands to ui.js?
|
// TODO: move sidebar commands to ui.js?
|
||||||
vimperator.commands.add(["sbcl[ose]"],
|
liberator.commands.add(["sbcl[ose]"],
|
||||||
"Close the sidebar window",
|
"Close the sidebar window",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E488: Trailing characters");
|
liberator.echoerr("E488: Trailing characters");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,13 +274,13 @@ vimperator.config = {
|
|||||||
toggleSidebar();
|
toggleSidebar();
|
||||||
});
|
});
|
||||||
|
|
||||||
vimperator.commands.add(["sideb[ar]", "sb[ar]", "sbope[n]"],
|
liberator.commands.add(["sideb[ar]", "sb[ar]", "sbope[n]"],
|
||||||
"Open the sidebar window",
|
"Open the sidebar window",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E471: Argument required");
|
liberator.echoerr("E471: Argument required");
|
||||||
return;
|
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",
|
"Close window",
|
||||||
function (args) { window.close(); });
|
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",
|
"Open one or more URLs in a new window",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
vimperator.open(args, vimperator.NEW_WINDOW);
|
liberator.open(args, liberator.NEW_WINDOW);
|
||||||
else
|
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">
|
<window id="main-window">
|
||||||
|
|
||||||
<keyset id="mainKeyset">
|
<keyset id="mainKeyset">
|
||||||
<key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':', '', vimperator.modes.EX);" modifiers=""/>
|
<key id="key_open_vimbar" key=":" oncommand="liberator.commandline.open(':', '', liberator.modes.EX);" modifiers=""/>
|
||||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="vimperator.events.onEscape();"/>
|
<key id="key_stop" keycode="VK_ESCAPE" oncommand="liberator.events.onEscape();"/>
|
||||||
<!-- other keys are handled inside vimperator.js event loop -->
|
<!-- other keys are handled inside the event loop in events.js -->
|
||||||
</keyset>
|
</keyset>
|
||||||
|
|
||||||
<panel id="vimperator-visualbell"/>
|
<panel id="liberator-visualbell"/>
|
||||||
|
|
||||||
<!--this notifies us also of focus events in the XUL
|
<!--this notifies us also of focus events in the XUL
|
||||||
from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !-->
|
from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !-->
|
||||||
<commandset id="onVimperatorFocus"
|
<commandset id="onVimperatorFocus"
|
||||||
commandupdater="true"
|
commandupdater="true"
|
||||||
events="focus"
|
events="focus"
|
||||||
oncommandupdate="vimperator.events.onFocusChange(event);"/>
|
oncommandupdate="liberator.events.onFocusChange(event);"/>
|
||||||
<commandset id="onVimperatorSelect"
|
<commandset id="onVimperatorSelect"
|
||||||
commandupdater="true"
|
commandupdater="true"
|
||||||
events="select"
|
events="select"
|
||||||
oncommandupdate="vimperator.events.onSelectionChange(event);"/>
|
oncommandupdate="liberator.events.onSelectionChange(event);"/>
|
||||||
|
|
||||||
<vbox id="vimperator-container" hidden="false">
|
<vbox id="liberator-container" hidden="false">
|
||||||
<listbox id="vimperator-bufferwindow" class="plain" rows="10" flex="1" hidden="true"
|
<listbox id="liberator-bufferwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||||
onclick= "vimperator.bufferwindow.onEvent(event);"
|
onclick= "liberator.bufferwindow.onEvent(event);"
|
||||||
ondblclick="vimperator.bufferwindow.onEvent(event);"
|
ondblclick="liberator.bufferwindow.onEvent(event);"
|
||||||
onkeydown= "vimperator.bufferwindow.onEvent(event);">
|
onkeydown= "liberator.bufferwindow.onEvent(event);">
|
||||||
<listcols>
|
<listcols>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
</listcols>
|
</listcols>
|
||||||
</listbox>
|
</listbox>
|
||||||
|
|
||||||
<listbox id="vimperator-previewwindow" class="plain" rows="10" flex="1" hidden="true"
|
<listbox id="liberator-previewwindow" class="plain" rows="10" flex="1" hidden="true"
|
||||||
onclick= "vimperator.previewwindow.onEvent(event);"
|
onclick= "liberator.previewwindow.onEvent(event);"
|
||||||
ondblclick="vimperator.previewwindow.onEvent(event);"
|
ondblclick="liberator.previewwindow.onEvent(event);"
|
||||||
onkeydown= "vimperator.previewwindow.onEvent(event);">
|
onkeydown= "liberator.previewwindow.onEvent(event);">
|
||||||
<listcols>
|
<listcols>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
</listcols>
|
</listcols>
|
||||||
</listbox>
|
</listbox>
|
||||||
|
|
||||||
<iframe id="vimperator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
<iframe id="liberator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
||||||
onclick="vimperator.commandline.onMultilineOutputEvent(event)"/>
|
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>
|
<listcols>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
<listcol flex="1" width="50%"/>
|
<listcol flex="1" width="50%"/>
|
||||||
</listcols>
|
</listcols>
|
||||||
</listbox>
|
</listbox>
|
||||||
|
|
||||||
<hbox id="vimperator-commandline" hidden="false" class="hl-Normal">
|
<hbox id="liberator-commandline" hidden="false" class="hl-Normal">
|
||||||
<label class="plain" id="vimperator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
<label class="plain" id="liberator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||||
<textbox class="plain" id="vimperator-commandline-command" flex="1" type="timed" timeout="100"
|
<textbox class="plain" id="liberator-commandline-command" flex="1" type="timed" timeout="100"
|
||||||
oninput="vimperator.commandline.onEvent(event);"
|
oninput="liberator.commandline.onEvent(event);"
|
||||||
onfocus="vimperator.commandline.onEvent(event);"
|
onfocus="liberator.commandline.onEvent(event);"
|
||||||
onblur="vimperator.commandline.onEvent(event);"/>
|
onblur="liberator.commandline.onEvent(event);"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<textbox id="vimperator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
<textbox id="liberator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
|
||||||
onkeypress="vimperator.commandline.onMultilineInputEvent(event);"
|
onkeypress="liberator.commandline.onMultilineInputEvent(event);"
|
||||||
oninput="vimperator.commandline.onMultilineInputEvent(event);"
|
oninput="liberator.commandline.onMultilineInputEvent(event);"
|
||||||
onblur="vimperator.commandline.onMultilineInputEvent(event);"/>
|
onblur="liberator.commandline.onMultilineInputEvent(event);"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
</window>
|
</window>
|
||||||
|
|
||||||
<statusbar id="status-bar" class="hl-StatusLine">
|
<statusbar id="status-bar" class="hl-StatusLine">
|
||||||
<hbox insertbefore="statusbar-display" id="vimperator-statusline" flex="1" height="10" hidden="false" align="center">
|
<hbox insertbefore="statusbar-display" id="liberator-statusline" flex="1" height="10" hidden="false" align="center">
|
||||||
<textbox class="plain" id="vimperator-statusline-field-url" readonly="false" flex="1" crop="end"/>
|
<textbox class="plain" id="liberator-statusline-field-url" readonly="false" flex="1" crop="end"/>
|
||||||
<label class="plain" id="vimperator-statusline-field-inputbuffer" flex="0"/>
|
<label class="plain" id="liberator-statusline-field-inputbuffer" flex="0"/>
|
||||||
<label class="plain" id="vimperator-statusline-field-progress" flex="0"/>
|
<label class="plain" id="liberator-statusline-field-progress" flex="0"/>
|
||||||
<label class="plain" id="vimperator-statusline-field-tabcount" flex="0"/>
|
<label class="plain" id="liberator-statusline-field-tabcount" flex="0"/>
|
||||||
<label class="plain" id="vimperator-statusline-field-bufferposition" flex="0"/>
|
<label class="plain" id="liberator-statusline-field-bufferposition" flex="0"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
<!-- just hide them since other elements expect them -->
|
<!-- just hide them since other elements expect them -->
|
||||||
<statusbarpanel id="statusbar-display" hidden="true"/>
|
<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.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
#vimperator-container {
|
#liberator-container {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vimperator-bufferwindow, #vimperator-completion, #vimperator-previewwindow {
|
#liberator-bufferwindow, #liberator-completion, #liberator-previewwindow {
|
||||||
-moz-user-focus: ignore;
|
-moz-user-focus: ignore;
|
||||||
overflow: -moz-scrollbars-none !important; /* does not seem to work fully */
|
overflow: -moz-scrollbars-none !important; /* does not seem to work fully */
|
||||||
border-width: 0px !important;
|
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 */
|
/* the selected item in listboxes is hardly readable without this */
|
||||||
#vimperator-completion > listitem[selected="true"] > listcell,
|
#liberator-completion > listitem[selected="true"] > listcell,
|
||||||
#vimperator-bufferwindow > listitem[selected="true"] > listcell,
|
#liberator-bufferwindow > listitem[selected="true"] > listcell,
|
||||||
#vimperator-previewwindow > listitem[selected="true"] > listcell {
|
#liberator-previewwindow > listitem[selected="true"] > listcell {
|
||||||
background-color: Highlight !important;
|
background-color: Highlight !important;
|
||||||
color: HighlightText !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-weight: bold;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
#vimperator-statusline {
|
#liberator-statusline {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
#vimperator-statusline > label {
|
#liberator-statusline > label {
|
||||||
padding: 0px 0px 0px 8px;
|
padding: 0px 0px 0px 8px;
|
||||||
}
|
}
|
||||||
#vimperator-statusline > label:first-child {
|
#liberator-statusline > label:first-child {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
#vimperator-statusline-field-url {
|
#liberator-statusline-field-url {
|
||||||
background-color: inherit;
|
background-color: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
@@ -76,19 +76,19 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vimperator-commandline {
|
#liberator-commandline {
|
||||||
padding: 1px;
|
padding: 1px;
|
||||||
/*
|
/*
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: black;
|
color: black;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
#vimperator-commandline-prompt, #vimperator-commandline-command {
|
#liberator-commandline-prompt, #liberator-commandline-command {
|
||||||
background-color: inherit;
|
background-color: inherit;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vimperator-visualbell {
|
#liberator-visualbell {
|
||||||
border: none;
|
border: none;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
}
|
}
|
||||||
@@ -158,29 +158,29 @@ a.hl-URL:hover {
|
|||||||
|
|
||||||
/* MOW */
|
/* MOW */
|
||||||
|
|
||||||
#vimperator-multiline-output {
|
#liberator-multiline-output {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vimperator-multiline-output-content {
|
#liberator-multiline-output-content {
|
||||||
white-space: pre; /* -moz-pre-wrap FIXME: Should lines wrap like Vim? */
|
white-space: pre; /* -moz-pre-wrap FIXME: Should lines wrap like Vim? */
|
||||||
font-family: -moz-fixed;
|
font-family: -moz-fixed;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vimperator-multiline-output-content * {
|
#liberator-multiline-output-content * {
|
||||||
font: inherit;
|
font: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vimperator-multiline-output-content table {
|
#liberator-multiline-output-content table {
|
||||||
white-space: inherit;
|
white-space: inherit;
|
||||||
border-spacing: 0px;
|
border-spacing: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#vimperator-multiline-output-content td,
|
#liberator-multiline-output-content td,
|
||||||
#vimperator-multiline-output-content th {
|
#liberator-multiline-output-content th {
|
||||||
padding: 0px 2px;
|
padding: 0px 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user