Unit Command.Colors
Uses
Classes, Interfaces, Objects and Records
Types
Description
This unit allows using colors when generating the application's output. It has configuration of Dark, Light and standard color themes. Check the CommandBuilder.OutputColor method that allows writing text using a certain color.
To use it, just add it to the program's uses clause, choose a theme from LightColorTheme or DarkColorTheme, you can also define your own theme using the record TColorTheme and assigning it to the TCommandBuilder.ColorTheme. See the example:
Application.CommandBuilder.ColorTheme := DarkColorTheme;
Application.CommandBuilder.OutputColor('Hello world', Application.CommandBuilder.Title);
See TCommandBuilder.OutputColor on how to use it. Color constants can be used directly as parameters for functions, in the example above we only used the theme for convention purposes. Library commands like UsageCommand, VersionCommand are directly affected by the chosen theme.
- Note
- This unit has an intilization section that tries to figure out the console color before any color change. This color will be restored before application terminates via the code in finalzation section.
Overview
Functions and Procedures
Constants
Variables
Description
Functions and Procedures
procedure ChangeConsoleColor(const AColor: Integer); |
Changes default console color for text output.
Ex: change text output color to LightGreen color constant:
ChangeConsoleColor(LightGreen) ;
|
procedure OutputPalleteColor(ABuilder: ICommandBuilder); |
This command outputs text for each color represented by the constant colors in this unit. You may add this command to the application using TCommandBuilder.AddCommand, so you can check how a given color is displayed on console. There is sample app called colors on the source code repository that shows how this command works.
|
Constants
Variables
StartupColor: byte; |
Contains the initial color detected by the application before any color change.
|
StartColorTheme: TColorTheme; |
Initial color themes available from the library. Can be assigned to CommandBuilder's ColorTheme property.
|
LightColorTheme: TColorTheme; |
Suggested light color theme. Good to use with a console that has a white background. Can be assigned to CommandBuilder's ColorTheme property.
|
DarkColorTheme: TColorTheme; |
Suggested dark color theme. Good to use with a console that has a dark background. Can be assigned to CommandBuilder's ColorTheme property.
|
Generated by PasDoc 0.16.0.