about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-15 01:12:38 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-15 01:18:02 +0100
commitec8bd20cbbf617fa9f39d18b69010f1dbb717b20 (patch)
treeaab3a5922ee8c7a85c65e7c1495633e406d6b48b /src
parentb175d8200561f6afc894b40aaf70502ee529aed8 (diff)
downloadchawan-ec8bd20cbbf617fa9f39d18b69010f1dbb717b20.tar.gz
container: cursor x fixes
* also set fromX to corrected target x if target x is less than corrected x;
  this is mainly so that setCursorX(-1) works as expected
* return w from cursorFirstX() even if cursorx is <= the last character
Diffstat (limited to 'src')
-rw-r--r--src/local/container.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index 21981049..011c7279 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -260,6 +260,7 @@ func cursorFirstX(container: Container): int =
     if w + tw > cc:
       return w
     w += tw
+  return w
 
 # Returns the X position of the last cell occupied by the character the cursor
 # currently points to.
@@ -513,8 +514,9 @@ proc setCursorX(container: Container, x: int, refresh = true, save = true)
     # target x is before the screen start
     if x2 < container.cursorx:
       # desired X position is lower than cursor X; move screen back to the
-      # desired position if valid, otherwise the last cell of the current line.
-      if x2 == x:
+      # desired position if valid, to 0 if the desired position is less than 0,
+      # otherwise the last cell of the current line.
+      if x2 <= x:
         container.setFromX(x, false)
       else:
         container.setFromX(cw - 1, false)