Modules

Print_Color

moduleSource
macOSLinuxWindowswasm

#import "Print_Color";

Procedures#

(to_standard_error := false) -> s64

How many colors are active on a standard stream (pushed and not yet popped).

(current: u16, color: Console_Color, style: Console_Style = .NORMAL) -> u16

The attribute word that shows color and style on top of current. A foreground color replaces only the foreground and a background color only the background, so a block colored on its text keeps the enclosing block's background. BOLD brightens the foreground; UNDERLINE underlines; NORMAL removes an enclosing underline.

(color: Console_Color, style: Console_Style = .NORMAL, to_standard_error := false)

Show color on a standard stream, remembering what was there. Every push needs a pop; the colors nest and each pop restores the enclosing one. A stream that is not a console is not touched, but the push still counts so the pops stay balanced.

(to_standard_error := false)

Undo the latest push on a standard stream. The outermost pop returns to the attributes the stream had before that push when SAVE_RESTORE_ON_WINDOWS is set, and otherwise to the ones it had before the first color was ever pushed. A pop without a push does the latter.

Types#

:: struct

The console's side of the native engine: read the attribute word of a standard stream and replace it. is_console is false for a stream that is redirected to a file or pipe (or closed), which the engine then leaves alone entirely. Windows installs the real console API; tests (and other platforms) install their own.

Constants#