home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / lemming / part01 / lemattr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-05  |  1.6 KB  |  84 lines

  1. /*
  2.  * lemattr.c - change object attributes (and reset global defaults)
  3.  *
  4.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  5.  */
  6.  
  7. #include "lem.h"
  8.  
  9. remake(newtype)
  10.     {
  11.     int i;
  12.     gtype = newtype;
  13.     forobjects
  14.     {
  15.     if (Osel && (Otype != newtype) && (Otype != TEXT))
  16.         {
  17.         objectop(i, SEL, DEL);
  18.         Otype = newtype;
  19.         objectop(i, DEL, SEL);
  20.         }
  21.     }
  22.     }
  23.  
  24. setattr(ch)
  25.     char ch;
  26.     {
  27.     switch(UC(ch))
  28.     {
  29.     case 'B': gemph = EMPHBOLD; break;
  30.     case 'I': gemph = EMPHITAL; break;
  31.     case 'N': gemph = EMPHNONE; break;
  32.     case 'L': galign = ALIGNLEFT; break;
  33.     case 'R': galign = ALIGNRGHT; break;
  34.     case 'C': galign = ALIGNCENT; break;
  35.     case '0': gsize = 1; galign = ALIGNCENT; gemph = EMPHNONE; break;
  36.     case '1':
  37.     case '2':
  38.     case '3':
  39.     case '4':
  40.     case '5':
  41.     case '6':
  42.     case '7':
  43.     case '8':
  44.     case '9': gsize = ch-'0'; break;
  45.     default: return(0);        /* invalid char - fail */
  46.     }
  47.     return(1);    /* good char */
  48.     }
  49. /*
  50.  * rewrite all objects with these attributes
  51.  */
  52.  
  53. forceattr()
  54.     {
  55.     int i, salign, semph, ssize;
  56.     char ch;
  57.     ch = getstroke();
  58.     if (setattr(ch))        /* set global attributes */
  59.     {
  60.     salign = galign;    /* save new global attributes */
  61.     semph = gemph;
  62.     ssize = gsize;
  63.     forobjects
  64.         {
  65.         if (Osel)
  66.         {
  67.         objectop(i, SEL, DEL);    /* get object */
  68.         galign = Oalign;    /* set matching global attribs, */
  69.         gemph = Oemph;
  70.         gsize = Osize;
  71.         setattr(ch);        /* reset some new attribute(s) */
  72.         Oalign = galign;    /* write back */
  73.         Oemph = gemph;
  74.         Osize = gsize;
  75.         objresize(i);        /* in case this changes geometry */
  76.         objectop(i, DEL, SEL);
  77.         }
  78.         }
  79.     galign = salign;    /* reset to new global attributes */
  80.     gemph = semph;
  81.     gsize = ssize;
  82.     }
  83.     }
  84.