mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 22:37:58 +01:00
Import part of top patch in queue: Add no-op option hive for plugin API reasons, cleanup some related code.
This commit is contained in:
@@ -154,13 +154,9 @@ var AutoCommands = Module("autocommands", {
|
|||||||
else
|
else
|
||||||
var { uri, doc } = buffer;
|
var { uri, doc } = buffer;
|
||||||
|
|
||||||
let baseArgs = update({ doc: doc }, arguments[1]);
|
|
||||||
|
|
||||||
event = event.toLowerCase();
|
event = event.toLowerCase();
|
||||||
for (let hive in values(this.matchingHives(uri, doc))) {
|
for (let hive in values(this.matchingHives(uri, doc))) {
|
||||||
let args = update({},
|
let args = hive.makeArgs(doc, null, arguments[1]);
|
||||||
hive.argsExtra(baseArgs),
|
|
||||||
arguments[1]);
|
|
||||||
|
|
||||||
for (let autoCmd in values(hive._store))
|
for (let autoCmd in values(hive._store))
|
||||||
if (autoCmd.eventName === event && autoCmd.filter(uri, doc)) {
|
if (autoCmd.eventName === event && autoCmd.filter(uri, doc)) {
|
||||||
|
|||||||
@@ -463,7 +463,10 @@ var Buffer = Module("buffer", {
|
|||||||
else
|
else
|
||||||
flags = services.focus.FLAG_SHOWRING;
|
flags = services.focus.FLAG_SHOWRING;
|
||||||
|
|
||||||
if (!elem.dactylHadFocus && elem.value && elem.selectionStart == elem.selectionEnd)
|
if (!elem.dactylHadFocus && elem.value &&
|
||||||
|
elem instanceof HTMLInputElement &&
|
||||||
|
elem.selectionStart != null &&
|
||||||
|
elem.selectionStart == elem.selectionEnd)
|
||||||
elem.selectionStart = elem.selectionEnd = elem.value.length;
|
elem.selectionStart = elem.selectionEnd = elem.value.length;
|
||||||
|
|
||||||
dactyl.focus(elem, flags);
|
dactyl.focus(elem, flags);
|
||||||
|
|||||||
@@ -1684,18 +1684,23 @@ var Events = Module("events", {
|
|||||||
|
|
||||||
get pass() (this.flush(), this.pass),
|
get pass() (this.flush(), this.pass),
|
||||||
|
|
||||||
keepQuotes: true,
|
parse: function parse() {
|
||||||
|
let value = parse.superapply(this, arguments);
|
||||||
setter: function (values) {
|
value.forEach(function (filter) {
|
||||||
values.forEach(function (filter) {
|
|
||||||
let vals = Option.splitList(filter.result);
|
let vals = Option.splitList(filter.result);
|
||||||
filter.keys = events.fromString(vals[0]).map(events.closure.toString);
|
filter.keys = events.fromString(vals[0]).map(events.closure.toString);
|
||||||
|
|
||||||
filter.commandKeys = vals.slice(1).map(events.closure.canonicalKeys);
|
filter.commandKeys = vals.slice(1).map(events.closure.canonicalKeys);
|
||||||
filter.inputKeys = filter.commandKeys.filter(bind("test", /^<[ACM]-/));
|
filter.inputKeys = filter.commandKeys.filter(bind("test", /^<[ACM]-/));
|
||||||
});
|
});
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
|
||||||
|
keepQuotes: true,
|
||||||
|
|
||||||
|
setter: function (value) {
|
||||||
this.flush();
|
this.flush();
|
||||||
return values;
|
return value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -119,12 +119,9 @@ var Map = Class("Map", {
|
|||||||
.map(function ([i, prop]) [prop, this[i]], arguments)
|
.map(function ([i, prop]) [prop, this[i]], arguments)
|
||||||
.toObject();
|
.toObject();
|
||||||
|
|
||||||
let orig = args;
|
args = this.hive.makeArgs(this.hive.group.lastDocument,
|
||||||
args = update({
|
contexts.context,
|
||||||
context: contexts.context,
|
args);
|
||||||
doc: this.hive.group.lastDocument
|
|
||||||
}, args);
|
|
||||||
update(args, this.hive.argsExtra(args), orig);
|
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
function repeat() self.action(args)
|
function repeat() self.action(args)
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ var Group = Class("Group", {
|
|||||||
|
|
||||||
argsExtra: function argsExtra() ({}),
|
argsExtra: function argsExtra() ({}),
|
||||||
|
|
||||||
|
makeArgs: function makeArgs(doc, context, args) {
|
||||||
|
let res = update({ doc: doc, context: context }, args);
|
||||||
|
return update(this.argsExtra(res), args);
|
||||||
|
},
|
||||||
|
|
||||||
get toStringParams() [this.name],
|
get toStringParams() [this.name],
|
||||||
|
|
||||||
get builtin() this.modules.contexts.builtinGroups.indexOf(this) >= 0,
|
get builtin() this.modules.contexts.builtinGroups.indexOf(this) >= 0,
|
||||||
@@ -288,7 +293,10 @@ var Contexts = Module("contexts", {
|
|||||||
groups: { value: this.activeGroups(uri) }
|
groups: { value: this.activeGroups(uri) }
|
||||||
}),
|
}),
|
||||||
|
|
||||||
activeGroups: function (uri, doc) {
|
activeGroups: function (uri) {
|
||||||
|
if (uri instanceof Ci.nsIDOMDocument)
|
||||||
|
var [doc, uri] = [uri, uri.documentURIObject || util.newURI(uri.documentURI)];
|
||||||
|
|
||||||
if (!uri)
|
if (!uri)
|
||||||
var { uri, doc } = this.modules.buffer;
|
var { uri, doc } = this.modules.buffer;
|
||||||
|
|
||||||
@@ -463,6 +471,7 @@ var Contexts = Module("contexts", {
|
|||||||
get modifiable() this.group.modifiable,
|
get modifiable() this.group.modifiable,
|
||||||
|
|
||||||
get argsExtra() this.group.argsExtra,
|
get argsExtra() this.group.argsExtra,
|
||||||
|
get makeArgs() this.group.makeArgs,
|
||||||
get builtin() this.group.builtin,
|
get builtin() this.group.builtin,
|
||||||
|
|
||||||
get name() this.group.name,
|
get name() this.group.name,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ try {
|
|||||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
defineModule("options", {
|
defineModule("options", {
|
||||||
exports: ["Option", "Options", "ValueError", "options"],
|
exports: ["Option", "Options", "ValueError", "options"],
|
||||||
require: ["messages", "storage"],
|
require: ["contexts", "messages", "storage"],
|
||||||
use: ["commands", "completion", "config", "prefs", "services", "styles", "template", "util"]
|
use: ["commands", "completion", "config", "prefs", "services", "styles", "template", "util"]
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
@@ -757,6 +757,18 @@ var Option = Class("Option", {
|
|||||||
EXPORTED_SYMBOLS.push(class_.className);
|
EXPORTED_SYMBOLS.push(class_.className);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
var OptionHive = Class("OptionHive", Contexts.Hive, {
|
||||||
|
init: function init(group) {
|
||||||
|
init.supercall(this, group);
|
||||||
|
this.values = {};
|
||||||
|
this.has = Set.has(this.values);
|
||||||
|
},
|
||||||
|
|
||||||
|
add: function add(names, description, type, defaultValue, extraInfo) {
|
||||||
|
return this.modules.options.add(names, description, type, defaultValue, extraInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @instance options
|
* @instance options
|
||||||
*/
|
*/
|
||||||
@@ -764,6 +776,12 @@ var Options = Module("options", {
|
|||||||
Local: function Local(dactyl, modules, window) let ({ contexts } = modules) ({
|
Local: function Local(dactyl, modules, window) let ({ contexts } = modules) ({
|
||||||
init: function init() {
|
init: function init() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
update(this, {
|
||||||
|
hives: contexts.Hives("options", Class("OptionHive", OptionHive, { modules: modules })),
|
||||||
|
user: contexts.hives.options.user
|
||||||
|
});
|
||||||
|
|
||||||
this.needInit = [];
|
this.needInit = [];
|
||||||
this._options = [];
|
this._options = [];
|
||||||
this._optionMap = {};
|
this._optionMap = {};
|
||||||
@@ -853,6 +871,10 @@ var Options = Module("options", {
|
|||||||
*/
|
*/
|
||||||
add: function add(names, description, type, defaultValue, extraInfo) {
|
add: function add(names, description, type, defaultValue, extraInfo) {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
if (!util.isDactyl(Components.stack.caller))
|
||||||
|
deprecated.warn(add, "options.add", "group.options.add");
|
||||||
|
|
||||||
util.assert(type in Option.types,
|
util.assert(type in Option.types,
|
||||||
_("option.noSuchType", type),
|
_("option.noSuchType", type),
|
||||||
true);
|
true);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ FEATURES:
|
|||||||
locations in the history list).
|
locations in the history list).
|
||||||
9 clean up error message codes and document
|
9 clean up error message codes and document
|
||||||
9 option groups, including buffer-local and site-specific
|
9 option groups, including buffer-local and site-specific
|
||||||
|
9 add [count] support to :b* and :tab* commands where missing
|
||||||
8 wherever possible: get rid of dialogs and ask console-like dialog questions
|
8 wherever possible: get rid of dialogs and ask console-like dialog questions
|
||||||
or write error prompts directly on the webpage or with :echo()
|
or write error prompts directly on the webpage or with :echo()
|
||||||
8 add search capability to MOW
|
8 add search capability to MOW
|
||||||
@@ -32,7 +33,6 @@ FEATURES:
|
|||||||
7 make an option to disable session saving by default when you close Firefox
|
7 make an option to disable session saving by default when you close Firefox
|
||||||
7 :grep support (needs location list)
|
7 :grep support (needs location list)
|
||||||
6 :mksession
|
6 :mksession
|
||||||
6 add [count] support to :b* and :tab* commands where missing
|
|
||||||
6 check/correct spellings in insert mode with some mappings
|
6 check/correct spellings in insert mode with some mappings
|
||||||
6 add more autocommands (TabClose, TabOpen, TabChanged etc)
|
6 add more autocommands (TabClose, TabOpen, TabChanged etc)
|
||||||
6 Use ctrl-w+j/k/w to switch between sidebar, content, preview window
|
6 Use ctrl-w+j/k/w to switch between sidebar, content, preview window
|
||||||
|
|||||||
Reference in New Issue
Block a user