summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2009-05-22 13:55:22 -0400
committerKris Maglione <maglione.k@gmail.com>2009-05-22 13:55:22 -0400
commite9fc3327ed6db07212079e7646404d5afe62e724 (patch)
tree0229567d9af6d69f24dd5e2ddfe4d28f7f9a96da /common
parent491d17a4a0f8289ef7c5015a8dd4fd5a6d4028dc (diff)
downloadpentadactyl-e9fc3327ed6db07212079e7646404d5afe62e724.tar.gz
Make :undo a bit saner. Add TODO about config.name checks.
Diffstat (limited to 'common')
-rw-r--r--common/content/buffer.js2
-rw-r--r--common/content/commands.js8
-rw-r--r--common/content/completion.js6
-rw-r--r--common/content/events.js4
-rw-r--r--common/content/io.js3
-rw-r--r--common/content/liberator.js2
-rw-r--r--common/content/mappings.js2
-rw-r--r--common/content/tabs.js30
8 files changed, 28 insertions, 29 deletions
diff --git a/common/content/buffer.js b/common/content/buffer.js
index f8d07e03..f51b6fff 100644
--- a/common/content/buffer.js
+++ b/common/content/buffer.js
@@ -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;
diff --git a/common/content/commands.js b/common/content/commands.js
index 1946a9cc..8e888865 100644
--- a/common/content/commands.js
+++ b/common/content/commands.js
@@ -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]);
diff --git a/common/content/completion.js b/common/content/completion.js
index 50e3e0df..7a319c6a 100644
--- a/common/content/completion.js
+++ b/common/content/completion.js
@@ -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
diff --git a/common/content/events.js b/common/content/events.js
index c3064e4b..56131a42 100644
--- a/common/content/events.js
+++ b/common/content/events.js
@@ -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)
{
diff --git a/common/content/io.js b/common/content/io.js
index 46f99f51..09e51da1 100644
--- a/common/content/io.js
+++ b/common/content/io.js
@@ -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;
},
diff --git a/common/content/liberator.js b/common/content/liberator.js
index 071dc965..880ea30d 100644
--- a/common/content/liberator.js
+++ b/common/content/liberator.js
@@ -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()) + ": $&"));
},
/**
diff --git a/common/content/mappings.js b/common/content/mappings.js
index bf90742e..ada1aa94 100644
--- a/common/content/mappings.js
+++ b/common/content/mappings.js
@@ -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 = {};
diff --git a/common/content/tabs.js b/common/content/tabs.js
index fabf9b0c..3b63fcc5 100644
--- a/common/content/tabs.js
+++ b/common/content/tabs.js
@@ -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