File: test_scanw.rb

package info (click to toggle)
ruby-ncurses 1.4.13-0.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 484 kB
  • sloc: ansic: 4,962; ruby: 1,099; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 593 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env ruby

# $Id: test_scanw.rb,v 1.1 2003-03-22 22:55:00 t-peters Exp $
#
# Test of the scanw function. Should really not be used in any serious curses
# program. To use it, install scanf for ruby.

# Copyright (C) 2003 Tobias Peters <t-peters@users.berlios.de>
#
# No warranties. Share and enjoy.

require "ncursesw"
begin
  Ncurses.initscr
  Ncurses.mvaddstr(4, 19, "Give me a number: ")
  Ncurses.refresh
  num = []
  Ncurses.scanw("%d", num)

  Ncurses.mvprintw(6, 19, "You gave: %d", num[0])
  Ncurses.refresh
  sleep 1
ensure
  Ncurses.endwin
end

puts("You gave: #{num[0]}")