Sha256: 196430cf39b6f6d7d7b142c0f54547a19fb4758c064b68b1c233acfe9b96b997

Contents?: true

Size: 1.46 KB

Versions: 25

Compression:

Stored size: 1.46 KB

Contents

$LOAD_PATH << "lib"

if ARGV.size != 2
  STDERR.puts "Usage: ruby ide.rb libname.rb progname.rb"
  exit
end

require 'rubytext'

RubyText.start

# print " "  # FIXME - bug requires this?

@lib, @code = ARGV

def menu
$debug.puts "Entering menu"
  @mywin.output do
#   boxme   # FIXME - dumb hack
    @mywin.clear
    puts
    puts " World's Simplest Ruby IDE\n "
    puts " Lib  = #{@lib}"
    puts " Code = #{@code}"
    puts 
    puts " 1  Edit lib"
    puts " 2  Edit code"
    puts " 3  Run code"
    puts " 4  pry"
    puts " 5  Shell"
    puts " 6  irb"
    puts " 7  RubyDocs"
    puts
    puts " 0  Quit"
    print "\n  Choice = "
    @mywin.refresh   # FIXME - dumb hack
  end
$debug.puts "Exiting menu"
end

def shell(str)
  STDSCR.clear
  RubyText.show_cursor
  system("stty sane")   # FIXME - dumb hack
  STDSCR.puts "\n\n  When you exit, you will\n  return to the IDE.\n "
  system(str)
  X.noecho   # FIXME Shouldn't have to do this stuff
  X.stdscr.keypad(true)
  X.cbreak   # by default
end

@mywin = RubyText.window(19, 30, 1, 2, true)

loop do 
  menu
  cmd = getch.chr
  case cmd
    when "1"; system("vi #{@lib}")
    when "2"; system("vi #{@code}") 
    when "3"; system("tput clear; ruby #{@code}; sleep 5")
    when "4"; shell("pry")
    when "5"; shell("bash")
    when "6"; shell("irb")
    when "7"; system("open -a Safari http://ruby-doc.org")
    when "0"; exit
    else 
      @mywin.rcprint 12, 4, "\n\n  No such command '#{cmd}'"
      sleep 2
      next
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
rubytext-0.0.62 examples/ide.rb
rubytext-0.0.61 examples/ide.rb
rubytext-0.0.60 examples/ide.rb
rubytext-0.0.59 examples/ide.rb
rubytext-0.0.58 examples/ide.rb
rubytext-0.0.57 examples/ide.rb
rubytext-0.0.56 examples/ide.rb
rubytext-0.0.55 examples/ide.rb
rubytext-0.0.54 examples/ide.rb
rubytext-0.0.53 examples/ide.rb
rubytext-0.0.52 examples/ide.rb
rubytext-0.0.51 examples/ide.rb
rubytext-0.0.50 examples/ide.rb
rubytext-0.0.49 examples/ide.rb
rubytext-0.0.48 examples/ide.rb
rubytext-0.0.47 examples/ide.rb
rubytext-0.0.46 examples/ide.rb
rubytext-0.0.45 examples/ide.rb
rubytext-0.0.44 examples/ide.rb
rubytext-0.0.43 examples/ide.rb