mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 05:37:58 +01:00
Add separate echo/command-line widgets
This commit is contained in:
@@ -298,8 +298,6 @@ function Events() //{{{
|
||||
{
|
||||
// TODO: is all of that necessary?
|
||||
modes.reset();
|
||||
commandline.clear();
|
||||
modes.show();
|
||||
statusline.updateTabCount();
|
||||
tabs.updateSelectionHistory();
|
||||
|
||||
@@ -1179,7 +1177,6 @@ function Events() //{{{
|
||||
selection.collapseToStart();
|
||||
}
|
||||
catch (e) {}
|
||||
commandline.clear();
|
||||
|
||||
modes.reset();
|
||||
liberator.focusContent(true);
|
||||
|
||||
@@ -1215,6 +1215,8 @@ const liberator = (function () //{{{
|
||||
config.dialogs = config.dialogs || [];
|
||||
config.helpFiles = config.helpFiles || [];
|
||||
|
||||
liberator.triggerObserver("load");
|
||||
|
||||
// commands must always be the first module to be initialized
|
||||
loadModule("commands", Commands);
|
||||
loadModule("options", Options);
|
||||
|
||||
@@ -79,13 +79,16 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
onclick="liberator.modules.commandline.onMultilineOutputEvent(event)"/>
|
||||
</vbox>
|
||||
|
||||
<hbox id="liberator-commandline" hidden="false" liberator:highlight="Normal">
|
||||
<label class="plain" id="liberator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox class="plain" id="liberator-commandline-command" flex="1" type="timed" timeout="100"
|
||||
oninput="liberator.modules.commandline.onEvent(event);"
|
||||
onfocus="liberator.modules.commandline.onEvent(event);"
|
||||
onblur="liberator.modules.commandline.onEvent(event);"/>
|
||||
</hbox>
|
||||
<stack orient="horizontal" align="stretch" class="liberator-container" liberator:highlight="CmdLine">
|
||||
<textbox class="plain" id="liberator-message" flex="1" readonly="true" liberator:highlight="Normal"/>
|
||||
<hbox id="liberator-commandline" hidden="false" class="liberator-container" liberator:highlight="Normal">
|
||||
<label class="plain" id="liberator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox class="plain" id="liberator-commandline-command" flex="1" type="timed" timeout="100"
|
||||
oninput="liberator.modules.commandline.onEvent(event);"
|
||||
onfocus="liberator.modules.commandline.onEvent(event);"
|
||||
onblur="liberator.modules.commandline.onEvent(event);"/>
|
||||
</hbox>
|
||||
</stack>
|
||||
|
||||
<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"
|
||||
|
||||
@@ -159,12 +159,7 @@ const modes = (function () //{{{
|
||||
if (!options["showmode"])
|
||||
return;
|
||||
|
||||
// never show mode messages if we are in command line mode
|
||||
if (main == modes.COMMAND_LINE)
|
||||
return;
|
||||
|
||||
commandline.echo(getModeMessage(), commandline.HL_MODEMSG,
|
||||
commandline.DISALLOW_MULTILINE);
|
||||
commandline.echo(getModeMessage(), "ModeMsg");
|
||||
},
|
||||
|
||||
// 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
|
||||
set: function (mainMode, extendedMode, silent)
|
||||
{
|
||||
silent = (silent || main == mainMode && extended == extendedMode);
|
||||
// if a main mode is set, the extended is always cleared
|
||||
if (typeof mainMode === "number")
|
||||
{
|
||||
|
||||
@@ -24,6 +24,8 @@ Highlights.prototype.CSS = <![CDATA[
|
||||
NonText color: blue; min-height: 16px; padding-left: 2px;
|
||||
Preview color: gray;
|
||||
|
||||
CmdLine font-family: monospace; padding: 1px;
|
||||
|
||||
CompGroup
|
||||
CompGroup:not(:first-of-type) margin-top: .5em;
|
||||
CompTitle color: magenta; background: white; font-weight: bold;
|
||||
|
||||
@@ -430,7 +430,11 @@ function CommandLine() //{{{
|
||||
// the command bar which contains the current command
|
||||
const commandWidget = document.getElementById("liberator-commandline-command");
|
||||
|
||||
|
||||
const messageBox = document.getElementById("liberator-message");
|
||||
|
||||
commandWidget.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
|
||||
messageBox.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
|
||||
|
||||
// the widget used for multiline output
|
||||
const multilineOutputWidget = document.getElementById("liberator-multiline-output");
|
||||
@@ -454,9 +458,13 @@ function CommandLine() //{{{
|
||||
|
||||
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 /
|
||||
function setPrompt(pmt, highlightGroup)
|
||||
{
|
||||
@@ -483,15 +491,16 @@ function CommandLine() //{{{
|
||||
function setLine(str, highlightGroup, forceSingle)
|
||||
{
|
||||
setHighlightGroup(highlightGroup);
|
||||
setPrompt("");
|
||||
setCommand(str);
|
||||
if (!forceSingle &&
|
||||
commandWidget.inputField.editor.rootElement
|
||||
.scrollWidth > commandWidget.inputField.scrollWidth)
|
||||
{
|
||||
setCommand("");
|
||||
messageBox.value = str;
|
||||
|
||||
if (!commandShown())
|
||||
commandline.hide();
|
||||
|
||||
let field = messageBox.inputField;
|
||||
if (!forceSingle && field.editor.rootElement.scrollWidth > field.scrollWidth)
|
||||
setMultiline(<span highlight="Message">{str}</span>, highlightGroup);
|
||||
}
|
||||
else
|
||||
messageBox.collapsed = false;
|
||||
}
|
||||
|
||||
// TODO: extract CSS
|
||||
@@ -847,9 +856,10 @@ function CommandLine() //{{{
|
||||
historyIndex = UNINITIALIZED;
|
||||
|
||||
modes.set(modes.COMMAND_LINE, currentExtendedMode);
|
||||
setHighlightGroup(this.HL_NORMAL);
|
||||
|
||||
setPrompt(currentPrompt);
|
||||
setCommand(currentCommand);
|
||||
commandlineWidget.collapsed = false;
|
||||
|
||||
commandWidget.focus();
|
||||
|
||||
@@ -873,19 +883,19 @@ function CommandLine() //{{{
|
||||
statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||
liberator.focusContent(false);
|
||||
|
||||
this.clear();
|
||||
keepCommand = false;
|
||||
},
|
||||
|
||||
clear: function clear()
|
||||
{
|
||||
multilineInputWidget.collapsed = true;
|
||||
outputContainer.collapsed = true;
|
||||
completionList.hide();
|
||||
this.resetCompletions();
|
||||
|
||||
this.hide();
|
||||
keepCommand = false;
|
||||
},
|
||||
|
||||
hide: function hide()
|
||||
{
|
||||
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
|
||||
@@ -975,13 +985,8 @@ function CommandLine() //{{{
|
||||
{
|
||||
// prevent losing focus, there should be a better way, but it just didn't work otherwise
|
||||
setTimeout(function () {
|
||||
if (liberator.mode == modes.COMMAND_LINE &&
|
||||
!(modes.extended & modes.INPUT_MULTILINE) &&
|
||||
!(modes.extended & modes.OUTPUT_MULTILINE) &&
|
||||
event.originalTarget == commandWidget.inputField)
|
||||
{
|
||||
if (commandShown() && event.originalTarget == commandWidget.inputField)
|
||||
commandWidget.inputField.focus();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
else if (event.type == "focus")
|
||||
@@ -1339,9 +1344,7 @@ function CommandLine() //{{{
|
||||
|
||||
if (passEvent || closeWindow)
|
||||
{
|
||||
// FIXME: use mode stack
|
||||
modes.pop();
|
||||
this.clear();
|
||||
|
||||
if (passEvent)
|
||||
events.onKeyPress(event);
|
||||
@@ -1354,10 +1357,6 @@ function CommandLine() //{{{
|
||||
|
||||
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;
|
||||
function isScrollable() !win.scrollMaxY == 0;
|
||||
function atEnd() win.scrollY / win.scrollMaxY >= 1;
|
||||
|
||||
@@ -96,8 +96,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
@-moz-document
|
||||
url-prefix(chrome://) {
|
||||
|
||||
#liberator-container {
|
||||
font-family: monospace;
|
||||
.liberator-container > * {
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
#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 */
|
||||
#status-bar, statusbarpanel {
|
||||
#status-bar,
|
||||
statusbarpanel {
|
||||
-moz-appearance: none !important;
|
||||
min-height: 18px !important;
|
||||
border: none !important;
|
||||
font-weight: bold;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#liberator-statusline {
|
||||
font-family: monospace;
|
||||
margin: 0px;
|
||||
@@ -138,14 +140,6 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
display: none;
|
||||
}
|
||||
|
||||
#liberator-commandline {
|
||||
padding: 1px;
|
||||
font-family: monospace;
|
||||
/*
|
||||
background-color: white;
|
||||
color: black;
|
||||
*/
|
||||
}
|
||||
#liberator-commandline-prompt {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
@@ -156,11 +150,6 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#liberator-visualbell {
|
||||
border: none;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
max-width: 90% !important;
|
||||
min-width: 10% !important;
|
||||
@@ -168,29 +157,37 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
/* MOW */
|
||||
|
||||
#liberator-completions, #liberator-multiline-output, #liberator-multiline-input {
|
||||
#liberator-completions,
|
||||
#liberator-multiline-output,
|
||||
#liberator-multiline-input {
|
||||
overflow: hidden;
|
||||
background-color: white;
|
||||
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;
|
||||
font-family: -moz-fixed;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#liberator-completions-content *, #liberator-multiline-output-content * {
|
||||
#liberator-completions-content *,
|
||||
#liberator-multiline-output-content * {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
#liberator-completions-content table, #liberator-multiline-output-content table {
|
||||
#liberator-completions-content table,
|
||||
#liberator-multiline-output-content table {
|
||||
white-space: inherit;
|
||||
border-spacing: 0px;
|
||||
}
|
||||
|
||||
#liberator-completions-content td, #liberator-multiline-output-content td,
|
||||
#liberator-completions-content th, #liberator-multiline-output-content th {
|
||||
#liberator-completions-content td,
|
||||
#liberator-multiline-output-content td,
|
||||
#liberator-completions-content th,
|
||||
#liberator-multiline-output-content th {
|
||||
padding: 0px 2px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user