summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-12-15 14:38:04 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-12-15 14:38:04 +0000
commiteb81eef03ee794b82e23026c01cd2fc4a1a78076 (patch)
tree0bafaac0d2e913d814a3e629dbaccba7ef1f4ed7 /src
parent39b43f4c3cb58c083671f0c4423dcdc79b0dcfed (diff)
Move SelectMode enum as an implementation detail in normal.cc
Diffstat (limited to 'src')
-rw-r--r--src/editor.hh8
-rw-r--r--src/normal.cc32
-rw-r--r--src/selectors.hh24
3 files changed, 32 insertions, 32 deletions
diff --git a/src/editor.hh b/src/editor.hh
index b26a8fee..5a468279 100644
--- a/src/editor.hh
+++ b/src/editor.hh
@@ -12,14 +12,6 @@ namespace InputModes { class Insert; }
class Register;
-enum class SelectMode
-{
- Replace,
- Extend,
- Append,
- ReplaceMain,
-};
-
enum class InsertMode : unsigned
{
Insert,
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)
{
diff --git a/src/selectors.hh b/src/selectors.hh
index 84cc9ed9..da9b195f 100644
--- a/src/selectors.hh
+++ b/src/selectors.hh
@@ -266,30 +266,6 @@ Selection find_next_match(const Buffer& buffer, const Selection& sel, const Rege
return {begin.coord(), end.coord(), std::move(captures)};
}
-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();
-}
-
void select_all_matches(const Buffer& buffer, SelectionList& selections,
const Regex& regex);