Rename select_whole_.* to just select_.*

This commit is contained in:
Maxime Coste 2014-05-26 21:44:57 +01:00
parent c1a7759e7f
commit 9aa38a1ea0
3 changed files with 30 additions and 22 deletions

View File

@ -913,11 +913,11 @@ void select_object(Context& context, int param)
Codepoint key; Codepoint key;
Selection (*func)(const Buffer&, const Selection&, ObjectFlags); Selection (*func)(const Buffer&, const Selection&, ObjectFlags);
} selectors[] = { } selectors[] = {
{ 'w', select_whole_word<Word> }, { 'w', select_word<Word> },
{ 'W', select_whole_word<WORD> }, { 'W', select_word<WORD> },
{ 's', select_whole_sentence }, { 's', select_sentence },
{ 'p', select_whole_paragraph }, { 'p', select_paragraph },
{ 'i', select_whole_indent }, { 'i', select_indent },
}; };
for (auto& sel : selectors) for (auto& sel : selectors)
{ {
@ -1387,7 +1387,7 @@ KeyMap keymap =
{ '.', repeat_last_insert }, { '.', repeat_last_insert },
{ '%', [](Context& context, int) { select_whole_buffer(context.buffer(), context.selections()); } }, { '%', [](Context& context, int) { select_buffer(context.buffer(), context.selections()); } },
{ ':', command }, { ':', command },
{ '|', pipe<InsertMode::Replace> }, { '|', pipe<InsertMode::Replace> },
@ -1417,7 +1417,7 @@ KeyMap keymap =
{ 'x', repeated(make_select<SelectMode::Replace>(select_line)) }, { 'x', repeated(make_select<SelectMode::Replace>(select_line)) },
{ 'X', repeated(make_select<SelectMode::Extend>(select_line)) }, { 'X', repeated(make_select<SelectMode::Extend>(select_line)) },
{ alt('x'), make_select<SelectMode::Replace>(select_whole_lines) }, { alt('x'), make_select<SelectMode::Replace>(select_lines) },
{ alt('X'), make_select<SelectMode::Replace>(trim_partial_lines) }, { alt('X'), make_select<SelectMode::Replace>(trim_partial_lines) },
{ 'm', make_select<SelectMode::Replace>(select_matching) }, { 'm', make_select<SelectMode::Replace>(select_matching) },

View File

@ -223,7 +223,7 @@ static bool is_end_of_sentence(char c)
return c == '.' or c == ';' or c == '!' or c == '?'; return c == '.' or c == ';' or c == '!' or c == '?';
} }
Selection select_whole_sentence(const Buffer& buffer, const Selection& selection, ObjectFlags flags) Selection select_sentence(const Buffer& buffer, const Selection& selection, ObjectFlags flags)
{ {
BufferIterator first = buffer.iterator_at(selection.cursor()); BufferIterator first = buffer.iterator_at(selection.cursor());
@ -284,7 +284,7 @@ Selection select_whole_sentence(const Buffer& buffer, const Selection& selection
: Selection{last.coord(), first.coord()}; : Selection{last.coord(), first.coord()};
} }
Selection select_whole_paragraph(const Buffer& buffer, const Selection& selection, ObjectFlags flags) Selection select_paragraph(const Buffer& buffer, const Selection& selection, ObjectFlags flags)
{ {
BufferIterator first = buffer.iterator_at(selection.cursor()); BufferIterator first = buffer.iterator_at(selection.cursor());
@ -360,7 +360,7 @@ static bool is_only_whitespaces(const String& str)
return it == str.end(); return it == str.end();
} }
Selection select_whole_indent(const Buffer& buffer, const Selection& selection, ObjectFlags flags) Selection select_indent(const Buffer& buffer, const Selection& selection, ObjectFlags flags)
{ {
int tabstop = buffer.options()["tabstop"].get<int>(); int tabstop = buffer.options()["tabstop"].get<int>();
LineCount line = selection.cursor().line; LineCount line = selection.cursor().line;
@ -394,7 +394,7 @@ Selection select_whole_indent(const Buffer& buffer, const Selection& selection,
return Selection{begin_line, {end_line, buffer[end_line].length() - 1}}; return Selection{begin_line, {end_line, buffer[end_line].length() - 1}};
} }
Selection select_whole_lines(const Buffer& buffer, const Selection& selection) Selection select_lines(const Buffer& buffer, const Selection& selection)
{ {
// no need to be utf8 aware for is_eol as we only use \n as line seperator // no need to be utf8 aware for is_eol as we only use \n as line seperator
BufferIterator first = buffer.iterator_at(selection.anchor()); BufferIterator first = buffer.iterator_at(selection.anchor());
@ -419,7 +419,7 @@ Selection select_whole_lines(const Buffer& buffer, const Selection& selection)
Selection trim_partial_lines(const Buffer& buffer, const Selection& selection) Selection trim_partial_lines(const Buffer& buffer, const Selection& selection)
{ {
// same as select_whole_lines // same as select_lines
BufferIterator first = buffer.iterator_at(selection.anchor()); BufferIterator first = buffer.iterator_at(selection.anchor());
BufferIterator last = buffer.iterator_at(selection.cursor()); BufferIterator last = buffer.iterator_at(selection.cursor());
BufferIterator& to_line_start = first <= last ? first : last; BufferIterator& to_line_start = first <= last ? first : last;
@ -433,7 +433,7 @@ Selection trim_partial_lines(const Buffer& buffer, const Selection& selection)
return Selection(first.coord(), last.coord()); return Selection(first.coord(), last.coord());
} }
void select_whole_buffer(const Buffer& buffer, SelectionList& selections) void select_buffer(const Buffer& buffer, SelectionList& selections)
{ {
selections = SelectionList{ Selection({0,0}, buffer.back_coord()) }; selections = SelectionList{ Selection({0,0}, buffer.back_coord()) };
} }

View File

@ -159,7 +159,7 @@ constexpr ObjectFlags operator|(ObjectFlags lhs, ObjectFlags rhs)
{ return (ObjectFlags)((int)lhs | (int) rhs); } { return (ObjectFlags)((int)lhs | (int) rhs); }
template<WordType word_type> template<WordType word_type>
Selection select_whole_word(const Buffer& buffer, const Selection& selection, ObjectFlags flags) Selection select_word(const Buffer& buffer, const Selection& selection, ObjectFlags flags)
{ {
Utf8Iterator first = buffer.iterator_at(selection.cursor()); Utf8Iterator first = buffer.iterator_at(selection.cursor());
Utf8Iterator last = first; Utf8Iterator last = first;
@ -200,16 +200,24 @@ Selection select_whole_word(const Buffer& buffer, const Selection& selection, Ob
: utf8_range(last, first); : utf8_range(last, first);
} }
Selection select_whole_sentence(const Buffer& buffer, const Selection& selection, Selection select_sentence(const Buffer& buffer,
ObjectFlags flags); const Selection& selection,
Selection select_whole_paragraph(const Buffer& buffer, const Selection& selection, ObjectFlags flags);
ObjectFlags flags);
Selection select_whole_indent(const Buffer& buffer, const Selection& selection, Selection select_paragraph(const Buffer& buffer,
ObjectFlags flags); const Selection& selection,
Selection select_whole_lines(const Buffer& buffer, const Selection& selection); ObjectFlags flags);
void select_whole_buffer(const Buffer& buffer, SelectionList& selections);
Selection select_indent(const Buffer& buffer,
const Selection& selection,
ObjectFlags flags);
Selection select_lines(const Buffer& buffer, const Selection& selection);
Selection trim_partial_lines(const Buffer& buffer, const Selection& selection); Selection trim_partial_lines(const Buffer& buffer, const Selection& selection);
void select_buffer(const Buffer& buffer, SelectionList& selections);
enum Direction { Forward, Backward }; enum Direction { Forward, Backward };
using MatchResults = boost::match_results<BufferIterator>; using MatchResults = boost::match_results<BufferIterator>;