1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 09:27:58 +01:00

Add EMBED mode.

This commit is contained in:
Kris Maglione
2009-09-03 20:34:19 -04:00
parent 561a3ff978
commit 5116502bf9
2 changed files with 21 additions and 9 deletions

View File

@@ -488,7 +488,9 @@ function Events() //{{{
let elem = liberator.focus; let elem = liberator.focus;
return ((elem instanceof HTMLInputElement && !/image/.test(elem.type)) || return ((elem instanceof HTMLInputElement && !/image/.test(elem.type)) ||
elem instanceof HTMLTextAreaElement || elem instanceof HTMLTextAreaElement ||
elem instanceof HTMLIsIndexElement); elem instanceof HTMLIsIndexElement ||
elem instanceof HTMLObjectElement ||
elem instanceof HTMLEmbedElement);
} }
function triggerLoadAutocmd(name, doc) function triggerLoadAutocmd(name, doc)
@@ -1303,6 +1305,11 @@ function Events() //{{{
buffer.lastInputField = elem; buffer.lastInputField = elem;
return; return;
} }
if (elem instanceof HTMLEmbedElement || elem instanceof HTMLObjectElement)
{
liberator.mode = modes.EMBED;
return;
}
if (elem instanceof HTMLTextAreaElement || (elem && elem.contentEditable == "true")) if (elem instanceof HTMLTextAreaElement || (elem && elem.contentEditable == "true"))
{ {
@@ -1577,7 +1584,7 @@ function Events() //{{{
if (countStr && !candidateCommand) if (countStr && !candidateCommand)
{ {
// no count for insert mode mappings // no count for insert mode mappings
if (liberator.mode == modes.INSERT || liberator.mode == modes.COMMAND_LINE) if (!modes.mainMode.count && !modes.mainMode.input)
stop = false; stop = false;
else else
input.buffer = inputStr; input.buffer = inputStr;
@@ -1656,7 +1663,7 @@ function Events() //{{{
if (!(modes.extended & modes.INPUT_MULTILINE)) if (!(modes.extended & modes.INPUT_MULTILINE))
commandline.onEvent(event); // reroute event in command line mode commandline.onEvent(event); // reroute event in command line mode
} }
else if (liberator.mode != modes.INSERT && liberator.mode != modes.TEXTAREA) else if (!modes.mainMode.input)
liberator.beep(); liberator.beep();
} }
} }

View File

@@ -137,6 +137,8 @@ const modes = (function () //{{{
get mainModes() (mode for ([k, mode] in Iterator(modeMap)) if (!mode.extended && mode.name == k)), get mainModes() (mode for ([k, mode] in Iterator(modeMap)) if (!mode.extended && mode.name == k)),
get mainMode() modeMap[main],
addMode: function (name, extended, options) addMode: function (name, extended, options)
{ {
let disp = name.replace("_", " ", "g"); let disp = name.replace("_", " ", "g");
@@ -148,6 +150,8 @@ const modes = (function () //{{{
} }
modeMap[name] = modeMap[this[name]] = util.extend({ modeMap[name] = modeMap[this[name]] = util.extend({
extended: extended, extended: extended,
count: true,
input: false,
mask: this[name], mask: this[name],
name: name, name: name,
disp: disp disp: disp
@@ -269,13 +273,14 @@ const modes = (function () //{{{
var modeMap = {}; var modeMap = {};
// main modes, only one should ever be active // main modes, only one should ever be active
self.addMode("NORMAL", { char: "n", display: -1 }); self.addMode("NORMAL", { char: "n", display: -1 });
self.addMode("INSERT", { char: "i" }); self.addMode("INSERT", { char: "i", input: true });
self.addMode("VISUAL", { char: "v", display: function () "VISUAL" + (extended & modes.LINE ? " LINE" : "") }); self.addMode("VISUAL", { char: "v", display: function () "VISUAL" + (extended & modes.LINE ? " LINE" : "") });
self.addMode("COMMAND_LINE", { char: "c" }); self.addMode("COMMAND_LINE", { char: "c", input: true });
self.addMode("CARET"); // text cursor is visible self.addMode("CARET"); // text cursor is visible
self.addMode("TEXTAREA", { char: "i" }); // text cursor is in a HTMLTextAreaElement self.addMode("TEXTAREA", { char: "i", input: true }); // text cursor is in a HTMLTextAreaElement
self.addMode("CUSTOM", { display: function () plugins.mode }); self.addMode("EMBED", { input: true });
self.addMode("CUSTOM", { display: function () plugins.mode });
// extended modes, can include multiple modes, and even main modes // extended modes, can include multiple modes, and even main modes
self.addMode("EX", true); self.addMode("EX", true);
self.addMode("HINTS", true); self.addMode("HINTS", true);