diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index 8b741d9a..9bec779b 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -115,9 +115,8 @@ var Bookmarks = Module("bookmarks", { if (charset != null && charset !== "UTF-8") options["-charset"] = charset; - commandline.open(":", - commands.commandToString({ command: "bmark", options: options, arguments: [url] }) + " -keyword ", - modes.EX); + CommandExMode().open( + commands.commandToString({ command: "bmark", options: options, arguments: [url] }) + " -keyword "); }, /** @@ -213,7 +212,7 @@ var Bookmarks = Module("bookmarks", { return iter(services.browserSearch.getVisibleEngines({})).map(function ([, engine]) { let alias = engine.alias; if (!alias || !/^[a-z-]+$/.test(alias)) - alias = engine.name.replace(/[a-z_-]+/i, "-").replace(/^-|-$/, "").toLowerCase(); + alias = engine.name.replace(/[^a-z_-]+/gi, "-").replace(/^-|-$/, "").toLowerCase(); if (!alias) alias = "search"; // for search engines which we can't find a suitable alias @@ -249,7 +248,7 @@ var Bookmarks = Module("bookmarks", { if (engine && engine.supportsResponseType(responseType)) var queryURI = engine.getSubmission(query, responseType).uri.spec; if (!queryURI) - return []; + return (callback || util.identity)([]); function process(resp) { let results = []; @@ -582,9 +581,8 @@ var Bookmarks = Module("bookmarks", { options["-charset"] = content.document.characterSet; } - commandline.open(":", - commands.commandToString({ command: "bmark", options: options, arguments: [buffer.uri.spec] }), - modes.EX); + CommandExMode().open( + commands.commandToString({ command: "bmark", options: options, arguments: [buffer.uri.spec] })); }); mappings.add(myModes, ["A"], diff --git a/common/content/browser.js b/common/content/browser.js index 1be4fcfb..ac647fee 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -65,33 +65,33 @@ var Browser = Module("browser", { mappings: function () { mappings.add([modes.NORMAL], - ["y"], "Yank current location to the clipboard", + ["y", ""], "Yank current location to the clipboard", function () { dactyl.clipboardWrite(buffer.uri.spec, true); }); // opening websites mappings.add([modes.NORMAL], ["o"], "Open one or more URLs", - function () { commandline.open(":", "open ", modes.EX); }); + function () { CommandExMode().open("open "); }); mappings.add([modes.NORMAL], ["O"], "Open one or more URLs, based on current location", - function () { commandline.open(":", "open " + buffer.uri.spec, modes.EX); }); + function () { CommandExMode().open("open " + buffer.uri.spec); }); mappings.add([modes.NORMAL], ["t"], "Open one or more URLs in a new tab", - function () { commandline.open(":", "tabopen ", modes.EX); }); + function () { CommandExMode().open("tabopen "); }); mappings.add([modes.NORMAL], ["T"], "Open one or more URLs in a new tab, based on current location", - function () { commandline.open(":", "tabopen " + buffer.uri.spec, modes.EX); }); + function () { CommandExMode().open("tabopen " + buffer.uri.spec); }); mappings.add([modes.NORMAL], ["w"], "Open one or more URLs in a new window", - function () { commandline.open(":", "winopen ", modes.EX); }); + function () { CommandExMode().open("winopen "); }); mappings.add([modes.NORMAL], ["W"], "Open one or more URLs in a new window, based on current location", - function () { commandline.open(":", "winopen " + buffer.uri.spec, modes.EX); }); + function () { CommandExMode().open("winopen " + buffer.uri.spec); }); mappings.add([modes.NORMAL], [""], "Increment last number in URL", diff --git a/common/content/buffer.js b/common/content/buffer.js index 2cdbae5b..020d9bdd 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -766,25 +766,25 @@ var Buffer = Module("buffer", { try { window.urlSecurityCheck(uri.spec, doc.nodePrincipal); - commandline.input("Save link: ", function (path) { - let file = io.File(path); - if (file.exists() && file.isDirectory()) - file.append(buffer.getDefaultNames(elem)[0][0]); + io.CommandFileMode("Save link: ", { + onSubmit: function (path) { + let file = io.File(path); + if (file.exists() && file.isDirectory()) + file.append(buffer.getDefaultNames(elem)[0][0]); - try { - if (!file.exists()) - file.create(File.NORMAL_FILE_TYPE, octal(644)); - } - catch (e) { - util.assert(false, "Invalid destination: " + e.name); - } + try { + if (!file.exists()) + file.create(File.NORMAL_FILE_TYPE, octal(644)); + } + catch (e) { + util.assert(false, "Invalid destination: " + e.name); + } - buffer.saveURI(uri, file); - }, { - autocomplete: true, - completer: function (context) completion.savePage(context, elem), - history: "file" - }); + buffer.saveURI(uri, file); + }, + + completer: function (context) completion.savePage(context, elem) + }).open(); } catch (e) { dactyl.echoerr(e); @@ -1360,17 +1360,15 @@ var Buffer = Module("buffer", { }, openUploadPrompt: function openUploadPrompt(elem) { - commandline.input("Upload file: ", function (path) { - let file = io.File(path); - dactyl.assert(file.exists()); + io.CommandFileMode("Upload file: ", { + onSubmit: function (path) { + let file = io.File(path); + dactyl.assert(file.exists()); - elem.value = file.path; - events.dispatch(elem, events.create(elem.ownerDocument, "change", {})); - }, { - completer: function (context) completion.file(context), - default: elem.value, - history: "file" - }); + elem.value = file.path; + events.dispatch(elem, events.create(elem.ownerDocument, "change", {})); + } + }).open(elem.value); } }, { commands: function () { @@ -1422,7 +1420,7 @@ var Buffer = Module("buffer", { let arg = args[0]; let opt = options.get("pageinfo"); - dactyl.assert(opt.validator(opt.parse(arg)), "E475: Invalid argument: " + arg); + dactyl.assert(!arg || opt.validator(opt.parse(arg)), "E475: Invalid argument: " + arg); buffer.showPageInfo(true, arg); }, { @@ -1530,7 +1528,8 @@ var Buffer = Module("buffer", { if (/^>>/.test(context.filter)) context.advance(/^>>\s*/.exec(context.filter)[0].length); - return completion.savePage(context, content.document); + completion.savePage(context, content.document); + context.fork("file", 0, completion, "file"); }, literal: 0 }); @@ -1642,7 +1641,6 @@ var Buffer = Module("buffer", { this, function (context) { context.completions = buffer.getDefaultNames(node); }); - return context.fork("files", 0, completion, "file"); }; }, events: function () { @@ -1653,7 +1651,7 @@ var Buffer = Module("buffer", { mappings: function () { var myModes = config.browserModes; - mappings.add(myModes, ["."], + mappings.add(myModes, [".", ""], "Repeat the last key event", function (args) { if (mappings.repeat) { @@ -1672,31 +1670,31 @@ var Buffer = Module("buffer", { function () { ex.stop(); }); // scrolling - mappings.add(myModes, ["j", "", ""], + mappings.add(myModes, ["j", "", "", ""], "Scroll document down", function (args) { buffer.scrollVertical("lines", Math.max(args.count, 1)); }, { count: true }); - mappings.add(myModes, ["k", "", ""], + mappings.add(myModes, ["k", "", "", ""], "Scroll document up", function (args) { buffer.scrollVertical("lines", -Math.max(args.count, 1)); }, { count: true }); - mappings.add(myModes, dactyl.has("mail") ? ["h"] : ["h", ""], + mappings.add(myModes, dactyl.has("mail") ? ["h", ""] : ["h", "", ""], "Scroll document to the left", function (args) { buffer.scrollHorizontal("columns", -Math.max(args.count, 1)); }, { count: true }); - mappings.add(myModes, dactyl.has("mail") ? ["l"] : ["l", ""], + mappings.add(myModes, dactyl.has("mail") ? ["l", ""] : ["l", "", ""], "Scroll document to the right", function (args) { buffer.scrollHorizontal("columns", Math.max(args.count, 1)); }, { count: true }); - mappings.add(myModes, ["0", "^"], + mappings.add(myModes, ["0", "^", ""], "Scroll to the absolute left of the document", function () { buffer.scrollToPercent(0, null); }); - mappings.add(myModes, ["$"], + mappings.add(myModes, ["$", ""], "Scroll to the absolute right of the document", function () { buffer.scrollToPercent(100, null); }); @@ -1710,7 +1708,7 @@ var Buffer = Module("buffer", { function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 100); }, { count: true }); - mappings.add(myModes, ["%"], + mappings.add(myModes, ["%", ""], "Scroll to {count} percent of the document", function (args) { dactyl.assert(args.count > 0 && args.count <= 100); @@ -1718,59 +1716,59 @@ var Buffer = Module("buffer", { }, { count: true }); - mappings.add(myModes, [""], + mappings.add(myModes, ["", ""], "Scroll window downwards in the buffer", function (args) { buffer._scrollByScrollSize(args.count, true); }, { count: true }); - mappings.add(myModes, [""], + mappings.add(myModes, ["", ""], "Scroll window upwards in the buffer", function (args) { buffer._scrollByScrollSize(args.count, false); }, { count: true }); - mappings.add(myModes, ["", "", ""], + mappings.add(myModes, ["", "", "", ""], "Scroll up a full page", function (args) { buffer.scrollVertical("pages", -Math.max(args.count, 1)); }, { count: true }); - mappings.add(myModes, ["", "", ""], + mappings.add(myModes, ["", "", "", ""], "Scroll down a full page", function (args) { buffer.scrollVertical("pages", Math.max(args.count, 1)); }, { count: true }); - mappings.add(myModes, ["]f"], + mappings.add(myModes, ["]f", ""], "Focus next frame", function (args) { buffer.shiftFrameFocus(Math.max(args.count, 1)); }, { count: true }); - mappings.add(myModes, ["[f"], + mappings.add(myModes, ["[f", ""], "Focus previous frame", function (args) { buffer.shiftFrameFocus(-Math.max(args.count, 1)); }, { count: true }); - mappings.add(myModes, ["]]"], + mappings.add(myModes, ["]]", ""], "Follow the link labeled 'next' or '>' if it exists", function (args) { buffer.findLink("next", options["nextpattern"], (args.count || 1) - 1, true); }, { count: true }); - mappings.add(myModes, ["[["], + mappings.add(myModes, ["[[", ""], "Follow the link labeled 'prev', 'previous' or '<' if it exists", function (args) { buffer.findLink("previous", options["previouspattern"], (args.count || 1) - 1, true); }, { count: true }); - mappings.add(myModes, ["gf"], + mappings.add(myModes, ["gf", ""], "Toggle between rendered and source view", function () { buffer.viewSource(null, false); }); - mappings.add(myModes, ["gF"], + mappings.add(myModes, ["gF", ""], "View source with an external editor", function () { buffer.viewSource(null, true); }); - mappings.add(myModes, ["gi"], + mappings.add(myModes, ["gi", ""], "Focus last used input field", function (args) { let elem = buffer.lastInputField; @@ -1810,7 +1808,7 @@ var Buffer = Module("buffer", { dactyl.open(url, { from: "paste", where: dactyl.NEW_TAB, background: true }); }); - mappings.add(myModes, ["p", ""], + mappings.add(myModes, ["p", "", ""], "Open (put) a URL based on the current clipboard contents in the current buffer", function () { let url = dactyl.clipboardRead(); @@ -1818,7 +1816,7 @@ var Buffer = Module("buffer", { dactyl.open(url); }); - mappings.add(myModes, ["P"], + mappings.add(myModes, ["P", ""], "Open (put) a URL based on the current clipboard contents in a new buffer", function () { let url = dactyl.clipboardRead(); @@ -1827,16 +1825,16 @@ var Buffer = Module("buffer", { }); // reloading - mappings.add(myModes, ["r"], + mappings.add(myModes, ["r", ""], "Reload the current web page", function () { tabs.reload(tabs.getTab(), false); }); - mappings.add(myModes, ["R"], + mappings.add(myModes, ["R", ""], "Reload while skipping the cache", function () { tabs.reload(tabs.getTab(), true); }); // yanking - mappings.add(myModes, ["Y"], + mappings.add(myModes, ["Y", ""], "Copy selected text or current word", function () { let sel = buffer.getCurrentWord(); @@ -1845,62 +1843,62 @@ var Buffer = Module("buffer", { }); // zooming - mappings.add(myModes, ["zi", "+"], + mappings.add(myModes, ["zi", "+", ""], "Enlarge text zoom of current web page", function (args) { buffer.zoomIn(Math.max(args.count, 1), false); }, { count: true }); - mappings.add(myModes, ["zm"], + mappings.add(myModes, ["zm", ""], "Enlarge text zoom of current web page by a larger amount", function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, false); }, { count: true }); - mappings.add(myModes, ["zo", "-"], + mappings.add(myModes, ["zo", "-", ""], "Reduce text zoom of current web page", function (args) { buffer.zoomOut(Math.max(args.count, 1), false); }, { count: true }); - mappings.add(myModes, ["zr"], + mappings.add(myModes, ["zr", ""], "Reduce text zoom of current web page by a larger amount", function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, false); }, { count: true }); - mappings.add(myModes, ["zz"], + mappings.add(myModes, ["zz", ""], "Set text zoom value of current web page", function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, false); }, { count: true }); - mappings.add(myModes, ["ZI", "zI"], + mappings.add(myModes, ["ZI", "zI", ""], "Enlarge full zoom of current web page", function (args) { buffer.zoomIn(Math.max(args.count, 1), true); }, { count: true }); - mappings.add(myModes, ["ZM", "zM"], + mappings.add(myModes, ["ZM", "zM", ""], "Enlarge full zoom of current web page by a larger amount", function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, true); }, { count: true }); - mappings.add(myModes, ["ZO", "zO"], + mappings.add(myModes, ["ZO", "zO", ""], "Reduce full zoom of current web page", function (args) { buffer.zoomOut(Math.max(args.count, 1), true); }, { count: true }); - mappings.add(myModes, ["ZR", "zR"], + mappings.add(myModes, ["ZR", "zR", ""], "Reduce full zoom of current web page by a larger amount", function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, true); }, { count: true }); - mappings.add(myModes, ["zZ"], + mappings.add(myModes, ["zZ", ""], "Set full zoom value of current web page", function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, true); }, { count: true }); // page info - mappings.add(myModes, [""], + mappings.add(myModes, ["", ""], "Print the current file name", function () { buffer.showPageInfo(false); }); - mappings.add(myModes, ["g"], + mappings.add(myModes, ["g", ""], "Print file information", function () { buffer.showPageInfo(true); }); }, diff --git a/common/content/commandline.js b/common/content/commandline.js index 51ed7f5a..6e80147d 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -14,52 +14,18 @@ var CommandWidgets = Class("CommandWidgets", { init: function init() { let s = "dactyl-statusline-field-"; - let fontSize = util.computedStyle(document.documentElement).fontSize; - styles.registerSheet("resource://dactyl-skin/dactyl.css"); - styles.system.add("font-size", "dactyl://content/buffer.xhtml", - "body { font-size: " + fontSize + "; } \ - html|html > xul|scrollbar { visibility: collapse !important; }", - true); - XML.ignoreWhitespace = true; util.overlayWindow(window, { objects: { eventTarget: commandline }, append: - - - - - - - - - - - - -