Sha256: 9d84c0d659058b04ff6665daabed5b41c33b8cbe242244aeb371e4769d926d15

Contents?: true

Size: 1.1 KB

Versions: 21

Compression:

Stored size: 1.1 KB

Contents

require 'rubytext'

def next_slide
  RubyText.hide_cursor
  case @proceed
    when /\d+/
      sleep @proceed.to_i
    when "pause"
      STDSCR.go @rmax-1-@upward, 0
      STDSCR.center "Press any key..."
      getch
  end
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, r: prog_top, c: 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, @proceed, @upward = ARGV
@upward ||= 0

show_code(prog, @upward)

require_relative prog

next_slide # if @upward == 0

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rubytext-0.1.7 examples/showme.rb
rubytext-0.1.6 examples/showme.rb
rubytext-0.1.5 examples/showme.rb
rubytext-0.1.4 examples/showme.rb
rubytext-0.1.3 examples/showme.rb
rubytext-0.1.2 examples/showme.rb
rubytext-0.1.1 examples/showme.rb
rubytext-0.1.0 examples/showme.rb
rubytext-0.0.99 examples/showme.rb
rubytext-0.0.98 examples/showme.rb
rubytext-0.0.97 examples/showme.rb
rubytext-0.0.96 examples/showme.rb
rubytext-0.0.95 examples/showme.rb
rubytext-0.0.94 examples/showme.rb
rubytext-0.0.93 examples/showme.rb
rubytext-0.0.92 examples/showme.rb
rubytext-0.0.91 examples/showme.rb
rubytext-0.0.90 examples/showme.rb
rubytext-0.0.89 examples/showme.rb
rubytext-0.0.88 examples/showme.rb