X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fcontent%2Feditor.js;fp=common%2Fcontent%2Feditor.js;h=d98fa950da6b4f8ad99cc7431beaee07762cd034;hb=354a049cce8415487552ce405cce167b7071fe1f;hp=01a25ebddb60346e5412d735ae2422b5716a99e1;hpb=3d837eb266a3a01d424192aa4ec1a167366178c5;p=dactyl.git diff --git a/common/content/editor.js b/common/content/editor.js index 01a25eb..d98fa95 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2011 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // Copyright (c) 2006-2009 by Martin Stubenschrott // // This work is licensed for reuse under an MIT license. Details are @@ -304,7 +304,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { // Skip to any requested offset. count = Math.abs(offset); - Editor.extendRange(range, offset > 0, { test: function (c) !!count-- }, true); + Editor.extendRange(range, offset > 0, + { test: c => !!count-- }, + true); range.collapse(offset < 0); return range; @@ -381,7 +383,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { textBox = null; let line, column; - let keepFocus = modes.stack.some(function (m) isinstance(m.main, modes.COMMAND_LINE)); + let keepFocus = modes.stack.some(m => isinstance(m.main, modes.COMMAND_LINE)); if (!forceEditing && textBox && textBox.type == "password") { commandline.input(_("editor.prompt.editPassword") + " ", @@ -400,7 +402,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { var editor_ = window.GetCurrentEditor ? GetCurrentEditor() : Editor.getEditor(document.commandDispatcher.focusedWindow); dactyl.assert(editor_); - text = Array.map(editor_.rootElement.childNodes, function (e) DOM.stringify(e, true)).join(""); + text = Array.map(editor_.rootElement.childNodes, + e => DOM.stringify(e, true)) + .join(""); if (!editor_.selection.rangeCount) var sel = ""; @@ -1131,7 +1135,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { "<*-Home>", "<*-End>", "<*-PageUp>", "<*-PageDown>", "", "", "<*-Tab>"], "Handled by " + config.host, - function () Events.PASS_THROUGH); + () => Events.PASS_THROUGH); mappings.add([modes.INSERT], ["", ""], "Expand Insert mode abbreviation", @@ -1316,7 +1320,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { var range = editor.selectedRange; if (range.collapsed) { count = count || 1; - Editor.extendRange(range, true, { test: function (c) !!count-- }, true); + Editor.extendRange(range, true, { test: c => !!count-- }, true); } editor.mungeRange(range, munger, count != null); @@ -1327,19 +1331,19 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { let bind = function bind(...args) mappings.add.apply(mappings, [[modes.AUTOCOMPLETE]].concat(args)); bind([""], "Return to Insert mode", - function () Events.PASS_THROUGH); + () => Events.PASS_THROUGH); bind([""], "Return to Insert mode", function () { events.feedkeys("", { skipmap: true }); }); bind([""], "Select the previous autocomplete result", - function () Events.PASS_THROUGH); + () => Events.PASS_THROUGH); bind([""], "Select the previous autocomplete result", function () { events.feedkeys("", { skipmap: true }); }); bind([""], "Select the next autocomplete result", - function () Events.PASS_THROUGH); + () => Events.PASS_THROUGH); bind([""], "Select the next autocomplete result", function () { events.feedkeys("", { skipmap: true }); }); @@ -1349,9 +1353,12 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { "The external text editor", "string", 'gvim -f + +"sil! call cursor(0, )" ', { format: function (obj, value) { - let args = commands.parseArgs(value || this.value, { argCount: "*", allowUnknownOptions: true }) - .map(util.compileMacro).filter(function (fmt) fmt.valid(obj)) - .map(function (fmt) fmt(obj)); + let args = commands.parseArgs(value || this.value, + { argCount: "*", allowUnknownOptions: true }) + .map(util.compileMacro) + .filter(fmt => fmt.valid(obj)) + .map(fmt => fmt(obj)); + if (obj["file"] && !this.has("file")) args.push(obj["file"]); return args; @@ -1359,7 +1366,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { has: function (key) Set.has(util.compileMacro(this.value).seen, key), validator: function (value) { this.format({}, value); - return Object.keys(util.compileMacro(value).seen).every(function (k) ["column", "file", "line"].indexOf(k) >= 0); + return Object.keys(util.compileMacro(value).seen) + .every(k => ["column", "file", "line"].indexOf(k) >= 0); } });