Changeset aca4a04 in mainline


Ignore:
Timestamp:
2012-07-10T12:38:05Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
550af2b
Parents:
f0d7bd9
Message:

Extract common code into function

Location:
kernel/generic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/console/prompt.h

    rf0d7bd9 raca4a04  
    4040#define MAX_TAB_HINTS 37
    4141
     42extern bool console_prompt_display_all_hints(indev_t *, size_t);
    4243extern bool console_prompt_more_hints(indev_t *, size_t *);
    4344
  • kernel/generic/src/console/kconsole.c

    rf0d7bd9 raca4a04  
    231231        /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */
    232232        if (found > MAX_TAB_HINTS) {
    233                 printf("\nDisplay all %zu possibilities? (y or n)", found);
    234                 wchar_t display;
    235                 do {
    236                         display = indev_pop_character(indev);
    237                 } while (display != 'y' && display != 'n' && display != 'Y' && display != 'N');
    238                 continue_showing_hints = (display == 'y') || (display == 'Y');
     233                printf("\n");
     234                continue_showing_hints = console_prompt_display_all_hints(indev, found);
    239235        }
    240236       
  • kernel/generic/src/console/prompt.c

    rf0d7bd9 raca4a04  
    3939#include <console/prompt.h>
    4040
     41bool console_prompt_display_all_hints(indev_t *indev, size_t hints)
     42{
     43        printf("Display all %zu possibilities? (y or n)", hints);
     44
     45        while (true) {
     46                wchar_t answer = indev_pop_character(indev);
     47
     48                if (answer == 'y' || answer == 'Y') {
     49                        printf(" y");
     50                        return true;
     51                }
     52
     53                if (answer == 'n' || answer == 'N') {
     54                        printf(" n");
     55                        return false;
     56                }
     57        }
     58}
     59
    4160bool console_prompt_more_hints(indev_t *indev, size_t *display_hints)
    4261{
  • kernel/generic/src/debug/symtab.c

    rf0d7bd9 raca4a04  
    255255        /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */
    256256        if (found > MAX_TAB_HINTS) {
    257                 printf("\nDisplay all %zu possibilities? (y or n)", found);
    258                 wchar_t display;
    259                 do {
    260                         display = indev_pop_character(indev);
    261                 } while (display != 'y' && display != 'n' && display != 'Y' && display != 'N');
    262                 continue_showing_hints = (display == 'y') || (display == 'Y');
     257                printf("\n");
     258                continue_showing_hints = console_prompt_display_all_hints(indev, found);
    263259        }
    264260       
Note: See TracChangeset for help on using the changeset viewer.