mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 08:39:37 +08:00
Implement self-insert-notfirst in reader
This adds basic support for self-insert-notfirst. When we see a self-insert-nonempty char event, we kick it back to the outer loop, which only inserts the character if the cursor is not at the beginning.
This commit is contained in:
parent
2e4cb15880
commit
b8a7cdacb6
|
@ -2525,6 +2525,8 @@ static bool text_ends_in_comment(const wcstring &text) {
|
||||||
/// \return true if an event is a normal character that should be inserted into the buffer.
|
/// \return true if an event is a normal character that should be inserted into the buffer.
|
||||||
static bool event_is_normal_char(const char_event_t &evt) {
|
static bool event_is_normal_char(const char_event_t &evt) {
|
||||||
if (!evt.is_char()) return false;
|
if (!evt.is_char()) return false;
|
||||||
|
// Non-normal insertion styles are treated as a non-normal character.
|
||||||
|
if (evt.input_style != char_event_t::style_normal) return false;
|
||||||
auto c = evt.get_char();
|
auto c = evt.get_char();
|
||||||
return !fish_reserved_codepoint(c) && c > 31 && c != 127;
|
return !fish_reserved_codepoint(c) && c > 31 && c != 127;
|
||||||
}
|
}
|
||||||
|
@ -3492,8 +3494,11 @@ maybe_t<wcstring> reader_data_t::readline(int nchars_or_0) {
|
||||||
} else {
|
} else {
|
||||||
// Ordinary char.
|
// Ordinary char.
|
||||||
wchar_t c = event_needing_handling->get_char();
|
wchar_t c = event_needing_handling->get_char();
|
||||||
if (!fish_reserved_codepoint(c) && (c >= L' ' || c == L'\n' || c == L'\r') &&
|
if (event_needing_handling->input_style == char_event_t::style_notfirst &&
|
||||||
c != 0x7F) {
|
active_edit_line()->position() == 0) {
|
||||||
|
// This character is skipped.
|
||||||
|
} else if (!fish_reserved_codepoint(c) && (c >= L' ' || c == L'\n' || c == L'\r') &&
|
||||||
|
c != 0x7F) {
|
||||||
// Regular character.
|
// Regular character.
|
||||||
editable_line_t *el = active_edit_line();
|
editable_line_t *el = active_edit_line();
|
||||||
insert_char(active_edit_line(), c);
|
insert_char(active_edit_line(), c);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user