home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Telnet 2.7b5 / source / Screens / vsintern.c < prev    next >
Encoding:
Text File  |  1995-04-18  |  35.5 KB  |  131 lines  |  [TEXT/CWIE]

  1. /*
  2.  *
  3.  *      Virtual Screen Kernel Internal Routines
  4.  *                      (vsintern.c)
  5.  *  National Center for Supercomputing Applications
  6.  *
  7.  *      by Gaige B. Paulsen
  8.  *
  9.  *    This file contains the private internal calls for the NCSA
  10.  *  Virtual Screen Kernel.
  11.  *
  12.  *        Version Date    Notes
  13.  *        ------- ------  ---------------------------------------------------
  14.  *        0.01    861102  Initial coding -GBP
  15.  *        0.50    861113  First compiled edition -GBP
  16.  *        0.70    861114  Internal operation confirmed -GBP
  17.  *        2.1        871130    NCSA Telnet 2.1 -GBP
  18.  *        2.2     880715    NCSA Telnet 2.2 -GBP
  19.  */
  20.  
  21. #ifdef MPW
  22. #pragma segment VS
  23. #endif
  24.  
  25.  
  26. #include "vsdata.h"
  27. #include "vskeys.h"
  28. #include "vsinterf.proto.h"
  29. #include "rsmac.proto.h"
  30. #include "rsinterf.proto.h"
  31. #include "maclook.proto.h"
  32. #include "wind.h"
  33.  
  34. #define ScrollbackQuantum 100
  35.  
  36. #define VSIclrattrib 0
  37.  
  38. #include "vsintern.proto.h"
  39.  
  40. extern short     TempItemsVRefNum;
  41. extern long        TempItemsDirID;
  42. extern WindRec *screens;
  43.  
  44. short VSIclip
  45.   (
  46.      short *x1, /* starting column */
  47.      short *y1, /* line on which to draw (assumed to lie within visible region) */
  48.      short *x2, /* ending column (inclusive) (output if *n >= 0) */
  49.      short *y2, /* ending line (inclusive) (output if *n >= 0) */
  50.      short *n, /* length of text to draw (input and output) */
  51.      short *offset /* length of initial part of text to skip (output) */
  52.   )
  53.   /* clips a text string to the visible region, given the starting
  54.     line and column in screen coordinates at which it is to be drawn.
  55.     If the length of the string is given, will also compute the ending
  56.     line and column. On return, these coordinates will be normalized
  57.     to the current visible region. Returns a nonzero function result
  58.     iff the string is completely invisible. */
  59.   {
  60.     if (*n >= 0)
  61.       {
  62.       /* compute ending line and column (inclusive) */
  63.         *x2 = *x1 + *n - 1;
  64.         *y2 = *y1;
  65.       }
  66.   /* else take these as given */
  67.  
  68.     if ((*x1 > VSIw->Rright) || (*y2 < VSIw->Rtop))
  69.         return (-1); /* nothing to draw */
  70.  
  71.     if (*x2 > VSIw->Rright)
  72.         *x2 = VSIw->Rright;
  73.     if (*y2 > VSIw->Rbottom)
  74.         *y2 = VSIw->Rbottom;
  75.   /* normalof characters
  76.     at the current cursor position. The text has already been
  77.     inserted into the screen buffer. Also, the cursor position has
  78.     already been updated, so the part needing redrawing begins at column
  79.     (VSIw->x - len). */
  80.   {
  81.         RSinsstring(VSIwn, VSIw->x - len, VSIw->y,
  82.             VSIw->attrib, len, start);
  83.   } /* VSIinsstring */
  84.  
  85. void VSIsave
  86.   (
  87.     void
  88.   )
  89.   /* saves the current cursor position and attribute settings. */
  90.   {
  91.     VSIw->Px = VSIw->x;
  92.     VSIw->Py = VSIw->y;
  93.     VSIw->Pattrib = VSIw->attrib;
  94.   } /* VSIsave */
  95.  
  96. void VSIrestore
  97.   (
  98.     void
  99.   )
  100.   /* restores the last-saved cursor position and attribute settings. */
  101.   {
  102.     if (VSIw->Pattrib < 0)
  103.       /* no previous save */
  104.         return;
  105.         
  106.     VSIw->x = VSIw->Px;
  107.     VSIw->y = VSIw->Py;
  108.     VSIrange();
  109.     VSIw->attrib = VSinattr(VSIw->Pattrib); /* hmm, this will clear the graphics character set selection */
  110.   } /* VSIrestore */
  111.  
  112. void VSIdraw
  113.   (
  114.     short VSIwn, /* window number */
  115.     short x, /* starting column */
  116.     short y, /* line on which to draw */
  117.     short a, /* text attributes */
  118.     short len, /* length of text to draw */
  119.     char *c /* pointer to text */
  120.   )
  121.   /* displays a piece of text (assumed to fit on a single line) on a
  122.     screen, using the specified attributes, and clipping to the
  123.     current visible region. Highlights any part of the text lying
  124.     within the current selection. */
  125.   {
  126.     short x2, y2, offset;
  127.  
  128.     if (!VSIclip(&x, &y, &x2, &y2, &len, &offset))
  129.         RSdraw(VSIwn, x, y, a, len, (char *) (c + offset));    /* BYU LSC */
  130.   } /* VSIdraw */
  131.