mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-13 17:05:44 +01:00
Make caret visible while selected when in Visual Text Edit mode.
This commit is contained in:
@@ -1502,6 +1502,8 @@ var CommandLine = Module("commandline", {
|
||||
});
|
||||
},
|
||||
modes: function initModes() {
|
||||
initModes.require("editor");
|
||||
|
||||
modes.addMode("COMMAND_LINE", {
|
||||
char: "c",
|
||||
description: "Active when the command line is focused",
|
||||
|
||||
@@ -36,6 +36,7 @@ var Editor = Module("editor", {
|
||||
},
|
||||
|
||||
get selection() this.editor && this.editor.selection || null,
|
||||
get selectionController() this.editor && this.editor.selectionController || null,
|
||||
|
||||
get isCaret() modes.getStack(1).main == modes.CARET,
|
||||
get isTextEdit() modes.getStack(1).main == modes.TEXT_EDIT,
|
||||
@@ -514,7 +515,64 @@ var Editor = Module("editor", {
|
||||
return DOM(elem).editor;
|
||||
}
|
||||
}, {
|
||||
mappings: function () {
|
||||
modes: function init_modes() {
|
||||
modes.addMode("OPERATOR", {
|
||||
char: "o",
|
||||
description: "Mappings which move the cursor",
|
||||
bases: []
|
||||
});
|
||||
modes.addMode("VISUAL", {
|
||||
char: "v",
|
||||
description: "Active when text is selected",
|
||||
display: function () "VISUAL" + (this._extended & modes.LINE ? " LINE" : ""),
|
||||
bases: [modes.COMMAND],
|
||||
ownsFocus: true
|
||||
}, {
|
||||
enter: function (stack) {
|
||||
if (editor.selectionController)
|
||||
editor.selectionController.setCaretVisibilityDuringSelection(true);
|
||||
},
|
||||
leave: function (stack, newMode) {
|
||||
if (newMode.main == modes.CARET) {
|
||||
let selection = content.getSelection();
|
||||
if (selection && !selection.isCollapsed)
|
||||
selection.collapseToStart();
|
||||
}
|
||||
else if (stack.pop)
|
||||
editor.deselectText();
|
||||
}
|
||||
});
|
||||
modes.addMode("TEXT_EDIT", {
|
||||
char: "t",
|
||||
description: "Vim-like editing of input elements",
|
||||
bases: [modes.COMMAND],
|
||||
ownsFocus: true
|
||||
}, {
|
||||
onKeyPress: function (eventList) {
|
||||
const KILL = false, PASS = true;
|
||||
|
||||
// Hack, really.
|
||||
if (eventList[0].charCode || /^<(?:.-)*(?:BS|Del|C-h|C-w|C-u|C-k)>$/.test(DOM.Event.stringify(eventList[0]))) {
|
||||
dactyl.beep();
|
||||
return KILL;
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
});
|
||||
|
||||
modes.addMode("INSERT", {
|
||||
char: "i",
|
||||
description: "Active when an input element is focused",
|
||||
insert: true,
|
||||
ownsFocus: true
|
||||
});
|
||||
modes.addMode("AUTOCOMPLETE", {
|
||||
description: "Active when an input autocomplete pop-up is active",
|
||||
display: function () "AUTOCOMPLETE (insert)",
|
||||
bases: [modes.INSERT]
|
||||
});
|
||||
},
|
||||
mappings: function init_mappings() {
|
||||
|
||||
Map.types["editor"] = {
|
||||
preExecute: function preExecute(args) {
|
||||
@@ -1039,8 +1097,7 @@ var Editor = Module("editor", {
|
||||
bind(["<C-n>"], "Select the next autocomplete result",
|
||||
function () { events.feedkeys("<Down>", { skipmap: true }); });
|
||||
},
|
||||
|
||||
options: function () {
|
||||
options: function init_options() {
|
||||
options.add(["editor"],
|
||||
"The external text editor",
|
||||
"string", 'gvim -f +<line> +"sil! call cursor(0, <column>)" <file>', {
|
||||
|
||||
@@ -57,28 +57,6 @@ var Modes = Module("modes", {
|
||||
description: "Active when nothing is focused",
|
||||
bases: [this.COMMAND]
|
||||
});
|
||||
this.addMode("OPERATOR", {
|
||||
char: "o",
|
||||
description: "Mappings which move the cursor",
|
||||
bases: []
|
||||
});
|
||||
this.addMode("VISUAL", {
|
||||
char: "v",
|
||||
description: "Active when text is selected",
|
||||
display: function () "VISUAL" + (this._extended & modes.LINE ? " LINE" : ""),
|
||||
bases: [this.COMMAND],
|
||||
ownsFocus: true
|
||||
}, {
|
||||
leave: function (stack, newMode) {
|
||||
if (newMode.main == modes.CARET) {
|
||||
let selection = content.getSelection();
|
||||
if (selection && !selection.isCollapsed)
|
||||
selection.collapseToStart();
|
||||
}
|
||||
else if (stack.pop)
|
||||
editor.deselectText();
|
||||
}
|
||||
});
|
||||
this.addMode("CARET", {
|
||||
char: "caret",
|
||||
description: "Active when the caret is visible in the web content",
|
||||
@@ -102,27 +80,6 @@ var Modes = Module("modes", {
|
||||
this.pref = false;
|
||||
}
|
||||
});
|
||||
this.addMode("TEXT_EDIT", {
|
||||
char: "t",
|
||||
description: "Vim-like editing of input elements",
|
||||
bases: [this.COMMAND],
|
||||
ownsFocus: true
|
||||
}, {
|
||||
onKeyPress: function (eventList) {
|
||||
const KILL = false, PASS = true;
|
||||
|
||||
// Hack, really.
|
||||
if (eventList[0].charCode || /^<(?:.-)*(?:BS|Del|C-h|C-w|C-u|C-k)>$/.test(DOM.Event.stringify(eventList[0]))) {
|
||||
dactyl.beep();
|
||||
return KILL;
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
});
|
||||
this.addMode("OUTPUT_MULTILINE", {
|
||||
description: "Active when the multi-line output buffer is open",
|
||||
bases: [this.NORMAL]
|
||||
});
|
||||
|
||||
this.addMode("INPUT", {
|
||||
char: "I",
|
||||
@@ -130,17 +87,6 @@ var Modes = Module("modes", {
|
||||
bases: [this.MAIN],
|
||||
insert: true
|
||||
});
|
||||
this.addMode("INSERT", {
|
||||
char: "i",
|
||||
description: "Active when an input element is focused",
|
||||
insert: true,
|
||||
ownsFocus: true
|
||||
});
|
||||
this.addMode("AUTOCOMPLETE", {
|
||||
description: "Active when an input autocomplete pop-up is active",
|
||||
display: function () "AUTOCOMPLETE (insert)",
|
||||
bases: [this.INSERT]
|
||||
});
|
||||
|
||||
this.addMode("EMBED", {
|
||||
description: "Active when an <embed> or <object> element is focused",
|
||||
|
||||
@@ -307,6 +307,12 @@ var MOW = Module("mow", {
|
||||
})
|
||||
}, {
|
||||
}, {
|
||||
modes: function initModes() {
|
||||
modes.addMode("OUTPUT_MULTILINE", {
|
||||
description: "Active when the multi-line output buffer is open",
|
||||
bases: [modes.NORMAL]
|
||||
});
|
||||
},
|
||||
mappings: function initMappings() {
|
||||
const PASS = true;
|
||||
const DROP = false;
|
||||
|
||||
Reference in New Issue
Block a user