diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index fb936e3b..8b741d9a 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -115,8 +115,9 @@ var Bookmarks = Module("bookmarks", { if (charset != null && charset !== "UTF-8") options["-charset"] = charset; - CommandExMode().open( - commands.commandToString({ command: "bmark", options: options, arguments: [url] }) + " -keyword "); + commandline.open(":", + commands.commandToString({ command: "bmark", options: options, arguments: [url] }) + " -keyword ", + modes.EX); }, /** @@ -581,8 +582,9 @@ var Bookmarks = Module("bookmarks", { options["-charset"] = content.document.characterSet; } - CommandExMode().open( - commands.commandToString({ command: "bmark", options: options, arguments: [buffer.uri.spec] })); + commandline.open(":", + commands.commandToString({ command: "bmark", options: options, arguments: [buffer.uri.spec] }), + modes.EX); }); mappings.add(myModes, ["A"], diff --git a/common/content/browser.js b/common/content/browser.js index ac647fee..1be4fcfb 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 () { CommandExMode().open("open "); }); + function () { commandline.open(":", "open ", modes.EX); }); mappings.add([modes.NORMAL], ["O"], "Open one or more URLs, based on current location", - function () { CommandExMode().open("open " + buffer.uri.spec); }); + function () { commandline.open(":", "open " + buffer.uri.spec, modes.EX); }); mappings.add([modes.NORMAL], ["t"], "Open one or more URLs in a new tab", - function () { CommandExMode().open("tabopen "); }); + function () { commandline.open(":", "tabopen ", modes.EX); }); mappings.add([modes.NORMAL], ["T"], "Open one or more URLs in a new tab, based on current location", - function () { CommandExMode().open("tabopen " + buffer.uri.spec); }); + function () { commandline.open(":", "tabopen " + buffer.uri.spec, modes.EX); }); mappings.add([modes.NORMAL], ["w"], "Open one or more URLs in a new window", - function () { CommandExMode().open("winopen "); }); + function () { commandline.open(":", "winopen ", modes.EX); }); mappings.add([modes.NORMAL], ["W"], "Open one or more URLs in a new window, based on current location", - function () { CommandExMode().open("winopen " + buffer.uri.spec); }); + function () { commandline.open(":", "winopen " + buffer.uri.spec, modes.EX); }); mappings.add([modes.NORMAL], [""], "Increment last number in URL", diff --git a/common/content/buffer.js b/common/content/buffer.js index df6e2329..2cdbae5b 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); - io.CommandFileMode("Save link: ", { - onSubmit: function (path) { - let file = io.File(path); - if (file.exists() && file.isDirectory()) - file.append(buffer.getDefaultNames(elem)[0][0]); + commandline.input("Save link: ", 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); - }, - - completer: function (context) completion.savePage(context, elem) - }).open(); + buffer.saveURI(uri, file); + }, { + autocomplete: true, + completer: function (context) completion.savePage(context, elem), + history: "file" + }); } catch (e) { dactyl.echoerr(e); @@ -1360,15 +1360,17 @@ var Buffer = Module("buffer", { }, openUploadPrompt: function openUploadPrompt(elem) { - io.CommandFileMode("Upload file: ", { - onSubmit: function (path) { - let file = io.File(path); - dactyl.assert(file.exists()); + commandline.input("Upload file: ", function (path) { + let file = io.File(path); + dactyl.assert(file.exists()); - elem.value = file.path; - events.dispatch(elem, events.create(elem.ownerDocument, "change", {})); - } - }).open(elem.value); + elem.value = file.path; + events.dispatch(elem, events.create(elem.ownerDocument, "change", {})); + }, { + completer: function (context) completion.file(context), + default: elem.value, + history: "file" + }); } }, { commands: function () { @@ -1528,8 +1530,7 @@ var Buffer = Module("buffer", { if (/^>>/.test(context.filter)) context.advance(/^>>\s*/.exec(context.filter)[0].length); - completion.savePage(context, content.document); - context.fork("file", 0, completion, "file"); + return completion.savePage(context, content.document); }, literal: 0 }); @@ -1641,6 +1642,7 @@ var Buffer = Module("buffer", { this, function (context) { context.completions = buffer.getDefaultNames(node); }); + return context.fork("files", 0, completion, "file"); }; }, events: function () { @@ -1651,7 +1653,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) { @@ -1670,31 +1672,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); }); @@ -1708,7 +1710,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); @@ -1716,59 +1718,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; @@ -1808,7 +1810,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(); @@ -1816,7 +1818,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(); @@ -1825,16 +1827,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(); @@ -1843,62 +1845,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 976b04d5..6fa3c94f 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -14,18 +14,52 @@ 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: + + + + + + + + + + + + +