-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
34 lines (26 loc) · 979 Bytes
/
main.cpp
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
#include "todoFn.h"
using namespace todo;
int main(int argc, char const *argv[]) {
// Store tasks from file in array
std::fstream fr = open_file();
vstr tasks = copy_tasks(fr);
// Start interactive loop
DisplayMode d = { .disp_sec = false, .section = "general" }; // Display-status variable (show default / section tasks)
vstr history;
std::string input;
while (true) {
if (d.disp_sec == true) display_section(d.section, tasks); // Display section tasks
else display_main(tasks); // Display current tasks (default)
prompt(); // Display prompt for user input
input = get_input(); // Store user input
// Input analysis
if (input.compare("exit") == 0) {
clear(); // Clear terminal screen
break; // Exit loop
}
handle_input(input, tasks, history, d); // Parse command from user
}
// Save edited tasks to file
save_file(tasks);
return 0;
}