-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext_editor.cpp
More file actions
85 lines (70 loc) · 1.74 KB
/
text_editor.cpp
File metadata and controls
85 lines (70 loc) · 1.74 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
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
// - - - - - - - - - - - - - - - - - - - -
// Name : Jeremy Choo, Siyuan Liu
// ID : 1602380, 1589879
// CMPUT 275, Winter 2019
//
// project: Text Editor
// - - - - - - - - - - - - - - - - - - - -
#include <iostream>
#include <string>
#include <fstream>
#include <unordered_set>
#include <ncurses.h>
#include <vector>
#include <locale> // std::isalnum std::locale std::tolower
#include "Editor.h"
using namespace std;
#define RED 1
#define GREEN 2
#define BLUE 3
void setup() {
/*
Set up for everything about the tools needed for output and color attribute.
*/
// ncurses start
initscr();
noecho();
cbreak();
if (!has_colors()) {
printw("This terminal does not support color");
getch();
return;
}
//start_ncurses(true, true);
use_default_colors();
start_color();
init_pair(GREEN, COLOR_GREEN, -1);
attron(COLOR_PAIR(2));
init_pair(RED, COLOR_RED, -1);
init_pair(BLUE, COLOR_BLUE, -1);
}
int main() {
/*
This is the main function of the program.
*/
setup();
// get screen size
int xMax, yMax;
getmaxyx(stdscr, yMax, xMax);
//program start message
WINDOW * startWindow = newwin(4, 30, yMax / 4, xMax / 4);
box(startWindow, 0, 0);
refresh();
mvwprintw(startWindow, 1, 1, "Program Start...\n press any key to continue");
wrefresh(startWindow);
getch();
clear();
// create a window for output
WINDOW * outputBox = newwin(yMax, xMax, 0, 0);
// prpgram start
Text_Editor Editor;
while (true) {
int c = getch();
// process input every time the user input
Editor.process_input(outputBox, c);
}
getch();
attroff(COLOR_PAIR(2));
endwin();
return 0;
}