mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 13:48:00 +01:00
faster echo() method
This commit is contained in:
@@ -156,6 +156,7 @@ function CommandLine() //{{{
|
|||||||
// sets the command - e.g. 'tabopen', 'open http://example.com/'
|
// sets the command - e.g. 'tabopen', 'open http://example.com/'
|
||||||
function setCommand(cmd)
|
function setCommand(cmd)
|
||||||
{
|
{
|
||||||
|
command_widget.hidden = false;
|
||||||
command_widget.value = cmd;
|
command_widget.value = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
// TODO: only some commands list the ex command above their output so
|
// TODO: only some commands list the ex command above their output so
|
||||||
// this should be moved to the generating functions eg. v.buffers.list
|
// this should be moved to the generating functions eg. v.buffers.list
|
||||||
var output = "<div class=\"ex-command-output\">" + ":" + command_widget.value + "<br/>" + str + "</div>";
|
var output = "<div class=\"ex-command-output\">" + ":" + command_widget.value.replace(/</, "<").replace(/>/, ">") + "<br/>" + str + "</div>";
|
||||||
if (!multiline_output_widget.collapsed)
|
if (!multiline_output_widget.collapsed)
|
||||||
{
|
{
|
||||||
// FIXME: need to make sure an open MOW is closed when commands
|
// FIXME: need to make sure an open MOW is closed when commands
|
||||||
@@ -201,24 +202,15 @@ function CommandLine() //{{{
|
|||||||
var elements = multiline_output_widget.contentDocument.getElementsByClassName("ex-command-output");
|
var elements = multiline_output_widget.contentDocument.getElementsByClassName("ex-command-output");
|
||||||
elements[elements.length - 1].scrollIntoView(true);
|
elements[elements.length - 1].scrollIntoView(true);
|
||||||
|
|
||||||
setPrompt("");
|
|
||||||
if (multiline_output_widget.contentWindow.scrollY >= multiline_output_widget.contentWindow.scrollMaxY)
|
if (multiline_output_widget.contentWindow.scrollY >= multiline_output_widget.contentWindow.scrollMaxY)
|
||||||
{
|
vimperator.commandline.echo("Press ENTER or type command to continue", vimperator.commandline.HL_QUESTION);
|
||||||
setHighlightGroup("hl-Question");
|
|
||||||
setCommand('Press ENTER or type command to continue');
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
vimperator.commandline.echo("-- More --", vimperator.commandline.HL_MOREMSG);
|
||||||
setHighlightGroup("hl-MoreMsg");
|
|
||||||
setCommand("-- More --");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
multiline_output_widget.contentWindow.scrollTo(0, content_height);
|
multiline_output_widget.contentWindow.scrollTo(0, content_height);
|
||||||
setHighlightGroup("hl-Question");
|
vimperator.commandline.echo("Press ENTER or type command to continue", vimperator.commandline.HL_QUESTION);
|
||||||
setPrompt("");
|
|
||||||
setCommand('Press ENTER or type command to continue');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
multiline_output_widget.contentWindow.focus();
|
multiline_output_widget.contentWindow.focus();
|
||||||
@@ -253,6 +245,11 @@ function CommandLine() //{{{
|
|||||||
this.HL_QUESTION = "hl-Question";
|
this.HL_QUESTION = "hl-Question";
|
||||||
this.HL_WARNING = "hl-Warning";
|
this.HL_WARNING = "hl-Warning";
|
||||||
|
|
||||||
|
// not yet used
|
||||||
|
this.FORCE_MULTILINE = 1 << 0;
|
||||||
|
this.FORCE_SINGLELINE = 1 << 1;
|
||||||
|
this.FORCE_ECHO = 1 << 2; // also echoes if the commandline has focus
|
||||||
|
|
||||||
this.getCommand = function()
|
this.getCommand = function()
|
||||||
{
|
{
|
||||||
return command_widget.value;
|
return command_widget.value;
|
||||||
@@ -291,6 +288,7 @@ function CommandLine() //{{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: flags not yet really functional --mst
|
// FIXME: flags not yet really functional --mst
|
||||||
|
// multiline string don't obey highlight_group
|
||||||
this.echo = function(str, highlight_group, flags)
|
this.echo = function(str, highlight_group, flags)
|
||||||
{
|
{
|
||||||
var focused = document.commandDispatcher.focusedElement;
|
var focused = document.commandDispatcher.focusedElement;
|
||||||
@@ -302,33 +300,28 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
highlight_group = highlight_group || this.HL_NORMAL;
|
highlight_group = highlight_group || this.HL_NORMAL;
|
||||||
setHighlightGroup(highlight_group);
|
setHighlightGroup(highlight_group);
|
||||||
if (flags || !multiline_output_widget.collapsed || str.indexOf("\n") > -1 || str.indexOf("<br>") > -1 || str.indexOf("<br/>") > -1)
|
if (flags /*|| !multiline_output_widget.collapsed*/ || /\n|<br\/?>/.test(str))
|
||||||
{
|
{
|
||||||
setMultiline(str);
|
setMultiline(str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setPrompt("");
|
if (!str)
|
||||||
setCommand(str);
|
str = "";
|
||||||
|
|
||||||
|
setPrompt(str);
|
||||||
|
command_widget.hidden = true;
|
||||||
|
|
||||||
|
// initially (in the xul) the prompt is 'collapsed', this makes
|
||||||
|
// sure it's visible, then we toggle the display which works better
|
||||||
|
prompt_widget.style.visibility = 'visible';
|
||||||
|
prompt_widget.style.display = 'inline';
|
||||||
|
prompt_widget.size = str.length;
|
||||||
}
|
}
|
||||||
cur_extended_mode = null;
|
cur_extended_mode = null;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: why is this duplicated? -- djk
|
|
||||||
this.echoErr = function(str)
|
|
||||||
{
|
|
||||||
var focused = document.commandDispatcher.focusedElement;
|
|
||||||
if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
setHighlightGroup(this.HL_ERRORMSG);
|
|
||||||
setPrompt("");
|
|
||||||
setCommand(str);
|
|
||||||
cur_extended_mode = null;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// this will prompt the user for a string
|
// this will prompt the user for a string
|
||||||
// vimperator.commandline.input("(s)ave or (o)pen the file?")
|
// vimperator.commandline.input("(s)ave or (o)pen the file?")
|
||||||
this.input = function(str)
|
this.input = function(str)
|
||||||
@@ -338,6 +331,7 @@ function CommandLine() //{{{
|
|||||||
setHighlightGroup(this.HL_QUESTION);
|
setHighlightGroup(this.HL_QUESTION);
|
||||||
setPrompt(str);
|
setPrompt(str);
|
||||||
setCommand("");
|
setCommand("");
|
||||||
|
command_widget.focus();
|
||||||
return "not implemented";
|
return "not implemented";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -369,9 +363,7 @@ function CommandLine() //{{{
|
|||||||
multiline_output_widget.collapsed = true;
|
multiline_output_widget.collapsed = true;
|
||||||
completionlist.hide();
|
completionlist.hide();
|
||||||
|
|
||||||
setHighlightGroup(this.HL_NORMAL);
|
this.echo("");
|
||||||
setPrompt(" "); // looks faster than an empty string as most prompts are 1 char long
|
|
||||||
setCommand("");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onEvent = function(event)
|
this.onEvent = function(event)
|
||||||
@@ -802,23 +794,11 @@ function CommandLine() //{{{
|
|||||||
else // set update the prompt string
|
else // set update the prompt string
|
||||||
{
|
{
|
||||||
if (show_more_help_prompt)
|
if (show_more_help_prompt)
|
||||||
{
|
this.echo("-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit", this.HL_MOREMSG);
|
||||||
setHighlightGroup(this.HL_MOREMSG);
|
|
||||||
setPrompt("");
|
|
||||||
setCommand("-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit");
|
|
||||||
}
|
|
||||||
else if (show_more_prompt || (vimperator.options["more"] && isScrollable() && !atEnd()))
|
else if (show_more_prompt || (vimperator.options["more"] && isScrollable() && !atEnd()))
|
||||||
{
|
this.echo("-- More --", this.HL_MOREMSG);
|
||||||
setHighlightGroup(this.HL_MOREMSG);
|
|
||||||
setPrompt("");
|
|
||||||
setCommand("-- More --");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
this.echo("Press ENTER or type command to continue", this.HL_QUESTION);
|
||||||
setHighlightGroup(this.HL_QUESTION);
|
|
||||||
setPrompt("");
|
|
||||||
setCommand('Press ENTER or type command to continue');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -732,7 +732,7 @@ const vimperator = (function() //{{{
|
|||||||
vimperator.log("All modules loaded", 3);
|
vimperator.log("All modules loaded", 3);
|
||||||
|
|
||||||
vimperator.echo = function(str) { vimperator.commandline.echo(str); }
|
vimperator.echo = function(str) { vimperator.commandline.echo(str); }
|
||||||
vimperator.echoerr = function(str) { vimperator.commandline.echoErr(str); }
|
vimperator.echoerr = function(str) { vimperator.commandline.echo(str, vimperator.commandline.HL_ERRORMSG); }
|
||||||
|
|
||||||
vimperator.globalVariables = {};
|
vimperator.globalVariables = {};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user