void prompt(char *filename) { if (clreol) cleareol(); else if (promptlen > 0) kill_line(); if (!hard) { promptlen = 8; if (Senter && Sexit) { tputs(Senter, 1, putch); promptlen += (2 * soglitch); } if (clreol) cleareol(); fputs("--More--", stdout); if (filename != NULL) promptlen += printf("(Next file: %s)", filename); else if (!no_intty) promptlen += printf("(%d%%)", (int)((file_pos * 100) / file_size)); if (dum_opt) { fputs(DUM_PROMPT, stdout); promptlen += sizeof(DUM_PROMPT) - 1; } if (Senter && Sexit) tputs(Sexit, 1, putch); if (clreol) clreos(); fflush(stdout); } else write(STDERR_FILENO, &bell, 1); inwait++; }
static void prompt(char *filename) { if (clreol) cleareol(); else if (promptlen > 0) kill_line(); if (!hard) { promptlen = 0; if (Senter && Sexit) { putstring(Senter); promptlen += (2 * soglitch); } if (clreol) cleareol(); promptlen += printf(_("--More--")); if (filename != NULL) { promptlen += printf(_("(Next file: %s)"), filename); } else if (!no_intty) { promptlen += printf("(%d%%)", (int)((file_pos * 100) / file_size)); } if (dum_opt) { promptlen += printf(_("[Press space to continue, 'q' to quit.]")); } if (Senter && Sexit) putstring(Sexit); if (clreol) clreos(); fflush(stdout); } else ringbell(); inwait++; }
/* * Clean up terminal state and exit. Also come here if interrupt signal received */ void __dead end_it(void) { reset_tty(); if (clreol) { putchar('\r'); clreos(); fflush(stdout); } else if (promptlen > 0) { kill_line(); fflush(stdout); } else write(STDERR_FILENO, "\n", 1); _exit(0); }
/* * Print out the contents of the file f, one screenful at a time. */ void screen(FILE *f, int num_lines) { int ch; int nchars; int length; /* length of current line */ static int prev_len = 1; /* length of previous line */ for (;;) { while (num_lines > 0 && !Pause) { if ((nchars = get_line(f, &length)) == EOF) { if (clreol) clreos(); return; } if (ssp_opt && length == 0 && prev_len == 0) continue; prev_len = length; if (bad_so || (Senter && *Senter == ' ' && promptlen > 0)) erasep(0); /* * Must clear before drawing line since tabs on some * terminals do not erase what they tab over. */ if (clreol) cleareol(); prbuf(Line, length); if (nchars < promptlen) { /* erasep() sets promptlen to 0 */ erasep(nchars); } else promptlen = 0; #if 0 /* XXX - is this needed? */ if (clreol) { /* must clear again in case we wrapped * */ cleareol(); } #endif if (nchars < Mcol || !fold_opt) { /* will turn off UL if necessary */ prbuf("\n", 1); } if (nchars == STOP) break; num_lines--; } if (pstate) { tputs(ULexit, 1, putch); pstate = 0; } fflush(stdout); if ((ch = Getc(f)) == EOF) { if (clreol) clreos(); return; } if (Pause && clreol) clreos(); Ungetc(ch, f); Pause = 0; startup = 0; if ((num_lines = command(NULL, f)) == 0) return; if (hard && promptlen > 0) erasep(0); if (noscroll && num_lines >= dlines) { if (clreol) home(); else doclear(); } /* * XXX - should store the *first* line on the screen, * not the last (but we don't know the file position). * Fixing this requires keeping an arry of dline off_ts * and updating each one when a new line is started. */ screen_start.line = Currline; screen_start.chrctr = Ftell(f); } }