2 (defun output-handle ()
3 (sb-win32::get-std-handle-or-null
4 sb-win32
::+std-output-handle
+))
6 (sb-alien:define-alien-type nil
7 (sb-alien:struct console-screen-buffer-info
9 (cursor-position sb-alien
:int
)
10 (attributes sb-alien
:int
)
11 (window sb-win32
:dword
)
12 (maximum-window-size sb-alien
:int
)))
14 (sb-alien:define-alien-routine
15 ("SetConsoleTextAttribute" set-console-text-attribute
)
17 (console sb-win32
:handle
)
18 (attributes sb-alien
:int
))
20 (sb-alien:define-alien-routine
21 ("GetConsoleScreenBufferInfo" get-console-screen-buffer-info
)
23 (console-output sb-win32
:handle
)
24 (info (* (sb-alien:struct console-screen-buffer-info
))))
26 (defun get-attributes ()
27 (sb-alien:with-alien
((info (sb-alien:struct console-screen-buffer-info
)))
28 (get-console-screen-buffer-info (output-handle)
30 (sb-alien:slot info
'attributes
)))
32 (defun console-color (color)
37 (defun set-color (color)
38 (set-console-text-attribute (output-handle) color
))
40 (defun %output-colored-text
(text color
&key bold
)
41 (declare (ignore bold
))
42 (let ((current-attributes (get-attributes)))
44 (progn (set-color (console-color color
))
47 (set-color current-attributes
))))