diff --git a/README.md b/README.md index 08cad21..0edebca 100644 --- a/README.md +++ b/README.md @@ -39,14 +39,14 @@ make run ```sh make run -# or - -make traces +# or (for strace) +make trace ``` + As of right now there are only 7 hardcoded replacements (for color) in the src/main.c file. These are actually regex patterns. ```c -// all are temporary +// OUT OF DATE. IM LAZY AND DIDNT UPDATE THEM YET "^d" //-> Magenta "r--" //-> Green "rw-" //-> Red @@ -68,7 +68,7 @@ If you need to use these kinds of applications, do not use this program to wrap -## Installation +## "Installation" Normal build: `make` diff --git a/include/config.h b/include/config.h index b1dcc4e..3477846 100644 --- a/include/config.h +++ b/include/config.h @@ -6,12 +6,12 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_HOTFIX 0 -#define VERSION_BUILD 354 +#define VERSION_BUILD 368 //#define DEFAULT_CMD "/bin/sh" #define CONF_DO_CMD_ACK 1 -#define DEBG_DO_EOL_MARK 1 +#define DEBG_DO_EOL_MARK 0 //EOLMARK defined in parsebuffer() @@ -35,6 +35,6 @@ //child stdout read buffer size #define BUFCHUNKSIZE 4096 #define BUFSAFEPAD 8 //shut it, ik its useless - +#define REG_NOFLAG 0 #endif \ No newline at end of file diff --git a/src/main.c b/src/main.c index 8dc070b..e0750bc 100644 --- a/src/main.c +++ b/src/main.c @@ -9,12 +9,11 @@ #include #include #include -//#include -//regex branch init +//#include /* who needs history anyway */ #include -// Custom debug include for some debug macros and functions +// custom headers #include #include #include @@ -22,44 +21,67 @@ #include #include -//temporary +//NOTE: temporarly in here for config, but probably will create a seperate file that loads the rules down the line + +/* +Rule Writiting Help: + Available Color Codes: KRED KGRN KYEL KBLU KMAG KCYN KWHT + KNRM to reset to default + If you want a smattering of the colors, `make debug` and `make run` + + Available Regex Flags: REG_NOFLAG REG_EXTENDED, REG_ICASE + REPLACE_GROUP selects the submatch of the regex to replace; + if your regex looks like this: /(matchme)otherstuff$/ ,you probably want to change it from 0 + + For now, there is no implementation for non static regex replacing. ex: x2tx ~ /x([02])tx/1/--$1-/ => x--2-tx + there is the function for it (line_regex_wrap_match), its just not used. its coming later + + Gotta be careful right now because earlier replaces also effect later ones (see processline()); + also these rules get applied to EVERY line +*/ + + +/*== USER CHANGE CONFIG ==*/ ct_match replace_rules[]= { - //gotta be careful right now because earlier replaces also effect later ones - { "alpine", 0, 0, KMAG"alpine"KNRM }, - { "r--", 0, 0, KGRN"r--"KNRM }, - { "rw-", 0, 0, KRED"rw-"KNRM }, - { " \\.\\.$", 0, 0, KBLU" .."KNRM }, - { " \\.$", 0, 0, KBLU" ."KNRM }, - { "^d", 0, 0, KMAG"d"KNRM }, - { "z9Da0Da1", 0, 0, KRED"z9Da0Da1"KNRM }, + /* {REGEX_PATTERN, REG_FLAGS, REPLACE_GROUP, REPLACE_WITH} */ + { "(alpine)[[:blank:]01]", REG_EXTENDED, 1, KMAG"alpine"KNRM }, /* matches alpine alpine0 alpine1 and only colorizes "alpine" */ + { "r--", REG_NOFLAG, 0, KGRN"r--"KNRM }, + { "rw-", REG_NOFLAG, 0, KRED"rw-"KNRM }, + { "^d[r\\-].* (\\.\\.)$", REG_EXTENDED, 1, KGRN".."KNRM }, + { "^d[r\\-].* (\\.)$", REG_EXTENDED, 1, KGRN"."KNRM }, + { "^d[r\\-].* ().*?$", REG_EXTENDED, 1, KBLU }, /* color directories blue; this one is such a hack omg just implement the function you keep talking about */ + { "z9Da0Da1", REG_NOFLAG, 0, KRED"(SUS STRING)z9Da0Da1"KNRM }, /* NOTE: this string is in the testing/long file btw. */ }; char ps1[] = KGRN"~>"KNRM; char ps1_ack[] = KBLU"1~"KNRM; + //CONF_DO_CMD_ACK defined in include/config.h to disable the ack above + //DBUG_DO_EOL_MARK defined in include/config.h if you want & at the end of lines +/*== REST IS CODE ==*/ +/* pls dont break it */ + ct_line processline(ct_line current_line){ int rules_length = (sizeof(replace_rules)/sizeof(replace_rules[0])); + //TODO: implement line_regex_wrap_match as well for easier rule writing for (int i=0; i 0) { parsebuffer(child_out_roll_buffer, read_size, read_loop_no); @@ -123,9 +145,8 @@ void supervise(int master_fd, int child_pid){ write(master_fd, parent_in_buffer, strlen(parent_in_buffer)); write(master_fd, "\n", 1); - usleep(100*1000); + usleep(200*1000); //dirty hack because *some* commands are slow } - free(child_out_roll_buffer); free(parent_in_buffer); } @@ -149,7 +170,6 @@ int main(int argc, char *argv[]) { exit(EX_USAGE); } - int master_fd; pid_t child_pid; //if the pty window size is to be assigned. shoudnt be a concern since only used by tui programs