Sha256: a12ee389a3bae93e01465a4084d3c3f6899e422c926e3ede51cddce02b21884a

Contents?: true

Size: 1.74 KB

Versions: 24

Compression:

Stored size: 1.74 KB

Contents

module Vedeu

  module EscapeSequences

    # Provides mouse related escape sequences.
    #
    # The X10 compatibility mode sends an escape sequence on button
    # press encoding the location and the mouse button pressed. It is
    # enabled by sending `\e[?9h` and disabled with `\e[?9l`.
    #
    # On button press, xterm(1) sends `\e[Mbxy` (6 characters).
    # Here b is button-1, and x and y are the x and y coordinates of
    # the mouse when the button was pressed. This is the same code the
    # kernel also produces.
    #
    # Normal tracking mode (not implemented in Linux 2.0.24) sends an
    # escape sequence on both button press and release. Modifier
    # information is also sent. It is enabled by sending `\e[?1000h`
    # and disabled with `\e[?1000l`. On button press or release,
    # xterm(1) sends `\e[Mbxy`. The low two bits of b encode button
    # information: 0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed,
    # 3=release. The upper bits encode what modifiers were down when
    # the button was pressed and are added together: 4=Shift, 8=Meta,
    # 16=Control. Again x and y are the x and y coordinates of the
    # mouse event. The upper left corner is (1,1).
    #
    # - From CONSOLE_CODES(4) (`man console_codes`)
    #
    module Mouse

      extend self

      # @return [Hash<Symbol => String>]
      def mouse_codes
        {
          mouse_x10_on:  "\e[?9h".freeze,
          mouse_x10_off: "\e[?9l".freeze,
          mouse_on:      "\e[?1000h".freeze,
          mouse_off:     "\e[?1000l".freeze,
        }
      end

      # @return [void]
      def setup!
        mouse_codes.each { |key, code| define_method(key) { code } }
      end

    end # Mouse

  end # EscapeSequences

  Vedeu::EscapeSequences::Mouse.setup!

end # Vedeu

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
vedeu-0.7.4 lib/vedeu/esc/mouse.rb
vedeu-0.7.3 lib/vedeu/esc/mouse.rb
vedeu-0.7.2 lib/vedeu/esc/mouse.rb
vedeu-0.7.1 lib/vedeu/esc/mouse.rb
vedeu-0.7.0 lib/vedeu/esc/mouse.rb
vedeu-0.6.71 lib/vedeu/esc/mouse.rb
vedeu-0.6.70 lib/vedeu/esc/mouse.rb
vedeu-0.6.69 lib/vedeu/esc/mouse.rb
vedeu-0.6.68 lib/vedeu/esc/mouse.rb
vedeu-0.6.67 lib/vedeu/esc/mouse.rb
vedeu-0.6.66 lib/vedeu/esc/mouse.rb
vedeu-0.6.65 lib/vedeu/esc/mouse.rb
vedeu-0.6.64 lib/vedeu/esc/mouse.rb
vedeu-0.6.63 lib/vedeu/esc/mouse.rb
vedeu-0.6.62 lib/vedeu/esc/mouse.rb
vedeu-0.6.61 lib/vedeu/esc/mouse.rb
vedeu-0.6.60 lib/vedeu/esc/mouse.rb
vedeu-0.6.59 lib/vedeu/esc/mouse.rb
vedeu-0.6.58 lib/vedeu/esc/mouse.rb
vedeu-0.6.57 lib/vedeu/esc/mouse.rb