- (void) initscr(); /* initialize the curses library */
- keypad(stdscr, TRUE); /* enable keyboard mapping */
- (void) nonl(); /* tell curses not to do NL->CR/NL on output */
- (void) cbreak(); /* take input chars one at a time, no wait for \n */
- (void) noecho(); /* don't echo input */
- idlok(stdscr, TRUE); /* allow use of insert/delete line */
-
- /* slurp the file */
- for (lptr = &lines[0]; fgets(buf, BUFSIZ, fp) != (char *)NULL; lptr++) {
- char temp[BUFSIZ], *s, *d;
- int col;
-
- if (lptr - lines >= MAXLINES) {
- endwin();
- (void) fprintf(stderr, "%s: %s is too large\n", argv[0], argv[1]);
- return EXIT_FAILURE;
- }
-
- /* convert tabs so that shift will work properly */
- for (s = buf, d = temp, col = 0; (*d = *s) != '\0'; s++) {
- if (*d == '\n') {
- *d = '\0';
- break;
- } else if (*d == '\t') {
- col = (col | 7) + 1;
- while ((d-temp) != col)
- *d++ = ' ';
- } else if (isprint(*d)) {
- col++;
- d++;
- } else {
- sprintf(d, "\\%03o", *s);
- d += strlen(d);
- col = (d - temp);
+int
+main(int argc, char *argv[])
+{
+ static const char *help[] =
+ {
+ "Commands:",
+ " q,^Q,ESC - quit this program",
+ "",
+ " p,<Up> - scroll the viewport up by one row",
+ " n,<Down> - scroll the viewport down by one row",
+ " l,<Left> - scroll the viewport left by one column",
+ " r,<Right> - scroll the viewport right by one column",
+ " <,> - scroll the viewport left/right by 8 columns",
+ "",
+ " h,<Home> - scroll the viewport to top of file",
+ " ^F,<PageDn> - scroll to the next page",
+ " ^B,<PageUp> - scroll to the previous page",
+ " e,<End> - scroll the viewport to end of file",
+ "",
+ " ^L - repaint using redrawwin()",
+ "",
+ " 0 through 9 - enter digits for count",
+ " s - use entered count for halfdelay() parameter",
+ " - if no entered count, stop nodelay()",
+ " <space> - begin nodelay()",
+ 0
+ };
+
+ int i;
+ int my_delay = 0;
+ NCURSES_CH_T **olptr;
+ int value = 0;
+ bool done = FALSE;
+ bool got_number = FALSE;
+ bool ignore_sigs = FALSE;
+ bool single_step = FALSE;
+ const char *my_label = "Input";
+
+ setlocale(LC_ALL, "");
+
+ while ((i = getopt(argc, argv, "cinstT:")) != -1) {
+ switch (i) {
+ case 'c':
+ try_color = TRUE;
+ break;
+ case 'i':
+ ignore_sigs = TRUE;
+ break;
+#if USE_WIDEC_SUPPORT
+ case 'n':
+ n_option = TRUE;
+ break;
+#endif
+ case 's':
+ single_step = TRUE;
+ break;
+#ifdef TRACE
+ case 'T':
+ {
+ char *next = 0;
+ int tvalue = (int) strtol(optarg, &next, 0);
+ if (tvalue < 0 || (next != 0 && *next != 0))
+ usage();
+ trace((unsigned) tvalue);