mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-12 07:15:46 +01:00
commandline and MIW try to keep focus now
changed commandline handling in general autosize MIW on new content new handling should be more robust, but there may be bugs, please report
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,6 +1,7 @@
|
|||||||
<pre>
|
<pre>
|
||||||
2007-08-*:
|
2007-08-*:
|
||||||
* version 0.5
|
* version 0.5
|
||||||
|
* the command line keeps focus now, even when clicking outside of it
|
||||||
* vimperator.events.feedkeys("2zi") support for scripts
|
* vimperator.events.feedkeys("2zi") support for scripts
|
||||||
* Ctrl-U/Ctrl-D for scrolling the window up/down and the associated
|
* Ctrl-U/Ctrl-D for scrolling the window up/down and the associated
|
||||||
'scroll' option
|
'scroll' option
|
||||||
|
|||||||
@@ -46,18 +46,19 @@ function Events() //{{{
|
|||||||
tabcontainer.addEventListener("TabOpen", function(event) {
|
tabcontainer.addEventListener("TabOpen", function(event) {
|
||||||
vimperator.statusline.updateTabCount();
|
vimperator.statusline.updateTabCount();
|
||||||
vimperator.buffer.updateBufferList();
|
vimperator.buffer.updateBufferList();
|
||||||
vimperator.setMode(); // trick to reshow the mode in the command line
|
//vimperator.setMode(); // trick to reshow the mode in the command line
|
||||||
}, false);
|
}, false);
|
||||||
tabcontainer.addEventListener("TabClose", function(event) {
|
tabcontainer.addEventListener("TabClose", function(event) {
|
||||||
vimperator.statusline.updateTabCount()
|
vimperator.statusline.updateTabCount()
|
||||||
vimperator.buffer.updateBufferList();
|
vimperator.buffer.updateBufferList();
|
||||||
vimperator.setMode(); // trick to reshow the mode in the command line
|
//vimperator.setMode(); // trick to reshow the mode in the command line
|
||||||
}, false);
|
}, false);
|
||||||
tabcontainer.addEventListener("TabSelect", function(event) {
|
tabcontainer.addEventListener("TabSelect", function(event) {
|
||||||
vimperator.statusline.updateTabCount();
|
vimperator.statusline.updateTabCount();
|
||||||
vimperator.buffer.updateBufferList();
|
vimperator.buffer.updateBufferList();
|
||||||
vimperator.setMode(); // trick to reshow the mode in the command line
|
//vimperator.setMode(); // trick to reshow the mode in the command line
|
||||||
vimperator.tabs.updateSelectionHistory();
|
vimperator.tabs.updateSelectionHistory();
|
||||||
|
setTimeout(vimperator.focusContent, 10); // just make sure, that no widget has focus
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// this adds an event which is is called on each page load, even if the
|
// this adds an event which is is called on each page load, even if the
|
||||||
@@ -205,7 +206,9 @@ function Events() //{{{
|
|||||||
this.destroy = function()
|
this.destroy = function()
|
||||||
{
|
{
|
||||||
// BIG TODO: removeEventListeners() to avoid mem leaks
|
// BIG TODO: removeEventListeners() to avoid mem leaks
|
||||||
window.dump("TODO: remove eventlisteners");
|
window.dump("TODO: remove all eventlisteners");
|
||||||
|
|
||||||
|
getBrowser().removeProgressListener(this.progressListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method pushes keys into the event queue from vimperator
|
// This method pushes keys into the event queue from vimperator
|
||||||
@@ -337,16 +340,15 @@ function Events() //{{{
|
|||||||
if (!vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY))
|
if (!vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY))
|
||||||
{
|
{
|
||||||
vimperator.setMode(vimperator.modes.NORMAL);
|
vimperator.setMode(vimperator.modes.NORMAL);
|
||||||
vimperator.echo("");
|
vimperator.commandline.clear();
|
||||||
vimperator.hints.disableHahMode();
|
vimperator.hints.disableHahMode();
|
||||||
vimperator.focusContent();
|
|
||||||
vimperator.statusline.updateUrl();
|
vimperator.statusline.updateUrl();
|
||||||
|
vimperator.focusContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onKeyPress = function(event)
|
this.onKeyPress = function(event)
|
||||||
{
|
{
|
||||||
//var key = event.toString()
|
|
||||||
var key = vimperator.events.toString(event);
|
var key = vimperator.events.toString(event);
|
||||||
if (!key)
|
if (!key)
|
||||||
return false;
|
return false;
|
||||||
@@ -562,7 +564,6 @@ function Events() //{{{
|
|||||||
}
|
}
|
||||||
window.addEventListener("keypress", this.onKeyPress, true);
|
window.addEventListener("keypress", this.onKeyPress, true);
|
||||||
|
|
||||||
|
|
||||||
this.progressListener =
|
this.progressListener =
|
||||||
{
|
{
|
||||||
QueryInterface: function(aIID)
|
QueryInterface: function(aIID)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ function CommandLine() //{{{
|
|||||||
multiline_output_widget.collapsed = false;
|
multiline_output_widget.collapsed = false;
|
||||||
setTimeout(function() { multiline_output_widget.collapsed = true; }, 0);
|
setTimeout(function() { multiline_output_widget.collapsed = true; }, 0);
|
||||||
|
|
||||||
// The widget used for multiline output
|
// The widget used for multiline iutput
|
||||||
var multiline_input_widget = document.getElementById("vimperator-multiline-input");
|
var multiline_input_widget = document.getElementById("vimperator-multiline-input");
|
||||||
|
|
||||||
// we need to save the mode which were in before opening the command line
|
// we need to save the mode which were in before opening the command line
|
||||||
@@ -81,10 +81,6 @@ function CommandLine() //{{{
|
|||||||
var old_mode = null; // when we leave the command prompt this mode is restored
|
var old_mode = null; // when we leave the command prompt this mode is restored
|
||||||
var old_extended_mode = null;
|
var old_extended_mode = null;
|
||||||
|
|
||||||
// an ugly hack that we allow the :echo(err) commands after hitting enter
|
|
||||||
// and before the blur() event gets fired
|
|
||||||
var echo_allowed = false;
|
|
||||||
|
|
||||||
// save the arguments for the inputMultiline method which are needed in the event handler
|
// save the arguments for the inputMultiline method which are needed in the event handler
|
||||||
var multiline_regexp = null;
|
var multiline_regexp = null;
|
||||||
var multiline_callback = null;
|
var multiline_callback = null;
|
||||||
@@ -100,7 +96,8 @@ function CommandLine() //{{{
|
|||||||
}
|
}
|
||||||
function setMessageStyle()
|
function setMessageStyle()
|
||||||
{
|
{
|
||||||
command_widget.inputField.setAttribute("style", "font-family: monospace; color:magenta; font-weight: bold");
|
prompt_widget.setAttribute("style", "font-family: monospace; color:magenta; font-weight: bold");
|
||||||
|
command_widget.inputField.setAttribute("style","font-family: monospace;");
|
||||||
}
|
}
|
||||||
function setErrorStyle()
|
function setErrorStyle()
|
||||||
{
|
{
|
||||||
@@ -142,14 +139,14 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
multiline_input_widget.collapsed = true;
|
multiline_input_widget.collapsed = true;
|
||||||
|
|
||||||
vimperator.log(content_height);
|
// vimperator.log(content_height);
|
||||||
cmd = cmd.replace(/\n|\\n/g, "<br/>") + "<br/><span style=\"color: green;\">Press ENTER or type command to continue</span>";
|
cmd = cmd.replace(/\n|\\n/g, "<br/>") + "<br/><span style=\"color: green;\">Press ENTER or type command to continue</span>";
|
||||||
multiline_output_widget.contentDocument.body.innerHTML = cmd;
|
multiline_output_widget.contentDocument.body.innerHTML = cmd;
|
||||||
|
|
||||||
// TODO: resize upon a window resize
|
// TODO: resize upon a window resize
|
||||||
var available_height = getBrowser().mPanelContainer.boxObject.height;
|
var available_height = getBrowser().mPanelContainer.boxObject.height;
|
||||||
var content_height = multiline_output_widget.contentDocument.height;
|
var content_height = multiline_output_widget.contentDocument.height;
|
||||||
vimperator.log(content_height);
|
// vimperator.log(content_height);
|
||||||
var height = content_height < available_height ? content_height : available_height;
|
var height = content_height < available_height ? content_height : available_height;
|
||||||
|
|
||||||
multiline_output_widget.style.height = height + "px";
|
multiline_output_widget.style.height = height + "px";
|
||||||
@@ -157,10 +154,26 @@ function CommandLine() //{{{
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
multiline_output_widget.focus();
|
multiline_output_widget.focus();
|
||||||
}, 10);
|
}, 10);
|
||||||
vimperator.log(content_height);
|
//vimperator.log(content_height);
|
||||||
multiline_output_widget.contentWindow.scrollTo(0, content_height); // scroll to the end when 'nomore' is set
|
multiline_output_widget.contentWindow.scrollTo(0, content_height); // scroll to the end when 'nomore' is set
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function autosizeMultilineInputWidget()
|
||||||
|
{
|
||||||
|
// XXX: faster/better method?
|
||||||
|
|
||||||
|
var lines = 0;
|
||||||
|
var str = multiline_input_widget.value;
|
||||||
|
for (var i = 0; i < str.length; i++)
|
||||||
|
{
|
||||||
|
if (str[i] == "\n")
|
||||||
|
lines++;
|
||||||
|
}
|
||||||
|
if (lines == 0)
|
||||||
|
lines = 1;
|
||||||
|
multiline_input_widget.setAttribute("rows", lines.toString());
|
||||||
|
}
|
||||||
|
|
||||||
function addToHistory(str)
|
function addToHistory(str)
|
||||||
{
|
{
|
||||||
if (str.length < 1)
|
if (str.length < 1)
|
||||||
@@ -199,9 +212,12 @@ function CommandLine() //{{{
|
|||||||
history_index = UNINITIALIZED;
|
history_index = UNINITIALIZED;
|
||||||
completion_index = UNINITIALIZED;
|
completion_index = UNINITIALIZED;
|
||||||
|
|
||||||
// the command_widget.focus() method calls setPrompt() and setCommand()
|
// save the mode, because we need to restore it
|
||||||
// this is done, because for follow-mouse window managers, we receive
|
[old_mode, old_extended_mode] = vimperator.getMode();
|
||||||
// blur and focus events once the user leaves the Firefox window with the mouse
|
vimperator.setMode(vimperator.modes.COMMAND_LINE, cur_extended_mode, true);
|
||||||
|
setPrompt(cur_prompt);
|
||||||
|
setCommand(cur_command);
|
||||||
|
|
||||||
command_widget.focus();
|
command_widget.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -209,7 +225,7 @@ function CommandLine() //{{{
|
|||||||
this.echo = function(str, flags)
|
this.echo = function(str, flags)
|
||||||
{
|
{
|
||||||
var focused = document.commandDispatcher.focusedElement;
|
var focused = document.commandDispatcher.focusedElement;
|
||||||
if (!echo_allowed && focused && focused == command_widget.inputField)
|
if (/*!echo_allowed && focused && */focused == command_widget.inputField)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (typeof str != "string")
|
if (typeof str != "string")
|
||||||
@@ -222,8 +238,6 @@ function CommandLine() //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
multiline_output_widget.collapsed = true;
|
|
||||||
multiline_input_widget.collapsed = true;
|
|
||||||
setPrompt("");
|
setPrompt("");
|
||||||
setCommand(str);
|
setCommand(str);
|
||||||
}
|
}
|
||||||
@@ -234,7 +248,7 @@ function CommandLine() //{{{
|
|||||||
this.echoErr = function(str)
|
this.echoErr = function(str)
|
||||||
{
|
{
|
||||||
var focused = document.commandDispatcher.focusedElement;
|
var focused = document.commandDispatcher.focusedElement;
|
||||||
if (!echo_allowed && focused && focused == command_widget.inputField)
|
if (/*!echo_allowed && focused && */focused == command_widget.inputField)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setErrorStyle();
|
setErrorStyle();
|
||||||
@@ -250,9 +264,9 @@ function CommandLine() //{{{
|
|||||||
{
|
{
|
||||||
// TODO: unfinished, need to find out how/if we can block the execution of code
|
// TODO: unfinished, need to find out how/if we can block the execution of code
|
||||||
// to make this code synchronous or at least use a callback
|
// to make this code synchronous or at least use a callback
|
||||||
setPrompt("");
|
|
||||||
setMessageStyle();
|
setMessageStyle();
|
||||||
setCommand(str);
|
setPrompt(str);
|
||||||
|
setCommand("");
|
||||||
return "not implemented";
|
return "not implemented";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -261,8 +275,8 @@ function CommandLine() //{{{
|
|||||||
this.inputMultiline = function(until_regexp, callback_func)
|
this.inputMultiline = function(until_regexp, callback_func)
|
||||||
{
|
{
|
||||||
// save the mode, because we need to restore it on blur()
|
// save the mode, because we need to restore it on blur()
|
||||||
// [old_mode, old_extended_mode] = vimperator.getMode();
|
[old_mode, old_extended_mode] = vimperator.getMode();
|
||||||
// vimperator.setMode(vimperator.modes.COMMAND_LINE, vimperator.modes.READ_MULTLINE, true);
|
vimperator.setMode(vimperator.modes.COMMAND_LINE, vimperator.modes.READ_MULTILINE, true);
|
||||||
|
|
||||||
// save the arguments, they are needed in the event handler onEvent
|
// save the arguments, they are needed in the event handler onEvent
|
||||||
multiline_regexp = until_regexp;
|
multiline_regexp = until_regexp;
|
||||||
@@ -270,15 +284,19 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
multiline_input_widget.collapsed = false;
|
multiline_input_widget.collapsed = false;
|
||||||
multiline_input_widget.value = "";
|
multiline_input_widget.value = "";
|
||||||
|
autosizeMultilineInputWidget();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
multiline_input_widget.focus();
|
multiline_input_widget.focus();
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.clear = function()
|
this.clear = function()
|
||||||
{
|
{
|
||||||
setPrompt(" "); // looks faster than an empty string
|
multiline_input_widget.collapsed = true;
|
||||||
|
multiline_output_widget.collapsed = true;
|
||||||
|
|
||||||
|
setPrompt(" "); // looks faster than an empty string as most prompts are 1 char long
|
||||||
setCommand("");
|
setCommand("");
|
||||||
setNormalStyle();
|
setNormalStyle();
|
||||||
};
|
};
|
||||||
@@ -289,53 +307,18 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
if (event.type == "blur")
|
if (event.type == "blur")
|
||||||
{
|
{
|
||||||
// when we do a command_widget.focus() we get a blur event immediately,
|
// prevent losing focus, there should be a better way, but it just didn't work otherwise
|
||||||
// so check if the target is the actualy input field
|
if (vimperator.hasMode(vimperator.modes.COMMAND_LINE))
|
||||||
if (event.target == command_widget.inputField)
|
setTimeout(function() { command_widget.inputField.focus(); }, 0);
|
||||||
{
|
|
||||||
var silent = false;
|
|
||||||
if (old_mode == vimperator.modes.NORMAL)
|
|
||||||
silent = true;
|
|
||||||
vimperator.setMode(old_mode || vimperator.modes.NORMAL, old_extended_mode || null, silent);
|
|
||||||
cur_command = command;
|
|
||||||
|
|
||||||
// don't add the echoed command to the history, on pressing <cr>, the
|
|
||||||
// command is saved right into the kepress handler
|
|
||||||
if (!echo_allowed)
|
|
||||||
addToHistory(command);
|
|
||||||
|
|
||||||
completionlist.hide();
|
|
||||||
vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (event.type == "focus")
|
else if (event.type == "focus")
|
||||||
{
|
{
|
||||||
// if we manually click into the command line, don't open it
|
if (!cur_extended_mode)
|
||||||
if (event.target == command_widget.inputField && cur_extended_mode != null)
|
|
||||||
{
|
|
||||||
// save the mode, because we need to restore it on blur()
|
|
||||||
[old_mode, old_extended_mode] = vimperator.getMode();
|
|
||||||
vimperator.setMode(vimperator.modes.COMMAND_LINE, cur_extended_mode);
|
|
||||||
|
|
||||||
setPrompt(cur_prompt);
|
|
||||||
setCommand(cur_command);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//event.stopPropagation(); // XXX: doesnt seem to work
|
|
||||||
//event.preventDefault(); // so we need to use the hack below --mst
|
|
||||||
|
|
||||||
// NOTE: echo_allowed is a misleading name here, actually this flag is set
|
|
||||||
// so that we don't save a history entry if the user clicks into the text field
|
|
||||||
echo_allowed = true;
|
|
||||||
event.target.blur();
|
event.target.blur();
|
||||||
echo_allowed = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (event.type == "input")
|
else if (event.type == "input")
|
||||||
{
|
{
|
||||||
vimperator.triggerCallback("change", command);
|
vimperator.triggerCallback("change", cur_extended_mode, command);
|
||||||
}
|
}
|
||||||
else if (event.type == "keypress")
|
else if (event.type == "keypress")
|
||||||
{
|
{
|
||||||
@@ -344,20 +327,24 @@ function CommandLine() //{{{
|
|||||||
/* user pressed ENTER to carry out a command */
|
/* user pressed ENTER to carry out a command */
|
||||||
if (vimperator.events.isAcceptKey(key))
|
if (vimperator.events.isAcceptKey(key))
|
||||||
{
|
{
|
||||||
echo_allowed = true;
|
var mode = cur_extended_mode; // save it here, as setMode() resets it
|
||||||
addToHistory(command);
|
addToHistory(command);
|
||||||
var res = vimperator.triggerCallback("submit", command);
|
vimperator.setMode(old_mode, old_extended_mode);
|
||||||
vimperator.focusContent();
|
vimperator.focusContent();
|
||||||
echo_allowed = false;
|
completionlist.hide();
|
||||||
return res;
|
vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||||
|
return vimperator.triggerCallback("submit", mode, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* user pressed ESCAPE to cancel this prompt */
|
/* user pressed ESCAPE to cancel this prompt */
|
||||||
else if (vimperator.events.isCancelKey(key))
|
else if (vimperator.events.isCancelKey(key))
|
||||||
{
|
{
|
||||||
var res = vimperator.triggerCallback("cancel");
|
var res = vimperator.triggerCallback("cancel", cur_extended_mode);
|
||||||
// the command history item is saved in the blur() handler
|
addToHistory(command);
|
||||||
|
vimperator.setMode(old_mode, old_extended_mode);
|
||||||
vimperator.focusContent();
|
vimperator.focusContent();
|
||||||
|
completionlist.hide();
|
||||||
|
vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||||
this.clear();
|
this.clear();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -422,12 +409,12 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
completion_prefix = command.substring(0, command_widget.selectionStart);
|
completion_prefix = command.substring(0, command_widget.selectionStart);
|
||||||
completion_postfix = command.substring(command_widget.selectionStart);
|
completion_postfix = command.substring(command_widget.selectionStart);
|
||||||
var res = vimperator.triggerCallback("complete", completion_prefix);
|
var res = vimperator.triggerCallback("complete", cur_extended_mode, completion_prefix);
|
||||||
if (res)
|
if (res)
|
||||||
[completion_start_index, completions] = res;
|
[completion_start_index, completions] = res;
|
||||||
|
|
||||||
// Sort the completion list
|
// Sort the completion list
|
||||||
if (vimperator.options["wildoptions"].match(/\bsort\b/))
|
if (vimperator.options["wildoptions"].search(/\bsort\b/))
|
||||||
{
|
{
|
||||||
completions.sort(function(a, b) {
|
completions.sort(function(a, b) {
|
||||||
if (a[0] < b[0])
|
if (a[0] < b[0])
|
||||||
@@ -545,24 +532,42 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
this.onMultilineInputEvent = function(event)
|
this.onMultilineInputEvent = function(event)
|
||||||
{
|
{
|
||||||
var key = vimperator.events.toString(event);
|
if (event.type == "keypress")
|
||||||
if (vimperator.events.isAcceptKey(key))
|
|
||||||
{
|
{
|
||||||
//var lines = multiline_input_widget.value.substr(0, multiline_input_widget.selectionStart).split(/\n/);
|
var key = vimperator.events.toString(event);
|
||||||
var text = multiline_input_widget.value.substr(0, multiline_input_widget.selectionStart);
|
if (vimperator.events.isAcceptKey(key))
|
||||||
if (text.match(multiline_regexp))
|
|
||||||
{
|
{
|
||||||
text = text.replace(multiline_regexp, "");
|
//var lines = multiline_input_widget.value.substr(0, multiline_input_widget.selectionStart).split(/\n/);
|
||||||
multiline_callback.call(this, text);
|
var text = multiline_input_widget.value.substr(0, multiline_input_widget.selectionStart);
|
||||||
|
if (text.match(multiline_regexp))
|
||||||
|
{
|
||||||
|
text = text.replace(multiline_regexp, "");
|
||||||
|
vimperator.setMode(old_mode, old_extended_mode);
|
||||||
|
multiline_input_widget.collapsed = true;
|
||||||
|
multiline_callback.call(this, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (vimperator.events.isCancelKey(key))
|
||||||
|
{
|
||||||
|
vimperator.setMode(old_mode, old_extended_mode);
|
||||||
multiline_input_widget.collapsed = true;
|
multiline_input_widget.collapsed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (event.type == "blur")
|
||||||
|
{
|
||||||
|
if (vimperator.hasMode(vimperator.modes.READ_MULTILINE))
|
||||||
|
setTimeout(function() { multiline_input_widget.inputField.focus(); }, 0);
|
||||||
|
}
|
||||||
|
else if (event.type == "input")
|
||||||
|
{
|
||||||
|
autosizeMultilineInputWidget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onMultilineOutputEvent = function(event)
|
this.onMultilineOutputEvent = function(event)
|
||||||
{
|
{
|
||||||
var key = vimperator.events.toString(event);
|
var key = vimperator.events.toString(event);
|
||||||
if (vimperator.events.isAcceptKey(key))
|
if (vimperator.events.isAcceptKey(key) || vimperator.events.isCancelKey(key))
|
||||||
{
|
{
|
||||||
multiline_output_widget.collapsed = true;
|
multiline_output_widget.collapsed = true;
|
||||||
vimperator.focusContent();
|
vimperator.focusContent();
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ const vimperator = (function() //{{{
|
|||||||
COMMAND_LINE: 1 << 4,
|
COMMAND_LINE: 1 << 4,
|
||||||
// extended modes
|
// extended modes
|
||||||
EX: 1 << 10,
|
EX: 1 << 10,
|
||||||
READ_MULTLINE: 1 << 11,
|
READ_MULTILINE: 1 << 11,
|
||||||
SEARCH_FORWARD: 1 << 12,
|
SEARCH_FORWARD: 1 << 12,
|
||||||
SEARCH_BACKWARD: 1 << 13,
|
SEARCH_BACKWARD: 1 << 13,
|
||||||
ESCAPE_ONE_KEY: 1 << 14,
|
ESCAPE_ONE_KEY: 1 << 14,
|
||||||
@@ -125,12 +125,13 @@ const vimperator = (function() //{{{
|
|||||||
count: -1 // parsed count from the input buffer
|
count: -1 // parsed count from the input buffer
|
||||||
},
|
},
|
||||||
|
|
||||||
/** TODO: for now, these callbacks are mostly for the command line, move there?
|
/**
|
||||||
* @param type Can be:
|
* @param type can be:
|
||||||
* "submit": when the user pressed enter in the command line
|
* "submit": when the user pressed enter in the command line
|
||||||
* "change"
|
* "change"
|
||||||
* "cancel"
|
* "cancel"
|
||||||
* "complete"
|
* "complete"
|
||||||
|
* TODO: "zoom": if the zoom value of the current buffer changed
|
||||||
*/
|
*/
|
||||||
registerCallback: function(type, mode, func)
|
registerCallback: function(type, mode, func)
|
||||||
{
|
{
|
||||||
@@ -138,12 +139,12 @@ const vimperator = (function() //{{{
|
|||||||
callbacks.push([type, mode, func]);
|
callbacks.push([type, mode, func]);
|
||||||
},
|
},
|
||||||
|
|
||||||
triggerCallback: function(type, data)
|
triggerCallback: function(type, mode, data)
|
||||||
{
|
{
|
||||||
for (var i in callbacks)
|
for (var i in callbacks)
|
||||||
{
|
{
|
||||||
var [thistype, thismode, thisfunc] = callbacks[i];
|
var [thistype, thismode, thisfunc] = callbacks[i];
|
||||||
if (vimperator.hasMode(thismode) && type == thistype)
|
if (mode == thismode && type == thistype)
|
||||||
return thisfunc.call(this, data);
|
return thisfunc.call(this, data);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -105,12 +105,14 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
onkeypress="vimperator.commandline.onMultilineOutputEvent(event)"/>
|
onkeypress="vimperator.commandline.onMultilineOutputEvent(event)"/>
|
||||||
|
|
||||||
<textbox id="vimperator-multiline-input" class="plain" flex="1" rows="10" hidden="false" collapsed="true" multiline="true"
|
<textbox id="vimperator-multiline-input" class="plain" flex="1" rows="10" hidden="false" collapsed="true" multiline="true"
|
||||||
onkeypress="vimperator.commandline.onMultilineInputEvent(event);"/>
|
onkeypress="vimperator.commandline.onMultilineInputEvent(event);"
|
||||||
|
oninput="vimperator.commandline.onMultilineInputEvent(event);"
|
||||||
|
onblur="vimperator.commandline.onMultilineInputEvent(event);"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
</toolbar>
|
</toolbar>
|
||||||
|
|
||||||
<keyset id="mainKeyset">
|
<keyset id="mainKeyset">
|
||||||
<key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':', '', vimperator.modes.MODE_EX);" modifiers=""/>
|
<key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':', '', vimperator.modes.EX);" modifiers=""/>
|
||||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="vimperator.events.onEscape();"/>
|
<key id="key_stop" keycode="VK_ESCAPE" oncommand="vimperator.events.onEscape();"/>
|
||||||
<!-- other keys are handled inside vimperator.js event loop -->
|
<!-- other keys are handled inside vimperator.js event loop -->
|
||||||
</keyset>
|
</keyset>
|
||||||
|
|||||||
Reference in New Issue
Block a user