From 5489a0b2dee4c9671db78401c51a34a4cf547e80 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 12 Dec 2008 19:47:33 -0500 Subject: [PATCH] :hi clear --- common/content/style.js | 23 ++++++++++++++++++++--- vimperator/locale/en-US/styling.txt | 10 +++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/common/content/style.js b/common/content/style.js index f0ac0a0a..a0212313 100644 --- a/common/content/style.js +++ b/common/content/style.js @@ -560,9 +560,17 @@ liberator.registerObserver("load_commands", function () height: 1em !important; min-height: 1em !important; max-height: 1em !important; overflow: hidden !important; ]]>; + let clear = args[0] == "clear"; + if (clear) + args.shift(); + let [key, css] = args; - if (!css && !(key && args.bang)) + if (clear && css) + return liberator.echo("E488: Trailing characters"); + + if (!css && !clear) { + // List matching keys let str = template.tabular(["Key", "Sample", "CSS"], ["padding: 0 1em 0 0; vertical-align: top", "text-align: center"], ([h.class, @@ -573,15 +581,24 @@ liberator.registerObserver("load_commands", function () commandline.echo(str, commandline.HL_NORMAL, commandline.FORCE_MULTILINE); return; } - let error = highlight.set(key, css, args.bang, "-append" in args); + if (!key && clear) + { + for (let h in highlight) + highlight.set(h.class, null, true); + return; + } + let error = highlight.set(key, css, clear, "-append" in args); if (error) liberator.echoerr(error); }, { - bang: true, // TODO: add this as a standard highlight completion function? completer: function (context, args) { + // Complete a highlight group on :hi clear ... + if (args.completeArg > 0 && args[0] == "clear") + args.completeArg = args.completeArg > 1 ? -1 : 0; + if (args.completeArg == 0) context.completions = [[v.class, ""] for (v in highlight)]; else if (args.completeArg == 1) diff --git a/vimperator/locale/en-US/styling.txt b/vimperator/locale/en-US/styling.txt index 0d62cf40..884a6e09 100644 --- a/vimperator/locale/en-US/styling.txt +++ b/vimperator/locale/en-US/styling.txt @@ -18,7 +18,7 @@ sourced. ________________________________________________________________________________ |:hi| |:highlight| + -||:hi[light][!] [-append] {group}[{selector}] [{css}]|| + +||:hi[light] [-append] {group}[{selector}] [{css}]|| + ________________________________________________________________________________ Highlight {group} with {css}. Normally, {css} is checked for valid syntax before it's applied. Once you're certain it's @@ -81,6 +81,14 @@ styles matching {group} are listed. If neither {css} nor [!] is provided, the style for {group} is reset to its default value. ________________________________________________________________________________ +|:highlight-clear| + +||:hi[light] clear [{group}[{selector}]]|| + +________________________________________________________________________________ +Reset the highlighting for {group} to its default value. If +{group} is not given, reset all highlighting groups. +________________________________________________________________________________ + + |:sty| |:style| + ||:sty[le][!] [-name={name}] [-append] {filter} [{css}]|| + ________________________________________________________________________________