-
Notifications
You must be signed in to change notification settings - Fork 0
/
customheader.h
75 lines (69 loc) · 1.78 KB
/
customheader.h
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
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h>
#include <unistd.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
#include <grp.h>
#include <dirent.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <signal.h>
using namespace std;
unsigned int xcor = 1, ycor = 1;
#define esc 27
#define cls printf("%c[2J", esc)
#define cursor printf("\033[%d;%df",xcor,ycor)
#define setcout(cx,cy) printf("\033[%d;%df",cx,cy)
#define clr_line printf("%c[2K", esc)
vector<string> cur_files;
struct termios initsetg, newsetg;
struct stat f_stat;
int to, from;
bool cmd_mode = false;
struct winsize terminal;
unsigned int term_row, scr_rows;
unsigned int term_col, scr_cols;
int cur_window = 0;
string cur_dir;
string app_home;
stack<string> forward_stack;
stack<string> back_stack;
vector<dirent> cur_dirs;
void list_files();
void update_list();
void travel();
void set_termios();
void command_mode();
void execute_cmd(string);
string cmd_delete_dir(string);
string cmd_delete_file(vector<string>);
string cmd_create_file(vector<string>);
string cmd_create_dir(vector<string>);
string cmd_rename(vector<string>);
string cmd_copy(vector<string>);
string cmd_copy_dir(string,string);
string cmd_move(vector<string>);
string cmd_search(vector<string>);
string cmd_search_dir(string,string);
void cmd_goto(vector<string>);
void winsz_handler(int);
string trimpath(string fp) {
if(fp=="")
return "";
if(fp[fp.length()-1]=='/')
fp = fp.substr(0,fp.length()-1);
string fpath;
if(fp[0]=='/')
fpath = fp.substr(1,fp.length()-1);
else if(fp[1]=='/' && (fp[0]=='.' || fp[0]=='~'))
fpath = fp.substr(2,fp.length()-2);
else if(fp=="." || fp=="~")
fpath = "";
else
fpath = fp;
return fpath;
}