diff options
Diffstat (limited to 'util-linux/more.c')
-rw-r--r-- | util-linux/more.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/util-linux/more.c b/util-linux/more.c index 926cf5f26..fafc80403 100644 --- a/util-linux/more.c +++ b/util-linux/more.c | |||
@@ -35,6 +35,9 @@ | |||
35 | //usage:#define more_example_usage | 35 | //usage:#define more_example_usage |
36 | //usage: "$ dmesg | more\n" | 36 | //usage: "$ dmesg | more\n" |
37 | 37 | ||
38 | #if ENABLE_PLATFORM_MINGW32 | ||
39 | #include <conio.h> | ||
40 | #endif | ||
38 | #include "libbb.h" | 41 | #include "libbb.h" |
39 | #include "common_bufsiz.h" | 42 | #include "common_bufsiz.h" |
40 | 43 | ||
@@ -95,9 +98,13 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
95 | * is not a tty and turns into cat. This makes sense. */ | 98 | * is not a tty and turns into cat. This makes sense. */ |
96 | if (!isatty(STDOUT_FILENO)) | 99 | if (!isatty(STDOUT_FILENO)) |
97 | return bb_cat(argv); | 100 | return bb_cat(argv); |
101 | #if !ENABLE_PLATFORM_MINGW32 | ||
98 | tty = fopen_for_read(CURRENT_TTY); | 102 | tty = fopen_for_read(CURRENT_TTY); |
99 | if (!tty) | 103 | if (!tty) |
100 | return bb_cat(argv); | 104 | return bb_cat(argv); |
105 | #else | ||
106 | tty = stdin; | ||
107 | #endif | ||
101 | 108 | ||
102 | G.tty_fileno = fileno(tty); | 109 | G.tty_fileno = fileno(tty); |
103 | 110 | ||
@@ -151,8 +158,12 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
151 | * to get input from the user. | 158 | * to get input from the user. |
152 | */ | 159 | */ |
153 | for (;;) { | 160 | for (;;) { |
161 | #if !ENABLE_PLATFORM_MINGW32 | ||
154 | fflush_all(); | 162 | fflush_all(); |
155 | input = getc(tty); | 163 | input = getc(tty); |
164 | #else | ||
165 | input = _getch(); | ||
166 | #endif | ||
156 | input = tolower(input); | 167 | input = tolower(input); |
157 | /* Erase the last message */ | 168 | /* Erase the last message */ |
158 | printf("\r%*s\r", len, ""); | 169 | printf("\r%*s\r", len, ""); |
@@ -166,6 +177,10 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
166 | * commands, else we show help msg. */ | 177 | * commands, else we show help msg. */ |
167 | if (input == ' ' || input == '\n' || input == 'r') | 178 | if (input == ' ' || input == '\n' || input == 'r') |
168 | break; | 179 | break; |
180 | #if ENABLE_PLATFORM_MINGW32 | ||
181 | if (input == '\r') | ||
182 | break; | ||
183 | #endif | ||
169 | len = printf("(Enter:next line Space:next page Q:quit R:show the rest)"); | 184 | len = printf("(Enter:next line Space:next page Q:quit R:show the rest)"); |
170 | } | 185 | } |
171 | len = 0; | 186 | len = 0; |
@@ -200,6 +215,10 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
200 | * will move us to a new line. */ | 215 | * will move us to a new line. */ |
201 | if (++lines >= G.terminal_height || input == '\n') | 216 | if (++lines >= G.terminal_height || input == '\n') |
202 | please_display_more_prompt = 1; | 217 | please_display_more_prompt = 1; |
218 | #if ENABLE_PLATFORM_MINGW32 | ||
219 | if (input == '\r') | ||
220 | please_display_more_prompt = 1; | ||
221 | #endif | ||
203 | len = 0; | 222 | len = 0; |
204 | } | 223 | } |
205 | if (c != '\n' && wrap) { | 224 | if (c != '\n' && wrap) { |