mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-12 03:05:46 +01:00
Add o_c, o_d, and o_y. Fix selection mode change magic bug.
This commit is contained in:
@@ -520,8 +520,10 @@ var Editor = Module("editor", {
|
|||||||
preExecute: function preExecute(args) {
|
preExecute: function preExecute(args) {
|
||||||
if (editor.editor)
|
if (editor.editor)
|
||||||
editor.editor.beginTransaction();
|
editor.editor.beginTransaction();
|
||||||
|
editor.inEditMap = true;
|
||||||
},
|
},
|
||||||
postExecute: function preExecute(args) {
|
postExecute: function preExecute(args) {
|
||||||
|
editor.inEditMap = false;
|
||||||
if (editor.editor)
|
if (editor.editor)
|
||||||
editor.editor.endTransaction();
|
editor.editor.endTransaction();
|
||||||
},
|
},
|
||||||
@@ -703,19 +705,25 @@ var Editor = Module("editor", {
|
|||||||
|
|
||||||
mappings.add([modes.TEXT_EDIT], key,
|
mappings.add([modes.TEXT_EDIT], key,
|
||||||
desc,
|
desc,
|
||||||
function ({ count, motion }) {
|
function ({ command, count, motion }) {
|
||||||
let start = editor.selectionRange.cloneRange();
|
let start = editor.selectionRange.cloneRange();
|
||||||
|
|
||||||
modes.push(modes.OPERATOR, null, {
|
modes.push(modes.OPERATOR, null, {
|
||||||
|
forCommand: command,
|
||||||
|
|
||||||
count: count,
|
count: count,
|
||||||
|
|
||||||
leave: function leave(stack) {
|
leave: function leave(stack) {
|
||||||
if (stack.push || stack.fromEscape)
|
if (stack.push || stack.fromEscape)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let range = RangeFind.union(start, editor.selectionRange);
|
editor.withSavedValues(["inEditMap"], function () {
|
||||||
editor.selectionRange = select ? range : start;
|
this.inEditMap = true;
|
||||||
doTxn(range, editor);
|
|
||||||
|
let range = RangeFind.union(start, editor.selectionRange);
|
||||||
|
editor.selectionRange = select ? range : start;
|
||||||
|
doTxn(range, editor);
|
||||||
|
});
|
||||||
|
|
||||||
modes.delay(function () {
|
modes.delay(function () {
|
||||||
if (mode)
|
if (mode)
|
||||||
@@ -737,7 +745,7 @@ var Editor = Module("editor", {
|
|||||||
|
|
||||||
addMotionMap(["d", "x"], "Delete text", true, function (editor) { editor.editor.cut(); });
|
addMotionMap(["d", "x"], "Delete text", true, function (editor) { editor.editor.cut(); });
|
||||||
addMotionMap(["c"], "Change text", true, function (editor) { editor.editor.cut(); }, modes.INSERT);
|
addMotionMap(["c"], "Change text", true, function (editor) { editor.editor.cut(); }, modes.INSERT);
|
||||||
addMotionMap(["y"], "Yank text", false, function (editor, range) { dactyl.clipboardWrite(DOM.stringify(range)) });
|
addMotionMap(["y"], "Yank text", false, function (editor, range) { dactyl.clipboardWrite(String(range)) });
|
||||||
|
|
||||||
addMotionMap(["gu"], "Lowercase text", false,
|
addMotionMap(["gu"], "Lowercase text", false,
|
||||||
function (editor, range) {
|
function (editor, range) {
|
||||||
@@ -749,6 +757,20 @@ var Editor = Module("editor", {
|
|||||||
editor.mungeRange(range, String.toLocaleUpperCase);
|
editor.mungeRange(range, String.toLocaleUpperCase);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mappings.add([modes.OPERATOR],
|
||||||
|
["c", "d", "y"], "Select the entire line",
|
||||||
|
function ({ command, count }) {
|
||||||
|
dactyl.assert(command == modes.getStack(0).params.forCommand);
|
||||||
|
editor.executeCommand("cmd_beginLine", 1);
|
||||||
|
editor.executeCommand("cmd_selectLineNext", count || 1);
|
||||||
|
let range = editor.selectionRange;
|
||||||
|
if (command == "c" && !range.collapsed) // Hack.
|
||||||
|
if (range.endContainer instanceof Text &&
|
||||||
|
range.endContainer.textContent[range.endOffset - 1] == "\n")
|
||||||
|
editor.executeCommand("cmd_selectCharPrevious", 1);
|
||||||
|
},
|
||||||
|
{ count: true, type: "operator" });
|
||||||
|
|
||||||
let bind = function bind(names, description, action, params)
|
let bind = function bind(names, description, action, params)
|
||||||
mappings.add([modes.INPUT], names, description,
|
mappings.add([modes.INPUT], names, description,
|
||||||
action, update({ type: "editor" }, params));
|
action, update({ type: "editor" }, params));
|
||||||
|
|||||||
@@ -909,6 +909,10 @@ var Events = Module("events", {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
onSelectionChange: function onSelectionChange(event) {
|
onSelectionChange: function onSelectionChange(event) {
|
||||||
|
// Ignore selection events caused by editor commands.
|
||||||
|
if (editor.inEditMap || modes.main == modes.OPERATOR)
|
||||||
|
return;
|
||||||
|
|
||||||
let controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
|
let controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
|
||||||
let couldCopy = controller && controller.isCommandEnabled("cmd_copy");
|
let couldCopy = controller && controller.isCommandEnabled("cmd_copy");
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,8 @@
|
|||||||
- Crude regular expression search is supported. [b8]
|
- Crude regular expression search is supported. [b8]
|
||||||
- New searches now start within the current viewport where possible. [b8]
|
- New searches now start within the current viewport where possible. [b8]
|
||||||
• Text editing improvements, including:
|
• Text editing improvements, including:
|
||||||
- Added t_gu, t_gU, and v_o. [b8]
|
- Added t_gu, t_gU, and v_o mappings. [b8]
|
||||||
|
- Added o_c, o_d, and o_y mappings. [b8]
|
||||||
- Added operator modes and proper first class motion maps. [b8]
|
- Added operator modes and proper first class motion maps. [b8]
|
||||||
- Improved undo support for most mappings. [b8]
|
- Improved undo support for most mappings. [b8]
|
||||||
• General completion improvements
|
• General completion improvements
|
||||||
|
|||||||
Reference in New Issue
Block a user