Changes in kernel/generic/src/console/kconsole.c [aca4a04:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
raca4a04 r9d58539 43 43 #include <console/chardev.h> 44 44 #include <console/cmd.h> 45 #include <console/prompt.h>46 45 #include <print.h> 47 46 #include <panic.h> … … 202 201 * 203 202 */ 204 NO_TRACE static int cmdtab_compl(char *input, size_t size , indev_t * indev)203 NO_TRACE static int cmdtab_compl(char *input, size_t size) 205 204 { 206 205 const char *name = input; 207 206 208 207 size_t found = 0; 209 /* Maximum Match Length : Length of longest matching common substring in210 case more than one match is found */211 size_t max_match_len = size;212 size_t max_match_len_tmp = size;213 size_t input_len = str_length(input);214 208 link_t *pos = NULL; 215 209 const char *hint; 216 210 char *output = malloc(MAX_CMDLINE, 0); 217 size_t hints_to_show = MAX_TAB_HINTS - 1;218 size_t total_hints_shown = 0;219 bool continue_showing_hints = true;220 211 221 212 output[0] = 0; … … 227 218 pos = pos->next; 228 219 found++; 229 }230 231 /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */232 if (found > MAX_TAB_HINTS) {233 printf("\n");234 continue_showing_hints = console_prompt_display_all_hints(indev, found);235 220 } 236 221 … … 240 225 while (cmdtab_search_one(name, &pos)) { 241 226 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 242 243 if (continue_showing_hints) { 244 printf("%s (%s)\n", hlp->name, hlp->description); 245 --hints_to_show; 246 ++total_hints_shown; 247 248 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */ 249 continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show); 250 } 251 } 252 227 printf("%s (%s)\n", hlp->name, hlp->description); 253 228 pos = pos->next; 254 for(max_match_len_tmp = 0; output[max_match_len_tmp] == hlp->name[input_len + max_match_len_tmp] 255 && max_match_len_tmp < max_match_len; ++max_match_len_tmp); 256 max_match_len = max_match_len_tmp; 257 } 258 /* keep only the characters common in all completions */ 259 output[max_match_len] = 0; 229 } 260 230 } 261 231 … … 324 294 if (beg == 0) { 325 295 /* Command completion */ 326 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) , indev);296 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE)); 327 297 } else { 328 298 /* Symbol completion */ 329 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) , indev);299 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE)); 330 300 } 331 301 332 302 if (found == 0) 333 303 continue; 334 335 /* We have hints, may be many. In case of more than one hint, 336 tmp will contain the common prefix. */ 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 337 315 size_t off = 0; 338 316 size_t i = 0; … … 342 320 i++; 343 321 } 344 345 if (found > 1) {346 /* No unique hint, list was printed */347 printf("%s> ", prompt);348 printf("%ls", current);349 position += str_length(tmp);350 print_cc('\b', wstr_length(current) - position);351 continue;352 }353 354 /* We have a hint */355 322 356 323 printf("%ls", current + position); … … 573 540 /** Parse command line. 574 541 * 575 * @param cmdline Command line as read from input device. 542 * @param cmdline Command line as read from input device. 576 543 * @param size Size (in bytes) of the string. 577 544 *
Note:
See TracChangeset
for help on using the changeset viewer.