views:

128

answers:

1

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?

+1  A: 

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

rampion
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