Changeset da68871a in mainline for kernel/generic/src/console/kconsole.c
- Timestamp:
- 2012-08-08T08:46:22Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 30c0826
- Parents:
- bc216a0 (diff), 1d01cca (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
rbc216a0 rda68871a 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> … … 202 203 * 203 204 */ 204 NO_TRACE static int cmdtab_compl(char *input, size_t size )205 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t *indev) 205 206 { 206 207 const char *name = input; 207 208 208 209 size_t found = 0; 210 211 /* 212 * Maximum Match Length: Length of longest matching common 213 * substring in case more than one match is found. 214 */ 215 size_t max_match_len = size; 216 size_t max_match_len_tmp = size; 217 size_t input_len = str_length(input); 209 218 link_t *pos = NULL; 210 219 const char *hint; 211 220 char *output = malloc(MAX_CMDLINE, 0); 221 size_t hints_to_show = MAX_TAB_HINTS - 1; 222 size_t total_hints_shown = 0; 223 bool continue_showing_hints = true; 212 224 213 225 output[0] = 0; … … 219 231 pos = pos->next; 220 232 found++; 233 } 234 235 /* 236 * If the number of possible completions is more than MAX_TAB_HINTS, 237 * ask the user whether to display them or not. 238 */ 239 if (found > MAX_TAB_HINTS) { 240 printf("\n"); 241 continue_showing_hints = 242 console_prompt_display_all_hints(indev, found); 221 243 } 222 244 … … 226 248 while (cmdtab_search_one(name, &pos)) { 227 249 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 228 printf("%s (%s)\n", hlp->name, hlp->description); 250 251 if (continue_showing_hints) { 252 printf("%s (%s)\n", hlp->name, hlp->description); 253 --hints_to_show; 254 ++total_hints_shown; 255 256 if ((hints_to_show == 0) && (total_hints_shown != found)) { 257 /* Ask user to continue */ 258 continue_showing_hints = 259 console_prompt_more_hints(indev, &hints_to_show); 260 } 261 } 262 229 263 pos = pos->next; 230 } 264 265 for (max_match_len_tmp = 0; 266 (output[max_match_len_tmp] == 267 hlp->name[input_len + max_match_len_tmp]) && 268 (max_match_len_tmp < max_match_len); ++max_match_len_tmp); 269 270 max_match_len = max_match_len_tmp; 271 } 272 273 /* Keep only the characters common in all completions */ 274 output[max_match_len] = 0; 231 275 } 232 276 … … 281 325 continue; 282 326 283 /* Find the beginning of the word 284 and copy it to tmp */ 327 /* 328 * Find the beginning of the word 329 * and copy it to tmp 330 */ 285 331 size_t beg; 286 332 for (beg = position - 1; (beg > 0) && (!isspace(current[beg])); … … 295 341 if (beg == 0) { 296 342 /* Command completion */ 297 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );343 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 298 344 } else { 299 345 /* Symbol completion */ 300 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );346 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 301 347 } 302 348 303 349 if (found == 0) 304 350 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 351 352 /* 353 * We have hints, possibly many. In case of more than one hint, 354 * tmp will contain the common prefix. 355 */ 316 356 size_t off = 0; 317 357 size_t i = 0; … … 319 359 if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE)) 320 360 break; 361 321 362 i++; 322 363 } 364 365 if (found > 1) { 366 /* No unique hint, list was printed */ 367 printf("%s> ", prompt); 368 printf("%ls", current); 369 position += str_length(tmp); 370 print_cc('\b', wstr_length(current) - position); 371 continue; 372 } 373 374 /* We have a hint */ 323 375 324 376 printf("%ls", current + position); … … 541 593 /** Parse command line. 542 594 * 543 * @param cmdline Command line as read from input device. 595 * @param cmdline Command line as read from input device. 544 596 * @param size Size (in bytes) of the string. 545 597 *
Note:
See TracChangeset
for help on using the changeset viewer.