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

add initial implementation of the 'history' option - no dynamic resizing yet

This commit is contained in:
Doug Kearns
2007-11-30 09:22:43 +00:00
parent 48884809a2
commit 19ad0f4d46
2 changed files with 14 additions and 6 deletions

View File

@@ -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",

View File

@@ -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);
} }