From 8ec92e3574b2b9d67ef8cd72201143e424798816 Mon Sep 17 00:00:00 2001 From: a bellenir Date: Mon, 4 Jan 2016 16:14:26 -0500 Subject: [PATCH] remember cursor's desired column --- source/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/main.c b/source/main.c index b5e7369..ba4951b 100644 --- a/source/main.c +++ b/source/main.c @@ -134,7 +134,13 @@ static void edit(void) ScreenDirty = false; } /* Place the cursor */ - move(Curr.y, Curr.x); + /* Cap the column selection at the end of text on the current line */ + int x = Curr.x; + if (Loc.line->length <= 1) + x = 0; + else if (x >= (Loc.line->length-1 - Loc.offset)) + x = (Loc.line->length-2 - Loc.offset); + move(Curr.y, x); } while((ch = getch()) != 'q'); } @@ -171,11 +177,6 @@ static void input(int ch) cursorEnd(); break; } - /* Cap the column selection at the end of text on the current line */ - if (Loc.line->length <= 1) - Curr.x = 0; - else if (Curr.x >= (Loc.line->length-1 - Loc.offset)) - Curr.x = (Loc.line->length-2 - Loc.offset); } static void cursorLeft() -- 2.52.0