Sha256: 8d36c7c85b01caef441ad3c80e0c5e98ec958afa9e1794ba038f46bcdb577a49

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

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

2 entries across 2 versions & 1 rubygems

Version Path
libuv-0.11.22 lib/libuv/tty.rb
libuv-0.11.4 lib/libuv/tty.rb