Sha256: 1dd5e2a082f509e45d786448a0ee03fe797ab9b795edde8afc37eabe65c72693
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require 'rubygems' require 'thread' # This program demonstrates that the curses getch call blocks all Ruby # threads. # # The code comes from a 2009 blog post by William Morgan. # http://masanjin.net/blog/ruby-ncurses-and-thread-blocking # # # Morgan is the original developer of Sup, a ruby curse email client (https://github.com/sup-heliotrope/sup) # and he works for tweeter now. # # Here is the original code from the post. =begin require 'ncurses' Ncurses.initscr Ncurses.noecho Ncurses.cbreak Ncurses.curs_set 0 Thread.new do sleep 0.1 Ncurses.stdscr.mvaddstr 0, 0, "library is GOOD." end begin Ncurses.stdscr.mvaddstr 0, 0, "library is BAD." Ncurses.getch ensure Ncurses.curs_set 1 Ncurses.endwin puts "bye" end =end # Here is the port. require 'curses' Thread.new do sleep 0.1 Curses.stdscr.setpos(0, 0) Curses.stdscr.addstr('library is GOOD') end Curses.init_screen Curses.raw Curses.clear Curses.curs_set(0) Curses.noecho Curses.cbreak Curses.start_color Curses.stdscr.setpos(0, 0) Curses.stdscr.addstr('library is BAD') Curses.stdscr.getch Curses.close_screen
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ppcurses-0.1.2 | test/threads/block_test.rb |
ppcurses-0.1.1 | test/threads/block_test.rb |
ppcurses-0.1.0 | test/threads/block_test.rb |