-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterm.c
More file actions
45 lines (38 loc) · 667 Bytes
/
term.c
File metadata and controls
45 lines (38 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Tony Givargis
* Copyright (C), 2023
* University of California, Irvine
*
* CS 238P - Operating Systems
* term.c
*/
#include "system.h"
#include "term.h"
static int nocolor;
void
term_init(int nocolor_) {
nocolor = nocolor_ ? 1 : 0;
}
void
term_color(enum term_color color) {
assert((0 <= color) && (7 >= color));
if (!nocolor) {
printf("\033[%dm", 30 + color);
fflush(stdout);
}
}
void
term_bold(void) {
if (!nocolor) {
printf("\033[1m");
fflush(stdout);
}
}
void
term_reset(void) {
if (!nocolor) {
printf("\033[?25h");
printf("\033[0m");
fflush(stdout);
}
}