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



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

def action
  @action
end

#buttonObject

Returns the value of attribute button

Returns:

  • (Object)

    the current value of button



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

def button
  @button
end

#modifiersObject

Returns the value of attribute modifiers

Returns:

  • (Object)

    the current value of modifiers



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

def modifiers
  @modifiers
end

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



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

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



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

def y
  @y
end

Instance Method Details

#alt?Boolean

Returns:

  • (Boolean)


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

def alt?;     ( modifiers & 8 ) != 0 end

#left?Boolean

Returns:

  • (Boolean)


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

def left?;   button == 0 end

#middle?Boolean

Returns:

  • (Boolean)


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

def middle?; button == 1 end

#press?Boolean

Returns:

  • (Boolean)


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

def press?;   action == :press end

#release?Boolean

Returns:

  • (Boolean)


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

def release?; action == :release end

#right?Boolean

Returns:

  • (Boolean)


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

def right?;  button == 2 end

#to_sObject



80
81
# File 'lib/terminal.rb', line 80

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

#wheel?Boolean

Returns:

  • (Boolean)


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

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

#wheel_down?Boolean

Returns:

  • (Boolean)


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

def wheel_down?; button == 5 end

#wheel_up?Boolean

Returns:

  • (Boolean)


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

def wheel_up?;   button == 4 end