diff options
| author | user <user@clank> | 2026-09-24 23:08:46 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-24 23:08:46 +0200 |
| commit | 0ed3787ce6182a9198d67bb2b6ce556d21c7b1ad (patch) | |
| tree | bd398978d05e52a2342f7b7a78428713683310db /usr | |
| parent | fs: hard links - ln(1), and rm that removes a NAME (diff) | |
| download | gbos-0ed3787ce6182a9198d67bb2b6ce556d21c7b1ad.tar.gz gbos-0ed3787ce6182a9198d67bb2b6ce556d21c7b1ad.tar.xz gbos-0ed3787ce6182a9198d67bb2b6ce556d21c7b1ad.zip | |
term: ESC[2J, so clear(1) can actually clear
The terminal understood SGR and nothing else, so there was no way to erase the
screen - printing 18 newlines only scrolls the history up out of sight.
term_erase_all blanks the buffer, resets the colours, homes the cursor and
repaints; the CSI parser routes 'J' to it, and clear(1) is four putc calls.
Diffstat (limited to '')
| -rw-r--r-- | usr/clear.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/usr/clear.c b/usr/clear.c new file mode 100644 index 0000000..76ee4dc --- /dev/null +++ b/usr/clear.c @@ -0,0 +1,10 @@ +#include "gbos.h" +/* clear: erase the screen and home the cursor. + * Emits ESC[2J, which the terminal understands (see term.asm term_erase_all) - + * printing 18 newlines would only scroll the history up, not clear it. */ +void main(void) { + putc(27); + putc('['); + putc('2'); + putc('J'); +} |
