|
2 | 2 | <img src=".\media\kolor_3.png" alt="banner">
|
3 | 3 | </p>
|
4 | 4 |
|
5 |
| -<h3 align="center">Pretty terminal output using ANSI escape codes</h3> |
| 5 | +<h3 align="center">Pretty terminal output using ANSI escape sequences</h3> |
6 | 6 |
|
7 | 7 | [How it works](https://en.wikipedia.org/wiki/ANSI_escape_code)
|
8 | 8 |
|
|
14 | 14 |
|
15 | 15 | int main() {
|
16 | 16 |
|
17 |
| - // set colors using constants |
18 |
| - std::cout << kolor::ESCAPE << kolor::FOREGROUND << kolor::format_rgb(200, 20, 50) << kolor::M << "Change colors using constants\n" << kolor::RESET; |
| 17 | + /** |
| 18 | + * This is an example on how to use kolor. |
| 19 | + * There are four different methods of changing the appearance of terminal output. |
| 20 | + * 1. Inline constants |
| 21 | + * 2. Inline set functions |
| 22 | + * 3. Wrapper functions |
| 23 | + * 4. Direct print functions |
| 24 | + */ |
19 | 25 |
|
20 |
| - // set colors using inline set functions |
21 |
| - std::cout << kolor::set_fg(100, 23, 66) << "Change color using inline set functions\n" << kolor::RESET; |
| 26 | + // Option 1: Change appearance using inline constants |
| 27 | + // 1.1 Turn text bold using the most verbose constants |
| 28 | + std::cout << kolor::ESCAPE << kolor::BOLD << kolor::M << "This text was made bold using inline constants.\n" << kolor::ESCAPE << kolor::RESET << kolor::M; |
22 | 29 |
|
23 |
| - // use print_bg function to change the background |
24 |
| - kolor::print_bg("Change background using print_bg\n", 23, 123, 90); |
| 30 | + // 1.2 Turn text bold using already escaped constants |
| 31 | + std::cout << kolor::BOLD_E << "This text was also made bold but with less code.\n" << kolor::RESET_E; |
25 | 32 |
|
26 |
| - // use print_fg function to change the foreground |
27 |
| - kolor::print_fg("Change foreground using print_fg\n", 23, 123, 90); |
| 33 | + // Options 2: Change appearance using set functions |
| 34 | + // 2.1 Turn text italic using the set_italic and set_reset |
| 35 | + std::cout << kolor::set_italic() << "This text is italic.\n" << kolor::set_reset(); |
28 | 36 |
|
29 |
| - // use print function to change background and foreground of an output |
30 |
| - kolor::print("use print function to change background and foreground", 144, 252, 3, 3, 140, 252); |
| 37 | + // 2.2 Turn text green using set_fg_rgb and set_reset |
| 38 | + std::cout << kolor::set_fg_rgb(0,255,0) << "This text was made green using rgb values.\n" << kolor::set_reset(); |
31 | 39 |
|
32 |
| - // reset everything |
33 |
| - std::cout << kolor::RESET; |
| 40 | + // Option 3: Change appearance using wrapper functions |
| 41 | + // wip |
34 | 42 |
|
| 43 | + // Option 4: Directly print text using print functions |
| 44 | + // 4.1 Print underlined text using print_underline |
| 45 | + kolor::print_underline("This text is underlined.\n"); |
| 46 | + |
| 47 | + // 4.2 Print red text using print_fg_rgb |
| 48 | + kolor::print_fg_rgb("This text is red.\n", 255, 0, 0); |
| 49 | + |
| 50 | + // 4.3 Print text with blue background using print_bg_rgb |
| 51 | + kolor::print_bg_rgb("This text has a blue background.\n", 0, 0, 255); |
35 | 52 | return 0;
|
36 | 53 | }
|
| 54 | + |
37 | 55 | ```
|
38 | 56 |
|
39 | 57 | ### Output
|
|
0 commit comments