Sha256: f7486217c6b32272021dac864cf60760f6c8857717c9fa1ff5846ce9efa3d8c9

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 Bytes

Contents

require 'io/console'

require_relative '../support/esc'

module Vedeu
  module Terminal
    extend self
    # :nocov:
    def open(&block)
      console.cooked do
        output Esc.string('reset')
        output Esc.string('clear')
        output Esc.string('hide_cursor')

        yield
      end if block_given?
    ensure
      output Esc.string('show_cursor')
      output Esc.string('reset')
      output Esc.clear_last_line
    end
    # :nocov:

    def input
      console.gets.chomp
    end

    def output(stream = '')
      console.print(stream)

      stream
    end

    def width
      size.last
    end

    def height
      size.first
    end

    def size
      console.winsize
    end

    def console
      IO.console
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.0.31 lib/vedeu/support/terminal.rb
vedeu-0.0.30 lib/vedeu/support/terminal.rb