Skip to content

kslng/ksl-colors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

KSL Colors Library

A simple console colors library for KSL, supported by the official KSL team.

Using

The KSL colors library comes with a bunch of default colors to pick from. The full list of colors is listed below. The library uses the colors namespace.

colors.red; // set foreground terminal color to red
colors.bright_red; // set foreground terminal color to bright red

colors.yellow; // set foreground terminal color to yellow
colors.bright_yellow; // set foreground terminal color to bright yellow

colors.green; // set foreground terminal color to green
colors.bright_green; // set foreground terminal color to bright green

colors.cyan; // set foreground terminal color to cyan
colors.bright_cyan; // set foreground terminal color to bright cyan

colors.reset; // resets terminal to default scheme

Note

More colors are likely to be added in the future. This library mainly supports the KSL compiler, so when the compiler needs new colors they'll be added here.

Examples

Below are a collection of examples, keep in mind that the terminal color will stay until explicitly reset, which is why most of these examples end with the reset string.

Show a debug message (where [DEBUG] is yellow):

io.writeln("{str}[DEBUG] {str}{str}".format(
	colors.yellow,
	colors.reset,
	"My debug message"
));

Show a completely cyan message:

io.writeln("{str}Hello World, but in Cyan!!{str}".format(
	colors.cyan,
	colors.reset
));

Change the terminal foreground color to green (and don't reset it):

io.writeln("{str}".format(colors.green));

Notes

The colors library should work on all platforms. Since command prompt on Windows doesn't support virtual terminal processing by default, the colors.init() function contains code that will enable it. Make sure you use this if you plan on using terminal colors on Windows (but it's probably best practice to always call it, just in case.)

Legal

KSL colors is copyright © of kgsensei and the KSL team.

About

A simple console colors library for KSL, supported by the official KSL team.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages