ncumbra 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG +14 -0
- data/README.md +21 -6
- data/examples/data/atp_matches_2017.csv +2887 -0
- data/examples/data/atp_matches_2018.csv +460 -0
- data/examples/data/import.sh +13 -0
- data/examples/data/schema.txt +51 -0
- data/examples/ex1.rb +2 -0
- data/examples/ex2.rb +1 -0
- data/examples/ex5.rb +1 -1
- data/examples/exbox.rb +3 -2
- data/examples/exm1.rb +1 -2
- data/examples/extab2.rb +170 -0
- data/examples/extab3.rb +306 -0
- data/examples/extabular.rb +123 -0
- data/examples/tasks.csv +88 -0
- data/lib/umbra/box.rb +38 -21
- data/lib/umbra/checkbox.rb +2 -2
- data/lib/umbra/dialog.rb +1 -2
- data/lib/umbra/eventhandler.rb +52 -4
- data/lib/umbra/field.rb +7 -3
- data/lib/umbra/form.rb +119 -55
- data/lib/umbra/keymappinghandler.rb +4 -4
- data/lib/umbra/label.rb +31 -17
- data/lib/umbra/labeledfield.rb +7 -8
- data/lib/umbra/listbox.rb +114 -341
- data/lib/umbra/messagebox.rb +93 -42
- data/lib/umbra/multiline.rb +476 -0
- data/lib/umbra/pad.rb +20 -14
- data/lib/umbra/radiobutton.rb +2 -2
- data/lib/umbra/table.rb +260 -0
- data/lib/umbra/tabular.rb +431 -0
- data/lib/umbra/textbox.rb +36 -223
- data/lib/umbra/togglebutton.rb +3 -5
- data/lib/umbra/version.rb +1 -1
- data/lib/umbra/widget.rb +72 -13
- data/lib/umbra/window.rb +59 -15
- data/lib/umbra.rb +82 -11
- data/umbra.gemspec +2 -2
- metadata +18 -4
data/lib/umbra.rb
CHANGED
@@ -4,22 +4,25 @@ require "umbra/window"
|
|
4
4
|
require "umbra/form"
|
5
5
|
|
6
6
|
module Umbra
|
7
|
+
|
8
|
+
def curses
|
9
|
+
FFI::NCurses
|
10
|
+
end
|
11
|
+
|
7
12
|
def alert str, config={}
|
8
13
|
require 'umbra/dialog'
|
9
|
-
#title = config[:title] || "Alert"
|
10
|
-
#cp = config[:color_pair] || create_color_pair( COLOR_BLUE, COLOR_WHITE )
|
11
|
-
#attr = config[:attrib] || NORMAL
|
12
14
|
|
13
15
|
config[:text] ||= str
|
14
16
|
config[:title] ||= "Alert"
|
15
17
|
config[:window_color_pair] ||= create_color_pair( COLOR_BLUE, COLOR_WHITE )
|
16
18
|
config[:window_attr] ||= NORMAL
|
17
19
|
config[:buttons] ||= ["Ok"]
|
18
|
-
|
20
|
+
|
19
21
|
#m = Dialog.new text: str, title: title, window_color_pair: cp, window_attr: attr
|
20
22
|
m = Dialog.new config
|
21
23
|
m.run
|
22
24
|
end
|
25
|
+
|
23
26
|
# confirmation dialog which prompts message with Ok and Cancel and returns true or false.
|
24
27
|
def confirm str, config={}
|
25
28
|
require 'umbra/dialog'
|
@@ -29,19 +32,87 @@ module Umbra
|
|
29
32
|
config[:window_color_pair] ||= create_color_pair( COLOR_BLUE, COLOR_WHITE )
|
30
33
|
config[:window_attr] ||= NORMAL
|
31
34
|
config[:buttons] ||= ["Ok", "Cancel"]
|
32
|
-
|
35
|
+
|
33
36
|
m = Dialog.new config
|
34
37
|
ret = m.run
|
35
38
|
return ret == 0
|
36
39
|
end
|
37
40
|
|
41
|
+
## Pop up a dialog with an array, such as an exception
|
42
|
+
def textdialog array, config={}
|
43
|
+
require 'umbra/messagebox'
|
44
|
+
config[:title] ||= "Alert"
|
45
|
+
config[:buttons] ||= ["Ok"]
|
46
|
+
|
47
|
+
mb = MessageBox.new config do
|
48
|
+
text array
|
49
|
+
end
|
50
|
+
mb.run
|
51
|
+
end
|
52
|
+
|
38
53
|
# view an array in a popup window
|
39
|
-
def view array, config={}
|
54
|
+
def view array, config={}, &block
|
40
55
|
require 'umbra/pad'
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
56
|
+
config[:title] ||= "Viewer"
|
57
|
+
config[:color_pair] ||= create_color_pair( COLOR_BLUE, COLOR_WHITE )
|
58
|
+
config[:attrib] ||= NORMAL
|
59
|
+
config[:list] = array
|
60
|
+
config[:height] ||= FFI::NCurses.LINES-2
|
61
|
+
config[:width] ||= FFI::NCurses.COLS-10
|
62
|
+
#m = Pad.new list: array, height: FFI::NCurses.LINES-2, width: FFI::NCurses.COLS-10, title: title, color_pair: cp, attrib: attr
|
63
|
+
m = Pad.new config, &block
|
45
64
|
m.run
|
46
65
|
end
|
47
|
-
|
66
|
+
|
67
|
+
## create a logger instance given a path, return the logger
|
68
|
+
def create_logger path, config={}
|
69
|
+
require 'logger'
|
70
|
+
_path = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)
|
71
|
+
logg = Logger.new(_path)
|
72
|
+
raise "Could not create logger: #{path}" unless logg
|
73
|
+
## if not set, will default to 0 which is debug. Other values are 1 - info, 2 - warn
|
74
|
+
logg.level = config[:level] || ENV["UMBRA_LOG_LEVEL"].to_i
|
75
|
+
#logg.info "START -- #{$0} log level: #{logg.level}. To change log level, increase UMBRA_LOG_LEVEL in your environment to 1 or 2 or 3."
|
76
|
+
return logg
|
77
|
+
end
|
78
|
+
|
79
|
+
## Trying out a key loop to simplify matters for user. NOT TESTED.
|
80
|
+
## @yield key pressed if block given, else calls form.handle_key(ch).
|
81
|
+
def main_loop form, &block
|
82
|
+
win = form.window
|
83
|
+
form.repaint
|
84
|
+
win.wrefresh
|
85
|
+
stopping = false
|
86
|
+
while true
|
87
|
+
catch :close do
|
88
|
+
while( ch = win.getkey) != 999
|
89
|
+
begin
|
90
|
+
if ch == curses::KEY_CTRL_Q
|
91
|
+
stopping = true
|
92
|
+
break
|
93
|
+
end
|
94
|
+
if block_given?
|
95
|
+
yield ch
|
96
|
+
else
|
97
|
+
form.handle_key ch
|
98
|
+
end
|
99
|
+
rescue => err
|
100
|
+
if $log
|
101
|
+
$log.debug( "loop in umbra.rb handle_key rescue reached ")
|
102
|
+
$log.debug( err.to_s)
|
103
|
+
$log.debug(err.backtrace.join("\n"))
|
104
|
+
end
|
105
|
+
textdialog [err.to_s, *err.backtrace], :title => "Exception"
|
106
|
+
end
|
107
|
+
win.wrefresh
|
108
|
+
end
|
109
|
+
#stopping = win.fire_close_handler ## TODO next version
|
110
|
+
#win.wrefresh
|
111
|
+
break if stopping
|
112
|
+
end
|
113
|
+
break if stopping
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
end # module
|
data/umbra.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["kepler"]
|
10
10
|
spec.email = ["githubkepler.50s@gishpuppy.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{tiny ncurses library for creating simple apps}
|
13
|
-
spec.description = %q{minimal, provides forms and a few basic widgets}
|
12
|
+
spec.summary = %q{tiny ncurses library for creating simple apps. Stripped version of Canis. 2018}
|
13
|
+
spec.description = %q{minimal ncurses wrapper/library, provides forms, lists, textareas, tables and a few other basic widgets. Stripped version of canis gem. 2018}
|
14
14
|
spec.homepage = "https://github.com/mare-imbrium/umbra"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
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.1
|
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-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,8 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.4.0
|
55
|
-
description: minimal, provides forms
|
55
|
+
description: minimal ncurses wrapper/library, provides forms, lists, textareas, tables
|
56
|
+
and a few other basic widgets. Stripped version of canis gem. 2018
|
56
57
|
email:
|
57
58
|
- githubkepler.50s@gishpuppy.com
|
58
59
|
executables: []
|
@@ -60,6 +61,7 @@ extensions: []
|
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
62
63
|
- ".gitignore"
|
64
|
+
- CHANGELOG
|
63
65
|
- Gemfile
|
64
66
|
- LICENSE
|
65
67
|
- README.md
|
@@ -67,6 +69,10 @@ files:
|
|
67
69
|
- Rakefile
|
68
70
|
- bin/console
|
69
71
|
- bin/setup
|
72
|
+
- examples/data/atp_matches_2017.csv
|
73
|
+
- examples/data/atp_matches_2018.csv
|
74
|
+
- examples/data/import.sh
|
75
|
+
- examples/data/schema.txt
|
70
76
|
- examples/ex1.rb
|
71
77
|
- examples/ex2.rb
|
72
78
|
- examples/ex21.rb
|
@@ -75,7 +81,11 @@ files:
|
|
75
81
|
- examples/ex5.rb
|
76
82
|
- examples/exbox.rb
|
77
83
|
- examples/exm1.rb
|
84
|
+
- examples/extab2.rb
|
85
|
+
- examples/extab3.rb
|
86
|
+
- examples/extabular.rb
|
78
87
|
- examples/keys.rb
|
88
|
+
- examples/tasks.csv
|
79
89
|
- examples/tt.rb
|
80
90
|
- lib/umbra.rb
|
81
91
|
- lib/umbra/box.rb
|
@@ -92,8 +102,11 @@ files:
|
|
92
102
|
- lib/umbra/listbox.rb
|
93
103
|
- lib/umbra/menu.rb
|
94
104
|
- lib/umbra/messagebox.rb
|
105
|
+
- lib/umbra/multiline.rb
|
95
106
|
- lib/umbra/pad.rb
|
96
107
|
- lib/umbra/radiobutton.rb
|
108
|
+
- lib/umbra/table.rb
|
109
|
+
- lib/umbra/tabular.rb
|
97
110
|
- lib/umbra/textbox.rb
|
98
111
|
- lib/umbra/togglebutton.rb
|
99
112
|
- lib/umbra/version.rb
|
@@ -123,5 +136,6 @@ rubyforge_project:
|
|
123
136
|
rubygems_version: 2.7.6
|
124
137
|
signing_key:
|
125
138
|
specification_version: 4
|
126
|
-
summary: tiny ncurses library for creating simple apps
|
139
|
+
summary: tiny ncurses library for creating simple apps. Stripped version of Canis.
|
140
|
+
2018
|
127
141
|
test_files: []
|