-#ifdef BB_FEATURE_USE_TERMIOS
- cin = fopen("/dev/tty", "r");
- if (!cin)
- cin = fopen("/dev/console", "r");
- getTermSettings(fileno(cin), &initial_settings);
- new_settings = initial_settings;
- new_settings.c_cc[VMIN] = 1;
- new_settings.c_cc[VTIME] = 0;
- new_settings.c_lflag &= ~ICANON;
- new_settings.c_lflag &= ~ECHO;
- setTermSettings(fileno(cin), &new_settings);
-
-# ifdef BB_FEATURE_AUTOWIDTH
- ioctl(fileno(stdout), TIOCGWINSZ, &win);
- if (win.ws_row > 4)
- terminal_height = win.ws_row - 2;
- if (win.ws_col > 0)
- terminal_width = win.ws_col - 1;
-# endif
-
- (void) signal(SIGINT, gotsig);
- (void) signal(SIGQUIT, gotsig);
- (void) signal(SIGTERM, gotsig);
-
-#endif
- while ((c = getc(file)) != EOF) {
- if (please_display_more_prompt) {
- int len = 0;
-
- please_display_more_prompt = 0;
- lines = 0;
+ please_display_more_prompt = 0;
+ /* never returns w, h <= 1 */
+ get_terminal_width_height(fileno(cin), &terminal_width, &terminal_height);
+ terminal_height -= 1;
+
+ len = 0;
+ lines = 0;
+ while (spaces || (c = getc(file)) != EOF) {
+ int wrap;
+ if (spaces)
+ spaces--;
+ loop_top:
+ if (input != 'r' && please_display_more_prompt) {