cmdline (merge-intel): fix display of last char when using backspace
authorOlivier Matz <zer0@droids-corp.org>
Fri, 24 Dec 2010 12:55:28 +0000 (13:55 +0100)
committerOlivier Matz <zer0@droids-corp.org>
Sun, 2 Jan 2011 20:53:15 +0000 (21:53 +0100)
This was introduced by previous commit on this file.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
src/lib/cmdline_rdline.c

index 48cf03e..38b0773 100644 (file)
@@ -164,20 +164,21 @@ rdline_get_buffer(struct rdline *rdl)
 }
 
 static void
-display_right_buffer(struct rdline *rdl)
+display_right_buffer(struct rdline *rdl, int force)
 {
        unsigned int i;
        char tmp;
 
-       if (CIRBUF_IS_EMPTY(&rdl->right))
+       if (!force && CIRBUF_IS_EMPTY(&rdl->right))
                return;
 
        rdline_puts(rdl, vt100_clear_right);
        CIRBUF_FOREACH(&rdl->right, i, tmp) {
                rdl->write_char(rdl, tmp);
        }
-       rdline_miniprintf(rdl, vt100_multi_left,
-                         CIRBUF_GET_LEN(&rdl->right));
+       if (!CIRBUF_IS_EMPTY(&rdl->right))
+               rdline_miniprintf(rdl, vt100_multi_left,
+                                 CIRBUF_GET_LEN(&rdl->right));
 }
 
 void
@@ -192,7 +193,7 @@ rdline_redisplay(struct rdline *rdl)
        CIRBUF_FOREACH(&rdl->left, i, tmp) {
                rdl->write_char(rdl, tmp);
        }
-       display_right_buffer(rdl);
+       display_right_buffer(rdl, 1);
 }
 
 int
@@ -273,7 +274,7 @@ rdline_char_in(struct rdline *rdl, char c)
                case CMDLINE_KEY_BKSPACE:
                        if(!cirbuf_del_tail_safe(&rdl->left)) {
                                rdline_puts(rdl, vt100_bs);
-                               display_right_buffer(rdl);
+                               display_right_buffer(rdl, 1);
                        }
                        break;
 
@@ -286,7 +287,7 @@ rdline_char_in(struct rdline *rdl, char c)
                                rdline_puts(rdl, vt100_bs);
                                cirbuf_del_tail(&rdl->left);
                        }
-                       display_right_buffer(rdl);
+                       display_right_buffer(rdl, 1);
                        break;
 
                case CMDLINE_KEY_SUPPR:
@@ -297,7 +298,7 @@ rdline_char_in(struct rdline *rdl, char c)
                                return RDLINE_RES_EOF;
                        }
                        if (!cirbuf_del_head_safe(&rdl->right)) {
-                               display_right_buffer(rdl);
+                               display_right_buffer(rdl, 1);
                        }
                        break;
 
@@ -342,7 +343,7 @@ rdline_char_in(struct rdline *rdl, char c)
                                rdl->write_char(rdl, rdl->kill_buf[i]);
                                i++;
                        }
-                       display_right_buffer(rdl);
+                       display_right_buffer(rdl, 0);
                        break;
 #endif /* !NO_RDLINE_KILL_BUF */
 
@@ -390,7 +391,7 @@ rdline_char_in(struct rdline *rdl, char c)
                                                rdl->write_char(rdl, tmp_buf[i]);
                                                i++;
                                        }
-                                       display_right_buffer(rdl);
+                                       display_right_buffer(rdl, 1);
                                        return RDLINE_RES_COMPLETE; /* ?? */
                                }
 
@@ -485,7 +486,7 @@ rdline_char_in(struct rdline *rdl, char c)
                return RDLINE_RES_SUCCESS;
 
        rdl->write_char(rdl, c);
-       display_right_buffer(rdl);
+       display_right_buffer(rdl, 0);
 
        return RDLINE_RES_SUCCESS;
 }