escape sequences

This commit is contained in:
iceman1001
2026-07-28 15:53:20 +02:00
parent f53b7516b7
commit 58eb7a9e43
+40 -8
View File
@@ -25,7 +25,27 @@
#define _CLEAR_SCROLLBACK_ "\x1b[3J"
#define _TOP_ "\x1b[1;1f"
// erase from cursor to end of line
#define _CLR_ "\x1b[0K"
// erase the entire current line, cursor column is unchanged
#define _CLR_LINE_ "\x1b[2K"
// erase from cursor to end of screen
#define _CLR_EOS_ "\x1b[J"
// cursor control. The ones taking a count / row are format strings and need an int arg
#define _CURSOR_HIDE_ "\x1b[?25l"
#define _CURSOR_SHOW_ "\x1b[?25h"
#define _CURSOR_HOME_ "\x1b[H" // move to row 1, col 1
#define _CURSOR_ROW_ "\x1b[%d;1H" // move to row %d, col 1
#define _CURSOR_UP_ "\x1b[%dA" // move up %d rows
// DEC private mode 2026, synchronized output. Terminals which support it hold
// the frame back until _SYNC_OFF_, terminals which don't ignore both
#define _SYNC_ON_ "\x1b[?2026h"
#define _SYNC_OFF_ "\x1b[?2026l"
#define ANSI_BOLD "\x1b[1m"
#define ANSI_DIM "\x1b[2m"
#define ANSI_BLACK "\x1b[30m"
#define ANSI_RED "\x1b[31m"
@@ -45,14 +65,26 @@
#define _CYAN_(s) ANSI_CYAN s AEND
#define _WHITE_(s) ANSI_WHITE s AEND
#define _BRIGHT_BLACK_(s) "\x1b[30;1m" s AEND
#define _BRIGHT_RED_(s) "\x1b[31;1m" s AEND
#define _BRIGHT_GREEN_(s) "\x1b[32;1m" s AEND
#define _BRIGHT_YELLOW_(s) "\x1b[33;1m" s AEND
#define _BRIGHT_BLUE_(s) "\x1b[34;1m" s AEND
#define _BRIGHT_MAGENTA_(s) "\x1b[35;1m" s AEND
#define _BRIGHT_CYAN_(s) "\x1b[36;1m" s AEND
#define _BRIGHT_WHITE_(s) "\x1b[37;1m" s AEND
#define ANSI_BRIGHT_BLACK "\x1b[30;1m"
#define ANSI_BRIGHT_RED "\x1b[31;1m"
#define ANSI_BRIGHT_GREEN "\x1b[32;1m"
#define ANSI_BRIGHT_YELLOW "\x1b[33;1m"
#define ANSI_BRIGHT_BLUE "\x1b[34;1m"
#define ANSI_BRIGHT_MAGENTA "\x1b[35;1m"
#define ANSI_BRIGHT_CYAN "\x1b[36;1m"
#define ANSI_BRIGHT_WHITE "\x1b[37;1m"
// 24-bit truecolor foreground, needs three int args (r, g, b)
#define ANSI_FG_RGB "\x1b[38;2;%d;%d;%dm"
#define _BRIGHT_BLACK_(s) ANSI_BRIGHT_BLACK s AEND
#define _BRIGHT_RED_(s) ANSI_BRIGHT_RED s AEND
#define _BRIGHT_GREEN_(s) ANSI_BRIGHT_GREEN s AEND
#define _BRIGHT_YELLOW_(s) ANSI_BRIGHT_YELLOW s AEND
#define _BRIGHT_BLUE_(s) ANSI_BRIGHT_BLUE s AEND
#define _BRIGHT_MAGENTA_(s) ANSI_BRIGHT_MAGENTA s AEND
#define _BRIGHT_CYAN_(s) ANSI_BRIGHT_CYAN s AEND
#define _BRIGHT_WHITE_(s) ANSI_BRIGHT_WHITE s AEND
#define _BACK_BLACK_(s) "\x1b[40m" s AEND
#define _BACK_RED_(s) "\x1b[41m" s AEND