home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / dflt14.zip / TEXT.C < prev    next >
Text File  |  1992-04-22  |  1KB  |  46 lines

  1. /* -------------- text.c -------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. int TextProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  6. {
  7.     int i, len;
  8.     CTLWINDOW *ct = GetControl(wnd);
  9.     char *cp, *cp2 = ct->itext;
  10.     switch (msg)    {
  11.         case PAINT:
  12.             if (ct == NULL ||
  13.                 ct->itext == NULL ||
  14.                     GetText(wnd) != NULL)
  15.                 break;
  16.             len = min(ct->dwnd.h, MsgHeight(cp2));
  17.             cp = cp2;
  18.             for (i = 0; i < len; i++)    {
  19.                 int mlen;
  20.                 char *txt = cp;
  21.                 char *cp1 = cp;
  22.                 char *np = strchr(cp, '\n');
  23.                 if (np != NULL)
  24.                     *np = '\0';
  25.                 mlen = strlen(cp);
  26.                 while ((cp1=strchr(cp1,SHORTCUTCHAR)) != NULL) {
  27.                     mlen += 3;
  28.                     cp1++;
  29.                 }
  30.                 if (np != NULL)
  31.                     *np = '\n';
  32.                 txt = DFmalloc(mlen+1);
  33.                  CopyCommand(txt, cp, FALSE, WndBackground(wnd));
  34.                 txt[mlen] = '\0';
  35.                 SendMessage(wnd, ADDTEXT, (PARAM)txt, 0);
  36.                 if ((cp = strchr(cp, '\n')) != NULL)
  37.                     cp++;
  38.                 free(txt);
  39.             }
  40.             break;
  41.         default:
  42.             break;
  43.     }
  44.     return BaseWndProc(TEXT, wnd, msg, p1, p2);
  45. }
  46.