1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-06 14:35:46 +01:00

Backout last change. Something broke just before I committed.

This commit is contained in:
Kris Maglione
2008-12-03 21:49:49 -05:00
parent 3592723aad
commit 35f807a046
5 changed files with 36 additions and 61 deletions

View File

@@ -598,18 +598,8 @@ function Hints() //{{{
mappings.add(myModes, [";"],
"Start an extended hint mode",
function (arg) {
commandline.input(";", function (arg) {
setTimeout(function () { hints.show(arg) }, 0);
},
{
completer: function (context) {
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hintModes))]
},
onChange: function () { commandline.close() }
});
});
//{ flags: Mappings.flags.ARGUMENT });
function (arg) { hints.show(arg); },
{ flags: Mappings.flags.ARGUMENT });
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////

View File

@@ -600,14 +600,14 @@ const liberator = (function () //{{{
callbacks.push([type, mode, func]);
},
triggerCallback: function (type, mode)
triggerCallback: function (type, mode, data)
{
// liberator.dump("type: " + type + " mode: " + mode + "data: " + data + "\n");
for (let [,callback] in Iterator(callbacks))
for (let i = 0; i < callbacks.length; i++)
{
var [thistype, thismode, thisfunc] = callbacks;
var [thistype, thismode, thisfunc] = callbacks[i];
if (mode == thismode && type == thistype)
return thisfunc.apply(this, Array.slice(arguments, 2));
return thisfunc.call(this, data);
}
return false;
},

View File

@@ -105,7 +105,7 @@ const modes = (function () //{{{
case modes.COMMAND_LINE:
// clean up for HINT mode
if (modes.extended & modes.HINTS)
hints.hide();
hints.hide();
commandline.close();
break;
}
@@ -152,11 +152,6 @@ const modes = (function () //{{{
mainModes.push(this[name]);
},
getMode: function (name)
{
return modeMap[name];
},
// show the current mode string in the command line
show: function ()
{
@@ -185,12 +180,12 @@ const modes = (function () //{{{
// if a main mode is set, the extended is always cleared
if (typeof mainMode === "number")
{
if (!silent && mainMode != main)
handleModeChange(main, mainMode);
main = mainMode;
if (!extendedMode)
extended = modes.NONE;
if (!silent && mainMode != main)
handleModeChange(main, mainMode);
}
if (typeof extendedMode === "number")
extended = extendedMode;

View File

@@ -45,7 +45,7 @@ function Option(names, description, type, defaultValue, extraInfo) //{{{
this.description = description || "";
// "", 0 are valid default values
this.defaultValue = (defaultValue == null) ? null : defaultValue;
this.defaultValue = (defaultValue === undefined) ? null : defaultValue;
this.setter = extraInfo.setter || null;
this.getter = extraInfo.getter || null;
@@ -73,7 +73,7 @@ function Option(names, description, type, defaultValue, extraInfo) //{{{
}
Option.prototype = {
get globalvalue() options.store.get(this.name),
set globalvalue(val) options.store.set(this.name, val),
set globalvalue(val) { options.store.set(this.name, val) },
parseValues: function (value)
{

View File

@@ -356,6 +356,11 @@ function CommandLine() //{{{
////////////////////// CALLBACKS ///////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
// callback for prompt mode
var promptSubmitCallback = null;
var promptChangeCallback = null;
var promptCompleter = null;
liberator.registerCallback("submit", modes.EX, function (command) { liberator.execute(command); });
liberator.registerCallback("complete", modes.EX, function (context) {
context.fork("ex", 0, completion, "ex");
@@ -369,20 +374,15 @@ function CommandLine() //{{{
liberator.registerCallback("cancel", modes.PROMPT, closePrompt);
liberator.registerCallback("submit", modes.PROMPT, closePrompt);
liberator.registerCallback("change", modes.PROMPT, function (str, ok) {
liberator.triggerCallback("change", modes.EX, str);
liberator.registerCallback("change", modes.PROMPT, function (str) {
if (promptChangeCallback)
promptChangeCallback(str, ok);
return promptChangeCallback(str);
});
liberator.registerCallback("complete", modes.PROMPT, function (context) {
if (promptCompleter)
context.fork("prompt", 0, commandline, promptCompleter);
promptCompleter(context);
});
var promptSubmitCallback = null;
var promptChangeCallback = null;
var promptCompleter = null;
function closePrompt(value)
{
let callback = promptSubmitCallback;
@@ -390,7 +390,7 @@ function CommandLine() //{{{
currentExtendedMode = null;
commandline.clear();
if (callback)
callback.call(commandline, value);
callback(value);
}
/////////////////////////////////////////////////////////////////////////////}}}
@@ -556,22 +556,6 @@ function CommandLine() //{{{
return arg;
}
function close(callback)
{
let command = commandline.getCommand();
inputHistory.add(command);
commandline.resetCompletions();
completionList.hide();
statusline.updateProgress(""); // we may have a "match x of y" visible
let mode = currentExtendedMode; // save it here, as setMode() resets it
currentExtendedMode = null; /* Don't let modes.pop trigger "cancel" */
modes.pop(!commandline.silent);
liberator.focusContent(false);
return liberator.triggerCallback(callback, mode, command, callback == "submit");
}
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// OPTIONS /////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -858,9 +842,11 @@ function CommandLine() //{{{
},
// normally used when pressing esc, does not execute a command
close: function ()
close: function close()
{
close("cancel");
let res = liberator.triggerCallback("cancel", currentExtendedMode);
inputHistory.add(this.getCommand());
statusline.updateProgress(""); // we may have a "match x of y" visible
this.clear();
},
@@ -924,14 +910,11 @@ function CommandLine() //{{{
promptSubmitCallback = callback;
promptChangeCallback = extra.onChange;
promptCompleter = extra.completer;
modes.push(modes.COMMAND_LINE, modes.PROMPT);
currentExtendedMode = modes.PROMPT;
setPrompt(prompt + " ", this.HL_QUESTION);
setCommand(extra.default || "");
commandWidget.focus();
completions = new Completions(CompletionContext(commandWidget.inputField.editor));
},
// reads a multi line input and returns the string once the last line matches
@@ -954,8 +937,7 @@ function CommandLine() //{{{
onEvent: function onEvent(event)
{
if (completions)
completions.previewClear();
completions.previewClear();
let command = this.getCommand();
if (event.type == "blur")
@@ -973,7 +955,7 @@ function CommandLine() //{{{
}
else if (event.type == "focus")
{
if (liberator.mode != modes.COMMAND_LINE && event.target == commandWidget.inputField)
if (!currentExtendedMode && event.target == commandWidget.inputField)
{
event.target.blur();
liberator.beep();
@@ -996,7 +978,15 @@ function CommandLine() //{{{
// FIXME: <Esc> should trigger "cancel" event
if (events.isAcceptKey(key))
{
return close("submit");
let mode = currentExtendedMode; // save it here, as setMode() resets it
currentExtendedMode = null; /* Don't let modes.pop trigger "cancel" */
inputHistory.add(command);
modes.pop(!commandline.silent);
this.resetCompletions();
completionList.hide();
liberator.focusContent(false);
statusline.updateProgress(""); // we may have a "match x of y" visible
return liberator.triggerCallback("submit", mode, command);
}
// user pressed UP or DOWN arrow to cycle history completion
else if (/^(<Up>|<Down>|<S-Up>|<S-Down>|<PageUp>|<PageDown>)$/.test(key))