Skip to content

Commit

Permalink
vty_cli: add backward word handler
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Oct 28, 2010
1 parent 86ac34c commit b155cf3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion vty_cli.c
Expand Up @@ -149,6 +149,15 @@ static void knet_vty_kill_line_from_beginning(struct knet_vty *vty)
knet_vty_kill_line(vty);
}

static void knet_vty_backward_word(struct knet_vty *vty)
{
while(vty->cursor_pos > 0 && vty->line[vty->cursor_pos - 1] == ' ')
knet_vty_backward_char(vty);

while(vty->cursor_pos > 0 && vty->line[vty->cursor_pos - 1] != ' ')
knet_vty_backward_char(vty);
}

static int knet_vty_process_buf(struct knet_vty *vty, unsigned char *buf, int buflen)
{
int i;
Expand Down Expand Up @@ -185,7 +194,7 @@ static int knet_vty_process_buf(struct knet_vty *vty, unsigned char *buf, int bu
break;
case 'b':
vty->escape = VTY_NORMAL;
log_info("backword word");
knet_vty_backward_word(vty);
break;
case 'f':
vty->escape = VTY_NORMAL;
Expand Down

0 comments on commit b155cf3

Please sign in to comment.