ziglibs / ansi-term

Zig library for dealing with ANSI terminals
MIT License
68 stars 7 forks source link

Proposal: Add Color.Default #10

Closed joachimschmidt557 closed 4 years ago

joachimschmidt557 commented 4 years ago

Right now, a Style has a foreground color and a background color, which are both of type ?Color. In my view, this is supposed to represent that a style does not have a foreground or background color, but I think it may be useful to think about changing this.

Proposal: A Style should represent a complete style which can be drawn onto an ANSI terminal, meaning it is mandatory to specify foreground and background color for a style. But what if an application using this library wants to specify just bold text? Then it can use Color.Default, a new "pseudo"-color. This also makes everything more explicit and transparent.

Previously, if a Style containing only FontStyle.bold and null for foreground and background was applied to a terminal which already had red background applied to it, applying the new style would have a different effect than if the terminal previously had blue background (red and bold vs blue and bold). With the proposed change, programmers apply a Style and can be 100% sure that this specific style is now active on the terminal.

Example of Color.Default: If the terminal currently has red foreground color and the new Style has Color.Default foreground color, the ANSI Reset CSI is written.