-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
69 lines (55 loc) · 1.38 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
#include <iostream>
#include <ncurses.h>
#include "Print.h"
#include "Editor.h"
Editor *editor;
// Initializes the curses.h
void curses_init()
{
initscr();
raw();
nonl();
set_escdelay(50);
keypad(stdscr, true);
if(has_colors()) {
start_color();
use_default_colors();
}
//BUTTON2_PRESSED | BUTTON3_PRESSED
mousemask(ALL_MOUSE_EVENTS, nullptr);
init_pair(1, COLOR_WHITE, COLOR_BLUE); // command bar colors
init_color(COLOR_YELLOW, 580, 500, 450);
init_pair(2, COLOR_YELLOW, -1); // line number colors
init_color(COLOR_RED, 1000, 700, 0);
init_color(COLOR_MAGENTA, 300, 210, 0);
init_pair(3, COLOR_RED, COLOR_MAGENTA); // line number colors
}
int main(int argc, char* argv[]) {
std::string filename;
if(argc != 2) {
return 1;
} else {
filename = std::string(argv[1]);
}
editor = new Editor(filename);
if(!editor->isOpen()) {
println("File can't be opened\n");
return 1;
}
curses_init();
editor->printStatusLine();
editor->printView();
editor->setCaret();
while(editor->isOpen()) {
editor->eatInput(getch());
editor->updateSelection();
editor->setScroll();
editor->printStatusLine();
editor->printView();
editor->setCaret();
}
free(editor);
refresh();
endwin();
return 0;
}