mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 23:27:58 +01:00
add 'maxitems' option (Jarkko Oranen)
This commit is contained in:
@@ -777,6 +777,11 @@ function CommandLine() //{{{
|
|||||||
"number", 500,
|
"number", 500,
|
||||||
{ validator: function (value) value >= 0 });
|
{ validator: function (value) value >= 0 });
|
||||||
|
|
||||||
|
options.add(["maxitems"],
|
||||||
|
"Maximum number of items to display at once",
|
||||||
|
"number", 20,
|
||||||
|
{ validator: function (value) value >= 0 });
|
||||||
|
|
||||||
options.add(["messages", "msgs"],
|
options.add(["messages", "msgs"],
|
||||||
"Number of messages to store in the message history",
|
"Number of messages to store in the message history",
|
||||||
"number", 100,
|
"number", 100,
|
||||||
@@ -1725,8 +1730,6 @@ function ItemList(id) //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
const CONTEXT_LINES = 3;
|
|
||||||
var maxItems = 20;
|
|
||||||
var completionElements = [];
|
var completionElements = [];
|
||||||
|
|
||||||
var iframe = document.getElementById(id);
|
var iframe = document.getElementById(id);
|
||||||
@@ -1782,7 +1785,7 @@ function ItemList(id) //{{{
|
|||||||
<div key="completions"/>
|
<div key="completions"/>
|
||||||
<div highlight="Completions">
|
<div highlight="Completions">
|
||||||
{
|
{
|
||||||
template.map(util.range(0, maxItems * 2), function (i)
|
template.map(util.range(0, options["maxitems"] * 2), function (i)
|
||||||
<span highlight="CompItem">
|
<span highlight="CompItem">
|
||||||
<li highlight="NonText">~</li>
|
<li highlight="NonText">~</li>
|
||||||
</span>)
|
</span>)
|
||||||
@@ -1818,7 +1821,7 @@ function ItemList(id) //{{{
|
|||||||
* Uses the entries in "items" to fill the listbox and does incremental
|
* Uses the entries in "items" to fill the listbox and does incremental
|
||||||
* filling to speed up things.
|
* filling to speed up things.
|
||||||
*
|
*
|
||||||
* @param {number} offset Start at this index and show maxItems.
|
* @param {number} offset Start at this index and show options["maxitems"].
|
||||||
*/
|
*/
|
||||||
function fill(offset)
|
function fill(offset)
|
||||||
{
|
{
|
||||||
@@ -1828,11 +1831,11 @@ function ItemList(id) //{{{
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
startIndex = offset;
|
startIndex = offset;
|
||||||
endIndex = Math.min(startIndex + maxItems, items.allItems.items.length);
|
endIndex = Math.min(startIndex + options["maxitems"], items.allItems.items.length);
|
||||||
|
|
||||||
let haveCompletions = false;
|
let haveCompletions = false;
|
||||||
let off = 0;
|
let off = 0;
|
||||||
let end = startIndex + maxItems;
|
let end = startIndex + options["maxitems"];
|
||||||
function getRows(context)
|
function getRows(context)
|
||||||
{
|
{
|
||||||
function fix(n) Math.max(0, Math.min(len, n));
|
function fix(n) Math.max(0, Math.min(len, n));
|
||||||
@@ -1946,6 +1949,8 @@ function ItemList(id) //{{{
|
|||||||
let sel = selIndex;
|
let sel = selIndex;
|
||||||
let len = items.allItems.items.length;
|
let len = items.allItems.items.length;
|
||||||
let newOffset = startIndex;
|
let newOffset = startIndex;
|
||||||
|
let maxItems = options["maxitems"];
|
||||||
|
let contextLines = (maxItems > 3)? 3 : Math.max(0, maxItems - 1);
|
||||||
|
|
||||||
if (index == -1 || index == null || index == len) // wrapped around
|
if (index == -1 || index == null || index == len) // wrapped around
|
||||||
{
|
{
|
||||||
@@ -1956,10 +1961,10 @@ function ItemList(id) //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (index <= startIndex + CONTEXT_LINES)
|
if (index <= startIndex + contextLines)
|
||||||
newOffset = index - CONTEXT_LINES;
|
newOffset = index - contextLines;
|
||||||
if (index >= endIndex - CONTEXT_LINES)
|
if (index >= endIndex - contextLines)
|
||||||
newOffset = index + CONTEXT_LINES - maxItems + 1;
|
newOffset = index + contextLines - maxItems + 1;
|
||||||
|
|
||||||
newOffset = Math.min(newOffset, len - maxItems);
|
newOffset = Math.min(newOffset, len - maxItems);
|
||||||
newOffset = Math.max(newOffset, 0);
|
newOffset = Math.max(newOffset, 0);
|
||||||
|
|||||||
@@ -39,3 +39,4 @@ Patches (in no special order):
|
|||||||
* Ryan Zheng (ctrl-x/a support)
|
* Ryan Zheng (ctrl-x/a support)
|
||||||
* Dan Boger (:set online support)
|
* Dan Boger (:set online support)
|
||||||
* Štěpán Němec (help copy-editing and favicon support)
|
* Štěpán Němec (help copy-editing and favicon support)
|
||||||
|
* Jarkko Oranen ('maxitems' option)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* add ' and " local marks
|
* add ' and " local marks
|
||||||
* add "w" and "W" Normal mode mappings for symmetry with o/O and t/T
|
* add "w" and "W" Normal mode mappings for symmetry with o/O and t/T
|
||||||
* add :messclear
|
* add :messclear
|
||||||
|
* add 'maxitems' configuration variable
|
||||||
|
|
||||||
2009-03-28:
|
2009-03-28:
|
||||||
* version 2.0
|
* version 2.0
|
||||||
|
|||||||
@@ -480,6 +480,12 @@ load plugins earlier, use the [c]:loadplugins[c] command within the
|
|||||||
vimperatorrc.
|
vimperatorrc.
|
||||||
____
|
____
|
||||||
|
|
||||||
|
|\'maxitems'|
|
||||||
|
||'maxitems'|| number (default: 20)
|
||||||
|
____
|
||||||
|
Maximum number of items to display at once in a listing.
|
||||||
|
____
|
||||||
|
|
||||||
|
|
||||||
|\'msgs'| |\'messages'|
|
|\'msgs'| |\'messages'|
|
||||||
||'messages' 'msgs'|| number (default: 100)
|
||'messages' 'msgs'|| number (default: 100)
|
||||||
|
|||||||
Reference in New Issue
Block a user