mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-24 20:13:00 +03:00
Add an 'insert_hide_sel' option, which hides selection when inserting
This commit is contained in:
parent
f0baf35117
commit
42fae29391
@ -259,20 +259,24 @@ void show_line_numbers(DisplayBuffer& display_buffer)
|
||||
}
|
||||
}
|
||||
|
||||
void highlight_selections(const Editor& editor, DisplayBuffer& display_buffer)
|
||||
void highlight_selections(const Window& window, DisplayBuffer& display_buffer)
|
||||
{
|
||||
for (size_t i = 0; i < editor.selections().size(); ++i)
|
||||
const bool only_cursor = window.is_editing() and window.options()["insert_hide_sel"].get<bool>();
|
||||
for (size_t i = 0; i < window.selections().size(); ++i)
|
||||
{
|
||||
auto& sel = editor.selections()[i];
|
||||
auto& sel = window.selections()[i];
|
||||
const bool forward = sel.first() <= sel.last();
|
||||
BufferIterator begin = forward ? sel.first() : utf8::next(sel.last());
|
||||
BufferIterator end = forward ? sel.last() : utf8::next(sel.first());
|
||||
|
||||
const bool primary = (i == editor.main_selection_index());
|
||||
ColorPair sel_colors = ColorRegistry::instance()[primary ? "PrimarySelection" : "SecondarySelection"];
|
||||
const bool primary = (i == window.main_selection_index());
|
||||
if (not only_cursor)
|
||||
{
|
||||
ColorPair sel_colors = ColorRegistry::instance()[primary ? "PrimarySelection" : "SecondarySelection"];
|
||||
highlight_range(display_buffer, begin, end, false,
|
||||
[&](DisplayAtom& atom) { atom.colors = sel_colors; });
|
||||
}
|
||||
ColorPair cur_colors = ColorRegistry::instance()[primary ? "PrimaryCursor" : "SecondaryCursor"];
|
||||
highlight_range(display_buffer, begin, end, false,
|
||||
[&](DisplayAtom& atom) { atom.colors = sel_colors; });
|
||||
highlight_range(display_buffer, sel.last(), utf8::next(sel.last()), false,
|
||||
[&](DisplayAtom& atom) { atom.colors = cur_colors; });
|
||||
}
|
||||
|
@ -260,6 +260,7 @@ GlobalOptions::GlobalOptions()
|
||||
declare_option<String>("filetype", "");
|
||||
declare_option<std::vector<String>>("completions", {});
|
||||
declare_option<std::vector<String>>("path", { "./", "/usr/include" });
|
||||
declare_option<bool>("insert_hide_sel", false);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -12,7 +12,7 @@ namespace Kakoune
|
||||
{
|
||||
|
||||
// Implementation in highlighters.cc
|
||||
void highlight_selections(const Editor& editor, DisplayBuffer& display_buffer);
|
||||
void highlight_selections(const Window& window, DisplayBuffer& display_buffer);
|
||||
void expand_tabulations(const OptionManager& options, DisplayBuffer& display_buffer);
|
||||
void expand_unprintable(DisplayBuffer& display_buffer);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user