return this.commandbar;
}
});
+ this.updateVisibility();
},
addElement: function addElement(obj) {
const self = this;
if (obj.value != null)
return [obj.value[0],
obj.get ? obj.get.call(this, elem) : elem.value]
- .concat(obj.value.slice(2))
+ .concat(obj.value.slice(2));
return null;
},
});
var CommandMode = Class("CommandMode", {
- init: function init() {
+ init: function CM_init() {
this.keepCommand = userContext.hidden_option_command_afterimage;
},
+ get autocomplete() options["autocomplete"].length,
+
get command() this.widgets.command[1],
set command(val) this.widgets.command = val,
get prompt() this.widgets.prompt,
set prompt(val) this.widgets.prompt = val,
- open: function (command) {
+ open: function CM_open(command) {
dactyl.assert(isinstance(this.mode, modes.COMMAND_LINE),
- "Not opening command line in non-command-line mode.");
+ /*L*/"Not opening command line in non-command-line mode.");
this.messageCount = commandline.messageCount;
modes.push(this.mode, this.extendedMode, this.closure);
get widgets() commandline.widgets,
- enter: function (stack) {
+ enter: function CM_enter(stack) {
commandline.commandSession = this;
if (stack.pop && commandline.command) {
this.onChange(commandline.command);
}
},
- leave: function (stack) {
+ leave: function CM_leave(stack) {
if (!stack.push) {
commandline.commandSession = null;
this.input.dactylKeyPress = undefined;
},
events: {
- input: function onInput(event) {
+ input: function CM_onInput(event) {
if (this.completions) {
this.resetCompletions();
}
this.onChange(commandline.command);
},
- keyup: function onKeyUp(event) {
+ keyup: function CM_onKeyUp(event) {
let key = events.toString(event);
if (/-?Tab>$/.test(key) && this.completions)
this.completions.tabTimer.flush();
keepCommand: false,
- onKeyPress: function onKeyPress(events) {
+ onKeyPress: function CM_onKeyPress(events) {
if (this.completions)
this.completions.previewClear();
return true; /* Pass event */
},
- onCancel: function (value) {
- },
+ onCancel: function (value) {},
- onChange: function (value) {
- },
+ onChange: function (value) {},
- onSubmit: function (value) {
- },
+ onHistory: function (value) {},
+
+ onSubmit: function (value) {},
- resetCompletions: function resetCompletions() {
+ resetCompletions: function CM_resetCompletions() {
if (this.completions) {
this.completions.context.cancelAll();
this.completions.wildIndex = -1;
prompt: ["Normal", ":"],
- complete: function complete(context) {
+ complete: function CEM_complete(context) {
context.fork("ex", 0, completion, "ex");
},
- onSubmit: function onSubmit(command) {
- contexts.withContext({ file: "[Command Line]", line: 1 },
+ onSubmit: function CEM_onSubmit(command) {
+ contexts.withContext({ file: /*L*/"[Command Line]", line: 1 },
function _onSubmit() {
io.withSavedValues(["readHeredoc"], function _onSubmit() {
this.readHeredoc = commandline.readHeredoc;
init.supercall(this);
},
- complete: function (context) {
+ complete: function CPM_complete(context) {
if (this.completer)
context.forkapply("prompt", 0, this, "completer", Array.slice(arguments, 1));
},
get completionList() {
let node = this.widgets.active.commandline;
+ if (this.commandSession && this.commandSession.completionList)
+ node = document.getElementById(this.commandSession.completionList);
+
if (!node.completionList) {
let elem = document.getElementById("dactyl-completions-" + node.id);
util.waitFor(bind(this.widgets._ready, null, elem));
* @param {XML} xml The output as an E4X XML object.
*/
commandOutput: function commandOutput(xml) {
- XML.ignoreWhitespace = false;
- XML.prettyPrinting = false;
+ XML.ignoreWhitespace = XML.prettyPrinting = false;
if (this.command)
- this.echo(<>:{this.command}</>, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
- this.echo(xml, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
+ this.echo(<><div xmlns={XHTML}>:{this.command}</div>
{xml}</>, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
+ else
+ this.echo(xml, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
this.command = null;
},
if (flags & this.APPEND_TO_MESSAGES) {
let message = isObject(data) ? data : { message: data };
+
+ // Make sure the memoized message property is an instance property.
+ message.message;
this._messageHistory.add(update({ highlight: highlightGroup }, message));
data = message.message;
}
let single = flags & (this.FORCE_SINGLELINE | this.DISALLOW_MULTILINE);
let action = this._echoLine;
- if ((flags & this.FORCE_MULTILINE) || (/\n/.test(data) || !isString(data)) && !(flags & this.FORCE_SINGLELINE))
+ if ((flags & this.FORCE_MULTILINE) || (/\n/.test(data) || !isinstance(data, [_, "String"])) && !(flags & this.FORCE_SINGLELINE))
action = mow.closure.echo;
if (single)
// FIXME: Buggy, especially when pasting.
inputMultiline: function inputMultiline(end, callback) {
let cmd = this.command;
+ let self = {
+ end: "\n" + end + "\n",
+ callback: callback
+ };
+
modes.push(modes.INPUT_MULTILINE, null, {
- mappingSelf: {
- end: "\n" + end + "\n",
- callback: callback
- }
+ holdFocus: true,
+ leave: function leave() {
+ if (!self.done)
+ self.callback(null);
+ },
+ mappingSelf: self
});
+
if (cmd != false)
this._echoLine(cmd, this.HL_NORMAL);
event.target.blur();
dactyl.beep();
}
- },
+ }
}
),
if (this.completions)
this.completions.previewClear();
this.input.value = val;
+ this.session.onHistory(val);
},
/**
dactyl.registerObserver("events.doneFeeding", this.closure.onDoneFeeding, true);
this.autocompleteTimer = Timer(200, 500, function autocompleteTell(tabPressed) {
- if (events.feedingKeys)
+ if (events.feedingKeys && !tabPressed)
this.ignoredCount++;
- if (options["autocomplete"].length) {
+ else if (this.session.autocomplete) {
this.itemList.visible = true;
this.complete(true, false);
}
get wildtype() this.wildtypes[this.wildIndex] || "",
complete: function complete(show, tabPressed) {
+ this.session.ignoredCount = 0;
this.context.reset();
this.context.tabPressed = tabPressed;
this.session.complete(this.context);
for (let [, context] in Iterator(list)) {
let done = function done() !(idx >= n + context.items.length || idx == -2 && !context.items.length);
- util.waitFor(function () !context.incomplete || done())
+ util.waitFor(function () !context.incomplete || done());
if (done())
break;
tab: function tab(reverse, wildmode) {
this.autocompleteTimer.flush();
+ this.ignoredCount = 0;
if (this._caret != this.caret)
this.reset();
if (this.selected == null)
statusline.progress = "";
else
- statusline.progress = "match " + (this.selected + 1) + " of " + this.items.length;
+ statusline.progress = _("completion.matchIndex", this.selected + 1, this.items.length);
}
if (this.items.length == 0)
mappings: function init_mappings() {
mappings.add([modes.COMMAND],
- [":"], "Enter command-line mode",
+ [":"], "Enter Command Line mode",
function () { CommandExMode().open(""); });
mappings.add([modes.INPUT_MULTILINE],
let index = text.indexOf(self.end);
if (index >= 0) {
+ self.done = true;
text = text.substring(1, index);
modes.pop();
_init: function _init() {
this._div = this._dom(
<div class="ex-command-output" highlight="Normal" style="white-space: nowrap">
- <div highlight="Completions" key="noCompletions"><span highlight="Title">No Completions</span></div>
+ <div highlight="Completions" key="noCompletions"><span highlight="Title">{_("completion.noCompletions")}</span></div>
<div key="completions"/>
<div highlight="Completions">
{
onKeyPress: function onKeyPress(event) false
}, {
- WAITING_MESSAGE: "Generating results..."
+ WAITING_MESSAGE: _("completion.generating")
});
// vim: set fdm=marker sw=4 ts=4 et: