mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-23 19:05:45 +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() {
|
modes: function initModes() {
|
||||||
|
initModes.require("editor");
|
||||||
|
|
||||||
modes.addMode("COMMAND_LINE", {
|
modes.addMode("COMMAND_LINE", {
|
||||||
char: "c",
|
char: "c",
|
||||||
description: "Active when the command line is focused",
|
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 selection() this.editor && this.editor.selection || null,
|
||||||
|
get selectionController() this.editor && this.editor.selectionController || null,
|
||||||
|
|
||||||
get isCaret() modes.getStack(1).main == modes.CARET,
|
get isCaret() modes.getStack(1).main == modes.CARET,
|
||||||
get isTextEdit() modes.getStack(1).main == modes.TEXT_EDIT,
|
get isTextEdit() modes.getStack(1).main == modes.TEXT_EDIT,
|
||||||
@@ -514,7 +515,64 @@ var Editor = Module("editor", {
|
|||||||
return DOM(elem).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"] = {
|
Map.types["editor"] = {
|
||||||
preExecute: function preExecute(args) {
|
preExecute: function preExecute(args) {
|
||||||
@@ -1039,8 +1097,7 @@ var Editor = Module("editor", {
|
|||||||
bind(["<C-n>"], "Select the next autocomplete result",
|
bind(["<C-n>"], "Select the next autocomplete result",
|
||||||
function () { events.feedkeys("<Down>", { skipmap: true }); });
|
function () { events.feedkeys("<Down>", { skipmap: true }); });
|
||||||
},
|
},
|
||||||
|
options: function init_options() {
|
||||||
options: function () {
|
|
||||||
options.add(["editor"],
|
options.add(["editor"],
|
||||||
"The external text editor",
|
"The external text editor",
|
||||||
"string", 'gvim -f +<line> +"sil! call cursor(0, <column>)" <file>', {
|
"string", 'gvim -f +<line> +"sil! call cursor(0, <column>)" <file>', {
|
||||||
|
|||||||
@@ -57,28 +57,6 @@ var Modes = Module("modes", {
|
|||||||
description: "Active when nothing is focused",
|
description: "Active when nothing is focused",
|
||||||
bases: [this.COMMAND]
|
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", {
|
this.addMode("CARET", {
|
||||||
char: "caret",
|
char: "caret",
|
||||||
description: "Active when the caret is visible in the web content",
|
description: "Active when the caret is visible in the web content",
|
||||||
@@ -102,27 +80,6 @@ var Modes = Module("modes", {
|
|||||||
this.pref = false;
|
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", {
|
this.addMode("INPUT", {
|
||||||
char: "I",
|
char: "I",
|
||||||
@@ -130,17 +87,6 @@ var Modes = Module("modes", {
|
|||||||
bases: [this.MAIN],
|
bases: [this.MAIN],
|
||||||
insert: true
|
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", {
|
this.addMode("EMBED", {
|
||||||
description: "Active when an <embed> or <object> element is focused",
|
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() {
|
mappings: function initMappings() {
|
||||||
const PASS = true;
|
const PASS = true;
|
||||||
const DROP = false;
|
const DROP = false;
|
||||||
|
|||||||
@@ -1837,11 +1837,11 @@ var Buffer = Module("Buffer", {
|
|||||||
notificationCallbacks: Class(XPCOM([Ci.nsIChannelEventSink, Ci.nsIInterfaceRequestor]), {
|
notificationCallbacks: Class(XPCOM([Ci.nsIChannelEventSink, Ci.nsIInterfaceRequestor]), {
|
||||||
getInterface: function getInterface(iid) this.QueryInterface(iid),
|
getInterface: function getInterface(iid) this.QueryInterface(iid),
|
||||||
|
|
||||||
asyncOnChannelRedirect: util.wrapCallback(function (oldChannel, newChannel, flags, callback) {
|
asyncOnChannelRedirect: function (oldChannel, newChannel, flags, callback) {
|
||||||
if (newChannel instanceof Ci.nsIHttpChannel)
|
if (newChannel instanceof Ci.nsIHttpChannel)
|
||||||
newChannel.requestMethod = "HEAD";
|
newChannel.requestMethod = "HEAD";
|
||||||
callback.onRedirectVerifyCallback(Cr.NS_OK);
|
callback.onRedirectVerifyCallback(Cr.NS_OK);
|
||||||
})
|
}
|
||||||
})()
|
})()
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ var Messages = Module("messages", {
|
|||||||
let { Buffer, commands, hints, io, mappings, modes, options, sanitizer } = overlay.activeModules;
|
let { Buffer, commands, hints, io, mappings, modes, options, sanitizer } = overlay.activeModules;
|
||||||
file = io.File(file);
|
file = io.File(file);
|
||||||
|
|
||||||
function foo(base, iter_, prop) iter(function _foo() {
|
function properties(base, iter_, prop) iter(function _properties() {
|
||||||
function key() [base, obj.identifier || obj.name].concat(Array.slice(arguments)).join(".").replace(/[:=]/g, "\\$&");
|
function key() [base, obj.identifier || obj.name].concat(Array.slice(arguments)).join(".").replace(/[\\:=]/g, "\\$&");
|
||||||
|
|
||||||
prop = prop || "description";
|
prop = prop || "description";
|
||||||
for (var obj in iter_) {
|
for (var obj in iter_) {
|
||||||
@@ -121,14 +121,15 @@ var Messages = Module("messages", {
|
|||||||
}()).toArray();
|
}()).toArray();
|
||||||
|
|
||||||
file.write(
|
file.write(
|
||||||
array(commands.allHives.map(function (h) foo("command", h)))
|
array(commands.allHives.map(function (h) properties("command", h)))
|
||||||
.concat(modes.all.map(function (m) foo("map", values(mappings.builtin.getStack(m)
|
.concat(modes.all.map(function (m)
|
||||||
.filter(function (map) map.modes[0] == m)))))
|
properties("map", values(mappings.builtin.getStack(m)
|
||||||
.concat(foo("mode", values(modes.all.filter(function (m) !m.hidden))))
|
.filter(function (map) map.modes[0] == m)))))
|
||||||
.concat(foo("option", options))
|
.concat(properties("mode", values(modes.all.filter(function (m) !m.hidden))))
|
||||||
.concat(foo("hintmode", values(hints.modes), "prompt"))
|
.concat(properties("option", options))
|
||||||
.concat(foo("pageinfo", values(Buffer.pageInfo), "title"))
|
.concat(properties("hintmode", values(hints.modes), "prompt"))
|
||||||
.concat(foo("sanitizeitem", values(sanitizer.itemMap)))
|
.concat(properties("pageinfo", values(Buffer.pageInfo), "title"))
|
||||||
|
.concat(properties("sanitizeitem", values(sanitizer.itemMap)))
|
||||||
.flatten().uniq().join("\n"));
|
.flatten().uniq().join("\n"));
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
@@ -154,7 +155,10 @@ var Messages = Module("messages", {
|
|||||||
function getter(key, default_) function getter() messages.get([name, key].join("."), default_);
|
function getter(key, default_) function getter() messages.get([name, key].join("."), default_);
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
var name = [this.constructor.className.toLowerCase(), this.identifier || this.name, prop].join(".");
|
var name = [this.constructor.className.toLowerCase(),
|
||||||
|
this.identifier || this.name,
|
||||||
|
prop].join(".");
|
||||||
|
|
||||||
if (!isObject(value))
|
if (!isObject(value))
|
||||||
value = messages.get(name, value);
|
value = messages.get(name, value);
|
||||||
else if (isArray(value))
|
else if (isArray(value))
|
||||||
|
|||||||
Reference in New Issue
Block a user