Sha256: c126ea225de1f257765c4b52018b0d783fe304254d31f7b1402086b6b346e3a5

Contents?: true

Size: 989 Bytes

Versions: 19

Compression:

Stored size: 989 Bytes

Contents

module Libuv
    class TTY < Handle
        include Stream


        def initialize(loop, fileno, readable)
            @loop = loop

            tty_ptr = ::Libuv::Ext.create_handle(:uv_tty)
            error = check_result(::Libuv::Ext.tty_init(loop.handle, tty_ptr, fileno, readable ? 1 : 0))
            
            super(tty_ptr, error)
        end

        def enable_raw_mode
            return if @closed
            check_result ::Libuv::Ext.tty_set_mode(handle, 1)
        end

        def disable_raw_mode
            return if @closed
            check_result ::Libuv::Ext.tty_set_mode(handle, 0)
        end

        def reset_mode
            ::Libuv::Ext.tty_reset_mode
        end

        def winsize
            return [] if @closed
            width = FFI::MemoryPointer.new(:int)
            height = FFI::MemoryPointer.new(:int)
            ::Libuv::Ext.tty_get_winsize(handle, width, height)
            [width.get_int(0), height.get_int(0)]
        end
    end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
libuv-1.0.3 lib/libuv/tty.rb
libuv-1.0.2 lib/libuv/tty.rb
libuv-1.0.0 lib/libuv/tty.rb
libuv-0.12.4 lib/libuv/tty.rb
libuv-0.12.3 lib/libuv/tty.rb
libuv-0.12.2 lib/libuv/tty.rb
libuv-0.12.0 lib/libuv/tty.rb
libuv-0.11.21 lib/libuv/tty.rb
libuv-0.11.20 lib/libuv/tty.rb
libuv-0.11.19 lib/libuv/tty.rb
libuv-0.11.18 lib/libuv/tty.rb
libuv-0.11.7 lib/libuv/tty.rb
libuv-0.11.5 lib/libuv/tty.rb
libuv-0.11.3 lib/libuv/tty.rb
libuv-0.11.2 lib/libuv/tty.rb
libuv-0.11.1 lib/libuv/tty.rb
libuv-0.11.0 lib/libuv/tty.rb
libuv-0.10.3 lib/libuv/tty.rb
libuv-0.10.2 lib/libuv/tty.rb