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

Create function for displaying —more— prompt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/kconsole.c

    r1e01a35 rf0d7bd9  
    4343#include <console/chardev.h>
    4444#include <console/cmd.h>
     45#include <console/prompt.h>
    4546#include <print.h>
    4647#include <panic.h>
     
    214215        const char *hint;
    215216        char *output = malloc(MAX_CMDLINE, 0);
    216         char display = 'y';
    217217        size_t hints_to_show = MAX_TAB_HINTS - 1;
    218218        size_t total_hints_shown = 0;
    219         char continue_showing_hints = 'y';
     219        bool continue_showing_hints = true;
    220220       
    221221        output[0] = 0;
     
    232232        if (found > MAX_TAB_HINTS) {
    233233                printf("\nDisplay all %zu possibilities? (y or n)", found);
     234                wchar_t display;
    234235                do {
    235236                        display = indev_pop_character(indev);
    236237                } while (display != 'y' && display != 'n' && display != 'Y' && display != 'N');
     238                continue_showing_hints = (display == 'y') || (display == 'Y');
    237239        }
    238240       
     
    243245                        cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link);
    244246
    245                         if (display == 'y' || display == 'Y') { /* We are still showing hints */
     247                        if (continue_showing_hints) {
    246248                                printf("%s (%s)\n", hlp->name, hlp->description);
    247249                                --hints_to_show;
     
    249251
    250252                                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 */
     253                                        continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show);
    273254                                }
    274255                        }
Note: See TracChangeset for help on using the changeset viewer.