Selectors: add select_to which selects until a given character on current line
This commit is contained in:
parent
0f4f201b6d
commit
c3faeb6c05
|
@ -368,6 +368,8 @@ std::unordered_map<char, std::function<void (Window& window, int count)>> keymap
|
||||||
{ 'L', [](Window& window, int count) { window.select(true, std::bind(move_select, std::ref(window), std::placeholders::_1,
|
{ 'L', [](Window& window, int count) { window.select(true, std::bind(move_select, std::ref(window), std::placeholders::_1,
|
||||||
WindowCoord(0, std::max(count,1)))); } },
|
WindowCoord(0, std::max(count,1)))); } },
|
||||||
|
|
||||||
|
{ 't', [](Window& window, int count) { window.select(false, std::bind(select_to, std::placeholders::_1, getch())); } },
|
||||||
|
|
||||||
{ 'd', [](Window& window, int count) { window.erase(); window.empty_selections(); } },
|
{ 'd', [](Window& window, int count) { window.erase(); window.empty_selections(); } },
|
||||||
{ 'c', [](Window& window, int count) { window.erase(); do_insert(window); } },
|
{ 'c', [](Window& window, int count) { window.erase(); do_insert(window); } },
|
||||||
{ 'i', [](Window& window, int count) { do_insert(window); } },
|
{ 'i', [](Window& window, int count) { do_insert(window); } },
|
||||||
|
|
|
@ -158,4 +158,13 @@ Selection select_matching(const BufferIterator& cursor)
|
||||||
return Selection(cursor, cursor);
|
return Selection(cursor, cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Selection select_to(const BufferIterator& cursor, char c)
|
||||||
|
{
|
||||||
|
BufferIterator end = cursor + 1;
|
||||||
|
skip_while(end, [c](char cur) { return not is_eol(cur) and cur != c; });
|
||||||
|
if (not is_eol(*end))
|
||||||
|
return Selection(cursor, end);
|
||||||
|
return Selection(cursor, cursor);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ Selection select_to_previous_word(const BufferIterator& cursor);
|
||||||
Selection select_line(const BufferIterator& cursor);
|
Selection select_line(const BufferIterator& cursor);
|
||||||
Selection move_select(Window& window, const BufferIterator& cursor, const WindowCoord& offset);
|
Selection move_select(Window& window, const BufferIterator& cursor, const WindowCoord& offset);
|
||||||
Selection select_matching(const BufferIterator& cursor);
|
Selection select_matching(const BufferIterator& cursor);
|
||||||
|
Selection select_to(const BufferIterator& cursor, char c);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user