CLI: ignore ANSI/VT100 arrow keys on default
This commit is contained in:
parent
c8854931b5
commit
d4edc2cd8f
23
CLI/CLI.c
23
CLI/CLI.c
@ -15,12 +15,12 @@
|
|||||||
CLI_charOutFn CLI_charOut;
|
CLI_charOutFn CLI_charOut;
|
||||||
CMDList_t* CMDList;
|
CMDList_t* CMDList;
|
||||||
FIFOBuffChar_t* FIFO;
|
FIFOBuffChar_t* FIFO;
|
||||||
#ifdef HISTORY
|
|
||||||
enum {
|
enum {
|
||||||
CLI_State_Default,
|
CLI_State_Default,
|
||||||
CLI_State_Esc,
|
CLI_State_Esc,
|
||||||
CLI_State_ANSIVT100
|
CLI_State_ANSIVT100
|
||||||
} CLI_State = CLI_State_Default;
|
} CLI_State = CLI_State_Default;
|
||||||
|
#ifdef HISTORY
|
||||||
History_t* History;
|
History_t* History;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -168,11 +168,9 @@ bool CLI_charIn(char c)
|
|||||||
C &= (~0x20); // convert to uppercase
|
C &= (~0x20); // convert to uppercase
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HISTORY
|
|
||||||
switch (CLI_State)
|
switch (CLI_State)
|
||||||
{
|
{
|
||||||
case CLI_State_Default:
|
case CLI_State_Default:
|
||||||
#endif
|
|
||||||
if ( //TODO: update list of accepted characters
|
if ( //TODO: update list of accepted characters
|
||||||
((C >= 'A') && (C <= 'Z'))
|
((C >= 'A') && (C <= 'Z'))
|
||||||
|| ((c >= '0') && (c <= '9'))
|
|| ((c >= '0') && (c <= '9'))
|
||||||
@ -209,14 +207,8 @@ bool CLI_charIn(char c)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 27: // escape (start for arrow keys)
|
case 27: // escape (start for arrow keys)
|
||||||
#ifdef HISTORY
|
|
||||||
CLI_State = CLI_State_Esc;
|
CLI_State = CLI_State_Esc;
|
||||||
break;
|
break;
|
||||||
#else
|
|
||||||
sprintf(&str[0], "\ninvlid char: ESC - (%i)\n", c);
|
|
||||||
CLI_stringOut(&str[0]);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sprintf(&str[0], "\ninvlid char: '%c' - (%i)\n", c, c);
|
sprintf(&str[0], "\ninvlid char: '%c' - (%i)\n", c, c);
|
||||||
@ -224,7 +216,6 @@ bool CLI_charIn(char c)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef HISTORY
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLI_State_Esc:
|
case CLI_State_Esc:
|
||||||
@ -241,25 +232,28 @@ bool CLI_charIn(char c)
|
|||||||
case CLI_State_ANSIVT100:
|
case CLI_State_ANSIVT100:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
#ifdef HISTORY
|
||||||
case 'A': // arrow up
|
case 'A': // arrow up
|
||||||
// history previus
|
// history previus
|
||||||
CLI_stringOut((char*)"(key arrow up)");
|
CLI_stringOut((char*)"(key: arrow up)");
|
||||||
CLI_State = CLI_State_Default;
|
CLI_State = CLI_State_Default;
|
||||||
break;
|
break;
|
||||||
case 'B': // arrow down
|
case 'B': // arrow down
|
||||||
CLI_stringOut((char*)"(key arrow down)");
|
|
||||||
// history next
|
// history next
|
||||||
|
CLI_stringOut((char*)"(key: arrow down)");
|
||||||
CLI_State = CLI_State_Default;
|
CLI_State = CLI_State_Default;
|
||||||
break;
|
break;
|
||||||
case 'C': // arrow right
|
case 'C': // arrow right
|
||||||
CLI_stringOut((char*)"(key arrow right)");
|
CLI_stringOut((char*)"(key: arrow right)");
|
||||||
CLI_State = CLI_State_Default;
|
CLI_State = CLI_State_Default;
|
||||||
break;
|
break;
|
||||||
case 'D': // arrow left
|
case 'D': // arrow left
|
||||||
CLI_stringOut((char*)"(key arrow left)");
|
CLI_stringOut((char*)"(key: arrow left)");
|
||||||
CLI_State = CLI_State_Default;
|
CLI_State = CLI_State_Default;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
|
// only to back on on alpha char. seems to be the with all '\x1d[' commands
|
||||||
if ((C >= 'A') && (C <= 'Z'))
|
if ((C >= 'A') && (C <= 'Z'))
|
||||||
{
|
{
|
||||||
CLI_State = CLI_State_Default;
|
CLI_State = CLI_State_Default;
|
||||||
@ -268,7 +262,6 @@ bool CLI_charIn(char c)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user