Class: Libuv::TTY

Inherits:
Handle show all
Includes:
Stream
Defined in:
lib/libuv/tty.rb

Constant Summary

Constants included from Stream

Stream::BACKLOG_ERROR, Stream::CLOSED_HANDLE_ERROR, Stream::STREAM_CLOSED_ERROR, Stream::WRITE_ERROR

Constants included from Assertions

Assertions::MSG_NO_PROC

Constants inherited from Q::Promise

Q::Promise::MAKE_PROMISE

Instance Attribute Summary

Attributes inherited from Handle

#closed, #loop, #storage

Instance Method Summary collapse

Methods included from Stream

#listen, #progress, #readable?, #shutdown, #start_read, #stop_read, #try_write, #writable?, #write

Methods inherited from Handle

#active?, #close, #closing?, #ref, #unref

Methods included from Assertions

#assert_block, #assert_boolean, #assert_type

Methods included from Resource

#check_result, #check_result!, #resolve, #to_ptr

Methods inherited from Q::DeferredPromise

#resolved?, #then

Methods inherited from Q::Promise

#catch, #finally, #progress

Constructor Details

#initialize(loop, fileno, readable) ⇒ TTY

Returns a new instance of TTY.



6
7
8
9
10
11
12
13
# File 'lib/libuv/tty.rb', line 6

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

Instance Method Details

#disable_raw_modeObject



20
21
22
23
# File 'lib/libuv/tty.rb', line 20

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

#enable_raw_modeObject



15
16
17
18
# File 'lib/libuv/tty.rb', line 15

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

#reset_modeObject



25
26
27
# File 'lib/libuv/tty.rb', line 25

def reset_mode
    ::Libuv::Ext.tty_reset_mode
end

#winsizeObject



29
30
31
32
33
34
35
# File 'lib/libuv/tty.rb', line 29

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