mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 02:47:58 +01:00
Add some MOW bindings to REPL mode. Add counts to MOW bindings.
This commit is contained in:
@@ -306,13 +306,13 @@ var MOW = Module("mow", {
|
||||
let bind = function bind(keys, description, action, test, default_) {
|
||||
mappings.add([modes.OUTPUT_MULTILINE],
|
||||
keys, description,
|
||||
function (command) {
|
||||
function (args) {
|
||||
if (!options["more"])
|
||||
var res = PASS;
|
||||
else if (test && !test(command))
|
||||
else if (test && !test(args))
|
||||
res = default_;
|
||||
else
|
||||
res = action.call(command);
|
||||
res = action.call(this, args);
|
||||
|
||||
if (res === PASS || res === DROP)
|
||||
modes.pop();
|
||||
@@ -321,48 +321,50 @@ var MOW = Module("mow", {
|
||||
if (res === BEEP)
|
||||
dactyl.beep();
|
||||
else if (res === PASS)
|
||||
events.feedkeys(command);
|
||||
events.feedkeys(args.command);
|
||||
}, {
|
||||
count: action.length > 0
|
||||
});
|
||||
};
|
||||
|
||||
bind(["j", "<C-e>", "<Down>"], "Scroll down one line",
|
||||
function () { mow.scrollVertical("lines", 1); },
|
||||
function ({ count }) { mow.scrollVertical("lines", 1 * (count || 1)); },
|
||||
function () mow.isScrollable(1), BEEP);
|
||||
|
||||
bind(["k", "<C-y>", "<Up>"], "Scroll up one line",
|
||||
function () { mow.scrollVertical("lines", -1); },
|
||||
function ({ count }) { mow.scrollVertical("lines", -1 * (count || 1)); },
|
||||
function () mow.isScrollable(-1), BEEP);
|
||||
|
||||
bind(["<C-j>", "<C-m>", "<Return>"], "Scroll down one line, exit on last line",
|
||||
function () { mow.scrollVertical("lines", 1); },
|
||||
function ({ count }) { mow.scrollVertical("lines", 1 * (count || 1)); },
|
||||
function () mow.isScrollable(1), DROP);
|
||||
|
||||
// half page down
|
||||
bind(["<C-d>"], "Scroll down half a page",
|
||||
function () { mow.scrollVertical("pages", .5); },
|
||||
function ({ count }) { mow.scrollVertical("pages", .5 * (count || 1)); },
|
||||
function () mow.isScrollable(1), BEEP);
|
||||
|
||||
bind(["<C-f>", "<PageDown>"], "Scroll down one page",
|
||||
function () { mow.scrollVertical("pages", 1); },
|
||||
function ({ count }) { mow.scrollVertical("pages", 1 * (count || 1)); },
|
||||
function () mow.isScrollable(1), BEEP);
|
||||
|
||||
bind(["<Space>"], "Scroll down one page",
|
||||
function () { mow.scrollVertical("pages", 1); },
|
||||
function ({ count }) { mow.scrollVertical("pages", 1 * (count || 1)); },
|
||||
function () mow.isScrollable(1), DROP);
|
||||
|
||||
bind(["<C-u>"], "Scroll up half a page",
|
||||
function () { mow.scrollVertical("pages", -.5); },
|
||||
function ({ count }) { mow.scrollVertical("pages", -.5 * (count || 1)); },
|
||||
function () mow.isScrollable(-1), BEEP);
|
||||
|
||||
bind(["<C-b>", "<PageUp>"], "Scroll up half a page",
|
||||
function () { mow.scrollVertical("pages", -1); },
|
||||
function ({ count }) { mow.scrollVertical("pages", -1 * (count || 1)); },
|
||||
function () mow.isScrollable(-1), BEEP);
|
||||
|
||||
bind(["gg"], "Scroll to the beginning of output",
|
||||
function () { mow.scrollToPercent(null, 0); });
|
||||
|
||||
bind(["G"], "Scroll to the end of output",
|
||||
function () { mow.body.scrollTop = mow.body.scrollHeight; });
|
||||
function ({ count }) { mow.scrollToPercent(null, count || 100); });
|
||||
|
||||
// copy text to clipboard
|
||||
bind(["<C-y>"], "Yank selection to clipboard",
|
||||
|
||||
@@ -693,7 +693,7 @@ var JavaScript = Module("javascript", {
|
||||
});
|
||||
},
|
||||
commandline: function initCommandLine(dactyl, modules, window) {
|
||||
const { modes } = modules;
|
||||
const { Buffer, modes } = modules;
|
||||
|
||||
var REPL = Class("REPL", {
|
||||
init: function init(context) {
|
||||
@@ -741,7 +741,9 @@ var JavaScript = Module("javascript", {
|
||||
this.document, this);
|
||||
|
||||
return this.rootNode;
|
||||
})
|
||||
}),
|
||||
|
||||
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.rootNode].concat(args)),
|
||||
});
|
||||
|
||||
modules.CommandREPLMode = Class("CommandREPLMode", modules.CommandMode, {
|
||||
@@ -816,9 +818,29 @@ var JavaScript = Module("javascript", {
|
||||
mappings: function initMappings(dactyl, modules, window) {
|
||||
const { mappings, modes } = modules;
|
||||
|
||||
mappings.add([modes.REPL], ["<Return>"],
|
||||
"Accept the current input",
|
||||
function bind() mappings.add.apply(mappings,
|
||||
[[modes.REPL]].concat(Array.slice(arguments)))
|
||||
|
||||
bind(["<Return>"], "Accept the current input",
|
||||
function ({ self }) { self.accept(); });
|
||||
|
||||
bind(["<C-e>"], "Scroll down one line",
|
||||
function ({ self }) { self.repl.scrollVertical("lines", 1); });
|
||||
|
||||
bind(["<C-y>"], "Scroll up one line",
|
||||
function ({ self }) { self.repl.scrollVertical("lines", -1); });
|
||||
|
||||
bind(["<C-d>"], "Scroll down half a page",
|
||||
function ({ self }) { self.repl.scrollVertical("pages", .5); });
|
||||
|
||||
bind(["<C-f>", "<PageDown>"], "Scroll down one page",
|
||||
function ({ self }) { self.repl.scrollVertical("pages", 1); });
|
||||
|
||||
bind(["<C-u>"], "Scroll up half a page",
|
||||
function ({ self }) { self.repl.scrollVertical("pages", -.5); });
|
||||
|
||||
bind(["<C-b>", "<PageUp>"], "Scroll up half a page",
|
||||
function ({ self }) { self.repl.scrollVertical("pages", -1); });
|
||||
},
|
||||
options: function (dactyl, modules, window) {
|
||||
modules.options.add(["jsdebugger", "jsd"],
|
||||
|
||||
Reference in New Issue
Block a user