2009-06-03 11 views
0

私は、次のコードを持ってSTDIN.getcは自分のアプリケーションのロック

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 

私は画面のinitアプリケーションのアプリケーション・ロックとdoesntのを実行してみてください。 Curses.getchを使用する場合、この問題は発生しません。

これがなぜ起こるのか誰にでも教えてもらえますか?問題を解決する方法は?

答えて

1

そして、これはあなたがすべて良いときれいな呪いとSTDIN

+1

のthatsを混ぜてはならない理由が、私はCurses.getchを使用して解決策を見つけることができませんでしたし、私の問題は私が決めたSTDINが解決しようとすると思われるので、ありますそれを試してください。 http://stackoverflow.com/questions/897687/ruby-keyboard-event-handlingを参照してください。 –

関連する問題