mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ffb9da9fa0
* samples/curses/*: Move Curses samples and refactor from mixin The samples are included in rdoc for module and use of mixin is confusing git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
27 lines
562 B
Ruby
27 lines
562 B
Ruby
require "curses"
|
|
|
|
def show_message(message)
|
|
width = message.length + 6
|
|
win = Curses::Window.new(5, width,
|
|
(Curses.lines - 5) / 2, (Curses.cols - width) / 2)
|
|
win.box('|', '-')
|
|
win.setpos(2, 3)
|
|
win.addstr(message)
|
|
win.refresh
|
|
win.getch
|
|
win.close
|
|
end
|
|
|
|
Curses.init_screen
|
|
begin
|
|
Curses.crmode
|
|
# show_message("Hit any key")
|
|
Curses.setpos((Curses.lines - 5) / 2, (Curses.cols - 10) / 2)
|
|
Curses.addstr("Hit any key")
|
|
Curses.refresh
|
|
char = Curses.getch
|
|
show_message("You typed: #{char}")
|
|
Curses.refresh
|
|
ensure
|
|
Curses.close_screen
|
|
end
|