-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
109 lines (71 loc) · 1.65 KB
/
main.c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
Main loop with alternatives and
calls for options.c
Will be using a global pointer as root node, so no need to send it to every function
try to make it as a constant if possible. So nothing can change it.
*/
#include <stdio.h>
#include <ctype.h>
#include "main.h"
#include "object.h"
#include "tree.h"
#include "undo.h"
#include "stdscan.c"
#define S_HEIGHT 40
int load_menu();
bool handle_menu_input(char);
void clean_screen();
void print_meny();
int main() {
load_menu();
return 0;
}
// TODO Skapa en UI-modul eller liknande.
int load_menu() {
bool exit = false;
clean_screen();
while(!exit) {
print_meny();
printf("What do you want to do?: ");
char input;
input = ask_for_char("Choice: ", "AaRrEePpUuLlQq");
exit = handle_menu_input(input);
}
printf("Exiting warehouse...");
return 0;
}
bool handle_menu_input(char c) {
switch(tolower(c)) {
case 'a':
case 'r':
case 'e':
case 'i':
case 'w':
case 'u':
printf("Pressed %c.\n", c);
break;
case 'q':
return true;
break;
default:
printf("%c is not implemented yet.\n", c);
break;
}
return false;
}
void print_meny(){
printf("\nWarehouse program 2.0\n"
"===========================================\n"
"[a]dding a ware\n"
"[r]emoving a ware\n"
"[e]diting the information\n"
"[i]nformation about a ware\n"
"[w]ares in the database\n"
"[u]ndoing the last action\n"
"[q]uit\n");
}
void clean_screen() {
int i;
for ( i = 0; i < S_HEIGHT; i++ )
putchar ( '\n' );
}