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

  1. /*
  2.  * lemhelp.c - give menu of key functions
  3.  *
  4.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  5.  */
  6.  
  7. #include "lem.h"
  8. #include "lemfont.h"
  9.  
  10. #define HELPCHARS "[IHMABCDEFGLNOPRSTUVWX^?"
  11.  
  12. help()
  13.     {
  14.     char c;
  15.     msgpost("[help]: <space> - all; \"/\" - fonts; <key> - function: ");
  16.     c = getstroke();
  17.     if (c == ' ') helpall();
  18.     else if (c == '/') helpfonts();
  19.     else if (c != '\0') helpkey(c);
  20.     }
  21.  
  22. char *helpmsg(c)
  23.     char c;
  24.     {
  25.     char *s;
  26.     if (c < ' ') c += ' ';    /* turn ^chars to upper case */
  27.     switch(UC(c))
  28.     {
  29.     case '[': s = "ESC  Delete Mark; Deselect all"; break;
  30.     case 'A': s = "^A   All select"; break;
  31.     case 'B': s = "^B   Box-ify selections"; break;
  32.     case 'C': s = "^C   Copy selections (in place)"; break;
  33.     case 'D': s = "^D   Delete selections"; break;
  34.     case 'E': s = "^E   Ellipse-ify selections"; break;
  35.     case 'F': s = "^F   Force<+key>: 0=reset/1-9=size/Bld/Nrm/Itl/Lft/Rht/Cen";break;
  36.     case 'G': s = "^G   Group selections"; break;
  37.     case 'H': s = "BS   Backspace input text"; break;
  38.     case 'I': s = "TAB  Select marked obj (cyclically)"; break;
  39.     case 'L': s = "^L   Refresh display"; break;
  40.     case 'J':
  41.     case 'M': s = "CR   Add text (if present)"; break;
  42.     case 'N': s = "^N   No select (deselect all)"; break;
  43.     case 'O': s = "^O   Output PIC \"filename\""; break;
  44.     case 'P': s = "^P   Pop (ungroup -- instantiate) selected groups"; break;
  45.     case 'Q': s = "^Q   Quit"; break;
  46.     case 'R': s = "^R   Read \"filename\""; break;
  47.     case 'S': s = "^Sc  Special function escape"; break;
  48.     case 'T': s = "^Td  Tickmarks (on/off)"; break;
  49.     case 'U': s = "^U   Undo selections (undelete, untransform)"; break;
  50.     case 'V': s = "^V   Vector-ify selections"; break;
  51.     case 'W': s = "^W   Write \"filename\""; break;
  52.     case 'X': s = "^X   Cut lines (selections scissor normal lines)"; break;
  53.     case '^': s = "^^   Help"; break;
  54.     case '?': s = "^^?  Help all"; break;
  55.     default:  s = "    (undefined)"; break;
  56.     }
  57.     return(s);
  58.     }
  59.  
  60. helpkey(c)
  61.     char c;
  62.     {
  63.     msgpost(helpmsg(c));
  64.     }
  65.  
  66. helpall()
  67.     {
  68.     int i, x, y;
  69.     char c;
  70.     erase();
  71.     x = 10;
  72.     y = screenh-fontleading(SYSFONT);
  73.     for (i=0; i<strlen(HELPCHARS); i++)
  74.     {
  75.     int baseline;
  76.     c = HELPCHARS[i];
  77.     fontwrite(SYSFONT, x, y, helpmsg(c), EMPHNONE, HELPCOL);
  78.     baseline = fontleading(SYSFONT);
  79.     y -= baseline;
  80.     if (y < baseline) break;
  81.     }
  82.     }
  83.  
  84. helpfonts()
  85.     {
  86.     int i, x, y;
  87.     char fontmsg[50];
  88.     erase();
  89.     x = 10;
  90.     y = screenh-fontleading(SYSFONT);
  91.     fontwrite(SYSFONT, x, y, "Current Fonts", EMPHNONE, HELPCOL);
  92.     y -= 2 * fontleading(SYSFONT);
  93.     for (i=1; i<rclen; i++)
  94.     {
  95.     int baseline;
  96.     sprintf(fontmsg, "%d    %s%d", i, lemfont[i].dsp, lemfont[i].psize);
  97.     fontwrite(SYSFONT, x, y, fontmsg, EMPHNONE, HELPCOL);
  98.     fontwrite(i, x+180, y, "regular", EMPHNONE, HELPCOL);
  99.     fontwrite(i, x+280, y, "bold",    EMPHBOLD, HELPCOL);
  100.     fontwrite(i, x+380, y, "italic",  EMPHITAL, HELPCOL);
  101.     if (gsize == i)
  102.          {
  103.          char *S;
  104.          S = (galign==ALIGNLEFT)?"[L]" : ((gemph==ALIGNRGHT)?"[R]":"[C]");
  105.          if (gemph == EMPHNONE) fontwrite(i, x+160, y, S,EMPHNONE,HELPCOL);
  106.          if (gemph == EMPHBOLD) fontwrite(i, x+260, y, S,EMPHBOLD,HELPCOL);
  107.          if (gemph == EMPHITAL) fontwrite(i, x+360, y, S,EMPHITAL,HELPCOL);
  108.          }
  109.     baseline = fontleading(SYSFONT);
  110.     y -= 2 * baseline;
  111.     if (y < baseline) break;
  112.     }
  113.     }
  114.