From 203cd065242a01ce27ccb4d7de9efa7fbceafc3b Mon Sep 17 00:00:00 2001 From: "Fabio M. Di Nitto" Date: Thu, 28 Oct 2010 09:17:52 +0200 Subject: [PATCH] vty_cli: fix refresh when adding in the middle of the buffer Signed-off-by: Fabio M. Di Nitto --- vty_cli.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vty_cli.c b/vty_cli.c index 694cd608c..55a00259f 100644 --- a/vty_cli.c +++ b/vty_cli.c @@ -29,10 +29,7 @@ static void knet_vty_reset_buf(struct knet_vty *vty) static void knet_vty_add_to_buf(struct knet_vty *vty, unsigned char *buf, int pos) { char outbuf[2]; - - outbuf[0] = buf[pos]; - outbuf[1] = 0; - knet_vty_write(vty, "%s", outbuf); + int i; if (vty->cursor_pos == vty->line_idx) { vty->line[vty->line_idx] = buf[pos]; @@ -43,6 +40,12 @@ static void knet_vty_add_to_buf(struct knet_vty *vty, unsigned char *buf, int po } vty->line_idx++; vty->cursor_pos++; + + outbuf[0] = buf[pos]; + outbuf[1] = 0; + knet_vty_write(vty, "%s%s", outbuf, &vty->line[vty->cursor_pos]); + for (i = 0; i < (vty->line_idx - vty->cursor_pos); i++) + knet_vty_write(vty, "%s", telnet_backward_char); } /*