[Lldb-commits] [lldb] [lldb] Use 1 based row and column for statusline (PR #143385)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 9 07:53:05 PDT 2025
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/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.
>From 7316a626d2934737a0b4a6a284357882e221e0b6 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Mon, 9 Jun 2025 14:50:29 +0000
Subject: [PATCH] [lldb] Use 1 based row and column for statusline
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.
>From what I read, some terminals correct 0 back to 1
and some treat 0 as a missing argument, which also
defaults to 1.
---
lldb/source/Core/Statusline.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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"
More information about the lldb-commits
mailing list