forked from KolibriOS/kolibrios
Shell 0.7.1. Pressing Up and Down keys was causing hanging up the program when command history was empty (but nobody cares). Fixed.
git-svn-id: svn://kolibrios.org@4050 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
eedc7e81df
commit
817c27709e
@ -1,3 +1,7 @@
|
||||
Shell 0.7.1 // 19.10.2013 // Albom
|
||||
* ˆá¯à ¢«¥ ®è¨¡ª , á¢ï§ ï á § ¢¨á ¨¥¬ ¯à¨ ¯®¯ë⪥ çâ¥¨ï ¯ãá⮩ ¨áâ®à¨¨ ª®¬ ¤ (¯® ª« ¢¨è ¬ Up ¨ Down)
|
||||
|
||||
|
||||
Shell 0.7.0 // 13.10.2013 // Albom
|
||||
* <20>¥à¥à ¡®â ¬®¤ã«ì ¢¢®¤ ª®¬ ¤ë (¤®¡ ¢«¥ ®¡à ¡®âª ª« ¢¨è "¢«¥¢®", "¢¯à ¢®", Del)
|
||||
* Œ¥«ª¨¥ ¨á¯à ¢«¥¨ï
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
#define SHELL_VERSION "0.7.0"
|
||||
#define SHELL_VERSION "0.7.1"
|
||||
|
||||
extern char PATH[256];
|
||||
extern char PARAM[256];
|
||||
@ -18,7 +18,7 @@ unsigned ALIAS_NUM = 0;
|
||||
|
||||
char CMD[256];
|
||||
char CMD_HISTORY[CMD_HISTORY_NUM][256];
|
||||
char CMD_NUM;
|
||||
char CMD_NUM = 0;
|
||||
char CMD_HISTORY_NUM_REAL = 0;
|
||||
|
||||
/// ===========================================================
|
||||
|
@ -1,40 +1,29 @@
|
||||
|
||||
/// ===========================================================
|
||||
|
||||
void command_history_add(char command[])
|
||||
void command_history_add()
|
||||
{
|
||||
|
||||
if ( (0 != strcmp( CMD_HISTORY[0], CMD)) &&
|
||||
(0 != strcmp( CMD_HISTORY[1], CMD)) &&
|
||||
(0 != strcmp( CMD_HISTORY[2], CMD)) &&
|
||||
(0 != strcmp( CMD_HISTORY[3], CMD)) &&
|
||||
(0 != strcmp( CMD_HISTORY[4], CMD)) &&
|
||||
(0 != strcmp( CMD_HISTORY[5], CMD)) &&
|
||||
(0 != strcmp( CMD_HISTORY[6], CMD)) &&
|
||||
(0 != strcmp( CMD_HISTORY[7], CMD)) &&
|
||||
(0 != strcmp( CMD_HISTORY[8], CMD)) &&
|
||||
(0 != strcmp( CMD_HISTORY[9], CMD)) )
|
||||
int i;
|
||||
|
||||
{
|
||||
strcpy(CMD_HISTORY[9], CMD_HISTORY[8]);
|
||||
strcpy(CMD_HISTORY[8], CMD_HISTORY[7]);
|
||||
strcpy(CMD_HISTORY[7], CMD_HISTORY[6]);
|
||||
strcpy(CMD_HISTORY[6], CMD_HISTORY[5]);
|
||||
strcpy(CMD_HISTORY[5], CMD_HISTORY[4]);
|
||||
strcpy(CMD_HISTORY[4], CMD_HISTORY[3]);
|
||||
strcpy(CMD_HISTORY[3], CMD_HISTORY[2]);
|
||||
strcpy(CMD_HISTORY[2], CMD_HISTORY[1]);
|
||||
strcpy(CMD_HISTORY[1], CMD_HISTORY[0]);
|
||||
for (i = 0; i < CMD_HISTORY_NUM_REAL; i++)
|
||||
if ( 0 == strcmp( CMD_HISTORY[i], CMD ) )
|
||||
return;
|
||||
|
||||
for (i = CMD_HISTORY_NUM_REAL; i > 0 ; i--)
|
||||
strcpy(CMD_HISTORY[i], CMD_HISTORY[i-1]);
|
||||
|
||||
strcpy(CMD_HISTORY[0], CMD);
|
||||
|
||||
if (CMD_HISTORY_NUM_REAL < CMD_HISTORY_NUM)
|
||||
if (CMD_HISTORY_NUM_REAL < CMD_HISTORY_NUM-1)
|
||||
CMD_HISTORY_NUM_REAL++;
|
||||
|
||||
}
|
||||
CMD_NUM = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// ===========================================================
|
||||
|
||||
void command_get()
|
||||
@ -67,7 +56,7 @@ for (;;)
|
||||
|
||||
case 13: // ENTER
|
||||
printf("\n\r");
|
||||
command_history_add(CMD);
|
||||
command_history_add();
|
||||
return;
|
||||
|
||||
|
||||
@ -174,7 +163,8 @@ for (;;)
|
||||
|
||||
|
||||
case 80: // Down
|
||||
for (i = 0; i < CMD_HISTORY_NUM; i++)
|
||||
|
||||
if (CMD_HISTORY_NUM_REAL > 0)
|
||||
{
|
||||
|
||||
for (i = cmdPos; i < cmdLen; i++)
|
||||
@ -183,7 +173,7 @@ for (;;)
|
||||
for (i = cmdLen; i > 0; i--)
|
||||
printf("%c %c", 8, 8);
|
||||
|
||||
if (CMD_NUM < CMD_HISTORY_NUM-1)
|
||||
if (CMD_NUM < CMD_HISTORY_NUM_REAL-1)
|
||||
CMD_NUM++;
|
||||
else
|
||||
CMD_NUM = 0;
|
||||
@ -191,8 +181,7 @@ for (;;)
|
||||
printf( CMD_HISTORY[CMD_NUM] );
|
||||
strcpy(CMD, CMD_HISTORY[CMD_NUM]);
|
||||
cmdLen = strlen(CMD);
|
||||
if ((cmdPos = strlen(CMD)) != 0)
|
||||
break;
|
||||
cmdPos = strlen(CMD);
|
||||
|
||||
}
|
||||
|
||||
@ -200,7 +189,7 @@ for (;;)
|
||||
|
||||
|
||||
case 72: // Up
|
||||
for (i = 0; i < CMD_HISTORY_NUM; i++)
|
||||
if (CMD_HISTORY_NUM_REAL > 0)
|
||||
{
|
||||
|
||||
for (i = cmdPos; i < cmdLen; i++)
|
||||
@ -212,13 +201,13 @@ for (;;)
|
||||
if (CMD_NUM > 0)
|
||||
CMD_NUM--;
|
||||
else
|
||||
CMD_NUM = CMD_HISTORY_NUM-1;
|
||||
CMD_NUM = CMD_HISTORY_NUM_REAL-1;
|
||||
|
||||
printf( CMD_HISTORY[CMD_NUM] );
|
||||
strcpy(CMD, CMD_HISTORY[CMD_NUM]);
|
||||
cmdLen = strlen(CMD);
|
||||
if ((cmdPos = strlen(CMD)) != 0)
|
||||
break;
|
||||
cmdPos = strlen(CMD);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user