diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-12-15 14:38:04 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-12-15 14:38:04 +0000 |
| commit | eb81eef03ee794b82e23026c01cd2fc4a1a78076 (patch) | |
| tree | 0bafaac0d2e913d814a3e629dbaccba7ef1f4ed7 /src/normal.cc | |
| parent | 39b43f4c3cb58c083671f0c4423dcdc79b0dcfed (diff) | |
Move SelectMode enum as an implementation detail in normal.cc
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/normal.cc b/src/normal.cc index ec8f32c0..aab5a029 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -22,6 +22,14 @@ namespace Kakoune using namespace std::placeholders; +enum class SelectMode +{ + Replace, + Extend, + Append, + ReplaceMain, +}; + template<SelectMode mode, typename T> class Select { @@ -360,6 +368,30 @@ void pipe(Context& context, int) }); } +template<Direction direction, SelectMode mode> +void select_next_match(const Buffer& buffer, SelectionList& selections, + const Regex& regex) +{ + if (mode == SelectMode::Replace) + { + for (auto& sel : selections) + sel = find_next_match<direction>(buffer, sel, regex); + } + if (mode == SelectMode::Extend) + { + for (auto& sel : selections) + sel.merge_with(find_next_match<direction>(buffer, sel, regex)); + } + else if (mode == SelectMode::ReplaceMain) + selections.main() = find_next_match<direction>(buffer, selections.main(), regex); + else if (mode == SelectMode::Append) + { + selections.push_back(find_next_match<direction>(buffer, selections.main(), regex)); + selections.set_main_index(selections.size() - 1); + } + selections.sort_and_merge_overlapping(); +} + template<SelectMode mode, Direction direction> void search(Context& context, int) { |
