From 6bc343bd07ddbffd5e4880e6e9c0af374d98b5c5 Mon Sep 17 00:00:00 2001 From: "Rustem Gimadutdinov (rgimad)" Date: Tue, 14 Apr 2020 14:46:35 +0000 Subject: [PATCH] SHELL 0.7.8 changelog - fixed bug with ctrl+v - added navigation in current string by Home, End - directory highlighting in ls command output git-svn-id: svn://kolibrios.org@7787 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/system/shell/cmd/cmd_ls.c | 7 +- programs/system/shell/globals.h | 2 +- .../system/shell/modules/module_command.c | 68 ++++++++++++------- 3 files changed, 51 insertions(+), 26 deletions(-) diff --git a/programs/system/shell/cmd/cmd_ls.c b/programs/system/shell/cmd/cmd_ls.c index 741251474d..ae4caecd2c 100644 --- a/programs/system/shell/cmd/cmd_ls.c +++ b/programs/system/shell/cmd/cmd_ls.c @@ -93,10 +93,13 @@ else t = (unsigned*) (k70.p16+32+(304)*i); type_of_file = *t; + + int is_folder = 0; + if ( (0x10 == (type_of_file&0x10)) || (8 == (type_of_file&8)) ) { is_folder = 1; strcat(cur_file, "/"); } - if ( (0x10 == (type_of_file&0x10)) || (8 == (type_of_file&8)) ) strcat(cur_file, "/"); - + if (is_folder) { printf("\033[0;36m"); } // set cyan for folder printf ("%*s", -longest_name_len, cur_file); + if (is_folder) { printf("\033[0m"); } // is had been set, reset if ((i>0) && ((i+1)%columns_max == 0)) printf ("\n\r"); } diff --git a/programs/system/shell/globals.h b/programs/system/shell/globals.h index 9dd6caf9bb..87e99d3adf 100644 --- a/programs/system/shell/globals.h +++ b/programs/system/shell/globals.h @@ -1,5 +1,5 @@ -#define SHELL_VERSION "0.7.7" +#define SHELL_VERSION "0.7.8" extern char PATH[256]; extern char PARAM[256]; diff --git a/programs/system/shell/modules/module_command.c b/programs/system/shell/modules/module_command.c index 66e44b0da2..4fcf81a112 100644 --- a/programs/system/shell/modules/module_command.c +++ b/programs/system/shell/modules/module_command.c @@ -23,8 +23,30 @@ if (CMD_HISTORY_NUM_REAL < CMD_HISTORY_NUM-1) CMD_HISTORY_NUM_REAL++; } +// ============================================================ +char * insert_string( char s1[], unsigned int pos, const char s2[] ) +{ + unsigned int n1 = strlen( s1 ); + unsigned int n2 = strlen( s2 ); + if ( n1 < pos ) pos = n1; + + unsigned int i; + for ( i = 0; i < n1 - pos; i++ ) + { + s1[n1 + n2 - i - 1] = s1[n1 - i - 1]; + } + + for ( i = 0; i < n2; i++) + { + s1[pos+i] = s2[i]; + } + + s1[n1 + n2] = '\0'; + + return s1; +} /// =========================================================== @@ -102,30 +124,19 @@ for (;;) { if ((int)*(clipBuf+8)==1) // 866 encoding? { - for (i = cmdPos; i < cmdLen; i++) - printf(" "); - for (i = cmdLen; i > 0; i--) - printf("%c %c", 8, 8); - cmdLen = 0; - cmdPos = 0; - CMD[0] = '\0'; - - // strcpy_n - for (i = 0; i < 255; i++) - { - CMD[i]=*(clipBuf+12+i); - if (CMD[i]=='\0') - break; - } - - cmdPos = cmdLen = strlen(CMD); -/* - printf("Length: %d\n", cmdLen); - for (i = 0; i < cmdLen; i++) - printf("%d ", CMD[i]); -*/ - printf("%s", CMD); + // clear previous text + for (i = cmdPos; i < cmdLen; i++) + printf(" "); + for (i = cmdLen; i > 0; i--) + printf("%c %c", 8, 8); + char *pasteText = clipBuf + 12; + int pasteLen = strlen(pasteText); + insert_string(CMD, cmdPos, pasteText); + cmdLen = strlen(CMD); + cmdPos += pasteLen; + printf("%s", CMD); + for (i = 0; i < cmdLen-cmdPos; i++) printf("%c", 8); // rewind the internal console cursor } } } @@ -206,6 +217,17 @@ for (;;) } break; + + case 0x47: // Home + // move internal cursor and cmdPos to the beginning of the line + for (;cmdPos > 0; cmdPos--) {printf("%c", 8);} + break; + + case 0x4F: // End + // move internal cursor and cmdPos to the end of the line + for (;cmdPos < cmdLen; cmdPos++) {printf("%c", CMD[cmdPos]);} + break; + case 75: // Left if (cmdPos > 0) {