home *** CD-ROM | disk | FTP | other *** search
- *** vis.c_orig Sun Oct 23 15:10:30 1988
- --- vis.c Sun Oct 23 15:47:01 1988
- ***************
- *** 27,32
- Sipe (rebel!george) to the point where Dan would no longer
- recoginze it. No copyright notices were embodied in the
- original net distribution.
- */
-
- #include <stdio.h>
-
- --- 27,36 -----
- Sipe (rebel!george) to the point where Dan would no longer
- recoginze it. No copyright notices were embodied in the
- original net distribution.
- +
- + Steve Alter (alter@ttidca.tti.com) added the -h option.
- +
- + Anton Chernoff (abc@lpi.uucp) added the -s option.
- */
-
- #include <stdio.h>
- ***************
- *** 120,125
- int sw;
- int badsw = 0;
- int baseline = BASELINE;
- long nextcycle;
- long curtime;
- long delta;
-
- --- 124,134 -----
- int sw;
- int badsw = 0;
- int baseline = BASELINE;
- + int doheader = 1;
- + int flagchanges = 0;
- + int flagch = 0;
- + int y, x;
- + int somode;
- long nextcycle;
- long curtime;
- long delta;
- ***************
- *** 134,140
- (void) signal(SIGINT, terminate); /* exit when requested */
- (void) signal(SIGPIPE, SIG_IGN); /* when output > screen size */
-
- ! while ((sw = getopt (argc, argv, "d:f")) != EOF)
- switch (sw) {
- case 'f':
- force = !force;
-
- --- 143,149 -----
- (void) signal(SIGINT, terminate); /* exit when requested */
- (void) signal(SIGPIPE, SIG_IGN); /* when output > screen size */
-
- ! while ((sw = getopt (argc, argv, "d:fhs")) != EOF)
- switch (sw) {
- case 'd':
- wait_delay = atoi(optarg);
- ***************
- *** 136,144
-
- while ((sw = getopt (argc, argv, "d:f")) != EOF)
- switch (sw) {
- - case 'f':
- - force = !force;
- - break;
- case 'd':
- wait_delay = atoi(optarg);
- if (wait_delay < 1) wait_delay = 1;
-
- --- 145,150 -----
-
- while ((sw = getopt (argc, argv, "d:fhs")) != EOF)
- switch (sw) {
- case 'd':
- wait_delay = atoi(optarg);
- if (wait_delay < 1) wait_delay = 1;
- ***************
- *** 143,148
- wait_delay = atoi(optarg);
- if (wait_delay < 1) wait_delay = 1;
- break;
- case '?':
- default:
- badsw = 1;
-
- --- 149,164 -----
- wait_delay = atoi(optarg);
- if (wait_delay < 1) wait_delay = 1;
- break;
- + case 'f':
- + force = !force;
- + break;
- + case 'h':
- + doheader = 0;
- + baseline = 0;
- + break;
- + case 's':
- + flagchanges = !flagchanges;
- + break;
- case '?':
- default:
- badsw = 1;
- ***************
- *** 152,158
- argc -= optind;
- if (badsw || argc < 1) {
- (void) fprintf(stderr,
- ! "Usage: %s [-d delay] [-f] command [args]\n", cmd);
- exit (-1);
- }
- initscr();
-
- --- 168,175 -----
- argc -= optind;
- if (badsw || argc < 1) {
- (void) fprintf(stderr,
- ! "Usage: %s [-d delay] [-f] [-h] [-s] command [args]\n",
- ! cmd);
- exit (-1);
- }
- initscr();
- ***************
- *** 163,176
- shcmd[2] = cmd;
- shcmd[3] = (char *) 0;
- }
- ! if (wait_delay != DELAY) {
- ! if (strlen(cmd) > COLS-39)
- ! (void) sprintf(cmd, "%.*s...", COLS-42, cmd);
- ! mvprintw(0, max((COLS-11)/2, strlen(cmd)+15), "Delay: %d",
- ! wait_delay);
- ! } else if (strlen(cmd) > COLS-21)
- ! (void) sprintf(cmd, "%.*s...", COLS-24, cmd);
- ! mvprintw(0, 0, "Command: %s", cmd);
- noecho(); /* don't let typing ruin our painting */
- nextcycle = time(0) + wait_delay;
- while (1) {
-
- --- 180,195 -----
- shcmd[2] = cmd;
- shcmd[3] = (char *) 0;
- }
- ! if (doheader) {
- ! if (wait_delay != DELAY) {
- ! if (strlen(cmd) > COLS-39)
- ! (void) sprintf(cmd, "%.*s...", COLS-42, cmd);
- ! mvprintw(0, max((COLS-11)/2, strlen(cmd)+15),
- ! "Delay: %d", wait_delay);
- ! } else if (strlen(cmd) > COLS-21)
- ! (void) sprintf(cmd, "%.*s...", COLS-24, cmd);
- ! mvprintw(0, 0, "Command: %s", cmd);
- ! }
- noecho(); /* don't let typing ruin our painting */
- nextcycle = time(0) + wait_delay;
- while (1) {
- ***************
- *** 174,180
- noecho(); /* don't let typing ruin our painting */
- nextcycle = time(0) + wait_delay;
- while (1) {
- ! mvprintw(0, COLS - 10, "Exec: %d", ++iteration);
- if (iteration == 1) refresh();
- (void) pipe(fildes);
- /* fork and exec redirecting stdout thru pipe to curses */
-
- --- 193,200 -----
- noecho(); /* don't let typing ruin our painting */
- nextcycle = time(0) + wait_delay;
- while (1) {
- ! if (doheader)
- ! mvprintw(0, COLS - 10, "Exec: %d", ++iteration);
- if (iteration == 1) refresh();
- (void) pipe(fildes);
- /* fork and exec redirecting stdout thru pipe to curses */
- ***************
- *** 191,196
- if (!(fp = fdopen(pinput, "r"))) terminate(-3);
- (void) close(poutput);
- curline = baseline;
- move(curline, 0);
- /* read the command's output */
- while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
-
- --- 211,217 -----
- if (!(fp = fdopen(pinput, "r"))) terminate(-3);
- (void) close(poutput);
- curline = baseline;
- + somode = 0;
- move(curline, 0);
- getyx(stdscr, y, x);
- /* read the command's output */
- ***************
- *** 192,197
- (void) close(poutput);
- curline = baseline;
- move(curline, 0);
- /* read the command's output */
- while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
- if (c == '\n') {
-
- --- 213,219 -----
- curline = baseline;
- somode = 0;
- move(curline, 0);
- + getyx(stdscr, y, x);
- /* read the command's output */
- while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
- {
- ***************
- *** 194,204
- move(curline, 0);
- /* read the command's output */
- while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
- ! if (c == '\n') {
- ! clrtoeol();
- ! move(++curline, 0);
- ! }
- ! else addch(c);
- if (ferror(fp)) terminate(-4);
- if (baseline > 1 && curline == LINES && c != EOF)
- --baseline;
-
- --- 216,250 -----
- getyx(stdscr, y, x);
- /* read the command's output */
- while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
- ! {
- !
- ! if (c == '\n') {
- ! if (x < COLS-1) clrtoeol();
- ! move(++curline, 0);
- ! getyx(stdscr, y, x);
- ! }
- ! else {
- ! if (x >= COLS-1)
- ! continue;
- ! getyx(stdscr, y, x);
- ! if (flagch)
- ! if ((c & 0177) == (inch() & 0177)) {
- ! if (somode) {
- ! standend();
- ! somode = 0;
- ! }
- ! }
- ! else {
- ! if (!somode) {
- ! standout();
- ! somode = 1;
- ! }
- ! }
- ! addch(c);
- ! }
- ! }
- ! if (somode) standend();
- ! flagch = flagchanges;
- if (ferror(fp)) terminate(-4);
- if (baseline > 1 && curline == LINES && c != EOF)
- --baseline;
- ***************
- *** 210,216
- (void) wait(&status); /* wait for child to terminate */
- /* if child didn't terminate properly, w_status will != 0 */
- if (status.w_status) {
- ! mvprintw(0, COLS - 12, "!");
- if (!force) terminate(status.w_status);
- }
- curtime = time(0);
-
- --- 256,263 -----
- (void) wait(&status); /* wait for child to terminate */
- /* if child didn't terminate properly, w_status will != 0 */
- if (status.w_status) {
- ! if (doheader)
- ! mvprintw(0, COLS - 12, "!");
- if (!force) terminate(status.w_status);
- }
- curtime = time(0);
-