Mercurial > louis > kiibohd-controller
comparison Debug/cli/cli.c @ 321:18c3c4924f20
Code cleanup from cli changes.
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Tue, 07 Apr 2015 22:11:04 -0700 |
parents | 3994a5a68793 |
children | 9dd55aa71d76 |
comparison
equal
deleted
inserted
replaced
320:64f43aad73af | 321:18c3c4924f20 |
---|---|
158 | 158 |
159 // Process the current line buffer | 159 // Process the current line buffer |
160 CLI_commandLookup(); | 160 CLI_commandLookup(); |
161 | 161 |
162 // Add the command to the history | 162 // Add the command to the history |
163 cli_saveHistory( CLILineBuffer ); | 163 CLI_saveHistory( CLILineBuffer ); |
164 | 164 |
165 // Keep the array circular, discarding the older entries | 165 // Keep the array circular, discarding the older entries |
166 if ( CLIHistoryTail < CLIHistoryHead ) | 166 if ( CLIHistoryTail < CLIHistoryHead ) |
167 CLIHistoryHead = ( CLIHistoryHead + 1 ) % CLIMaxHistorySize; | 167 CLIHistoryHead = ( CLIHistoryHead + 1 ) % CLIMaxHistorySize; |
168 CLIHistoryTail++; | 168 CLIHistoryTail++; |
171 CLIHistoryTail = 0; | 171 CLIHistoryTail = 0; |
172 CLIHistoryHead = 1; | 172 CLIHistoryHead = 1; |
173 } | 173 } |
174 | 174 |
175 CLIHistoryCurrent = CLIHistoryTail; // 'Up' starts at the last item | 175 CLIHistoryCurrent = CLIHistoryTail; // 'Up' starts at the last item |
176 cli_saveHistory( NULL ); // delete the old temp buffer | 176 CLI_saveHistory( NULL ); // delete the old temp buffer |
177 | 177 |
178 // Reset the buffer | 178 // Reset the buffer |
179 CLILineBufferCurrent = 0; | 179 CLILineBufferCurrent = 0; |
180 | 180 |
181 // Reset the prompt after processing has finished | 181 // Reset the prompt after processing has finished |
210 { | 210 { |
211 if ( CLIHistoryCurrent == CLIHistoryTail ) | 211 if ( CLIHistoryCurrent == CLIHistoryTail ) |
212 { | 212 { |
213 // Is first time pressing arrow. Save the current buffer | 213 // Is first time pressing arrow. Save the current buffer |
214 CLILineBuffer[ prev_buf_pos ] = '\0'; | 214 CLILineBuffer[ prev_buf_pos ] = '\0'; |
215 cli_saveHistory( CLILineBuffer ); | 215 CLI_saveHistory( CLILineBuffer ); |
216 } | 216 } |
217 | 217 |
218 // Grab the previus item from the history if there is one | 218 // Grab the previus item from the history if there is one |
219 if ( RING_PREV( CLIHistoryCurrent ) != RING_PREV( CLIHistoryHead ) ) | 219 if ( RING_PREV( CLIHistoryCurrent ) != RING_PREV( CLIHistoryHead ) ) |
220 CLIHistoryCurrent = RING_PREV( CLIHistoryCurrent ); | 220 CLIHistoryCurrent = RING_PREV( CLIHistoryCurrent ); |
221 cli_retreiveHistory( CLIHistoryCurrent ); | 221 CLI_retreiveHistory( CLIHistoryCurrent ); |
222 } | 222 } |
223 if ( CLILineBuffer[ prev_buf_pos + 2 ] == 0x42 ) // Hist next | 223 if ( CLILineBuffer[ prev_buf_pos + 2 ] == 0x42 ) // Hist next |
224 { | 224 { |
225 // Grab the next item from the history if it exists | 225 // Grab the next item from the history if it exists |
226 if ( RING_NEXT( CLIHistoryCurrent ) != RING_NEXT( CLIHistoryTail ) ) | 226 if ( RING_NEXT( CLIHistoryCurrent ) != RING_NEXT( CLIHistoryTail ) ) |
227 CLIHistoryCurrent = RING_NEXT( CLIHistoryCurrent ); | 227 CLIHistoryCurrent = RING_NEXT( CLIHistoryCurrent ); |
228 cli_retreiveHistory( CLIHistoryCurrent ); | 228 CLI_retreiveHistory( CLIHistoryCurrent ); |
229 } | 229 } |
230 } | 230 } |
231 return; | 231 return; |
232 | 232 |
233 case 0x08: | 233 case 0x08: |