1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 04:47:58 +01:00

Make :undo a bit saner. Add TODO about config.name checks.

This commit is contained in:
Kris Maglione
2009-05-22 13:55:22 -04:00
parent 491d17a4a0
commit e9fc3327ed
9 changed files with 30 additions and 29 deletions

View File

@@ -1099,7 +1099,7 @@ function Buffer() //{{{
elem.contentWindow.focus(); elem.contentWindow.focus();
return; return;
} }
else if (elemTagName == "input" && elem.type.toLowerCase() == "file") else if (elemTagName == "input" && elem.type == "file")
{ {
openUploadPrompt(elem); openUploadPrompt(elem);
buffer.lastInputField = elem; buffer.lastInputField = elem;

View File

@@ -54,6 +54,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
*/ */
function Command(specs, description, action, extraInfo) //{{{ function Command(specs, description, action, extraInfo) //{{{
{ {
specs = Array.concat(specs);
if (!extraInfo) if (!extraInfo)
extraInfo = {}; extraInfo = {};
@@ -71,12 +73,12 @@ function Command(specs, description, action, extraInfo) //{{{
for (let [,spec] in Iterator(specs)) for (let [,spec] in Iterator(specs))
{ {
let matches = spec.match(/(\w+)\[(\w+)\]/); let matches = spec.match(/(\w+)\[(\w+)\](\w*)/);
if (matches) if (matches)
{ {
shortNames.push(matches[1]); shortNames.push(matches[1] + matches[3]);
longNames.push(matches[1] + matches[2]); longNames.push(matches[1] + matches[2] + matches[3]);
// order as long1, short1, long2, short2 // order as long1, short1, long2, short2
names.push(matches[1] + matches[2]); names.push(matches[1] + matches[2]);
names.push(matches[1]); names.push(matches[1]);

View File

@@ -339,6 +339,12 @@ CompletionContext.prototype = {
{ {
let [k, v] = i; let [k, v] = i;
let _k = "_" + k; let _k = "_" + k;
if (typeof v == "string" && !/^[a-z_$][0-9a-z_$]*$/i.test(v))
{
if (!/[.[]/.test(v[0]))
v = "." + v;
v = eval("(function(i) i" + v + ")")
}
if (typeof v == "function") if (typeof v == "function")
res.__defineGetter__(k, function () _k in this ? this[_k] : (this[_k] = v(this.item))); res.__defineGetter__(k, function () _k in this ? this[_k] : (this[_k] = v(this.item)));
else else

View File

@@ -929,8 +929,6 @@ function Events() //{{{
{ {
liberator.threadYield(1, true); liberator.threadYield(1, true);
noremap = !!noremap;
for (var i = 0; i < keys.length; i++) for (var i = 0; i < keys.length; i++)
{ {
let charCode = keys.charCodeAt(i); let charCode = keys.charCodeAt(i);
@@ -983,7 +981,7 @@ function Events() //{{{
let evt = doc.createEvent("KeyEvents"); let evt = doc.createEvent("KeyEvents");
evt.initKeyEvent("keypress", true, true, view, ctrl, alt, shift, meta, keyCode, charCode); evt.initKeyEvent("keypress", true, true, view, ctrl, alt, shift, meta, keyCode, charCode);
evt.noremap = noremap; evt.noremap = !!noremap;
evt.isMacro = true; evt.isMacro = true;
if (string) if (string)
{ {

View File

@@ -794,6 +794,7 @@ function IO() //{{{
* @param {string[]} args An array of arguments to pass to <b>program</b>. * @param {string[]} args An array of arguments to pass to <b>program</b>.
* @param {boolean} blocking Whether to wait until the process terminates. * @param {boolean} blocking Whether to wait until the process terminates.
*/ */
blockingProcesses: [],
run: function (program, args, blocking) run: function (program, args, blocking)
{ {
args = args || []; args = args || [];
@@ -845,7 +846,7 @@ lookup:
let process = services.create("process"); let process = services.create("process");
process.init(file); process.init(file);
process.run(blocking, args, args.length); process.run(blocking, args.map(String), args.length);
return process.exitValue; return process.exitValue;
}, },

View File

@@ -711,7 +711,7 @@ const liberator = (function () //{{{
msg = util.objectToString(msg); msg = util.objectToString(msg);
else else
msg += "\n"; msg += "\n";
window.dump(("config" in modules && config.name.toLowerCase()) + ": " + msg); window.dump(msg.replace(/^./gm, ("config" in modules && config.name.toLowerCase()) + ": $&"));
}, },
/** /**

View File

@@ -50,6 +50,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
*/ */
function Map(modes, keys, description, action, extraInfo) //{{{ function Map(modes, keys, description, action, extraInfo) //{{{
{ {
modes = Array.concat(modes);
if (!extraInfo) if (!extraInfo)
extraInfo = {}; extraInfo = {};

View File

@@ -601,7 +601,6 @@ function Tabs() //{{{
/* Why not xulmus? */ /* Why not xulmus? */
if (liberator.has("session") && config.name != "Xulmus") if (liberator.has("session") && config.name != "Xulmus")
{ {
// TODO: extract common functionality of "undoall"
commands.add(["u[ndo]"], commands.add(["u[ndo]"],
"Undo closing of a tab", "Undo closing of a tab",
function (args) function (args)
@@ -612,23 +611,16 @@ function Tabs() //{{{
if (count < 1) if (count < 1)
count = 1; count = 1;
if (args) if (m = /^(\d+)(:|$)/.exec(args || ''))
window.undoCloseTab(Number(m[1]) - 1);
else if (args)
{ {
count = 0;
for (let [i, item] in Iterator(tabs.closedTabs)) for (let [i, item] in Iterator(tabs.closedTabs))
{ if (item.state.entries[item.state.index - 1].url == args)
if (item.state.entries[0].url == args) return void window.undoCloseTab(i);
{
count = i + 1;
break;
}
}
if (!count) liberator.echoerr("Exxx: No matching closed tab");
return void liberator.echoerr("Exxx: No matching closed tab");
} }
window.undoCloseTab(count - 1);
}, },
{ {
argCount: "?", argCount: "?",
@@ -636,8 +628,8 @@ function Tabs() //{{{
{ {
context.anchored = false; context.anchored = false;
context.compare = CompletionContext.Sort.unsorted; context.compare = CompletionContext.Sort.unsorted;
context.keys = { text: function (item) item.state.entries[0].url, description: "title" }; context.keys = { text: function ([i, item]) (i + 1) + ": " + item.state.entries[item.state.index - 1].url, description: "[1].title", icon: "[1].image" };
context.completions = tabs.closedTabs; context.completions = Iterator(tabs.closedTabs);
}, },
count: true, count: true,
literal: 0 literal: 0
@@ -758,10 +750,8 @@ function Tabs() //{{{
* @property {Object[]} The array of closed tabs for the current * @property {Object[]} The array of closed tabs for the current
* session. * session.
*/ */
get closedTabs() get closedTabs() services.get("json").decode(services.get("sessionStore")
{ .getClosedTabData(window)),
return services.get("json").decode(services.get("sessionStore").getClosedTabData(window));
},
/** /**
* Returns the index of <b>tab</b> or the index of the currently * Returns the index of <b>tab</b> or the index of the currently

View File

@@ -43,6 +43,8 @@ BUGS:
- The MOW shouldn't close when executing hints and ;F isn't working. - The MOW shouldn't close when executing hints and ;F isn't working.
FEATURES: FEATURES:
8 Replace config.name tests in liberator with more specific feature
tests or overridable APIs where at all feasible.
8 change the extension ID to vimperator@vimperator.org rather than 8 change the extension ID to vimperator@vimperator.org rather than
vimperator@mozdev.org vimperator@mozdev.org
8 finish :help TODOs 8 finish :help TODOs