aboutsummaryrefslogtreecommitdiff
path: root/util-linux/more.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/more.c')
-rw-r--r--util-linux/more.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/util-linux/more.c b/util-linux/more.c
index 934b30f8a..d04c17f90 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
@@ -100,9 +103,13 @@ int more_main(int argc UNUSED_PARAM, char **argv)
100 * is not a tty and turns into cat. This makes sense. */ 103 * is not a tty and turns into cat. This makes sense. */
101 if (!isatty(STDOUT_FILENO)) 104 if (!isatty(STDOUT_FILENO))
102 return bb_cat(argv); 105 return bb_cat(argv);
106#if !ENABLE_PLATFORM_MINGW32
103 cin = fopen_for_read(CURRENT_TTY); 107 cin = fopen_for_read(CURRENT_TTY);
104 if (!cin) 108 if (!cin)
105 return bb_cat(argv); 109 return bb_cat(argv);
110#else
111 cin = stdin;
112#endif
106 113
107 if (ENABLE_FEATURE_USE_TERMIOS) { 114 if (ENABLE_FEATURE_USE_TERMIOS) {
108 cin_fileno = fileno(cin); 115 cin_fileno = fileno(cin);
@@ -158,7 +165,11 @@ int more_main(int argc UNUSED_PARAM, char **argv)
158 * to get input from the user. 165 * to get input from the user.
159 */ 166 */
160 for (;;) { 167 for (;;) {
168#if !ENABLE_PLATFORM_MINGW32
161 input = getc(cin); 169 input = getc(cin);
170#else
171 input = _getch();
172#endif
162 input = tolower(input); 173 input = tolower(input);
163 if (!ENABLE_FEATURE_USE_TERMIOS) 174 if (!ENABLE_FEATURE_USE_TERMIOS)
164 printf("\033[A"); /* cursor up */ 175 printf("\033[A"); /* cursor up */
@@ -172,6 +183,10 @@ int more_main(int argc UNUSED_PARAM, char **argv)
172 * commands, else we show help msg. */ 183 * commands, else we show help msg. */
173 if (input == ' ' || input == '\n' || input == 'q' || input == 'r') 184 if (input == ' ' || input == '\n' || input == 'q' || input == 'r')
174 break; 185 break;
186#if ENABLE_PLATFORM_MINGW32
187 if (input == '\r')
188 break;
189#endif
175 len = printf("(Enter:next line Space:next page Q:quit R:show the rest)"); 190 len = printf("(Enter:next line Space:next page Q:quit R:show the rest)");
176 } 191 }
177 len = 0; 192 len = 0;
@@ -212,6 +227,10 @@ int more_main(int argc UNUSED_PARAM, char **argv)
212 * will move us to a new line. */ 227 * will move us to a new line. */
213 if (++lines >= terminal_height || input == '\n') 228 if (++lines >= terminal_height || input == '\n')
214 please_display_more_prompt = 1; 229 please_display_more_prompt = 1;
230#if ENABLE_PLATFORM_MINGW32
231 if (input == '\r')
232 please_display_more_prompt = 1;
233#endif
215 len = 0; 234 len = 0;
216 } 235 }
217 if (c != '\n' && wrap) { 236 if (c != '\n' && wrap) {