tAllow left/right navigation across start of lines and end of lines - ve - a minimal text editor (work in progress)
 (HTM) git clone git://src.adamsgaard.dk/ve
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit eb5c375b6985de714e2487c22e248171a8d2c926
 (DIR) parent ff5731cf9db9e1933a13654bce29476117121ab5
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Tue,  6 Aug 2019 13:27:05 +0200
       
       Allow left/right navigation across start of lines and end of lines
       
       Diffstat:
         M input.c                             |      14 +++++++++++---
       
       1 file changed, 11 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/input.c b/input.c
       t@@ -14,21 +14,29 @@ editor_move_cursor(char key)
                
                switch(key) {
                        case 'h':
       -                        if (E.cursor_x > 0)
       +                        if (E.cursor_x != 0) {
                                        E.cursor_x--;
       +                        } else if (E.cursor_y > 0) {
       +                                E.cursor_y--;
       +                                E.cursor_x = E.row[E.cursor_y].size;
       +                        }
                                break;
                        case 'j':
                                if (E.cursor_y < E.num_rows - 1)
                                        E.cursor_y++;
                                break;
                        case 'k':
       -                        if (E.cursor_y > 0)
       +                        if (E.cursor_y != 0)
                                        E.cursor_y--;
                                break;
                        case 'l':
                                row = (E.cursor_y >= E.num_rows) ? NULL : &E.row[E.cursor_y];
       -                        if (row && E.cursor_x < row->size)
       +                        if (row && E.cursor_x < row->size) {
                                        E.cursor_x++;
       +                        } else if (row && E.cursor_x == row->size) {
       +                                E.cursor_y++;
       +                                E.cursor_x = 0;
       +                        }
                                break;
                }