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.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/util-linux/more.c b/util-linux/more.c
index bffe6ee5e..0be8e0b9b 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
@@ -59,6 +62,7 @@ static void tcsetattr_tty_TCSANOW(struct termios *settings)
59 tcsetattr(G.tty_fileno, TCSANOW, settings); 62 tcsetattr(G.tty_fileno, TCSANOW, settings);
60} 63}
61 64
65#if !ENABLE_PLATFORM_MINGW32
62static void gotsig(int sig UNUSED_PARAM) 66static void gotsig(int sig UNUSED_PARAM)
63{ 67{
64 /* bb_putchar_stderr doesn't use stdio buffering, 68 /* bb_putchar_stderr doesn't use stdio buffering,
@@ -67,6 +71,7 @@ static void gotsig(int sig UNUSED_PARAM)
67 tcsetattr_tty_TCSANOW(&G.initial_settings); 71 tcsetattr_tty_TCSANOW(&G.initial_settings);
68 _exit_FAILURE(); 72 _exit_FAILURE();
69} 73}
74#endif
70 75
71#define CONVERTED_TAB_SIZE 8 76#define CONVERTED_TAB_SIZE 8
72 77
@@ -96,9 +101,13 @@ int more_main(int argc UNUSED_PARAM, char **argv)
96 * is not a tty and turns into cat. This makes sense. */ 101 * is not a tty and turns into cat. This makes sense. */
97 if (!isatty(STDOUT_FILENO)) 102 if (!isatty(STDOUT_FILENO))
98 return bb_cat(argv); 103 return bb_cat(argv);
104#if !ENABLE_PLATFORM_MINGW32
99 tty = fopen_for_read(CURRENT_TTY); 105 tty = fopen_for_read(CURRENT_TTY);
100 if (!tty) 106 if (!tty)
101 return bb_cat(argv); 107 return bb_cat(argv);
108#else
109 tty = stdin;
110#endif
102 111
103 G.tty_fileno = fileno(tty); 112 G.tty_fileno = fileno(tty);
104 113
@@ -153,6 +162,11 @@ int more_main(int argc UNUSED_PARAM, char **argv)
153 */ 162 */
154 for (;;) { 163 for (;;) {
155 fflush_all(); 164 fflush_all();
165#if ENABLE_PLATFORM_MINGW32
166 if (!(terminal_mode(FALSE) & VT_INPUT))
167 input = _getch();
168 else
169#endif
156 input = getc(tty); 170 input = getc(tty);
157 input = tolower(input); 171 input = tolower(input);
158 /* Erase the last message */ 172 /* Erase the last message */
@@ -167,6 +181,10 @@ int more_main(int argc UNUSED_PARAM, char **argv)
167 * commands, else we show help msg. */ 181 * commands, else we show help msg. */
168 if (input == ' ' || input == '\n' || input == 'r') 182 if (input == ' ' || input == '\n' || input == 'r')
169 break; 183 break;
184#if ENABLE_PLATFORM_MINGW32
185 if (input == '\r')
186 break;
187#endif
170 len = printf("(Enter:next line Space:next page Q:quit R:show the rest)"); 188 len = printf("(Enter:next line Space:next page Q:quit R:show the rest)");
171 } 189 }
172 len = 0; 190 len = 0;
@@ -201,6 +219,10 @@ int more_main(int argc UNUSED_PARAM, char **argv)
201 * will move us to a new line. */ 219 * will move us to a new line. */
202 if (++lines >= G.terminal_height || input == '\n') 220 if (++lines >= G.terminal_height || input == '\n')
203 please_display_more_prompt = 1; 221 please_display_more_prompt = 1;
222#if ENABLE_PLATFORM_MINGW32
223 if (input == '\r')
224 please_display_more_prompt = 1;
225#endif
204 len = 0; 226 len = 0;
205 } 227 }
206 if (c != '\n' && wrap) { 228 if (c != '\n' && wrap) {