-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtui-clock.cpp
More file actions
54 lines (33 loc) · 1.13 KB
/
Copy pathtui-clock.cpp
File metadata and controls
54 lines (33 loc) · 1.13 KB
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
46
47
48
49
50
51
52
53
54
// DATE: 08.06.2023
#include "tui-clock-render.cpp"
char keys;
TERM_CENTER center;
TIME current_time;
Render tui_clock;
int main()
{
if (!tui_clock.is_enough_space()){
tui_clock.set_exit_message(NO_SPACE);
return EXIT_FAILURE;
}
tui_clock.get_keys_press(&keys);
tui_clock.get_term_center(¢er);
tui_clock.get_time(¤t_time);
tui_clock.display_clock(¢er, ¤t_time);
while (true)
{
if (keys == 'q') { return EXIT_SUCCESS; }
tui_clock.get_keys_press(&keys, 10);
tui_clock.update_sec(¢er, ¤t_time);
tui_clock.get_time(¤t_time);
if ( current_time.tm_sec == 0 ) { tui_clock.display_clock(¢er, ¤t_time); }
if (tui_clock.is_term_size_changed()) {
if (!tui_clock.is_enough_space()) { tui_clock.set_exit_message(NO_SPACE); return EXIT_FAILURE; }
tui_clock.clear_screen();
tui_clock.get_term_center(¢er);
tui_clock.display_clock(¢er, ¤t_time);
}
usleep(1000*1000/FRAME_RATE);
}
return EXIT_SUCCESS;
}