module RETerm::MouseInput

Constants

ALL_EVENTS
MOUSE_MAP

Public Instance Methods

mouse_paste?() click to toggle source
# File lib/reterm/mixins/mouse_input.rb, line 14
def mouse_paste?
  !!reterm_opts[:mouse_paste]
end
on_button(b, evnt, coords) click to toggle source

May be overridden in subclass, invoked when the user interacts with a button.

@param [Integer] b number of the button that was invoked @param [Symbol] evnt button event, may be :press, :release,

:click, :dclick (double click), :tclick (triple click)
# File lib/reterm/mixins/mouse_input.rb, line 24
def on_button(b, evnt, coords)
  #puts "B#{b} #{evnt}, #{coords}"
end
process_mouse(ch) click to toggle source
# File lib/reterm/mixins/mouse_input.rb, line 28
def process_mouse(ch)
  return nil unless ch == Ncurses::KEY_MOUSE

  mev = Ncurses::MEVENT.new
  Ncurses.getmouse(mev)

  if mev.bstate == Ncurses::BUTTON2_CLICKED && mouse_paste?
    # TODO grab clipboard buffer & return character array
    #   (need to handle seperately in invoker)
    #
    # use https://github.com/janlelis/clipboard
    # but note this requires external programs!
  end

  # TODO 5 button support (requiest "--enable-ext-mouse" ncurses flag
  # which is not specified in many major distrubtions)
  1.upto(4).each { |b|
    MOUSE_MAP.each { |n, e|
      if mev.bstate == Ncurses.const_get("BUTTON#{b}_#{n}")
        x,y,z = mev.x, mev.y, mev.z
        on_button(b, e, [x,y,z])
      end
    }
  }

  # TODO wrap MEVENT w/ our own class,
  # w/ high levels helpers for buttons, coords, etc
  mev
end