-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
85 lines (74 loc) · 2.87 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
#include "headers.h"
using namespace std;
int main() {
init();
top_bottom_bar(win_row, win_col);
int i;
char arr[100];
for(i=0;home[i]!=0;i++)
arr[i] = home[i];
arr[i]=0;
vector <struct dirent *> dir_list = ls_cmd(arr);
dir_his.push_back(home);
his_itr = dir_his.begin();
bool scroll_bit = false;
int list_size = dir_list.size();
if(list_size>windows_capacity) {
display(dir_list, 0, windows_capacity-1, scroll_bit, "D");
scroll_bit = true;
} else {
display(dir_list, 0, list_size-1, scroll_bit, "D");
}
refresh(dir_list, scroll_bit, list_size);
char key_press;
while(true) {
try {
key_press = check_keypress();
if(!MODE.compare("NORMAL")) {
if(key_press == -10) {
for(int i=2;i<=6;i++)
cout<<"\033["<<cur_row<<";"<<i<<"H"<<" ";
onPressUpN(dir_list, scroll_bit);
} else if(key_press == -11) {
if(list_row<list_size-1) {
for(int i=2;i<=6;i++)
cout<<"\033["<<cur_row<<";"<<i<<"H"<<" ";
onPressDownN(dir_list, scroll_bit, list_size);
}
} else if(key_press == -12) {
onPressRightN(dir_list, scroll_bit, list_size);
} else if(key_press == -13) {
onPressLeftN(dir_list, scroll_bit, list_size);
} else if(key_press == 10) {
onPressEnterN(dir_list, scroll_bit, list_size);
} else if(key_press == 127) {
onPressBackN(dir_list, scroll_bit, list_size);
} else if(key_press == 104) {
onPressHomeN(dir_list, scroll_bit, list_size);
} else if(key_press == 58) {
switch_mode(dir_list, list_size, scroll_bit);
} else if(key_press == 113) {
cout<<CLEAR;
return 0;
}
} else if(!MODE.compare("CMD")) {
if(key_press == 27) {
switch_mode(dir_list, list_size, scroll_bit);
} else if(key_press == 10) {
onPressEnterC(dir_list, scroll_bit, list_size);
} else if(key_press == 127) {
onPressBackC();
} else if(key_press!=-11 && key_press!=-12 && key_press!=-13 && key_press!=-10){
storeCmd(key_press);
}
}
} catch(int e) {
reset(dir_list, scroll_bit, list_size);
string error;
error.append("An unexpected exception has raised, so all buffers are cleaned.");
show_error(error);
cout<<"\033["<<cur_row<<";0H";
}
}
return 0;
}