Changeset 1e01a35 in mainline for kernel/generic/src/console/kconsole.c
- Timestamp:
- 2012-07-10T12:01:07Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f0d7bd9
- Parents:
- b4ca0a9c
- git-author:
- Sandeep Kumar <> (2012-07-10 12:01:07)
- git-committer:
- Vojtech Horky <vojtechhorky@…> (2012-07-10 12:01:07)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
rb4ca0a9c r1e01a35 201 201 * 202 202 */ 203 NO_TRACE static int cmdtab_compl(char *input, size_t size )203 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev) 204 204 { 205 205 const char *name = input; 206 206 207 207 size_t found = 0; 208 /* Maximum Match Length : Length of longest matching common substring in 209 case more than one match is found */ 210 size_t max_match_len = size; 211 size_t max_match_len_tmp = size; 212 size_t input_len = str_length(input); 208 213 link_t *pos = NULL; 209 214 const char *hint; 210 215 char *output = malloc(MAX_CMDLINE, 0); 216 char display = 'y'; 217 size_t hints_to_show = MAX_TAB_HINTS - 1; 218 size_t total_hints_shown = 0; 219 char continue_showing_hints = 'y'; 211 220 212 221 output[0] = 0; … … 218 227 pos = pos->next; 219 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("\nDisplay all %zu possibilities? (y or n)", found); 234 do { 235 display = indev_pop_character(indev); 236 } while (display != 'y' && display != 'n' && display != 'Y' && display != 'N'); 220 237 } 221 238 … … 225 242 while (cmdtab_search_one(name, &pos)) { 226 243 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 227 printf("%s (%s)\n", hlp->name, hlp->description); 244 245 if (display == 'y' || display == 'Y') { /* We are still showing hints */ 246 printf("%s (%s)\n", hlp->name, hlp->description); 247 --hints_to_show; 248 ++total_hints_shown; 249 250 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */ 251 printf("--More--"); 252 do { 253 continue_showing_hints = indev_pop_character(indev); 254 if (continue_showing_hints == 'y' || continue_showing_hints == 'Y' 255 || continue_showing_hints == ' ') { 256 hints_to_show = MAX_TAB_HINTS - 1; /* Display a full page again */ 257 break; 258 } 259 260 if (continue_showing_hints == 'n' || continue_showing_hints == 'N' 261 || continue_showing_hints == 'q' || continue_showing_hints == 'Q') { 262 display = 'n'; /* Stop displaying hints */ 263 break; 264 } 265 266 if (continue_showing_hints == '\n') { 267 hints_to_show = 1; /* Show one more hint */ 268 break; 269 } 270 } while (1); 271 272 printf("\r \r"); /* Delete the --More-- option */ 273 } 274 } 275 228 276 pos = pos->next; 229 } 277 for(max_match_len_tmp = 0; output[max_match_len_tmp] == hlp->name[input_len + max_match_len_tmp] 278 && max_match_len_tmp < max_match_len; ++max_match_len_tmp); 279 max_match_len = max_match_len_tmp; 280 } 281 /* keep only the characters common in all completions */ 282 output[max_match_len] = 0; 230 283 } 231 284 … … 294 347 if (beg == 0) { 295 348 /* Command completion */ 296 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );349 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 297 350 } else { 298 351 /* Symbol completion */ 299 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE) );352 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev); 300 353 } 301 354 302 355 if (found == 0) 303 356 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 357 358 /* We have hints, may be many. In case of more than one hint, 359 tmp will contain the common prefix. */ 315 360 size_t off = 0; 316 361 size_t i = 0; … … 320 365 i++; 321 366 } 367 368 if (found > 1) { 369 /* No unique hint, list was printed */ 370 printf("%s> ", prompt); 371 printf("%ls", current); 372 position += str_length(tmp); 373 print_cc('\b', wstr_length(current) - position); 374 continue; 375 } 376 377 /* We have a hint */ 322 378 323 379 printf("%ls", current + position); … … 540 596 /** Parse command line. 541 597 * 542 * @param cmdline Command line as read from input device. 598 * @param cmdline Command line as read from input device. 543 599 * @param size Size (in bytes) of the string. 544 600 *
Note:
See TracChangeset
for help on using the changeset viewer.