mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 09:48:00 +01:00
Speed up completion scrolling by 10ui.js
This commit is contained in:
@@ -107,13 +107,13 @@ function CommandLine() //{{{
|
|||||||
var wildIndex = 0; // keep track how often we press <Tab> in a row
|
var wildIndex = 0; // keep track how often we press <Tab> in a row
|
||||||
var startHints = false; // whether we're waiting to start hints mode
|
var startHints = false; // whether we're waiting to start hints mode
|
||||||
|
|
||||||
var statusTimer = new util.Timer(5, 100, function () {
|
var statusTimer = new util.Timer(5, 100, function statusTell() {
|
||||||
if (completionIndex >= completions.items.length)
|
if (completionIndex >= completions.items.length)
|
||||||
statusline.updateProgress("");
|
statusline.updateProgress("");
|
||||||
else
|
else
|
||||||
statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.items.length);
|
statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.items.length);
|
||||||
});
|
});
|
||||||
var autocompleteTimer = new util.Timer(201, 300, function (tabPressed) {
|
var autocompleteTimer = new util.Timer(201, 300, function autocompleteTell(tabPressed) {
|
||||||
if (events.feedingKeys)
|
if (events.feedingKeys)
|
||||||
return;
|
return;
|
||||||
completionContext.reset();
|
completionContext.reset();
|
||||||
@@ -121,7 +121,7 @@ function CommandLine() //{{{
|
|||||||
commandline.setCompletions(completionContext.allItems);
|
commandline.setCompletions(completionContext.allItems);
|
||||||
});
|
});
|
||||||
|
|
||||||
var tabTimer = new util.Timer(10, 10, function (event) {
|
var tabTimer = new util.Timer(10, 10, function tabTell(event) {
|
||||||
let command = commandline.getCommand();
|
let command = commandline.getCommand();
|
||||||
|
|
||||||
// always reset our completion history so up/down keys will start with new values
|
// always reset our completion history so up/down keys will start with new values
|
||||||
@@ -1329,7 +1329,12 @@ function ItemList(id) //{{{
|
|||||||
|
|
||||||
noCompletions = div.getElementsByTagName("div")[0];
|
noCompletions = div.getElementsByTagName("div")[0];
|
||||||
completionBody = div.getElementsByTagName("div")[1];
|
completionBody = div.getElementsByTagName("div")[1];
|
||||||
items.contextList.forEach(function (context) {
|
|
||||||
|
// 1:
|
||||||
|
doc.body.replaceChild(div, doc.body.firstChild);
|
||||||
|
// 2:
|
||||||
|
|
||||||
|
items.contextList.forEach(function init_eachContext(context) {
|
||||||
if (!context.items.length)
|
if (!context.items.length)
|
||||||
return;
|
return;
|
||||||
context.cache.dom = dom(<div>
|
context.cache.dom = dom(<div>
|
||||||
@@ -1353,7 +1358,7 @@ function ItemList(id) //{{{
|
|||||||
XML.ignoreWhiteSpace = false;
|
XML.ignoreWhiteSpace = false;
|
||||||
let diff = offset - startIndex;
|
let diff = offset - startIndex;
|
||||||
if (items == null || offset == null || diff == 0 || offset < 0)
|
if (items == null || offset == null || diff == 0 || offset < 0)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
let stuff = dom(<div class="hl-Completions"/>);
|
let stuff = dom(<div class="hl-Completions"/>);
|
||||||
|
|
||||||
@@ -1369,27 +1374,30 @@ function ItemList(id) //{{{
|
|||||||
return context.getRows(offset - start, endIndex - start, doc);
|
return context.getRows(offset - start, endIndex - start, doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
items.contextList.forEach(function (context) {
|
items.contextList.forEach(function fill_eachContext(context) {
|
||||||
let dom = context.cache.dom;
|
let dom = context.cache.dom;
|
||||||
if (!dom)
|
if (!dom)
|
||||||
return;
|
return;
|
||||||
let d = stuff.cloneNode(true);
|
let d = stuff.cloneNode(true);
|
||||||
for (let [,row] in Iterator(getRows(context)))
|
for (let [,row] in Iterator(getRows(context)))
|
||||||
d.appendChild(row);
|
d.appendChild(row);
|
||||||
|
|
||||||
//liberator.dump(util.map(util.range(0, dom.childNodes.length), function (i) elemToString(dom.childNodes[i])));
|
|
||||||
|
|
||||||
dom.replaceChild(d, dom.childNodes[3] || dom.childNodes[1]);
|
dom.replaceChild(d, dom.childNodes[3] || dom.childNodes[1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
noCompletions.style.display = off > 0 ? "none" : "block";
|
noCompletions.style.display = off > 0 ? "none" : "block";
|
||||||
|
|
||||||
let node = div.cloneNode(true);
|
// 1:
|
||||||
completionElements = node.getElementsByClassName("hl-CompItem");
|
completionElements = div.getElementsByClassName("hl-CompItem");
|
||||||
completionBody = node.getElementsByTagName("div")[1];
|
|
||||||
doc.body.replaceChild(node, doc.body.firstChild);
|
// 2:
|
||||||
|
//let node = div.cloneNode(true);
|
||||||
|
//completionElements = node.getElementsByClassName("hl-CompItem");
|
||||||
|
//completionBody = node.getElementsByTagName("div")[1];
|
||||||
|
//doc.body.replaceChild(node, doc.body.firstChild);
|
||||||
|
//completionElements = node.getElementsByClassName("hl-CompItem");
|
||||||
|
|
||||||
autoSize();
|
autoSize();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -1433,6 +1441,8 @@ function ItemList(id) //{{{
|
|||||||
//if (container.collapsed) // fixme
|
//if (container.collapsed) // fixme
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
|
//let now = Date.now();
|
||||||
|
|
||||||
let len = items.allItems.items.length;
|
let len = items.allItems.items.length;
|
||||||
if (index == -1 || index == len) // wrapped around
|
if (index == -1 || index == len) // wrapped around
|
||||||
{
|
{
|
||||||
@@ -1457,11 +1467,14 @@ function ItemList(id) //{{{
|
|||||||
if (selIndex > -1)
|
if (selIndex > -1)
|
||||||
getCompletion(selIndex).removeAttribute("selected");
|
getCompletion(selIndex).removeAttribute("selected");
|
||||||
|
|
||||||
fill(newOffset);
|
let res = fill(newOffset);
|
||||||
selIndex = index;
|
selIndex = index;
|
||||||
getCompletion(index).setAttribute("selected", "true");
|
getCompletion(index).setAttribute("selected", "true");
|
||||||
|
|
||||||
return;
|
//if (index == 0)
|
||||||
|
// this.start = now;
|
||||||
|
//if (index == Math.min(len - 1, 100))
|
||||||
|
// liberator.dump({ time: Date.now() - this.start });
|
||||||
},
|
},
|
||||||
|
|
||||||
onEvent: function onEvent(event) false
|
onEvent: function onEvent(event) false
|
||||||
|
|||||||
Reference in New Issue
Block a user