home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / spotlite.prg < prev    next >
Text File  |  1993-10-14  |  3KB  |  101 lines

  1. /*
  2.  * File......: SPOTLITE.PRG
  3.  * Author....: Dave Pearson
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Dave Pearson
  7.  * Date......: $Date$
  8.  * Revision..: $Revision$
  9.  * Log file..: $Logfile$
  10.  *
  11.  * This is an original work by Dave Pearson and is placed in the public
  12.  * domain.
  13.  *
  14.  * Modification history:
  15.  * ---------------------
  16.  *
  17.  * $Log$
  18.  *
  19.  */
  20.  
  21. #include "gt_lib.ch"
  22.  
  23. // A couple of in-line replacement functions from use with GT_SpotLight().
  24.  
  25. #xtranslate ScrnOffset(<nRow>,<nCol>) => ;
  26.             ((((<nRow>)*((maxcol()+1)*2))+((<nCol>+1)*2))-1)
  27.  
  28. #xtranslate GrabScrnLine(<cScreen>,<nRow>,<nCol>,<nWidth>) => ;
  29.             substr(<cScreen>,ScrnOffset(<nRow>,<nCol>),(<nWidth>)*2)
  30.  
  31. /*  $DOC$
  32.  *  $FUNCNAME$
  33.  *      GT_SPOTLIGHT()
  34.  *  $CATEGORY$
  35.  *      Screen Saver
  36.  *  $ONELINER$
  37.  *      Spotlight screen saver.
  38.  *  $SYNTAX$
  39.  *      GT_SpotLight([<nDelay>]) --> NIL
  40.  *  $ARGUMENTS$
  41.  *      <nDelay> is an optional numeric parameter that is the delay to
  42.  *      use when updating the display. This is in 1/18ths of a second.
  43.  *      If not supplied this parameter defaults to 2.
  44.  *  $RETURNS$
  45.  *      Nothing.
  46.  *  $DESCRIPTION$
  47.  *      GT_SpotLight() is a screen saver function.
  48.  *  $EXAMPLES$
  49.  *      // Call the screen saver with a delay of 3/18 of a second.
  50.  *
  51.  *      GT_SpotLight(3)
  52.  *  $END$
  53.  */
  54.  
  55. function GT_SpotLight(nDelay)
  56. local cScreen    := savescreen()      ,;
  57.       nTop       := 0                 ,;
  58.       nLeft      := 0                 ,;
  59.       nBottom    := 4                 ,;
  60.       nRight     := 12                ,;
  61.       nXMove     := 1                 ,;
  62.       nYMove     := 1                 ,;
  63.       nLine      := 0                 ,;
  64.       cSpotLight := NULL              ,;
  65.       hOldScreen := GT_SaveScr()      ,;
  66.       nOldCursor := setcursor(SC_NONE),;
  67.       cOldColour := setcolor("w/n")   ,;
  68.       bQuit      := GT_Interrupt()
  69. default nDelay to 2
  70. default bQuit  to {|| inkey() != 0 }
  71. scroll()
  72. do while !eval(bQuit)
  73.    cSpotLight := NULL
  74.    for nLine := nTop to nBottom
  75.       cSpotLight += GrabScrnLine(cScreen,nLine,nLeft,(nRight-nLeft)+1)
  76.    next
  77.    dispbegin()
  78.    scroll()
  79.    restscreen(nTop,nLeft,nBottom,nRight,cSpotLight)
  80.    dispend()
  81.    tone(0,2)
  82.    if nXMove == 1
  83.       nXMove := if(nRight == maxcol(),-1,nXMove)
  84.    else
  85.       nXMove := if(nLeft == 0,1,nXMove)
  86.    endif
  87.    if nYMove == 1
  88.       nYMove := if(nBottom == maxrow(),-1,nYMove)
  89.    else
  90.       nYMove := if(nTop == 0,1,nYMove)
  91.    endif
  92.    nTop    += nYMove
  93.    nLeft   += nXMove
  94.    nBottom += nYMove
  95.    nRight  += nXMove
  96. enddo
  97. setcolor(cOldColour)
  98. GT_RestScr(hOldScreen)
  99. setcursor(nOldCursor)
  100. return(NIL)
  101.