diff options
author | 2012-07-15 14:02:34 -0700 | |
---|---|---|
committer | 2012-07-15 14:02:34 -0700 | |
commit | 548ea1e54aa17590a573ec5a976ee0413345d360 (patch) | |
tree | 05ebb323c5babc665bae6675b5d02478605b98f4 /reader.cpp | |
parent | 4755c5f8c892978919d9b652bcfee6ef220c7ca6 (diff) |
Added binding for accepting an autosuggestion
Diffstat (limited to 'reader.cpp')
-rw-r--r-- | reader.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
@@ -1204,6 +1204,18 @@ static void update_autosuggestion(void) { #endif } +static void accept_autosuggestion(void) { + /* Accept any autosuggestion by replacing the command line with it. */ + if (! data->autosuggestion.empty()) { + /* Accept the autosuggestion */ + data->command_line = data->autosuggestion; + data->buff_pos = data->command_line.size(); + data->command_line_changed(); + reader_super_highlight_me_plenty(data->buff_pos); + reader_repaint(); + } +} + /** Flash the screen. This function only changed the color of the current line, since the flash_screen sequnce is rather painful to @@ -3015,15 +3027,7 @@ const wchar_t *reader_readline() data->buff_pos++; reader_repaint(); } else { - /* We're at the end of our buffer, and the user hit right. Try autosuggestion. */ - if (! data->autosuggestion.empty()) { - /* Accept the autosuggestion */ - data->command_line = data->autosuggestion; - data->buff_pos = data->command_line.size(); - data->command_line_changed(); - reader_super_highlight_me_plenty(data->buff_pos); - reader_repaint(); - } + accept_autosuggestion(); } break; } @@ -3113,7 +3117,7 @@ const wchar_t *reader_readline() break; } - + case R_SUPPRESS_AUTOSUGGESTION: { data->suppress_autosuggestion = true; @@ -3121,6 +3125,12 @@ const wchar_t *reader_readline() reader_repaint(); break; } + + case R_ACCEPT_AUTOSUGGESTION: + { + accept_autosuggestion(); + break; + } /* Other, if a normal character, we add it to the command */ default: |