1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 23:47:58 +01:00

Cosmetic changes.

--HG--
branch : key-processing
This commit is contained in:
Kris Maglione
2011-01-23 22:23:20 -05:00
parent 6176b54e73
commit 3b43cde8df

View File

@@ -1668,6 +1668,13 @@ var CommandLine = Module("commandline", {
}, },
mappings: function () { mappings: function () {
mappings.add([modes.COMMAND],
[":"], "Enter command-line mode",
function () { commandline.open(":", "", modes.EX); });
let bind = function bind()
mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(Array.slice(arguments)))
// Any "non-keyword" character triggers abbreviation expansion // Any "non-keyword" character triggers abbreviation expansion
// TODO: Add "<CR>" and "<Tab>" to this list // TODO: Add "<CR>" and "<Tab>" to this list
// At the moment, adding "<Tab>" breaks tab completion. Adding // At the moment, adding "<Tab>" breaks tab completion. Adding
@@ -1675,23 +1682,21 @@ var CommandLine = Module("commandline", {
// TODO: Make non-keyword recognition smarter so that there need not // TODO: Make non-keyword recognition smarter so that there need not
// be two lists of the same characters (one here and a regexp in // be two lists of the same characters (one here and a regexp in
// mappings.js) // mappings.js)
mappings.add([modes.COMMAND_LINE], bind(["<Space>", '"', "'"], "Expand command line abbreviation",
["<Space>", '"', "'"], "Expand command line abbreviation", function () {
function () { commandline.resetCompletions();
commandline.resetCompletions(); editor.expandAbbreviation(modes.COMMAND_LINE);
editor.expandAbbreviation(modes.COMMAND_LINE); return Events.PASS;
return Events.PASS; });
});
mappings.add([modes.COMMAND_LINE], bind(["<Return>", "<C-j>", "<C-m>"], "Accept the current input",
["<Return>", "<C-j>", "<C-m>"], "Accept the current input", function (args) {
function (args) { commandline._keepCommand = userContext.hidden_option_command_afterimage;
commandline._keepCommand = userContext.hidden_option_command_afterimage; let mode = commandline.currentExtendedMode;
let mode = commandline.currentExtendedMode; commandline.currentExtendedMode = null; // Don't let modes.pop trigger "cancel"
commandline.currentExtendedMode = null; // Don't let modes.pop trigger "cancel" modes.pop();
modes.pop(); commandline.triggerCallback("submit", mode, commandline.command);
commandline.triggerCallback("submit", mode, commandline.command); });
});
[ [
[["<Up>", "<A-p>"], "previous matching", true, true], [["<Up>", "<A-p>"], "previous matching", true, true],
@@ -1699,46 +1704,35 @@ var CommandLine = Module("commandline", {
[["<Down>", "<A-n>"], "next matching", false, true], [["<Down>", "<A-n>"], "next matching", false, true],
[["<S-Down>", "<C-n>", "<PageDown>"], "next", false, false] [["<S-Down>", "<C-n>", "<PageDown>"], "next", false, false]
].forEach(function ([keys, desc, up, search]) { ].forEach(function ([keys, desc, up, search]) {
mappings.add([modes.COMMAND_LINE], bind(keys, "Recall the " + desc + " command line from the history list",
keys, "Recall the " + desc + " command line from the history list", function (args) {
function (args) { dactyl.assert(commandline._history);
dactyl.assert(commandline._history); commandline._history.select(up, search);
commandline._history.select(up, search); });
});
}); });
mappings.add([modes.COMMAND_LINE], bind(["<A-Tab>", "<Tab>"], "Select the next matching completion item",
["<A-Tab>", "<Tab>"], "Select the next matching completion item", function ({ events }) { commandline._tabTimer.tell(events[0]); });
function ({ events }) { commandline._tabTimer.tell(events[0]); });
mappings.add([modes.COMMAND_LINE], bind(["<A-S-Tab>", "<S-Tab>"], "Select the previous matching completion item",
["<A-S-Tab>", "<S-Tab>"], "Select the previous matching completion item", function ({ events }) { commandline._tabTimer.tell(events[0]); });
function ({ events }) { commandline._tabTimer.tell(events[0]); });
mappings.add([modes.COMMAND_LINE], bind(["<BS>", "<C-h>"], "Delete the previous character",
["<BS>", "<C-h>"], "Delete the previous character", function () {
function () { if (!commandline.command)
if (!commandline.command) modes.pop();
modes.pop(); else
else return Events.PASS;
return Events.PASS; });
});
mappings.add([modes.COMMAND_LINE], bind(["<C-]>", "<C-5>"], "Expand command line abbreviation",
["<C-]>", "<C-5>"], "Expand command line abbreviation", function () { editor.expandAbbreviation(modes.COMMAND_LINE); });
function () { editor.expandAbbreviation(modes.COMMAND_LINE); });
mappings.add([modes.NORMAL], bind(["g<"], "Redisplay the last command output",
["g<"], "Redisplay the last command output", function () {
function () { dactyl.assert(commandline._lastMowOutput, "No previous command output");
dactyl.assert(commandline._lastMowOutput, "No previous command output"); commandline._echoMultiline(commandline._lastMowOutput, commandline.HL_NORMAL);
commandline._echoMultiline(commandline._lastMowOutput, commandline.HL_NORMAL); });
});
// add the ":" mapping in all but insert mode mappings
mappings.add(modes.COMMAND,
[":"], "Enter command-line mode",
function () { commandline.open(":", "", modes.EX); });
let mow = modules.mow = { let mow = modules.mow = {
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)) __noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args))
@@ -1750,7 +1744,7 @@ var CommandLine = Module("commandline", {
const DROP = false; const DROP = false;
const BEEP = {}; const BEEP = {};
function bind(keys, description, action, test, default_) { bind = function bind(keys, description, action, test, default_) {
mappings.add([modes.OUTPUT_MULTILINE], mappings.add([modes.OUTPUT_MULTILINE],
keys, description, keys, description,
function (command) { function (command) {