ncumbra 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/README.md +712 -6
- data/examples/ex1.rb +2 -3
- data/examples/ex3.rb +2 -3
- data/examples/ex4.rb +1 -2
- data/examples/ex5.rb +4 -3
- data/examples/exbox.rb +1 -1
- data/examples/extab3.rb +1 -2
- data/lib/umbra.rb +2 -0
- data/lib/umbra/box.rb +23 -9
- data/lib/umbra/button.rb +13 -14
- data/lib/umbra/checkbox.rb +3 -3
- data/lib/umbra/eventhandler.rb +2 -3
- data/lib/umbra/field.rb +23 -12
- data/lib/umbra/form.rb +19 -109
- data/lib/umbra/listbox.rb +26 -20
- data/lib/umbra/menu.rb +2 -2
- data/lib/umbra/messagebox.rb +2 -2
- data/lib/umbra/multiline.rb +95 -32
- data/lib/umbra/pad.rb +5 -3
- data/lib/umbra/radiobutton.rb +2 -2
- data/lib/umbra/tabular.rb +5 -2
- data/lib/umbra/textbox.rb +14 -153
- data/lib/umbra/togglebutton.rb +75 -112
- data/lib/umbra/version.rb +1 -1
- data/lib/umbra/widget.rb +9 -14
- data/lib/umbra/window.rb +8 -2
- data/tut/field.rb +72 -0
- data/tut/hello.rb +17 -0
- data/tut/label_hello.rb +28 -0
- data/tut/labfield.rb +63 -0
- metadata +6 -2
data/lib/umbra/window.rb
CHANGED
@@ -197,7 +197,7 @@ module Umbra
|
|
197
197
|
def getch
|
198
198
|
FFI::NCurses.wtimeout(@pointer, $ncurses_timeout || 1000)
|
199
199
|
c = FFI::NCurses.wgetch(@pointer)
|
200
|
-
if c == 27
|
200
|
+
if c == 27 ## {{{
|
201
201
|
|
202
202
|
# don't wait for another key
|
203
203
|
FFI::NCurses.nodelay(@pointer, true)
|
@@ -227,7 +227,7 @@ module Umbra
|
|
227
227
|
return key
|
228
228
|
|
229
229
|
end
|
230
|
-
end
|
230
|
+
end ## }}}
|
231
231
|
#FFI::NCurses.nodelay(@pointer, false) # this works but trying out for continueous updates
|
232
232
|
c
|
233
233
|
rescue SystemExit, Interrupt
|
@@ -236,6 +236,12 @@ module Umbra
|
|
236
236
|
-1 # is C-c
|
237
237
|
end
|
238
238
|
|
239
|
+
## Convenience method for a waiting getch
|
240
|
+
def getchar
|
241
|
+
$ncurses_timeout = -1
|
242
|
+
return self.getch
|
243
|
+
end
|
244
|
+
|
239
245
|
# this works fine for basic, control and function keys
|
240
246
|
def OLDgetch
|
241
247
|
c = FFI::NCurses.wgetch(@pointer)
|
data/tut/field.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# tutorial example with a label and a field
|
3
|
+
# 2018-05-25 - 14:00
|
4
|
+
require 'umbra'
|
5
|
+
require 'umbra/label'
|
6
|
+
require 'umbra/field'
|
7
|
+
|
8
|
+
begin
|
9
|
+
include Umbra
|
10
|
+
init_curses
|
11
|
+
win = Window.new
|
12
|
+
## Create a label on top, spanning the second column
|
13
|
+
title = Label.new( :text => "Demo of Fields", :row => 1, :col => 1 , :width => FFI::NCurses.COLS-2,
|
14
|
+
:justify => :center, :color_pair => CP_BLACK)
|
15
|
+
|
16
|
+
form = Form.new win
|
17
|
+
form.add_widget title ## register label with form
|
18
|
+
row = 3
|
19
|
+
col = 5
|
20
|
+
## create another label
|
21
|
+
w = Label.new( :text => "Name:", :row => row, :col => col , :width => 20)
|
22
|
+
w.color_pair = CP_WHITE
|
23
|
+
w.justify = :right
|
24
|
+
w.attr = FFI::NCurses::A_BOLD
|
25
|
+
form.add_widget w
|
26
|
+
|
27
|
+
row = 3
|
28
|
+
col = 30
|
29
|
+
## create a field
|
30
|
+
w = Field.new( :name => "name", :row => row, :col => col , :width => 50)
|
31
|
+
w.color_pair = CP_CYAN
|
32
|
+
w.attr = FFI::NCurses::A_REVERSE
|
33
|
+
w.highlight_color_pair = CP_YELLOW
|
34
|
+
w.highlight_attr = REVERSE
|
35
|
+
w.null_allowed = true
|
36
|
+
w.values = %w{ruby perl python java awk sed rust lua}
|
37
|
+
w1 = Field.new( :name => "address", :row => row+1, :col => col , :width => 50)
|
38
|
+
w1.color_pair = w.color_pair
|
39
|
+
w1.attr = w.attr
|
40
|
+
form.add_widget w, w1
|
41
|
+
|
42
|
+
|
43
|
+
## Create a label and position at the bottom row
|
44
|
+
message_label = Label.new({text: "Message comes here C-q to quit",
|
45
|
+
:name=>"message_label",:row => win.height-2, :col => 2, :width => -2,
|
46
|
+
:color_pair => CP_MAGENTA})
|
47
|
+
form.add_widget message_label
|
48
|
+
|
49
|
+
|
50
|
+
form.pack
|
51
|
+
form.select_first_field
|
52
|
+
win.wrefresh
|
53
|
+
|
54
|
+
while (ch = win.getkey) != FFI::NCurses::KEY_CTRL_Q
|
55
|
+
next if ch == -1
|
56
|
+
begin
|
57
|
+
form.handle_key ch
|
58
|
+
rescue => e
|
59
|
+
alert e.to_s
|
60
|
+
end
|
61
|
+
win.wrefresh
|
62
|
+
end
|
63
|
+
|
64
|
+
rescue => e
|
65
|
+
win.destroy if win
|
66
|
+
FFI::NCurses.endwin
|
67
|
+
puts e.to_s
|
68
|
+
puts e.backtrace.join("\n")
|
69
|
+
ensure
|
70
|
+
win.destroy if win
|
71
|
+
FFI::NCurses.endwin
|
72
|
+
end
|
data/tut/hello.rb
ADDED
data/tut/label_hello.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# 2018-05-24
|
3
|
+
require 'umbra'
|
4
|
+
require 'umbra/label'
|
5
|
+
|
6
|
+
begin
|
7
|
+
include Umbra
|
8
|
+
init_curses
|
9
|
+
#$log = create_logger '/dev/null'
|
10
|
+
win = Window.new
|
11
|
+
title = Label.new( :text => "Demo of Labels", :row => 0, :col => 0 , :width => FFI::NCurses.COLS-1,
|
12
|
+
:justify => :center, :color_pair => 0)
|
13
|
+
|
14
|
+
form = Form.new win
|
15
|
+
form.add_widget title
|
16
|
+
form.pack
|
17
|
+
form.repaint
|
18
|
+
win.wrefresh
|
19
|
+
|
20
|
+
while (ch = win.getkey) != 113
|
21
|
+
next if ch == -1
|
22
|
+
win.wrefresh
|
23
|
+
end
|
24
|
+
|
25
|
+
ensure
|
26
|
+
win.destroy
|
27
|
+
FFI::NCurses.endwin
|
28
|
+
end
|
data/tut/labfield.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# example showing labeledfield
|
3
|
+
# 2018-05-26
|
4
|
+
require 'umbra'
|
5
|
+
require 'umbra/label'
|
6
|
+
require 'umbra/labeledfield'
|
7
|
+
|
8
|
+
begin
|
9
|
+
include Umbra
|
10
|
+
init_curses
|
11
|
+
win = Window.new
|
12
|
+
title = Label.new( :text => "Demo of LabeledFields", :row => 0, :col => 0 , :width => -1,
|
13
|
+
:justify => :center, :color_pair => CP_BLACK)
|
14
|
+
|
15
|
+
form = Form.new win
|
16
|
+
form.add_widget title
|
17
|
+
labels = ["Name:", "Age:", "Address:","Mobile No.:", "Email Id:","Hobbies:"]
|
18
|
+
names = ["name", "age", "address","mobile", "email","hobbies"]
|
19
|
+
|
20
|
+
row = 3
|
21
|
+
col = 30
|
22
|
+
names.each_with_index {|lab, ix|
|
23
|
+
w = LabeledField.new( :name => lab, :row => row, :col => col , :width => 50, label: labels[ix],
|
24
|
+
:label_highlight_attr => BOLD
|
25
|
+
)
|
26
|
+
row += 2
|
27
|
+
w.color_pair = CP_CYAN
|
28
|
+
w.attr = FFI::NCurses::A_REVERSE
|
29
|
+
w.highlight_color_pair = CP_YELLOW
|
30
|
+
w.highlight_attr = REVERSE
|
31
|
+
w.null_allowed = true
|
32
|
+
form.add_widget w
|
33
|
+
}
|
34
|
+
message_label = Label.new({text: "Message comes here C-q to quit",
|
35
|
+
:name=>"message_label",:row => -2, :col => 2, :width => 60,
|
36
|
+
:color_pair => CP_MAGENTA})
|
37
|
+
form.add_widget message_label
|
38
|
+
form.pack
|
39
|
+
form.select_first_field
|
40
|
+
win.wrefresh
|
41
|
+
|
42
|
+
y = x = 1
|
43
|
+
while (ch = win.getkey) != FFI::NCurses::KEY_CTRL_Q
|
44
|
+
if ch == -1
|
45
|
+
message_label.text = Time.now
|
46
|
+
form.repaint
|
47
|
+
next
|
48
|
+
end
|
49
|
+
begin
|
50
|
+
form.handle_key ch
|
51
|
+
rescue => e
|
52
|
+
alert(e.to_s)
|
53
|
+
end
|
54
|
+
win.wrefresh
|
55
|
+
end
|
56
|
+
|
57
|
+
rescue => e
|
58
|
+
win.destroy if win
|
59
|
+
FFI::NCurses.endwin
|
60
|
+
ensure
|
61
|
+
win.destroy if win
|
62
|
+
FFI::NCurses.endwin
|
63
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncumbra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kepler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,6 +112,10 @@ files:
|
|
112
112
|
- lib/umbra/version.rb
|
113
113
|
- lib/umbra/widget.rb
|
114
114
|
- lib/umbra/window.rb
|
115
|
+
- tut/field.rb
|
116
|
+
- tut/hello.rb
|
117
|
+
- tut/label_hello.rb
|
118
|
+
- tut/labfield.rb
|
115
119
|
- umbra.gemspec
|
116
120
|
homepage: https://github.com/mare-imbrium/umbra
|
117
121
|
licenses:
|