curses_menu 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2226bebb142878eb4467c0471c3978f683746634acc51e6852f3b9298fbd3cf
4
- data.tar.gz: 23f6626cf28f160149106907a307cdc49ce64741f62ffb6053e16ad276267223
3
+ metadata.gz: 607c643000199bc2b3ef7cf3b2cd16346bcb8f1c4035eb30c2d033bac0df1626
4
+ data.tar.gz: e71f143c744eff5b971c2821ee1538990fc9906baf5596fec4622294f4ffc4e4
5
5
  SHA512:
6
- metadata.gz: 31d298f6320962b6061936eff73ba7a517f10c0ec0b8b681455ae71df372b8ef5e0ee674d598fe094c76de18531a1d4a3a07b58ae2d405a6112a03b00bfd5275
7
- data.tar.gz: 6f49adde82fac8dfd6e7f513184735b3f9e9f0024857b00604b9180bd926659a1a9ddece7ef112ad671f1921d60c236204359c8d6fe361a491c9fe393a31cd4f
6
+ metadata.gz: 66129319cbf7647404eb77ef0d1f8ef095bbd1e5cf3b61561a23bd5d7e7f675e4d7a62721baa377d228b7bea2b280423603f0a7280cf40ab3389d70174c1154f
7
+ data.tar.gz: bf877618677e1ca577f6e1899f85800f12b91c40a0c620deb9d07b52fa1b6ec1d28ed2a5c3cdb709c76daee35476644ead429b8e5a7e04573c32c0dc98e06a83
data/examples/actions.rb CHANGED
@@ -1,25 +1,25 @@
1
- require 'curses_menu'
2
-
3
- nbr = 0
4
- CursesMenu.new 'Items can have several actions. Look at the footer!' do |menu|
5
- menu.item "Current number is #{nbr} - Use a or d", actions: {
6
- 'd' => {
7
- name: 'Increase',
8
- execute: proc do
9
- nbr += 1
10
- :menu_refresh
11
- end
12
- },
13
- 'a' => {
14
- name: 'Decrease',
15
- execute: proc do
16
- nbr -= 1
17
- :menu_refresh
18
- end
19
- }
20
- }
21
- menu.item 'Quit' do
22
- puts 'Quitting...'
23
- :menu_exit
24
- end
25
- end
1
+ require 'curses_menu'
2
+
3
+ nbr = 0
4
+ CursesMenu.new 'Items can have several actions. Look at the footer!' do |menu|
5
+ menu.item "Current number is #{nbr} - Use a or d", actions: {
6
+ 'd' => {
7
+ name: 'Increase',
8
+ execute: proc do
9
+ nbr += 1
10
+ :menu_refresh
11
+ end
12
+ },
13
+ 'a' => {
14
+ name: 'Decrease',
15
+ execute: proc do
16
+ nbr -= 1
17
+ :menu_refresh
18
+ end
19
+ }
20
+ }
21
+ menu.item 'Quit' do
22
+ puts 'Quitting...'
23
+ :menu_exit
24
+ end
25
+ end
@@ -1,49 +1,49 @@
1
- require 'curses_menu'
2
-
3
- keys = [
4
- # Select first
5
- CursesMenu::KEY_ENTER,
6
- # Select second
7
- Curses::KEY_DOWN,
8
- 'a',
9
- 'b',
10
- # Select third (sub-menu)
11
- Curses::KEY_DOWN,
12
- CursesMenu::KEY_ENTER,
13
- # Select sub-menu first
14
- CursesMenu::KEY_ENTER,
15
- # Exit sub-menu
16
- CursesMenu::KEY_ESCAPE,
17
- # Navigate a bit
18
- Curses::KEY_NPAGE,
19
- Curses::KEY_HOME,
20
- # Select last
21
- Curses::KEY_END,
22
- CursesMenu::KEY_ENTER
23
- ]
24
- CursesMenu.new('Menu being used automatically', key_presses: keys) do |menu|
25
- menu.item 'Simple item' do
26
- puts 'Selected a simple item'
27
- end
28
- menu.item 'Several actions on this item', actions: {
29
- 'a' => {
30
- name: 'Action A',
31
- execute: proc { puts 'Selected action A' }
32
- },
33
- 'b' => {
34
- name: 'Action B',
35
- execute: proc { puts 'Selected action B' }
36
- }
37
- }
38
- menu.item 'Sub-menu' do
39
- CursesMenu.new('Sub-menu!', key_presses: keys) do |sub_menu|
40
- sub_menu.item 'Simple sub-menu item' do
41
- puts 'Selected item from sub-menu'
42
- end
43
- end
44
- end
45
- menu.item 'Quit' do
46
- puts 'Quitting...'
47
- :menu_exit
48
- end
49
- end
1
+ require 'curses_menu'
2
+
3
+ keys = [
4
+ # Select first
5
+ CursesMenu::KEY_ENTER,
6
+ # Select second
7
+ Curses::KEY_DOWN,
8
+ 'a',
9
+ 'b',
10
+ # Select third (sub-menu)
11
+ Curses::KEY_DOWN,
12
+ CursesMenu::KEY_ENTER,
13
+ # Select sub-menu first
14
+ CursesMenu::KEY_ENTER,
15
+ # Exit sub-menu
16
+ CursesMenu::KEY_ESCAPE,
17
+ # Navigate a bit
18
+ Curses::KEY_NPAGE,
19
+ Curses::KEY_HOME,
20
+ # Select last
21
+ Curses::KEY_END,
22
+ CursesMenu::KEY_ENTER
23
+ ]
24
+ CursesMenu.new('Menu being used automatically', key_presses: keys) do |menu|
25
+ menu.item 'Simple item' do
26
+ puts 'Selected a simple item'
27
+ end
28
+ menu.item 'Several actions on this item', actions: {
29
+ 'a' => {
30
+ name: 'Action A',
31
+ execute: proc { puts 'Selected action A' }
32
+ },
33
+ 'b' => {
34
+ name: 'Action B',
35
+ execute: proc { puts 'Selected action B' }
36
+ }
37
+ }
38
+ menu.item 'Sub-menu' do
39
+ CursesMenu.new('Sub-menu!', key_presses: keys) do |sub_menu|
40
+ sub_menu.item 'Simple sub-menu item' do
41
+ puts 'Selected item from sub-menu'
42
+ end
43
+ end
44
+ end
45
+ menu.item 'Quit' do
46
+ puts 'Quitting...'
47
+ :menu_exit
48
+ end
49
+ end
@@ -1,130 +1,148 @@
1
- require 'curses_menu'
2
-
3
- dynamic_row_1 = CursesMenu::CursesRow.new(
4
- first_cell: { text: 'Select to' },
5
- second_cell: {
6
- text: 'change the',
7
- color_pair: CursesMenu::COLORS_GREEN
8
- },
9
- third_cell: {
10
- text: 'cells order',
11
- color_pair: CursesMenu::COLORS_RED
12
- }
13
- )
14
- dynamic_row_2 = CursesMenu::CursesRow.new(
15
- first_cell: { text: 'Select to change' },
16
- second_cell: {
17
- text: 'the cells properties',
18
- color_pair: CursesMenu::COLORS_GREEN,
19
- fixed_size: 40
20
- }
21
- )
22
- CursesMenu.new 'Extended formatting available too!' do |menu|
23
- menu.item CursesMenu::CursesRow.new(
24
- default_cell: {
25
- text: 'Simple color change - GREEN!',
26
- color_pair: CursesMenu::COLORS_GREEN
27
- }
28
- )
29
- menu.item CursesMenu::CursesRow.new(
30
- green_cell: {
31
- text: 'Several cells ',
32
- color_pair: CursesMenu::COLORS_GREEN
33
- },
34
- red_cell: {
35
- text: 'with different ',
36
- color_pair: CursesMenu::COLORS_RED
37
- },
38
- blue_cell: {
39
- text: 'formatting',
40
- color_pair: CursesMenu::COLORS_BLUE
41
- }
42
- )
43
- menu.item CursesMenu::CursesRow.new(
44
- default_cell: {
45
- text: 'Use prefixes and suffixes',
46
- begin_with: '[ ',
47
- end_with: ' ]'
48
- }
49
- )
50
- menu.item CursesMenu::CursesRow.new(
51
- first_cell: {
52
- text: 'This will have a fixed size!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!',
53
- begin_with: '[ ',
54
- end_with: ' ]',
55
- fixed_size: 40
56
- },
57
- second_cell: {
58
- text: 'And other cells will be aligned',
59
- color_pair: CursesMenu::COLORS_GREEN
60
- }
61
- )
62
- menu.item CursesMenu::CursesRow.new(
63
- first_cell: {
64
- text: 'Pretty nice',
65
- fixed_size: 40
66
- },
67
- second_cell: {
68
- text: 'for alignment',
69
- color_pair: CursesMenu::COLORS_GREEN
70
- }
71
- )
72
- menu.item CursesMenu::CursesRow.new(
73
- first_cell: {
74
- text: 'And you can justify',
75
- justify: :right,
76
- fixed_size: 40
77
- },
78
- second_cell: {
79
- text: 'your text when size is fixed!',
80
- justify: :left,
81
- color_pair: CursesMenu::COLORS_GREEN
82
- }
83
- )
84
- menu.item CursesMenu::CursesRow.new(
85
- first_cell: {
86
- text: 'You can even',
87
- justify: :right,
88
- fixed_size: 40,
89
- pad: '_-'
90
- },
91
- second_cell: {
92
- text: 'pad it!',
93
- justify: :left,
94
- color_pair: CursesMenu::COLORS_GREEN,
95
- fixed_size: 40,
96
- pad: '*'
97
- }
98
- )
99
- menu.item CursesMenu::CursesRow.new(
100
- {
101
- first_cell: { text: 'Use a' },
102
- second_cell: {
103
- text: 'different separator',
104
- color_pair: CursesMenu::COLORS_GREEN
105
- },
106
- third_cell: { text: 'between cells' }
107
- },
108
- separator: '|'
109
- )
110
- menu.item dynamic_row_1 do
111
- dynamic_row_1.cells_order([:first_cell, :second_cell, :third_cell].sort_by { rand })
112
- :menu_refresh
113
- end
114
- menu.item dynamic_row_2 do
115
- dynamic_row_2.change_cells(
116
- first_cell: {
117
- color_pair: [CursesMenu::COLORS_GREEN, CursesMenu::COLORS_RED, CursesMenu::COLORS_BLUE].sample
118
- },
119
- second_cell: {
120
- color_pair: [CursesMenu::COLORS_GREEN, CursesMenu::COLORS_RED, CursesMenu::COLORS_BLUE].sample,
121
- pad: ['*', ' ', '|', '='].sample
122
- }
123
- )
124
- :menu_refresh
125
- end
126
- menu.item 'Quit' do
127
- puts 'Quitting...'
128
- :menu_exit
129
- end
130
- end
1
+ require 'curses_menu'
2
+
3
+ dynamic_row_1 = CursesMenu::CursesRow.new(
4
+ {
5
+ first_cell: { text: 'Select to' },
6
+ second_cell: {
7
+ text: 'change the',
8
+ color_pair: CursesMenu::COLORS_GREEN
9
+ },
10
+ third_cell: {
11
+ text: 'cells order',
12
+ color_pair: CursesMenu::COLORS_RED
13
+ }
14
+ }
15
+ )
16
+ dynamic_row_2 = CursesMenu::CursesRow.new(
17
+ {
18
+ first_cell: { text: 'Select to change' },
19
+ second_cell: {
20
+ text: 'the cells properties',
21
+ color_pair: CursesMenu::COLORS_GREEN,
22
+ fixed_size: 40
23
+ }
24
+ }
25
+ )
26
+ CursesMenu.new 'Extended formatting available too!' do |menu|
27
+ menu.item CursesMenu::CursesRow.new(
28
+ {
29
+ default_cell: {
30
+ text: 'Simple color change - GREEN!',
31
+ color_pair: CursesMenu::COLORS_GREEN
32
+ }
33
+ }
34
+ )
35
+ menu.item CursesMenu::CursesRow.new(
36
+ {
37
+ green_cell: {
38
+ text: 'Several cells ',
39
+ color_pair: CursesMenu::COLORS_GREEN
40
+ },
41
+ red_cell: {
42
+ text: 'with different ',
43
+ color_pair: CursesMenu::COLORS_RED
44
+ },
45
+ blue_cell: {
46
+ text: 'formatting',
47
+ color_pair: CursesMenu::COLORS_BLUE
48
+ }
49
+ }
50
+ )
51
+ menu.item CursesMenu::CursesRow.new(
52
+ {
53
+ default_cell: {
54
+ text: 'Use prefixes and suffixes',
55
+ begin_with: '[ ',
56
+ end_with: ' ]'
57
+ }
58
+ }
59
+ )
60
+ menu.item CursesMenu::CursesRow.new(
61
+ {
62
+ first_cell: {
63
+ text: 'This will have a fixed size!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!',
64
+ begin_with: '[ ',
65
+ end_with: ' ]',
66
+ fixed_size: 40
67
+ },
68
+ second_cell: {
69
+ text: 'And other cells will be aligned',
70
+ color_pair: CursesMenu::COLORS_GREEN
71
+ }
72
+ }
73
+ )
74
+ menu.item CursesMenu::CursesRow.new(
75
+ {
76
+ first_cell: {
77
+ text: 'Pretty nice',
78
+ fixed_size: 40
79
+ },
80
+ second_cell: {
81
+ text: 'for alignment',
82
+ color_pair: CursesMenu::COLORS_GREEN
83
+ }
84
+ }
85
+ )
86
+ menu.item CursesMenu::CursesRow.new(
87
+ {
88
+ first_cell: {
89
+ text: 'And you can justify',
90
+ justify: :right,
91
+ fixed_size: 40
92
+ },
93
+ second_cell: {
94
+ text: 'your text when size is fixed!',
95
+ justify: :left,
96
+ color_pair: CursesMenu::COLORS_GREEN
97
+ }
98
+ }
99
+ )
100
+ menu.item CursesMenu::CursesRow.new(
101
+ {
102
+ first_cell: {
103
+ text: 'You can even',
104
+ justify: :right,
105
+ fixed_size: 40,
106
+ pad: '_-'
107
+ },
108
+ second_cell: {
109
+ text: 'pad it!',
110
+ justify: :left,
111
+ color_pair: CursesMenu::COLORS_GREEN,
112
+ fixed_size: 40,
113
+ pad: '*'
114
+ }
115
+ }
116
+ )
117
+ menu.item CursesMenu::CursesRow.new(
118
+ {
119
+ first_cell: { text: 'Use a' },
120
+ second_cell: {
121
+ text: 'different separator',
122
+ color_pair: CursesMenu::COLORS_GREEN
123
+ },
124
+ third_cell: { text: 'between cells' }
125
+ },
126
+ separator: '|'
127
+ )
128
+ menu.item dynamic_row_1 do
129
+ dynamic_row_1.cells_order(%i[first_cell second_cell third_cell].sort_by { rand })
130
+ :menu_refresh
131
+ end
132
+ menu.item dynamic_row_2 do
133
+ dynamic_row_2.change_cells(
134
+ first_cell: {
135
+ color_pair: [CursesMenu::COLORS_GREEN, CursesMenu::COLORS_RED, CursesMenu::COLORS_BLUE].sample
136
+ },
137
+ second_cell: {
138
+ color_pair: [CursesMenu::COLORS_GREEN, CursesMenu::COLORS_RED, CursesMenu::COLORS_BLUE].sample,
139
+ pad: ['*', ' ', '|', '='].sample
140
+ }
141
+ )
142
+ :menu_refresh
143
+ end
144
+ menu.item 'Quit' do
145
+ puts 'Quitting...'
146
+ :menu_exit
147
+ end
148
+ end
data/examples/hello.rb CHANGED
@@ -1,8 +1,8 @@
1
- require 'curses_menu'
2
-
3
- CursesMenu.new 'My awesome new menu!' do |menu|
4
- menu.item 'How\'s life?' do
5
- puts 'Couldn\'t be easier'
6
- :menu_exit
7
- end
8
- end
1
+ require 'curses_menu'
2
+
3
+ CursesMenu.new 'My awesome new menu!' do |menu|
4
+ menu.item 'How\'s life?' do
5
+ puts 'Couldn\'t be easier'
6
+ :menu_exit
7
+ end
8
+ end