mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 22:28:00 +01:00
Allow <Tab> completion of ;hint modes (again).
This commit is contained in:
@@ -598,8 +598,17 @@ function Hints() //{{{
|
|||||||
|
|
||||||
mappings.add(myModes, [";"],
|
mappings.add(myModes, [";"],
|
||||||
"Start an extended hint mode",
|
"Start an extended hint mode",
|
||||||
function (arg) { hints.show(arg); },
|
function (arg) {
|
||||||
{ flags: Mappings.flags.ARGUMENT });
|
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 //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
@@ -620,7 +629,7 @@ function Hints() //{{{
|
|||||||
liberator.beep();
|
liberator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
commandline.input(hintMode.prompt + ":", null, { onChange: onInput });
|
commandline.input(hintMode.prompt + ": ", null, { onChange: onInput });
|
||||||
modes.extended = modes.HINTS;
|
modes.extended = modes.HINTS;
|
||||||
|
|
||||||
submode = minor;
|
submode = minor;
|
||||||
|
|||||||
@@ -1026,7 +1026,7 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
if (urls.length > 20 && !force)
|
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) {
|
function (resp) {
|
||||||
if (resp && resp.match(/^y(es)?$/i))
|
if (resp && resp.match(/^y(es)?$/i))
|
||||||
liberator.open(urls, where, true);
|
liberator.open(urls, where, true);
|
||||||
|
|||||||
@@ -152,6 +152,8 @@ const modes = (function () //{{{
|
|||||||
mainModes.push(this[name]);
|
mainModes.push(this[name]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getMode: function (name) modeMap[name],
|
||||||
|
|
||||||
// show the current mode string in the command line
|
// show the current mode string in the command line
|
||||||
show: function ()
|
show: function ()
|
||||||
{
|
{
|
||||||
@@ -180,12 +182,12 @@ const modes = (function () //{{{
|
|||||||
// if a main mode is set, the extended is always cleared
|
// if a main mode is set, the extended is always cleared
|
||||||
if (typeof mainMode === "number")
|
if (typeof mainMode === "number")
|
||||||
{
|
{
|
||||||
|
if (!silent && mainMode != main)
|
||||||
|
handleModeChange(main, mainMode);
|
||||||
|
|
||||||
main = mainMode;
|
main = mainMode;
|
||||||
if (!extendedMode)
|
if (!extendedMode)
|
||||||
extended = modes.NONE;
|
extended = modes.NONE;
|
||||||
|
|
||||||
if (!silent && mainMode != main)
|
|
||||||
handleModeChange(main, mainMode);
|
|
||||||
}
|
}
|
||||||
if (typeof extendedMode === "number")
|
if (typeof extendedMode === "number")
|
||||||
extended = extendedMode;
|
extended = extendedMode;
|
||||||
|
|||||||
@@ -375,22 +375,21 @@ function CommandLine() //{{{
|
|||||||
liberator.registerCallback("cancel", modes.PROMPT, closePrompt);
|
liberator.registerCallback("cancel", modes.PROMPT, closePrompt);
|
||||||
liberator.registerCallback("submit", modes.PROMPT, closePrompt);
|
liberator.registerCallback("submit", modes.PROMPT, closePrompt);
|
||||||
liberator.registerCallback("change", modes.PROMPT, function (str) {
|
liberator.registerCallback("change", modes.PROMPT, function (str) {
|
||||||
|
liberator.triggerCallback("change", modes.EX, str);
|
||||||
if (promptChangeCallback)
|
if (promptChangeCallback)
|
||||||
return promptChangeCallback(str);
|
return promptChangeCallback.call(commandline, str);
|
||||||
});
|
});
|
||||||
liberator.registerCallback("complete", modes.PROMPT, function (context) {
|
liberator.registerCallback("complete", modes.PROMPT, function (context) {
|
||||||
if (promptCompleter)
|
if (promptCompleter)
|
||||||
promptCompleter(context);
|
context.fork("input", 0, commandline, promptCompleter);
|
||||||
});
|
});
|
||||||
|
|
||||||
function closePrompt(value)
|
function closePrompt(value)
|
||||||
{
|
{
|
||||||
let callback = promptSubmitCallback;
|
let callback = promptSubmitCallback;
|
||||||
promptSubmitCallback = null;
|
promptSubmitCallback = null;
|
||||||
currentExtendedMode = null;
|
|
||||||
commandline.clear();
|
|
||||||
if (callback)
|
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
|
// normally used when pressing esc, does not execute a command
|
||||||
close: function close()
|
close: function close()
|
||||||
{
|
{
|
||||||
let res = liberator.triggerCallback("cancel", currentExtendedMode);
|
let mode = currentExtendedMode;
|
||||||
|
currentExtendedMode = null;
|
||||||
|
liberator.triggerCallback("cancel", mode);
|
||||||
|
|
||||||
inputHistory.add(this.getCommand());
|
inputHistory.add(this.getCommand());
|
||||||
statusline.updateProgress(""); // we may have a "match x of y" visible
|
statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||||
|
liberator.focusContent(false);
|
||||||
|
|
||||||
this.clear();
|
this.clear();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -911,11 +915,15 @@ function CommandLine() //{{{
|
|||||||
promptSubmitCallback = callback;
|
promptSubmitCallback = callback;
|
||||||
promptChangeCallback = extra.onChange;
|
promptChangeCallback = extra.onChange;
|
||||||
promptCompleter = extra.completer;
|
promptCompleter = extra.completer;
|
||||||
|
|
||||||
modes.push(modes.COMMAND_LINE, modes.PROMPT);
|
modes.push(modes.COMMAND_LINE, modes.PROMPT);
|
||||||
currentExtendedMode = modes.PROMPT;
|
currentExtendedMode = modes.PROMPT;
|
||||||
setPrompt(prompt + " ", this.HL_QUESTION);
|
|
||||||
|
setPrompt(prompt, extra.promptHighlight || this.HL_QUESTION);
|
||||||
setCommand(extra.default || "");
|
setCommand(extra.default || "");
|
||||||
commandWidget.focus();
|
commandWidget.focus();
|
||||||
|
|
||||||
|
completions = new Completions(CompletionContext(commandWidget.inputField.editor));
|
||||||
},
|
},
|
||||||
|
|
||||||
// reads a multi line input and returns the string once the last line matches
|
// reads a multi line input and returns the string once the last line matches
|
||||||
@@ -938,7 +946,8 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
onEvent: function onEvent(event)
|
onEvent: function onEvent(event)
|
||||||
{
|
{
|
||||||
completions.previewClear();
|
if (completions)
|
||||||
|
completions.previewClear();
|
||||||
let command = this.getCommand();
|
let command = this.getCommand();
|
||||||
|
|
||||||
if (event.type == "blur")
|
if (event.type == "blur")
|
||||||
@@ -979,14 +988,10 @@ function CommandLine() //{{{
|
|||||||
// FIXME: <Esc> should trigger "cancel" event
|
// FIXME: <Esc> should trigger "cancel" event
|
||||||
if (events.isAcceptKey(key))
|
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" */
|
currentExtendedMode = null; /* Don't let modes.pop trigger "cancel" */
|
||||||
inputHistory.add(command);
|
modes.pop();
|
||||||
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);
|
return liberator.triggerCallback("submit", mode, command);
|
||||||
}
|
}
|
||||||
// user pressed UP or DOWN arrow to cycle history completion
|
// user pressed UP or DOWN arrow to cycle history completion
|
||||||
|
|||||||
Reference in New Issue
Block a user