| 1 | #ifdef RCSID |
| 2 | static char RCSid[] = |
| 3 | "$Header$"; |
| 4 | #endif |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved. |
| 8 | * |
| 9 | * Please see the accompanying license file, LICENSE.TXT, for information |
| 10 | * on using and copying this software. |
| 11 | */ |
| 12 | /* |
| 13 | Name |
| 14 | vmconmor.cpp - TADS 3 console input/output - MORE-enabled/text-only version |
| 15 | Function |
| 16 | There are three possible configurations for the output formatter. |
| 17 | For each configuration, there is one extra file that must be linked |
| 18 | into the system when building an application; the choice of this |
| 19 | file determines the configuration of the system. The three choices |
| 20 | are: |
| 21 | |
| 22 | Text only, MORE mode enabled - vmconmor.cpp |
| 23 | Text only, OS-level MORE handling - vmconnom.cpp |
| 24 | HTML mode - vmconhtm.cpp |
| 25 | Notes |
| 26 | |
| 27 | Modified |
| 28 | 09/06/99 MJRoberts - Creation |
| 29 | */ |
| 30 | |
| 31 | #include "os.h" |
| 32 | #include "t3std.h" |
| 33 | #include "vmconsol.h" |
| 34 | |
| 35 | |
| 36 | /* ------------------------------------------------------------------------ */ |
| 37 | /* |
| 38 | * This is a MORE-enabled configuration, so indicate that we should handle |
| 39 | * MORE mode in the formatter layer. |
| 40 | */ |
| 41 | int CVmFormatter::formatter_more_mode() const |
| 42 | { |
| 43 | return TRUE; |
| 44 | } |
| 45 | |
| 46 | /* ------------------------------------------------------------------------ */ |
| 47 | /* |
| 48 | * This is a non-HTML version, so we turn off the HTML-target flag |
| 49 | */ |
| 50 | int CVmFormatter::get_init_html_target() const |
| 51 | { |
| 52 | return FALSE; |
| 53 | } |
| 54 | |
| 55 | /* ------------------------------------------------------------------------ */ |
| 56 | /* |
| 57 | * This is a text-only (non-HTML) version, so the HTML start/end functions |
| 58 | * do nothing |
| 59 | */ |
| 60 | void CVmFormatterMain::start_html_in_os() |
| 61 | { |
| 62 | } |
| 63 | |
| 64 | void CVmFormatterMain::end_html_in_os() |
| 65 | { |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | * This is a MORE-enabled configuration, so indicate that we handle line |
| 70 | * wrapping ourselves (not in the OS layer). |
| 71 | */ |
| 72 | int CVmFormatterMain::get_os_line_wrap() |
| 73 | { |
| 74 | return FALSE; |
| 75 | } |
| 76 | |
| 77 | /* ------------------------------------------------------------------------ */ |
| 78 | /* |
| 79 | * This is a MORE-mode version, so show a MORE prompt ourselves |
| 80 | */ |
| 81 | void CVmConsole::show_con_more_prompt(VMG0_) |
| 82 | { |
| 83 | int done; |
| 84 | int next_page; |
| 85 | |
| 86 | /* display the "MORE" prompt */ |
| 87 | disp_str_->print_to_os("[More]"); |
| 88 | disp_str_->flush_to_os(); |
| 89 | |
| 90 | /* wait for an acceptable keystroke */ |
| 91 | for (done = FALSE ; !done ; ) |
| 92 | { |
| 93 | os_event_info_t evt; |
| 94 | |
| 95 | /* get an event */ |
| 96 | switch(os_get_event(0, FALSE, &evt)) |
| 97 | { |
| 98 | case OS_EVT_KEY: |
| 99 | switch(evt.key[0]) |
| 100 | { |
| 101 | case ' ': |
| 102 | /* stop waiting, show one page */ |
| 103 | done = TRUE; |
| 104 | next_page = TRUE; |
| 105 | break; |
| 106 | |
| 107 | case '\r': |
| 108 | case '\n': |
| 109 | case 0x2028: /* unicode line separator character */ |
| 110 | /* stop waiting, show one line */ |
| 111 | done = TRUE; |
| 112 | next_page = FALSE; |
| 113 | break; |
| 114 | |
| 115 | default: |
| 116 | /* ignore any other keystrokes */ |
| 117 | break; |
| 118 | } |
| 119 | break; |
| 120 | |
| 121 | case OS_EVT_EOF: |
| 122 | /* end of file - there's nothing to wait for now */ |
| 123 | done = TRUE; |
| 124 | next_page = TRUE; |
| 125 | |
| 126 | /* stop showing [more] prompts, as the user can't respond */ |
| 127 | G_os_moremode = FALSE; |
| 128 | break; |
| 129 | |
| 130 | default: |
| 131 | /* ignore other events */ |
| 132 | break; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * Remove the prompt from the screen by backing up and overwriting |
| 138 | * it with spaces. (Note that this assumes that we're running in |
| 139 | * some kind of terminal or character mode with a fixed-pitch font; |
| 140 | * if that's not the case, the OS layer should be taking |
| 141 | * responsibility for pagination anyway, so this code shouldn't be |
| 142 | * in use in the first place.) |
| 143 | */ |
| 144 | disp_str_->print_to_os( "\r \r" ); |
| 145 | |
| 146 | /* |
| 147 | * if they pressed the space key, it means that we should show an |
| 148 | * entire new page, so reset the line count to zero; otherwise, |
| 149 | * we'll want to display another MORE prompt at the very next line, |
| 150 | * so leave the line count alone |
| 151 | */ |
| 152 | if (next_page) |
| 153 | disp_str_->reset_line_count(FALSE); |
| 154 | } |
| 155 |