curses_menu 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/curses_menu/version.rb +1 -1
- data/lib/curses_menu.rb +2 -2
- data/spec/curses_menu_test/actions_spec.rb +2 -2
- data/spec/curses_menu_test/formatting_spec.rb +4 -6
- data/spec/curses_menu_test/scrolling_spec.rb +3 -3
- data/spec/curses_menu_test.rb +10 -4
- metadata +17 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74becd64c41df7dc7628e8c2b2c416c56f430c53d9be7e3e68698bb6bc1633aa
|
4
|
+
data.tar.gz: 02bf486f61ae412243d536912202a36eb03d72d6c3c0e4ff034808221193d3f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7014fece6ecf47e9f0dba36ee8b835841b8176809a09f52bf16e87892719075da8847427a62b2558068bb15abd6cb12cab0f49b4456693c417740c0d306f77d
|
7
|
+
data.tar.gz: c407a1d42c57f39fa7c32488191097186c574fca00bd043e664b7cce45f0fba946d227712f9754025b0c9c72fac342cd721e3429cd2d4427b3d2bc4bfdc6dac6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# [v0.0.6](https://github.com/Muriel-Salvan/curses_menu/compare/v0.0.5...v0.0.6) (2022-10-12 15:48:18)
|
2
|
+
|
3
|
+
### Patches
|
4
|
+
|
5
|
+
* [Bump versions](https://github.com/Muriel-Salvan/curses_menu/commit/ec272ce612c45a127f90613f3133e0186eab8e22)
|
6
|
+
|
7
|
+
# [v0.0.5](https://github.com/Muriel-Salvan/curses_menu/compare/v0.0.4...v0.0.5) (2021-08-18 11:48:24)
|
8
|
+
|
9
|
+
### Patches
|
10
|
+
|
11
|
+
* [[Hotfix] Add Windows support](https://github.com/Muriel-Salvan/curses_menu/commit/b47b51a79988363c0e292987fe4a97dd6f05c6d8)
|
12
|
+
|
1
13
|
# [v0.0.4](https://github.com/Muriel-Salvan/curses_menu/compare/v0.0.3...v0.0.4) (2021-08-18 10:25:59)
|
2
14
|
|
3
15
|
### Patches
|
data/lib/curses_menu/version.rb
CHANGED
data/lib/curses_menu.rb
CHANGED
@@ -74,7 +74,7 @@ class CursesMenu
|
|
74
74
|
}
|
75
75
|
if current_items[selected_idx][:actions]
|
76
76
|
display_actions.merge!(
|
77
|
-
current_items[selected_idx][:actions].
|
77
|
+
current_items[selected_idx][:actions].to_h do |action_shortcut, action_info|
|
78
78
|
[
|
79
79
|
case action_shortcut
|
80
80
|
when KEY_ENTER
|
@@ -84,7 +84,7 @@ class CursesMenu
|
|
84
84
|
end,
|
85
85
|
action_info[:name]
|
86
86
|
]
|
87
|
-
end
|
87
|
+
end
|
88
88
|
)
|
89
89
|
end
|
90
90
|
print(
|
@@ -7,7 +7,7 @@ describe CursesMenu do
|
|
7
7
|
actioned = true
|
8
8
|
end
|
9
9
|
end
|
10
|
-
expect(actioned).to
|
10
|
+
expect(actioned).to be(true)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'actions the default selection when pressed enter on the correct item' do
|
@@ -115,7 +115,7 @@ describe CursesMenu do
|
|
115
115
|
:menu_exit
|
116
116
|
end
|
117
117
|
end
|
118
|
-
expect(quit).to
|
118
|
+
expect(quit).to be(true)
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'navigates in sub-menus' do
|
@@ -15,9 +15,7 @@ describe CursesMenu do
|
|
15
15
|
# This test is pending a better support for UTF-8.
|
16
16
|
# cf https://github.com/ruby/curses/issues/65
|
17
17
|
# TODO: Uncomment when Ruby curses will be fixed.
|
18
|
-
# rubocop:disable Style/AsciiComments
|
19
18
|
# assert_line 3, 'Simple string - 単純な文字列'
|
20
|
-
# rubocop:enable Style/AsciiComments
|
21
19
|
assert_line 3, /^Simple string - .+$/
|
22
20
|
end
|
23
21
|
|
@@ -245,7 +243,7 @@ describe CursesMenu do
|
|
245
243
|
|
246
244
|
it 'does not exceed line when several cells are too long' do
|
247
245
|
nbr_visible_chars = Curses.stdscr.maxx
|
248
|
-
nbr_chars_per_cell = nbr_visible_chars / 3 + 1
|
246
|
+
nbr_chars_per_cell = (nbr_visible_chars / 3) + 1
|
249
247
|
test_menu do |menu|
|
250
248
|
menu.item CursesMenu::CursesRow.new(
|
251
249
|
{
|
@@ -257,13 +255,13 @@ describe CursesMenu do
|
|
257
255
|
)
|
258
256
|
menu.item 'Menu item 2'
|
259
257
|
end
|
260
|
-
assert_line 3, "#{'1' * nbr_chars_per_cell} #{'2' * nbr_chars_per_cell} #{'3' * (nbr_visible_chars - 2 * nbr_chars_per_cell - 3)}"
|
258
|
+
assert_line 3, "#{'1' * nbr_chars_per_cell} #{'2' * nbr_chars_per_cell} #{'3' * (nbr_visible_chars - (2 * nbr_chars_per_cell) - 3)}"
|
261
259
|
assert_line 4, 'Menu item 2'
|
262
260
|
end
|
263
261
|
|
264
262
|
it 'does not exceed line when several cells are too long due to separators' do
|
265
263
|
nbr_visible_chars = Curses.stdscr.maxx
|
266
|
-
nbr_chars_per_cell = nbr_visible_chars / 3 + 1
|
264
|
+
nbr_chars_per_cell = (nbr_visible_chars / 3) + 1
|
267
265
|
test_menu do |menu|
|
268
266
|
menu.item CursesMenu::CursesRow.new(
|
269
267
|
{
|
@@ -274,7 +272,7 @@ describe CursesMenu do
|
|
274
272
|
)
|
275
273
|
menu.item 'Menu item 2'
|
276
274
|
end
|
277
|
-
assert_line 3, "#{'1' * nbr_chars_per_cell}#{'2' * nbr_chars_per_cell}#{'3' * (nbr_visible_chars - 2 * nbr_chars_per_cell - 1)}"
|
275
|
+
assert_line 3, "#{'1' * nbr_chars_per_cell}#{'2' * nbr_chars_per_cell}#{'3' * (nbr_visible_chars - (2 * nbr_chars_per_cell) - 1)}"
|
278
276
|
assert_line 4, 'Menu item 2'
|
279
277
|
end
|
280
278
|
|
@@ -45,7 +45,7 @@ describe CursesMenu do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
assert_line 3, "Menu item #{nbr_visible_items - 2}"
|
48
|
-
assert_line(-3, "Menu item #{2 * nbr_visible_items - 3}")
|
48
|
+
assert_line(-3, "Menu item #{(2 * nbr_visible_items) - 3}")
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'scrolls by using page down key' do
|
@@ -56,7 +56,7 @@ describe CursesMenu do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
assert_line 3, "Menu item #{nbr_visible_items - 1}"
|
59
|
-
assert_line(-3, "Menu item #{nbr_visible_items * 2 - 2}")
|
59
|
+
assert_line(-3, "Menu item #{(nbr_visible_items * 2) - 2}")
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'scrolls by using page up key' do
|
@@ -78,7 +78,7 @@ describe CursesMenu do
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
assert_line 3, "Menu item #{nbr_visible_items}"
|
81
|
-
assert_line(-3, "Menu item #{nbr_visible_items * 2 - 1}")
|
81
|
+
assert_line(-3, "Menu item #{(nbr_visible_items * 2) - 1}")
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'scrolls by using home key' do
|
data/spec/curses_menu_test.rb
CHANGED
@@ -36,7 +36,7 @@ module CursesMenuTest
|
|
36
36
|
window.setpos old_y, old_x
|
37
37
|
# Build the map of colors per color pair acutally registered
|
38
38
|
colors_left_shift = Curses::A_COLOR.to_s(2).match(/^1+(0+)$/)[1].size
|
39
|
-
color_pairs = CursesMenu.constants.select { |const| const.to_s.start_with?('COLORS_') }.
|
39
|
+
color_pairs = CursesMenu.constants.select { |const| const.to_s.start_with?('COLORS_') }.to_h do |const|
|
40
40
|
color_pair = CursesMenu.const_get(const)
|
41
41
|
[
|
42
42
|
# On Windows using Curses.color_pair can result in bugs [BUG] Unnormalized Fixnum value when using/displaying the value.
|
@@ -46,12 +46,18 @@ module CursesMenuTest
|
|
46
46
|
color_pair << colors_left_shift,
|
47
47
|
const
|
48
48
|
]
|
49
|
-
end
|
49
|
+
end
|
50
50
|
chars.
|
51
51
|
map do |chr|
|
52
52
|
{
|
53
|
-
char:
|
54
|
-
|
53
|
+
char: begin
|
54
|
+
(chr & Curses::A_CHARTEXT).chr(Encoding::UTF_8)
|
55
|
+
rescue RangeError
|
56
|
+
# On Windows curses returns wrong encoded characters.
|
57
|
+
# In this case we just force an ASCII version of it.
|
58
|
+
(chr & 255).chr(Encoding::UTF_8)
|
59
|
+
end,
|
60
|
+
color: color_pairs[chr & Curses::A_COLOR] || (chr & Curses::A_COLOR),
|
55
61
|
attributes: chr & Curses::A_ATTRIBUTES
|
56
62
|
}
|
57
63
|
end.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curses_menu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muriel Salvan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
33
|
+
version: '3.11'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
40
|
+
version: '3.11'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sem_ver_components
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.36'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.36'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '2.
|
75
|
+
version: '2.13'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '2.
|
82
|
+
version: '2.13'
|
83
83
|
description:
|
84
84
|
email:
|
85
85
|
- muriel@x-aeon.com
|
@@ -87,17 +87,17 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files:
|
89
89
|
- CHANGELOG.md
|
90
|
-
- README.md
|
91
90
|
- LICENSE.md
|
92
|
-
-
|
93
|
-
- examples/
|
94
|
-
- examples/sub_menus.rb
|
91
|
+
- README.md
|
92
|
+
- examples/actions.rb
|
95
93
|
- examples/automatic_key_presses.rb
|
96
|
-
- examples/refresh.rb
|
97
94
|
- examples/formatting.rb
|
98
|
-
- examples/
|
99
|
-
- examples/
|
95
|
+
- examples/hello.rb
|
96
|
+
- examples/refresh.rb
|
100
97
|
- examples/scrolling.rb
|
98
|
+
- examples/several_items.rb
|
99
|
+
- examples/sub_menus.rb
|
100
|
+
- examples/utf_8.rb
|
101
101
|
files:
|
102
102
|
- CHANGELOG.md
|
103
103
|
- LICENSE.md
|
@@ -126,6 +126,7 @@ licenses:
|
|
126
126
|
- BSD-3-Clause
|
127
127
|
metadata:
|
128
128
|
homepage_uri: https://github.com/Muriel-Salvan/curses_menu
|
129
|
+
rubygems_mfa_required: 'true'
|
129
130
|
post_install_message:
|
130
131
|
rdoc_options: []
|
131
132
|
require_paths:
|
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
- !ruby/object:Gem::Version
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
145
|
+
rubygems_version: 3.3.7
|
145
146
|
signing_key:
|
146
147
|
specification_version: 4
|
147
148
|
summary: Simple menu offering choices with navigation keys using curses
|