// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2008-2014 Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
}
[this.commandbar.container, this.statusbar.container].forEach(check);
- // Work around a redrawing bug.
- if (changed && config.haveGecko("16", "20")) {
- util.delay(function () {
- // Urgh.
- statusline.statusBar.style.paddingRight = "1px";
- DOM(statusline.statusBar).rect; // Force reflow.
- statusline.statusBar.style.paddingRight = "";
- }, 0);
- }
-
- if (this.initialized && loaded.mow && mow.visible)
+ if (this.initialized && loaded.has("mow") && mow.visible)
mow.resize(false);
},
false);
this.messageCount = commandline.messageCount;
- modes.push(this.mode, this.extendedMode, this.closure);
+ modes.push(this.mode, this.extendedMode, this.bound);
this.widgets.active.commandline.collapsed = false;
this.widgets.prompt = this.prompt;
* Displays the multi-line output of a command, preceded by the last
* executed ex command string.
*
- * @param {XML} xml The output as an E4X XML object.
+ * @param {object} xml The output as a JSON XML object.
*/
commandOutput: function commandOutput(xml) {
if (!this.command)
let action = this._echoLine;
if ((flags & this.FORCE_MULTILINE) || (/\n/.test(data) || !isinstance(data, [_, "String"])) && !(flags & this.FORCE_SINGLELINE))
- action = mow.closure.echo;
+ action = mow.bound.echo;
let checkSingleLine = () => action == this._echoLine;
// So complicated...
if (checkSingleLine() && !this.widgets.mowContainer.collapsed) {
highlightGroup += " Message";
- action = mow.closure.echo;
+ action = mow.bound.echo;
}
else if (!checkSingleLine() && this.widgets.mowContainer.collapsed) {
if (this._lastEcho && this.widgets.message && this.widgets.message[1] == this._lastEcho.msg) {
* pop at any time to close the prompt.
*
* @param {string} prompt The input prompt to use.
- * @param {function(string)} callback
* @param {Object} extra
* @... {function} onChange - A function to be called with the current
* input every time it changes.
* @... {string} default - The initial value that will be returned
* if the user presses <CR> straightaway. @default ""
*/
- input: function _input(prompt, callback, extra = {}) {
- CommandPromptMode(prompt, update({ onSubmit: callback }, extra)).open();
- },
+ input: promises.withCallbacks(function _input([callback, reject], prompt, extra={}, thing={}) {
+ if (callable(extra))
+ // Deprecated.
+ [callback, extra] = [extra, thing];
+
+ CommandPromptMode(prompt, update({ onSubmit: callback, onCancel: reject }, extra)).open();
+ }),
readHeredoc: function readHeredoc(end) {
- let args;
- commandline.inputMultiline(end, function (res) { args = res; });
- util.waitFor(() => args !== undefined);
- return args;
+ return util.waitFor(commandline.inputMultiline(end));
},
/**
* callback with that string as a parameter.
*
* @param {string} end
- * @param {function(string)} callback
+ * @returns {Promise<string>}
*/
// FIXME: Buggy, especially when pasting.
- inputMultiline: function inputMultiline(end, callback) {
+ inputMultiline: promises.withCallbacks(function inputMultiline([callback], end) {
let cmd = this.command;
let self = {
end: "\n" + end + "\n",
this._autosizeMultilineInputWidget();
this.timeout(function () { dactyl.focus(this.widgets.multilineInput); }, 10);
- },
+ }),
get commandMode() this.commandSession && isinstance(modes.main, modes.COMMAND_LINE),
if (privateData == "never-save")
return;
- this.store = this.store.filter(line => (line.value || line) != str);
- dactyl.trapErrors(function () {
- this.store.push({ value: str, timestamp: Date.now() * 1000, privateData: privateData });
- }, this);
- this.store = this.store.slice(Math.max(0, this.store.length - options["history"]));
+ let store = Array.filter(this.store, line => (line.value || line) != str);
+ dactyl.trapErrors(
+ () => store.push({ value: str, timestamp: Date.now() * 1000, privateData: privateData }));
+ this.store = store.slice(Math.max(0, store.length - options["history"]));
},
/**
* @property {function} Returns whether a data item should be
this.itemList = commandline.completionList;
this.itemList.open(this.context);
- dactyl.registerObserver("events.doneFeeding", this.closure.onDoneFeeding, true);
+ dactyl.registerObserver("events.doneFeeding", this.bound.onDoneFeeding, true);
this.autocompleteTimer = Timer(200, 500, function autocompleteTell(tabPressed) {
if (events.feedingKeys && !tabPressed)
* called.
*/
cleanup: function cleanup() {
- dactyl.unregisterObserver("events.doneFeeding", this.closure.onDoneFeeding);
+ dactyl.unregisterObserver("events.doneFeeding", this.bound.onDoneFeeding);
this.previewClear();
this.tabTimer.reset();
* @default {@link #selected}
* @returns {object}
*/
- getItem: function getItem(tuple = this.selected)
+ getItem: function getItem(tuple=this.selected)
tuple && tuple[0] && tuple[0].items[tuple[1]],
/**
* @default false
* @private
*/
- select: function select(idx, count = 1, fromTab = false) {
+ select: function select(idx, count=1, fromTab=false) {
switch (idx) {
case this.UP:
case this.DOWN:
this.resize(flags);
}, this);
- DOM(this.win).resize(this._onResize.closure.tell);
+ DOM(this.win).resize(this._onResize.bound.tell);
},
get rootXML()
if (start < 0 || start >= this.itemCount)
return null;
- group = array.nth(groups, g => let (i = start - g.offsets.start) i >= 0 && i < g.itemCount, 0);
+ group = groups.find(g => let (i = start - g.offsets.start) i >= 0 && i < g.itemCount);
return [group.context, start - group.offsets.start];
},
// We need to collect all of the rescrolling functions in
// one go, as the height calculation that they need to do
- // would force a reflow after each DOM modification.
+ // would force an expensive reflow after each call due to
+ // DOM modifications, otherwise.
this.activeGroups.filter(g => !g.collapsed)
.map(g => g.rescrollFunc)
.forEach(call);
getGroup: function getGroup(context)
context instanceof ItemList.Group ? context
: context && context.getCache("itemlist-group",
- bind("Group", ItemList, this, context)),
+ () => ItemList.Group(this, context)),
getOffset: function getOffset(tuple) tuple && this.getGroup(tuple[0]).getOffset(tuple[1])
}, {
first = row;
let container = DOM(this.nodes.items);
- let before = first ? DOM(first).closure.before
- : DOM(this.nodes.items).closure.append;
+ let before = first ? DOM(first).bound.before
+ : DOM(this.nodes.items).bound.append;
for (let [i, row] in this.context.getRows(range.start, range.end,
this.doc)) {