Changeset 1bebadee in mainline for kernel/generic/src/console/kconsole.c
- Timestamp:
- 2012-07-18T11:11:29Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c5cbc1b7
- Parents:
- 1f7da3b (diff), 730dce77 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
r1f7da3b r1bebadee 43 43 #include <console/chardev.h> 44 44 #include <console/cmd.h> 45 #include <console/prompt.h> 45 46 #include <print.h> 46 47 #include <panic.h> … … 201 202 * 202 203 */ 203 NO_TRACE static int cmdtab_compl(char *input, size_t size )204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t *indev) 204 205 { 205 206 const char *name = input; 206 207 207 208 size_t found = 0; 209 210 /* 211 * Maximum Match Length: Length of longest matching common 212 * substring in case more than one match is found. 213 */ 214 size_t max_match_len = size; 215 size_t max_match_len_tmp = size; 216 size_t input_len = str_length(input); 208 217 link_t *pos = NULL; 209 218 const char *hint; 210 219 char *output = malloc(MAX_CMDLINE, 0); 220 size_t hints_to_show = MAX_TAB_HINTS - 1; 221 size_t total_hints_shown = 0; 222 bool continue_showing_hints = true; 211 223 212 224 output[0] = 0; … … 218 230 pos = pos->next; 219 231 found++; 232 } 233 234 /* 235 * If the number of possible completions is more than MAX_TAB_HINTS, 236 * ask the user whether to display them or not. 237 */ 238 if (found > MAX_TAB_HINTS) { 239 printf("\n"); 240 continue_showing_hints = 241 console_prompt_display_all_hints(indev, found); 220 242 } 221 243 … … 225 247 while (cmdtab_search_one(name, &pos)) { 226 248 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 227 printf("%s (%s)\n", hlp->name, hlp->description); 249 250 if (continue_showing_hints) { 251 printf("%s (%s)\n", hlp->name, hlp->description); 252 --hints_to_show; 253 ++total_hints_shown; 254 255 if ((hints_to_show == 0) && (total_hints_shown != found)) { 256 /* Ask user to continue */ 257 continue_showing_hints = 258 console_prompt_more_hints(indev, &hints_to_show); 259 } 260 } 261 228 262 pos = pos->next; 229 } 263 264 for (max_match_len_tmp = 0; 265 (output[max_match_len_tmp] == 266 hlp->name[input_len + max_match_len_tmp]) && 267 (max_match_len_tmp < max_match_len); ++max_match_len_tmp); 268 269 max_match_len = max_match_len_tmp; 270 } 271 272 /* Keep only the characters common in all completions */ 273 output[max_match_len] = 0; 230 274 } 231 275 … … 280 324 continue; 281 325 282 /* Find the beginning of the word 283 and copy it to tmp */ 326 /* 327 * Find the beginning of the word 328 * and copy it to tmp 329 */ 284 330 size_t beg; 285 331 for (beg = position - 1; (beg > 0) && (!isspace(current[beg])); … … 294 340 if (beg == 0) { 295 341 /* Command completion */ 296 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );342 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 297 343 } else { 298 344 /* Symbol completion */ 299 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );345 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 300 346 } 301 347 302 348 if (found == 0) 303 349 continue; 304 305 if (found > 1) { 306 /* No unique hint, list was printed */ 307 printf("%s> ", prompt); 308 printf("%ls", current); 309 print_cc('\b', wstr_length(current) - position); 310 continue; 311 } 312 313 /* We have a hint */ 314 350 351 /* 352 * We have hints, possibly many. In case of more than one hint, 353 * tmp will contain the common prefix. 354 */ 315 355 size_t off = 0; 316 356 size_t i = 0; … … 318 358 if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE)) 319 359 break; 360 320 361 i++; 321 362 } 363 364 if (found > 1) { 365 /* No unique hint, list was printed */ 366 printf("%s> ", prompt); 367 printf("%ls", current); 368 position += str_length(tmp); 369 print_cc('\b', wstr_length(current) - position); 370 continue; 371 } 372 373 /* We have a hint */ 322 374 323 375 printf("%ls", current + position); … … 540 592 /** Parse command line. 541 593 * 542 * @param cmdline Command line as read from input device. 594 * @param cmdline Command line as read from input device. 543 595 * @param size Size (in bytes) of the string. 544 596 *
Note:
See TracChangeset
for help on using the changeset viewer.