1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 11:27:58 +01:00

Quick hack to show the longest-substring preview on the commandline.

This commit is contained in:
Kris Maglione
2008-11-27 07:36:36 +00:00
parent 81e4be0aee
commit d87c66210f
2 changed files with 19 additions and 3 deletions

View File

@@ -1183,7 +1183,6 @@ function Completion() //{{{
// dynamically get completions as specified with the command's completer function
let command = commands.get(cmd);
let compObject = { start: 0, items: [] };
if (!command)
{
context.highlight(0, cmd.length, "SPELLCHECK");
@@ -1204,7 +1203,7 @@ function Completion() //{{{
cmdContext.advance(args.completeStart);
cmdContext.quote = args.quote;
cmdContext.filter = args.completeFilter;
compObject = command.completer.call(command, cmdContext, args);
let compObject = command.completer.call(command, cmdContext, args);
if (compObject instanceof Array) // for now at least, let completion functions return arrays instead of objects
compObject = { start: compObject[0], items: compObject[1] };
if (compObject != null)

View File

@@ -792,7 +792,14 @@ function CommandLine() //{{{
onEvent: function onEvent(event)
{
var command = this.getCommand();
let command = this.getCommand();
let editor = commandWidget.inputField.editor;
try
{
let node = editor.rootElement;
node.removeChild(node.firstChild.nextSibling);
}
catch (e) {}
if (event.type == "blur")
{
@@ -818,6 +825,16 @@ function CommandLine() //{{{
else if (event.type == "input")
{
liberator.triggerCallback("change", currentExtendedMode, command);
// Kludge. Major kludge.
let wildmode = options.get("wildmode");
let wildType = wildmode.values[Math.min(wildIndex, wildmode.values.length - 1)];
if (wildmode.checkHas(wildType, "longest"))
{
let start = commandWidget.selectionStart;
let substring = completionContext.longestAllSubstring.substr(start - completionContext.allItems.start);
editor.insertNode(util.xmlToDom(<span style="color: gray">{substring}</span>, document), editor.rootElement, 1);
commandWidget.selectionStart = commandWidget.selectionEnd = start;
}
}
else if (event.type == "keypress")
{