mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-01 05:35:49 +01:00
Only show "Waiting..." message if wed otherwise show items (should maybe do the same for context.message); prefix window functions with "window."; general cleanup.
This commit is contained in:
@@ -235,7 +235,7 @@ function Bookmarks() //{{{
|
|||||||
"string", "google",
|
"string", "google",
|
||||||
{
|
{
|
||||||
completer: function completer(context) completion.search(context, true),
|
completer: function completer(context) completion.search(context, true),
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["preload"],
|
options.add(["preload"],
|
||||||
@@ -270,7 +270,7 @@ function Bookmarks() //{{{
|
|||||||
"Show jumplist",
|
"Show jumplist",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
var sh = getWebNavigation().sessionHistory;
|
var sh = window.getWebNavigation().sessionHistory;
|
||||||
|
|
||||||
let entries = [sh.getEntryAtIndex(i, false) for (i in util.range(0, sh.count))];
|
let entries = [sh.getEntryAtIndex(i, false) for (i in util.range(0, sh.count))];
|
||||||
let list = template.jumps(sh.index, entries);
|
let list = template.jumps(sh.index, entries);
|
||||||
@@ -516,8 +516,8 @@ function Bookmarks() //{{{
|
|||||||
|
|
||||||
function process(resp)
|
function process(resp)
|
||||||
{
|
{
|
||||||
let json = Components.classes["@mozilla.org/dom/json;1"]
|
const json = Components.classes["@mozilla.org/dom/json;1"]
|
||||||
.createInstance(Components.interfaces.nsIJSON);
|
.createInstance(Components.interfaces.nsIJSON);
|
||||||
let results = [];
|
let results = [];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -557,7 +557,7 @@ function Bookmarks() //{{{
|
|||||||
// did not :open <tab> once before
|
// did not :open <tab> once before
|
||||||
this.getSearchEngines();
|
this.getSearchEngines();
|
||||||
|
|
||||||
url = getShortcutOrURI(searchString, aPostDataRef);
|
url = window.getShortcutOrURI(searchString, aPostDataRef);
|
||||||
if (url == searchString)
|
if (url == searchString)
|
||||||
url = null;
|
url = null;
|
||||||
|
|
||||||
@@ -642,12 +642,12 @@ function History() //{{{
|
|||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
var sh = getWebNavigation().sessionHistory;
|
var sh = window.getWebNavigation().sessionHistory;
|
||||||
for (let i = sh.index - 1; i >= 0; i--)
|
for (let i = sh.index - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (sh.getEntryAtIndex(i, false).URI.spec == args)
|
if (sh.getEntryAtIndex(i, false).URI.spec == args)
|
||||||
{
|
{
|
||||||
getWebNavigation().gotoIndex(i);
|
window.getWebNavigation().gotoIndex(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -664,7 +664,7 @@ function History() //{{{
|
|||||||
completer: function completer(context)
|
completer: function completer(context)
|
||||||
{
|
{
|
||||||
let filter = context.filter;
|
let filter = context.filter;
|
||||||
var sh = getWebNavigation().sessionHistory;
|
var sh = window.getWebNavigation().sessionHistory;
|
||||||
var completions = [];
|
var completions = [];
|
||||||
for (let i in util.range(sh.index, 0, true))
|
for (let i in util.range(sh.index, 0, true))
|
||||||
{
|
{
|
||||||
@@ -694,12 +694,12 @@ function History() //{{{
|
|||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
var sh = getWebNavigation().sessionHistory;
|
var sh = window.getWebNavigation().sessionHistory;
|
||||||
for (let i in util.range(sh.index + 1, sh.count))
|
for (let i in util.range(sh.index + 1, sh.count))
|
||||||
{
|
{
|
||||||
if (sh.getEntryAtIndex(i, false).URI.spec == args)
|
if (sh.getEntryAtIndex(i, false).URI.spec == args)
|
||||||
{
|
{
|
||||||
getWebNavigation().gotoIndex(i);
|
window.getWebNavigation().gotoIndex(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -716,7 +716,7 @@ function History() //{{{
|
|||||||
completer: function completer(context)
|
completer: function completer(context)
|
||||||
{
|
{
|
||||||
let filter = context.filter;
|
let filter = context.filter;
|
||||||
var sh = getWebNavigation().sessionHistory;
|
var sh = window.getWebNavigation().sessionHistory;
|
||||||
var completions = [];
|
var completions = [];
|
||||||
for (let i in util.range(sh.index + 1, sh.count))
|
for (let i in util.range(sh.index + 1, sh.count))
|
||||||
{
|
{
|
||||||
@@ -786,29 +786,29 @@ function History() //{{{
|
|||||||
// TODO: better names and move to buffer.?
|
// TODO: better names and move to buffer.?
|
||||||
stepTo: function stepTo(steps)
|
stepTo: function stepTo(steps)
|
||||||
{
|
{
|
||||||
let index = getWebNavigation().sessionHistory.index + steps;
|
let index = window.getWebNavigation().sessionHistory.index + steps;
|
||||||
if (index >= 0 && index < getWebNavigation().sessionHistory.count)
|
if (index >= 0 && index < window.getWebNavigation().sessionHistory.count)
|
||||||
getWebNavigation().gotoIndex(index);
|
window.getWebNavigation().gotoIndex(index);
|
||||||
else
|
else
|
||||||
liberator.beep();
|
liberator.beep();
|
||||||
},
|
},
|
||||||
|
|
||||||
goToStart: function goToStart()
|
goToStart: function goToStart()
|
||||||
{
|
{
|
||||||
let index = getWebNavigation().sessionHistory.index;
|
let index = window.getWebNavigation().sessionHistory.index;
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
return liberator.beep(); // really wanted?
|
return liberator.beep(); // really wanted?
|
||||||
|
|
||||||
getWebNavigation().gotoIndex(0);
|
window.getWebNavigation().gotoIndex(0);
|
||||||
},
|
},
|
||||||
|
|
||||||
goToEnd: function goToEnd()
|
goToEnd: function goToEnd()
|
||||||
{
|
{
|
||||||
let index = getWebNavigation().sessionHistory.index;
|
let index = window.getWebNavigation().sessionHistory.index;
|
||||||
if (index == getWebNavigation().sessionHistory.count - 1)
|
if (index == window.getWebNavigation().sessionHistory.count - 1)
|
||||||
return liberator.beep();
|
return liberator.beep();
|
||||||
|
|
||||||
getWebNavigation().gotoIndex(max);
|
window.getWebNavigation().gotoIndex(max);
|
||||||
},
|
},
|
||||||
|
|
||||||
// if openItems is true, open the matching history items in tabs rather than display
|
// if openItems is true, open the matching history items in tabs rather than display
|
||||||
|
|||||||
@@ -146,7 +146,10 @@ function Buffer() //{{{
|
|||||||
"stringlist", "\\bprev|previous\\b,^<$,^(<<|«)$,^(<|«),(<|«)$");
|
"stringlist", "\\bprev|previous\\b,^<$,^(<<|«)$,^(<|«),(<|«)$");
|
||||||
|
|
||||||
options.add(["pageinfo", "pa"], "Desired info on :pa[geinfo]", "charlist", "gfm",
|
options.add(["pageinfo", "pa"], "Desired info on :pa[geinfo]", "charlist", "gfm",
|
||||||
{ completer: function (filter) [[k, v[1]] for ([k, v] in Iterator(pageInfo))] });
|
{
|
||||||
|
completer: function (filter) [[k, v[1]] for ([k, v] in Iterator(pageInfo))],
|
||||||
|
validator: Option.validateCompleter
|
||||||
|
});
|
||||||
|
|
||||||
options.add(["scroll", "scr"],
|
options.add(["scroll", "scr"],
|
||||||
"Number of lines to scroll with <C-u> and <C-d> commands",
|
"Number of lines to scroll with <C-u> and <C-d> commands",
|
||||||
@@ -162,7 +165,7 @@ function Buffer() //{{{
|
|||||||
["1", "Show the link in the status line"],
|
["1", "Show the link in the status line"],
|
||||||
["2", "Show the link in the command line"]
|
["2", "Show the link in the command line"]
|
||||||
],
|
],
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["usermode", "um"],
|
options.add(["usermode", "um"],
|
||||||
@@ -173,7 +176,7 @@ function Buffer() //{{{
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getMarkupDocumentViewer().authorStyleDisabled = value;
|
window.getMarkupDocumentViewer().authorStyleDisabled = value;
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
@@ -183,7 +186,7 @@ function Buffer() //{{{
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return getMarkupDocumentViewer().authorStyleDisabled;
|
return window.getMarkupDocumentViewer().authorStyleDisabled;
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
}
|
}
|
||||||
@@ -217,7 +220,7 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
mappings.add(myModes, ["<C-c>"],
|
mappings.add(myModes, ["<C-c>"],
|
||||||
"Stop loading",
|
"Stop loading",
|
||||||
function () { BrowserStop(); });
|
function () { window.BrowserStop(); });
|
||||||
|
|
||||||
// scrolling
|
// scrolling
|
||||||
mappings.add(myModes, ["j", "<Down>", "<C-e>"],
|
mappings.add(myModes, ["j", "<Down>", "<C-e>"],
|
||||||
@@ -517,7 +520,7 @@ function Buffer() //{{{
|
|||||||
if (options["usermode"])
|
if (options["usermode"])
|
||||||
options["usermode"] = false;
|
options["usermode"] = false;
|
||||||
|
|
||||||
stylesheetSwitchAll(window.content, args);
|
window.stylesheetSwitchAll(window.content, args);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
completer: function (context) completion.alternateStylesheet(context),
|
completer: function (context) completion.alternateStylesheet(context),
|
||||||
@@ -567,9 +570,9 @@ function Buffer() //{{{
|
|||||||
.getDocumentMetadata("content-disposition");
|
.getDocumentMetadata("content-disposition");
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
internalSave(doc.location.href, doc, null, contentDisposition,
|
window.internalSave(doc.location.href, doc, null, contentDisposition,
|
||||||
doc.contentType, false, null, chosenData, doc.referrer ?
|
doc.contentType, false, null, chosenData, doc.referrer ?
|
||||||
makeURI(doc.referrer) : null, true);
|
window.makeURI(doc.referrer) : null, true);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "?",
|
argCount: "?",
|
||||||
@@ -579,7 +582,7 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
commands.add(["st[op]"],
|
commands.add(["st[op]"],
|
||||||
"Stop loading",
|
"Stop loading",
|
||||||
function () { BrowserStop(); },
|
function () { window.BrowserStop(); },
|
||||||
{ argCount: "0" });
|
{ argCount: "0" });
|
||||||
|
|
||||||
commands.add(["vie[wsource]"],
|
commands.add(["vie[wsource]"],
|
||||||
@@ -671,7 +674,7 @@ function Buffer() //{{{
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
urlSecurityCheck(data.href, principal,
|
window.urlSecurityCheck(data.href, principal,
|
||||||
Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
|
Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
@@ -793,7 +796,7 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
get alternateStyleSheets()
|
get alternateStyleSheets()
|
||||||
{
|
{
|
||||||
var stylesheets = getAllStyleSheets(window.content);
|
var stylesheets = window.getAllStyleSheets(window.content);
|
||||||
|
|
||||||
return stylesheets.filter(
|
return stylesheets.filter(
|
||||||
function (stylesheet) /^(screen|all|)$/i.test(stylesheet.media.mediaText) && !/^\s*$/.test(stylesheet.title)
|
function (stylesheet) /^(screen|all|)$/i.test(stylesheet.media.mediaText) && !/^\s*$/.test(stylesheet.title)
|
||||||
@@ -1106,15 +1109,15 @@ function Buffer() //{{{
|
|||||||
saveLink: function (elem, skipPrompt)
|
saveLink: function (elem, skipPrompt)
|
||||||
{
|
{
|
||||||
var doc = elem.ownerDocument;
|
var doc = elem.ownerDocument;
|
||||||
var url = makeURLAbsolute(elem.baseURI, elem.href);
|
var url = window.makeURLAbsolute(elem.baseURI, elem.href);
|
||||||
var text = elem.textContent;
|
var text = elem.textContent;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
urlSecurityCheck(url, doc.nodePrincipal);
|
window.urlSecurityCheck(url, doc.nodePrincipal);
|
||||||
// we always want to save that link relative to the current working directory
|
// we always want to save that link relative to the current working directory
|
||||||
options.setPref("browser.download.lastDir", io.getCurrentDirectory().path);
|
options.setPref("browser.download.lastDir", io.getCurrentDirectory().path);
|
||||||
saveURL(url, text, null, true, skipPrompt, makeURI(url, doc.characterSet));
|
window.saveURL(url, text, null, true, skipPrompt, makeURI(url, doc.characterSet));
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -635,7 +635,7 @@ function Commands() //{{{
|
|||||||
|
|
||||||
// check for correct number of arguments
|
// check for correct number of arguments
|
||||||
if (args.length == 0 && /^[1+]$/.test(argCount) ||
|
if (args.length == 0 && /^[1+]$/.test(argCount) ||
|
||||||
literal != null && /[+?]/.test(argCount) && !/\S/.test(args.literalArg || ""))
|
literal != null && /[1+]/.test(argCount) && !/\S/.test(args.literalArg || ""))
|
||||||
{
|
{
|
||||||
if (!complete)
|
if (!complete)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ function CompletionContext(editor, name, offset)
|
|||||||
this.message = null;
|
this.message = null;
|
||||||
this.name = name || "";
|
this.name = name || "";
|
||||||
this._completions = []; // FIXME
|
this._completions = []; // FIXME
|
||||||
this.getKey = function (item, key) (typeof self.keys[key] == "function") ? self.keys[key].call(this, item) :
|
this.getKey = function (item, key) (typeof self.keys[key] == "function") ? self.keys[key].call(this, item.item) :
|
||||||
key in self.keys ? item.item[self.keys[key]]
|
key in self.keys ? item.item[self.keys[key]]
|
||||||
: item.item[key];
|
: item.item[key];
|
||||||
}
|
}
|
||||||
@@ -225,17 +225,36 @@ CompletionContext.prototype = {
|
|||||||
{
|
{
|
||||||
this.hasItems = true;
|
this.hasItems = true;
|
||||||
this._generate = arg;
|
this._generate = arg;
|
||||||
|
liberator.dump(this.name + ": set generate()");
|
||||||
if (this.background && this.regenerate)
|
if (this.background && this.regenerate)
|
||||||
{
|
{
|
||||||
|
//**/ this.__i = (this.__i || 0) + 1;
|
||||||
|
//**/ let self = this;
|
||||||
|
//**/ function dump(msg) liberator.callInMainThread(function () liberator.dump(self.name + ":" + self.__i + ": " + msg));
|
||||||
|
//**/ dump("set generate() regenerating");
|
||||||
let lock = {};
|
let lock = {};
|
||||||
this.cache.backgroundLock = lock;
|
this.cache.backgroundLock = lock;
|
||||||
this.incomplete = true;
|
this.incomplete = true;
|
||||||
liberator.callAsync(this, function () {
|
let thread = this.getCache("backgroundThread", liberator.newThread);
|
||||||
let items = this.generate();
|
//**/ dump(thread);
|
||||||
|
liberator.callAsync(thread, this, function () {
|
||||||
|
//**/ dump("In async");
|
||||||
if (this.cache.backgroundLock != lock)
|
if (this.cache.backgroundLock != lock)
|
||||||
|
{
|
||||||
|
//**/ dump("Lock !ok");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
let items = this.generate();
|
||||||
|
//**/ dump("Generated");
|
||||||
|
if (this.cache.backgroundLock != lock)
|
||||||
|
{
|
||||||
|
//**/ dump("Lock !ok");
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.incomplete = false;
|
this.incomplete = false;
|
||||||
|
//**/ dump("completions=");
|
||||||
this.completions = items;
|
this.completions = items;
|
||||||
|
//**/ dump("completions==");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -907,9 +926,9 @@ function Completion() //{{{
|
|||||||
let compare = context.compare;
|
let compare = context.compare;
|
||||||
context.compare = function (a, b)
|
context.compare = function (a, b)
|
||||||
{
|
{
|
||||||
if (!isNaN(a.key) && !isNaN(b.key))
|
if (!isNaN(a.item.key) && !isNaN(b.item.key))
|
||||||
return a.key - b.key;
|
return a.item.key - b.item.key;
|
||||||
return isNaN(b.key) - isNaN(a.key) || compare(a, b);
|
return isNaN(b.item.key) - isNaN(a.item.key) || compare(a, b);
|
||||||
}
|
}
|
||||||
if (!context.anchored) // We've already listed anchored matches, so don't list them again here.
|
if (!context.anchored) // We've already listed anchored matches, so don't list them again here.
|
||||||
context.filters.push(function (item) util.compareIgnoreCase(item.text.substr(0, this.filter.length), this.filter));
|
context.filters.push(function (item) util.compareIgnoreCase(item.text.substr(0, this.filter.length), this.filter));
|
||||||
@@ -1457,7 +1476,7 @@ function Completion() //{{{
|
|||||||
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
.getService(Components.interfaces.nsIPrefBranch);
|
.getService(Components.interfaces.nsIPrefBranch);
|
||||||
context.title = ["Firefox Preference", "Value"];
|
context.title = ["Firefox Preference", "Value"];
|
||||||
context.keys = { text: function (item) item.item, description: function (item) options.getPref(item.item) };
|
context.keys = { text: function (item) item, description: function (item) options.getPref(item) };
|
||||||
context.completions = prefs.getChildList("", { value: 0 });
|
context.completions = prefs.getChildList("", { value: 0 });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ function AutoCommands() //{{{
|
|||||||
"stringlist", "",
|
"stringlist", "",
|
||||||
{
|
{
|
||||||
completer: function () config.autocommands.concat([["all", "All events"]]),
|
completer: function () config.autocommands.concat([["all", "All events"]]),
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["focuscontent", "fc"],
|
options.add(["focuscontent", "fc"],
|
||||||
@@ -808,7 +808,7 @@ function Events() //{{{
|
|||||||
// make sure the page is stopped before starting to play the macro
|
// make sure the page is stopped before starting to play the macro
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getWebNavigation().stop(nsIWebNavigation.STOP_ALL);
|
window.getWebNavigation().stop(nsIWebNavigation.STOP_ALL);
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
@@ -1321,13 +1321,13 @@ function Events() //{{{
|
|||||||
// {
|
// {
|
||||||
// //alert(command_line.value.substring(0, command_line.selectionStart));
|
// //alert(command_line.value.substring(0, command_line.selectionStart));
|
||||||
// command_line.value = command_line.value.substring(0, command_line.selectionStart) +
|
// command_line.value = command_line.value.substring(0, command_line.selectionStart) +
|
||||||
// readFromClipboard() +
|
// window.readFromClipboard() +
|
||||||
// command_line.value.substring(command_line.selectionEnd, command_line.value.length);
|
// command_line.value.substring(command_line.selectionEnd, command_line.value.length);
|
||||||
// alert(command_line.value);
|
// alert(command_line.value);
|
||||||
// }
|
// }
|
||||||
// //else
|
// //else
|
||||||
// // {
|
// // {
|
||||||
// // openURLs(readFromClipboard());
|
// // openURLs(window.readFromClipboard());
|
||||||
// // }
|
// // }
|
||||||
// return true;
|
// return true;
|
||||||
// } }}}
|
// } }}}
|
||||||
|
|||||||
@@ -328,15 +328,15 @@ function Hints() //{{{
|
|||||||
if (!followFirst)
|
if (!followFirst)
|
||||||
return false; // no return hit; don't examine uniqueness
|
return false; // no return hit; don't examine uniqueness
|
||||||
|
|
||||||
// OK. return hit. But there's more than one hint. And
|
// OK. return hit. But there's more than one hint, and
|
||||||
// there's no tab-selected current link. Do not follow in mode 2
|
// there's no tab-selected current link. Do not follow in mode 2
|
||||||
if ((options["followhints"] == 2) && validHints.length > 1 && !hintNumber)
|
if (options["followhints"] == 2 && validHints.length > 1 && !hintNumber)
|
||||||
return liberator.beep();
|
return liberator.beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!followFirst)
|
if (!followFirst)
|
||||||
{
|
{
|
||||||
var firstHref = validHints[0].getAttribute("href") || null;
|
let firstHref = validHints[0].getAttribute("href") || null;
|
||||||
if (firstHref)
|
if (firstHref)
|
||||||
{
|
{
|
||||||
if (validHints.some(function (e) e.getAttribute("href") != firstHref))
|
if (validHints.some(function (e) e.getAttribute("href") != firstHref))
|
||||||
@@ -551,7 +551,7 @@ function Hints() //{{{
|
|||||||
"string", DEFAULT_HINTTAGS);
|
"string", DEFAULT_HINTTAGS);
|
||||||
|
|
||||||
options.add(["hinttimeout", "hto"],
|
options.add(["hinttimeout", "hto"],
|
||||||
"Automatically follow non unique numerical hint",
|
"Timeout before automatically following a non-unique numerical hint",
|
||||||
"number", 0,
|
"number", 0,
|
||||||
{ validator: function (value) value >= 0 });
|
{ validator: function (value) value >= 0 });
|
||||||
|
|
||||||
@@ -560,7 +560,14 @@ function Hints() //{{{
|
|||||||
// better one right now.
|
// better one right now.
|
||||||
"Change the behaviour of <Return> in hint mode",
|
"Change the behaviour of <Return> in hint mode",
|
||||||
"number", 0,
|
"number", 0,
|
||||||
{ validator: function (value) value >= 0 && value < 3 });
|
{
|
||||||
|
completer: function () [
|
||||||
|
["0", "Follow the first hint as soon as typed text uniquely identifies it. Follow the selected hint on [m]<Return>[m]."],
|
||||||
|
["1", "Follow the selected hint on [m]<Return>[m]."],
|
||||||
|
["2", "Follow the selected hint on [m]<Return>[m] only it's been [m]<Tab>[m]-selected."]
|
||||||
|
],
|
||||||
|
validator: function (value) Option.validateCompleter
|
||||||
|
});
|
||||||
|
|
||||||
options.add(["hintmatching", "hm"],
|
options.add(["hintmatching", "hm"],
|
||||||
"How links are matched",
|
"How links are matched",
|
||||||
@@ -570,7 +577,7 @@ function Hints() //{{{
|
|||||||
{
|
{
|
||||||
return [[m, ""] for each (m in ["contains", "wordstartswith", "firstletters", "custom"])];
|
return [[m, ""] for each (m in ["contains", "wordstartswith", "firstletters", "custom"])];
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["wordseparators", "wsp"],
|
options.add(["wordseparators", "wsp"],
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ const liberator = (function () //{{{
|
|||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
toJavaScriptConsole();
|
window.toJavaScriptConsole();
|
||||||
liberator.reportError(e);
|
liberator.reportError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ const liberator = (function () //{{{
|
|||||||
["b", "Bookmark bar"]
|
["b", "Bookmark bar"]
|
||||||
].concat(!liberator.has("tabs") ? [] : tabopts);
|
].concat(!liberator.has("tabs") ? [] : tabopts);
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["helpfile", "hf"],
|
options.add(["helpfile", "hf"],
|
||||||
@@ -648,17 +648,18 @@ const liberator = (function () //{{{
|
|||||||
return false; // so you can do: if (...) return liberator.beep();
|
return false; // so you can do: if (...) return liberator.beep();
|
||||||
},
|
},
|
||||||
|
|
||||||
callAsync: function (self, func)
|
newThread: function () threadManager.newThread(0),
|
||||||
|
|
||||||
|
callAsync: function (thread, self, func)
|
||||||
{
|
{
|
||||||
let thread = threadManager.newThread(0);
|
hread = thread || threadManager.newThread(0);
|
||||||
thread.dispatch(new Runnable(self, func, Array.slice(arguments, 2)), thread.DISPATCH_NORMAL);
|
thread.dispatch(new Runnable(self, func, Array.slice(arguments, 2)), thread.DISPATCH_NORMAL);
|
||||||
},
|
},
|
||||||
|
|
||||||
// be sure to call GUI related methods like alert() or dump() ONLY in the main thread
|
// be sure to call GUI related methods like alert() or dump() ONLY in the main thread
|
||||||
callFunctionInThread: function (thread, func)
|
callFunctionInThread: function (thread, func)
|
||||||
{
|
{
|
||||||
if (!thread)
|
thread = thread || threadManager.newThread(0);
|
||||||
thread = threadManager.newThread(0);
|
|
||||||
|
|
||||||
// DISPATCH_SYNC is necessary, otherwise strange things will happen
|
// DISPATCH_SYNC is necessary, otherwise strange things will happen
|
||||||
thread.dispatch(new Runnable(null, func, Array.slice(arguments, 2)), thread.DISPATCH_SYNC);
|
thread.dispatch(new Runnable(null, func, Array.slice(arguments, 2)), thread.DISPATCH_SYNC);
|
||||||
@@ -1026,54 +1027,54 @@ const liberator = (function () //{{{
|
|||||||
if (urls.length == 0)
|
if (urls.length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (liberator.forceNewTab && liberator.has("tabs"))
|
function open(urls, where)
|
||||||
where = liberator.NEW_TAB;
|
|
||||||
else if (!where || !liberator.has("tabs"))
|
|
||||||
where = liberator.CURRENT_TAB;
|
|
||||||
|
|
||||||
var url = typeof urls[0] == "string" ? urls[0] : urls[0][0];
|
|
||||||
var postdata = typeof urls[0] == "string" ? null : urls[0][1];
|
|
||||||
var whichwindow = window;
|
|
||||||
|
|
||||||
// decide where to load the first url
|
|
||||||
switch (where)
|
|
||||||
{
|
{
|
||||||
case liberator.CURRENT_TAB:
|
let url = Array.concat(urls)[0];
|
||||||
getBrowser().loadURIWithFlags(url, null, null, null, postdata);
|
let postdata = Array.concat(urls)[1];
|
||||||
break;
|
let whichwindow = window;
|
||||||
|
|
||||||
case liberator.NEW_TAB:
|
// decide where to load the first url
|
||||||
var firsttab = getBrowser().addTab(url, null, null, postdata);
|
switch (where)
|
||||||
getBrowser().selectedTab = firsttab;
|
{
|
||||||
break;
|
case liberator.CURRENT_TAB:
|
||||||
|
getBrowser().loadURIWithFlags(url, null, null, null, postdata);
|
||||||
|
break;
|
||||||
|
|
||||||
case liberator.NEW_BACKGROUND_TAB:
|
case liberator.NEW_BACKGROUND_TAB:
|
||||||
getBrowser().addTab(url, null, null, postdata);
|
case liberator.NEW_TAB:
|
||||||
break;
|
if (!liberator.has("tabs"))
|
||||||
|
open(urls, liberator.NEW_WINDOW);
|
||||||
|
|
||||||
case liberator.NEW_WINDOW:
|
let tab = getBrowser().addTab(url, null, null, postdata);
|
||||||
window.open();
|
if (where == liberator.NEW_TAB)
|
||||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
getBrowser().selectedTab = tab;
|
||||||
.getService(Components.interfaces.nsIWindowMediator);
|
break;
|
||||||
whichwindow = wm.getMostRecentWindow("navigator:browser");
|
|
||||||
whichwindow.loadURI(url, null, postdata);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
case liberator.NEW_WINDOW:
|
||||||
liberator.echoerr("Exxx: Invalid 'where' directive in liberator.open(...)");
|
const wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||||
return false;
|
.getService(Components.interfaces.nsIWindowMediator);
|
||||||
|
window.open();
|
||||||
|
whichwindow = wm.getMostRecentWindow("navigator:browser");
|
||||||
|
whichwindow.loadURI(url, null, postdata);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
liberator.echoerr("Exxx: Invalid 'where' directive in liberator.open(...)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only load more than one url if we have tab support
|
if (liberator.forceNewTab)
|
||||||
if (!liberator.has("tabs"))
|
where = liberator.NEW_TAB;
|
||||||
return true;
|
else if (!where)
|
||||||
|
where = liberator.CURRENT_TAB;
|
||||||
|
|
||||||
// all other URLs are always loaded in background
|
for (let [i, url] in Iterator(urls))
|
||||||
for (let i = 1; i < urls.length; i++)
|
|
||||||
{
|
{
|
||||||
url = typeof urls[i] == "string" ? urls[i] : urls[i][0];
|
open(url, where);
|
||||||
postdata = typeof urls[i] == "string" ? null : urls[i][1];
|
if (i == 0 && !liberator.has("tabs"))
|
||||||
whichwindow.getBrowser().addTab(url, null, null, postdata);
|
break;
|
||||||
|
where = liberator.NEW_BACKGROUND_TAB;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1101,7 +1102,7 @@ const liberator = (function () //{{{
|
|||||||
.getService(nsIAppStartup)
|
.getService(nsIAppStartup)
|
||||||
.quit(nsIAppStartup.eForceQuit);
|
.quit(nsIAppStartup.eForceQuit);
|
||||||
else
|
else
|
||||||
goQuitApplication();
|
window.goQuitApplication();
|
||||||
},
|
},
|
||||||
|
|
||||||
reportError: function (error)
|
reportError: function (error)
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ function Mail() //{{{
|
|||||||
|
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
/*options.add(["threads"],
|
/*options.add(["threads"],
|
||||||
@@ -271,7 +271,7 @@ function Mail() //{{{
|
|||||||
|
|
||||||
mappings.add(myModes, ["d", "<Del>"],
|
mappings.add(myModes, ["d", "<Del>"],
|
||||||
"Move mail to Trash folder",
|
"Move mail to Trash folder",
|
||||||
function () { goDoCommand("cmd_delete"); });
|
function () { window.goDoCommand("cmd_delete"); });
|
||||||
|
|
||||||
mappings.add(myModes, ["j", "<Right>"],
|
mappings.add(myModes, ["j", "<Right>"],
|
||||||
"Select next message",
|
"Select next message",
|
||||||
@@ -351,19 +351,19 @@ function Mail() //{{{
|
|||||||
|
|
||||||
mappings.add(myModes, ["r"],
|
mappings.add(myModes, ["r"],
|
||||||
"Reply to sender",
|
"Reply to sender",
|
||||||
function () { goDoCommand("cmd_reply"); });
|
function () { window.goDoCommand("cmd_reply"); });
|
||||||
|
|
||||||
mappings.add(myModes, ["R"],
|
mappings.add(myModes, ["R"],
|
||||||
"Reply to all",
|
"Reply to all",
|
||||||
function () { goDoCommand("cmd_replyall"); });
|
function () { window.goDoCommand("cmd_replyall"); });
|
||||||
|
|
||||||
mappings.add(myModes, ["f"],
|
mappings.add(myModes, ["f"],
|
||||||
"Forward message",
|
"Forward message",
|
||||||
function () { goDoCommand("cmd_forward"); });
|
function () { window.goDoCommand("cmd_forward"); });
|
||||||
|
|
||||||
mappings.add(myModes, ["F"],
|
mappings.add(myModes, ["F"],
|
||||||
"Forward message inline",
|
"Forward message inline",
|
||||||
function () { goDoCommand("cmd_forwardInline"); });
|
function () { window.goDoCommand("cmd_forwardInline"); });
|
||||||
|
|
||||||
// SCROLLING
|
// SCROLLING
|
||||||
mappings.add(myModes, ["<Down>"],
|
mappings.add(myModes, ["<Down>"],
|
||||||
@@ -526,11 +526,11 @@ function Mail() //{{{
|
|||||||
|
|
||||||
mappings.add(myModes, ["zr", "zR"],
|
mappings.add(myModes, ["zr", "zR"],
|
||||||
"Expand all threads",
|
"Expand all threads",
|
||||||
function () { goDoCommand("cmd_expandAllThreads"); });
|
function () { window.goDoCommand("cmd_expandAllThreads"); });
|
||||||
|
|
||||||
mappings.add(myModes, ["zm", "zM"],
|
mappings.add(myModes, ["zm", "zM"],
|
||||||
"Collapse all threads",
|
"Collapse all threads",
|
||||||
function () { goDoCommand("cmd_collapseAllThreads"); });
|
function () { window.goDoCommand("cmd_collapseAllThreads"); });
|
||||||
|
|
||||||
mappings.add(myModes, ["<C-i>"],
|
mappings.add(myModes, ["<C-i>"],
|
||||||
"Go forward",
|
"Go forward",
|
||||||
@@ -728,7 +728,7 @@ function Mail() //{{{
|
|||||||
|
|
||||||
commands.add(["empty[trash]"],
|
commands.add(["empty[trash]"],
|
||||||
"Empty trash of the current account",
|
"Empty trash of the current account",
|
||||||
function () { goDoCommand("cmd_emptyTrash"); },
|
function () { window.goDoCommand("cmd_emptyTrash"); },
|
||||||
{ argCount: "0" });
|
{ argCount: "0" });
|
||||||
|
|
||||||
commands.add(["get[messages]"],
|
commands.add(["get[messages]"],
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ function Mappings() //{{{
|
|||||||
|
|
||||||
addUserMap: function (modes, keys, description, action, extra)
|
addUserMap: function (modes, keys, description, action, extra)
|
||||||
{
|
{
|
||||||
keys = keys.map(function (key) expandLeader(key));
|
keys = keys.map(expandLeader);
|
||||||
var map = new Map(modes, keys, description || "User defined mapping", action, extra);
|
var map = new 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
|
||||||
|
|||||||
@@ -53,23 +53,23 @@ const config = { //{{{
|
|||||||
|
|
||||||
dialogs: [
|
dialogs: [
|
||||||
["about", "About Thunderbird",
|
["about", "About Thunderbird",
|
||||||
function () { openAboutDialog(); }],
|
function () { window.openAboutDialog(); }],
|
||||||
["addons", "Manage Add-ons",
|
["addons", "Manage Add-ons",
|
||||||
function () { openAddonsMgr(); }],
|
function () { window.openAddonsMgr(); }],
|
||||||
["addressbook", "Address book",
|
["addressbook", "Address book",
|
||||||
function () { toAddressBook(); }],
|
function () { window.toAddressBook(); }],
|
||||||
["checkupdates", "Check for updates",
|
["checkupdates", "Check for updates",
|
||||||
function () { checkForUpdates(); }],
|
function () { window.checkForUpdates(); }],
|
||||||
/*["cleardata", "Clear private data",
|
/*["cleardata", "Clear private data",
|
||||||
function () { Components.classes[GLUE_CID].getService(Components.interfaces.nsIBrowserGlue).sanitize(window || null); }],*/
|
function () { Components.classes[GLUE_CID].getService(Components.interfaces.nsIBrowserGlue).sanitize(window || null); }],*/
|
||||||
["console", "JavaScript console",
|
["console", "JavaScript console",
|
||||||
function () { toJavaScriptConsole(); }],
|
function () { window.toJavaScriptConsole(); }],
|
||||||
/*["customizetoolbar", "Customize the Toolbar",
|
/*["customizetoolbar", "Customize the Toolbar",
|
||||||
function () { BrowserCustomizeToolbar(); }],*/
|
function () { BrowserCustomizeToolbar(); }],*/
|
||||||
["dominspector", "DOM Inspector",
|
["dominspector", "DOM Inspector",
|
||||||
function () { inspectDOMDocument(content.document); }],
|
function () { window.inspectDOMDocument(content.document); }],
|
||||||
["downloads", "Manage Downloads",
|
["downloads", "Manage Downloads",
|
||||||
function () { toOpenWindowByType('Download:Manager', 'chrome://mozapps/content/downloads/downloads.xul', 'chrome,dialog=no,resizable'); }],
|
function () { window.toOpenWindowByType('Download:Manager', 'chrome://mozapps/content/downloads/downloads.xul', 'chrome,dialog=no,resizable'); }],
|
||||||
/*["import", "Import Preferences, Bookmarks, History, etc. from other browsers",
|
/*["import", "Import Preferences, Bookmarks, History, etc. from other browsers",
|
||||||
function () { BrowserImport(); }],
|
function () { BrowserImport(); }],
|
||||||
["openfile", "Open the file selector dialog",
|
["openfile", "Open the file selector dialog",
|
||||||
@@ -87,9 +87,9 @@ const config = { //{{{
|
|||||||
["print", "Show print dialog",
|
["print", "Show print dialog",
|
||||||
function () { PrintUtils.print(); }],
|
function () { PrintUtils.print(); }],
|
||||||
["saveframe", "Save frame to disk",
|
["saveframe", "Save frame to disk",
|
||||||
function () { saveFrameDocument(); }],
|
function () { window.saveFrameDocument(); }],
|
||||||
["savepage", "Save page to disk",
|
["savepage", "Save page to disk",
|
||||||
function () { saveDocument(window.content.document); }],
|
function () { window.saveDocument(window.content.document); }],
|
||||||
/*["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",
|
||||||
@@ -135,11 +135,11 @@ const config = { //{{{
|
|||||||
|
|
||||||
mappings.add([modes.COMPOSE],
|
mappings.add([modes.COMPOSE],
|
||||||
["y"], "Send message now",
|
["y"], "Send message now",
|
||||||
function () { goDoCommand("cmd_sendNow"); });
|
function () { window.goDoCommand("cmd_sendNow"); });
|
||||||
|
|
||||||
mappings.add([modes.COMPOSE],
|
mappings.add([modes.COMPOSE],
|
||||||
["Y"], "Send message later",
|
["Y"], "Send message later",
|
||||||
function () { goDoCommand("cmd_sendLater"); });
|
function () { window.goDoCommand("cmd_sendLater"); });
|
||||||
|
|
||||||
// FIXME: does not really work reliably
|
// FIXME: does not really work reliably
|
||||||
mappings.add([modes.COMPOSE],
|
mappings.add([modes.COMPOSE],
|
||||||
|
|||||||
@@ -281,6 +281,16 @@ Option.prototype = {
|
|||||||
return "E474: Invalid argument: " + values;
|
return "E474: Invalid argument: " + values;
|
||||||
this.setValues(newValue, scope);
|
this.setValues(newValue, scope);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
// TODO: Run this by default?
|
||||||
|
Option.validateCompleter = function (values)
|
||||||
|
{
|
||||||
|
let context = CompletionContext("");
|
||||||
|
let res = this.completer(context);
|
||||||
|
if (!res)
|
||||||
|
res = context.allItems.map(function (item) [item.text]);
|
||||||
|
return Array.concat(values).every(
|
||||||
|
function (value) res.some(function (item) item[0] == value));
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
function Options() //{{{
|
function Options() //{{{
|
||||||
@@ -504,7 +514,7 @@ function Options() //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
openPreferences();
|
window.openPreferences();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -942,17 +952,6 @@ function Options() //{{{
|
|||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Run this by default?
|
|
||||||
validateCompleter: function (values)
|
|
||||||
{
|
|
||||||
let context = CompletionContext("");
|
|
||||||
let res = this.completer(context);
|
|
||||||
if (!res)
|
|
||||||
res = context.allItems.map(function (item) [item.text]);
|
|
||||||
return Array.concat(values).every(
|
|
||||||
function (value) res.some(function (item) item[0] == value));
|
|
||||||
},
|
|
||||||
|
|
||||||
get store() storage.options,
|
get store() storage.options,
|
||||||
|
|
||||||
getPref: function (name, forcedDefault)
|
getPref: function (name, forcedDefault)
|
||||||
|
|||||||
@@ -130,14 +130,12 @@ function Tabs() //{{{
|
|||||||
{
|
{
|
||||||
tabStrip.collapsed = true;
|
tabStrip.collapsed = true;
|
||||||
}
|
}
|
||||||
else if (value == 1)
|
|
||||||
{
|
|
||||||
options.setPref("browser.tabStrip.autoHide", true);
|
|
||||||
tabStrip.collapsed = false;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
options.setPref("browser.tabStrip.autoHide", false);
|
let pref = "browser.tabStrip.autoHide";
|
||||||
|
if (options.getPref(pref) == null)
|
||||||
|
pref = "browser.tabs.autoHide";
|
||||||
|
options.setPref(pref, value == 1);
|
||||||
tabStrip.collapsed = false;
|
tabStrip.collapsed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +149,7 @@ function Tabs() //{{{
|
|||||||
["2", "Always show tab bar"]
|
["2", "Always show tab bar"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
if (config.name == "Vimperator")
|
if (config.name == "Vimperator")
|
||||||
@@ -169,7 +167,7 @@ function Tabs() //{{{
|
|||||||
["paste", "P and gP mappings"]
|
["paste", "P and gP mappings"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["newtab"],
|
options.add(["newtab"],
|
||||||
@@ -187,7 +185,7 @@ function Tabs() //{{{
|
|||||||
["prefs", ":pref[erences]! or :prefs! command"]
|
["prefs", ":pref[erences]! or :prefs! command"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["popups", "pps"],
|
options.add(["popups", "pps"],
|
||||||
@@ -217,7 +215,7 @@ function Tabs() //{{{
|
|||||||
["4", "Open in the same tab unless it has a specific requested size"]
|
["4", "Open in the same tab unless it has a specific requested size"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
// TODO: Add option, or only apply when go~=[nN]
|
// TODO: Add option, or only apply when go~=[nN]
|
||||||
styles.addSheet("tab-binding", "chrome://browser/content/browser.xul",
|
styles.addSheet("tab-binding", "chrome://browser/content/browser.xul",
|
||||||
@@ -361,7 +359,7 @@ function Tabs() //{{{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "+",
|
argCount: "+",
|
||||||
completer: function (context) completion.ex(context.filter),
|
completer: function (context) completion.ex(context),
|
||||||
literal: 0
|
literal: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -583,53 +581,37 @@ function Tabs() //{{{
|
|||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let count = args.count;
|
let count = args.count;
|
||||||
args = args.string;
|
args = args[0]
|
||||||
|
|
||||||
if (count < 1)
|
if (count < 1)
|
||||||
count = 1;
|
count = 1;
|
||||||
|
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
let ss = Components.classes["@mozilla.org/browser/sessionstore;1"]
|
count = 0;
|
||||||
.getService(Components.interfaces.nsISessionStore);
|
for (let [i, item] in Iterator(tabs.closedTabs))
|
||||||
let undoItems = eval("(" + ss.getClosedTabData(window) + ")");
|
|
||||||
let found = false;
|
|
||||||
|
|
||||||
for (let i = 0; i < undoItems.length; i++)
|
|
||||||
{
|
{
|
||||||
if (undoItems[i].state.entries[0].url == args)
|
if (item.state.entries[0].url == args)
|
||||||
{
|
{
|
||||||
count = i + 1;
|
count = i + 1;
|
||||||
found = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!count)
|
||||||
{
|
{
|
||||||
liberator.echoerr("Exxx: No matching closed tab");
|
liberator.echoerr("Exxx: No matching closed tab");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
undoCloseTab(count - 1);
|
window.undoCloseTab(count - 1);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
completer: function (context)
|
completer: function (context)
|
||||||
{
|
{
|
||||||
// get closed-tabs from nsSessionStore
|
context.keys = { text: function (item) item.state.entries[0].url, description: "title" };
|
||||||
var ss = Components.classes["@mozilla.org/browser/sessionstore;1"]
|
context.completions = tabs.closedTabs;
|
||||||
.getService(Components.interfaces.nsISessionStore);
|
|
||||||
var undoItems = eval("(" + ss.getClosedTabData(window) + ")");
|
|
||||||
var completions = [];
|
|
||||||
for (let i = 0; i < undoItems.length; i++)
|
|
||||||
{
|
|
||||||
var url = undoItems[i].state.entries[0].url;
|
|
||||||
var title = undoItems[i].title;
|
|
||||||
if (completion.match([url, title], context.filter, false))
|
|
||||||
completions.push([url, title]);
|
|
||||||
}
|
|
||||||
return [0, completions];
|
|
||||||
},
|
},
|
||||||
count: true,
|
count: true,
|
||||||
literal: 0
|
literal: 0
|
||||||
@@ -639,12 +621,8 @@ function Tabs() //{{{
|
|||||||
"Undo closing of all closed tabs",
|
"Undo closing of all closed tabs",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let ss = Components.classes["@mozilla.org/browser/sessionstore;1"]
|
for (let i in Itarator(tabs.closedTabs))
|
||||||
.getService(Components.interfaces.nsISessionStore);
|
window.undoCloseTab(0);
|
||||||
let undoItems = eval("(" + ss.getClosedTabData(window) + ")");
|
|
||||||
|
|
||||||
for (let i = 0; i < undoItems.length; i++)
|
|
||||||
undoCloseTab(); // doesn't work with i as the index to undoCloseTab
|
|
||||||
|
|
||||||
},
|
},
|
||||||
{ argCount: "0" });
|
{ argCount: "0" });
|
||||||
@@ -739,6 +717,15 @@ function Tabs() //{{{
|
|||||||
return getBrowser().mTabContainer.selectedItem;
|
return getBrowser().mTabContainer.selectedItem;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get closedTabs()
|
||||||
|
{
|
||||||
|
const json = Components.classes["@mozilla.org/dom/json;1"]
|
||||||
|
.createInstance(Components.interfaces.nsIJSON);
|
||||||
|
const ss = Components.classes["@mozilla.org/browser/sessionstore;1"]
|
||||||
|
.getService(Components.interfaces.nsISessionStore);
|
||||||
|
return json.decode(ss.getClosedTabData(window));
|
||||||
|
},
|
||||||
|
|
||||||
list: function (filter)
|
list: function (filter)
|
||||||
{
|
{
|
||||||
completion.listCompleter("buffer", filter);
|
completion.listCompleter("buffer", filter);
|
||||||
@@ -764,7 +751,7 @@ function Tabs() //{{{
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (buffer.URL != "about:blank" ||
|
if (buffer.URL != "about:blank" ||
|
||||||
getWebNavigation().sessionHistory.count > 0)
|
window.getWebNavigation().sessionHistory.count > 0)
|
||||||
{
|
{
|
||||||
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
||||||
getBrowser().removeTab(tab);
|
getBrowser().removeTab(tab);
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
return engines.map(function (engine) [engine.alias, engine.description]);
|
return engines.map(function (engine) [engine.alias, engine.description]);
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: these belong in ui.js
|
// TODO: these belong in ui.js
|
||||||
@@ -489,7 +489,7 @@ function CommandLine() //{{{
|
|||||||
"charlist", "sfl",
|
"charlist", "sfl",
|
||||||
{
|
{
|
||||||
completer: function completer(filter) [k for each (k in completion.urlCompleters)],
|
completer: function completer(filter) [k for each (k in completion.urlCompleters)],
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["wildcase", "wic"],
|
options.add(["wildcase", "wic"],
|
||||||
@@ -501,7 +501,7 @@ function CommandLine() //{{{
|
|||||||
["match", "Case is always significant"],
|
["match", "Case is always significant"],
|
||||||
["ignore", "Case is never significant"]
|
["ignore", "Case is never significant"]
|
||||||
],
|
],
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["wildignore", "wig"],
|
options.add(["wildignore", "wig"],
|
||||||
@@ -538,7 +538,7 @@ function CommandLine() //{{{
|
|||||||
["list:longest", "List all and complete common string"]
|
["list:longest", "List all and complete common string"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter,
|
validator: Option.validateCompleter,
|
||||||
checkHas: function (value, val)
|
checkHas: function (value, val)
|
||||||
{
|
{
|
||||||
let [first, second] = value.split(":", 2);
|
let [first, second] = value.split(":", 2);
|
||||||
@@ -557,7 +557,7 @@ function CommandLine() //{{{
|
|||||||
["sort", "Always sort the completion list"]
|
["sort", "Always sort the completion list"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -1422,7 +1422,7 @@ function ItemList(id) //{{{
|
|||||||
|
|
||||||
let haveCompletions = false;
|
let haveCompletions = false;
|
||||||
let off = 0;
|
let off = 0;
|
||||||
let end = endIndex;
|
let end = startIndex + maxItems;
|
||||||
function getRows(context)
|
function getRows(context)
|
||||||
{
|
{
|
||||||
function fix(n) Math.max(0, Math.min(len, n));
|
function fix(n) Math.max(0, Math.min(len, n));
|
||||||
@@ -1430,7 +1430,9 @@ function ItemList(id) //{{{
|
|||||||
let len = context.items.length;
|
let len = context.items.length;
|
||||||
let start = off;
|
let start = off;
|
||||||
off += len;
|
off += len;
|
||||||
return [fix(offset - start), fix(endIndex - start)];
|
let res = [fix(offset - start), fix(end - start)];
|
||||||
|
res[2] = (context.incomplete && res[1] >= offset && off - 1 < end);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
items.contextList.forEach(function fill_eachContext(context) {
|
items.contextList.forEach(function fill_eachContext(context) {
|
||||||
@@ -1439,17 +1441,17 @@ function ItemList(id) //{{{
|
|||||||
return;
|
return;
|
||||||
haveCompletions = true;
|
haveCompletions = true;
|
||||||
|
|
||||||
|
let root = nodes.root
|
||||||
|
let items = nodes.items;
|
||||||
|
let [start, end, waiting] = getRows(context);
|
||||||
|
|
||||||
if (context.message)
|
if (context.message)
|
||||||
nodes.message.textContent = context.message;
|
nodes.message.textContent = context.message;
|
||||||
nodes.message.style.display = context.message ? "block" : "none";
|
nodes.message.style.display = context.message ? "block" : "none";
|
||||||
nodes.waiting.style.display = context.incomplete ? "block" : "none";
|
nodes.waiting.style.display = waiting ? "block" : "none";
|
||||||
nodes.up.style.opacity = "0";
|
nodes.up.style.opacity = "0";
|
||||||
nodes.down.style.display = "none";
|
nodes.down.style.display = "none";
|
||||||
|
|
||||||
let root = nodes.root
|
|
||||||
let items = nodes.items;
|
|
||||||
let [start, end] = getRows(context);
|
|
||||||
|
|
||||||
for (let [i, row] in Iterator(context.getRows(start, end, doc)))
|
for (let [i, row] in Iterator(context.getRows(start, end, doc)))
|
||||||
nodes[i] = row;
|
nodes[i] = row;
|
||||||
for (let [i, row] in util.Array.iterator2(nodes))
|
for (let [i, row] in util.Array.iterator2(nodes))
|
||||||
@@ -1616,7 +1618,7 @@ function StatusLine() //{{{
|
|||||||
["2", "Always display status line"]
|
["2", "Always display status line"]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validator: options.validateCompleter
|
validator: Option.validateCompleter
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -1671,7 +1673,7 @@ function StatusLine() //{{{
|
|||||||
// when session information is available, add [+] when we can go backwards
|
// when session information is available, add [+] when we can go backwards
|
||||||
if (config.name == "Vimperator")
|
if (config.name == "Vimperator")
|
||||||
{
|
{
|
||||||
let sh = getWebNavigation().sessionHistory;
|
let sh = window.getWebNavigation().sessionHistory;
|
||||||
let modified = "";
|
let modified = "";
|
||||||
if (sh.index > 0)
|
if (sh.index > 0)
|
||||||
modified += "+";
|
modified += "+";
|
||||||
|
|||||||
@@ -465,30 +465,26 @@ const util = { //{{{
|
|||||||
{
|
{
|
||||||
let urls = str.split(new RegExp("\s*" + options["urlseparator"] + "\s*"));
|
let urls = str.split(new RegExp("\s*" + options["urlseparator"] + "\s*"));
|
||||||
|
|
||||||
for (let url = 0; url < urls.length; url++)
|
return urls.map(function (url) {
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
let file = io.getFile(urls[url]);
|
let file = io.getFile(url);
|
||||||
if (file.exists() && file.isReadable())
|
if (file.exists() && file.isReadable())
|
||||||
{
|
return file.path;
|
||||||
urls[url] = file.path;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
// removes spaces from the string if it starts with http:// or something like that
|
// removes spaces from the string if it starts with http:// or something like that
|
||||||
if (/^\w+:\/\//.test(urls[url]))
|
if (/^\w+:\/\//.test(url))
|
||||||
urls[url] = urls[url].replace(/\s+/g, "");
|
url = url.replace(/\s+/g, "");
|
||||||
|
|
||||||
// strip each 'URL' - makes things simpler later on
|
// strip each 'URL' - makes things simpler later on
|
||||||
urls[url] = urls[url].replace(/^\s+/, "").replace(/\s+$/, "");
|
url = url.replace(/^\s+|\s+$/, "");
|
||||||
|
|
||||||
// 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 (/\s/.test(urls[url]) || !/[.:\/]/.test(urls[url]))
|
if (/\s/.test(url) || !/[.:\/]/.test(url))
|
||||||
{
|
{
|
||||||
// TODO: it would be clearer if the appropriate call to
|
// TODO: it would be clearer if the appropriate call to
|
||||||
// getSearchURL was made based on whether or not the first word was
|
// getSearchURL was made based on whether or not the first word was
|
||||||
@@ -497,27 +493,22 @@ const util = { //{{{
|
|||||||
// like the comments below ;-)
|
// like the comments below ;-)
|
||||||
|
|
||||||
// check for a search engine match in the string
|
// check for a search engine match in the string
|
||||||
let searchURL = bookmarks.getSearchURL(urls[url], false);
|
let searchURL = bookmarks.getSearchURL(url, false);
|
||||||
if (searchURL)
|
if (searchURL)
|
||||||
{
|
{
|
||||||
urls[url] = searchURL;
|
return searchURL;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
else // no search engine match, search for the whole string in the default engine
|
else // no search engine match, search for the whole string in the default engine
|
||||||
{
|
{
|
||||||
searchURL = bookmarks.getSearchURL(urls[url], true);
|
searchURL = bookmarks.getSearchURL(url, true);
|
||||||
if (searchURL)
|
if (searchURL)
|
||||||
{
|
return searchURL;
|
||||||
urls[url] = searchURL;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if we are here let Firefox handle the url and hope it does
|
// if we are here let Firefox handle the url and hope it does
|
||||||
// something useful with it :)
|
// something useful with it :)
|
||||||
}
|
return url;
|
||||||
|
});
|
||||||
return urls;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
xmlToDom: function xmlToDom(node, doc, nodes)
|
xmlToDom: function xmlToDom(node, doc, nodes)
|
||||||
|
|||||||
@@ -54,41 +54,41 @@ const config = { //{{{
|
|||||||
|
|
||||||
dialogs: [
|
dialogs: [
|
||||||
["about", "About Firefox",
|
["about", "About Firefox",
|
||||||
function () { openDialog("chrome://browser/content/aboutDialog.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
function () { window.openDialog("chrome://browser/content/aboutDialog.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
||||||
["addbookmark", "Add bookmark for the current page",
|
["addbookmark", "Add bookmark for the current page",
|
||||||
function () { PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksRootId); }],
|
function () { PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksRootId); }],
|
||||||
["addons", "Manage Add-ons",
|
["addons", "Manage Add-ons",
|
||||||
function () { BrowserOpenAddonsMgr(); }],
|
function () { window.BrowserOpenAddonsMgr(); }],
|
||||||
["bookmarks", "List your bookmarks",
|
["bookmarks", "List your bookmarks",
|
||||||
function () { openDialog("chrome://browser/content/bookmarks/bookmarksPanel.xul", "Bookmarks", "dialog,centerscreen,width=600,height=600"); }],
|
function () { window.openDialog("chrome://browser/content/bookmarks/bookmarksPanel.xul", "Bookmarks", "dialog,centerscreen,width=600,height=600"); }],
|
||||||
["checkupdates", "Check for updates",
|
["checkupdates", "Check for updates",
|
||||||
function () { checkForUpdates(); }],
|
function () { window.checkForUpdates(); }],
|
||||||
["cleardata", "Clear private data",
|
["cleardata", "Clear private data",
|
||||||
function () { Components.classes[GLUE_CID].getService(Components.interfaces.nsIBrowserGlue).sanitize(window || null); }],
|
function () { Components.classes[GLUE_CID].getService(Components.interfaces.nsIBrowserGlue).sanitize(window || null); }],
|
||||||
["cookies", "List your cookies",
|
["cookies", "List your cookies",
|
||||||
function () { toOpenWindowByType("Browser:Cookies", "chrome://browser/content/preferences/cookies.xul", "chrome,dialog=no,resizable"); }],
|
function () { window.toOpenWindowByType("Browser:Cookies", "chrome://browser/content/preferences/cookies.xul", "chrome,dialog=no,resizable"); }],
|
||||||
["console", "JavaScript console",
|
["console", "JavaScript console",
|
||||||
function () { toJavaScriptConsole(); }],
|
function () { window.toJavaScriptConsole(); }],
|
||||||
["customizetoolbar", "Customize the Toolbar",
|
["customizetoolbar", "Customize the Toolbar",
|
||||||
function () { BrowserCustomizeToolbar(); }],
|
function () { window.BrowserCustomizeToolbar(); }],
|
||||||
["dominspector", "DOM Inspector",
|
["dominspector", "DOM Inspector",
|
||||||
function () { try { inspectDOMDocument(content.document); } catch (e) { liberator.echoerr("DOM Inspector extension not installed"); } }],
|
function () { try { window.inspectDOMDocument(content.document); } catch (e) { liberator.echoerr("DOM Inspector extension not installed"); } }],
|
||||||
["downloads", "Manage Downloads",
|
["downloads", "Manage Downloads",
|
||||||
function () { toOpenWindowByType("Download:Manager", "chrome://mozapps/content/downloads/downloads.xul", "chrome,dialog=no,resizable"); }],
|
function () { window.toOpenWindowByType("Download:Manager", "chrome://mozapps/content/downloads/downloads.xul", "chrome,dialog=no,resizable"); }],
|
||||||
["history", "List your history",
|
["history", "List your history",
|
||||||
function () { openDialog("chrome://browser/content/history/history-panel.xul", "History", "dialog,centerscreen,width=600,height=600"); }],
|
function () { window.openDialog("chrome://browser/content/history/history-panel.xul", "History", "dialog,centerscreen,width=600,height=600"); }],
|
||||||
["import", "Import Preferences, Bookmarks, History, etc. from other browsers",
|
["import", "Import Preferences, Bookmarks, History, etc. from other browsers",
|
||||||
function () { BrowserImport(); }],
|
function () { window.BrowserImport(); }],
|
||||||
["openfile", "Open the file selector dialog",
|
["openfile", "Open the file selector dialog",
|
||||||
function () { BrowserOpenFileWindow(); }],
|
function () { window.BrowserOpenFileWindow(); }],
|
||||||
["pageinfo", "Show information about the current page",
|
["pageinfo", "Show information about the current page",
|
||||||
function () { BrowserPageInfo(); }],
|
function () { window.BrowserPageInfo(); }],
|
||||||
["pagesource", "View page source",
|
["pagesource", "View page source",
|
||||||
function () { BrowserViewSourceOfDocument(content.document); }],
|
function () { window.BrowserViewSourceOfDocument(content.document); }],
|
||||||
["places", "Places Organizer: Manage your bookmarks and history",
|
["places", "Places Organizer: Manage your bookmarks and history",
|
||||||
function () { PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_BOOKMARKS); }],
|
function () { PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_BOOKMARKS); }],
|
||||||
["preferences", "Show Firefox preferences dialog",
|
["preferences", "Show Firefox preferences dialog",
|
||||||
function () { openPreferences(); }],
|
function () { window.openPreferences(); }],
|
||||||
["printpreview", "Preview the page before printing",
|
["printpreview", "Preview the page before printing",
|
||||||
function () { PrintUtils.printPreview(onEnterPrintPreview, onExitPrintPreview); }],
|
function () { PrintUtils.printPreview(onEnterPrintPreview, onExitPrintPreview); }],
|
||||||
["printsetup", "Setup the page size and orientation before printing",
|
["printsetup", "Setup the page size and orientation before printing",
|
||||||
@@ -96,11 +96,11 @@ const config = { //{{{
|
|||||||
["print", "Show print dialog",
|
["print", "Show print dialog",
|
||||||
function () { PrintUtils.print(); }],
|
function () { PrintUtils.print(); }],
|
||||||
["saveframe", "Save frame to disk",
|
["saveframe", "Save frame to disk",
|
||||||
function () { saveFrameDocument(); }],
|
function () { window.saveFrameDocument(); }],
|
||||||
["savepage", "Save page to disk",
|
["savepage", "Save page to disk",
|
||||||
function () { saveDocument(window.content.document); }],
|
function () { window.saveDocument(window.content.document); }],
|
||||||
["searchengines", "Manage installed search engines",
|
["searchengines", "Manage installed search engines",
|
||||||
function () { openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
function () { window.openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); }],
|
||||||
["selectionsource", "View selection source",
|
["selectionsource", "View selection source",
|
||||||
function () { buffer.viewSelectionSource(); }]
|
function () { buffer.viewSelectionSource(); }]
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user