Archived
1
0

Merge pull request #48 from mattventura/master

Avoid putting blank entries in history, allow linefeed for enter
This commit is contained in:
Jacob Alexander 2015-06-12 18:33:23 -07:00
commit 46fc3e596b

View File

@ -149,12 +149,20 @@ void CLI_process()
// Check for control characters // Check for control characters
switch ( CLILineBuffer[prev_buf_pos] ) switch ( CLILineBuffer[prev_buf_pos] )
{ {
case 0x0D: // Enter // Enter
case 0x0A: // LF
case 0x0D: // CR
CLILineBuffer[CLILineBufferCurrent - 1] = ' '; // Replace Enter with a space (resolves a bug in args) CLILineBuffer[CLILineBufferCurrent - 1] = ' '; // Replace Enter with a space (resolves a bug in args)
// Remove the space if there is no command // Remove the space if there is no command
if ( CLILineBufferCurrent == 1 ) if ( CLILineBufferCurrent == 1 )
{
CLILineBufferCurrent--; CLILineBufferCurrent--;
}
else
{
// Only do command-related stuff if there was actually a command
// Avoids clogging command history with blanks
// Process the current line buffer // Process the current line buffer
CLI_commandLookup(); CLI_commandLookup();
@ -175,6 +183,8 @@ void CLI_process()
CLIHistoryCurrent = CLIHistoryTail; // 'Up' starts at the last item CLIHistoryCurrent = CLIHistoryTail; // 'Up' starts at the last item
CLI_saveHistory( NULL ); // delete the old temp buffer CLI_saveHistory( NULL ); // delete the old temp buffer
}
// Reset the buffer // Reset the buffer
CLILineBufferCurrent = 0; CLILineBufferCurrent = 0;
@ -199,7 +209,7 @@ void CLI_process()
case 0x1B: // Esc / Escape codes case 0x1B: // Esc / Escape codes
// Check for other escape sequence // Check for other escape sequence
// \e[ is an escape code in vt100 compatable terminals // \e[ is an escape code in vt100 compatible terminals
if ( CLILineBufferCurrent >= prev_buf_pos + 3 if ( CLILineBufferCurrent >= prev_buf_pos + 3
&& CLILineBuffer[ prev_buf_pos ] == 0x1B && CLILineBuffer[ prev_buf_pos ] == 0x1B
&& CLILineBuffer[ prev_buf_pos + 1] == 0x5B ) && CLILineBuffer[ prev_buf_pos + 1] == 0x5B )