Created
August 29, 2017 21:52
-
-
Save ben-albrecht/d876460d8dacdaa16e3d336036d80022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Printing pretty colors in Chapel */ | |
module Colors { | |
// C color codes | |
param RESET = "\x1B[0m", | |
BOLD = "\x1B[1m", | |
UNDERLINE = "\x1B[4m", | |
GRN = "\x1B[32m", | |
YEL = "\x1B[33m", | |
BLU = "\x1B[34m", | |
MAG = "\x1B[35m", | |
CYN = "\x1B[36m", | |
WHT = "\x1B[37m"; | |
// Color functions | |
proc red(str: string) return RED + str + RESET; | |
proc green(str: string) return GRN + str + RESET; | |
proc yellow(str: string) return YEL + str + RESET; | |
proc blue(str: string) return BLU + str + RESET; | |
proc magenta(str: string) return MAG + str + RESET; | |
proc cyan(str: string) return CYN + str + RESET; | |
proc white(str: string) return WHT + str + RESET; | |
/* Demo of Colors module */ | |
proc main() { | |
writeln(red('Hel'), green('lo'), ' ', yellow('Wo'), blue('rld'), magenta('!')); | |
writeln(red('this text is red')); | |
writeln(green('this text is green')); | |
writeln('...'); | |
writeln(BOLD, 'BOLD!', RESET); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment