X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fcontent%2Feditor.js;fp=common%2Fcontent%2Feditor.js;h=38153e48fae087863ca8516a4746385aabb04b82;hb=0bcd111e64a8cb0f8019a4cb3270fc5b46270a1b;hp=d98fa950da6b4f8ad99cc7431beaee07762cd034;hpb=4385b68da3a031ef7347f966df57b6e52d48ec94;p=dactyl.git diff --git a/common/content/editor.js b/common/content/editor.js index d98fa95..38153e4 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2013 Kris Maglione +// Copyright (c) 2008-2014 Kris Maglione // Copyright (c) 2006-2009 by Martin Stubenschrott // // This work is licensed for reuse under an MIT license. Details are @@ -46,7 +46,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { }, this); }, - defaultRegister: "*", + defaultRegister: "*+", selectionRegisters: { "*": "selection", @@ -64,11 +64,12 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { if (name == null) name = editor.currentRegister || editor.defaultRegister; + name = String(name)[0]; if (name == '"') name = 0; if (name == "_") var res = null; - else if (Set.has(this.selectionRegisters, name)) + else if (hasOwnProperty(this.selectionRegisters, name)) res = { text: dactyl.clipboardRead(this.selectionRegisters[name]) || "" }; else if (!/^[0-9]$/.test(name)) res = this.registers.get(name); @@ -101,17 +102,19 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { value = DOM.stringify(value); value = { text: value, isLine: modes.extended & modes.LINE, timestamp: Date.now() * 1000 }; - if (name == '"') - name = 0; - if (name == "_") - ; - else if (Set.has(this.selectionRegisters, name)) - dactyl.clipboardWrite(value.text, verbose, this.selectionRegisters[name]); - else if (!/^[0-9]$/.test(name)) - this.registers.set(name, value); - else { - this.registerRing.insert(value, name); - this.registerRing.truncate(10); + for (let n of String(name)) { + if (n == '"') + n = 0; + if (n == "_") + ; + else if (hasOwnProperty(this.selectionRegisters, n)) + dactyl.clipboardWrite(value.text, verbose, this.selectionRegisters[n]); + else if (!/^[0-9]$/.test(n)) + this.registers.set(n, value); + else { + this.registerRing.insert(value, n); + this.registerRing.truncate(10); + } } }, @@ -386,8 +389,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { let keepFocus = modes.stack.some(m => isinstance(m.main, modes.COMMAND_LINE)); if (!forceEditing && textBox && textBox.type == "password") { - commandline.input(_("editor.prompt.editPassword") + " ", - function (resp) { + commandline.input(_("editor.prompt.editPassword") + " ") + .then(function (resp) { if (resp && resp.match(/^y(es)?$/i)) editor.editFieldExternally(true); }); @@ -424,7 +427,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { column = 1 + pre.replace(/[^]*\n/, "").length; let origGroup = DOM(textBox).highlight.toString(); - let cleanup = util.yieldable(function cleanup(error) { + let cleanup = promises.task(function cleanup(error) { if (timer) timer.cancel(); @@ -443,9 +446,11 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { DOM(textBox).highlight.remove("EditorEditing"); if (!keepFocus) dactyl.focus(textBox); + for (let group in values(blink.concat(blink, ""))) { highlight.highlightNode(textBox, origGroup + " " + group); - yield 100; + + yield promises.sleep(100); } } }); @@ -760,9 +765,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { completion: function initCompletion() { completion.register = function complete_register(context) { context = context.fork("registers"); - context.keys = { text: util.identity, description: editor.closure.getRegister }; + context.keys = { text: util.identity, description: editor.bound.getRegister }; - context.match = function (r) !this.filter || ~this.filter.indexOf(r); + context.match = function (r) !this.filter || this.filter.contains(r); context.fork("clipboard", 0, this, function (ctxt) { ctxt.match = context.match; @@ -1363,11 +1368,12 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { args.push(obj["file"]); return args; }, - has: function (key) Set.has(util.compileMacro(this.value).seen, key), + has: function (key) util.compileMacro(this.value).seen.has(key), validator: function (value) { this.format({}, value); - return Object.keys(util.compileMacro(value).seen) - .every(k => ["column", "file", "line"].indexOf(k) >= 0); + let allowed = RealSet(["column", "file", "line"]); + return [k for (k of util.compileMacro(value).seen)] + .every(k => allowed.has(k)); } });