home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / textutil / gcmacro.zip / SCROLL.S < prev    next >
Text File  |  1993-05-10  |  4KB  |  119 lines

  1. /*****************************************************************************
  2.   4 May 93: G. Grafton Cole                                SCROLL FUNCTIONS
  3.  
  4.   I burned these macros into SE.
  5.  ****************************************************************************/
  6.  
  7. /****************************************************************************
  8.   4 May 93: G. Grafton Cole                                     SCROLL LOCK
  9.    If scroll lock is ON: If more than one window is open.
  10.       The cursor line goes to inverse video.
  11.       Uses current window and next window and scrolls (rolls) both windows
  12.          up or down.
  13. ****************************************************************************/
  14.  
  15. integer   scroll_lock    = 0,                               // global
  16.           DEFcursor_att  = Color(Bright White on Blue)
  17.  
  18. proc ScrollLock()
  19.     integer y   = WhereY()
  20.  
  21.     scroll_lock = scroll_lock ^ 1
  22.     Message("Scroll Lock turned ", iif(scroll_lock, "on", "off"))
  23.  
  24.     if scroll_lock                             // change cursor line when ON
  25.        VGoToXY(1,y)                            // position cursor
  26.        PutAttr(Color(Blue on White),80)        // highlight line
  27.        Set(CursorAttr, Color(Blue on White))   // set cursor line attribute
  28.     else
  29.        VGoToXY(1,y)                            // restore default cursor line
  30.        PutAttr(DEFcursor_att,80)               //   attribute
  31.        Set(CursorAttr, DEFcursor_att)
  32.     endif
  33. end
  34. /******************************************************************************
  35.   4 May 93: G. Grafton Cole                              TOGGLE SCROLL / ROLL
  36.   Toggles between scroll and roll and implements scroll lock
  37.  *****************************************************************************/
  38.  
  39. integer  scroll_mode = 1                                     // global
  40.  
  41. proc ScrollMode()                        // toggle
  42.   scroll_mode = scroll_mode ^ 1
  43.   Message(iif(scroll_mode, "  SCROLLING", "  ROLLING")+" is in effect")
  44. end
  45.  
  46. proc mRollUp()
  47.     if scroll_mode
  48.        ScrollUp()
  49.     else
  50.        RollUp()
  51.     endif
  52.     if scroll_lock and NextWindow()         // if lock do both windows
  53.        RollUp()
  54.        PrevWindow()
  55.     endif
  56. end
  57.  
  58. proc mRollDown()
  59.     if scroll_mode
  60.        ScrollDown()
  61.     else
  62.        RollDown()
  63.     endif
  64.     if scroll_lock and NextWindow()
  65.        RollDown()
  66.        PrevWindow()
  67.     endif
  68. end
  69.  
  70. /****************************************************************************
  71.   4 May 93: G. Grafton Cole                                    SCROLL ALIGN
  72.  
  73.  If more than one window:  uses current and next window
  74.   Uses the current cursor line as the search string for next window
  75.   If found:
  76.     Positions the 2ed window to the next occurance of the search string
  77.     Position the search and found string in the center of the windows
  78.     Marks the lines in inverse video
  79.   If not found:
  80.     Returns Message with "string" NOT FOUND
  81.   If only one window:  no action taken.
  82.  
  83.   This is a fairly primitive implementation, but if you are checking two
  84.     versions of the same file, it does the job.
  85.  ***************************************************************************/
  86. proc ScrollAlign()
  87.   string  s[30] = GetLine()
  88.   integer     i = 0
  89.  
  90.     if NextWindow()                             // if only one window
  91.         PrevWindow()                            // get out
  92.     else
  93.         Return()
  94.     endif
  95.  
  96.     ScrollToRow(Query(WindowRows)/2)            // center query line
  97.     if NextWindow()
  98.         if Find(s," ")                          // search forward
  99.           ScrollToRow(Query(WindowRows)/2)
  100.           VGoToXY(2,WhereY())
  101.           PutAttr(Color(Red on White),78)       // highlight line
  102.           i = 1
  103.         elseif Find(s,"g")                      // not found, search global
  104.           ScrollToRow(Query(WindowRows)/2)
  105.           VGoToXY(2,WhereY())
  106.           PutAttr(Color(Red on White),78)       // highlight line
  107.           i = 1
  108.         else                                    // not found, giveup
  109.           Message("<" + s + ">" + " NOT FOUND")
  110.         endif
  111.     endif
  112.     PrevWindow()
  113.     if i
  114.       VGoToXY(2,(Query(WindowRows)/2)+2)          // ?? + 2
  115.       PutAttr(Color(Red on White),78)             // highlight line
  116.     endif
  117. end
  118. /*------------------ END OF SCROLL FUNCTIONS  -------------------------------*/
  119.