From 9047523588811f476d650d6890e6fbc7b4829f13 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Wed, 28 Aug 2019 13:10:37 +0300 Subject: [PATCH] Add crummy ANSI color routines Output raw codes straight to the terminal, don't coordinate with anybody. --- scheme-core/system.scm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scheme-core/system.scm b/scheme-core/system.scm index 3c6b315..907897b 100644 --- a/scheme-core/system.scm +++ b/scheme-core/system.scm @@ -916,6 +916,34 @@ Up Scheme " 1)) +(define (sgr . ns) + (let ((out (open-output-string))) + (display "\x1b[" out) + (unless (null? ns) + (let loop ((ns ns)) + (display (car ns) out) + (let ((ns (cdr ns))) + (unless (null? ns) + (display #\; out) + (loop ns))))) + (display "m" out) + (get-output-string out))) + +(define bold 1) + +(define (fg n) (+ 30 n)) +(define (bg n) (+ 40 n)) + +(define black 0) +(define red 1) +(define green 2) +(define yellow 3) +(define blue 4) +(define magenta 5) +(define cyan 6) +(define white 7) +(define default-color 8) + (define (repl) (define (prompt) (display "up> ")