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 /src | |
| 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.cc | 12 | ||||
| -rw-r--r-- | src/highlighters.cc | 20 | ||||
| -rw-r--r-- | src/highlighters.hh | 2 |
3 files changed, 18 insertions, 16 deletions
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>; } |
