mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 10:08:00 +01:00
add initial implementation of the 'history' option - no dynamic resizing yet
This commit is contained in:
@@ -525,6 +525,12 @@ vimperator.Options = function () //{{{
|
|||||||
defaultValue: DEFAULT_HINTTAGS
|
defaultValue: DEFAULT_HINTTAGS
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
optionManager.add(new vimperator.Option(["history", "hi"], "number",
|
||||||
|
{
|
||||||
|
shortHelp: "Number of Ex commands and search patterns to store in the commandline history",
|
||||||
|
defaultValue: 500
|
||||||
|
}
|
||||||
|
));
|
||||||
optionManager.add(new vimperator.Option(["hlsearch", "hls"], "boolean",
|
optionManager.add(new vimperator.Option(["hlsearch", "hls"], "boolean",
|
||||||
{
|
{
|
||||||
shortHelp: "Highlight previous search pattern matches",
|
shortHelp: "Highlight previous search pattern matches",
|
||||||
|
|||||||
@@ -45,15 +45,17 @@ vimperator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
// TODO: clean this up when it's not 3am...
|
// TODO: clean this up when it's not 3am...
|
||||||
var history = {
|
var history = {
|
||||||
SIZE: 500,
|
get size() { return vimperator.options["history"]; },
|
||||||
|
|
||||||
get _mode() { return (vimperator.modes.extended == vimperator.modes.EX) ? "cmd" : "search"; },
|
get mode() { return (vimperator.modes.extended == vimperator.modes.EX) ? "cmd" : "search"; },
|
||||||
|
|
||||||
cmd: null, // ex command history
|
cmd: null, // ex command history
|
||||||
|
|
||||||
search: null, // text search history
|
search: null, // text search history
|
||||||
|
|
||||||
get: function () { return this[this._mode]; },
|
get: function () { return this[this.mode]; },
|
||||||
set: function (lines) { this[this._mode] = lines; },
|
|
||||||
|
set: function (lines) { this[this.mode] = lines; },
|
||||||
|
|
||||||
load: function ()
|
load: function ()
|
||||||
{
|
{
|
||||||
@@ -80,8 +82,8 @@ vimperator.CommandLine = function () //{{{
|
|||||||
});
|
});
|
||||||
|
|
||||||
// add string to the command line history
|
// add string to the command line history
|
||||||
if (lines.push(str) > this.SIZE) // remove the first 10% of the history
|
if (lines.push(str) > this.size) // remove the first 10% of the history
|
||||||
lines = lines.slice(this.SIZE / 10);
|
lines = lines.slice(this.size / 10);
|
||||||
|
|
||||||
this.set(lines);
|
this.set(lines);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user