Shell 0.7.0. Command line editing implemented. + Some small fixes.

git-svn-id: svn://kolibrios.org@4015 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Albom 2013-10-13 10:47:59 +00:00
parent 1de6c3475c
commit f115e0da5a
8 changed files with 137 additions and 54 deletions

View File

@ -1,3 +1,12 @@
Shell 0.7.0 // 13.10.2013 // Albom
* <20>¥à¥à ¡®â ­ ¬®¤ã«ì ¢¢®¤  ª®¬ ­¤ë (¤®¡ ¢«¥­  ®¡à ¡®âª  ª« ¢¨è "¢«¥¢®", "¢¯à ¢®", Del)
* Œ¥«ª¨¥ ¨á¯à ¢«¥­¨ï
Shell 0.6.4 // 09.10.2013 // Leency
* <20>®¤¤¥à¦ª  ®â­®á¨â¥«ì­ëå ¯ã⥩ ¢ áªà¨¯â å
Shell 0.6.3 // 20.09.2013 // Albom Shell 0.6.3 // 20.09.2013 // Albom
* msvc-style  âਡãâë ¤«ï ®âª«î祭¨ï ¢ëà ¢­¨¢ ­¨ï ¢ áâàãªâãà å (ᯠᨡ® CleverMouse ¨ Kirakishou!) * msvc-style  âਡãâë ¤«ï ®âª«î祭¨ï ¢ëà ¢­¨¢ ­¨ï ¢ áâàãªâãà å (ᯠᨡ® CleverMouse ¨ Kirakishou!)

Binary file not shown.

View File

@ -10,7 +10,7 @@ if (NULL == dir)
#if LANG_ENG #if LANG_ENG
printf(" cd <directory>\n\r"); printf(" cd <directory>\n\r");
#elif LANG_RUS #elif LANG_RUS
printf(" cd <директория>\n\r"); printf(" cd <え爛<EFBFBD><EFBFBD><EFBFBD>>\n\r");
#endif #endif
return TRUE; return TRUE;
} }

View File

@ -18,21 +18,21 @@ k70.p16 = (unsigned) malloc(32+k70.p12*560);
k70.p20 = 0; k70.p20 = 0;
/// !!! /// !!!
// Если ls запускается без параметров, просматриваем текущий каталог // …᫨ ls § ¯ã᪠¥âáï ¡¥§ ¯ à ¬¥â஢, ¯à®á¬ âਢ ¥¬ ⥪ã騩 ª â «®£
if ( !strlen(dir) ) if ( !strlen(dir) )
k70.p21 = cur_dir; k70.p21 = cur_dir;
else else
k70.p21 = dir; k70.p21 = dir;
result = kol_file_70(&k70); result = kol_file_70(&k70);
if ( !((result==0) || (result==6)) ) // проверяем существование каталога if ( !((result==0) || (result==6)) ) // ¯à®¢¥à塞 áãé¥á⢮¢ ­¨¥ ª â «®£ 
{ {
free( (void*) k70.p16); free( (void*) k70.p16);
return FALSE; return FALSE;
} }
n = (unsigned*) (k70.p16+8); n = (unsigned*) (k70.p16+8);
num_of_file = *n; // число файлов в каталоге num_of_file = *n; // ç¨á«® ä ©«®¢ ¢ ª â «®£¥
for (i = 0; i < num_of_file; i++) for (i = 0; i < num_of_file; i++)
{ {

View File

@ -8,7 +8,7 @@ if (!strlen(param))
#if LANG_ENG #if LANG_ENG
printf(" sleep <time in the 1/100 of second>\n\r"); printf(" sleep <time in the 1/100 of second>\n\r");
#elif LANG_RUS #elif LANG_RUS
printf(" sleep <интервал в сотых доля секунды>\n\r"); printf(" sleep <¨­â¥à¢ « ¢ á®âëå ¤®«ï ᥪ㭤ë>\n\r");
#endif #endif
return TRUE; return TRUE;
} }

View File

@ -34,7 +34,6 @@ else
{ {
strcpy(temp, cur_dir); strcpy(temp, cur_dir);
strcat(temp, file); strcat(temp, file);
if ( !file_check(temp) ) if ( !file_check(temp) )
k70.p00 = 2; k70.p00 = 2;
else else

View File

@ -1,5 +1,5 @@
#define SHELL_VERSION "0.6.4" #define SHELL_VERSION "0.7.0"
extern char PATH[256]; extern char PATH[256];
extern char PARAM[256]; extern char PARAM[256];
@ -21,8 +21,6 @@ char CMD_HISTORY[CMD_HISTORY_NUM][256];
char CMD_NUM; char CMD_NUM;
char CMD_HISTORY_NUM_REAL = 0; char CMD_HISTORY_NUM_REAL = 0;
unsigned CMD_POS;
/// =========================================================== /// ===========================================================
char script_sign[] = {"#SHS"}; char script_sign[] = {"#SHS"};

View File

@ -1,15 +1,6 @@
/// =========================================================== /// ===========================================================
void command_clear()
{
for (;CMD_POS;CMD_POS--)
printf("%c %c", 8, 8);
CMD[0]='\0';
}
/// ===========================================================
void command_history_add(char command[]) void command_history_add(char command[])
{ {
@ -49,11 +40,11 @@ if ( (0 != strcmp( CMD_HISTORY[0], CMD)) &&
void command_get() void command_get()
{ {
unsigned key; unsigned key;
//unsigned pos = 0;
int hist;
CMD_POS = 0; unsigned i;
CMD_NUM = 0; unsigned cmdLen = 0;
unsigned cmdPos = 0;
CMD[0] = '\0';
for (;;) for (;;)
{ {
@ -64,56 +55,133 @@ for (;;)
switch (key) switch (key)
{ {
case 27: // ESC case 27: // ESC
command_clear(); 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';
break; break;
case 13: // ENTER
CMD[CMD_POS] = '\0';
printf("\n\r");
case 13: // ENTER
printf("\n\r");
command_history_add(CMD); command_history_add(CMD);
return; return;
case 8: // BACKSPACE case 8: // BACKSPACE
if (CMD_POS > 0) if (cmdPos > 0)
{ {
printf ("%c %c", 8, 8); for (i = cmdPos-1; i < cmdLen; i++)
CMD_POS--; CMD[i] = CMD[i+1];
for (i = 0; i < cmdLen-cmdPos; i++)
printf (" ");
for (i = 0; i < cmdLen; i++)
printf ("%c %c", 8, 8);
printf("%s", CMD);
for (i = 0; i < cmdLen-cmdPos; i++)
printf("%c", 8);
cmdPos--;
cmdLen--;
} }
break; break;
case 9: // TAB case 9: // TAB
break; break;
default:
if (CMD_POS < 255)
{
default:
if (cmdLen < 255)
{
if ( kol_key_control() & 0x40 ) // ¥á«¨ ¢ª«îçñ­ CapsLock if ( kol_key_control() & 0x40 ) // ¥á«¨ ¢ª«îçñ­ CapsLock
if ( (kol_key_control() & 1) || (kol_key_control() & 2)) // ¥á«¨ ­ ¦ âë è¨äâë if ( (kol_key_control() & 1) || (kol_key_control() & 2)) // ¥á«¨ ­ ¦ âë è¨äâë
key = tolower(key); key = tolower(key);
else else
key = toupper(key); key = toupper(key);
CMD[CMD_POS] = key; for (i = cmdLen+1; i > cmdPos; i--)
CMD_POS++; CMD[i] = CMD[i-1];
printf("%c", key);
CMD[cmdPos] = key;
for (i = cmdPos; i > 0; i--)
printf("%c %c", 8, 8);
printf("%s", CMD);
for (i = 0; i < cmdLen-cmdPos; i++)
printf("%c", 8);
cmdPos++;
cmdLen++;
} }
break; break;
};
}
else // ®¡à ¡®âª  à áè¨à¥­­ëå ª« ¢¨è
{
key = (key>>8)&0xff;
// printf ("%d\n\r", key);
}
}
else
{
key = (key>>8)&0xff;
switch (key) switch (key)
{ {
case 83: // Del
if (cmdPos < cmdLen)
{
for (i = cmdPos; i < cmdLen; i++)
CMD[i] = CMD[i+1];
for (i = 0; i < cmdLen-cmdPos; i++)
printf(" ");
for (i = 0; i < cmdLen-cmdPos; i++)
printf("%c", 8);
for (i = cmdPos; i < cmdLen; i++)
printf("%c", CMD[i]);
for (i = 0; i < cmdLen-cmdPos; i++)
printf("%c", 8);
cmdLen--;
}
break;
case 75: // Left
if (cmdPos > 0)
{
printf("%c", 8);
cmdPos--;
}
break;
case 77: // Right
if (cmdPos < cmdLen)
{
printf("%c", CMD[cmdPos]);
cmdPos++;
}
break;
case 80: // Down case 80: // Down
for (hist = 0; hist < CMD_HISTORY_NUM; hist++) for (i = 0; i < CMD_HISTORY_NUM; i++)
{ {
command_clear();
for (i = cmdPos; i < cmdLen; i++)
printf(" ");
for (i = cmdLen; i > 0; i--)
printf("%c %c", 8, 8);
if (CMD_NUM < CMD_HISTORY_NUM-1) if (CMD_NUM < CMD_HISTORY_NUM-1)
CMD_NUM++; CMD_NUM++;
@ -122,16 +190,24 @@ for (;;)
printf( CMD_HISTORY[CMD_NUM] ); printf( CMD_HISTORY[CMD_NUM] );
strcpy(CMD, CMD_HISTORY[CMD_NUM]); strcpy(CMD, CMD_HISTORY[CMD_NUM]);
if ((CMD_POS = strlen(CMD)) != 0) cmdLen = strlen(CMD);
if ((cmdPos = strlen(CMD)) != 0)
break; break;
} }
break; break;
case 72: // Up case 72: // Up
for (hist = 0; hist < CMD_HISTORY_NUM; hist++) for (i = 0; i < CMD_HISTORY_NUM; i++)
{ {
command_clear();
for (i = cmdPos; i < cmdLen; i++)
printf(" ");
for (i = cmdLen; i > 0; i--)
printf("%c %c", 8, 8);
if (CMD_NUM > 0) if (CMD_NUM > 0)
CMD_NUM--; CMD_NUM--;
@ -140,22 +216,23 @@ for (;;)
printf( CMD_HISTORY[CMD_NUM] ); printf( CMD_HISTORY[CMD_NUM] );
strcpy(CMD, CMD_HISTORY[CMD_NUM]); strcpy(CMD, CMD_HISTORY[CMD_NUM]);
if ((CMD_POS = strlen(CMD)) != 0) cmdLen = strlen(CMD);
if ((cmdPos = strlen(CMD)) != 0)
break; break;
} }
break; break;
case 0: // console window closed case 0: // console window closed
cmd_exit(NULL); cmd_exit(NULL);
}; }
}
}
}
}
} }
/// =========================================================== /// ===========================================================
int command_get_cmd(char cmd[]) int command_get_cmd(char cmd[])