]> git.mdlowis.com Git - projs/tide.git/commitdiff
Cap cursor at end of visible text of current line
authorMike Lowis <mike.lowis@gentex.com>
Mon, 4 Jan 2016 14:31:38 +0000 (14:31 +0000)
committerMike Lowis <mike.lowis@gentex.com>
Mon, 4 Jan 2016 14:31:38 +0000 (14:31 +0000)
source/main.c

index d9ba65095cfc0976dd222bb0d0a2e3d513024668..11a8ba22cda0e94248f02d34899d02a7174e27f3 100644 (file)
@@ -134,6 +134,8 @@ static void input(int ch)
                     ScreenDirty = true;
                 }
             }
+            if (Loc.line->next)
+                Loc.line = Loc.line->next;
             break;
 
         case KEY_UP:
@@ -146,6 +148,8 @@ static void input(int ch)
                     ScreenDirty = true;
                 }
             }
+            if (Loc.line->prev)
+                Loc.line = Loc.line->prev;
             break;
 
         case KEY_RIGHT:
@@ -160,6 +164,9 @@ static void input(int ch)
             }
             break;
     }
+    /* Cap the column selection at the end of text on the current line */
+    if (Curr.x >= (Loc.line->length-1 - Loc.offset))
+        Curr.x = (Loc.line->length-2 - Loc.offset);
 }
 
 static void edit(void)