diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wreadln.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/wreadln.c b/src/wreadln.c index 0bfc41408..5d019d900 100644 --- a/src/wreadln.c +++ b/src/wreadln.c @@ -120,17 +120,12 @@ static inline void drawline(const struct wreadln *wr) static void wreadln_insert_byte(struct wreadln *wr, gint key) { - if (strlen(wr->line + wr->cursor)) { /* if the cursor is */ - /* not at the last pos */ - gsize rest = strlen(wr->line + wr->cursor) + 1; - - memmove(wr->line + wr->cursor + 1, - wr->line + wr->cursor, rest); - wr->line[wr->cursor] = key; - } else { - wr->line[wr->cursor + 1] = 0; - wr->line[wr->cursor] = key; - } + size_t rest = strlen(wr->line + wr->cursor) + 1; + const size_t length = 1; + + memmove(wr->line + wr->cursor + length, + wr->line + wr->cursor, rest); + wr->line[wr->cursor] = key; cursor_move_right(wr); } |