replxx readline compatibility

- By default M-BACKSPACE is KILL_TO_WHITESPACE_ON_LEFT, while in
  readline it is backward-kill-word, so use KILL_TO_BEGINING_OF_WORD
  instead.
- By default C-w is KILL_TO_BEGINING_OF_WORD, while in readline it is
  unix-word-rubout, so use KILL_TO_WHITESPACE_ON_LEFT instead.
This commit is contained in:
Azat Khuzhin 2021-05-02 23:22:54 +03:00
parent 08f10dced0
commit 5ff78fb297

View File

@ -91,6 +91,10 @@ ReplxxLineReader::ReplxxLineReader(
/// it also binded to M-p/M-n).
rx.bind_key(Replxx::KEY::meta('N'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::COMPLETE_NEXT, code); });
rx.bind_key(Replxx::KEY::meta('P'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::COMPLETE_PREVIOUS, code); });
/// By default M-BACKSPACE is KILL_TO_WHITESPACE_ON_LEFT, while in readline it is backward-kill-word
rx.bind_key(Replxx::KEY::meta(Replxx::KEY::BACKSPACE), [this](char32_t code) { return rx.invoke(Replxx::ACTION::KILL_TO_BEGINING_OF_WORD, code); });
/// By default C-w is KILL_TO_BEGINING_OF_WORD, while in readline it is unix-word-rubout
rx.bind_key(Replxx::KEY::control('W'), [this](char32_t code) { return rx.invoke(Replxx::ACTION::KILL_TO_WHITESPACE_ON_LEFT, code); });
rx.bind_key(Replxx::KEY::meta('E'), [this](char32_t) { openEditor(); return Replxx::ACTION_RESULT::CONTINUE; });
}