-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
129 lines (110 loc) · 2.35 KB
/
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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "buffer.h"
#include "menu.h"
// TODO: make this into a factory pattern - get rid of if/else
class bufferMenu{
public:
int key;
buffer editor;
menuHeader header;
void handleCallBack(string callBack){
if (callBack == "New"){
;
}
if (callBack == "Open"){
editor.openFile(string("./"));
}
if (callBack == "Save"){
if (editor.CurrentFileName != " ")
editor.writeFile(editor.CurrentFileName);
else
// prompt for filename
;
}
if (callBack == "Save As"){
// open new window to prompt for fileName
;
}
if (callBack == "List All Buffers"){
;
}
if (callBack == "Cut"){
;
}
if (callBack == "Copy"){
;
}
if (callBack == "Paste"){
;
}
if (callBack == "Select All"){
;
}
if (callBack == "Find"){
;
}
if (callBack == "Preferences"){
;
}
if (callBack == "Next Buffer"){
;
}
if (callBack == "Prev Buffer"){
;
}
if (callBack == "Life"){
// system("./gameOfLife");
}
if (callBack == "Pong"){
;
}
if (callBack == "Space Invaders"){
;
}
}
void getUserInput(){
while (1)
{
key = getch();
//string callBack;
int ty,tx;
getyx(editor.bufSubWin,ty,tx);
header.drawMenuBar();
wmove(editor.bufSubWin,ty,tx);
//werase(nmacs.header.messagebar);
//wrefresh(nmacs.header.messagebar);
if (key==KEY_F(1)) { handleCallBack( header.handleSubMenu(0) ); }
else if (key==KEY_F(2)) { handleCallBack( header.handleSubMenu(1) ); }
else if (key==KEY_F(3)) { handleCallBack( header.handleSubMenu(2) ); }
else if (key==KEY_F(4)) { handleCallBack( header.handleSubMenu(3) ); }
else { editor.getUserInput(key); }
//
curs_set(2);
}
}
}; // end bufferMenu class
int main()
{
initscr();
cbreak();
curs_set(2);
noecho();
// this section is iffy
start_color();
init_pair(1,COLOR_GREEN,COLOR_BLACK);
init_pair(2,COLOR_BLACK,COLOR_GREEN);
init_pair(3,COLOR_BLUE,COLOR_GREEN);
keypad(stdscr,true);
bufferMenu nmacs;
//menuHeader nmacs;
int key = 0;
nmacs.editor.init();
nmacs.editor.update();
nmacs.editor.mode = "file";
string filename = string("Makefile");
nmacs.editor.openFile(filename);
nmacs.header.drawMenuBar();
nmacs.getUserInput();
// getch();
endwin();
return 0;
}