Sha256: 61b87a8c5b33dc19e5ceee912b1b189ebd2179cfa317440659ae980fef26e8fb

Contents?: true

Size: 960 Bytes

Versions: 32

Compression:

Stored size: 960 Bytes

Contents

require 'io/console'

module Cuboid
module Support
module Mixins

# Terminal manipulation methods.
module Terminal

    # Clears the line before printing using `puts`.
    #
    # @param    [String]    str
    #   String to output
    def reputs( str = '' )
        reprint str + "\n"
    end

    # Clears the line before printing.
    #
    # @param    [String]    str
    #   String to output.
    def reprint( str = '' )
        print restr( str )
    end

    def restr( str = '' )
        "\e[0K" + str
    end

    # Clear the bottom of the screen
    def clear_screen
        print "\e[2J"
    end

    def empty_screen
        move_to_home
        rows, cols = $stdin.winsize
        (rows - 1).times{ puts ' ' * cols }
        move_to_home
    end

    # Moves cursor top left to its home
    def move_to_home
        print "\e[H"
    end

    # Flushes the STDOUT buffer
    def flush
        $stdout.flush
    end

    extend self
end

end
end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
cuboid-0.2.11 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.10 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.9 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.8 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.7 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.6 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.5 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.4.2 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.4.1 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.4 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.3 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.2 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2.1 lib/cuboid/support/mixins/terminal.rb
cuboid-0.2 lib/cuboid/support/mixins/terminal.rb
cuboid-0.1.9.1 lib/cuboid/support/mixins/terminal.rb
cuboid-0.1.9 lib/cuboid/support/mixins/terminal.rb
cuboid-0.1.8 lib/cuboid/support/mixins/terminal.rb
cuboid-0.1.7 lib/cuboid/support/mixins/terminal.rb
cuboid-0.1.6.1 lib/cuboid/support/mixins/terminal.rb
cuboid-0.1.6 lib/cuboid/support/mixins/terminal.rb