diff --git a/src/highlighters.cc b/src/highlighters.cc index ed1d4abe..b837ca88 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -206,6 +206,7 @@ public: auto atom_it = display_buffer.begin(); auto sel_it = selections.begin(); + // underline each selections while (atom_it != display_buffer.end() and sel_it != selections.end()) { @@ -253,10 +254,22 @@ public: assert(false); } - boost::regex ex("\n"); - for (auto& sel : selections) - colorize_regex_range(display_buffer, sel.first, sel.second, - ex, Color::Default, Color::Yellow); + // invert selection last char + for (auto& sel : m_window.selections()) + { + 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; + } } diff --git a/src/main.cc b/src/main.cc index 57aa4492..7291dda7 100644 --- a/src/main.cc +++ b/src/main.cc @@ -195,7 +195,7 @@ void init_ncurses() nonl(); intrflush(stdscr, false); keypad(stdscr, true); - curs_set(2); + curs_set(0); start_color(); ESCDELAY=25; } @@ -209,6 +209,9 @@ struct prompt_aborted {}; 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; getmaxyx(stdscr, max_y, max_x); move(max_y-1, 0);