This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 90040ce0f0a include/nuttx/vt100.h: fix macro syntax errors and add
cursor movement macros
90040ce0f0a is described below
commit 90040ce0f0a7bf3df200fc1ba9a827e97f594add
Author: Sarthak Pandey <[email protected]>
AuthorDate: Wed Oct 14 00:50:10 2026 +0530
include/nuttx/vt100.h: fix macro syntax errors and add cursor movement
macros
Several macro definitions in vt100.h had syntax bugs or limitations:
- VT100_NUMERIC_9 had a missing closing brace ({'9', instead of {'9'}}).
- VT100_RESET had a typo in the definition (#define VT100_RESET RIS ...).
- Horizontal cursor movement macros had comments referencing 'lines'
instead of 'columns'.
- Parameterless 1-step cursor movement array macros were missing, forcing
drivers (like nxterm) to define them manually.
- Added VT100_CURSORUP_, VT100_CURSORDN_, VT100_CURSORRT_, and
VT100_CURSORLF_ as parameterless 1-step array initializers.
- Added VT100_STR_CURSORUP, VT100_STR_CURSORDN, VT100_STR_CURSORRT, and
VT100_STR_CURSORLF string macros.
- Updated graphics/nxterm/nxterm_vt100.c to use the new standard macros.
Fixes: #15933
Signed-off-by: Sarthak Pandey <[email protected]>
---
graphics/nxterm/nxterm_vt100.c | 13 +++----------
include/nuttx/vt100.h | 20 ++++++++++++++------
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/graphics/nxterm/nxterm_vt100.c b/graphics/nxterm/nxterm_vt100.c
index e421af785ab..c92a9f4305e 100644
--- a/graphics/nxterm/nxterm_vt100.c
+++ b/graphics/nxterm/nxterm_vt100.c
@@ -66,16 +66,9 @@ static enum nxterm_vt100state_e
/* <esc>[K is the VT100 command erases to the end of the line. */
-static const char g_erasetoeol[] = VT100_CLEAREOL;
-static const char g_cursorleft[] =
-{
- ASCII_ESC, '[', 'D'
-};
-
-static const char g_cursorright[] =
-{
- ASCII_ESC, '[', 'C'
-};
+static const char g_erasetoeol[] = VT100_CLEAREOL;
+static const char g_cursorleft[] = VT100_CURSORLF_;
+static const char g_cursorright[] = VT100_CURSORRT_;
/* The list of all VT100 sequences supported by the emulation */
diff --git a/include/nuttx/vt100.h b/include/nuttx/vt100.h
index 16c3cde00e9..3250c1d7372 100644
--- a/include/nuttx/vt100.h
+++ b/include/nuttx/vt100.h
@@ -109,10 +109,14 @@
#define VT100_CURSOROFF2 {ASCII_ESC, '[', '?', '5', '0', 'l'} /* Cursor
OFF */
#define VT100_CURSORON2 {ASCII_ESC, '[', '?', '5', '0', 'h'} /* Cursor ON
*/
-#define VT100_CURSORUP(n) {ASCII_ESC, '[', (n), 'A'} /* Move cursor
up n lines */
-#define VT100_CURSORDN(n) {ASCII_ESC, '[', (n), 'B'} /* Move cursor
down n lines */
-#define VT100_CURSORRT(n) {ASCII_ESC, '[', (n), 'C'} /* Move cursor
right n lines */
-#define VT100_CURSORLF(n) {ASCII_ESC, '[', (n), 'D'} /* Move cursor
left n lines */
+#define VT100_CURSORUP(n) {ASCII_ESC, '[', (n), 'A'} /* Move cursor
up n lines (n is char '1'..'9') */
+#define VT100_CURSORDN(n) {ASCII_ESC, '[', (n), 'B'} /* Move cursor
down n lines (n is char '1'..'9') */
+#define VT100_CURSORRT(n) {ASCII_ESC, '[', (n), 'C'} /* Move cursor
right n columns (n is char '1'..'9') */
+#define VT100_CURSORLF(n) {ASCII_ESC, '[', (n), 'D'} /* Move cursor
left n columns (n is char '1'..'9') */
+#define VT100_CURSORUP_ {ASCII_ESC, '[', 'A'} /* Move cursor
up 1 line */
+#define VT100_CURSORDN_ {ASCII_ESC, '[', 'B'} /* Move cursor
down 1 line */
+#define VT100_CURSORRT_ {ASCII_ESC, '[', 'C'} /* Move cursor
right 1 column */
+#define VT100_CURSORLF_ {ASCII_ESC, '[', 'D'} /* Move cursor
left 1 column */
#define VT100_CURSORHOME {ASCII_ESC, '[', 'H'} /* Move cursor
to upper left corner */
#define VT100_CURSORHOME_ {ASCII_ESC, '[', ';', 'H'} /* Move cursor
to upper left corner */
@@ -162,7 +166,7 @@
#define VT100_GETTYPE {ASCII_ESC, '[', '?', '1', ';', (n), '0', 'c'} /*
Response: terminal type code n */
-#define VT100_RESET RIS {ASCII_ESC, 'c'} /* Reset
terminal to initial state */
+#define VT100_RESET {ASCII_ESC, 'c'} /* Reset
terminal to initial state */
#define VT100_ALIGN {ASCII_ESC, '#', '8'} /* Screen
alignment display */
@@ -229,6 +233,10 @@
#define VT100_STR_CLEARSCREEN "\033[2J" /* Clear entire
screen */
#define VT100_STR_CURSORHOME "\033[1;1H" /* Move cursor
to upper left corner */
+#define VT100_STR_CURSORUP "\033[A" /* Move cursor
up 1 line */
+#define VT100_STR_CURSORDN "\033[B" /* Move cursor
down 1 line */
+#define VT100_STR_CURSORRT "\033[C" /* Move cursor
right 1 column */
+#define VT100_STR_CURSORLF "\033[D" /* Move cursor
left 1 column */
#define VT100_STR_CLEAREOL "\033[K" /* Erase to end
of current line */
#define VT100_STR_CLEAREOS "\033[J" /* Erase to end
of screen */
#define VT100_STR_BOLD "\033[1m" /* Turn bold
mode on */
@@ -279,7 +287,7 @@
#define VT100_ALT_7 {ASCII_ESC, 'O', 'w'}
#define VT100_NUMERIC_8 {'8'}
#define VT100_ALT_8 {ASCII_ESC, 'O', 'x'}
-#define VT100_NUMERIC_9 {'9',
+#define VT100_NUMERIC_9 {'9'}
#define VT100_ALT_9 {ASCII_ESC, 'O', 'y'}
#define VT100_NUMERIC_MINUS {'-'}
#define VT100_ALT_MINUS {ASCII_ESC, 'O', 'm'}