ColorLib, providing foreground/background colors                                                                                Block #1 is messy since it has to identify which port           we are using. This is a bit of a hack, but it seems to          work for now...                                                                                                                                                                                                                                                 here last @ create where , ,                                    : cleanup drop where dup @ last ! cell+ @ h0 ! reset ;          : self  s" scr_size" find ?if cleanup 6 s ;; then 2drop ;       : vt100 s" syscall" find ?if cleanup 2 s ;; then 2drop ;        : isWin < from kernel32.dll > ;                                 : win? isWin ['] from cell- @ 0; cleanup 8 s rdrop ;            : ffi s" from" find ?if win? 2 s ;; then 2drop ;                :: self vt100 ffi ; execute e                                   : (esc) 27 emit type ;                                          : clear s" [2J" (esc)       : home s" [1;1H" (esc) ;            : normal s" [0m" (esc) ;    : bold s" [1m" (esc) ;              : black s" [30m" (esc) ;    : red s" [31m" (esc) ;              : green s" [32m" (esc) ;    : yellow s" [33m" (esc) ;           : blue s" [34m" (esc) ;     : magenta s" [35m" (esc) ;          : cyan s" [36m" (esc) ;     : white s" [37m" (esc) ;            n e                                                             : onBlack s" [40m" (esc) ;  : onRed     s" [41m" (esc) ;        : onGreen s" [42m" (esc) ;  : onYellow  s" [43m" (esc) ;        : onBlue  s" [44m" (esc) ;  : onMagenta s" [45m" (esc) ;        : onCyan  s" [46m" (esc) ;  : onWhite   s" [47m" (esc) ;                                                                                                                                                                                                                                                                        : clear scr_size for space next home ;                          : (fg) $fffff0ff swap 8 << setAttr ;                            : (bg) $ffff0fff swap 12 << setAttr ;                           : black 0 (fg) ;   : blue 1 (fg) ;   : green $B (fg) ;          : cyan 3 (fg) ;    : red 5 (fg) ;                               : brown 6 (fg) ;   : white 4 (fg) ;  : yellow $E (fg) ;         : brightWhite 15 (fg) ;                                         n e                                                             : onBlack 0 (bg) ;   : onBlue 1 (bg) ;   : onGreen $B (bg) ;    : onCyan 3 (bg) ;    : onRed 5 (bg) ;                           : onBrown 6 (bg) ;   : onWhite 4 (bg) ;  : onYellow $E (bg) ;   : onBrightWhite 15 (bg) ;                                       : normal white onBlack clear ;                                                                                                                                                                                                                                  : clear scr_size for space next home ;                          : (fg) $fffff0ff swap 8 << setAttr ;                            : (bg) $ffff0fff swap 12 << setAttr ;                           : black 0 (fg) ;   : blue 1 (fg) ;   : green 2 (fg) ;           : cyan 3 (fg) ;    : red 4 (fg) ;    : magenta 5 (fg) ;         : brown 6 (fg) ;   : white 7 (fg) ;  : yellow 14 (fg) ;         : brightWhite 15 (fg) ;                                         n e                                                             : onBlack 0 (bg) ;   : onBlue 1 (bg) ;   : onGreen 2 (bg) ;     : onCyan 3 (bg) ;    : onRed 4 (bg) ;    : onMagenta 5 (bg) ;   : onBrown 6 (bg) ;   : onWhite 7 (bg) ;  : onYellow 14 (bg) ;   : onBrightWhite 15 (bg) ;                                       : normal white onBlack clear ;                                                                                                                                                                                                                                  loc:                                                              from kernel32.dll                                               2 import SetConsoleCursorPosition                               2 import SetConsoleTextAttribute                                2 import GetConsoleScreenBufferInfo                             1 import GetStdHandle                                           -11 GetStdHandle : h literal ;                                n e                                                               : attr@ h here GetConsoleScreenBufferInfo drop here 8 + w@ ;    : attr! h swap SetConsoleTextAttribute    drop ;                : home  h 0    SetConsoleCursorPosition   drop ;                ' home  ' attr@  ' attr!                                      ;loc  alias attr!  alias attr@  alias home                                                                                                                                                      n e                                                             : clear home 80 30 * for space next home ;                      : (fg) attr@ $fffffff0 and + attr! ;                            : (bg) attr@ $ffffff0f and + attr! ;                            : bold attr@ 8 or attr! ;                                       : black 0 (fg) ;   : blue 1 (fg)  ;  : green 2 (fg) ;           : cyan 3 (fg) ;    : red 4 (fg) ;    : magenta 5 (fg) ;         : yellow 6 (fg) ;  : white 7 (fg) ;                             n e                                                             : onBlack 0 (bg) ;    : onBlue $10 (bg)  ;  : onGreen $20 (bg) ;: onCyan $30 (bg) ;   : onRed $40 (bg) ;  : onMagenta $50 (bg) ;: onYellow $60 (bg) ; : onWhite $70 (bg) ;                      : normal white onBlack clear ;                                                                                                                                                                                                                                                                                                  