X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2FCLIShell_src%2Fmain.c;h=579df881d8636023058b797d18b821d5a283ba93;hb=45f9a29e481ce9ea7ca7121541f0e0f90147f5b1;hp=836c6f50ec718f6ebc5860b7acbdbb19cb676bc4;hpb=95a7eaaa4a1065334125b65130866f8d1048ddb7;p=tpg%2Facess2.git diff --git a/Usermode/Applications/CLIShell_src/main.c b/Usermode/Applications/CLIShell_src/main.c index 836c6f50..579df881 100644 --- a/Usermode/Applications/CLIShell_src/main.c +++ b/Usermode/Applications/CLIShell_src/main.c @@ -1,12 +1,17 @@ /* * AcessOS Shell Version 3 */ +#define USE_READLINE 0 #include #include #include #include #include "header.h" +#if USE_READLINE +# include "readline.h" +#endif + #define _stdin 0 #define _stdout 1 #define _stderr 2 @@ -51,7 +56,15 @@ int main(int argc, char *argv[], char *envp[]) int length = 0; int i; int iArgCount = 0; + #if !USE_READLINE int bCached = 1; + #else + tReadline readline_state = {0}; + #endif + + #if USE_READLINE + readline_state.UseHistory = 1; + #endif gasEnvironment = envp; @@ -74,13 +87,19 @@ int main(int argc, char *argv[], char *envp[]) { // Free last command & arguments if(saArgs[0]) free(saArgs); + #if !USE_READLINE if(!bCached) free(sCommandStr); bCached = 0; + #endif write(_stdout, strlen(gsCurrentDirectory), gsCurrentDirectory); write(_stdout, 2, "$ "); // Read Command line + #if USE_READLINE + sCommandStr = Readline( &readline_state ); + length = strlen(sCommandStr); + #else sCommandStr = ReadCommandLine( &length ); if(!sCommandStr) { @@ -99,6 +118,7 @@ int main(int argc, char *argv[], char *envp[]) gasCommandHistory[ giLastCommand ] = sCommandStr; bCached = 1; } + #endif // Parse Command Line into arguments Parse_Args(sCommandStr, saArgs); @@ -123,6 +143,10 @@ int main(int argc, char *argv[], char *envp[]) // Shall we? CallCommand( &saArgs[1] ); + + #if USE_READLINE + free( sCommandStr ); + #endif } } @@ -135,7 +159,7 @@ char *ReadCommandLine(int *Length) char *ret; int len, pos, space = 1023; char ch; - #if 1 + #if 0 int scrollbackPos = giLastCommand; #endif