SelectionHighlighter: reverse color of the last char of each selection
the terminal cursor is now longer shown
This commit is contained in:
parent
0e805238b5
commit
6411193f10
|
@ -206,6 +206,7 @@ public:
|
||||||
auto atom_it = display_buffer.begin();
|
auto atom_it = display_buffer.begin();
|
||||||
auto sel_it = selections.begin();
|
auto sel_it = selections.begin();
|
||||||
|
|
||||||
|
// underline each selections
|
||||||
while (atom_it != display_buffer.end()
|
while (atom_it != display_buffer.end()
|
||||||
and sel_it != selections.end())
|
and sel_it != selections.end())
|
||||||
{
|
{
|
||||||
|
@ -253,10 +254,22 @@ public:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::regex ex("\n");
|
// invert selection last char
|
||||||
for (auto& sel : selections)
|
for (auto& sel : m_window.selections())
|
||||||
colorize_regex_range(display_buffer, sel.first, sel.second,
|
{
|
||||||
ex, Color::Default, Color::Yellow);
|
const BufferIterator& last = sel.last();
|
||||||
|
|
||||||
|
DisplayBuffer::iterator atom_it = display_buffer.atom_containing(last);
|
||||||
|
if (atom_it == display_buffer.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (atom_it->begin() < last)
|
||||||
|
atom_it = ++display_buffer.split(atom_it, last);
|
||||||
|
if (atom_it->end() > last + 1)
|
||||||
|
atom_it = display_buffer.split(atom_it, last + 1);
|
||||||
|
|
||||||
|
atom_it->attribute() |= Attributes::Reverse;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ void init_ncurses()
|
||||||
nonl();
|
nonl();
|
||||||
intrflush(stdscr, false);
|
intrflush(stdscr, false);
|
||||||
keypad(stdscr, true);
|
keypad(stdscr, true);
|
||||||
curs_set(2);
|
curs_set(0);
|
||||||
start_color();
|
start_color();
|
||||||
ESCDELAY=25;
|
ESCDELAY=25;
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,9 @@ struct prompt_aborted {};
|
||||||
|
|
||||||
std::string ncurses_prompt(const std::string& text, Completer completer = complete_nothing)
|
std::string ncurses_prompt(const std::string& text, Completer completer = complete_nothing)
|
||||||
{
|
{
|
||||||
|
curs_set(2);
|
||||||
|
auto restore_cursor = on_scope_end([]() { curs_set(0); });
|
||||||
|
|
||||||
int max_x, max_y;
|
int max_x, max_y;
|
||||||
getmaxyx(stdscr, max_y, max_x);
|
getmaxyx(stdscr, max_y, max_x);
|
||||||
move(max_y-1, 0);
|
move(max_y-1, 0);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user