Sha256: 1ea1827625ab2dffa21f8684a03c6949a949335ae7323963fc710ee745c83bc1

Contents?: true

Size: 1.08 KB

Versions: 28

Compression:

Stored size: 1.08 KB

Contents

require 'rubytext'
require 'timeout'

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

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

  prog_top = @rmax-nlines-3 - upward.to_i
  code = RubyText.window(nlines+2, @cmax-2, prog_top, 1, 
                         fg: Green, bg: Black)
  code.puts text

  right = STDSCR.cols - prog.length - 8
  STDSCR.go prog_top, right 
  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: "/tmp/showme.log", fg: White, bg: Black)

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

RubyText.hide_cursor

check_window

prog, @upward = ARGV
@upward ||= 0

show_code(prog, @upward)

require_relative prog

next_slide # if @upward == 0

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
rubytext-0.0.84 examples/showme.rb
rubytext-0.0.83 examples/showme.rb
rubytext-0.0.82 examples/showme.rb
rubytext-0.0.81 examples/showme.rb
rubytext-0.0.80 examples/showme.rb
rubytext-0.0.79 examples/showme.rb
rubytext-0.0.78 examples/showme.rb
rubytext-0.0.77 examples/showme.rb
rubytext-0.0.76 examples/showme.rb
rubytext-0.0.75 examples/showme.rb
rubytext-0.0.74 examples/showme.rb
rubytext-0.0.73 examples/showme.rb
rubytext-0.0.72 examples/showme.rb
rubytext-0.0.71 examples/showme.rb
rubytext-0.0.70 examples/showme.rb
rubytext-0.0.69 examples/showme.rb
rubytext-0.0.68 examples/showme.rb
rubytext-0.0.67 examples/showme.rb
rubytext-0.0.66 examples/showme.rb
rubytext-0.0.65 examples/showme.rb