1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 22:07: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();
return;
}
else if (elemTagName == "input" && elem.type.toLowerCase() == "file")
else if (elemTagName == "input" && elem.type == "file")
{
openUploadPrompt(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) //{{{
{
specs = Array.concat(specs);
if (!extraInfo)
extraInfo = {};
@@ -71,12 +73,12 @@ function Command(specs, description, action, extraInfo) //{{{
for (let [,spec] in Iterator(specs))
{
let matches = spec.match(/(\w+)\[(\w+)\]/);
let matches = spec.match(/(\w+)\[(\w+)\](\w*)/);
if (matches)
{
shortNames.push(matches[1]);
longNames.push(matches[1] + matches[2]);
shortNames.push(matches[1] + matches[3]);
longNames.push(matches[1] + matches[2] + matches[3]);
// order as long1, short1, long2, short2
names.push(matches[1] + matches[2]);
names.push(matches[1]);

View File

@@ -339,6 +339,12 @@ CompletionContext.prototype = {
{
let [k, v] = i;
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")
res.__defineGetter__(k, function () _k in this ? this[_k] : (this[_k] = v(this.item)));
else

View File

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

View File

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

View File

@@ -711,7 +711,7 @@ const liberator = (function () //{{{
msg = util.objectToString(msg);
else
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) //{{{
{
modes = Array.concat(modes);
if (!extraInfo)
extraInfo = {};

View File

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