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

Add separate echo/command-line widgets

This commit is contained in:
Kris Maglione
2008-12-06 09:41:59 -05:00
parent 89c0620634
commit 983c2be92b
7 changed files with 63 additions and 67 deletions

View File

@@ -298,8 +298,6 @@ function Events() //{{{
{ {
// TODO: is all of that necessary? // TODO: is all of that necessary?
modes.reset(); modes.reset();
commandline.clear();
modes.show();
statusline.updateTabCount(); statusline.updateTabCount();
tabs.updateSelectionHistory(); tabs.updateSelectionHistory();
@@ -1179,7 +1177,6 @@ function Events() //{{{
selection.collapseToStart(); selection.collapseToStart();
} }
catch (e) {} catch (e) {}
commandline.clear();
modes.reset(); modes.reset();
liberator.focusContent(true); liberator.focusContent(true);

View File

@@ -1215,6 +1215,8 @@ const liberator = (function () //{{{
config.dialogs = config.dialogs || []; config.dialogs = config.dialogs || [];
config.helpFiles = config.helpFiles || []; config.helpFiles = config.helpFiles || [];
liberator.triggerObserver("load");
// commands must always be the first module to be initialized // commands must always be the first module to be initialized
loadModule("commands", Commands); loadModule("commands", Commands);
loadModule("options", Options); loadModule("options", Options);

View File

@@ -79,13 +79,16 @@ the terms of any one of the MPL, the GPL or the LGPL.
onclick="liberator.modules.commandline.onMultilineOutputEvent(event)"/> onclick="liberator.modules.commandline.onMultilineOutputEvent(event)"/>
</vbox> </vbox>
<hbox id="liberator-commandline" hidden="false" liberator:highlight="Normal"> <stack orient="horizontal" align="stretch" class="liberator-container" liberator:highlight="CmdLine">
<label class="plain" id="liberator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/> <textbox class="plain" id="liberator-message" flex="1" readonly="true" liberator:highlight="Normal"/>
<textbox class="plain" id="liberator-commandline-command" flex="1" type="timed" timeout="100" <hbox id="liberator-commandline" hidden="false" class="liberator-container" liberator:highlight="Normal">
oninput="liberator.modules.commandline.onEvent(event);" <label class="plain" id="liberator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
onfocus="liberator.modules.commandline.onEvent(event);" <textbox class="plain" id="liberator-commandline-command" flex="1" type="timed" timeout="100"
onblur="liberator.modules.commandline.onEvent(event);"/> oninput="liberator.modules.commandline.onEvent(event);"
</hbox> onfocus="liberator.modules.commandline.onEvent(event);"
onblur="liberator.modules.commandline.onEvent(event);"/>
</hbox>
</stack>
<vbox class="liberator-container" hidden="false" collapsed="false"> <vbox class="liberator-container" hidden="false" collapsed="false">
<textbox id="liberator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true" <textbox id="liberator-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"

View File

@@ -159,12 +159,7 @@ const modes = (function () //{{{
if (!options["showmode"]) if (!options["showmode"])
return; return;
// never show mode messages if we are in command line mode commandline.echo(getModeMessage(), "ModeMsg");
if (main == modes.COMMAND_LINE)
return;
commandline.echo(getModeMessage(), commandline.HL_MODEMSG,
commandline.DISALLOW_MULTILINE);
}, },
// add/remove always work on the extended mode only // add/remove always work on the extended mode only
@@ -178,6 +173,7 @@ const modes = (function () //{{{
// if silent == true, you also need to take care of the mode handling changes yourself // if silent == true, you also need to take care of the mode handling changes yourself
set: function (mainMode, extendedMode, silent) set: function (mainMode, extendedMode, silent)
{ {
silent = (silent || main == mainMode && extended == extendedMode);
// if a main mode is set, the extended is always cleared // if a main mode is set, the extended is always cleared
if (typeof mainMode === "number") if (typeof mainMode === "number")
{ {

View File

@@ -24,6 +24,8 @@ Highlights.prototype.CSS = <![CDATA[
NonText color: blue; min-height: 16px; padding-left: 2px; NonText color: blue; min-height: 16px; padding-left: 2px;
Preview color: gray; Preview color: gray;
CmdLine font-family: monospace; padding: 1px;
CompGroup CompGroup
CompGroup:not(:first-of-type) margin-top: .5em; CompGroup:not(:first-of-type) margin-top: .5em;
CompTitle color: magenta; background: white; font-weight: bold; CompTitle color: magenta; background: white; font-weight: bold;

View File

@@ -430,7 +430,11 @@ function CommandLine() //{{{
// the command bar which contains the current command // the command bar which contains the current command
const commandWidget = document.getElementById("liberator-commandline-command"); const commandWidget = document.getElementById("liberator-commandline-command");
const messageBox = document.getElementById("liberator-message");
commandWidget.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement); commandWidget.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
messageBox.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
// the widget used for multiline output // the widget used for multiline output
const multilineOutputWidget = document.getElementById("liberator-multiline-output"); const multilineOutputWidget = document.getElementById("liberator-multiline-output");
@@ -454,9 +458,13 @@ function CommandLine() //{{{
function setHighlightGroup(group) function setHighlightGroup(group)
{ {
commandlineWidget.setAttributeNS(NS.uri, "highlight", group); messageBox.setAttributeNS(NS.uri, "highlight", group);
} }
function commandShown() modes.main == modes.COMMAND_LINE &&
!(modes.extended & modes.INPUT_MULTILINE) &&
!(modes.extended & modes.OUTPUT_MULTILINE);
// sets the prompt - for example, : or / // sets the prompt - for example, : or /
function setPrompt(pmt, highlightGroup) function setPrompt(pmt, highlightGroup)
{ {
@@ -483,15 +491,16 @@ function CommandLine() //{{{
function setLine(str, highlightGroup, forceSingle) function setLine(str, highlightGroup, forceSingle)
{ {
setHighlightGroup(highlightGroup); setHighlightGroup(highlightGroup);
setPrompt(""); messageBox.value = str;
setCommand(str);
if (!forceSingle && if (!commandShown())
commandWidget.inputField.editor.rootElement commandline.hide();
.scrollWidth > commandWidget.inputField.scrollWidth)
{ let field = messageBox.inputField;
setCommand(""); if (!forceSingle && field.editor.rootElement.scrollWidth > field.scrollWidth)
setMultiline(<span highlight="Message">{str}</span>, highlightGroup); setMultiline(<span highlight="Message">{str}</span>, highlightGroup);
} else
messageBox.collapsed = false;
} }
// TODO: extract CSS // TODO: extract CSS
@@ -847,9 +856,10 @@ function CommandLine() //{{{
historyIndex = UNINITIALIZED; historyIndex = UNINITIALIZED;
modes.set(modes.COMMAND_LINE, currentExtendedMode); modes.set(modes.COMMAND_LINE, currentExtendedMode);
setHighlightGroup(this.HL_NORMAL);
setPrompt(currentPrompt); setPrompt(currentPrompt);
setCommand(currentCommand); setCommand(currentCommand);
commandlineWidget.collapsed = false;
commandWidget.focus(); commandWidget.focus();
@@ -873,19 +883,19 @@ function CommandLine() //{{{
statusline.updateProgress(""); // we may have a "match x of y" visible statusline.updateProgress(""); // we may have a "match x of y" visible
liberator.focusContent(false); liberator.focusContent(false);
this.clear();
keepCommand = false;
},
clear: function clear()
{
multilineInputWidget.collapsed = true; multilineInputWidget.collapsed = true;
outputContainer.collapsed = true; outputContainer.collapsed = true;
completionList.hide(); completionList.hide();
this.resetCompletions(); this.resetCompletions();
this.hide();
keepCommand = false;
},
hide: function hide()
{
if (!keepCommand || this.silent) if (!keepCommand || this.silent)
setLine("", this.HL_NORMAL); commandlineWidget.collapsed = true;
}, },
// liberator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst // liberator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst
@@ -975,13 +985,8 @@ function CommandLine() //{{{
{ {
// prevent losing focus, there should be a better way, but it just didn't work otherwise // prevent losing focus, there should be a better way, but it just didn't work otherwise
setTimeout(function () { setTimeout(function () {
if (liberator.mode == modes.COMMAND_LINE && if (commandShown() && event.originalTarget == commandWidget.inputField)
!(modes.extended & modes.INPUT_MULTILINE) &&
!(modes.extended & modes.OUTPUT_MULTILINE) &&
event.originalTarget == commandWidget.inputField)
{
commandWidget.inputField.focus(); commandWidget.inputField.focus();
}
}, 0); }, 0);
} }
else if (event.type == "focus") else if (event.type == "focus")
@@ -1339,9 +1344,7 @@ function CommandLine() //{{{
if (passEvent || closeWindow) if (passEvent || closeWindow)
{ {
// FIXME: use mode stack
modes.pop(); modes.pop();
this.clear();
if (passEvent) if (passEvent)
events.onKeyPress(event); events.onKeyPress(event);
@@ -1354,10 +1357,6 @@ function CommandLine() //{{{
updateMorePrompt: function updateMorePrompt(force, showHelp) updateMorePrompt: function updateMorePrompt(force, showHelp)
{ {
// prevent MOW events (still useful) from wiping out the command-line when in EX extended mode
if (modes.extended != modes.OUTPUT_MULTILINE)
return;
let win = multilineOutputWidget.contentWindow; let win = multilineOutputWidget.contentWindow;
function isScrollable() !win.scrollMaxY == 0; function isScrollable() !win.scrollMaxY == 0;
function atEnd() win.scrollY / win.scrollMaxY >= 1; function atEnd() win.scrollY / win.scrollMaxY >= 1;

View File

@@ -96,8 +96,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
@-moz-document @-moz-document
url-prefix(chrome://) { url-prefix(chrome://) {
#liberator-container { .liberator-container > * {
font-family: monospace; font-family: inherit;
} }
#liberator-completions { #liberator-completions {
@@ -108,13 +108,15 @@ the terms of any one of the MPL, the GPL or the LGPL.
} }
/* fixes the min-height: 22px from firefox */ /* fixes the min-height: 22px from firefox */
#status-bar, statusbarpanel { #status-bar,
statusbarpanel {
-moz-appearance: none !important; -moz-appearance: none !important;
min-height: 18px !important; min-height: 18px !important;
border: none !important; border: none !important;
font-weight: bold; font-weight: bold;
font-family: monospace; font-family: monospace;
} }
#liberator-statusline { #liberator-statusline {
font-family: monospace; font-family: monospace;
margin: 0px; margin: 0px;
@@ -138,14 +140,6 @@ the terms of any one of the MPL, the GPL or the LGPL.
display: none; display: none;
} }
#liberator-commandline {
padding: 1px;
font-family: monospace;
/*
background-color: white;
color: black;
*/
}
#liberator-commandline-prompt { #liberator-commandline-prompt {
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
@@ -156,11 +150,6 @@ the terms of any one of the MPL, the GPL or the LGPL.
color: inherit; color: inherit;
} }
#liberator-visualbell {
border: none;
background-color: black;
}
#sidebar { #sidebar {
max-width: 90% !important; max-width: 90% !important;
min-width: 10% !important; min-width: 10% !important;
@@ -168,29 +157,37 @@ the terms of any one of the MPL, the GPL or the LGPL.
/* MOW */ /* MOW */
#liberator-completions, #liberator-multiline-output, #liberator-multiline-input { #liberator-completions,
#liberator-multiline-output,
#liberator-multiline-input {
overflow: hidden; overflow: hidden;
background-color: white; background-color: white;
color: black; color: black;
} }
#liberator-completions-content, #liberator-multiline-output-content, #liberator-multiline-input { #liberator-completions-content,
#liberator-multiline-output-content,
#liberator-multiline-input {
white-space: pre; white-space: pre;
font-family: -moz-fixed; font-family: -moz-fixed;
margin: 0px; margin: 0px;
} }
#liberator-completions-content *, #liberator-multiline-output-content * { #liberator-completions-content *,
#liberator-multiline-output-content * {
font: inherit; font: inherit;
} }
#liberator-completions-content table, #liberator-multiline-output-content table { #liberator-completions-content table,
#liberator-multiline-output-content table {
white-space: inherit; white-space: inherit;
border-spacing: 0px; border-spacing: 0px;
} }
#liberator-completions-content td, #liberator-multiline-output-content td, #liberator-completions-content td,
#liberator-completions-content th, #liberator-multiline-output-content th { #liberator-multiline-output-content td,
#liberator-completions-content th,
#liberator-multiline-output-content th {
padding: 0px 2px; padding: 0px 2px;
} }