From 5e732e3bf16d9e5e9251353fe299ef396aa23aa5 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 28 Nov 2008 05:07:23 +0000 Subject: [PATCH] Add 'wildcase' option --- NEWS | 3 +++ content/completion.js | 22 +++++++++++++++++++--- content/ui.js | 30 +++++++++++++++++++++--------- locale/en-US/index.txt | 1 + locale/en-US/options.txt | 13 +++++++++++++ locale/en-US/styling.txt | 14 ++++++++++++++ 6 files changed, 71 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 166025fa..6baaa87b 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,9 @@ * IMPORTANT: renamed Startup and Quit autocmd events to VimperatorEnter and VimperatorLeave respectively + * add 'wildcase' option + * 'linkbgcolor', 'linkfgcolor', ... have been replaced with highlight + groups, HintElem and HintActive * new 'followhints' option * :buffers supports a filter now to only list buffers matching filter (vim incompatible, but consistent with other commands) diff --git a/content/completion.js b/content/completion.js index 7d9fc5ba..9b981244 100644 --- a/content/completion.js +++ b/content/completion.js @@ -56,6 +56,7 @@ function CompletionContext(editor, name, offset) self.keys = util.cloneObject(parent.keys); delete self._generate; delete self._filter; // FIXME? + delete self._ignoreCase; ["anchored", "compare", "editor", "filterFunc", "keys", "_process", "quote", "title", "top"].forEach(function (key) self[key] = parent[key]); if (self != this) @@ -208,7 +209,11 @@ CompletionContext.prototype = { }, get filter() this._filter != null ? this._filter : this.value.substr(this.offset, this.caret), - set filter(val) this._filter = val, + set filter(val) + { + delete this._ignoreCase; + return this._filter = val + }, get format() ({ title: this.title, @@ -222,8 +227,18 @@ CompletionContext.prototype = { this.process = format.process || this.process; }, - // XXX - get ignoreCase() this.filter == this.filter.toLowerCase(), + get ignoreCase() + { + if ("_ignoreCase" in this) + return this._ignoreCase; + let mode = options["wildcase"]; + if (mode == "match") + return this._ignoreCase = false; + if (mode == "ignore") + return this._ignoreCase = true; + return this._ignoreCase = !/[A-Z]/.test(this.filter); + }, + set ignoreCase(val) this._ignoreCase = val, get items() { @@ -318,6 +333,7 @@ CompletionContext.prototype = { advance: function advance(count) { + delete this._ignoreCase; this.offset += count; if (this.quote) { diff --git a/content/ui.js b/content/ui.js index 8dff6fce..47c75482 100644 --- a/content/ui.js +++ b/content/ui.js @@ -435,15 +435,6 @@ function CommandLine() //{{{ ////////////////////// OPTIONS ///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - // TODO: doesn't belong in ui.js - options.add(["complete", "cpt"], - "Items which are completed at the :[tab]open prompt", - "charlist", "sfl", - { - completer: function completer(filter) [k for each (k in completion.urlCompleters)], - validator: options.validateCompleter - }); - options.add(["history", "hi"], "Number of Ex commands and search patterns to store in the command-line history", "number", 500, @@ -478,6 +469,27 @@ function CommandLine() //{{{ validator: options.validateCompleter }); + // TODO: these belong in ui.js + options.add(["complete", "cpt"], + "Items which are completed at the :[tab]open prompt", + "charlist", "sfl", + { + completer: function completer(filter) [k for each (k in completion.urlCompleters)], + validator: options.validateCompleter + }); + + options.add(["wildcase", "wic"], + "Completion case matching mode", + "string", "smart", + { + completer: function () [ + ["smart", "Case is significant when capital letters are typed"], + ["match", "Case is always significant"], + ["ignore", "Case is never significant"] + ], + validator: options.validateCompleter + }); + options.add(["wildignore", "wig"], "List of file patterns to ignore when completing files", "stringlist", "", diff --git a/locale/en-US/index.txt b/locale/en-US/index.txt index 66320a4d..524392c5 100644 --- a/locale/en-US/index.txt +++ b/locale/en-US/index.txt @@ -308,6 +308,7 @@ section:Options[option-index] ||'usermode'|| Show current website with a minimal style sheet to make it easily accessible + ||'verbose'|| Define which info messages are displayed + ||'visualbell'|| Use visual bell instead of beeping on errors + +||'wildcase'|| Completion case matching mode + ||'wildignore'|| List of file patterns to ignore when completing files + ||'wildmode'|| Define how command-line completion works + ||'wildoptions'|| Change how command-line completion is done + diff --git a/locale/en-US/options.txt b/locale/en-US/options.txt index d29ccec7..d4ac8058 100644 --- a/locale/en-US/options.txt +++ b/locale/en-US/options.txt @@ -743,6 +743,19 @@ this option. ____ +|\'wildcase'| |\'wic'| +||'wildcase' 'wic'|| string (default: "smart") +____ +Defines how completions are matched with regard to character case. + +`---------------`------------------------ +"smart" Case is significant when capital letters are typed +"match" Case is always significant +"ignore" Case is never significant +----------------------------------------- +____ + + |\'wildignore'| |\'wig'| ||'wildignore' 'wig'|| stringlist (default: "") ____ diff --git a/locale/en-US/styling.txt b/locale/en-US/styling.txt index f92f0875..0d62cf40 100644 --- a/locale/en-US/styling.txt +++ b/locale/en-US/styling.txt @@ -30,15 +30,29 @@ Valid groups are: `------------------`----------------------------------- *Bell* Vimperator's visual bell *Boolean* A JavaScript Boolean object +*CompDesc* The description column of the completion list +*CompIcon* The favicon of a completion row +*CompItem* A completion row +*CompLess* The indicator shown when completions may be scrolled up +*CompMore* The indicator shown when completions may be scrolled down +*CompResult* The result column of the completion list +*CompTitle* Completion row titles *ErrorMsg* Error messages *Filter* The matching text in a completion list +*FrameIndicator* The indicator shown when a new frame is selected *Function* A JavaScript Function object *Hint* A hint indicator. See [c]:help hints[c]. +*HintActive* The hint element which will be selected on +*HintElem* The element which a hint refers to. +*HintImage* The indicator which floats above hinted images. +*Indicator* *InfoMsg* Information messages *Keyword* A bookmark keyword for a URL *LineNr* The line number of an error +*Message* *ModeMsg* The mode indicator in the command line *MoreMsg* The indicator that there is more text to view +*NonText* *Normal* Normal text in the command line *Null* A JavaScript Null object *Number* A JavaScript Number object