Loading ...
Sorry, an error occurred while loading the content.
 

[jasspa] Line hilighting using the mouse selected region.

Expand Messages
  • Jon
    Some people might find this useful. This is a modification to hiline.emf that uses the mouse selection to set up the line hilighting when invoked
    Message 1 of 1 , Jan 18, 2000
      Some people might find this useful. This is a modification to
      hiline.emf that uses the mouse selection to set up the line
      hilighting when invoked from a

      right-mouse -> Hilight Line -> <color/remove>

      selection. The macro determines the mouse selected region and
      makes an appropriate decision as to how the line hilighting
      scheme is to be applied.

      The following rules apply to the mouse selection:-

      a) Point in line selected (i.e. mark == point)

      Hilight the line only.

      b) Region in the line selected. Both point and mark are on
      the same line.

      Extract the selected text and hilight all lines that
      match the search pattern. The color "remove" is also
      pattern matched to selectively remove lines.

      c) Region selected mark & point on different lines

      Block up the region with appropriate hilight.

      Note that the macro protects against folded line hilighting and
      may be safely used in a folded buffer.

      This macro has only been tested with the latest beta, it should
      work with the 99/12/01 release. If it fails then restore the
      existing macro.

      To install, replace the existing macro "line-scheme" in
      hiline.emf with the macro that is supplied below. Then execute
      the buffer (i.e. M-x execute-buffer) or restart the editor.

      Hopefully I have not made any mistakes - seems to be working
      here!!

      Regards
      Jon.

      ______________________________________________________________________

      ;
      ; Set the line scheme of a single line - Called from the
      ; hilight line pop-up in mouse.emf. In this instance we
      ; search for the mouse region. We apply the following
      ; tests:-
      ;
      ; a) Point in line selected (i.e. mark == point)
      ;
      ; Hilight the line.
      ;
      ; b) Region in the line selected. Both point and
      ; mark are on the same line.
      ;
      ; Search for all lines that match the pattern
      ;
      ; c) Region selected mark & point different lines
      ;
      ; Block up the region with appropriate hilight.
      ;
      0 define-macro line-scheme
      ; Get the properties of the line color.
      !if @?
      set-variable #l5 @#
      !else
      set-variable #l5 -1
      !endif
      ; Determine the markup region on the screen
      0 show-region
      !if &equ &band $result 0x6 0x6
      set-alpha-mark "."
      ; Goto start of region and get the extents.
      -2 show-region
      set-variable #l1 $window-line
      set-variable #l2 $window-col
      set-alpha-mark "<"
      2 show-region
      set-variable #l3 $window-line
      set-variable #l4 $window-col
      set-alpha-mark ">"
      goto-alpha-mark "."

      ; Check the lines to see if they are the same
      !if &equ #l1 #l3
      ; If the columns are the same this is a point then only
      ; hilight the line.
      !if &equ #l2 #l4
      ; Protect folded lines
      !if &or &equ $line-scheme -1 ¬ &or &gre $line-scheme .scheme.hlcyan &les $line-scheme .scheme.hlwhite
      set-variable $line-scheme #l5
      !endif
      !else
      ; The columns are different assume that this is a selection
      ; search. Get the selected region by using the yank buffer
      ; to get the search string. Once we have the search string
      ; then we convert this to a non regular expression and
      ; locate *ALL* of the lines that are carrying this pattern.
      goto-alpha-mark "<"
      set-mark
      goto-alpha-mark ">"
      copy-region
      set-variable #l9 @y
      -1 yank
      str-to-regex #l9
      beginning-of-buffer
      !repeat
      !force search-forward #l9
      set-variable #l8 $status
      !if #l8
      ; Protect folded lines
      !if &or &equ $line-scheme -1 ¬ &or &gre $line-scheme .scheme.hlcyan &les $line-scheme .scheme.hlwhite
      set-variable $line-scheme #l5
      !endif
      !endif
      !until ¬ #l8
      !endif
      !else
      ; Block fill the region. First decide which is the smallest and
      ; then select all of the lines to the hilighted state.
      !if &les #l1 #l3
      set-variable #l7 #l1
      set-variable #l8 #l4
      set-variable #l6 &sub #l3 #l7
      !else
      set-variable #l7 #l3
      set-variable #l8 #l2
      set-variable #l6 &sub #l1 #l7
      !endif
      ; If we are not at column 0 then add 1, this is effectivelly
      ; where the selection region has spilled over onto the next
      ; line.
      !if &gre #l8 0
      set-variable #l6 &add #l6 1
      !endif
      ; Back to the start of the region and apply block hilight.
      goto-line #l7
      !repeat
      ; Protect folded lines
      !if &or &equ $line-scheme -1 ¬ &or &gre $line-scheme .scheme.hlcyan &les $line-scheme .scheme.hlwhite
      set-variable $line-scheme #l5
      !endif
      set-variable #l6 &sub #l6 1
      !force forward-line
      !until ¬ &and $status &gre #l6 0
      !endif
      ; Restore our cursor position
      goto-alpha-mark "."
      !else
      ; Not sure what this is. Simply hilight the line.
      ; Protect folded lines.
      !if &or &equ $line-scheme -1 ¬ &or &gre $line-scheme .scheme.hlcyan &les $line-scheme .scheme.hlwhite
      set-variable $line-scheme #l5
      !endif
      !endif
      !emacro
    Your message has been successfully submitted and would be delivered to recipients shortly.