Sha256: 72cc48712ee75870e26603054bc17762467dacf3a7c2dfbb557ef2e771d628d5

Contents?: true

Size: 985 Bytes

Versions: 7

Compression:

Stored size: 985 Bytes

Contents

require 'rubytext'
require 'timeout'

def next_slide
  RubyText.hide_cursor
  sleep 2
  Timeout.timeout(999) do
    STDSCR.go @rmax-1, 0
    STDSCR.center "Press any key..."
    getch
  end
rescue Timeout::Error
end

def show_code(prog)
  text = File.read(prog)
  nlines = text.split("\n").size

  prog_top = @rmax-nlines-3
  code = RubyText.window(nlines+2, @cmax-2, prog_top, 1, 
                         true, fg: :green, bg: :black)
  code.puts text

  STDSCR.go prog_top, 61
  STDSCR.print "[ #{prog} ]"
  STDSCR.go 0,0
end

def check_window
  if @rmax < 25 || @cmax < 80
    puts "\n  Your window should be 25x80 or larger,"
    puts   "  but this one is only  #{rmax}x#{cmax}."
    puts "  Please resize and run again!"
    getch
    exit 1
  end
end

#### Main

RubyText.start(:cbreak, log: "showme.log", fg: :white, bg: :black)

@cmax = STDSCR.cols
@rmax = STDSCR.rows

RubyText.hide_cursor

check_window

prog = ARGV.first

show_code(prog)

require_relative prog

next_slide

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubytext-0.0.35 examples/showme.rb
rubytext-0.0.34 examples/showme.rb
rubytext-0.0.33 examples/showme.rb
rubytext-0.0.32 examples/showme.rb
rubytext-0.0.31 examples/showme.rb
rubytext-0.0.30 examples/showme.rb
rubytext-0.0.29 examples/showme.rb