mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-30 07:13:32 +02:00
Make completions without enough room behave a bit better. This may cause sizing problems. Please test thoroughly.
This commit is contained in:
@@ -497,7 +497,7 @@ function CommandLine() //{{{
|
|||||||
});
|
});
|
||||||
|
|
||||||
var autocompleteTimer = new Timer(200, 500, function autocompleteTell(tabPressed) {
|
var autocompleteTimer = new Timer(200, 500, function autocompleteTell(tabPressed) {
|
||||||
if (!events.feedingKeys && completions)
|
if (!events.feedingKeys && completions && options.get("wildoptions").has("auto"))
|
||||||
{
|
{
|
||||||
completions.complete(true, false);
|
completions.complete(true, false);
|
||||||
completions.itemList.show();
|
completions.itemList.show();
|
||||||
@@ -517,10 +517,7 @@ function CommandLine() //{{{
|
|||||||
////////////////////// CALLBACKS ///////////////////////////////////////////////
|
////////////////////// CALLBACKS ///////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
// callback for prompt mode
|
var input = {};
|
||||||
var promptSubmitCallback = null;
|
|
||||||
var promptChangeCallback = null;
|
|
||||||
var promptCompleter = null;
|
|
||||||
|
|
||||||
liberator.registerCallback("submit", modes.EX, function (command) {
|
liberator.registerCallback("submit", modes.EX, function (command) {
|
||||||
liberator.execute(command);
|
liberator.execute(command);
|
||||||
@@ -529,28 +526,28 @@ function CommandLine() //{{{
|
|||||||
context.fork("ex", 0, completion, "ex");
|
context.fork("ex", 0, completion, "ex");
|
||||||
});
|
});
|
||||||
liberator.registerCallback("change", modes.EX, function (command) {
|
liberator.registerCallback("change", modes.EX, function (command) {
|
||||||
if (options.get("wildoptions").has("auto"))
|
autocompleteTimer.tell(false);
|
||||||
autocompleteTimer.tell(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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 (input.complete)
|
||||||
if (promptChangeCallback)
|
autocompleteTimer.tell(false);
|
||||||
return promptChangeCallback.call(commandline, str);
|
if (input.change)
|
||||||
|
return input.change.call(commandline, str);
|
||||||
});
|
});
|
||||||
liberator.registerCallback("complete", modes.PROMPT, function (context) {
|
liberator.registerCallback("complete", modes.PROMPT, function (context) {
|
||||||
if (promptCompleter)
|
if (input.complete)
|
||||||
context.fork("input", 0, commandline, promptCompleter);
|
context.fork("input", 0, commandline, input.complete);
|
||||||
});
|
});
|
||||||
|
|
||||||
function closePrompt(value)
|
function closePrompt(value)
|
||||||
{
|
{
|
||||||
let callback = promptSubmitCallback;
|
let callback = input.submit;
|
||||||
promptSubmitCallback = null;
|
input = {};
|
||||||
if (callback)
|
if (callback)
|
||||||
callback.call(commandline, value == null ? commandline.command : value);
|
callback.call(commandline, value != null ? value : commandline.command);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -1059,7 +1056,8 @@ function CommandLine() //{{{
|
|||||||
completions = Completions(commandWidget.inputField);
|
completions = Completions(commandWidget.inputField);
|
||||||
|
|
||||||
// open the completion list automatically if wanted
|
// open the completion list automatically if wanted
|
||||||
liberator.triggerCallback("change", currentExtendedMode, cmd);
|
if (cmd.length)
|
||||||
|
liberator.triggerCallback("change", currentExtendedMode, cmd);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1191,13 +1189,15 @@ function CommandLine() //{{{
|
|||||||
* @... {string} promptHighlight - The HighlightGroup used for the
|
* @... {string} promptHighlight - The HighlightGroup used for the
|
||||||
* prompt. @default "Question"
|
* prompt. @default "Question"
|
||||||
*/
|
*/
|
||||||
input: function input(prompt, callback, extra)
|
input: function _input(prompt, callback, extra)
|
||||||
{
|
{
|
||||||
extra = extra || {};
|
extra = extra || {};
|
||||||
|
|
||||||
promptSubmitCallback = callback;
|
input = {
|
||||||
promptChangeCallback = extra.onChange;
|
submit: callback,
|
||||||
promptCompleter = extra.completer;
|
change: extra.onChange,
|
||||||
|
complete: extra.completer,
|
||||||
|
};
|
||||||
|
|
||||||
modes.push(modes.COMMAND_LINE, modes.PROMPT);
|
modes.push(modes.COMMAND_LINE, modes.PROMPT);
|
||||||
currentExtendedMode = modes.PROMPT;
|
currentExtendedMode = modes.PROMPT;
|
||||||
@@ -1731,7 +1731,7 @@ function ItemList(id) //{{{
|
|||||||
div.style.minWidth = "";
|
div.style.minWidth = "";
|
||||||
// FIXME: Belongs elsewhere.
|
// FIXME: Belongs elsewhere.
|
||||||
commandline.updateOutputHeight(false);
|
commandline.updateOutputHeight(false);
|
||||||
container.height -= commandline.getSpaceNeeded();
|
setTimeout(function () { container.height -= commandline.getSpaceNeeded() }, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCompletion(index) completionElements.snapshotItem(index - startIndex);
|
function getCompletion(index) completionElements.snapshotItem(index - startIndex);
|
||||||
@@ -1752,6 +1752,7 @@ function ItemList(id) //{{{
|
|||||||
</div>
|
</div>
|
||||||
</div>, divNodes);
|
</div>, divNodes);
|
||||||
doc.body.replaceChild(div, doc.body.firstChild);
|
doc.body.replaceChild(div, doc.body.firstChild);
|
||||||
|
div.scrollIntoView(true);
|
||||||
|
|
||||||
items.contextList.forEach(function init_eachContext(context) {
|
items.contextList.forEach(function init_eachContext(context) {
|
||||||
delete context.cache.nodes;
|
delete context.cache.nodes;
|
||||||
@@ -1771,6 +1772,8 @@ function ItemList(id) //{{{
|
|||||||
</div>, context.cache.nodes);
|
</div>, context.cache.nodes);
|
||||||
divNodes.completions.appendChild(context.cache.nodes.root);
|
divNodes.completions.appendChild(context.cache.nodes.root);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(function () { autoSize(); }, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1855,7 +1858,6 @@ function ItemList(id) //{{{
|
|||||||
|
|
||||||
completionElements = buffer.evaluateXPath("//xhtml:div[@liberator:highlight='CompItem']", doc);
|
completionElements = buffer.evaluateXPath("//xhtml:div[@liberator:highlight='CompItem']", doc);
|
||||||
|
|
||||||
autoSize();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1931,7 +1933,10 @@ function ItemList(id) //{{{
|
|||||||
getCompletion(sel).removeAttribute("selected");
|
getCompletion(sel).removeAttribute("selected");
|
||||||
fill(newOffset);
|
fill(newOffset);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
|
{
|
||||||
getCompletion(index).setAttribute("selected", "true");
|
getCompletion(index).setAttribute("selected", "true");
|
||||||
|
getCompletion(index).scrollIntoView(false);
|
||||||
|
}
|
||||||
|
|
||||||
//if (index == 0)
|
//if (index == 0)
|
||||||
// this.start = now;
|
// this.start = now;
|
||||||
|
|||||||
Reference in New Issue
Block a user