mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-09 00:04:11 +01:00
Use table tags in :addons and :downloads to better support :yank.
This commit is contained in:
@@ -147,20 +147,19 @@ var Addon = Class("Addon", {
|
||||
};
|
||||
XML.ignoreWhitespace = true;
|
||||
util.xmlToDom(
|
||||
<li highlight="Addon" key="row" xmlns:dactyl={NS} xmlns={XHTML}>
|
||||
<span highlight="AddonName" key="name">
|
||||
</span>
|
||||
<span highlight="AddonVersion" key="version"/>
|
||||
<span highlight="AddonStatus" key="status"/>
|
||||
<span highlight="AddonButtons Buttons">
|
||||
<tr highlight="Addon" key="row" xmlns:dactyl={NS} xmlns={XHTML}>
|
||||
<td highlight="AddonName" key="name"/>
|
||||
<td highlight="AddonVersion" key="version"/>
|
||||
<td highlight="AddonStatus" key="status"/>
|
||||
<td highlight="AddonButtons Buttons">
|
||||
<a highlight="Button" key="enable">On </a>
|
||||
<a highlight="Button" key="disable">Off</a>
|
||||
<a highlight="Button" key="delete">Del</a>
|
||||
<a highlight="Button" key="update">Upd</a>
|
||||
<a highlight="Button" key="options">Opt</a>
|
||||
</span>
|
||||
<span highlight="AddonDescription" key="description"/>
|
||||
</li>,
|
||||
</td>
|
||||
<td highlight="AddonDescription" key="description"/>
|
||||
</tr>,
|
||||
this.list.document, this.nodes);
|
||||
|
||||
this.update();
|
||||
@@ -266,15 +265,15 @@ var AddonList = Class("AddonList", {
|
||||
message: Class.memoize(function () {
|
||||
|
||||
XML.ignoreWhitespace = true;
|
||||
util.xmlToDom(<ul highlight="Addons" key="list" xmlns={XHTML}>
|
||||
<li highlight="AddonHead">
|
||||
<span>Name</span>
|
||||
<span>Version</span>
|
||||
<span>Status</span>
|
||||
<span/>
|
||||
<span>Description</span>
|
||||
</li>
|
||||
</ul>, this.document, this.nodes);
|
||||
util.xmlToDom(<table highlight="Addons" key="list" xmlns={XHTML}>
|
||||
<tr highlight="AddonHead">
|
||||
<td>Name</td>
|
||||
<td>Version</td>
|
||||
<td>Status</td>
|
||||
<td/>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</table>, this.document, this.nodes);
|
||||
|
||||
return this.nodes.list;
|
||||
}),
|
||||
@@ -314,7 +313,7 @@ var AddonList = Class("AddonList", {
|
||||
if (addon && addon.id in this.addons)
|
||||
this.addons[addon.id].update();
|
||||
if (this.ready)
|
||||
this.modules.commandline.updateOutputHeight(false);
|
||||
this.modules.mow.resize(false);
|
||||
},
|
||||
|
||||
onDisabled: function (addon) { this.update(addon); },
|
||||
|
||||
@@ -818,7 +818,7 @@ memoize(Class.prototype, "closure", function () {
|
||||
iter(properties(this), properties(this, true)).forEach(function (k) {
|
||||
if (!this.__lookupGetter__(k) && callable(this[k]))
|
||||
closure[k] = closure(this[k]);
|
||||
else if (!(k in closure || k in Object.prototype))
|
||||
else if (!(k in closure))
|
||||
Object.defineProperty(closure, k, {
|
||||
get: function get_proxy() self[k],
|
||||
set: function set_proxy(val) self[k] = val,
|
||||
@@ -985,9 +985,10 @@ let StructBase = Class("StructBase", Array, {
|
||||
});
|
||||
|
||||
var Timer = Class("Timer", {
|
||||
init: function (minInterval, maxInterval, callback) {
|
||||
init: function (minInterval, maxInterval, callback, self) {
|
||||
this._timer = services.Timer();
|
||||
this.callback = callback;
|
||||
this.self = self || this;
|
||||
this.minInterval = minInterval;
|
||||
this.maxInterval = maxInterval;
|
||||
this.doneAt = 0;
|
||||
@@ -1004,7 +1005,7 @@ var Timer = Class("Timer", {
|
||||
// minInterval is the time between the completion of the command and the next firing
|
||||
this.doneAt = Date.now() + this.minInterval;
|
||||
|
||||
this.callback(this.arg);
|
||||
this.callback.call(this.self, this.arg);
|
||||
}
|
||||
catch (e) {
|
||||
if (typeof util === "undefined")
|
||||
@@ -1042,8 +1043,8 @@ var Timer = Class("Timer", {
|
||||
this.doneAt = 0;
|
||||
},
|
||||
|
||||
flush: function () {
|
||||
if (this.doneAt == -1)
|
||||
flush: function (force) {
|
||||
if (this.doneAt == -1 || force)
|
||||
this.notify();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -29,31 +29,31 @@ var Download = Class("Download", {
|
||||
commandTarget: self
|
||||
};
|
||||
util.xmlToDom(
|
||||
<li highlight="Download" key="row" xmlns:dactyl={NS} xmlns={XHTML}>
|
||||
<span highlight="DownloadTitle">
|
||||
<tr highlight="Download" key="row" xmlns:dactyl={NS} xmlns={XHTML}>
|
||||
<td highlight="DownloadTitle">
|
||||
<span highlight="Link">
|
||||
<a key="launch" dactyl:command="download.command"
|
||||
href={self.target.spec} path={self.targetFile.path}>{self.displayName}</a>
|
||||
<span highlight="LinkInfo">{self.targetFile.path}</span>
|
||||
</span>
|
||||
</span>
|
||||
<span highlight="DownloadState" key="state"/>
|
||||
<span highlight="DownloadButtons Buttons">
|
||||
</td>
|
||||
<td highlight="DownloadState" key="state"/>
|
||||
<td highlight="DownloadButtons Buttons">
|
||||
<a highlight="Button" key="pause">Pause</a>
|
||||
<a highlight="Button" key="remove">Remove</a>
|
||||
<a highlight="Button" key="resume">Resume</a>
|
||||
<a highlight="Button" key="retry">Retry</a>
|
||||
<a highlight="Button" key="cancel">Cancel</a>
|
||||
<a highlight="Button" key="delete">Delete</a>
|
||||
</span>
|
||||
<span highlight="DownloadProgress" key="progress">
|
||||
</td>
|
||||
<td highlight="DownloadProgress" key="progress">
|
||||
<span highlight="DownloadProgressHave" key="progressHave"
|
||||
/>/<span highlight="DownloadProgressTotal" key="progressTotal"/>
|
||||
</span>
|
||||
<span highlight="DownloadPercent" key="percent"/>
|
||||
<span highlight="DownloadTime" key="time"/>
|
||||
<a highlight="DownloadSource" key="source" href={self.source.spec}>{self.source.spec}</a>
|
||||
</li>,
|
||||
</td>
|
||||
<td highlight="DownloadPercent" key="percent"/>
|
||||
<td highlight="DownloadTime" key="time"/>
|
||||
<td><a highlight="DownloadSource" key="source" href={self.source.spec}>{self.source.spec}</a></td>
|
||||
</tr>,
|
||||
this.list.document, this.nodes);
|
||||
|
||||
self.updateStatus();
|
||||
@@ -179,8 +179,8 @@ var DownloadList = Class("DownloadList",
|
||||
|
||||
message: Class.memoize(function () {
|
||||
|
||||
util.xmlToDom(<ul highlight="Downloads" key="list" xmlns={XHTML}>
|
||||
<li highlight="DownloadHead">
|
||||
util.xmlToDom(<table highlight="Downloads" key="list" xmlns={XHTML}>
|
||||
<tr highlight="DownloadHead">
|
||||
<span>Title</span>
|
||||
<span>Status</span>
|
||||
<span/>
|
||||
@@ -188,23 +188,23 @@ var DownloadList = Class("DownloadList",
|
||||
<span/>
|
||||
<span>Time remaining</span>
|
||||
<span>Source</span>
|
||||
</li>
|
||||
<li highlight="Download"><span><div style="min-height: 1ex; /* FIXME */"/></span></li>
|
||||
<li highlight="Download" key="totals" active="true">
|
||||
<span><span highlight="Title">Totals:</span> <span key="total"/></span>
|
||||
<span/>
|
||||
<span highlight="DownloadButtons">
|
||||
</tr>
|
||||
<tr highlight="Download"><span><div style="min-height: 1ex; /* FIXME */"/></span></tr>
|
||||
<tr highlight="Download" key="totals" active="true">
|
||||
<td><span highlight="Title">Totals:</span> <span key="total"/></td>
|
||||
<td/>
|
||||
<td highlight="DownloadButtons">
|
||||
<a highlight="Button" key="clear">Clear</a>
|
||||
</span>
|
||||
<span highlight="DownloadProgress" key="progress">
|
||||
</td>
|
||||
<td highlight="DownloadProgress" key="progress">
|
||||
<span highlight="DownloadProgressHave" key="progressHave"
|
||||
/>/<span highlight="DownloadProgressTotal" key="progressTotal"/>
|
||||
</span>
|
||||
<span highlight="DownloadPercent" key="percent"/>
|
||||
<span highlight="DownloadTime" key="time"/>
|
||||
<span/>
|
||||
</li>
|
||||
</ul>, this.document, this.nodes);
|
||||
</td>
|
||||
<td highlight="DownloadPercent" key="percent"/>
|
||||
<td highlight="DownloadTime" key="time"/>
|
||||
<td/>
|
||||
</tr>
|
||||
</table>, this.document, this.nodes);
|
||||
|
||||
for (let row in iter(services.downloadManager.DBConnection
|
||||
.createStatement("SELECT id FROM moz_downloads")))
|
||||
@@ -296,7 +296,7 @@ var DownloadList = Class("DownloadList",
|
||||
else {
|
||||
this.addDownload(download.id);
|
||||
|
||||
this.modules.commandline.updateOutputHeight(false);
|
||||
this.modules.mow.resize(false);
|
||||
this.nodes.list.scrollIntoView(false);
|
||||
}
|
||||
this.update();
|
||||
|
||||
@@ -15,24 +15,25 @@ var RangeFinder = Module("rangefinder", {
|
||||
Local: function (dactyl, modules, window) ({
|
||||
init: function () {
|
||||
this.dactyl = dactyl;
|
||||
this.commandline = modules.commandline;
|
||||
this.modes = modules.modes;
|
||||
this.modules = modules;
|
||||
this.window = window;
|
||||
this.options = modules.options;
|
||||
this.lastFindPattern = "";
|
||||
},
|
||||
|
||||
get commandline() this.modules.commandline,
|
||||
get modes() this.modules.modes,
|
||||
get options() this.modules.options,
|
||||
|
||||
get rangeFind() modules.buffer.localStore.rangeFind,
|
||||
set rangeFind(val) modules.buffer.localStore.rangeFind = val
|
||||
}),
|
||||
|
||||
openPrompt: function (mode) {
|
||||
let backwards = mode == this.modes.FIND_BACKWARD;
|
||||
this.commandline.open(backwards ? "?" : "/", "", mode);
|
||||
this.CommandMode(mode).open();
|
||||
|
||||
if (this.rangeFind && this.rangeFind.window.get() === this.window)
|
||||
this.rangeFind.reset();
|
||||
this.find("", backwards);
|
||||
this.find("", mode === this.modes.FIND_BACKWARD);
|
||||
},
|
||||
|
||||
bootstrap: function (str, backward) {
|
||||
@@ -119,8 +120,12 @@ var RangeFinder = Module("rangefinder", {
|
||||
this.rangeFind.focus();
|
||||
},
|
||||
|
||||
// Called when the user types a key in the find dialog. Triggers a find attempt if 'incfind' is set
|
||||
onKeyPress: function (command) {
|
||||
onCancel: function () {
|
||||
if (this.rangeFind)
|
||||
this.rangeFind.cancel();
|
||||
},
|
||||
|
||||
onChange: function (command) {
|
||||
if (this.options["incfind"]) {
|
||||
command = this.bootstrap(command);
|
||||
this.rangeFind.find(command);
|
||||
@@ -138,13 +143,6 @@ var RangeFinder = Module("rangefinder", {
|
||||
this.rangeFind.focus();
|
||||
},
|
||||
|
||||
// Called when the find is canceled - for example if someone presses
|
||||
// escape while typing a find
|
||||
onCancel: function () {
|
||||
if (this.rangeFind)
|
||||
this.rangeFind.cancel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Highlights all occurrences of the last sought for string in the
|
||||
* current buffer.
|
||||
@@ -163,12 +161,12 @@ var RangeFinder = Module("rangefinder", {
|
||||
}
|
||||
}, {
|
||||
}, {
|
||||
/* Must come before commandline. */
|
||||
modes: function (dactyl, modules, window) {
|
||||
const { modes } = modules;
|
||||
const { commandline, modes } = modules;
|
||||
modes.addMode("FIND", {
|
||||
extended: true,
|
||||
description: "Find mode, active when typing search input",
|
||||
bases: [modes.COMMAND_LINE],
|
||||
input: true
|
||||
});
|
||||
modes.addMode("FIND_FORWARD", {
|
||||
@@ -184,15 +182,6 @@ var RangeFinder = Module("rangefinder", {
|
||||
input: true
|
||||
}, { history: "search" });
|
||||
},
|
||||
commandline: function (dactyl, modules, window) {
|
||||
const { commandline, modes, rangefinder } = modules;
|
||||
commandline.registerCallback("change", modes.FIND_FORWARD, rangefinder.closure.onKeyPress);
|
||||
commandline.registerCallback("submit", modes.FIND_FORWARD, rangefinder.closure.onSubmit);
|
||||
commandline.registerCallback("cancel", modes.FIND_FORWARD, rangefinder.closure.onCancel);
|
||||
commandline.registerCallback("change", modes.FIND_BACKWARD, rangefinder.closure.onKeyPress);
|
||||
commandline.registerCallback("submit", modes.FIND_BACKWARD, rangefinder.closure.onSubmit);
|
||||
commandline.registerCallback("cancel", modes.FIND_BACKWARD, rangefinder.closure.onCancel);
|
||||
},
|
||||
commands: function (dactyl, modules, window) {
|
||||
const { commands, rangefinder } = modules;
|
||||
commands.add(["noh[lfind]"],
|
||||
@@ -200,6 +189,22 @@ var RangeFinder = Module("rangefinder", {
|
||||
function () { rangefinder.clear(); },
|
||||
{ argCount: "0" });
|
||||
},
|
||||
commandline: function (dactyl, modules, window) {
|
||||
this.CommandMode = Class("CommandFindMode", modules.CommandMode, {
|
||||
init: function init(mode) {
|
||||
this.mode = mode;
|
||||
init.supercall(this);
|
||||
},
|
||||
|
||||
historyKey: "find",
|
||||
|
||||
get prompt() this.mode === modules.modes.FIND_BACKWARD ? "?" : "/",
|
||||
|
||||
onCancel: this.closure.onCancel,
|
||||
onChange: this.closure.onChange,
|
||||
onSubmit: this.closure.onSubmit
|
||||
});
|
||||
},
|
||||
mappings: function (dactyl, modules, window) {
|
||||
const { buffer, config, mappings, modes, rangefinder } = modules;
|
||||
var myModes = config.browserModes.concat([modes.CARET]);
|
||||
|
||||
@@ -61,6 +61,27 @@ var IO = Module("io", {
|
||||
services.downloadManager.addListener(this.downloadListener);
|
||||
},
|
||||
|
||||
CommandFileMode: Class("CommandFileMode", modules.CommandMode, {
|
||||
init: function init(prompt, params) {
|
||||
init.supercall(this);
|
||||
this.prompt = isArray(prompt) ? prompt : ["Question", prompt];
|
||||
update(this, params);
|
||||
},
|
||||
|
||||
historyKey: "file",
|
||||
|
||||
get mode() modules.modes.FILE_INPUT,
|
||||
|
||||
complete: function (context) {
|
||||
if (this.completer)
|
||||
this.completer(context);
|
||||
|
||||
context = context.fork("files", 0);
|
||||
modules.completion.file(context);
|
||||
context.filters = context.filters.concat(this.filters || []);
|
||||
}
|
||||
}),
|
||||
|
||||
destroy: function destroy() {
|
||||
services.downloadManager.removeListener(this.downloadListener);
|
||||
for (let [, plugin] in Iterator(plugins.contexts))
|
||||
@@ -1002,6 +1023,16 @@ unlet s:cpo_save
|
||||
}]);
|
||||
|
||||
},
|
||||
modes: function (dactyl, modules, window) {
|
||||
const { commandline, modes } = modules;
|
||||
|
||||
modes.addMode("FILE_INPUT", {
|
||||
extended: true,
|
||||
description: "Active when selecting a file",
|
||||
bases: [modes.COMMAND_LINE],
|
||||
input: true
|
||||
});
|
||||
},
|
||||
options: function (dactyl, modules, window) {
|
||||
const { options } = modules;
|
||||
|
||||
|
||||
@@ -176,6 +176,7 @@ var Overlay = Module("Overlay", {
|
||||
"io",
|
||||
"mappings",
|
||||
"marks",
|
||||
"mow",
|
||||
"options",
|
||||
"statusline",
|
||||
"styles",
|
||||
@@ -203,12 +204,14 @@ var Overlay = Module("Overlay", {
|
||||
modules.loaded = loaded;
|
||||
|
||||
function init(module) {
|
||||
let name = module.constructor.className;
|
||||
|
||||
function init(func, mod)
|
||||
function () defineModule.time(module.className || module.constructor.className, mod,
|
||||
func, module,
|
||||
func, modules[name],
|
||||
modules.dactyl, modules, window);
|
||||
|
||||
set.add(loaded, module.constructor.className);
|
||||
set.add(loaded, name);
|
||||
for (let [mod, func] in Iterator(module.INIT)) {
|
||||
if (mod in loaded)
|
||||
init(func, mod)();
|
||||
@@ -240,7 +243,7 @@ var Overlay = Module("Overlay", {
|
||||
|
||||
defineModule.loadLog.push("Load" + (isString(prereq) ? " " + prereq + " dependency: " : ": ") + module.className);
|
||||
if (frame && frame.filename)
|
||||
defineModule.loadLog.push(" from: " + frame.filename + ":" + frame.lineNumber);
|
||||
defineModule.loadLog.push(" from: " + frame.filename.replace(/.* -> /, "") + ":" + frame.lineNumber);
|
||||
|
||||
delete modules[module.className];
|
||||
modules[module.className] = defineModule.time(module.className, "init", module);
|
||||
|
||||
@@ -138,7 +138,9 @@ var Template = Module("Template", {
|
||||
init.supercall(this, node);
|
||||
|
||||
let obj = params.eventTarget;
|
||||
for (let [event, handler] in Iterator(obj[this.getAttribute("events") || "events"]))
|
||||
let events = obj[this.getAttribute("events") || "events"];
|
||||
|
||||
for (let [event, handler] in Iterator(events))
|
||||
node.addEventListener(event, obj.closure(handler), false);
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user