[f0d7bd9] | 1 | /*
|
---|
| 2 | * Copyright (c) 2012 Sandeep Kumar
|
---|
| 3 | * Copyright (c) 2012 Vojtech Horky
|
---|
| 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | /** @addtogroup genericconsole
|
---|
| 31 | * @{
|
---|
| 32 | */
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
| 35 | * @file
|
---|
| 36 | * @brief Kernel console special prompts.
|
---|
| 37 | */
|
---|
| 38 |
|
---|
| 39 | #include <console/prompt.h>
|
---|
| 40 |
|
---|
[aca4a04] | 41 | bool 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 |
|
---|
[f0d7bd9] | 60 | bool console_prompt_more_hints(indev_t *indev, size_t *display_hints)
|
---|
| 61 | {
|
---|
| 62 | ASSERT(display_hints != NULL);
|
---|
| 63 |
|
---|
| 64 | printf("--More--");
|
---|
| 65 | while (true) {
|
---|
| 66 | wchar_t continue_showing_hints = indev_pop_character(indev);
|
---|
| 67 | /* Display a full page again? */
|
---|
| 68 | if (continue_showing_hints == 'y'
|
---|
| 69 | || continue_showing_hints == 'Y'
|
---|
| 70 | || continue_showing_hints == ' ') {
|
---|
| 71 | *display_hints = MAX_TAB_HINTS - 1;
|
---|
| 72 | break;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | /* Stop displaying hints? */
|
---|
| 76 | if (continue_showing_hints == 'n'
|
---|
| 77 | || continue_showing_hints == 'N'
|
---|
| 78 | || continue_showing_hints == 'q'
|
---|
| 79 | || continue_showing_hints == 'Q') {
|
---|
| 80 | *display_hints = 0;
|
---|
| 81 | break;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /* Show one more hint? */
|
---|
| 85 | if (continue_showing_hints == '\n') {
|
---|
| 86 | *display_hints = 1;
|
---|
| 87 | break;
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | /* Delete the --More-- option */
|
---|
| 92 | printf("\r \r");
|
---|
| 93 |
|
---|
| 94 | return *display_hints > 0;
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | /** @}
|
---|
| 98 | */
|
---|