From c4db46b58b3bd46767284afbfa370d4ef1233d0e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 24 May 2017 15:41:43 +0100 Subject: [PATCH] Rename line-flags option type to line-specs Generalize this option type, which is a timestamped list of |. That way this type is not strongly coupled with the flag-lines highlighter, and can be reused for other use cases. --- rc/base/lint.kak | 2 +- rc/extra/clang.kak | 2 +- rc/extra/git-tools.kak | 4 ++-- src/commands.cc | 12 ++++++------ src/highlighters.cc | 16 ++++++++-------- src/highlighters.hh | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/rc/base/lint.kak b/rc/base/lint.kak index 3e6022b6a8..0329d8a5e5 100644 --- a/rc/base/lint.kak +++ b/rc/base/lint.kak @@ -3,7 +3,7 @@ The output returned by this command is expected to comply with the following for {filename}:{line}:{column}: {kind}: {message}} \ str lintcmd -decl -hidden line-flags lint_flags +decl -hidden line-specs lint_flags decl -hidden str lint_errors def lint -docstring 'Parse the current buffer with a linter' %{ diff --git a/rc/extra/clang.kak b/rc/extra/clang.kak index b94bf5a686..71ddd79553 100644 --- a/rc/extra/clang.kak +++ b/rc/extra/clang.kak @@ -3,7 +3,7 @@ decl -docstring "options to pass to the `clang` shell command" \ decl -hidden str clang_tmp_dir decl -hidden completions clang_completions -decl -hidden line-flags clang_flags +decl -hidden line-specs clang_flags decl -hidden str clang_errors def -params ..1 \ diff --git a/rc/extra/git-tools.kak b/rc/extra/git-tools.kak index 63f4eae20f..6774433459 100644 --- a/rc/extra/git-tools.kak +++ b/rc/extra/git-tools.kak @@ -17,8 +17,8 @@ hook -group git-status-highlight global WinSetOption filetype=git-status %{ hook -group git-status-highlight global WinSetOption filetype=(?!git-status).* %{ remove-highlighter git-status-highlight } -decl -hidden line-flags git_blame_flags -decl -hidden line-flags git_diff_flags +decl -hidden line-specs git_blame_flags +decl -hidden line-specs git_diff_flags face GitBlame default,magenta face GitDiffFlags default,black diff --git a/src/commands.cc b/src/commands.cc index c32c29de41..b11db6a54f 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -43,9 +43,9 @@ namespace Kakoune { -StringView option_type_name(Meta::Type>) +StringView option_type_name(Meta::Type>) { - return "line-flags"; + return "line-specs"; } StringView option_type_name(Meta::Type>) @@ -1334,7 +1334,7 @@ const CommandDesc declare_option_cmd = { " int-list: list of integers\n" " str-list: list of character strings\n" " completions: list of completion candidates\n" - " line-flags: list of line flags\n" + " line-specs: list of line specs\n" " range-specs: list of range specs\n", ParameterDesc{ { { "hidden", { false, "do not display option name when completing" } }, @@ -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-specs"}; + auto c = {"int", "bool", "str", "regex", "int-list", "str-list", "completions", "line-specs", "range-specs"}; return { 0_byte, cursor_pos, complete(prefix, cursor_pos, c) }; }), [](const ParametersParser& parser, Context& context, const ShellContext&) @@ -1375,8 +1375,8 @@ const CommandDesc declare_option_cmd = { opt = ®.declare_option>(parser[1], docstring, {}, flags); else if (parser[0] == "completions") opt = ®.declare_option(parser[1], docstring, {}, flags); - else if (parser[0] == "line-flags") - opt = ®.declare_option>(parser[1], docstring, {}, flags); + else if (parser[0] == "line-specs") + opt = ®.declare_option>(parser[1], docstring, {}, flags); else if (parser[0] == "range-specs") opt = ®.declare_option>(parser[1], docstring, {}, flags); else diff --git a/src/highlighters.cc b/src/highlighters.cc index 51758b6b29..610ddffd36 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -1184,7 +1184,7 @@ struct FlagLinesHighlighter : Highlighter m_option_name{std::move(option_name)}, m_default_face{std::move(default_face)} {} - using LineAndFlagList = TimestampedList; + using LineAndSpecList = TimestampedList; static HighlighterAndId create(HighlighterParameters params) { @@ -1196,7 +1196,7 @@ struct FlagLinesHighlighter : Highlighter get_face(default_face); // validate param // throw if wrong option type - GlobalScope::instance().options()[option_name].get(); + GlobalScope::instance().options()[option_name].get(); return {"hlflags_" + params[1], make_unique(option_name, default_face) }; } @@ -1205,7 +1205,7 @@ struct FlagLinesHighlighter : Highlighter void do_highlight(const Context& context, HighlightPass, DisplayBuffer& display_buffer, BufferRange) override { - auto& line_flags = context.options()[m_option_name].get_mutable(); + auto& line_flags = context.options()[m_option_name].get_mutable(); auto& buffer = context.buffer(); update_line_flags_ifn(buffer, line_flags); @@ -1235,7 +1235,7 @@ struct FlagLinesHighlighter : Highlighter { int line_num = (int)line.range().begin.line + 1; auto it = find_if(lines, - [&](const LineAndFlag& l) + [&](const LineAndSpec& l) { return std::get<0>(l) == line_num; }); if (it == lines.end()) line.insert(line.begin(), empty); @@ -1255,7 +1255,7 @@ struct FlagLinesHighlighter : Highlighter void do_compute_display_setup(const Context& context, HighlightPass, DisplaySetup& setup) override { - auto& line_flags = context.options()[m_option_name].get_mutable(); + auto& line_flags = context.options()[m_option_name].get_mutable(); auto& buffer = context.buffer(); update_line_flags_ifn(buffer, line_flags); @@ -1274,7 +1274,7 @@ struct FlagLinesHighlighter : Highlighter setup.window_range.column -= width; } - void update_line_flags_ifn(const Buffer& buffer, LineAndFlagList& line_flags) + void update_line_flags_ifn(const Buffer& buffer, LineAndSpecList& line_flags) { if (line_flags.prefix == buffer.timestamp()) return; @@ -1282,7 +1282,7 @@ struct FlagLinesHighlighter : Highlighter auto& lines = line_flags.list; std::sort(lines.begin(), lines.end(), - [](const LineAndFlag& lhs, const LineAndFlag& rhs) + [](const LineAndSpec& lhs, const LineAndSpec& rhs) { return std::get<0>(lhs) < std::get<0>(rhs); }); auto modifs = compute_line_modifications(buffer, line_flags.prefix); @@ -1968,7 +1968,7 @@ void register_highlighters() "flag_lines", { FlagLinesHighlighter::create, "Parameters: