0

I have the following code

class TimeReport
  def run
    init_screen
    lines = Curses::lines
    cols  = Curses::cols
    read=""

    begin
      crmode
      noecho

      gotoDay  diaActual.data.to_s #loads the screen with data

      while !read.eql?("q")
        printPrompt #simply prints the command prompt
        read=STDIN.getc
        printOnSpot 10,10,read.to_s #prints what was read

        if(!read.empty? && !read.strip.empty?)
          processPrompt(read,@ecra) # process the read command
          else
          printInfo "Say What??" 
          end
      end

    ensure

    echo
    nocrmode
    close_screen
    end
  end
end
TimeReport.new.run

When i try running the application the application locks and doesnt init the screen. If i use Curses.getch this issue doesn't occur.

Can anyone enlighten me as to why this happens? and ways to fix the issue?

Nuno Furtado
  • 4,548
  • 8
  • 37
  • 57

1 Answers1

1

And this is why you shouldn't mix Curses and STDIN

rampion
  • 87,131
  • 49
  • 199
  • 315
  • 1
    thats all good and pretty, but since i couldn't find a solution using Curses.getch and my problem seems to be solved by STDIN i decided i should try it. see http://stackoverflow.com/questions/897687/ruby-keyboard-event-handling – Nuno Furtado Jun 03 '09 at 11:31