Skip to content

Commit

Permalink
vty_cli: add ctrl+w 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 203cd06 commit db175c0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions vty_cli.c
Expand Up @@ -161,6 +161,15 @@ static void knet_vty_backward_word(struct knet_vty *vty)
knet_vty_backward_char(vty);
}

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

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

static int knet_vty_process_buf(struct knet_vty *vty, unsigned char *buf, int buflen)
{
int i;
Expand Down Expand Up @@ -210,7 +219,7 @@ static int knet_vty_process_buf(struct knet_vty *vty, unsigned char *buf, int bu
case CONTROL('H'):
case 0x7f:
vty->escape = VTY_NORMAL;
log_info("backward kill word");
knet_vty_backward_kill_word(vty);
break;
default:
break;
Expand Down Expand Up @@ -258,7 +267,7 @@ static int knet_vty_process_buf(struct knet_vty *vty, unsigned char *buf, int bu
knet_vty_kill_line_from_beginning(vty);
break;
case CONTROL('W'):
log_info("kill backward word");
knet_vty_backward_kill_word(vty);
break;
case CONTROL('Z'):
log_info("end config");
Expand Down

0 comments on commit db175c0

Please sign in to comment.