mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 09:08:37 +01:00
Speed up completions. Fix Structcommands.jsdefaultValue in FF 3.0. Temporarilly name anonymous functions for profiling.
This commit is contained in:
@@ -853,8 +853,9 @@ function Commands() //{{{
|
|||||||
bang: true,
|
bang: true,
|
||||||
// Yeah, this is a bit scary. Perhaps I'll fix it when I'm
|
// Yeah, this is a bit scary. Perhaps I'll fix it when I'm
|
||||||
// awake.
|
// awake.
|
||||||
options: util.Array.assocToObj(util.map({argCount: "-nargs", bang: "-bang", count: "-count"},
|
options: util.Array.assocToObj(
|
||||||
function ([k, v]) k in cmd && cmd[k] != "0" && [v, typeof cmd[k] == "boolean" ? null : cmd[k]])
|
util.map({argCount: "-nargs", bang: "-bang", count: "-count"},
|
||||||
|
function ([k, v]) k in cmd && cmd[k] != "0" && [v, typeof cmd[k] == "boolean" ? null : cmd[k]])
|
||||||
.filter(function (k) k)),
|
.filter(function (k) k)),
|
||||||
arguments: [cmd.name],
|
arguments: [cmd.name],
|
||||||
literalArg: cmd.replacementText
|
literalArg: cmd.replacementText
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
// An eval with a cleaner lexical scope.
|
// An eval with a cleaner lexical scope.
|
||||||
modules._cleanEval = function (__liberator_eval_arg, __liberator_eval_tmp)
|
modules._cleanEval = function _cleanEval(__liberator_eval_arg, __liberator_eval_tmp)
|
||||||
{
|
{
|
||||||
return window.eval(__liberator_eval_arg);
|
return window.eval(__liberator_eval_arg);
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,7 @@ function CompletionContext(editor, name, offset)
|
|||||||
this.offset = parent.offset + (offset || 0);
|
this.offset = parent.offset + (offset || 0);
|
||||||
this.__defineGetter__("tabPressed", function () this.parent.tabPressed);
|
this.__defineGetter__("tabPressed", function () this.parent.tabPressed);
|
||||||
this.__defineGetter__("onUpdate", function () this.parent.onUpdate);
|
this.__defineGetter__("onUpdate", function () this.parent.onUpdate);
|
||||||
|
this.__defineGetter__("updateAsync", function () this.parent.updateAsync);
|
||||||
this.__defineGetter__("value", function () this.parent.value);
|
this.__defineGetter__("value", function () this.parent.value);
|
||||||
this.__defineGetter__("selectionTypes", function () this.parent.selectionTypes);
|
this.__defineGetter__("selectionTypes", function () this.parent.selectionTypes);
|
||||||
this.incomplete = false;
|
this.incomplete = false;
|
||||||
@@ -114,18 +115,19 @@ CompletionContext.prototype = {
|
|||||||
{
|
{
|
||||||
this.hasItems = items.length > 0;
|
this.hasItems = items.length > 0;
|
||||||
this._items = items;
|
this._items = items;
|
||||||
this.onUpdate.call(this);
|
if (this.updateAsync)
|
||||||
|
this.onUpdate.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
get title() this._title || ["Completions"], // XXX
|
get title() this._title || ["Completions"], // XXX
|
||||||
set title(val) this._title = val,
|
set title(val) this._title = val,
|
||||||
|
|
||||||
advance: function (count)
|
advance: function advance(count)
|
||||||
{
|
{
|
||||||
this.offset += count;
|
this.offset += count;
|
||||||
},
|
},
|
||||||
|
|
||||||
fork: function (name, offset, completer, self)
|
fork: function fork(name, offset, completer, self)
|
||||||
{
|
{
|
||||||
let context = new CompletionContext(this, name, offset);
|
let context = new CompletionContext(this, name, offset);
|
||||||
if (completer)
|
if (completer)
|
||||||
@@ -133,7 +135,7 @@ CompletionContext.prototype = {
|
|||||||
return context;
|
return context;
|
||||||
},
|
},
|
||||||
|
|
||||||
highlight: function (start, length, type)
|
highlight: function highlight(start, length, type)
|
||||||
{
|
{
|
||||||
try // Firefox <3.1 doesn't have repaintSelection
|
try // Firefox <3.1 doesn't have repaintSelection
|
||||||
{
|
{
|
||||||
@@ -157,7 +159,7 @@ CompletionContext.prototype = {
|
|||||||
catch (e) {}
|
catch (e) {}
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function ()
|
reset: function reset()
|
||||||
{
|
{
|
||||||
let self = this;
|
let self = this;
|
||||||
if (this.parent)
|
if (this.parent)
|
||||||
@@ -165,6 +167,7 @@ CompletionContext.prototype = {
|
|||||||
// Not ideal.
|
// Not ideal.
|
||||||
for (let type in this.selectionTypes)
|
for (let type in this.selectionTypes)
|
||||||
this.highlight(0, 0, type);
|
this.highlight(0, 0, type);
|
||||||
|
this.updateAsync = false;
|
||||||
this.selectionTypes = {};
|
this.selectionTypes = {};
|
||||||
this.tabPressed = false;
|
this.tabPressed = false;
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
@@ -269,7 +272,7 @@ function Completion() //{{{
|
|||||||
if (!(objects instanceof Array))
|
if (!(objects instanceof Array))
|
||||||
objects = [objects];
|
objects = [objects];
|
||||||
|
|
||||||
completion.filterMap = [null, function (v) template.highlight(v, true)];
|
completion.filterMap = [null, function highlight(v) template.highlight(v, true)];
|
||||||
|
|
||||||
let [obj, key] = objects;
|
let [obj, key] = objects;
|
||||||
let cache = this.context.cache.objects || {};
|
let cache = this.context.cache.objects || {};
|
||||||
@@ -485,7 +488,7 @@ function Completion() //{{{
|
|||||||
lastIdx = i;
|
lastIdx = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.complete = function (context)
|
this.complete = function _complete(context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
let string = context.filter;
|
let string = context.filter;
|
||||||
@@ -787,13 +790,13 @@ function Completion() //{{{
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
setFunctionCompleter: function (funcs, completers)
|
setFunctionCompleter: function setFunctionCompleter(funcs, completers)
|
||||||
{
|
{
|
||||||
if (!(funcs instanceof Array))
|
if (!(funcs instanceof Array))
|
||||||
funcs = [funcs];
|
funcs = [funcs];
|
||||||
for (let [,func] in Iterator(funcs))
|
for (let [,func] in Iterator(funcs))
|
||||||
{
|
{
|
||||||
func.liberatorCompleter = function (func, obj, string, args) {
|
func.liberatorCompleter = function liberatorCompleter(func, obj, string, args) {
|
||||||
let completer = completers[args.length - 1];
|
let completer = completers[args.length - 1];
|
||||||
if (!completer)
|
if (!completer)
|
||||||
return [];
|
return [];
|
||||||
@@ -834,7 +837,7 @@ function Completion() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// cancel any ongoing search
|
// cancel any ongoing search
|
||||||
cancel: function()
|
cancel: function cancel()
|
||||||
{
|
{
|
||||||
if (completionService)
|
if (completionService)
|
||||||
completionService.stopSearch();
|
completionService.stopSearch();
|
||||||
@@ -936,7 +939,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
autocmdEvent: function autocmdEvent(filter) [0, this.filter(config.autocommands, filter)],
|
autocmdEvent: function autocmdEvent(filter) [0, this.filter(config.autocommands, filter)],
|
||||||
|
|
||||||
bookmark: function (filter)
|
bookmark: function bookmark(filter)
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
start: 0,
|
start: 0,
|
||||||
@@ -1033,7 +1036,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
dialog: function dialog(filter) [0, this.filter(config.dialogs, filter)],
|
dialog: function dialog(filter) [0, this.filter(config.dialogs, filter)],
|
||||||
|
|
||||||
directory: function (context, tail)
|
directory: function directory(context, tail)
|
||||||
{
|
{
|
||||||
this.file(context, tail);
|
this.file(context, tail);
|
||||||
context.items = context.items.filter(function (i) i[1] == "Directory");
|
context.items = context.items.filter(function (i) i[1] == "Directory");
|
||||||
@@ -1081,25 +1084,26 @@ function Completion() //{{{
|
|||||||
if (command)
|
if (command)
|
||||||
{
|
{
|
||||||
[prefix] = context.filter.match(/^(?:\w*[\s!]|!)\s*/);
|
[prefix] = context.filter.match(/^(?:\w*[\s!]|!)\s*/);
|
||||||
context = context.fork(cmd, prefix.length);
|
let cmdContext = context.fork(cmd, prefix.length);
|
||||||
let argContext = context.fork("args", args.completeStart);
|
let argContext = cmdContext.fork("args", args.completeStart);
|
||||||
args = command.parseArgs(context.filter, argContext);
|
args = command.parseArgs(cmdContext.filter, argContext);
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
// XXX, XXX, XXX
|
// XXX, XXX, XXX
|
||||||
if (!args.completeOpt && command.completer)
|
if (!args.completeOpt && command.completer)
|
||||||
{
|
{
|
||||||
context.advance(args.completeStart);
|
cmdContext.advance(args.completeStart);
|
||||||
compObject = command.completer.call(command, context, args, special, count);
|
compObject = command.completer.call(command, cmdContext, args, special, count);
|
||||||
if (compObject instanceof Array) // for now at least, let completion functions return arrays instead of objects
|
if (compObject instanceof Array) // for now at least, let completion functions return arrays instead of objects
|
||||||
compObject = { start: compObject[0], items: compObject[1] };
|
compObject = { start: compObject[0], items: compObject[1] };
|
||||||
if (compObject != null)
|
if (compObject != null)
|
||||||
{
|
{
|
||||||
context.advance(compObject.start);
|
cmdContext.advance(compObject.start);
|
||||||
context.title = ["Completions"];
|
cmdContext.title = ["Completions"];
|
||||||
context.items = compObject.items;
|
cmdContext.items = compObject.items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cmdContext.updateAsync = true;
|
||||||
}
|
}
|
||||||
//liberator.dump([[v.name, v.offset, v.items.length, v.hasItems] for each (v in context.contexts)]);
|
//liberator.dump([[v.name, v.offset, v.items.length, v.hasItems] for each (v in context.contexts)]);
|
||||||
}
|
}
|
||||||
@@ -1112,7 +1116,7 @@ function Completion() //{{{
|
|||||||
let [dir] = context.filter.match(/^(?:.*[\/\\])?/);
|
let [dir] = context.filter.match(/^(?:.*[\/\\])?/);
|
||||||
// dir == "" is expanded inside readDirectory to the current dir
|
// dir == "" is expanded inside readDirectory to the current dir
|
||||||
|
|
||||||
let generate = function ()
|
let generate = function generate()
|
||||||
{
|
{
|
||||||
let files = [], mapped = [];
|
let files = [], mapped = [];
|
||||||
|
|
||||||
@@ -1173,7 +1177,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
get javascriptCompleter() javascript,
|
get javascriptCompleter() javascript,
|
||||||
|
|
||||||
javascript: function (context)
|
javascript: function _javascript(context)
|
||||||
{
|
{
|
||||||
return javascript.complete(context);
|
return javascript.complete(context);
|
||||||
},
|
},
|
||||||
@@ -1229,7 +1233,7 @@ function Completion() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// XXX: Move to bookmarks.js?
|
// XXX: Move to bookmarks.js?
|
||||||
searchEngineSuggest: function (context, engineAliases)
|
searchEngineSuggest: function searchEngineSuggest(context, engineAliases)
|
||||||
{
|
{
|
||||||
if (!filter)
|
if (!filter)
|
||||||
return [0, []];
|
return [0, []];
|
||||||
@@ -1273,7 +1277,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
shellCommand: function shellCommand(filter)
|
shellCommand: function shellCommand(filter)
|
||||||
{
|
{
|
||||||
let generate = function ()
|
let generate = function generate()
|
||||||
{
|
{
|
||||||
const environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
const environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
||||||
.getService(Components.interfaces.nsIEnvironment);
|
.getService(Components.interfaces.nsIEnvironment);
|
||||||
@@ -1345,10 +1349,10 @@ function Completion() //{{{
|
|||||||
s: this.search,
|
s: this.search,
|
||||||
f: this.file,
|
f: this.file,
|
||||||
S: this.searchEngineSuggest,
|
S: this.searchEngineSuggest,
|
||||||
b: function (context)
|
b: function b(context)
|
||||||
{
|
{
|
||||||
context.title = ["Bookmark", "Title"];
|
context.title = ["Bookmark", "Title"];
|
||||||
context.createRow = function (context, item, class)
|
context.createRow = function createRow(context, item, class)
|
||||||
{
|
{
|
||||||
// FIXME
|
// FIXME
|
||||||
if (class)
|
if (class)
|
||||||
@@ -1357,7 +1361,7 @@ function Completion() //{{{
|
|||||||
}
|
}
|
||||||
context.items = bookmarks.get(context.filter)
|
context.items = bookmarks.get(context.filter)
|
||||||
},
|
},
|
||||||
l: function (context)
|
l: function l(context)
|
||||||
{
|
{
|
||||||
if (!completionService)
|
if (!completionService)
|
||||||
return
|
return
|
||||||
@@ -1392,7 +1396,7 @@ function Completion() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Temporary
|
// FIXME: Temporary
|
||||||
_url: function (filter, complete)
|
_url: function _url(filter, complete)
|
||||||
{
|
{
|
||||||
let context = new CompletionContext(filter);
|
let context = new CompletionContext(filter);
|
||||||
this.url(context, complete);
|
this.url(context, complete);
|
||||||
|
|||||||
@@ -166,8 +166,7 @@ function Editor() //{{{
|
|||||||
"Abbreviate a key sequence" + modeDescription,
|
"Abbreviate a key sequence" + modeDescription,
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let lhs = args.arguments[0];
|
let [lhs, rhs] = args.arguments;
|
||||||
let rhs = args.literalArg;
|
|
||||||
if (rhs)
|
if (rhs)
|
||||||
editor.addAbbreviation(mode, lhs, rhs);
|
editor.addAbbreviation(mode, lhs, rhs);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -72,8 +72,7 @@ function AutoCommands() //{{{
|
|||||||
"Execute commands automatically on events",
|
"Execute commands automatically on events",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
let [event, regex] = args.arguments;
|
let [event, regex, cmd] = args.arguments;
|
||||||
let cmd = args.literalArg;
|
|
||||||
let events = null;
|
let events = null;
|
||||||
if (event)
|
if (event)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -158,8 +158,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ?:\s+ <- don't remember; (...)? optional = rhs
|
// ?:\s+ <- don't remember; (...)? optional = rhs
|
||||||
let [lhs] = args.arguments;
|
let [lhs, rhs] = args.arguments;
|
||||||
let rhs = args.literalArg;
|
|
||||||
|
|
||||||
if (!rhs) // list the mapping
|
if (!rhs) // list the mapping
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -128,7 +128,6 @@ function Highlights(name, store, serial)
|
|||||||
.replace(";!important;", ";", "g"); // Seeming Spidermonkey bug
|
.replace(";!important;", ";", "g"); // Seeming Spidermonkey bug
|
||||||
css = style.selector + " { " + css + " }";
|
css = style.selector + " { " + css + " }";
|
||||||
|
|
||||||
style.filter; // FIXME: needed for FF 3.0 (not 3.1) - track down when I'm awake...
|
|
||||||
let error = styles.addSheet(style.selector, style.filter, css, true, force);
|
let error = styles.addSheet(style.selector, style.filter, css, true, force);
|
||||||
if (!error)
|
if (!error)
|
||||||
style.value = newStyle;
|
style.value = newStyle;
|
||||||
@@ -396,9 +395,8 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
"Add or list user styles",
|
"Add or list user styles",
|
||||||
function (args, special)
|
function (args, special)
|
||||||
{
|
{
|
||||||
let [filter] = args.arguments;
|
let [filter, css] = args.arguments;
|
||||||
let name = args["-name"];
|
let name = args["-name"];
|
||||||
let css = args.literalArg;
|
|
||||||
|
|
||||||
if (!css)
|
if (!css)
|
||||||
{
|
{
|
||||||
@@ -491,8 +489,7 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
height: 1em !important; min-height: 1em !important; max-height: 1em !important;
|
height: 1em !important; min-height: 1em !important; max-height: 1em !important;
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
]]>;
|
]]>;
|
||||||
let key = args.arguments[0];
|
let [key, css] = args.arguments[0];
|
||||||
let css = args.literalArg;
|
|
||||||
if (!css && !(key && special))
|
if (!css && !(key && special))
|
||||||
{
|
{
|
||||||
let str = template.tabular(["Key", "Sample", "CSS"],
|
let str = template.tabular(["Key", "Sample", "CSS"],
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const template = {
|
const template = {
|
||||||
add: function (a, b) a + b,
|
add: function add(a, b) a + b,
|
||||||
join: function (c) function (a, b) a + c + b,
|
join: function join(c) function (a, b) a + c + b,
|
||||||
|
|
||||||
map: function (iter, fn, sep)
|
map: function map(iter, fn, sep)
|
||||||
{
|
{
|
||||||
if (iter.length) /* Kludge? */
|
if (iter.length) /* Kludge? */
|
||||||
iter = util.Array.iterator(iter);
|
iter = util.Array.iterator(iter);
|
||||||
@@ -20,7 +20,7 @@ const template = {
|
|||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
maybeXML: function (xml)
|
maybeXML: function maybeXML(xml)
|
||||||
{
|
{
|
||||||
if (typeof xml == "xml")
|
if (typeof xml == "xml")
|
||||||
return xml;
|
return xml;
|
||||||
@@ -32,7 +32,7 @@ const template = {
|
|||||||
return <>{xml}</>;
|
return <>{xml}</>;
|
||||||
},
|
},
|
||||||
|
|
||||||
completionRow: function (context, item, class)
|
completionRow: function completionRow(context, item, class)
|
||||||
{
|
{
|
||||||
let text = item.text || item[0] || "";
|
let text = item.text || item[0] || "";
|
||||||
let description = item.description || item[1] || "";
|
let description = item.description || item[1] || "";
|
||||||
@@ -66,7 +66,7 @@ const template = {
|
|||||||
|
|
||||||
// if "processStrings" is true, any passed strings will be surrounded by " and
|
// if "processStrings" is true, any passed strings will be surrounded by " and
|
||||||
// any line breaks are displayed as \n
|
// any line breaks are displayed as \n
|
||||||
highlight: function (arg, processStrings)
|
highlight: function highlight(arg, processStrings)
|
||||||
{
|
{
|
||||||
// some objects like window.JSON or getBrowsers()._browsers need the try/catch
|
// some objects like window.JSON or getBrowsers()._browsers need the try/catch
|
||||||
try
|
try
|
||||||
@@ -107,7 +107,7 @@ const template = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightFilter: function (str, filter)
|
highlightFilter: function highlightFilter(str, filter)
|
||||||
{
|
{
|
||||||
if (typeof str == "xml")
|
if (typeof str == "xml")
|
||||||
return str;
|
return str;
|
||||||
@@ -125,7 +125,7 @@ const template = {
|
|||||||
})());
|
})());
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightRegexp: function (str, re)
|
highlightRegexp: function highlightRegexp(str, re)
|
||||||
{
|
{
|
||||||
if (typeof str == "xml")
|
if (typeof str == "xml")
|
||||||
return str;
|
return str;
|
||||||
@@ -137,7 +137,7 @@ const template = {
|
|||||||
})());
|
})());
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightSubstrings: function (str, iter)
|
highlightSubstrings: function highlightSubstrings(str, iter)
|
||||||
{
|
{
|
||||||
if (typeof str == "xml")
|
if (typeof str == "xml")
|
||||||
return str;
|
return str;
|
||||||
@@ -157,7 +157,7 @@ const template = {
|
|||||||
return s + <>{str.substr(start)}</>;
|
return s + <>{str.substr(start)}</>;
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightURL: function (str, force)
|
highlightURL: function highlightURL(str, force)
|
||||||
{
|
{
|
||||||
if (force || /^[a-zA-Z]+:\/\//.test(str))
|
if (force || /^[a-zA-Z]+:\/\//.test(str))
|
||||||
return <a class="hl-URL" href="#">{str}</a>;
|
return <a class="hl-URL" href="#">{str}</a>;
|
||||||
@@ -165,14 +165,14 @@ const template = {
|
|||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
generic: function (xml)
|
generic: function generic(xml)
|
||||||
{
|
{
|
||||||
return <>:{commandline.getCommand()}<br/></> + xml;
|
return <>:{commandline.getCommand()}<br/></> + xml;
|
||||||
},
|
},
|
||||||
|
|
||||||
// every item must have a .xml property which defines how to draw itself
|
// every item must have a .xml property which defines how to draw itself
|
||||||
// @param headers is an array of strings, the text for the header columns
|
// @param headers is an array of strings, the text for the header columns
|
||||||
genericTable: function (headers, items)
|
genericTable: function genericTable(headers, items)
|
||||||
{
|
{
|
||||||
return this.generic(
|
return this.generic(
|
||||||
<table>
|
<table>
|
||||||
@@ -188,7 +188,7 @@ const template = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// returns a single row for a bookmark or history item
|
// returns a single row for a bookmark or history item
|
||||||
bookmarkItem: function (item)
|
bookmarkItem: function bookmarkItem(item)
|
||||||
{
|
{
|
||||||
var extra = [];
|
var extra = [];
|
||||||
if (item.keyword)
|
if (item.keyword)
|
||||||
@@ -215,7 +215,7 @@ const template = {
|
|||||||
</ul>
|
</ul>
|
||||||
},
|
},
|
||||||
|
|
||||||
jumps: function (index, elems)
|
jumps: function jumps(index, elems)
|
||||||
{
|
{
|
||||||
return this.generic(
|
return this.generic(
|
||||||
<table>
|
<table>
|
||||||
@@ -234,7 +234,7 @@ const template = {
|
|||||||
</table>);
|
</table>);
|
||||||
},
|
},
|
||||||
|
|
||||||
options: function (title, opts)
|
options: function options(title, opts)
|
||||||
{
|
{
|
||||||
return this.generic(
|
return this.generic(
|
||||||
<table>
|
<table>
|
||||||
@@ -253,7 +253,7 @@ const template = {
|
|||||||
</table>);
|
</table>);
|
||||||
},
|
},
|
||||||
|
|
||||||
table: function (title, data, indent)
|
table: function table(title, data, indent)
|
||||||
{
|
{
|
||||||
let table =
|
let table =
|
||||||
<table>
|
<table>
|
||||||
@@ -272,7 +272,7 @@ const template = {
|
|||||||
return table;
|
return table;
|
||||||
},
|
},
|
||||||
|
|
||||||
tabular: function (headings, style, iter)
|
tabular: function tabular(headings, style, iter)
|
||||||
{
|
{
|
||||||
/* This might be mind-bogglingly slow. We'll see. */
|
/* This might be mind-bogglingly slow. We'll see. */
|
||||||
return this.generic(
|
return this.generic(
|
||||||
@@ -295,7 +295,7 @@ const template = {
|
|||||||
</table>);
|
</table>);
|
||||||
},
|
},
|
||||||
|
|
||||||
usage: function (iter)
|
usage: function usage(iter)
|
||||||
{
|
{
|
||||||
return this.generic(
|
return this.generic(
|
||||||
<table>
|
<table>
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
get length() this.store.length,
|
get length() this.store.length,
|
||||||
|
|
||||||
get: function (index) this.store.get(index),
|
get: function get(index) this.store.get(index),
|
||||||
|
|
||||||
add: function (str)
|
add: function add(str)
|
||||||
{
|
{
|
||||||
if (!str)
|
if (!str)
|
||||||
return;
|
return;
|
||||||
@@ -81,7 +81,7 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
get length() this._messages.length,
|
get length() this._messages.length,
|
||||||
|
|
||||||
add: function (message)
|
add: function add(message)
|
||||||
{
|
{
|
||||||
if (!message)
|
if (!message)
|
||||||
return;
|
return;
|
||||||
@@ -316,7 +316,7 @@ function CommandLine() //{{{
|
|||||||
"Items which are completed at the :[tab]open prompt",
|
"Items which are completed at the :[tab]open prompt",
|
||||||
"charlist", "sfl",
|
"charlist", "sfl",
|
||||||
{
|
{
|
||||||
completer: function (filter)
|
completer: function completer(filter)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
["s", "Search engines and keyword URLs"],
|
["s", "Search engines and keyword URLs"],
|
||||||
@@ -327,7 +327,7 @@ function CommandLine() //{{{
|
|||||||
["S", "Suggest engines"]
|
["S", "Suggest engines"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: function (value) !/[^sfbhSl]/.test(value)
|
validator: function validator(value) !/[^sfbhSl]/.test(value)
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["history", "hi"],
|
options.add(["history", "hi"],
|
||||||
@@ -352,7 +352,7 @@ function CommandLine() //{{{
|
|||||||
"Engine Alias which has a feature of suggest",
|
"Engine Alias which has a feature of suggest",
|
||||||
"stringlist", "google",
|
"stringlist", "google",
|
||||||
{
|
{
|
||||||
completer: function (value)
|
completer: function completer(value)
|
||||||
{
|
{
|
||||||
let ss = Components.classes["@mozilla.org/browser/search-service;1"]
|
let ss = Components.classes["@mozilla.org/browser/search-service;1"]
|
||||||
.getService(Components.interfaces.nsIBrowserSearchService);
|
.getService(Components.interfaces.nsIBrowserSearchService);
|
||||||
@@ -361,7 +361,7 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
return engines.map(function (engine) [engine.alias, engine.description]);
|
return engines.map(function (engine) [engine.alias, engine.description]);
|
||||||
},
|
},
|
||||||
validator: function (value)
|
validator: function validator(value)
|
||||||
{
|
{
|
||||||
let ss = Components.classes["@mozilla.org/browser/search-service;1"]
|
let ss = Components.classes["@mozilla.org/browser/search-service;1"]
|
||||||
.getService(Components.interfaces.nsIBrowserSearchService);
|
.getService(Components.interfaces.nsIBrowserSearchService);
|
||||||
@@ -377,7 +377,7 @@ function CommandLine() //{{{
|
|||||||
"List of file patterns to ignore when completing files",
|
"List of file patterns to ignore when completing files",
|
||||||
"stringlist", "",
|
"stringlist", "",
|
||||||
{
|
{
|
||||||
validator: function (value)
|
validator: function validator(value)
|
||||||
{
|
{
|
||||||
// TODO: allow for escaping the ","
|
// TODO: allow for escaping the ","
|
||||||
try
|
try
|
||||||
@@ -396,7 +396,7 @@ function CommandLine() //{{{
|
|||||||
"Define how command line completion works",
|
"Define how command line completion works",
|
||||||
"stringlist", "list:full",
|
"stringlist", "list:full",
|
||||||
{
|
{
|
||||||
completer: function (filter)
|
completer: function completer(filter)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
["", "Complete only the first match"],
|
["", "Complete only the first match"],
|
||||||
@@ -407,7 +407,7 @@ function CommandLine() //{{{
|
|||||||
["list:longest", "List all and complete common string"]
|
["list:longest", "List all and complete common string"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: function (value)
|
validator: function validator(value)
|
||||||
{
|
{
|
||||||
return value.split(",").every(
|
return value.split(",").every(
|
||||||
function (item) /^(full|longest|list|list:full|list:longest|)$/.test(item)
|
function (item) /^(full|longest|list|list:full|list:longest|)$/.test(item)
|
||||||
@@ -419,14 +419,14 @@ function CommandLine() //{{{
|
|||||||
"Change how command line completion is done",
|
"Change how command line completion is done",
|
||||||
"stringlist", "",
|
"stringlist", "",
|
||||||
{
|
{
|
||||||
completer: function (value)
|
completer: function completer(value)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
["auto", "Automatically show completions while you are typing"],
|
["auto", "Automatically show completions while you are typing"],
|
||||||
["sort", "Always sort the completion list"]
|
["sort", "Always sort the completion list"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: function (value)
|
validator: function validator(value)
|
||||||
{
|
{
|
||||||
return value.split(",").every(function (item) /^(sort|auto|)$/.test(item));
|
return value.split(",").every(function (item) /^(sort|auto|)$/.test(item));
|
||||||
}
|
}
|
||||||
@@ -562,12 +562,12 @@ function CommandLine() //{{{
|
|||||||
storage.styles.removeSheet("silent-mode", null, null, null, true);
|
storage.styles.removeSheet("silent-mode", null, null, null, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
getCommand: function ()
|
getCommand: function getCommand()
|
||||||
{
|
{
|
||||||
return commandWidget.value;
|
return commandWidget.value;
|
||||||
},
|
},
|
||||||
|
|
||||||
open: function (prompt, cmd, extendedMode)
|
open: function open(prompt, cmd, extendedMode)
|
||||||
{
|
{
|
||||||
// save the current prompts, we need it later if the command widget
|
// save the current prompts, we need it later if the command widget
|
||||||
// receives focus without calling the this.open() method
|
// receives focus without calling the this.open() method
|
||||||
@@ -598,7 +598,7 @@ function CommandLine() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// normally used when pressing esc, does not execute a command
|
// normally used when pressing esc, does not execute a command
|
||||||
close: function ()
|
close: function close()
|
||||||
{
|
{
|
||||||
var res = liberator.triggerCallback("cancel", currentExtendedMode);
|
var res = liberator.triggerCallback("cancel", currentExtendedMode);
|
||||||
inputHistory.add(this.getCommand());
|
inputHistory.add(this.getCommand());
|
||||||
@@ -606,7 +606,7 @@ function CommandLine() //{{{
|
|||||||
this.clear();
|
this.clear();
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function ()
|
clear: function clear()
|
||||||
{
|
{
|
||||||
multilineInputWidget.collapsed = true;
|
multilineInputWidget.collapsed = true;
|
||||||
outputContainer.collapsed = true;
|
outputContainer.collapsed = true;
|
||||||
@@ -617,7 +617,7 @@ function CommandLine() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// liberator.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 echo(str, highlightGroup, flags)
|
||||||
{
|
{
|
||||||
var focused = document.commandDispatcher.focusedElement;
|
var focused = document.commandDispatcher.focusedElement;
|
||||||
if (focused && focused == commandWidget.inputField || focused == multilineInputWidget.inputField)
|
if (focused && focused == commandWidget.inputField || focused == multilineInputWidget.inputField)
|
||||||
@@ -662,7 +662,7 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
// this will prompt the user for a string
|
// this will prompt the user for a string
|
||||||
// commandline.input("(s)ave or (o)pen the file?")
|
// commandline.input("(s)ave or (o)pen the file?")
|
||||||
input: function (prompt, callback, extra)
|
input: function input(prompt, callback, extra)
|
||||||
{
|
{
|
||||||
extra = extra || {};
|
extra = extra || {};
|
||||||
|
|
||||||
@@ -678,7 +678,7 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
// reads a multi line input and returns the string once the last line matches
|
// reads a multi line input and returns the string once the last line matches
|
||||||
// @param untilRegexp
|
// @param untilRegexp
|
||||||
inputMultiline: function (untilRegexp, callbackFunc)
|
inputMultiline: function inputMultiline(untilRegexp, callbackFunc)
|
||||||
{
|
{
|
||||||
// save the mode, because we need to restore it
|
// save the mode, because we need to restore it
|
||||||
modes.push(modes.COMMAND_LINE, modes.INPUT_MULTILINE);
|
modes.push(modes.COMMAND_LINE, modes.INPUT_MULTILINE);
|
||||||
@@ -694,7 +694,7 @@ function CommandLine() //{{{
|
|||||||
setTimeout(function () { multilineInputWidget.focus(); }, 10);
|
setTimeout(function () { multilineInputWidget.focus(); }, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
onEvent: function (event)
|
onEvent: function onEvent(event)
|
||||||
{
|
{
|
||||||
var command = this.getCommand();
|
var command = this.getCommand();
|
||||||
|
|
||||||
@@ -944,7 +944,7 @@ function CommandLine() //{{{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onMultilineInputEvent: function (event)
|
onMultilineInputEvent: function onMultilineInputEvent(event)
|
||||||
{
|
{
|
||||||
if (event.type == "keypress")
|
if (event.type == "keypress")
|
||||||
{
|
{
|
||||||
@@ -980,7 +980,7 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
// FIXME: if 'more' is set and the MOW is not scrollable we should still
|
// FIXME: if 'more' is set and the MOW is not scrollable we should still
|
||||||
// allow a down motion after an up rather than closing
|
// allow a down motion after an up rather than closing
|
||||||
onMultilineOutputEvent: function (event)
|
onMultilineOutputEvent: function onMultilineOutputEvent(event)
|
||||||
{
|
{
|
||||||
var win = multilineOutputWidget.contentWindow;
|
var win = multilineOutputWidget.contentWindow;
|
||||||
|
|
||||||
@@ -1177,7 +1177,7 @@ function CommandLine() //{{{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
highlight: function (start, end, type)
|
highlight: function highlight(start, end, type)
|
||||||
{
|
{
|
||||||
// FIXME: Kludge.
|
// FIXME: Kludge.
|
||||||
try // Firefox <3.1 doesn't have repaintSelection
|
try // Firefox <3.1 doesn't have repaintSelection
|
||||||
@@ -1199,7 +1199,7 @@ function CommandLine() //{{{
|
|||||||
catch (e) {}
|
catch (e) {}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateMorePrompt: function (force, showHelp)
|
updateMorePrompt: function updateMorePrompt(force, showHelp)
|
||||||
{
|
{
|
||||||
let win = multilineOutputWidget.contentWindow;
|
let win = multilineOutputWidget.contentWindow;
|
||||||
function isScrollable() !win.scrollMaxY == 0;
|
function isScrollable() !win.scrollMaxY == 0;
|
||||||
@@ -1213,7 +1213,7 @@ function CommandLine() //{{{
|
|||||||
setLine("Press ENTER or type command to continue", this.HL_QUESTION);
|
setLine("Press ENTER or type command to continue", this.HL_QUESTION);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateOutputHeight: function (open)
|
updateOutputHeight: function updateOutputHeight(open)
|
||||||
{
|
{
|
||||||
if (!open && outputContainer.collapsed)
|
if (!open && outputContainer.collapsed)
|
||||||
return;
|
return;
|
||||||
@@ -1233,7 +1233,7 @@ function CommandLine() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// to allow asynchronous adding of completions
|
// to allow asynchronous adding of completions
|
||||||
setCompletions: function (newCompletions)
|
setCompletions: function setCompletions(newCompletions)
|
||||||
{
|
{
|
||||||
if (liberator.mode != modes.COMMAND_LINE)
|
if (liberator.mode != modes.COMMAND_LINE)
|
||||||
return;
|
return;
|
||||||
@@ -1272,7 +1272,7 @@ function CommandLine() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// TODO: does that function need to be public?
|
// TODO: does that function need to be public?
|
||||||
resetCompletions: function ()
|
resetCompletions: function resetCompletions()
|
||||||
{
|
{
|
||||||
autocompleteTimer.reset();
|
autocompleteTimer.reset();
|
||||||
completion.cancel();
|
completion.cancel();
|
||||||
@@ -1403,8 +1403,8 @@ function ItemList(id) //{{{
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
clear: function () { this.setItems(); doc.body.innerHTML = ""; },
|
clear: function clear() { this.setItems(); doc.body.innerHTML = ""; },
|
||||||
hide: function () { container.collapsed = true; },
|
hide: function hide() { container.collapsed = true; },
|
||||||
show: function show()
|
show: function show()
|
||||||
{
|
{
|
||||||
/* FIXME: Should only happen with autocomplete,
|
/* FIXME: Should only happen with autocomplete,
|
||||||
@@ -1417,7 +1417,7 @@ function ItemList(id) //{{{
|
|||||||
}
|
}
|
||||||
container.collapsed = false;
|
container.collapsed = false;
|
||||||
},
|
},
|
||||||
visible: function () !container.collapsed,
|
visible: function visible() !container.collapsed,
|
||||||
|
|
||||||
// if @param selectedItem is given, show the list and select that item
|
// if @param selectedItem is given, show the list and select that item
|
||||||
setItems: function setItems(newItems, selectedItem)
|
setItems: function setItems(newItems, selectedItem)
|
||||||
@@ -1468,7 +1468,7 @@ function ItemList(id) //{{{
|
|||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
onEvent: function (event) false
|
onEvent: function onEvent(event) false
|
||||||
};
|
};
|
||||||
//}}}
|
//}}}
|
||||||
}; //}}}
|
}; //}}}
|
||||||
@@ -1498,7 +1498,7 @@ function StatusLine() //{{{
|
|||||||
"Show the status line",
|
"Show the status line",
|
||||||
"number", 2,
|
"number", 2,
|
||||||
{
|
{
|
||||||
setter: function (value)
|
setter: function setter(value)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
document.getElementById("status-bar").collapsed = true;
|
document.getElementById("status-bar").collapsed = true;
|
||||||
@@ -1509,7 +1509,7 @@ function StatusLine() //{{{
|
|||||||
|
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
completer: function (filter)
|
completer: function completer(filter)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
["0", "Never display status line"],
|
["0", "Never display status line"],
|
||||||
@@ -1517,7 +1517,7 @@ function StatusLine() //{{{
|
|||||||
["2", "Always display status line"]
|
["2", "Always display status line"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: function (value) value >= 0 && value <= 2
|
validator: function validator(value) value >= 0 && value <= 2
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -1526,7 +1526,7 @@ function StatusLine() //{{{
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
setClass: function (type)
|
setClass: function setClass(type)
|
||||||
{
|
{
|
||||||
const highlightGroup = {
|
const highlightGroup = {
|
||||||
secure: "StatusLineSecure",
|
secure: "StatusLineSecure",
|
||||||
@@ -1538,7 +1538,7 @@ function StatusLine() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// update all fields of the statusline
|
// update all fields of the statusline
|
||||||
update: function ()
|
update: function update()
|
||||||
{
|
{
|
||||||
this.updateUrl();
|
this.updateUrl();
|
||||||
this.updateInputBuffer();
|
this.updateInputBuffer();
|
||||||
@@ -1548,7 +1548,7 @@ function StatusLine() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// if "url" is ommited, build a usable string for the URL
|
// if "url" is ommited, build a usable string for the URL
|
||||||
updateUrl: function (url)
|
updateUrl: function updateUrl(url)
|
||||||
{
|
{
|
||||||
if (typeof url == "string")
|
if (typeof url == "string")
|
||||||
{
|
{
|
||||||
@@ -1590,7 +1590,7 @@ function StatusLine() //{{{
|
|||||||
urlWidget.value = url;
|
urlWidget.value = url;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateInputBuffer: function (buffer)
|
updateInputBuffer: function updateInputBuffer(buffer)
|
||||||
{
|
{
|
||||||
if (!buffer || typeof buffer != "string")
|
if (!buffer || typeof buffer != "string")
|
||||||
buffer = "";
|
buffer = "";
|
||||||
@@ -1598,7 +1598,7 @@ function StatusLine() //{{{
|
|||||||
inputBufferWidget.value = buffer;
|
inputBufferWidget.value = buffer;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateProgress: function (progress)
|
updateProgress: function updateProgress(progress)
|
||||||
{
|
{
|
||||||
if (!progress)
|
if (!progress)
|
||||||
progress = "";
|
progress = "";
|
||||||
@@ -1626,7 +1626,7 @@ function StatusLine() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// you can omit either of the 2 arguments
|
// you can omit either of the 2 arguments
|
||||||
updateTabCount: function (currentIndex, totalTabs)
|
updateTabCount: function updateTabCount(currentIndex, totalTabs)
|
||||||
{
|
{
|
||||||
if (!liberator.has("tabs"))
|
if (!liberator.has("tabs"))
|
||||||
{
|
{
|
||||||
@@ -1652,7 +1652,7 @@ function StatusLine() //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// percent is given between 0 and 1
|
// percent is given between 0 and 1
|
||||||
updateBufferPosition: function (percent)
|
updateBufferPosition: function updateBufferPosition(percent)
|
||||||
{
|
{
|
||||||
if (!percent || typeof percent != "number")
|
if (!percent || typeof percent != "number")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -333,7 +333,8 @@ const util = { //{{{
|
|||||||
i = parseInt(i);
|
i = parseInt(i);
|
||||||
else if (/^[A-Z_]+$/.test(i))
|
else if (/^[A-Z_]+$/.test(i))
|
||||||
i = "";
|
i = "";
|
||||||
keys.push([i, <>{key}{noVal ? "" : <>: {value}</>}<br/>
</>]);
|
keys.push([i, <>{key}{noVal ? "" : <>: {value}</> // Vim /
|
||||||
|
}<br/>
</>]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
@@ -516,7 +517,7 @@ function Struct()
|
|||||||
ConStructor.defaultValue = function (key, val)
|
ConStructor.defaultValue = function (key, val)
|
||||||
{
|
{
|
||||||
let i = args.indexOf(key);
|
let i = args.indexOf(key);
|
||||||
ConStructor.prototype.__defineGetter__(i, function () this[i] = val.call(this));
|
ConStructor.prototype.__defineGetter__(i, function () (this[i] = val.call(this), this[i])); // Kludge for FF 3.0
|
||||||
ConStructor.prototype.__defineSetter__(i, function (val) {
|
ConStructor.prototype.__defineSetter__(i, function (val) {
|
||||||
let value = val;
|
let value = val;
|
||||||
this.__defineGetter__(i, function () value);
|
this.__defineGetter__(i, function () value);
|
||||||
|
|||||||
Reference in New Issue
Block a user