Author: David Spickett
Date: 2025-06-10T09:59:16+01:00
New Revision: 6ec48b449fb60a766d4faf185613f1b4a8638bfa

URL: 
https://github.com/llvm/llvm-project/commit/6ec48b449fb60a766d4faf185613f1b4a8638bfa
DIFF: 
https://github.com/llvm/llvm-project/commit/6ec48b449fb60a766d4faf185613f1b4a8638bfa.diff

LOG: [lldb] Use 1 based row and column for statusline (#143385)

I can't find a proper source for this but many materials say that ANSI
rows and columns start at 1 not 0.

https://www2.math.upenn.edu/~kazdan/210/computer/ansi.html is as good as
I can get:
```
<row> is a number from 1 through 25 that specifies the row to which the cursor 
is to be moved.
<col> is a number from 1 through 80 that specifies the column to which the 
cursor is to be moved.
```

0 does work in Windows terminal and Linux terminals, but we might as
well be correct and it's one less thing to reason about when auditing
this code.

>From what I read, some terminals correct 0 back to 1 and some treat 0 as
a missing argument, which also defaults to 1.

Added: 
    

Modified: 
    lldb/source/Core/Statusline.cpp
    lldb/test/API/functionalities/statusline/TestStatusline.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Core/Statusline.cpp b/lldb/source/Core/Statusline.cpp
index 52f6134123b76..8a8640805cac0 100644
--- a/lldb/source/Core/Statusline.cpp
+++ b/lldb/source/Core/Statusline.cpp
@@ -24,8 +24,8 @@
 #define ANSI_SAVE_CURSOR ESCAPE "7"
 #define ANSI_RESTORE_CURSOR ESCAPE "8"
 #define ANSI_CLEAR_BELOW ESCAPE "[J"
-#define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
-#define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
+#define ANSI_SET_SCROLL_ROWS ESCAPE "[1;%ur"
+#define ANSI_TO_START_OF_ROW ESCAPE "[%u;1f"
 #define ANSI_REVERSE_VIDEO ESCAPE "[7m"
 #define ANSI_UP_ROWS ESCAPE "[%dA"
 

diff  --git a/lldb/test/API/functionalities/statusline/TestStatusline.py 
b/lldb/test/API/functionalities/statusline/TestStatusline.py
index 53ac7432f4ba1..68c5ad3090cfd 100644
--- a/lldb/test/API/functionalities/statusline/TestStatusline.py
+++ b/lldb/test/API/functionalities/statusline/TestStatusline.py
@@ -44,7 +44,7 @@ def test(self):
         self.expect(
             "set set show-statusline true",
             [
-                "\x1b[0;{}r".format(self.TERMINAL_HEIGHT - 1),
+                "\x1b[1;{}r".format(self.TERMINAL_HEIGHT - 1),
                 "a.out | main.c:2:11 | breakpoint 1.1                        ",
             ],
         )
@@ -66,7 +66,7 @@ def test(self):
 
         # Hide the statusline and check or the control character.
         self.expect(
-            "set set show-statusline false", 
["\x1b[0;{}r".format(self.TERMINAL_HEIGHT)]
+            "set set show-statusline false", 
["\x1b[1;{}r".format(self.TERMINAL_HEIGHT)]
         )
 
     def test_no_color(self):


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to