Changes in kernel/generic/src/console/kconsole.c [1066041:aca4a04] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
r1066041 raca4a04 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> … … 59 60 #include <putchar.h> 60 61 #include <str.h> 61 #include <mm/slab.h>62 62 63 63 /** Simple kernel console. … … 202 202 * 203 203 */ 204 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) 205 205 { 206 206 const char *name = input; 207 207 208 208 size_t found = 0; 209 /* Maximum Match Length : Length of longest matching common substring in 210 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); 209 214 link_t *pos = NULL; 210 215 const char *hint; 211 216 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; 212 220 213 221 output[0] = 0; … … 219 227 pos = pos->next; 220 228 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); 221 235 } 222 236 … … 226 240 while (cmdtab_search_one(name, &pos)) { 227 241 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 228 printf("%s (%s)\n", hlp->name, hlp->description); 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 229 253 pos = pos->next; 230 } 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; 231 260 } 232 261 … … 295 324 if (beg == 0) { 296 325 /* Command completion */ 297 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );326 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 298 327 } else { 299 328 /* Symbol completion */ 300 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );329 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 301 330 } 302 331 303 332 if (found == 0) 304 333 continue; 305 306 if (found > 1) { 307 /* No unique hint, list was printed */ 308 printf("%s> ", prompt); 309 printf("%ls", current); 310 print_cc('\b', wstr_length(current) - position); 311 continue; 312 } 313 314 /* We have a hint */ 315 334 335 /* We have hints, may be many. In case of more than one hint, 336 tmp will contain the common prefix. */ 316 337 size_t off = 0; 317 338 size_t i = 0; … … 321 342 i++; 322 343 } 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 */ 323 355 324 356 printf("%ls", current + position); … … 541 573 /** Parse command line. 542 574 * 543 * @param cmdline Command line as read from input device. 575 * @param cmdline Command line as read from input device. 544 576 * @param size Size (in bytes) of the string. 545 577 *
Note:
See TracChangeset
for help on using the changeset viewer.