summaryrefslogtreecommitdiffstats
path: root/include/escape.h
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2026-09-19 06:09:54 +0000
committerEthan Werner <mail@ethanwerner.com>2026-09-19 06:09:54 +0000
commitbf19b9938508f70011395f4dc283ca758ec6a8d3 (patch)
tree46dc4c442ed8d8d43040433c6a4794e76f8e618a /include/escape.h
parent96ecf29e8be977f51f351308ef2c7c492bb829aa (diff)
llm toolingHEADmaster
Diffstat (limited to 'include/escape.h')
-rwxr-xr-xinclude/escape.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/include/escape.h b/include/escape.h
index db46694..af616b3 100755
--- a/include/escape.h
+++ b/include/escape.h
@@ -37,10 +37,16 @@ void esc_fcursor_right(FILE *, u32 n);
void esc_cursor_line_next(u32 n);
void esc_fcursor_line_next(FILE *, u32 n);
+#define ESC_CURSOR_PREVIOUS(n) CSI #n "F"
+void esc_cursor_previous(u32 n);
+void esc_fcursor_previous(FILE *, u32 n);
+
#define ESC_CURSOR_POSITION(col, row) CSI #row ";" #col "H"
void esc_cursor_position(u32 col, u32 row);
void esc_fcursor_position(FILE *, u32 col, u32 row);
+#define ESC_CURSOR_COLUMN_HOME CSI "G"
+
#define ESC_CLEAR_SCREEN CSI "2J"
void esc_clear_screen(void);
void esc_fclear_screen(FILE *);
@@ -77,6 +83,8 @@ void esc_fscroll_down(FILE *, u32 n);
#define ESC_RESET CSI "0" ESC_SGR
#define ESC_BOLD CSI "1" ESC_SGR
+#define ESC_DIM CSI "2" ESC_SGR
+#define ESC_ITALIC CSI "3" ESC_SGR
#define ESC_UNDERLINE CSI "4" ESC_SGR
#define ESC_BLINK CSI "5" ESC_SGR
#define ESC_REVERSE CSI "7" ESC_SGR
@@ -106,6 +114,60 @@ void esc_fcolor_bg_256(FILE *, u32 n);
#define ESC_COLOR_FG_BRIGHT(n) CSI "9" #n ESC_SGR
#define ESC_COLOR_BG_BRIGHT(n) CSI "10" #n ESC_SGR
+/* Named standard colors (ANSI 0-7). */
+#define ESC_COLOR_BLACK ESC_COLOR_FG(0)
+#define ESC_COLOR_RED ESC_COLOR_FG(1)
+#define ESC_COLOR_GREEN ESC_COLOR_FG(2)
+#define ESC_COLOR_YELLOW ESC_COLOR_FG(3)
+#define ESC_COLOR_BLUE ESC_COLOR_FG(4)
+#define ESC_COLOR_MAGENTA ESC_COLOR_FG(5)
+#define ESC_COLOR_CYAN ESC_COLOR_FG(6)
+#define ESC_COLOR_WHITE ESC_COLOR_FG(7)
+
+#define ESC_CURSOR_HIDE CSI "?25l"
+void esc_cursor_hide(void);
+void esc_fcursor_hide(FILE *);
+
+#define ESC_CURSOR_SHOW CSI "?25h"
+void esc_cursor_show(void);
+void esc_fcursor_show(FILE *);
+
+#define ESC_CURSOR_SAVE CSI "s"
+void esc_cursor_save(void);
+void esc_fcursor_save(FILE *);
+
+#define ESC_CURSOR_RESTORE CSI "u"
+void esc_cursor_restore(void);
+void esc_fcursor_restore(FILE *);
+
+#define ESC_BELL "\x07"
+void esc_bell(void);
+void esc_fbell(FILE *);
+
+#define ESC_ALT_SCREEN_ON CSI "?1049h"
+void esc_alt_screen_on(void);
+void esc_falt_screen_on(FILE *);
+
+#define ESC_ALT_SCREEN_OFF CSI "?1049l"
+void esc_alt_screen_off(void);
+void esc_falt_screen_off(FILE *);
+
+#define ESC_BRACKETED_PASTE_ON CSI "?2004h"
+void esc_bracketed_paste_on(void);
+void esc_fbracketed_paste_on(FILE *);
+
+#define ESC_BRACKETED_PASTE_OFF CSI "?2004l"
+void esc_bracketed_paste_off(void);
+void esc_fbracketed_paste_off(FILE *);
+
+#define ESC_KITTY_ON CSI ">1u"
+void esc_kitty_on(void);
+void esc_fkitty_on(FILE *);
+
+#define ESC_KITTY_OFF CSI ">0u"
+void esc_kitty_off(void);
+void esc_fkitty_off(FILE *);
+
#ifdef __cplusplus
}
#endif
@@ -121,6 +183,7 @@ void esc_fcursor_down(FILE *f, u32 n) { if (!f) return; fprintf(f, CSI "%uB", (u
void esc_fcursor_left(FILE *f, u32 n) { if (!f) return; fprintf(f, CSI "%uD", (unsigned)n); }
void esc_fcursor_right(FILE *f, u32 n) { if (!f) return; fprintf(f, CSI "%uC", (unsigned)n); }
void esc_fcursor_line_next(FILE *f, u32 n) { if (!f) return; fprintf(f, CSI "%uE", (unsigned)n); }
+void esc_fcursor_previous(FILE *f, u32 n) { if (!f) return; fprintf(f, CSI "%uF", (unsigned)n); }
void esc_fcursor_position(FILE *f, u32 col, u32 row) {
if (!f) return;
fprintf(f, CSI "%u;%uH", (unsigned)row, (unsigned)col);
@@ -151,11 +214,24 @@ void esc_fcolor_bg_256(FILE *f, u32 n) {
fprintf(f, CSI "48;5;%u" ESC_SGR, (unsigned)n);
}
+void esc_fcursor_hide(FILE *f) { if (!f) return; fputs(CSI "?25l", f); }
+void esc_fcursor_show(FILE *f) { if (!f) return; fputs(CSI "?25h", f); }
+void esc_fcursor_save(FILE *f) { if (!f) return; fputs(CSI "s", f); }
+void esc_fcursor_restore(FILE *f) { if (!f) return; fputs(CSI "u", f); }
+void esc_fbell(FILE *f) { if (!f) return; fputc('\a', f); }
+void esc_falt_screen_on(FILE *f) { if (!f) return; fputs(CSI "?1049h", f); }
+void esc_falt_screen_off(FILE *f) { if (!f) return; fputs(CSI "?1049l", f); }
+void esc_fbracketed_paste_on(FILE *f) { if (!f) return; fputs(CSI "?2004h", f); }
+void esc_fbracketed_paste_off(FILE *f) { if (!f) return; fputs(CSI "?2004l", f); }
+void esc_fkitty_on(FILE *f) { if (!f) return; fputs(CSI ">1u", f); }
+void esc_fkitty_off(FILE *f) { if (!f) return; fputs(CSI ">0u", f); }
+
void esc_cursor_up(u32 n) { esc_fcursor_up(stdout, n); }
void esc_cursor_down(u32 n) { esc_fcursor_down(stdout, n); }
void esc_cursor_left(u32 n) { esc_fcursor_left(stdout, n); }
void esc_cursor_right(u32 n) { esc_fcursor_right(stdout, n); }
void esc_cursor_line_next(u32 n) { esc_fcursor_line_next(stdout, n); }
+void esc_cursor_previous(u32 n) { esc_fcursor_previous(stdout, n); }
void esc_cursor_position(u32 col, u32 row) {
esc_fcursor_position(stdout, col, row);
}
@@ -181,4 +257,16 @@ void esc_color_bg_256(u32 n) {
esc_fcolor_bg_256(stdout, n);
}
+void esc_cursor_hide(void) { esc_fcursor_hide(stdout); }
+void esc_cursor_show(void) { esc_fcursor_show(stdout); }
+void esc_cursor_save(void) { esc_fcursor_save(stdout); }
+void esc_cursor_restore(void) { esc_fcursor_restore(stdout); }
+void esc_bell(void) { esc_fbell(stdout); }
+void esc_alt_screen_on(void) { esc_falt_screen_on(stdout); }
+void esc_alt_screen_off(void) { esc_falt_screen_off(stdout); }
+void esc_bracketed_paste_on(void) { esc_fbracketed_paste_on(stdout); }
+void esc_bracketed_paste_off(void) { esc_fbracketed_paste_off(stdout); }
+void esc_kitty_on(void) { esc_fkitty_on(stdout); }
+void esc_kitty_off(void) { esc_fkitty_off(stdout); }
+
#endif // ESCAPE_IMPLEMENTATION \ No newline at end of file