-#ifdef BB_FEATURE_USE_TERMIOS
- input = getc(cin);
-#else
- input = getc(stdin);
-#endif
-
-#ifdef BB_FEATURE_USE_TERMIOS
- /* Erase the "More" message */
- while (--len >= 0)
- putc('\b', stdout);
- while (++len <= terminal_width)
- putc(' ', stdout);
- while (--len >= 0)
- putc('\b', stdout);
- fflush(stdout);
-#endif
- len=0;
+ for (;;) {
+ input = getc(cin);
+ input = tolower(input);
+ if (!ENABLE_FEATURE_USE_TERMIOS)
+ printf("\033[A"); /* cursor up */
+ /* Erase the last message */
+ printf("\r%*s\r", len, "");
+
+ /* Due to various multibyte escape
+ * sequences, it's not ok to accept
+ * any input as a command to scroll
+ * the screen. We only allow known
+ * commands, else we show help msg. */
+ if (input == ' ' || input == '\n' || input == 'q' || input == 'r')
+ break;
+ len = printf("(Enter:next line Space:next page Q:quit R:show the rest)");
+ }
+ len = 0;
+ lines = 0;
+ please_display_more_prompt = 0;
+
+ if (input == 'q')
+ goto end;
+
+ /* The user may have resized the terminal.
+ * Re-read the dimensions. */
+ if (ENABLE_FEATURE_USE_TERMIOS) {
+ get_terminal_width_height(cin_fileno, &terminal_width, &terminal_height);
+ terminal_height -= 1;
+ }