summaryrefslogtreecommitdiff
path: root/sample/curses/hello.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/curses/hello.rb')
-rw-r--r--sample/curses/hello.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/sample/curses/hello.rb b/sample/curses/hello.rb
new file mode 100644
index 00000000000..a630fb999b8
--- /dev/null
+++ b/sample/curses/hello.rb
@@ -0,0 +1,27 @@
+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