diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-05-17 19:35:54 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-05-17 19:40:52 +0100 |
| commit | dfaafcd49a34f55bc832da96ab365e1c4bb3350a (patch) | |
| tree | b086525a5edb2749027e64cb3e7abac78642d63e | |
| parent | 44d2db2706da29fa9aad2e0a882bb850d7c8168b (diff) | |
Rename range-faces to range-specs
range-faces are now used to replace-range highlighters, where the string
part is not interpretted as a face but as a display line, so the name was
not relevant anymore.
| -rw-r--r-- | README.asciidoc | 9 | ||||
| -rw-r--r-- | doc/manpages/highlighters.asciidoc | 10 | ||||
| -rw-r--r-- | doc/manpages/options.asciidoc | 4 | ||||
| -rw-r--r-- | rc/base/spell.kak | 2 | ||||
| -rw-r--r-- | src/commands.cc | 12 | ||||
| -rw-r--r-- | src/highlighters.cc | 20 | ||||
| -rw-r--r-- | src/highlighters.hh | 2 |
7 files changed, 35 insertions, 24 deletions
diff --git a/README.asciidoc b/README.asciidoc index e075b35f..c777ced9 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -863,9 +863,9 @@ Options are typed, their type can be * `{int,str}-list`: a list, elements are separated by a colon (:) if an element needs to contain a colon, it can be escaped with a backslash. - * `range-faces`: a `:` separated list of a pair of a buffer range + * `range-specs`: a `:` separated list of a pair of a buffer range (`<begin line>.<begin column>,<end line>.<end column>` or - `<begin line>.<end line>+<length>`) and a face (separated by `|`), + `<begin line>.<end line>+<length>`) and a string (separated by `|`), except for the first element which is just the timestamp of the buffer. * `line-flags`: a `:` separated list of a line number and a corresponding flag (`<line>|<flag text>`), except for the first element which is just @@ -1245,7 +1245,10 @@ General highlighters are: the rest of the buffer, default is `|`. * `wrap \<-word>`: Soft wrap buffer content to window width, wrap at word boundaries if `-word` is specified. * `fill <face>`: fill using given face, mostly useful with <<regions-highlighters,Regions highlighters>> - * `ranges <option_name>`: use the data in the range-faces option of the given name to highlight the buffer. + * `ranges <option_name>`: use the data in the range-specs option of the given name to highlight the buffer. + The string part of the is interpretted as a face to apply to the range. + * `replace-ranges <option_name>`: use the data in the range-specs option of the given name to highlight the buffer. + The string part of the is interpretted as a display line to display in place of the range. Highlighting Groups ^^^^^^^^^^^^^^^^^^^ diff --git a/doc/manpages/highlighters.asciidoc b/doc/manpages/highlighters.asciidoc index ad941afb..0d804bbb 100644 --- a/doc/manpages/highlighters.asciidoc +++ b/doc/manpages/highlighters.asciidoc @@ -91,8 +91,14 @@ General highlighters wrap at word boundaries instead of codepoint boundaries. *ranges* <option_name>:: - use the data in the range-faces option of the given name to highlight - the buffer. + use the data in the range-specs option of the given name to highlight + the buffer. The string part of the is interpretted as a face to apply + to the range. + +*replace-ranges* <option_name>:: + use the data in the range-specs option of the given name to highlight + the buffer. The string part of the is interpretted as a display line to + display in place of the range. *fill* <face>:: fill using the given *face*, mostly useful with regions highlighters diff --git a/doc/manpages/options.asciidoc b/doc/manpages/options.asciidoc index 95159087..93245f1a 100644 --- a/doc/manpages/options.asciidoc +++ b/doc/manpages/options.asciidoc @@ -21,10 +21,10 @@ Types *int-list*, *str-list*:: a list, elements are separated by a colon (:) if an element needs to contain a colon, it can be escaped with a backslash -*range-faces*:: +*range-specs*:: a `:` separated list of a pair of a buffer range (`<begin line>.<begin column>,<end line>.<end column>` or - `<begin line>.<begin column>+<length>`) and a face (separated by `|`), + `<begin line>.<begin column>+<length>`) and a string (separated by `|`), except for the first element which is just the timestamp of the buffer. *line-flags*:: a `:` separated list of a line number and a corresponding flag diff --git a/rc/base/spell.kak b/rc/base/spell.kak index 87e82dc0..67bd5713 100644 --- a/rc/base/spell.kak +++ b/rc/base/spell.kak @@ -1,4 +1,4 @@ -decl -hidden range-faces spell_regions +decl -hidden range-specs spell_regions decl -hidden str spell_lang decl -hidden str spell_tmp_file diff --git a/src/commands.cc b/src/commands.cc index d9ab5a2e..c32c29de 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -48,9 +48,9 @@ StringView option_type_name(Meta::Type<TimestampedList<LineAndFlag>>) return "line-flags"; } -StringView option_type_name(Meta::Type<TimestampedList<RangeAndFace>>) +StringView option_type_name(Meta::Type<TimestampedList<RangeAndString>>) { - return "range-faces"; + return "range-specs"; } namespace @@ -1335,7 +1335,7 @@ const CommandDesc declare_option_cmd = { " str-list: list of character strings\n" " completions: list of completion candidates\n" " line-flags: list of line flags\n" - " range-faces: list of range faces\n", + " range-specs: list of range specs\n", ParameterDesc{ { { "hidden", { false, "do not display option name when completing" } }, { "docstring", { true, "specify option description" } } }, @@ -1346,7 +1346,7 @@ const CommandDesc declare_option_cmd = { make_completer( [](const Context& context, CompletionFlags flags, const String& prefix, ByteCount cursor_pos) -> Completions { - auto c = {"int", "bool", "str", "regex", "int-list", "str-list", "completions", "line-flags", "range-faces"}; + auto c = {"int", "bool", "str", "regex", "int-list", "str-list", "completions", "line-flags", "range-specs"}; return { 0_byte, cursor_pos, complete(prefix, cursor_pos, c) }; }), [](const ParametersParser& parser, Context& context, const ShellContext&) @@ -1377,8 +1377,8 @@ const CommandDesc declare_option_cmd = { opt = ®.declare_option<CompletionList>(parser[1], docstring, {}, flags); else if (parser[0] == "line-flags") opt = ®.declare_option<TimestampedList<LineAndFlag>>(parser[1], docstring, {}, flags); - else if (parser[0] == "range-faces") - opt = ®.declare_option<TimestampedList<RangeAndFace>>(parser[1], docstring, {}, flags); + else if (parser[0] == "range-specs") + opt = ®.declare_option<TimestampedList<RangeAndString>>(parser[1], docstring, {}, flags); else throw runtime_error(format("unknown type {}", parser[0])); diff --git a/src/highlighters.cc b/src/highlighters.cc index bd1f4160..2de9c6bb 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -1345,10 +1345,10 @@ void option_from_string(StringView str, InclusiveBufferRange& opt) opt = { first, last }; } -BufferCoord& get_first(RangeAndFace& r) { return std::get<0>(r).first; } -BufferCoord& get_last(RangeAndFace& r) { return std::get<0>(r).last; } +BufferCoord& get_first(RangeAndString& r) { return std::get<0>(r).first; } +BufferCoord& get_last(RangeAndString& r) { return std::get<0>(r).last; } -static void update_ranges_ifn(const Buffer& buffer, TimestampedList<RangeAndFace>& range_and_faces) +static void update_ranges_ifn(const Buffer& buffer, TimestampedList<RangeAndString>& range_and_faces) { if (range_and_faces.prefix == buffer.timestamp()) return; @@ -1386,7 +1386,7 @@ struct RangesHighlighter : Highlighter const String& option_name = params[0]; // throw if wrong option type - GlobalScope::instance().options()[option_name].get<TimestampedList<RangeAndFace>>(); + GlobalScope::instance().options()[option_name].get<TimestampedList<RangeAndString>>(); return {"hlranges_" + params[0], make_unique<RangesHighlighter>(option_name)}; } @@ -1395,7 +1395,7 @@ private: void do_highlight(const Context& context, HighlightPass, DisplayBuffer& display_buffer, BufferRange) override { auto& buffer = context.buffer(); - auto& range_and_faces = context.options()[m_option_name].get_mutable<TimestampedList<RangeAndFace>>(); + auto& range_and_faces = context.options()[m_option_name].get_mutable<TimestampedList<RangeAndString>>(); update_ranges_ifn(buffer, range_and_faces); for (auto& range : range_and_faces.list) @@ -1428,7 +1428,7 @@ struct ReplaceRangesHighlighter : Highlighter const String& option_name = params[0]; // throw if wrong option type - GlobalScope::instance().options()[option_name].get<TimestampedList<RangeAndFace>>(); + GlobalScope::instance().options()[option_name].get<TimestampedList<RangeAndString>>(); return {"replace_ranges_" + params[0], make_unique<ReplaceRangesHighlighter>(option_name)}; } @@ -1437,7 +1437,7 @@ private: void do_highlight(const Context& context, HighlightPass, DisplayBuffer& display_buffer, BufferRange) override { auto& buffer = context.buffer(); - auto& range_and_faces = context.options()[m_option_name].get_mutable<TimestampedList<RangeAndFace>>(); + auto& range_and_faces = context.options()[m_option_name].get_mutable<TimestampedList<RangeAndString>>(); update_ranges_ifn(buffer, range_and_faces); for (auto& range : range_and_faces.list) @@ -1973,12 +1973,14 @@ void register_highlighters() "ranges", { RangesHighlighter::create, "Parameters: <option name>\n" - "Use the range-faces option given as parameter to highlight buffer\n" } }); + "Use the range-specs option given as parameter to highlight buffer\n" + "each spec is interpreted as a face to apply to the range\n" } }); registry.insert({ "replace-ranges", { ReplaceRangesHighlighter::create, "Parameters: <option name>\n" - "Use the range-faces option given as parameter to highlight buffer\n" } }); + "Use the range-specs option given as parameter to highlight buffer\n" + "each spec is interpreted as a display line to display in place of the range\n" } }); registry.insert({ "line", { create_line_highlighter, diff --git a/src/highlighters.hh b/src/highlighters.hh index 6435efdc..2ea3390d 100644 --- a/src/highlighters.hh +++ b/src/highlighters.hh @@ -19,7 +19,7 @@ String option_to_string(InclusiveBufferRange range); void option_from_string(StringView str, InclusiveBufferRange& opt); using LineAndFlag = std::tuple<LineCount, String>; -using RangeAndFace = std::tuple<InclusiveBufferRange, String>; +using RangeAndString = std::tuple<InclusiveBufferRange, String>; } |
