home *** CD-ROM | disk | FTP | other *** search
/ C/C++ User's Journal & Wi…eveloper's Journal Tools / C-C__Users_Journal_and_Windows_Developers_Journal_Tools_1997.iso / windbase / windbase.exe / MEMSLC.3 / EDITOR / SCREEN.C < prev    next >
C/C++ Source or Header  |  1995-03-18  |  9KB  |  287 lines

  1. /*****************************************************************************\
  2. **                                                                           **
  3. **  WW     WW IIIIIIII NNN   NN DDDDDDD  BBBBBBB     AA     SSSSSS EEEEEEEE  **
  4. **  WW  W  WW    II    NNNN  NN DD    DD BB    BB  AA  AA  SS      EE        **
  5. **  WW  W  WW    II    NN NN NN DD    DD BBBBBBB  AAAAAAAA  SSSSSS EEEEEE    **
  6. **   WW W WW     II    NN  NNNN DD    DD BB    BB AA    AA      SS EE        **
  7. **    WWWWW   IIIIIIII NN   NNN DDDDDDD  BBBBBBB  AA    AA SSSSSS  EEEEEEEE  **
  8. **                                                                           **
  9. **   SSSSSS  OOOOOO  FFFFFFFF TTTTTTTT WW     WW    AA    RRRRRRR  EEEEEEEE  **
  10. **  SS      OO    OO FF          TT    WW  W  WW  AA  AA  RR    RR EE        **
  11. **   SSSSS  OO    OO FFFFF       TT    WW  W  WW AAAAAAAA RRRRRRR  EEEEEE    **
  12. **       SS OO    OO FF          TT     WW W WW  AA    AA RR   RR  EE        **
  13. **  SSSSSS   OOOOOO  FF          TT      WWWWW   AA    AA RR    RR EEEEEEEE  **
  14. **                                                                           **
  15. *********** NOTICE ************************************************************
  16. **        This file contains valuable trade secrets and proprietary          **
  17. **        assets of Windbase Software Inc.  Embodying substantial            **
  18. **        creative efforts and confidential information.  Unauthorized       **
  19. **        use, copying, decompiling, translating, disclosure or              **
  20. **        transfer, of any kind, is strictly prohibited.                     **
  21. **                                                                           **
  22. **        COPYRIGHT (C) 1992, 1993, 1994.  Windbase Software Inc.            **
  23. **        ALL RIGHTS RESERVED.                                               **
  24. \*****************************************************************************/
  25.  
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <conio.h>
  29. #include <string.h>
  30. #include <malloc.h>
  31. #include <dos.h>
  32.  
  33. #include "../../memsl.h"
  34. #include "port.h"
  35. #include "vedt.h"
  36.  
  37. /***************************************************************************\
  38. **
  39. \***************************************************************************/
  40. void FillScreen(EDITOR *editor)
  41.   {
  42.     WBDLIST *dlistptr;
  43.     char *strptr;
  44.     int i = 0, len;
  45.     int p1pos = editor->p1pos-editor->offset,
  46.     p2pos = editor->p2pos-editor->offset;
  47.     long linenum = 0;
  48.  
  49.     if ((dlistptr = WBDListPointer(editor->dltopscr)) != NULL)
  50.       {
  51.     i = 0;
  52.     if (editor->p1 && editor->p2)
  53.       linenum = editor->linenum-editor->row;
  54.     strptr = WBDListGet(dlistptr,WB_CURRENT);
  55.     while (i <= editor->fillend && strptr != NULL)
  56.       {
  57.         if (i >= editor->fillstart && i <= editor->fillend)
  58.           {
  59.         if (strptr == editor->strptr)
  60.           strptr = editor->str;
  61.         len = strlen(strptr+1);
  62.         gotoxy(1,1+i);
  63.         if (WBDListIsPtrEqual(editor->p1,dlistptr)
  64.           && WBDListIsPtrEqual(editor->p1,editor->p2))
  65.           {
  66.             if (p1pos < MAXCOL && (p1pos >= 0 || p2pos >= 0))
  67.               {
  68.             if (p1pos < 0)
  69.               p1pos = 0;
  70.             if (p2pos > MAXCOL)
  71.               p2pos = MAXCOL;
  72.             if (editor->offset < len)
  73.               scrprintf("%0.*s",p1pos,strptr+1+editor->offset);
  74.             else
  75.               scrprintf("%0.*s",p1pos,"");
  76.             if (editor->hideblock == 0)
  77.               reversevideo();
  78.             gotoxy(1+p1pos,1+i);
  79.             if (p1pos+editor->offset < len)
  80.               scrprintf("%0.*s",p2pos-p1pos,strptr+1+p1pos+editor->offset);
  81.             if (wherex() < p2pos)
  82.               for (p1pos = wherex(); p1pos < p2pos+1; p1pos++)
  83.                 {
  84.                   gotoxy(p1pos,1+i);
  85.                   putch(' ');
  86.                 }
  87.             normvideo();
  88.             gotoxy(1+p2pos,1+i);
  89.             if (p2pos+editor->offset < len)
  90.               scrprintf("%0.*s",MAXCOL-p2pos,strptr+1+p2pos+editor->offset);
  91.               }
  92.             else
  93.               if (editor->offset < len)
  94.             scrprintf("%0.*s",MAXCOL,strptr+1+editor->offset);
  95.           }
  96.         else if (WBDListIsPtrEqual(editor->p1,dlistptr))
  97.           {
  98.             if (p1pos < MAXCOL)
  99.               {
  100.             if (p1pos < 0)
  101.               p1pos = 0;
  102.             if (editor->offset < len)
  103.               scrprintf("%0.*s",p1pos,strptr+1+editor->offset);
  104.             else
  105.               scrprintf("%0.*s",p1pos,"");
  106.             if (editor->hideblock == 0)
  107.               reversevideo();
  108.             gotoxy(1+p1pos,1+i);
  109.             if (p1pos+editor->offset < len)
  110.               scrprintf("%0.*s",MAXCOL-p1pos,strptr+1+p1pos+editor->offset);
  111.               }
  112.             else
  113.               if (editor->offset < len)
  114.             scrprintf("%0.*s",MAXCOL,strptr+1+editor->offset);
  115.           }
  116.         else if (WBDListIsPtrEqual(editor->p2,dlistptr))
  117.           {
  118.             if (p2pos > 0)
  119.               {
  120.             if (p2pos > MAXCOL)
  121.               p2pos = MAXCOL;
  122.             if (editor->hideblock == 0)
  123.               reversevideo();
  124.             if (editor->offset < len)
  125.               scrprintf("%0.*s",p2pos,strptr+1+editor->offset);
  126.             if (wherex() < p2pos)
  127.               for (p1pos = wherex(); p1pos < p2pos+1; p1pos++)
  128.                 {
  129.                   gotoxy(p1pos,1+i);
  130.                   putch(' ');
  131.                 }
  132.             normvideo();
  133.             gotoxy(1+p2pos,1+i);
  134.             if (p2pos+editor->offset < len)
  135.               scrprintf("%0.*s",MAXCOL-p2pos,strptr+1+p2pos+editor->offset);
  136.               }
  137.             else
  138.               if (editor->offset < len)
  139.             scrprintf("%0.*s",MAXCOL,strptr+1+editor->offset);
  140.           }
  141.         else
  142.           {
  143.             if (editor->p1 && editor->p2)
  144.               if (linenum > editor->p1line
  145.             && linenum < editor->p2line
  146.             && editor->hideblock == 0)
  147.               reversevideo();
  148.  
  149.             if (editor->offset < len)
  150.               scrprintf("%0.*s",MAXCOL,strptr+1+editor->offset);
  151.           }
  152.         clreol();
  153.         normvideo();
  154.           }
  155.         strptr = WBDListGet(dlistptr,WB_NEXT);
  156.         i++; linenum++;
  157.       }
  158.     normvideo();
  159.     while (i <= editor->fillend)
  160.       {
  161.         gotoxy(1,1+i);
  162.         clreol();
  163.         i++;
  164.       }
  165.     WBDListClose(dlistptr);
  166.       }
  167.     editor->refillscr = editor->fillend = 0;
  168.     editor->fillstart = MAXROW-1;
  169.   }
  170.  
  171. /***************************************************************************\
  172. **
  173. \***************************************************************************/
  174. void Draw(EDITOR *editor)
  175.   {
  176.     if (editor->deltop)
  177.       {
  178.         gotoxy(1,1);
  179.         delline();
  180.         editor->deltop = 0;
  181.       }
  182.     else if (editor->instop)
  183.       {
  184.         gotoxy(1,1);
  185.         insline();
  186.         editor->instop = 0;
  187.       }
  188.     if (editor->refillscr)
  189.       FillScreen(editor);
  190.   }
  191.  
  192. /***************************************************************************\
  193. **
  194. \***************************************************************************/
  195. void UpdateCoordinates(EDITOR *editor, int start, int end)
  196.   {
  197.     editor->refillscr = 1;
  198.     if (start < editor->fillstart && start >= 0)
  199.       editor->fillstart = start;
  200.     if (end > editor->fillend && end <= MAXROW-1)
  201.       editor->fillend = end;
  202.   }
  203.  
  204. /***************************************************************************\
  205. **
  206. \***************************************************************************/
  207. void Cursor(int cursorsize)
  208.   {
  209.     union REGS regs;
  210.  
  211.     regs.h.ah = 01;
  212.     switch(cursorsize)
  213.       {
  214.         case 0:
  215.           regs.h.ch|=0x20;
  216.         break;
  217.         case 1:
  218.           regs.h.ch = 1;
  219.           regs.h.cl = 14;
  220.         break;
  221.     case 2:
  222.           regs.h.ch = 13;
  223.           regs.h.cl = 14;
  224.         break;
  225.       }
  226.     int86(0x10,®s,®s);
  227.   }
  228.  
  229. /***************************************************************************\
  230. **
  231. \***************************************************************************/
  232. void UpdateStats(EDITOR *editor, int updateall)
  233.   {
  234.     window(1,1,MAXSCRCOL,MAXSCRROW);
  235.     reversevideo();
  236.     if (updateall)
  237.       {
  238.     gotoxy(1,24); clreol();
  239.     gotoxy(1,25); clreol();
  240.     if (editor->viewonly)
  241.       {
  242.         gotoxy(1,25); scrprintf("View: %s",editor->filename);
  243.       }
  244.     else
  245.       {
  246.         gotoxy(1,25); scrprintf("Edit: %s",editor->filename);
  247.         gotoxy(26,24); scrprintf("%s",editor->insert?"Ins":"Ovr");
  248.         gotoxy(30,24); scrprintf("%s",(*editor->srchoptions&SRCH_FORWARD)?"Fwd":"Bck");
  249.         gotoxy(34,24); scrprintf("%s",editor->indent?"AI":"  ");
  250.         gotoxy(37,24); scrprintf("Tabs: %d",editor->tabspec);
  251.       }
  252.     gotoxy(56,24);
  253.     if (editor->macro_on)
  254.       scrprintf("Macro Def");
  255.     else if (editor->macro_exe)
  256.       scrprintf("Macr