-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.h
More file actions
89 lines (72 loc) · 2.7 KB
/
Copy pathheader.h
File metadata and controls
89 lines (72 loc) · 2.7 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
86
87
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <time.h>
#include <stdbool.h>
#include <ctype.h>
//colors
#define BLU "\x1b[38;2;122;162;247m"
#define GREN "\x1b[38;2;158;206;106m"
#define RD "\x1b[38;2;247;118;142m"
#define YLOW "\x1b[38;2;224;175;104m"
#define CYN "\x1b[38;2;125;207;255m"
#define RST "\x1b[0m"
#define GRY "\x1b[38;2;65;72;104m"
#define ORNGE "\x1b[38;2;255;158;100m"
#define WHT "\x1b[38;2;192;202;245m"
#define __INIT_STRING ""
#define sprtr " "
#define capcity 1024 //no of lines stored at a time
int size_BUFER=0;
char** Terminal_Buffer=NULL;
//relative path of directory wrt the starting location
char* RELP_DIR=NULL;
//OLD DIR
char* OLD_DIR=NULL;
char* STARTING_DIR =NULL;
//logo
char LINUX[] =
" " GRY "#####" RST "\n"
" " GRY "#######" RST "\n"
" " GRY "##" WHT "O" GRY "#" WHT "O" GRY "##" RST "\n"
" " GRY "#" ORNGE "#####" GRY "#" RST "\n"
" " GRY "###########" RST "\n"
" " GRY "#############" RST "\n"
" " GRY "###############" RST "\n"
" " GRY "################" RST "\n"
" " ORNGE "##" GRY "############" ORNGE "#" RST "\n"
ORNGE "######" GRY "########" ORNGE "######" RST "\n"
ORNGE "#######" GRY "######" ORNGE "#######" RST "\n"
" " ORNGE "#####" GRY "######" ORNGE "#####" RST "\n";
//contents of help function
char docstrin[]=
"--------------------------------------------------------------\n"
" COMMAND DESCRIPTION\n"
"--------------------------------------------------------------\n"
" help Displays this manual.\n"
" cd [dir] Change directory (~: home, -: back, /: absolute).\n"
" ls [dir] List files in the current or specified directory.\n"
" pwd Print the current working directory.\n"
" echo [str] Print a string to the standard output.\n"
" cat [file] Concatenate and print file content (text only).\n"
" touch [file] Create a new empty file or update timestamps.\n"
" clear Clear the terminal screen.\n"
" exit [code] Exit the shell with an optional status code.\n"
"--------------------------------------------------------------\n"
"Tip: The prompt turns RED if the last command failed.\n\n";
void init_buffer();
//helper function to parse command into arguments
char** split(char* line);
//helper function to store command into a screen buffer
bool parse(void);
//helper function to take input of dynamic size and stop at \n or ctrl-D
bool input(void);
//main command execution
bool run(char** args);
//CD implementation handling cd -, cd ~, cd relpath and cd abspath by using string manipulation
bool cd(char* args);
//defining exit behaviour
void term(void);