[RFC] ColorD
Walter Bright
newshound2 at digitalmars.com
Sun Oct 21 15:31:51 PDT 2012
On 10/21/2012 12:28 PM, Robik wrote:
> Simple example:
>
> import std.stdio, colord;
> void main()
> {
> setConsoleColors(Fg.red, Bg.blue);
> writeln("Red text on blue background.");
> resetConsoleColors(); // Bring back initial state
> }
Need a method to get the current state, and reset the current state. Otherwise,
nested calls to the console functions will screw up the state.
I.e.:
auto save = getConsoleState();
setConsoleColors(Fg.red, Bg.blue);
writeln("Red text on blue background.");
setConsoleState(save); // Bring back initial state
Or better:
auto save = getConsoleState();
scope (exit) setConsoleState(save);
setConsoleColors(Fg.red, Bg.blue);
writeln("Red text on blue background.");
More information about the Digitalmars-d
mailing list