mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-27 02:23:26 +03:00
Fix past-the-eol column highlighter getting highlighted as buffer range
Make the column highlighter faces final, and change final logic to give precedence to the base face when both the base and new face are final. Fixes #4669
This commit is contained in:
parent
af89d6e052
commit
195fe8fd29
@ -24,11 +24,11 @@ struct DisplayAtom : public UseMemoryDomain<MemoryDomain::Display>
|
|||||||
public:
|
public:
|
||||||
enum Type { Range, ReplacedRange, Text };
|
enum Type { Range, ReplacedRange, Text };
|
||||||
|
|
||||||
DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end)
|
DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end, Face face = {})
|
||||||
: m_type(Range), m_buffer(&buffer), m_range{begin, end} {}
|
: face(face), m_type(Range), m_buffer(&buffer), m_range{begin, end} {}
|
||||||
|
|
||||||
DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end, String str)
|
DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end, String str, Face face = {})
|
||||||
: m_type(ReplacedRange), m_buffer(&buffer), m_range{begin, end}, m_text{std::move(str)} {}
|
: face(face), m_type(ReplacedRange), m_buffer(&buffer), m_range{begin, end}, m_text{std::move(str)} {}
|
||||||
|
|
||||||
DisplayAtom(String str, Face face)
|
DisplayAtom(String str, Face face)
|
||||||
: face(face), m_type(Text), m_text(std::move(str)) {}
|
: face(face), m_type(Text), m_text(std::move(str)) {}
|
||||||
|
@ -65,10 +65,10 @@ inline Face merge_faces(const Face& base, const Face& face)
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto choose = [&](Color Face::*color, Attribute final_attr) {
|
auto choose = [&](Color Face::*color, Attribute final_attr) {
|
||||||
if (face.attributes & final_attr)
|
|
||||||
return face.*color;
|
|
||||||
if (base.attributes & final_attr)
|
if (base.attributes & final_attr)
|
||||||
return base.*color;
|
return base.*color;
|
||||||
|
if (face.attributes & final_attr)
|
||||||
|
return face.*color;
|
||||||
if (face.*color == Color::Default)
|
if (face.*color == Color::Default)
|
||||||
return base.*color;
|
return base.*color;
|
||||||
if ((base.*color).isRGB() and (face.*color).isRGB() and (face.*color).a != 255)
|
if ((base.*color).isRGB() and (face.*color).isRGB() and (face.*color).a != 255)
|
||||||
|
@ -558,6 +558,17 @@ std::unique_ptr<Highlighter> create_dynamic_regex_highlighter(HighlighterParamet
|
|||||||
return make_hl(get_regex, get_face);
|
return make_hl(get_regex, get_face);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
Face make_final(Face face)
|
||||||
|
{
|
||||||
|
face.attributes |= Attribute::Final;
|
||||||
|
return face;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const HighlighterDesc line_desc = {
|
const HighlighterDesc line_desc = {
|
||||||
"Parameters: <value string> <face>\n"
|
"Parameters: <value string> <face>\n"
|
||||||
"Highlight the line given by evaluating <value string> with <face>",
|
"Highlight the line given by evaluating <value string> with <face>",
|
||||||
@ -604,7 +615,7 @@ std::unique_ptr<Highlighter> create_line_highlighter(HighlighterParameters param
|
|||||||
}
|
}
|
||||||
const ColumnCount remaining = context.context.window().dimensions().column - column;
|
const ColumnCount remaining = context.context.window().dimensions().column - column;
|
||||||
if (remaining > 0)
|
if (remaining > 0)
|
||||||
it->push_back({ String{' ', remaining}, face });
|
it->push_back({ String{' ', remaining}, make_final(face) });
|
||||||
};
|
};
|
||||||
|
|
||||||
return make_highlighter(std::move(func));
|
return make_highlighter(std::move(func));
|
||||||
@ -670,8 +681,8 @@ std::unique_ptr<Highlighter> create_column_highlighter(HighlighterParameters par
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (remaining_col > 0)
|
if (remaining_col > 0)
|
||||||
line.push_back({buffer, last_pos, last_pos, String{' ', remaining_col}});
|
line.push_back({buffer, last_pos, last_pos, String{' ', remaining_col}, make_final(Face{})});
|
||||||
line.push_back({buffer, last_pos, last_pos, " "}).face = face;
|
line.push_back({buffer, last_pos, last_pos, " ", make_final(face)});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,2 @@
|
|||||||
ui_out '{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }'
|
ui_out -ignore 1
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 1│" }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "\u000a" }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "green", "underline": "default", "attributes": [] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 2│" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": "a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "b" }, { "face": { "fg": "default", "bg": "green", "underline": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 3│" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "ab" }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": [] }, "contents": "c" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "\u000a" }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "green", "underline": "default", "attributes": [] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 4│" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "ab" }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": [] }, "contents": "c" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "d" }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": "\u000a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "green", "underline": "default", "attributes": [] }, "contents": " " }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'
|
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 1│" }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "\u000a" }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }, { "face": { "fg": "default", "bg": "green", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 2│" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": "a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "b" }, { "face": { "fg": "default", "bg": "green", "underline": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 3│" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "ab" }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": [] }, "contents": "c" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "\u000a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }, { "face": { "fg": "default", "bg": "green", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 4│" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "ab" }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": [] }, "contents": "c" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "d" }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": "\u000a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }, { "face": { "fg": "default", "bg": "green", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] }'
|
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "info_hide", "params": [] }'
|
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "out 1:1 " }, { "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": "" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "underline": "default", "attributes": [] }] }'
|
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "set_cursor", "params": ["buffer", { "line": 0, "column": 3 }] }'
|
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "refresh", "params": [true] }'
|
|
||||||
|
@ -1,7 +1,2 @@
|
|||||||
ui_out '{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }'
|
ui_out -ignore 1
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxxxxxxxxx" }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": "x" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "x" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxx\u000a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": " " }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'
|
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxxxxxxxxx" }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": [] }, "contents": "x" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "x" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxx\u000a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }, { "face": { "fg": "default", "bg": "blue", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] }'
|
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "info_hide", "params": [] }'
|
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "out 1:89 " }, { "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": "" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "underline": "default", "attributes": [] }] }'
|
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "set_cursor", "params": ["buffer", { "line": 0, "column": 79 }] }'
|
|
||||||
ui_out '{ "jsonrpc": "2.0", "method": "refresh", "params": [true] }'
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
J
|
@ -0,0 +1,2 @@
|
|||||||
|
foo
|
||||||
|
bar
|
@ -0,0 +1 @@
|
|||||||
|
add-highlighter window/ column 6 ,red
|
@ -0,0 +1,2 @@
|
|||||||
|
ui_out -ignore 1
|
||||||
|
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "white", "bg": "blue", "underline": "default", "attributes": [] }, "contents": "foo\u000a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }], [{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "b" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "ar\u000a" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": ["final_fg","final_bg","final_attr"] }, "contents": " " }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'
|
Loading…
Reference in New Issue
Block a user