diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-07-27 16:08:35 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-07-27 16:08:35 +1000 |
| commit | 10ed78fe8a580b3558348746ee53f81c5b0aeae1 (patch) | |
| tree | 63a9d9705b258a8262215eb1afb32ca046bd7525 /src | |
| parent | 128dafdfe98632a890876413d0b3d9ca67f071d5 (diff) | |
Reduce templatization further to reduce binary size
Diffstat (limited to 'src')
| -rw-r--r-- | src/normal.cc | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/normal.cc b/src/normal.cc index 6961a54d..ea183bc4 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1537,10 +1537,9 @@ enum class SelectFlags constexpr bool with_bit_ops(Meta::Type<SelectFlags>) { return true; } -template<SelectFlags flags> -void select_to_next_char(Context& context, NormalParams params) +void select_to_next_char(Context& context, NormalParams params, SelectFlags flags) { - auto get_title = [] { + auto get_title = [=] { return format("{} {} {} char", flags & SelectFlags::Extend ? "extend" : "select", flags & SelectFlags::Inclusive ? "onto" : "to", @@ -1548,20 +1547,26 @@ void select_to_next_char(Context& context, NormalParams params) }; on_next_key_with_autoinfo(context, "to-char", KeymapMode::None, - [params](Key key, Context& context) { + [params, flags](Key key, Context& context) { auto cp = key.codepoint(); if (not cp or key == Key::Escape) return; - constexpr auto new_flags = flags & SelectFlags::Extend ? SelectMode::Extend + auto new_flags = flags & SelectFlags::Extend ? SelectMode::Extend : SelectMode::Replace; select_and_set_last( - context, new_flags, [cp=*cp, count=params.count] (auto& context, auto& sel) { + context, new_flags, [cp=*cp, count=params.count, flags] (auto& context, auto& sel) { auto& func = flags & SelectFlags::Reverse ? select_to_reverse : select_to; return func(context, sel, cp, count, flags & SelectFlags::Inclusive); }); }, get_title(), "enter char to select to"); } +template<SelectFlags flags> +void select_to_next_char(Context& context, NormalParams params) +{ + select_to_next_char(context, params, flags); +} + void start_or_end_macro_recording(Context& context, NormalParams params) { if (context.input_handler().is_recording()) @@ -2116,8 +2121,8 @@ void repeated(Context& context, NormalParams params) do { func(context, {0, params.reg}); } while(--params.count > 0); } -template<typename Type, Direction direction, SelectMode mode = SelectMode::Replace> -void move_cursor(Context& context, NormalParams params) +template<typename Type> +void move_cursor(Context& context, NormalParams params, Direction direction, SelectMode mode) { kak_assert(mode == SelectMode::Replace or mode == SelectMode::Extend); const Type offset{direction * std::max(params.count,1)}; @@ -2133,6 +2138,12 @@ void move_cursor(Context& context, NormalParams params) selections.sort_and_merge_overlapping(); } +template<typename Type, Direction direction, SelectMode mode = SelectMode::Replace> +void move_cursor(Context& context, NormalParams params) +{ + move_cursor<Type>(context, params, direction, mode); +} + void select_whole_buffer(Context& context, NormalParams) { auto& buffer = context.buffer(); |
