curses 1.2.7 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -150,6 +150,16 @@ if header_library
150
150
  $defs << '-DHAVE_MENU'
151
151
  end
152
152
 
153
+ if (have_header("ncursesw/form.h") ||
154
+ have_header("ncurses/form.h") ||
155
+ have_header("curses/form.h") ||
156
+ have_header("form.h")) &&
157
+ (have_library("formw", "new_form") ||
158
+ have_library("form", "new_form"))
159
+ $defs << '-DHAVE_FORM'
160
+ have_func("form_driver_w")
161
+ end
162
+
153
163
  if RUBY_VERSION >= '2.1'
154
164
  create_header
155
165
  create_makefile("curses")
@@ -0,0 +1,52 @@
1
+ require "curses"
2
+
3
+ Curses.init_screen
4
+ Curses.cbreak
5
+ Curses.noecho
6
+ Curses.stdscr.keypad = true
7
+ at_exit do
8
+ Curses.close_screen
9
+ end
10
+
11
+ fields = [
12
+ Curses::Field.new(1, 10, 4, 18, 0, 0),
13
+ Curses::Field.new(1, 10, 6, 18, 0, 0)
14
+ ]
15
+ fields.each do |field|
16
+ field.set_back(Curses::A_UNDERLINE)
17
+ field.opts_off(Curses::O_AUTOSKIP)
18
+ end
19
+
20
+ form = Curses::Form.new(fields)
21
+ form.post
22
+
23
+ Curses.setpos(4, 10)
24
+ Curses.addstr("Value 1:")
25
+ Curses.setpos(6, 10)
26
+ Curses.addstr("Value 2:")
27
+
28
+ while ch = Curses.get_char
29
+ begin
30
+ case ch
31
+ when Curses::KEY_F1
32
+ break
33
+ when Curses::KEY_DOWN
34
+ form.driver(Curses::REQ_NEXT_FIELD)
35
+ form.driver(Curses::REQ_END_LINE)
36
+ when Curses::KEY_UP
37
+ form.driver(Curses::REQ_PREV_FIELD)
38
+ form.driver(Curses::REQ_END_LINE)
39
+ when Curses::KEY_RIGHT
40
+ form.driver(Curses::REQ_NEXT_CHAR)
41
+ when Curses::KEY_LEFT
42
+ form.driver(Curses::REQ_PREV_CHAR)
43
+ when Curses::KEY_BACKSPACE
44
+ form.driver(Curses::REQ_DEL_PREV)
45
+ else
46
+ form.driver(ch)
47
+ end
48
+ rescue Curses::RequestDeniedError
49
+ end
50
+ end
51
+
52
+ form.unpost
@@ -5,13 +5,13 @@ Curses.cbreak
5
5
  Curses.noecho
6
6
  Curses.stdscr.keypad = true
7
7
  at_exit do
8
- Curses.cloes_screen
8
+ Curses.close_screen
9
9
  end
10
10
 
11
11
  menu = Curses::Menu.new([
12
- Curses::Item.new("Apple", "Red fruit"),
13
- Curses::Item.new("Orange", "Orange fruit"),
14
- Curses::Item.new("Banana", "Yellow fruit")
12
+ ["Apple", "Red fruit"],
13
+ ["Orange", "Orange fruit"],
14
+ ["Banana", "Yellow fruit"]
15
15
  ])
16
16
  menu.post
17
17
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curses
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-10 00:00:00.000000000 Z
12
+ date: 2019-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -77,6 +77,7 @@ files:
77
77
  - ext/curses/depend
78
78
  - ext/curses/extconf.rb
79
79
  - lib/curses.rb
80
+ - sample/form.rb
80
81
  - sample/hello.rb
81
82
  - sample/menu.rb
82
83
  - sample/mouse.rb