aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2015-08-04 13:02:26 +0100
committerRon Yorston <rmy@pobox.com>2015-08-04 13:06:42 +0100
commit6fe172c34f6c559a0028d506dabd428ef640d388 (patch)
tree2291a26748185b719cde2de7e9cd15f688741d7e
parent49996fd7cb61c187e7194432bd37d6987d4257ab (diff)
downloadbusybox-w32-6fe172c34f6c559a0028d506dabd428ef640d388.tar.gz
busybox-w32-6fe172c34f6c559a0028d506dabd428ef640d388.tar.bz2
busybox-w32-6fe172c34f6c559a0028d506dabd428ef640d388.zip
more: WIN32 port
This isn't enabled by default because Windows has `more.com` as a pager. Note that enabling `more` also turns on the use of termios for screen manipulation. You'll need to turn that off by going to BusyBox Settings -> BusyBox Library Tuning.
-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 359571397..29984df8c 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -22,6 +22,9 @@
22//usage:#define more_example_usage 22//usage:#define more_example_usage
23//usage: "$ dmesg | more\n" 23//usage: "$ dmesg | more\n"
24 24
25#if ENABLE_PLATFORM_MINGW32
26#include <conio.h>
27#endif
25#include "libbb.h" 28#include "libbb.h"
26 29
27/* Support for FEATURE_USE_TERMIOS */ 30/* Support for FEATURE_USE_TERMIOS */
@@ -77,9 +80,13 @@ int more_main(int argc UNUSED_PARAM, char **argv)
77 * is not a tty and turns into cat. This makes sense. */ 80 * is not a tty and turns into cat. This makes sense. */
78 if (!isatty(STDOUT_FILENO)) 81 if (!isatty(STDOUT_FILENO))
79 return bb_cat(argv); 82 return bb_cat(argv);
83#if !ENABLE_PLATFORM_MINGW32
80 cin = fopen_for_read(CURRENT_TTY); 84 cin = fopen_for_read(CURRENT_TTY);
81 if (!cin) 85 if (!cin)
82 return bb_cat(argv); 86 return bb_cat(argv);
87#else
88 cin = stdin;
89#endif
83 90
84 if (ENABLE_FEATURE_USE_TERMIOS) { 91 if (ENABLE_FEATURE_USE_TERMIOS) {
85 cin_fileno = fileno(cin); 92 cin_fileno = fileno(cin);
@@ -135,7 +142,11 @@ int more_main(int argc UNUSED_PARAM, char **argv)
135 * to get input from the user. 142 * to get input from the user.
136 */ 143 */
137 for (;;) { 144 for (;;) {
145#if !ENABLE_PLATFORM_MINGW32
138 input = getc(cin); 146 input = getc(cin);
147#else
148 input = _getch();
149#endif
139 input = tolower(input); 150 input = tolower(input);
140 if (!ENABLE_FEATURE_USE_TERMIOS) 151 if (!ENABLE_FEATURE_USE_TERMIOS)
141 printf("\033[A"); /* cursor up */ 152 printf("\033[A"); /* cursor up */
@@ -149,6 +160,10 @@ int more_main(int argc UNUSED_PARAM, char **argv)
149 * commands, else we show help msg. */ 160 * commands, else we show help msg. */
150 if (input == ' ' || input == '\n' || input == 'q' || input == 'r') 161 if (input == ' ' || input == '\n' || input == 'q' || input == 'r')
151 break; 162 break;
163#if ENABLE_PLATFORM_MINGW32
164 if (input == '\r')
165 break;
166#endif
152 len = printf("(Enter:next line Space:next page Q:quit R:show the rest)"); 167 len = printf("(Enter:next line Space:next page Q:quit R:show the rest)");
153 } 168 }
154 len = 0; 169 len = 0;
@@ -189,6 +204,10 @@ int more_main(int argc UNUSED_PARAM, char **argv)
189 * will move us to a new line. */ 204 * will move us to a new line. */
190 if (++lines >= terminal_height || input == '\n') 205 if (++lines >= terminal_height || input == '\n')
191 please_display_more_prompt = 1; 206 please_display_more_prompt = 1;
207#if ENABLE_PLATFORM_MINGW32
208 if (input == '\r')
209 please_display_more_prompt = 1;
210#endif
192 len = 0; 211 len = 0;
193 } 212 }
194 if (c != '\n' && wrap) { 213 if (c != '\n' && wrap) {