home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / jade-3.0.lha / Jade / src / amiga_render.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-19  |  3.7 KB  |  125 lines

  1. /* amiga_render.c -- Rendering for AmigaDOS
  2.    Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4. This file is part of Jade.
  5.  
  6. Jade is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. Jade is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with Jade; see the file COPYING.    If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include "jade.h"
  21. #include "jade_protos.h"
  22.  
  23. #ifdef _DCC
  24. # define GfxBase_DECLARED
  25. #endif
  26. #include <clib/graphics_protos.h>
  27. #include <graphics/gfxbase.h>
  28. #include <graphics/gfxmacros.h>
  29.  
  30. _PR void redrawcmdline(VW *, u_char *, u_char *, long, long);
  31. _PR void redrawcmdlinefrom(VW *, u_char *, u_char*, long, long, long);
  32. _PR void restorecmdline(VW *);
  33. _PR void cmdlncursor(VW *, bool);
  34. _PR void scrollvw(VW *, long);
  35.  
  36. extern struct GfxBase *GfxBase;
  37.  
  38. /*
  39.  */
  40. void
  41. redrawcmdline(VW *vw, u_char *prompt, u_char *cmdLine, long promptLen, long cmdLen)
  42. {
  43.     short yclr = ((vw->vw_MaxY - 1) * vw->vw_FontY) + vw->vw_YStartPix;
  44.     CLR_RECT(vw, vw->vw_XStartPix, yclr, vw->vw_XEndPix, yclr + vw->vw_FontY);
  45.     MOVE(vw, vw->vw_XStartPix, ((vw->vw_MaxY - 1) * vw->vw_FontY) + vw->vw_FontStart);
  46.     drawbit(vw, P_TEXT, prompt, 100000, 0, promptLen + 1);
  47.     drawbit(vw, P_TEXT, cmdLine - promptLen, 100000, promptLen,
  48.         cmdLen + promptLen + 1);
  49. }
  50.  
  51. void
  52. redrawcmdlinefrom(VW *vw, u_char *prompt, u_char *cmdLine, long promptLen, long cmdLen, long startPos)
  53. {
  54.     struct RastPort *rp = vw->vw_WindowSys.ws_Rp;
  55.     short yclr = ((vw->vw_MaxY - 1) * vw->vw_FontY) + vw->vw_YStartPix;
  56.     short xord;
  57.     if(startPos < vw->vw_StartCol)
  58.     startPos = vw->vw_StartCol;
  59.     if(startPos < (vw->vw_StartCol + vw->vw_MaxX))
  60.     {
  61.     xord = vw->vw_XStartPix + (startPos * vw->vw_FontX);
  62.     CLR_RECT(vw, xord, yclr, vw->vw_XEndPix, yclr + vw->vw_FontY);
  63.     MOVE(vw, xord, ((vw->vw_MaxY - 1) * vw->vw_FontY) + vw->vw_FontStart);
  64.     if(startPos < promptLen)
  65.     {
  66.         drawbit(vw, P_TEXT, prompt, 100000, startPos, promptLen + 1);
  67.         drawbit(vw, P_TEXT, cmdLine - promptLen, 100000, promptLen,
  68.             cmdLen + promptLen + 1);
  69.     }
  70.     else
  71.         drawbit(vw, P_TEXT, cmdLine - promptLen, 100000,
  72.             startPos, cmdLen + promptLen + 1);
  73.     }
  74. }
  75.  
  76. /*
  77.  * redraws the line which the command line overwrote
  78.  */
  79. void
  80. restorecmdline(VW *vw)
  81. {
  82.     TX *tx = vw->vw_LastRefTx ? vw->vw_LastRefTx : vw->vw_Tx;
  83.     short yord = ((vw->vw_MaxY - 1) * vw->vw_FontY) + vw->vw_YStartPix;
  84.     long linenum = vw->vw_StartLine + vw->vw_MaxY - 1;
  85.     CLR_RECT(vw, vw->vw_XStartPix, yord, vw->vw_XEndPix, yord + vw->vw_FontY);
  86.     if(tx->tx_NumLines > linenum)
  87.     {
  88.     pentoline(vw, vw->vw_MaxY - 1);
  89.     drawline(vw, tx->tx_Lines + linenum, linenum);
  90.     }
  91. }
  92.  
  93. /*
  94.  * draws the cursor for the command line
  95.  */
  96. void
  97. cmdlncursor(VW *vw, bool status)
  98. {
  99.     struct RastPort *rp = vw->vw_WindowSys.ws_Rp;
  100.     if(status == CURS_ON)
  101.     {
  102.     SetAPen(rp, 1);
  103.     SetDrMd(rp, JAM1 | INVERSVID);
  104.     }
  105.     else
  106.     {
  107.     SetAPen(rp, 1);
  108.     SetDrMd(rp, JAM1);
  109.     }
  110.     Move(rp, vw->vw_XStartPix + ((vw->vw_CursorPos.pos_Col - vw->vw_StartCol) * vw->vw_FontX), ((vw->vw_MaxY - 1) * vw->vw_FontY) + vw->vw_FontStart);
  111.     Text(rp, " ", 1);
  112. }
  113.  
  114. /*
  115.  * Scrolls the view `lines' towards line 0,
  116.  */
  117. void
  118. scrollvw(VW *vw, long lines)
  119. {
  120.     struct RastPort *rp = vw->vw_WindowSys.ws_Rp;
  121.     ScrollRaster(rp, 0, lines * vw->vw_FontY, vw->vw_XStartPix,
  122.          vw->vw_YStartPix, vw->vw_XEndPix,
  123.          vw->vw_YStartPix + (vw->vw_MaxY * vw->vw_FontY) - 1);
  124. }
  125.