Class: Typr::Mouse

Inherits:
Struct
  • Object
show all
Defined in:
lib/terminal.rb

Overview

A mouse event decoded from the input stream. x / y are 1-based terminal coordinates; button is 0=left, 1=middle, 2=right, or 4-7 for the wheel (up/down/left/right); modifiers holds the SGR shift/alt/ctrl bits. Non-widget code can test key.is_a?(Typr::Mouse).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject

Returns the value of attribute action

Returns:

  • (Object)

    the current value of action



64
65
66
# File 'lib/terminal.rb', line 64

def action
  @action
end

#buttonObject

Returns the value of attribute button

Returns:

  • (Object)

    the current value of button



64
65
66
# File 'lib/terminal.rb', line 64

def button
  @button
end

#modifiersObject

Returns the value of attribute modifiers

Returns:

  • (Object)

    the current value of modifiers



64
65
66
# File 'lib/terminal.rb', line 64

def modifiers
  @modifiers
end

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



64
65
66
# File 'lib/terminal.rb', line 64

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



64
65
66
# File 'lib/terminal.rb', line 64

def y
  @y
end

Instance Method Details

#left?Boolean

Returns:

  • (Boolean)


70
# File 'lib/terminal.rb', line 70

def left?;   button == 0 end

#middle?Boolean

Returns:

  • (Boolean)


71
# File 'lib/terminal.rb', line 71

def middle?; button == 1 end

#press?Boolean

Returns:

  • (Boolean)


65
# File 'lib/terminal.rb', line 65

def press?;   action == :press end

#release?Boolean

Returns:

  • (Boolean)


66
# File 'lib/terminal.rb', line 66

def release?; action == :release end

#right?Boolean

Returns:

  • (Boolean)


72
# File 'lib/terminal.rb', line 72

def right?;  button == 2 end

#to_sObject



73
74
# File 'lib/terminal.rb', line 73

def to_s; "%s button=%i x=%i y=%i%s" % [ action, button, x, y,
( modifiers > 0 ? " modifiers=#{modifiers}" : "" ) ] end

#wheel?Boolean

Returns:

  • (Boolean)


67
# File 'lib/terminal.rb', line 67

def wheel?;   button.between?(4, 7) end

#wheel_down?Boolean

Returns:

  • (Boolean)


69
# File 'lib/terminal.rb', line 69

def wheel_down?; button == 5 end

#wheel_up?Boolean

Returns:

  • (Boolean)


68
# File 'lib/terminal.rb', line 68

def wheel_up?;   button == 4 end