Timer Console
Loading...
Searching...
No Matches
write.h
Go to the documentation of this file.
1/*
2MIT License
3
4Copyright (c) 2025 Ryan Large
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in all
14copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE.
23*/
24
25#ifndef WRITE_H
26#define WRITE_H
27
28#include <iostream>
29
32*/
33class Write {
34public:
35
40 int height;
41 int width;
42
49 TerminalSize(const int& width, const int& height) : width(width), height(height) {}
50};
51
55enum Colors {
56 YELLOW = 0,
57 RED = 1,
58 BLUE =2,
59 BLACK = 3,
61 CYAN = 5,
62 WHITE = 6,
64};
65
69static TerminalSize myTerminalSize;
70
71Write();
72
77static std::string c(const Colors& color);
78
86static void clearSection(int x, int y, int width, int height);
87
94static void printInSection(int x, int y, std::string text);
95
99static void clearAllConsole();
100
101protected:
102private:
103};
104
105#endif
static void printInSection(int x, int y, std::string text)
printInSection takes a section of the terminal and prints the specified string in the section
Definition write.cpp:61
static std::string c(const Colors &color)
c method returns a color associated with enum
Definition write.cpp:67
static void clearSection(int x, int y, int width, int height)
clearSection erases specified section of the terminal by replacing them with empty strings
Definition write.cpp:48
Colors
Colors integer enum creates an easy interface for defining colors to use in the console when printing...
Definition write.h:55
@ ENDCOLOR
Definition write.h:63
@ RED
Definition write.h:57
@ CYAN
Definition write.h:61
@ WHITE
Definition write.h:62
@ BLACK
Definition write.h:59
@ BLUE
Definition write.h:58
@ YELLOW
Definition write.h:56
@ PURPLE
Definition write.h:60
Write()
Definition write.cpp:37
static void clearAllConsole()
clearAllConsole method clears the entire console erasing all characters on the console screen
Definition write.cpp:106
static TerminalSize myTerminalSize
myTerminalSize is a public variable to use throughout the application to easily query the terminal di...
Definition write.h:32
TerminalSize(const int &width, const int &height)
Constructor takes in width and height and initializes struct.
Definition write.h:49
int height
Definition write.h:40
int width
Definition write.h:41