1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 22:07:58 +01:00

Allow <Tab> completion of ;hint modes (again).

This commit is contained in:
Kris Maglione
2008-12-04 08:18:10 -05:00
parent 6c9fc50317
commit bcb9775b03
4 changed files with 38 additions and 22 deletions

View File

@@ -598,8 +598,17 @@ function Hints() //{{{
mappings.add(myModes, [";"],
"Start an extended hint mode",
function (arg) { hints.show(arg); },
{ flags: Mappings.flags.ARGUMENT });
function (arg) {
commandline.input(";", function (arg) { setTimeout(function () hints.show(arg), 0) },
{
promptHighlight: "Normal",
completer: function (context) {
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hintModes))];
},
onChange: function () { modes.pop() }
});
});
//{ flags: Mappings.flags.ARGUMENT });
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
@@ -620,7 +629,7 @@ function Hints() //{{{
liberator.beep();
return;
}
commandline.input(hintMode.prompt + ":", null, { onChange: onInput });
commandline.input(hintMode.prompt + ": ", null, { onChange: onInput });
modes.extended = modes.HINTS;
submode = minor;

View File

@@ -1026,7 +1026,7 @@ const liberator = (function () //{{{
if (urls.length > 20 && !force)
{
commandline.input("This will open " + urls.length + " new tabs. Would you like to continue? (yes/[no])",
commandline.input("This will open " + urls.length + " new tabs. Would you like to continue? (yes/[no]) ",
function (resp) {
if (resp && resp.match(/^y(es)?$/i))
liberator.open(urls, where, true);

View File

@@ -152,6 +152,8 @@ const modes = (function () //{{{
mainModes.push(this[name]);
},
getMode: function (name) modeMap[name],
// show the current mode string in the command line
show: function ()
{
@@ -180,12 +182,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

@@ -375,22 +375,21 @@ function CommandLine() //{{{
liberator.registerCallback("cancel", modes.PROMPT, closePrompt);
liberator.registerCallback("submit", modes.PROMPT, closePrompt);
liberator.registerCallback("change", modes.PROMPT, function (str) {
liberator.triggerCallback("change", modes.EX, str);
if (promptChangeCallback)
return promptChangeCallback(str);
return promptChangeCallback.call(commandline, str);
});
liberator.registerCallback("complete", modes.PROMPT, function (context) {
if (promptCompleter)
promptCompleter(context);
context.fork("input", 0, commandline, promptCompleter);
});
function closePrompt(value)
{
let callback = promptSubmitCallback;
promptSubmitCallback = null;
currentExtendedMode = null;
commandline.clear();
if (callback)
callback(value);
callback.call(commandline, value == null ? commandline.getCommand() : value);
}
/////////////////////////////////////////////////////////////////////////////}}}
@@ -845,9 +844,14 @@ function CommandLine() //{{{
// normally used when pressing esc, does not execute a command
close: function close()
{
let res = liberator.triggerCallback("cancel", currentExtendedMode);
let mode = currentExtendedMode;
currentExtendedMode = null;
liberator.triggerCallback("cancel", mode);
inputHistory.add(this.getCommand());
statusline.updateProgress(""); // we may have a "match x of y" visible
liberator.focusContent(false);
this.clear();
},
@@ -911,11 +915,15 @@ 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);
setPrompt(prompt, extra.promptHighlight || 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
@@ -938,6 +946,7 @@ function CommandLine() //{{{
onEvent: function onEvent(event)
{
if (completions)
completions.previewClear();
let command = this.getCommand();
@@ -979,14 +988,10 @@ function CommandLine() //{{{
// FIXME: <Esc> should trigger "cancel" event
if (events.isAcceptKey(key))
{
let mode = currentExtendedMode; // save it here, as setMode() resets it
let mode = currentExtendedMode; // save it here, as modes.pop() 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
modes.pop();
return liberator.triggerCallback("submit", mode, command);
}
// user pressed UP or DOWN arrow to cycle history completion