home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume5 / vis.patch1 / vis.c.diff < prev    next >
Encoding:
Text File  |  1989-02-03  |  7.0 KB  |  282 lines

  1. *** vis.c_orig    Sun Oct 23 15:10:30 1988
  2. --- vis.c    Sun Oct 23 15:47:01 1988
  3. ***************
  4. *** 27,32
  5.       Sipe (rebel!george) to the point where Dan would no longer
  6.       recoginze it.  No copyright notices were embodied in the
  7.       original net distribution.
  8.   */
  9.   
  10.   #include <stdio.h>
  11.  
  12. --- 27,36 -----
  13.       Sipe (rebel!george) to the point where Dan would no longer
  14.       recoginze it.  No copyright notices were embodied in the
  15.       original net distribution.
  16. +     Steve Alter (alter@ttidca.tti.com) added the -h option.
  17. +     Anton Chernoff (abc@lpi.uucp) added the -s option.
  18.   */
  19.   
  20.   #include <stdio.h>
  21. ***************
  22. *** 120,125
  23.       int sw;
  24.       int badsw = 0;
  25.       int baseline = BASELINE;
  26.       long nextcycle;
  27.       long curtime;
  28.       long delta;
  29.  
  30. --- 124,134 -----
  31.       int sw;
  32.       int badsw = 0;
  33.       int baseline = BASELINE;
  34. +     int doheader = 1;
  35. +     int flagchanges = 0;
  36. +     int flagch = 0;
  37. +     int y, x;
  38. +     int somode;
  39.       long nextcycle;
  40.       long curtime;
  41.       long delta;
  42. ***************
  43. *** 134,140
  44.       (void) signal(SIGINT, terminate);    /* exit when requested */
  45.       (void) signal(SIGPIPE, SIG_IGN);    /* when output > screen size */
  46.   
  47. !     while ((sw = getopt (argc, argv, "d:f")) != EOF)
  48.           switch (sw) {
  49.               case 'f':
  50.                   force = !force;
  51.  
  52. --- 143,149 -----
  53.       (void) signal(SIGINT, terminate);    /* exit when requested */
  54.       (void) signal(SIGPIPE, SIG_IGN);    /* when output > screen size */
  55.   
  56. !     while ((sw = getopt (argc, argv, "d:fhs")) != EOF)
  57.           switch (sw) {
  58.               case 'd':
  59.                   wait_delay = atoi(optarg);
  60. ***************
  61. *** 136,144
  62.   
  63.       while ((sw = getopt (argc, argv, "d:f")) != EOF)
  64.           switch (sw) {
  65. -             case 'f':
  66. -                 force = !force;
  67. -                 break;
  68.               case 'd':
  69.                   wait_delay = atoi(optarg);
  70.                   if (wait_delay < 1) wait_delay = 1;
  71.  
  72. --- 145,150 -----
  73.   
  74.       while ((sw = getopt (argc, argv, "d:fhs")) != EOF)
  75.           switch (sw) {
  76.               case 'd':
  77.                   wait_delay = atoi(optarg);
  78.                   if (wait_delay < 1) wait_delay = 1;
  79. ***************
  80. *** 143,148
  81.                   wait_delay = atoi(optarg);
  82.                   if (wait_delay < 1) wait_delay = 1;
  83.                   break;
  84.               case '?':
  85.               default:
  86.                   badsw = 1;
  87.  
  88. --- 149,164 -----
  89.                   wait_delay = atoi(optarg);
  90.                   if (wait_delay < 1) wait_delay = 1;
  91.                   break;
  92. +             case 'f':
  93. +                 force = !force;
  94. +                 break;
  95. +             case 'h':
  96. +                 doheader = 0;
  97. +                 baseline = 0;
  98. +                 break;
  99. +             case 's':
  100. +                 flagchanges = !flagchanges;
  101. +                 break;
  102.               case '?':
  103.               default:
  104.                   badsw = 1;
  105. ***************
  106. *** 152,158
  107.       argc -= optind;
  108.       if (badsw || argc < 1) {
  109.           (void) fprintf(stderr,
  110. !             "Usage: %s [-d delay] [-f] command [args]\n", cmd);
  111.           exit (-1);
  112.       }
  113.       initscr();
  114.  
  115. --- 168,175 -----
  116.       argc -= optind;
  117.       if (badsw || argc < 1) {
  118.           (void) fprintf(stderr,
  119. !             "Usage: %s [-d delay] [-f] [-h] [-s] command [args]\n",
  120. !             cmd);
  121.           exit (-1);
  122.       }
  123.       initscr();
  124. ***************
  125. *** 163,176
  126.           shcmd[2] = cmd;
  127.           shcmd[3] = (char *) 0;
  128.       }
  129. !     if (wait_delay != DELAY) {
  130. !         if (strlen(cmd) > COLS-39)
  131. !             (void) sprintf(cmd, "%.*s...", COLS-42, cmd);
  132. !         mvprintw(0, max((COLS-11)/2, strlen(cmd)+15), "Delay:  %d",
  133. !             wait_delay);
  134. !     } else if (strlen(cmd) > COLS-21)
  135. !         (void) sprintf(cmd, "%.*s...", COLS-24, cmd);
  136. !     mvprintw(0, 0, "Command:  %s", cmd);
  137.       noecho();            /* don't let typing ruin our painting */
  138.       nextcycle = time(0) + wait_delay;
  139.       while (1) {
  140.  
  141. --- 180,195 -----
  142.           shcmd[2] = cmd;
  143.           shcmd[3] = (char *) 0;
  144.       }
  145. !     if (doheader) {
  146. !         if (wait_delay != DELAY) {
  147. !             if (strlen(cmd) > COLS-39)
  148. !                 (void) sprintf(cmd, "%.*s...", COLS-42, cmd);
  149. !             mvprintw(0, max((COLS-11)/2, strlen(cmd)+15),
  150. !                 "Delay:  %d", wait_delay);
  151. !         } else if (strlen(cmd) > COLS-21)
  152. !             (void) sprintf(cmd, "%.*s...", COLS-24, cmd);
  153. !         mvprintw(0, 0, "Command:  %s", cmd);
  154. !     }
  155.       noecho();            /* don't let typing ruin our painting */
  156.       nextcycle = time(0) + wait_delay;
  157.       while (1) {
  158. ***************
  159. *** 174,180
  160.       noecho();            /* don't let typing ruin our painting */
  161.       nextcycle = time(0) + wait_delay;
  162.       while (1) {
  163. !         mvprintw(0, COLS - 10, "Exec:  %d", ++iteration);
  164.           if (iteration == 1) refresh();
  165.           (void) pipe(fildes);
  166.           /* fork and exec redirecting stdout thru pipe to curses */
  167.  
  168. --- 193,200 -----
  169.       noecho();            /* don't let typing ruin our painting */
  170.       nextcycle = time(0) + wait_delay;
  171.       while (1) {
  172. !         if (doheader)
  173. !             mvprintw(0, COLS - 10, "Exec:  %d", ++iteration);
  174.           if (iteration == 1) refresh();
  175.           (void) pipe(fildes);
  176.           /* fork and exec redirecting stdout thru pipe to curses */
  177. ***************
  178. *** 191,196
  179.           if (!(fp = fdopen(pinput, "r"))) terminate(-3);
  180.           (void) close(poutput);
  181.           curline = baseline;
  182.           move(curline, 0);
  183.           /* read the command's output */
  184.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  185.  
  186. --- 211,217 -----
  187.           if (!(fp = fdopen(pinput, "r"))) terminate(-3);
  188.           (void) close(poutput);
  189.           curline = baseline;
  190. +         somode = 0;
  191.           move(curline, 0);
  192.           getyx(stdscr, y, x);
  193.           /* read the command's output */
  194. ***************
  195. *** 192,197
  196.           (void) close(poutput);
  197.           curline = baseline;
  198.           move(curline, 0);
  199.           /* read the command's output */
  200.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  201.                   if (c == '\n') {
  202.  
  203. --- 213,219 -----
  204.           curline = baseline;
  205.           somode = 0;
  206.           move(curline, 0);
  207. +         getyx(stdscr, y, x);
  208.           /* read the command's output */
  209.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  210.           {
  211. ***************
  212. *** 194,204
  213.           move(curline, 0);
  214.           /* read the command's output */
  215.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  216. !                 if (c == '\n') {
  217. !                     clrtoeol();
  218. !                     move(++curline, 0);
  219. !                 }
  220. !                 else addch(c);
  221.           if (ferror(fp)) terminate(-4);
  222.           if (baseline > 1 && curline == LINES && c != EOF)
  223.               --baseline;
  224.  
  225. --- 216,250 -----
  226.           getyx(stdscr, y, x);
  227.           /* read the command's output */
  228.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  229. !         {
  230. !             if (c == '\n') {
  231. !                 if (x < COLS-1) clrtoeol();
  232. !                 move(++curline, 0);
  233. !                 getyx(stdscr, y, x);
  234. !             }
  235. !             else {
  236. !                 if (x >= COLS-1)
  237. !                     continue;
  238. !                 getyx(stdscr, y, x);
  239. !                 if (flagch)
  240. !                     if ((c & 0177) == (inch() & 0177)) {
  241. !                         if (somode) {
  242. !                             standend();
  243. !                             somode = 0;
  244. !                         }
  245. !                     }
  246. !                     else {
  247. !                         if (!somode) {
  248. !                             standout();
  249. !                             somode = 1;
  250. !                         }
  251. !                     }
  252. !                 addch(c);
  253. !             }
  254. !         }
  255. !         if (somode) standend();
  256. !         flagch = flagchanges;
  257.           if (ferror(fp)) terminate(-4);
  258.           if (baseline > 1 && curline == LINES && c != EOF)
  259.               --baseline;
  260. ***************
  261. *** 210,216
  262.           (void) wait(&status);    /* wait for child to terminate */
  263.           /* if child didn't terminate properly, w_status will != 0 */
  264.           if (status.w_status) {
  265. !             mvprintw(0, COLS - 12, "!");
  266.               if (!force) terminate(status.w_status);
  267.           }
  268.           curtime = time(0);
  269.  
  270. --- 256,263 -----
  271.           (void) wait(&status);    /* wait for child to terminate */
  272.           /* if child didn't terminate properly, w_status will != 0 */
  273.           if (status.w_status) {
  274. !             if (doheader)
  275. !                 mvprintw(0, COLS - 12, "!");
  276.               if (!force) terminate(status.w_status);
  277.           }
  278.           curtime = time(0);
  279.