mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-08-10 01:06:59 +02:00
cli: Implement delete-word in cread_line()
The Ctrl-W option is implemented in the cread_line_simple() but not in the full version. This seems odd, so add an implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
6321391ac3
commit
dcc18ce0db
@ -89,6 +89,14 @@ static char hist_lines[HIST_MAX][HIST_SIZE + 1]; /* Save room for NULL */
|
|||||||
|
|
||||||
#define add_idx_minus_one() ((hist_add_idx == 0) ? hist_max : hist_add_idx-1)
|
#define add_idx_minus_one() ((hist_add_idx == 0) ? hist_max : hist_add_idx-1)
|
||||||
|
|
||||||
|
static void getcmd_putchars(int count, int ch)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
getcmd_putch(ch);
|
||||||
|
}
|
||||||
|
|
||||||
static void hist_init(void)
|
static void hist_init(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -337,6 +345,29 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,
|
|||||||
case CTL_CH('o'):
|
case CTL_CH('o'):
|
||||||
insert = !insert;
|
insert = !insert;
|
||||||
break;
|
break;
|
||||||
|
case CTL_CH('w'):
|
||||||
|
if (num) {
|
||||||
|
uint base;
|
||||||
|
|
||||||
|
for (base = num - 1;
|
||||||
|
base >= 0 && buf[base] == ' ';)
|
||||||
|
base--;
|
||||||
|
for (; base > 0 && buf[base - 1] != ' ';)
|
||||||
|
base--;
|
||||||
|
|
||||||
|
/* now delete chars from base to num */
|
||||||
|
wlen = num - base;
|
||||||
|
eol_num -= wlen;
|
||||||
|
memmove(&buf[base], &buf[num],
|
||||||
|
eol_num - base + 1);
|
||||||
|
num = base;
|
||||||
|
getcmd_putchars(wlen, CTL_BACKSPACE);
|
||||||
|
puts(buf + base);
|
||||||
|
getcmd_putchars(wlen, ' ');
|
||||||
|
getcmd_putchars(wlen + eol_num - num,
|
||||||
|
CTL_BACKSPACE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CTL_CH('x'):
|
case CTL_CH('x'):
|
||||||
case CTL_CH('u'):
|
case CTL_CH('u'):
|
||||||
BEGINNING_OF_LINE();
|
BEGINNING_OF_LINE();
|
||||||
|
Loading…
Reference in New Issue
Block a user