diff --git a/src/input_handler.cc b/src/input_handler.cc index 5d6f437a..133c85b1 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -24,7 +24,7 @@ public: InputMode(const InputMode&) = delete; InputMode& operator=(const InputMode&) = delete; - virtual void on_key(const Key& key) = 0; + virtual void on_key(Key key) = 0; Context& context() const { return m_input_handler.context(); } using Insertion = InputHandler::Insertion; @@ -58,7 +58,7 @@ public: context().hooks().run_hook("NormalEnd", "", context()); } - void on_key(const Key& key) override + void on_key(Key key) override { if (key.modifiers == Key::Modifiers::None and isdigit(key.key)) m_count = m_count * 10 + key.key - '0'; @@ -84,7 +84,7 @@ private: class LineEditor { public: - void handle_key(const Key& key) + void handle_key(Key key) { if (key == Key::Left or key == Key{Key::Modifiers::Control, 'b'}) @@ -172,7 +172,7 @@ public: get_color("MenuBackground"), MenuStyle::Prompt); } - void on_key(const Key& key) override + void on_key(Key key) override { auto match_filter = [this](const String& str) { return boost::regex_match(str.begin(), str.end(), m_filter); @@ -299,7 +299,7 @@ public: display(); } - void on_key(const Key& key) override + void on_key(Key key) override { std::vector& history = ms_history[m_prompt]; const String& line = m_line_editor.line(); @@ -476,7 +476,7 @@ public: NextKey(InputHandler& input_handler, KeyCallback callback) : InputMode(input_handler), m_callback(callback) {} - void on_key(const Key& key) override + void on_key(Key key) override { reset_normal_mode(); m_callback(key, context()); @@ -746,7 +746,7 @@ public: context().hooks().run_hook("InsertBegin", "", context()); } - void on_key(const Key& key) override + void on_key(Key key) override { if (&context().editor() != &m_inserter.editor()) return reset_normal_mode().on_key(key); @@ -892,7 +892,7 @@ void InputHandler::on_next_key(KeyCallback callback) m_mode.reset(new InputModes::NextKey(*this, callback)); } -bool is_valid(const Key& key) +bool is_valid(Key key) { return key != Key::Invalid and key.key <= 0x10FFFF; } diff --git a/src/input_handler.hh b/src/input_handler.hh index ccd8426c..edc9e5e0 100644 --- a/src/input_handler.hh +++ b/src/input_handler.hh @@ -29,7 +29,7 @@ enum class PromptEvent Validate }; using PromptCallback = std::function; -using KeyCallback = std::function; +using KeyCallback = std::function; class InputMode; enum class InsertMode : unsigned; diff --git a/src/keys.cc b/src/keys.cc index 956d9e59..98909029 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -87,7 +87,7 @@ KeyList parse_keys(const String& str) return result; } -String key_to_str(const Key& key) +String key_to_str(Key key) { bool named = false; String res; diff --git a/src/keys.hh b/src/keys.hh index 0df78853..cfff452f 100644 --- a/src/keys.hh +++ b/src/keys.hh @@ -44,17 +44,17 @@ struct Key constexpr Key(Codepoint key) : modifiers(Modifiers::None), key(key) {} - constexpr bool operator==(const Key& other) const + constexpr bool operator==(Key other) const { return modifiers == other.modifiers and key == other.key; } - constexpr bool operator!=(const Key& other) const + constexpr bool operator!=(Key other) const { return modifiers != other.modifiers or key != other.key; } }; typedef std::vector KeyList; KeyList parse_keys(const String& str); -String key_to_str(const Key& key); +String key_to_str(Key key); } @@ -64,7 +64,7 @@ namespace std template<> struct hash : unary_function { - size_t operator()(const Kakoune::Key& key) const + size_t operator()(Kakoune::Key key) const { return static_cast(key.modifiers) * 1024 + key.key; } diff --git a/src/normal.cc b/src/normal.cc index 50912251..cc0b3d83 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -69,7 +69,7 @@ void goto_commands(Context& context) "│ a: last buffer │\n" "│ f: file │\n" "╰─────────────────────╯\n", context); - context.input_handler().on_next_key([=](const Key& key, Context& context) { + context.input_handler().on_next_key([=](Key key, Context& context) { if (hide) context.ui().info_hide(); if (key.modifiers != Key::Modifiers::None) @@ -169,7 +169,7 @@ void view_commands(Context& context) "│ j: scroll down │\n" "│ k: scroll up │\n" "╰────────────────────────╯\n", context); - context.input_handler().on_next_key([hide](const Key& key, Context& context) { + context.input_handler().on_next_key([hide](Key key, Context& context) { if (hide) context.ui().info_hide(); if (key.modifiers != Key::Modifiers::None or not context.has_window()) @@ -206,7 +206,7 @@ void view_commands(Context& context) void replace_with_char(Context& context) { - context.input_handler().on_next_key([](const Key& key, Context& context) { + context.input_handler().on_next_key([](Key key, Context& context) { if (not isprint(key.key)) return; Editor& editor = context.editor(); @@ -573,7 +573,7 @@ void select_object(Context& context) "│ p: paragraph │\n" "╰────────────────────────────╯\n", context); context.input_handler().on_next_key( - [=](const Key& key, Context& context) { + [=](Key key, Context& context) { if (hide) context.ui().info_hide(); typedef std::function Selector; @@ -660,7 +660,7 @@ template void select_to_next_char(Context& context) { int param = context.numeric_param(); - context.input_handler().on_next_key([param](const Key& key, Context& context) { + context.input_handler().on_next_key([param](Key key, Context& context) { context.editor().select( std::bind(flags & SelectFlags::Reverse ? select_to_reverse : select_to, _1, _2, key.key, param, flags & SelectFlags::Inclusive), @@ -673,7 +673,7 @@ void start_or_end_macro_recording(Context& context) if (context.input_handler().is_recording()) context.input_handler().stop_recording(); else - context.input_handler().on_next_key([](const Key& key, Context& context) { + context.input_handler().on_next_key([](Key key, Context& context) { if (key.modifiers == Key::Modifiers::None) context.input_handler().start_recording(key.key); }); @@ -682,7 +682,7 @@ void start_or_end_macro_recording(Context& context) void replay_macro(Context& context) { int count = context.numeric_param(); - context.input_handler().on_next_key([count](const Key& key, Context& context) mutable { + context.input_handler().on_next_key([count](Key key, Context& context) mutable { if (key.modifiers == Key::Modifiers::None) { static std::unordered_set running_macros;