Skip to content

Commit 6ec48b4

Browse files
[lldb] Use 1 based row and column for statusline (llvm#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.
1 parent 45f57ee commit 6ec48b4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lldb/source/Core/Statusline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#define ANSI_SAVE_CURSOR ESCAPE "7"
2525
#define ANSI_RESTORE_CURSOR ESCAPE "8"
2626
#define ANSI_CLEAR_BELOW ESCAPE "[J"
27-
#define ANSI_SET_SCROLL_ROWS ESCAPE "[0;%ur"
28-
#define ANSI_TO_START_OF_ROW ESCAPE "[%u;0f"
27+
#define ANSI_SET_SCROLL_ROWS ESCAPE "[1;%ur"
28+
#define ANSI_TO_START_OF_ROW ESCAPE "[%u;1f"
2929
#define ANSI_REVERSE_VIDEO ESCAPE "[7m"
3030
#define ANSI_UP_ROWS ESCAPE "[%dA"
3131

lldb/test/API/functionalities/statusline/TestStatusline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test(self):
4444
self.expect(
4545
"set set show-statusline true",
4646
[
47-
"\x1b[0;{}r".format(self.TERMINAL_HEIGHT - 1),
47+
"\x1b[1;{}r".format(self.TERMINAL_HEIGHT - 1),
4848
"a.out | main.c:2:11 | breakpoint 1.1 ",
4949
],
5050
)
@@ -66,7 +66,7 @@ def test(self):
6666

6767
# Hide the statusline and check or the control character.
6868
self.expect(
69-
"set set show-statusline false", ["\x1b[0;{}r".format(self.TERMINAL_HEIGHT)]
69+
"set set show-statusline false", ["\x1b[1;{}r".format(self.TERMINAL_HEIGHT)]
7070
)
7171

7272
def test_no_color(self):

0 commit comments

Comments
 (0)