comparison Debug/cli/cli.c @ 395:e581daa76a14

Write whole debug cli command to history Previously the command was being modified in place in order to find the command name. This was happening before saving to the history. Fixes #70
author Eric Mertens <emertens@gmail.com>
date Mon, 26 Oct 2015 17:55:41 -0700
parents d8f61e15aca1
children
comparison
equal deleted inserted replaced
394:0d96d2bbf225 395:e581daa76a14
157 { 157 {
158 CLILineBufferCurrent--; 158 CLILineBufferCurrent--;
159 } 159 }
160 else 160 else
161 { 161 {
162 // Only do command-related stuff if there was actually a command 162 // Add the command to the history
163 // Avoids clogging command history with blanks 163 CLI_saveHistory( CLILineBuffer );
164 164
165 // Process the current line buffer 165 // Process the current line buffer
166 CLI_commandLookup(); 166 CLI_commandLookup();
167
168 // Add the command to the history
169 CLI_saveHistory( CLILineBuffer );
170 167
171 // Keep the array circular, discarding the older entries 168 // Keep the array circular, discarding the older entries
172 if ( CLIHistoryTail < CLIHistoryHead ) 169 if ( CLIHistoryTail < CLIHistoryHead )
173 CLIHistoryHead = ( CLIHistoryHead + 1 ) % CLIMaxHistorySize; 170 CLIHistoryHead = ( CLIHistoryHead + 1 ) % CLIMaxHistorySize;
174 CLIHistoryTail++; 171 CLIHistoryTail++;
422 { 419 {
423 //clear the item 420 //clear the item
424 CLIHistoryBuffer[ CLIHistoryTail ][ 0 ] = '\0'; 421 CLIHistoryBuffer[ CLIHistoryTail ][ 0 ] = '\0';
425 return; 422 return;
426 } 423 }
424
425 // Don't write empty lines to the history
426 const char *cursor = buff;
427 while (*cursor == ' ') { cursor++; } // advance past the leading whitespace
428 if (*cursor == '\0') { return ; }
427 429
428 // Copy the line to the history 430 // Copy the line to the history
429 int i; 431 int i;
430 for (i = 0; i < CLILineBufferCurrent; i++) 432 for (i = 0; i < CLILineBufferCurrent; i++)
431 { 433 {