From 19ad0f4d466b38f5e2d50f39233e4b56385a2e49 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 30 Nov 2007 09:22:43 +0000 Subject: [PATCH] add initial implementation of the 'history' option - no dynamic resizing yet --- content/options.js | 6 ++++++ content/ui.js | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/content/options.js b/content/options.js index ed9fdd2b..9688125b 100644 --- a/content/options.js +++ b/content/options.js @@ -525,6 +525,12 @@ vimperator.Options = function () //{{{ 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", { shortHelp: "Highlight previous search pattern matches", diff --git a/content/ui.js b/content/ui.js index 55617b66..9ddc017e 100644 --- a/content/ui.js +++ b/content/ui.js @@ -45,15 +45,17 @@ vimperator.CommandLine = function () //{{{ // TODO: clean this up when it's not 3am... 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 + search: null, // text search history - get: function () { return this[this._mode]; }, - set: function (lines) { this[this._mode] = lines; }, + get: function () { return this[this.mode]; }, + + set: function (lines) { this[this.mode] = lines; }, load: function () { @@ -80,8 +82,8 @@ vimperator.CommandLine = function () //{{{ }); // add string to the command line history - if (lines.push(str) > this.SIZE) // remove the first 10% of the history - lines = lines.slice(this.SIZE / 10); + if (lines.push(str) > this.size) // remove the first 10% of the history + lines = lines.slice(this.size / 10); this.set(lines); }