home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / snapshot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-28  |  2.7 KB  |  137 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: snapshot.c,v 1.9 1995/10/28 14:13:13 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    snapshot.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    15 Oct 1984
  9.  * Last update:
  10.  *        28 Oct 1995, rewrote using rmsio
  11.  *        19 Feb 1995, prototypes
  12.  *        18 Feb 1995, port to AXP (renamed 'alarm'). 
  13.  *        27 Jan 1985, save old-sgr on status line to restore it.
  14.  *        17 Oct 1984
  15.  *
  16.  * Function:    This procedure copies the current screen-contents from the
  17.  *        CRT module to the output file SNAPSHOT.CRT, doing minor
  18.  *        formatting to make it readable on a printer.
  19.  */
  20.  
  21. #include    <starlet.h>
  22. #include    <stdio.h>
  23. #include    <signal.h>    /* for 'sleep()' */
  24. #include    <string.h>
  25. #include    <ctype.h>
  26.  
  27. #include    "crt.h"
  28. #include    "rmsio.h"
  29. #include    "strutils.h"
  30. #include    "sysutils.h"
  31.  
  32. static    RFILE    *fp    = 0;
  33. static    int    calls    = 0;
  34.  
  35. #define PUTLINE rputr(fp, dline, strlen(dline)); dline[0] = '\0'
  36. #define    CORNER    strcat(dline,"+")
  37. #define    BAR    CORNER; \
  38.         for(j=0; j < width; j++) \
  39.             strcat(dline,"-"); \
  40.         CORNER; \
  41.         PUTLINE
  42.  
  43. #define    VERT    strcat(dline, "|")
  44. #define    VEC(j)    ((j == lpp1) ? sline : crtvec[j])
  45.  
  46. void
  47. snapshot (void)
  48. {
  49.     int    top    = crt_top (),
  50.         end    = crt_end (),
  51.         lpp    = crt_lpp (),
  52.         width    = crt_width () - 1,
  53.         save_x    = crt_x (),
  54.         save_y    = crt_y (),
  55.         oldsgr    = crt_qsgr(lpp-1);
  56.     DATENT    date;
  57.     register
  58.     int    lpp1    = lpp - 1,
  59.         j,    k,    over;
  60.     char    bfr    [CRT_COLS],
  61.         dline    [CRT_COLS*3],    /* full-line + underlining */
  62.         sline    [CRT_COLS];    /* saved original message-line */
  63.     register
  64.     char    *s_,    c;
  65.  
  66.     if (!fp)
  67.     {
  68.         fp = ropen ("sys$login:snapshot.crt", "w");
  69.         if (!fp)
  70.         {
  71.             sound_alarm ();
  72.             return;
  73.         }
  74.         calls = 0;
  75.     }
  76.  
  77.     strcpy (sline, crtvec[lpp1]);
  78.     sprintf (bfr, "%03d: Copying screen to SNAPSHOT.CRT ... ", ++calls);
  79.     crt_high (bfr, strlen(bfr));
  80.     crt_text (bfr, lpp1, 2);    /* Show this in REVERSE        */
  81.  
  82.     sys$gettim (&date);
  83.     sysasctim (bfr, &date, 21);
  84.  
  85.     strcpy(dline, "\f");
  86.     PUTLINE;
  87.     PUTLINE;
  88.  
  89.     sprintf(dline, "Screen dumped: %s", bfr);
  90.     PUTLINE;
  91.  
  92.     sprintf (dline, "Image top: %d  bottom: %d", top, end);
  93.     PUTLINE;
  94.     PUTLINE;
  95.  
  96.     BAR;
  97.     for (j = 0; j < lpp; j++)
  98.     {
  99.         VERT;
  100.         for (s_ = VEC(j), k = over = 0;
  101.             k < width;
  102.                 k++)
  103.         {
  104.             if (*s_)
  105.             {
  106.                 c = *s_++;
  107.                 if (!isascii(c))
  108.                 {
  109.                     c = toascii(c);
  110.                     over = k + 1;
  111.                 }
  112.                 sprintf (strnull(dline), "%c", c);
  113.             }
  114.             else
  115.                 strcat (dline, " ");
  116.         }
  117.         VERT;
  118.         if (over)
  119.         {
  120.             strcat(dline,"\r ");
  121.             for (s_ = VEC(j), k = 0; k < over; k++)
  122.             {
  123.                 c = *s_++;
  124.                 sprintf (strnull(dline), "%c",
  125.                     isascii(c) ? ' ' : '_');
  126.             }
  127.         }
  128.         PUTLINE;
  129.     }
  130.     BAR;
  131.  
  132.     sleep(1);            /* Make sure user sees message    */
  133.     crt_text ("",    lpp1, 0);    /* flush differences in highlit    */
  134.     crt_text (sline, lpp1, oldsgr);    /* Use original highlighting    */
  135.     crt_move (save_y, save_x);
  136. }
  137.