1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-04 15:34:11 +01:00

Fix some selection mode change stupidiocy with noinsertmode set.

This commit is contained in:
Kris Maglione
2011-10-06 10:58:31 -04:00
parent 1e3a5f37c9
commit ddf4d02244
2 changed files with 20 additions and 23 deletions

View File

@@ -346,7 +346,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
else if (/^[+-]?0\d/.test(range))
number = number.toString(8).replace(/^[+-]?/, "$&0");
this.mungeRange(range, function () String(number), true);
this.selectedRange = range;
this.editor.insertText(String(number));
this.selection.modify("move", "backward", "character");
},
@@ -511,7 +512,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
let abbrev = abbreviations.match(mode, String(range));
if (abbrev) {
range.setStart(range.startContainer, range.endOffset - abbrev.lhs.length);
this.mungeRange(range, function () abbrev.expand(this.element), true);
this.selectedRange = range;
this.editor.insertText(abbrev.expand(this.element));
}
},
@@ -786,10 +788,14 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
},
};
Map.types["operator"] = {
preExecute: function preExecute(args) {
editor.inEditMap = true;
},
postExecute: function preExecute(args) {
editor.inEditMap = true;
if (modes.main == modes.OPERATOR)
modes.pop();
},
}
};
// add mappings for commands like h,j,k,l,etc. in CARET, VISUAL and TEXT_EDIT mode

View File

@@ -867,21 +867,16 @@ var Events = Module("events", {
let haveInput = modes.stack.some(function (m) m.main.input);
if (elem instanceof HTMLTextAreaElement
|| elem instanceof Element && DOM(elem).style.MozUserModify === "read-write"
|| elem == null && win && Editor.getEditor(win)) {
if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart)
modes.pop();
if (DOM(elem || win).isEditable) {
if (!haveInput)
if (options["insertmode"])
modes.push(modes.INSERT);
else if (!isinstance(modes.main, [modes.TEXT_EDIT, modes.VISUAL])) {
modes.push(modes.TEXT_EDIT);
if (elem.selectionEnd - elem.selectionStart > 0)
modes.push(modes.VISUAL);
}
if (!isinstance(modes.main, [modes.INPUT, modes.TEXT_EDIT, modes.VISUAL]))
if (options["insertmode"])
modes.push(modes.INSERT);
else {
modes.push(modes.TEXT_EDIT);
if (elem.selectionEnd - elem.selectionStart > 0)
modes.push(modes.VISUAL);
}
if (hasHTMLDocument(win))
buffer.lastInputField = elem;
@@ -926,12 +921,8 @@ var Events = Module("events", {
let controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
let couldCopy = controller && controller.isCommandEnabled("cmd_copy");
if (modes.main == modes.VISUAL) {
if (!couldCopy)
modes.pop(); // Really not ideal.
}
else if (couldCopy) {
if (modes.main == modes.TEXT_EDIT && !options["insertmode"])
if (couldCopy) {
if (modes.main == modes.TEXT_EDIT)
modes.push(modes.VISUAL);
else if (modes.main == modes.CARET)
modes.push(modes.VISUAL);