Seppo Mustonen : Programming Survo in C

5. Shadow lines

Various display effects (color, underlining, reversed video, etc.) and other attributes related to characters and edit lines are maintained by shadow lines. Normally an edit line has no shadow line, but when at least one character is typed in special display mode (turned on by the FORMAT key, for example), the SURVO 84C system creates a shadow line for the current line. Shadow lines are as long as normal edit lines, i.e. ed1 bytes and they are saved in the order they are created after the last normal edit line (ed2).
     The shadow lines may contain any kind of characters. Space (blank) is the default and means normal display on the screen. Characters `1', `2', ...,`7' are reserved for the current palette of colors (or display effects). Their actual meaning can be controlled by the user (by editing the auxiliary file SURVO.APU). These and other control codes are also used in printing to produce various special effects.
     The total amount of shadow lines is limited by the system parameter edshad (default is 20). This limit may, however, be changed by the REDIM operation. If the user tries to exceed the current limit, the system gives a warning.
     If a shadow line becomes empty, the system frees it for subsequent use in the same edit field.
     The shadow lines can be read and written as normal edit lines. The index of the shadow line for the jth edit line is zs[j]. If there is no shadow line, zs[j]=0.
     The library function shadow_create is used to create new shadow lines and shadow_test frees the shadow line if it consists of spaces only.
     Normally the modules have no need to use shadow lines.

To illustrate working with shadow lines, we have made a small module !SHADOW which creates and fills all the shadow lines of specific edit lines with a selected character. For example, SHADOW 6,10,7 turns all characters on lines 6-10 to inverse mode and SHADOW 1,END frees each shadow line in the current edit field.

  1 /* !shadow.c 28.3.1986/SM (28.3.1986)
  2     SHADOW L1,L2,<shadow_character> 
  3 */
  4 #include "survo.h"
  5 #include "survoext.h"
  6
  7 main(argc,argv)
  8 int argc; char *argv[];
  9     {
 10     int i,j,j1,j2;
 11     char ch;
 12     char shadow[LLENGTH];
 13
 14     if (argc==1) return;
 15     s_init(argv[1]);
 16     if (g<3)
 17         {
 18         sur_print("\nUsage: SHADOW L1,L2,<shadow_character>");
 19         WAIT; return;
 20         }
 21
 22     j1=edline2(word[1],1,1); if (j1==0) return;
 23     j2=edline2(word[2],j1,1); if (j2==0) return;
 24     if (g>3) ch=*word[3]; else ch=' ';
 25     for (i=0; i<ed1-1; ++i) shadow[i]=ch;
 26     shadow[ed1-1]=EOS;
 27
 28     for (j=j1; j<=j2; ++j)
 29         {
 30         if (zs[j]==0)
 31             {
 32             i=shadow_create(j);
 33             if (i<0) return;
 34             }
 35         edwrite(shadow,zs[j],1);
 36         if (ch==' ') shadow_test(j);
 37         }
 38     }

When referring to edit lines, both line numbers and line labels may be used in SURVO 84C. Line labels are one character symbols written in the control column of the edit field. Thus in modules which take line labels as their parameters (as !SHADOW above) both alternatives must be supported. This is done simply by using the library function edline2. It was employed twice in !SHADOW (lines 22-23).


Previous: Edit field
Next: Space allocation


Front page of Programming Survo in C