Skip to content

Commit e1e55d3

Browse files
epilysphilmd
authored andcommitted
util/readline: Add C-u shortcut
Add support for the unix-line-discard readline action, which erases from the cursor position up to the beginning of the line. The default binding, C-u, was chosen. This is useful to quickly erase command input while working on the monitor interface. Signed-off-by: Manos Pitsidianakis <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Message-ID: <6772067e1c0d4b1c5310e5446e9e3e1c6b3b5bc0.1718265822.git.manos.pitsidianakis@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
1 parent 96c99e3 commit e1e55d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

util/readline.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,14 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
271271
rs->hist_entry = -1;
272272
}
273273

274+
static void readline_kill_line(ReadLineState *rs)
275+
{
276+
while (rs->cmd_buf_index > 0) {
277+
readline_backward_char(rs);
278+
readline_delete_char(rs);
279+
}
280+
}
281+
274282
/* completion support */
275283

276284
void readline_add_completion(ReadLineState *rs, const char *str)
@@ -426,6 +434,10 @@ void readline_handle_byte(ReadLineState *rs, int ch)
426434
/* ^P Prev line in history */
427435
readline_up_char(rs);
428436
break;
437+
case 21:
438+
/* ^U Kill backward from point to the beginning of the line. */
439+
readline_kill_line(rs);
440+
break;
429441
case 23:
430442
/* ^W */
431443
readline_backword(rs);

0 commit comments

Comments
 (0)