1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-09 06:23:41 +02:00

Fix :time :stuff, etc.

This commit is contained in:
Kris Maglione
2008-12-07 10:48:03 -05:00
parent 419c7ca662
commit 7693ac5000
9 changed files with 32 additions and 37 deletions

View File

@@ -1141,7 +1141,7 @@ function Completion() //{{{
context = context.contexts["/list"]; context = context.contexts["/list"];
context.wait(); context.wait();
let list = template.generic( let list = template.commandOutput(
<div highlight="Completions"> <div highlight="Completions">
{ template.completionRow(context.title, "CompTitle") } { template.completionRow(context.title, "CompTitle") }
{ template.map(context.items, function (item) context.createRow(item), null, 100) } { template.map(context.items, function (item) context.createRow(item), null, 100) }

View File

@@ -207,7 +207,7 @@ function AutoCommands() //{{{
} }
}); });
var list = template.generic( var list = template.commandOutput(
<table> <table>
<tr highlight="Title"> <tr highlight="Title">
<td colspan="2">----- Auto Commands -----</td> <td colspan="2">----- Auto Commands -----</td>

View File

@@ -354,7 +354,7 @@ function Hints() //{{{
} }
hintNumber = 0; hintNumber = 0;
hintString = commandline.getCommand(); hintString = commandline.command;
updateStatusline(); updateStatusline();
showHints(); showHints();
if (validHints.length == 1) if (validHints.length == 1)

View File

@@ -365,7 +365,7 @@ function IO() //{{{
let output = io.system(args); let output = io.system(args);
commandline.echo(template.generic(<span highlight="CmdOutput">{output}</span>)); commandline.commandOutput(template.commandOutput(<span highlight="CmdOutput">{output}</span>));
autocommands.trigger("ShellCmdPost", {}); autocommands.trigger("ShellCmdPost", {});
}, },

View File

@@ -475,7 +475,7 @@ const liberator = (function () //{{{
totalUnits = "msec"; totalUnits = "msec";
} }
var str = template.generic( let str = template.commandOutput(
<table> <table>
<tr highlight="Title" align="left"> <tr highlight="Title" align="left">
<th colspan="3">Code execution summary</th> <th colspan="3">Code execution summary</th>
@@ -528,7 +528,7 @@ const liberator = (function () //{{{
if (args.bang) if (args.bang)
liberator.open("about:"); liberator.open("about:");
else else
liberator.echo(template.generic(<>{config.name} {liberator.version} running on:<br/>{navigator.userAgent}</>)); liberator.echo(template.commandOutput(<>{config.name} {liberator.version} running on:<br/>{navigator.userAgent}</>));
}, },
{ {
argCount: "0", argCount: "0",
@@ -850,10 +850,10 @@ const liberator = (function () //{{{
err = "E477: No ! allowed"; err = "E477: No ! allowed";
} }
if (!err) if (err)
command.execute(args, special, count, modifiers); return liberator.echoerr(err);
else commandline.command = str.replace(/^\s*:\s*/);
liberator.echoerr(err); command.execute(args, special, count, modifiers);
}, },
// TODO: move to buffer.focus()? // TODO: move to buffer.focus()?

View File

@@ -81,7 +81,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
<stack orient="horizontal" align="stretch" class="liberator-container" liberator:highlight="CmdLine"> <stack orient="horizontal" align="stretch" class="liberator-container" liberator:highlight="CmdLine">
<textbox class="plain" id="liberator-message" flex="1" readonly="true" liberator:highlight="Normal"/> <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"> <hbox id="liberator-commandline" hidden="false" collapsed="true" class="liberator-container" liberator:highlight="Normal">
<label class="plain" id="liberator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/> <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" <textbox class="plain" id="liberator-commandline-command" flex="1" type="timed" timeout="100"
oninput="liberator.modules.commandline.onEvent(event);" oninput="liberator.modules.commandline.onEvent(event);"

View File

@@ -159,7 +159,7 @@ const modes = (function () //{{{
if (!options["showmode"]) if (!options["showmode"])
return; return;
commandline.echo(getModeMessage(), "ModeMsg"); commandline.echo(getModeMessage(), "ModeMsg", commandline.DISALLOW_MULTILINE);
}, },
// add/remove always work on the extended mode only // add/remove always work on the extended mode only
@@ -226,8 +226,11 @@ const modes = (function () //{{{
remove: function (mode) remove: function (mode)
{ {
extended &= ~mode; if (extended & mode)
this.show(); {
extended &= ~mode;
this.show();
}
}, },
get passNextKey() passNextKey, get passNextKey() passNextKey,

View File

@@ -204,9 +204,9 @@ const template = {
return str; return str;
}, },
generic: function generic(xml) commandOutput: function generic(xml)
{ {
return <>:{commandline.getCommand()}<br/>{xml}</>; return <>:{commandline.command}<br/>{xml}</>;
}, },
// every item must have a .xml property which defines how to draw itself // every item must have a .xml property which defines how to draw itself

View File

@@ -168,7 +168,7 @@ function CommandLine() //{{{
get completion() get completion()
{ {
let str = commandline.getCommand(); let str = commandline.command;
return str.substring(this.prefix.length, str.length - this.suffix.length); return str.substring(this.prefix.length, str.length - this.suffix.length);
}, },
set completion set_completion(completion) set completion set_completion(completion)
@@ -373,7 +373,7 @@ function CommandLine() //{{{
if (this.substring && this.substring != this.completion) if (this.substring && this.substring != this.completion)
{ {
this.completion = this.substring; this.completion = this.substring;
liberator.triggerCallback("change", currentExtendedMode, commandline.getCommand()); liberator.triggerCallback("change", currentExtendedMode, commandline.command);
} }
break; break;
} }
@@ -412,7 +412,6 @@ function CommandLine() //{{{
}); });
var tabTimer = new util.Timer(0, 0, function tabTell(event) { var tabTimer = new util.Timer(0, 0, function tabTell(event) {
liberator.dump("tabTell");
if (completions) if (completions)
completions.tab(event.shiftKey); completions.tab(event.shiftKey);
}); });
@@ -456,7 +455,7 @@ function CommandLine() //{{{
let callback = promptSubmitCallback; let callback = promptSubmitCallback;
promptSubmitCallback = null; promptSubmitCallback = null;
if (callback) if (callback)
callback.call(commandline, value == null ? commandline.getCommand() : value); callback.call(commandline, value == null ? commandline.command : value);
} }
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
@@ -477,7 +476,6 @@ 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"); const messageBox = document.getElementById("liberator-message");
commandWidget.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement); commandWidget.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement);
@@ -496,6 +494,9 @@ function CommandLine() //{{{
// this is then used if we focus the command line again without the "official" // this is then used if we focus the command line again without the "official"
// way of calling "open" // way of calling "open"
var currentExtendedMode = null; // the extended mode which we last openend the command line for var currentExtendedMode = null; // the extended mode which we last openend the command line for
// modules.__defineGetter__("currentExtendedMode", function () _currentExtendedMode)
// modules.__defineSetter__("currentExtendedMode", function (val) (liberator.dumpStack("currentExtendedMode = " + (val && modes.getMode(val).name)),
// _currentExtendedMode = val))
var currentPrompt = null; var currentPrompt = null;
var currentCommand = null; var currentCommand = null;
@@ -541,8 +542,6 @@ function CommandLine() //{{{
let field = messageBox.inputField; let field = messageBox.inputField;
if (!forceSingle && field.editor.rootElement.scrollWidth > field.scrollWidth) if (!forceSingle && field.editor.rootElement.scrollWidth > field.scrollWidth)
echoMultiline(<span highlight="Message">{str}</span>, highlightGroup); echoMultiline(<span highlight="Message">{str}</span>, highlightGroup);
else
messageBox.collapsed = false;
} }
// TODO: resize upon a window resize // TODO: resize upon a window resize
@@ -871,7 +870,7 @@ function CommandLine() //{{{
storage.styles.removeSheet("silent-mode", null, null, null, true); storage.styles.removeSheet("silent-mode", null, null, null, true);
}, },
getCommand: function getCommand() get command()
{ {
try try
{ {
@@ -880,6 +879,7 @@ function CommandLine() //{{{
catch (e) {} catch (e) {}
return commandWidget.value; return commandWidget.value;
}, },
set command(cmd) commandWidget.value = cmd,
open: function open(prompt, cmd, extendedMode) open: function open(prompt, cmd, extendedMode)
{ {
@@ -890,12 +890,12 @@ function CommandLine() //{{{
currentExtendedMode = extendedMode || null; currentExtendedMode = extendedMode || null;
keepCommand = false; keepCommand = false;
modes.set(modes.COMMAND_LINE, currentExtendedMode);
setPrompt(currentPrompt); setPrompt(currentPrompt);
setCommand(currentCommand); setCommand(currentCommand);
commandlineWidget.collapsed = false; commandlineWidget.collapsed = false;
modes.set(modes.COMMAND_LINE, currentExtendedMode);
commandWidget.focus(); commandWidget.focus();
history = History(commandWidget.inputField, (modes.extended == modes.EX) ? "command" : "search"); history = History(commandWidget.inputField, (modes.extended == modes.EX) ? "command" : "search");
@@ -940,13 +940,8 @@ function CommandLine() //{{{
// 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
echo: function echo(str, highlightGroup, flags) echo: function echo(str, highlightGroup, flags)
{ {
let focused = document.commandDispatcher.focusedElement;
if (focused && focused == commandWidget.inputField || focused == multilineInputWidget.inputField)
return false;
if (silent) if (silent)
return false; return false;
if (modes.main == modes.COMMAND_LINE)
return false;
highlightGroup = highlightGroup || this.HL_NORMAL; highlightGroup = highlightGroup || this.HL_NORMAL;
@@ -956,7 +951,7 @@ function CommandLine() //{{{
// The DOM isn't threadsafe. It must only be accessed from the main thread. // The DOM isn't threadsafe. It must only be accessed from the main thread.
liberator.callInMainThread(function () liberator.callInMainThread(function ()
{ {
let action = echoLine; let action = outputContainer.collapsed ? echoLine : echoMultiline;
if (flags & commandline.FORCE_MULTILINE) if (flags & commandline.FORCE_MULTILINE)
action = echoMultiline; action = echoMultiline;
else if (flags & commandline.FORCE_SINGLELINE) else if (flags & commandline.FORCE_SINGLELINE)
@@ -973,9 +968,6 @@ function CommandLine() //{{{
if (action) if (action)
action(str, highlightGroup, (flags & (this.FORCE_SINGLELINE | this.DISALLOW_MULTILINE))); action(str, highlightGroup, (flags & (this.FORCE_SINGLELINE | this.DISALLOW_MULTILINE)));
// Why do we do this? --Kris
currentExtendedMode = null;
}); });
return true; return true;
@@ -1022,7 +1014,7 @@ function CommandLine() //{{{
onEvent: function onEvent(event) onEvent: function onEvent(event)
{ {
let command = this.getCommand(); let command = this.command;
if (event.type == "blur") if (event.type == "blur")
{ {
@@ -1034,7 +1026,7 @@ function CommandLine() //{{{
} }
else if (event.type == "focus") else if (event.type == "focus")
{ {
if (!currentExtendedMode && event.target == commandWidget.inputField) if (!commandShown() && event.target == commandWidget.inputField)
{ {
event.target.blur(); event.target.blur();
liberator.beep(); liberator.beep();