home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / dflt20.zip / TEXT.C < prev    next >
Text File  |  1992-10-06  |  1KB  |  50 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 SETFOCUS:
  12.             return TRUE;
  13.         case LEFT_BUTTON:
  14.             return TRUE;
  15.         case PAINT:
  16.             if (ct == NULL ||
  17.                 ct->itext == NULL ||
  18.                     GetText(wnd) != NULL)
  19.                 break;
  20.             len = min(ct->dwnd.h, MsgHeight(cp2));
  21.             cp = cp2;
  22.             for (i = 0; i < len; i++)    {
  23.                 int mlen;
  24.                 char *txt = cp;
  25.                 char *cp1 = cp;
  26.                 char *np = strchr(cp, '\n');
  27.                 if (np != NULL)
  28.                     *np = '\0';
  29.                 mlen = strlen(cp);
  30.                 while ((cp1=strchr(cp1,SHORTCUTCHAR)) != NULL) {
  31.                     mlen += 3;
  32.                     cp1++;
  33.                 }
  34.                 if (np != NULL)
  35.                     *np = '\n';
  36.                 txt = DFmalloc(mlen+1);
  37.                  CopyCommand(txt, cp, FALSE, WndBackground(wnd));
  38.                 txt[mlen] = '\0';
  39.                 SendMessage(wnd, ADDTEXT, (PARAM)txt, 0);
  40.                 if ((cp = strchr(cp, '\n')) != NULL)
  41.                     cp++;
  42.                 free(txt);
  43.             }
  44.             break;
  45.         default:
  46.             break;
  47.     }
  48.     return BaseWndProc(TEXT, wnd, msg, p1, p2);
  49. }
  50.