ppcurses 0.0.21 → 0.0.22
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 +7 -7
- data/README.rdoc +1 -1
- data/lib/ppcurses/Constants.rb +8 -0
- data/lib/ppcurses/Screen.rb +7 -2
- data/lib/ppcurses/actions/BaseAction.rb +7 -7
- data/lib/ppcurses/actions/GetBooleanAction.rb +2 -2
- data/lib/ppcurses/actions/InsertSQLDataAction.rb +4 -4
- data/lib/ppcurses/actions/PromptAction.rb +5 -5
- data/lib/ppcurses/actions/ShowMenuAction.rb +2 -2
- data/lib/ppcurses/menu/BaseMenu.rb +88 -12
- data/lib/ppcurses/menu/CompositeMenu.rb +5 -5
- data/lib/ppcurses/menu/Menu.rb +48 -76
- data/lib/ppcurses/menu/RadioMenu.rb +7 -9
- data/lib/ppcurses/menu/class_diagram.txt +15 -0
- data/lib/ppcurses/menu/menu_item.rb +56 -0
- data/lib/ppcurses.rb +2 -0
- data/test/getBooleanAction.rb +4 -4
- data/test/insertSQLAction.rb +4 -4
- data/test/menu/changeMenuBorder.rb +17 -0
- data/test/{compositeMenu.rb → menu/compositeMenu.rb} +6 -6
- data/test/menu/displayMenu.rb +15 -0
- data/test/{menuInMenu.rb → menu/menuInMenu.rb} +6 -6
- data/test/menu/menuWmenuItems.rb +24 -0
- metadata +30 -30
- data/test/displayMenu.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0471020cb99e01db0442124a99b4964966202dbb
|
4
|
+
data.tar.gz: 19f200d50de12b5788e02989cec57db41fe4ce41
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f65b1cd40c6046404292bac909cbd1d8b08a56f11c86ed14f0bda8307626d2ee6691e0e6c703a07c7ec4e01619e376a4c2d5dcb713d0cea7fd7dad6fc3abf52d
|
7
|
+
data.tar.gz: 645855d467fbaf5ee24dad1653f008a30530edefeb7181a821578d14f7b6359990d08ab27dd37d267e577d1e447782ae47d2ee535d51309494dafde3ff7f0910
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= PPCurses
|
2
2
|
|
3
|
-
Some convenience code to initialize curses and some rudimentary GUI classes. See the **test** directory for example
|
3
|
+
Some convenience code to initialize curses and some rudimentary GUI classes. See the **test** directory for example programs.
|
4
4
|
|
5
5
|
== Install
|
6
6
|
[sudo] gem install 'ppcurses'
|
data/lib/ppcurses/Screen.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# Curses reference:
|
2
|
+
# http://www.ruby-doc.org/stdlib-1.9.3/libdoc/curses/rdoc/Curses.html
|
3
|
+
|
1
4
|
require 'curses'
|
2
5
|
include Curses
|
3
6
|
|
@@ -5,14 +8,16 @@ module PPCurses
|
|
5
8
|
|
6
9
|
# Screen initializes the Curses screen
|
7
10
|
# Pass a code block to the run method to start things
|
8
|
-
|
11
|
+
#
|
12
|
+
# noinspection RubyResolve
|
13
|
+
class Screen
|
9
14
|
|
10
15
|
# Creates a curses session
|
11
16
|
#
|
12
17
|
# Example:
|
13
18
|
# >> myScreen.run { displayMenu() }
|
14
19
|
#
|
15
|
-
def run
|
20
|
+
def run
|
16
21
|
begin
|
17
22
|
init_screen
|
18
23
|
Curses.raw
|
@@ -9,7 +9,7 @@ module PPCurses
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def x_padding
|
12
|
-
self.win_padding
|
12
|
+
self.win_padding
|
13
13
|
end
|
14
14
|
|
15
15
|
def win_padding
|
@@ -17,24 +17,24 @@ module PPCurses
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def win_width
|
20
|
-
Curses.cols - win_padding
|
20
|
+
Curses.cols - win_padding
|
21
21
|
end
|
22
22
|
|
23
23
|
def win_height
|
24
|
-
Curses.lines - win_padding
|
24
|
+
Curses.lines - win_padding
|
25
25
|
end
|
26
26
|
|
27
27
|
def create_window
|
28
|
-
@win = Window.new( win_height
|
29
|
-
win_padding
|
28
|
+
@win = Window.new( self.win_height, self.win_width,
|
29
|
+
self.win_padding/2, self.win_padding/2)
|
30
30
|
@win.clear
|
31
31
|
@win.box('|', '-')
|
32
|
-
@win.setpos(@win.cury
|
32
|
+
@win.setpos(@win.cury+1, self.x_padding )
|
33
33
|
end
|
34
34
|
|
35
35
|
def show
|
36
36
|
if @win.nil?
|
37
|
-
self.create_window
|
37
|
+
self.create_window
|
38
38
|
end
|
39
39
|
|
40
40
|
@win.refresh
|
@@ -21,7 +21,7 @@ module PPCurses
|
|
21
21
|
|
22
22
|
|
23
23
|
def execute
|
24
|
-
print_prompt
|
24
|
+
print_prompt
|
25
25
|
# Enables reading arrow keys in getch
|
26
26
|
@win.keypad(true)
|
27
27
|
while 1
|
@@ -33,7 +33,7 @@ module PPCurses
|
|
33
33
|
if c == 10 then break end
|
34
34
|
|
35
35
|
echo
|
36
|
-
print_prompt
|
36
|
+
print_prompt
|
37
37
|
end
|
38
38
|
echo
|
39
39
|
end
|
@@ -37,7 +37,7 @@ module PPCurses
|
|
37
37
|
proceed = GetBooleanAction.new('Proceed? ')
|
38
38
|
proceed.set_parent_action(self)
|
39
39
|
proceed.set_window(@win)
|
40
|
-
proceed.execute
|
40
|
+
proceed.execute
|
41
41
|
|
42
42
|
did_insert = false
|
43
43
|
|
@@ -46,8 +46,8 @@ module PPCurses
|
|
46
46
|
begin
|
47
47
|
prep_statement = @db.prepare(@sql)
|
48
48
|
prep_statement.bind_params(data_array)
|
49
|
-
prep_statement.execute
|
50
|
-
prep_statement.close
|
49
|
+
prep_statement.execute
|
50
|
+
prep_statement.close
|
51
51
|
did_insert = true
|
52
52
|
self.print_success_line('Execution successful')
|
53
53
|
rescue SQLite3::Exception => e
|
@@ -56,7 +56,7 @@ module PPCurses
|
|
56
56
|
ensure
|
57
57
|
self.print_line('')
|
58
58
|
self.print_line('< Press any key to continue > ')
|
59
|
-
@win.getch
|
59
|
+
@win.getch
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
@@ -14,21 +14,21 @@ module PPCurses
|
|
14
14
|
|
15
15
|
def x_padding
|
16
16
|
if @parent.nil?
|
17
|
-
self.win_padding
|
17
|
+
self.win_padding
|
18
18
|
else
|
19
|
-
@parent.win_padding
|
19
|
+
@parent.win_padding
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def print_prompt
|
24
|
-
@win.setpos(@win.cury
|
24
|
+
@win.setpos(@win.cury, self.x_padding )
|
25
25
|
@win.addstr(@prompt)
|
26
26
|
end
|
27
27
|
|
28
28
|
def execute
|
29
|
-
print_prompt
|
29
|
+
print_prompt
|
30
30
|
echo
|
31
|
-
@data = @win.getstr
|
31
|
+
@data = @win.getstr
|
32
32
|
noecho
|
33
33
|
end
|
34
34
|
|
@@ -1,19 +1,95 @@
|
|
1
|
-
|
1
|
+
require 'curses'
|
2
2
|
|
3
|
-
|
4
|
-
@sub_menu = menu
|
5
|
-
end
|
3
|
+
module PPCurses
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
@win.refresh
|
5
|
+
#noinspection RubyResolve
|
6
|
+
class BaseMenu
|
10
7
|
|
11
|
-
|
12
|
-
|
8
|
+
attr_accessor :menu_items
|
9
|
+
attr_accessor :selection
|
10
|
+
|
11
|
+
attr_accessor :side_wall_char
|
12
|
+
attr_accessor :top_bot_wall_char
|
13
|
+
|
14
|
+
#
|
15
|
+
# Current base ruby is 1.9.2. action_items could be an optional parameter
|
16
|
+
# if the base was moved up to 2.0
|
17
|
+
#
|
18
|
+
def initialize(menu_items, action_items )
|
19
|
+
@selection=0
|
20
|
+
@max_menu_width = 0
|
21
|
+
|
22
|
+
@side_wall_char = '|'
|
23
|
+
@top_bot_wall_char = '-'
|
24
|
+
|
25
|
+
sample = menu_items[0]
|
26
|
+
|
27
|
+
case sample
|
28
|
+
when String
|
29
|
+
# Case 1: menu_items is a list of strings, with an associated action list
|
30
|
+
build_menu_items(menu_items, action_items)
|
31
|
+
else
|
32
|
+
# Case 2: Received a list of MenuItem, or objects that implement
|
33
|
+
# MenuItem protocol
|
34
|
+
@menu_items=menu_items
|
35
|
+
end
|
36
|
+
|
37
|
+
find_max_menu_width
|
38
|
+
|
39
|
+
create_window
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_menu_items(menu_items, action_items)
|
44
|
+
@menu_items = []
|
45
|
+
|
46
|
+
(0...menu_items.length).each { |i|
|
47
|
+
menu_item = MenuItem.new(menu_items[i])
|
48
|
+
unless action_items.nil?
|
49
|
+
menu_item.action = action_items[i]
|
50
|
+
end
|
51
|
+
|
52
|
+
@menu_items.push(menu_item)
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def find_max_menu_width
|
57
|
+
@max_menu_width = 0
|
58
|
+
(0...menu_items.length).each { |i|
|
59
|
+
display = menu_items[i].display_string
|
60
|
+
@max_menu_width = display.length if display.length > @max_menu_width
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_window
|
65
|
+
w_height = @menu_items.length + 4
|
66
|
+
w_width = @max_menu_width + 4
|
67
|
+
@win = Window.new(w_height,w_width,(lines-w_height) / 2, (cols-w_width)/2)
|
68
|
+
|
69
|
+
@win.timeout=-1
|
70
|
+
# Enables reading arrow keys in getch
|
71
|
+
@win.keypad(true)
|
72
|
+
end
|
73
|
+
|
74
|
+
def set_sub_menu(menu)
|
75
|
+
@sub_menu = menu
|
76
|
+
end
|
77
|
+
|
78
|
+
def hide
|
79
|
+
@win.clear
|
80
|
+
@win.refresh
|
81
|
+
|
82
|
+
@sub_menu.hide if @sub_menu
|
83
|
+
end
|
84
|
+
|
85
|
+
def selected_menu_name
|
86
|
+
@menu_items[@selection].title
|
87
|
+
end
|
88
|
+
|
89
|
+
def close
|
90
|
+
@win.close
|
91
|
+
end
|
13
92
|
|
14
|
-
def selected_menu_name()
|
15
|
-
@items[@selection]
|
16
93
|
end
|
17
94
|
|
18
95
|
end
|
19
|
-
|
@@ -12,18 +12,18 @@ module PPCurses
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def show
|
15
|
-
@menu1.show
|
16
|
-
@menu2.show
|
15
|
+
@menu1.show
|
16
|
+
@menu2.show
|
17
17
|
end
|
18
18
|
|
19
19
|
|
20
20
|
def menu_selection
|
21
|
-
@menu1.menu_selection
|
21
|
+
@menu1.menu_selection
|
22
22
|
end
|
23
23
|
|
24
24
|
def close
|
25
|
-
@menu1.close
|
26
|
-
@menu2.close
|
25
|
+
@menu1.close
|
26
|
+
@menu2.close
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
data/lib/ppcurses/menu/Menu.rb
CHANGED
@@ -5,115 +5,87 @@ require_relative 'BaseMenu.rb'
|
|
5
5
|
require 'curses'
|
6
6
|
|
7
7
|
module PPCurses
|
8
|
-
|
8
|
+
#noinspection RubyResolve
|
9
9
|
class Menu < BaseMenu
|
10
10
|
|
11
|
-
|
12
|
-
@
|
13
|
-
@actions = Array.new
|
14
|
-
@selection = 0
|
15
|
-
|
16
|
-
max_menu_width = 0
|
17
|
-
|
18
|
-
menu_items.each do |item|
|
19
|
-
@items.push item
|
20
|
-
if item.length > max_menu_width then max_menu_width = item.length end
|
21
|
-
end
|
22
|
-
|
23
|
-
unless action_items.nil?
|
24
|
-
action_items.each do |item|
|
25
|
-
@actions.push item
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
w_height = @items.length + 4
|
30
|
-
w_width = max_menu_width + 4
|
31
|
-
@win = Window.new(w_height,w_width,(lines-w_height) / 2, (cols-w_width)/2)
|
32
|
-
|
33
|
-
@win.timeout=-1
|
34
|
-
# Enables reading arrow keys in getch
|
35
|
-
@win.keypad(true)
|
36
|
-
end
|
37
|
-
|
38
|
-
def show
|
39
|
-
@win.box('|', '-')
|
11
|
+
def show
|
12
|
+
@win.box(self.side_wall_char, self.top_bot_wall_char)
|
40
13
|
y = 2
|
41
14
|
x = 2
|
42
15
|
|
43
|
-
|
16
|
+
(0...@menu_items.length).each { |i|
|
44
17
|
@win.setpos(y, x)
|
45
|
-
if @selection == i
|
46
|
-
@win.addstr(@
|
47
|
-
if @selection == i
|
18
|
+
@win.attron(A_REVERSE) if @selection == i
|
19
|
+
@win.addstr(@menu_items[i].display_string)
|
20
|
+
@win.attroff(A_REVERSE) if @selection == i
|
48
21
|
y += 1
|
49
|
-
|
22
|
+
}
|
50
23
|
|
51
24
|
@win.refresh
|
52
25
|
|
53
|
-
@sub_menu.show
|
54
|
-
|
26
|
+
@sub_menu.show if @sub_menu
|
27
|
+
end
|
55
28
|
|
56
|
-
|
57
|
-
|
58
|
-
|
29
|
+
def set_global_action(action)
|
30
|
+
@global_action = action
|
31
|
+
end
|
59
32
|
|
60
|
-
|
33
|
+
def menu_selection
|
61
34
|
|
62
35
|
while 1
|
63
36
|
c = @win.getch
|
64
37
|
|
65
38
|
not_processed = !self.handle_menu_selection(c)
|
66
39
|
|
67
|
-
if c ==
|
68
|
-
self.hide
|
40
|
+
if c == ESCAPE
|
41
|
+
self.hide
|
69
42
|
break
|
70
43
|
end
|
71
44
|
|
72
|
-
if not_processed
|
73
|
-
@sub_menu.handle_menu_selection(c) if @sub_menu
|
74
|
-
end
|
45
|
+
@sub_menu.handle_menu_selection(c) if not_processed && @sub_menu
|
75
46
|
|
76
47
|
end
|
77
48
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
49
|
+
end
|
50
|
+
|
51
|
+
def handle_menu_selection(c)
|
52
|
+
n_choices = @menu_items.length
|
82
53
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
54
|
+
if c == KEY_UP
|
55
|
+
(@selection == 0) ? @selection = n_choices - 1 : @selection -= 1
|
56
|
+
self.show
|
57
|
+
return true
|
58
|
+
end
|
88
59
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
60
|
+
if c == KEY_DOWN
|
61
|
+
(@selection == n_choices-1) ? @selection = 0 : @selection += 1
|
62
|
+
self.show
|
63
|
+
return true
|
64
|
+
end
|
94
65
|
|
95
|
-
|
66
|
+
if c == ENTER
|
96
67
|
|
97
|
-
|
98
|
-
|
99
|
-
|
68
|
+
unless @global_action.nil?
|
69
|
+
@global_action.execute
|
70
|
+
end
|
100
71
|
|
101
|
-
|
102
|
-
|
103
|
-
|
72
|
+
unless @menu_items[@selection].action.nil?
|
73
|
+
@menu_items[@selection].action.execute
|
74
|
+
end
|
104
75
|
|
105
|
-
|
106
|
-
|
107
|
-
|
76
|
+
self.show
|
77
|
+
return true
|
78
|
+
end
|
108
79
|
|
109
|
-
|
110
|
-
|
80
|
+
item_consumed = @menu_items[@selection].handle_key(c)
|
81
|
+
if item_consumed
|
82
|
+
self.show
|
83
|
+
end
|
111
84
|
|
85
|
+
item_consumed
|
86
|
+
end
|
112
87
|
|
113
|
-
def close
|
114
|
-
@win.close()
|
115
|
-
end
|
116
88
|
|
117
|
-
|
89
|
+
end
|
118
90
|
|
119
91
|
end
|
@@ -5,6 +5,7 @@ module PPCurses
|
|
5
5
|
#noinspection RubyResolve
|
6
6
|
class RadioMenu < BaseMenu
|
7
7
|
|
8
|
+
# TODO - duplicate code from Menu ...
|
8
9
|
def initialize( menu_items, action_items )
|
9
10
|
@items = Array.new
|
10
11
|
@actions = Array.new
|
@@ -58,7 +59,7 @@ module PPCurses
|
|
58
59
|
|
59
60
|
self.handle_menu_selection(c)
|
60
61
|
|
61
|
-
if c ==
|
62
|
+
if c == ESCAPE
|
62
63
|
@win.clear
|
63
64
|
@win.refresh
|
64
65
|
break
|
@@ -74,27 +75,24 @@ module PPCurses
|
|
74
75
|
|
75
76
|
if c == KEY_RIGHT
|
76
77
|
if @selection < n_choices - 1 then @selection += 1 else @selection = 0 end
|
77
|
-
self.show
|
78
|
+
self.show
|
78
79
|
end
|
79
80
|
|
80
81
|
if c == KEY_LEFT
|
81
82
|
if @selection > 0 then @selection -= 1 else @selection = n_choices-1 end
|
82
|
-
self.show
|
83
|
+
self.show
|
83
84
|
end
|
84
85
|
|
85
|
-
if c ==
|
86
|
+
if c == ENTER then
|
86
87
|
unless @actions.nil?
|
87
|
-
@actions[@selection].execute
|
88
|
-
self.show
|
88
|
+
@actions[@selection].execute
|
89
|
+
self.show
|
89
90
|
end
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
93
94
|
|
94
95
|
|
95
|
-
def close
|
96
|
-
@win.close()
|
97
|
-
end
|
98
96
|
|
99
97
|
end
|
100
98
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
+---------------+
|
4
|
+
| BaseMenu | +----------------+
|
5
|
+
+---------------+ | MenuItem |
|
6
|
+
+ + +----------------+
|
7
|
+
| |
|
8
|
+
+---------v--+ +v-------------+
|
9
|
+
| Menu | | RadioMenu |
|
10
|
+
+------------+ +--------------+
|
11
|
+
|
12
|
+
|
13
|
+
+---------------------+
|
14
|
+
|CompositeMenu |
|
15
|
+
+---------------------+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module PPCurses
|
4
|
+
|
5
|
+
PP_MIXED_STATE = -1
|
6
|
+
PP_OFF_STATE = 0
|
7
|
+
PP_ON_STATE = 1
|
8
|
+
|
9
|
+
SELECTED_CHAR = '✓'
|
10
|
+
|
11
|
+
class MenuItem
|
12
|
+
attr_accessor :title
|
13
|
+
attr_accessor :action
|
14
|
+
attr_accessor :state
|
15
|
+
attr_accessor :selectable
|
16
|
+
|
17
|
+
def initialize( title )
|
18
|
+
@title = title
|
19
|
+
@state = PP_OFF_STATE
|
20
|
+
@selectable = false
|
21
|
+
end
|
22
|
+
|
23
|
+
def display_string
|
24
|
+
if @state == PP_OFF_STATE
|
25
|
+
return ' ' + @title
|
26
|
+
end
|
27
|
+
|
28
|
+
SELECTED_CHAR + ' ' + @title
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def toggle_on_off_state
|
33
|
+
if @state == PP_OFF_STATE
|
34
|
+
@state = PP_ON_STATE
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
if @state == PP_ON_STATE
|
39
|
+
@state = PP_OFF_STATE
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def handle_key(key)
|
45
|
+
|
46
|
+
if key == ' ' and @selectable
|
47
|
+
toggle_on_off_state
|
48
|
+
return true
|
49
|
+
end
|
50
|
+
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
data/lib/ppcurses.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
|
2
2
|
module PPCurses
|
3
3
|
require_relative 'ppcurses/Screen.rb'
|
4
|
+
require_relative 'ppcurses/Constants.rb'
|
4
5
|
# Menus
|
5
6
|
require_relative 'ppcurses/menu/Menu.rb'
|
6
7
|
require_relative 'ppcurses/menu/CompositeMenu.rb'
|
7
8
|
require_relative 'ppcurses/menu/RadioMenu.rb'
|
9
|
+
require_relative 'ppcurses/menu/menu_item.rb'
|
8
10
|
# Actions
|
9
11
|
require_relative 'ppcurses/actions/ShowMenuAction.rb'
|
10
12
|
require_relative 'ppcurses/actions/GetStringAction.rb'
|
data/test/getBooleanAction.rb
CHANGED
@@ -6,11 +6,11 @@ require_relative '../lib/ppcurses.rb'
|
|
6
6
|
action = PPCurses::GetBooleanAction.new('Is the sky blue? ')
|
7
7
|
|
8
8
|
def do_boolean_action(action)
|
9
|
-
action.show
|
10
|
-
action.execute
|
9
|
+
action.show
|
10
|
+
action.execute
|
11
11
|
end
|
12
12
|
|
13
|
-
screen = PPCurses::Screen.new
|
13
|
+
screen = PPCurses::Screen.new
|
14
14
|
screen.run { do_boolean_action(action) }
|
15
15
|
|
16
|
-
puts 'Value input was: ' + action.data
|
16
|
+
puts 'Value input was: ' + action.data
|
data/test/insertSQLAction.rb
CHANGED
@@ -14,8 +14,8 @@ string_action = PPCurses::GetStringAction.new('What is your name? ')
|
|
14
14
|
integer_action = PPCurses::GetIntegerAction.new('Input an integer? ')
|
15
15
|
|
16
16
|
def do_action(action)
|
17
|
-
action.show
|
18
|
-
action.execute
|
17
|
+
action.show
|
18
|
+
action.execute
|
19
19
|
end
|
20
20
|
|
21
21
|
|
@@ -29,8 +29,8 @@ SQL
|
|
29
29
|
sql_action = PPCurses::InsertSQLDataAction.new( [string_action, integer_action],
|
30
30
|
'Insert into testTable(name, val) values (?, ?)', db)
|
31
31
|
|
32
|
-
screen = PPCurses::Screen.new
|
33
|
-
screen.run {
|
32
|
+
screen = PPCurses::Screen.new
|
33
|
+
screen.run { do_action(sql_action) }
|
34
34
|
|
35
35
|
|
36
36
|
db.close
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require_relative '../../lib/ppcurses.rb'
|
5
|
+
|
6
|
+
def display_menu
|
7
|
+
menu = PPCurses::Menu.new( [ 'Press', '<ESCAPE>', 'to Quit'], nil )
|
8
|
+
menu.side_wall_char = '\\'
|
9
|
+
menu.top_bot_wall_char = '='
|
10
|
+
|
11
|
+
menu.show
|
12
|
+
menu.menu_selection
|
13
|
+
menu.close
|
14
|
+
end
|
15
|
+
|
16
|
+
screen = PPCurses::Screen.new
|
17
|
+
screen.run { display_menu }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../../lib/ppcurses.rb'
|
5
5
|
|
6
6
|
def display_menu
|
7
7
|
center_menu = PPCurses::Menu.new( [ 'Press', '<ESCAPE>', 'to Quit'], nil )
|
@@ -10,11 +10,11 @@ def display_menu
|
|
10
10
|
main_menu = PPCurses::CompositeMenu.new(center_menu, radio_menu)
|
11
11
|
|
12
12
|
|
13
|
-
main_menu.show
|
14
|
-
main_menu.menu_selection
|
15
|
-
main_menu.close
|
13
|
+
main_menu.show
|
14
|
+
main_menu.menu_selection
|
15
|
+
main_menu.close
|
16
16
|
end
|
17
17
|
|
18
|
-
screen = PPCurses::Screen.new
|
19
|
-
screen.run { display_menu
|
18
|
+
screen = PPCurses::Screen.new
|
19
|
+
screen.run { display_menu }
|
20
20
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require_relative '../../lib/ppcurses.rb'
|
5
|
+
|
6
|
+
def display_menu
|
7
|
+
main_menu = PPCurses::Menu.new( [ 'Press', '<ESCAPE>', 'to Quit'], nil )
|
8
|
+
main_menu.show
|
9
|
+
main_menu.menu_selection
|
10
|
+
main_menu.close
|
11
|
+
end
|
12
|
+
|
13
|
+
screen = PPCurses::Screen.new
|
14
|
+
screen.run { display_menu }
|
15
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../../lib/ppcurses.rb'
|
5
5
|
|
6
6
|
def display_menu
|
7
7
|
main_menu = PPCurses::Menu.new( [ 'Press', '<ESCAPE>', 'to Quit'], nil )
|
@@ -10,11 +10,11 @@ def display_menu
|
|
10
10
|
menu_action = PPCurses::ShowMenuAction.new(inner_menu)
|
11
11
|
main_menu.set_global_action(menu_action)
|
12
12
|
|
13
|
-
main_menu.show
|
14
|
-
main_menu.menu_selection
|
15
|
-
main_menu.close
|
13
|
+
main_menu.show
|
14
|
+
main_menu.menu_selection
|
15
|
+
main_menu.close
|
16
16
|
end
|
17
17
|
|
18
|
-
screen = PPCurses::Screen.new
|
19
|
-
screen.run { display_menu
|
18
|
+
screen = PPCurses::Screen.new
|
19
|
+
screen.run { display_menu }
|
20
20
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require_relative '../../lib/ppcurses.rb'
|
5
|
+
|
6
|
+
def display_menu
|
7
|
+
|
8
|
+
item1 = PPCurses::MenuItem.new('Item 1')
|
9
|
+
item1.selectable=true
|
10
|
+
item2 = PPCurses::MenuItem.new('Item 2')
|
11
|
+
item2.selectable=true
|
12
|
+
item2.state=PPCurses::PP_ON_STATE # Displays a checkbox next to the menu item
|
13
|
+
item3 = PPCurses::MenuItem.new('Item 3')
|
14
|
+
item3.selectable=true
|
15
|
+
|
16
|
+
main_menu = PPCurses::Menu.new( [ item1, item2, item3], nil )
|
17
|
+
main_menu.show
|
18
|
+
main_menu.menu_selection
|
19
|
+
main_menu.close
|
20
|
+
end
|
21
|
+
|
22
|
+
screen = PPCurses::Screen.new
|
23
|
+
screen.run { display_menu }
|
24
|
+
|
metadata
CHANGED
@@ -1,26 +1,21 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ppcurses
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Matthieu Cormier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
date: 2013-09-08 00:00:00 Z
|
11
|
+
date: 2014-02-09 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
|
15
13
|
description: Curses abstraction
|
16
14
|
email: mcormier@preenandprune.com
|
17
15
|
executables: []
|
18
|
-
|
19
16
|
extensions: []
|
20
|
-
|
21
17
|
extra_rdoc_files: []
|
22
|
-
|
23
|
-
files:
|
18
|
+
files:
|
24
19
|
- lib/ppcurses/actions/BaseAction.rb
|
25
20
|
- lib/ppcurses/actions/GetBooleanAction.rb
|
26
21
|
- lib/ppcurses/actions/GetDataAction.rb
|
@@ -31,48 +26,53 @@ files:
|
|
31
26
|
- lib/ppcurses/actions/NulAction.rb
|
32
27
|
- lib/ppcurses/actions/PromptAction.rb
|
33
28
|
- lib/ppcurses/actions/ShowMenuAction.rb
|
29
|
+
- lib/ppcurses/Constants.rb
|
34
30
|
- lib/ppcurses/menu/BaseMenu.rb
|
31
|
+
- lib/ppcurses/menu/class_diagram.txt
|
35
32
|
- lib/ppcurses/menu/CompositeMenu.rb
|
36
33
|
- lib/ppcurses/menu/Menu.rb
|
34
|
+
- lib/ppcurses/menu/menu_item.rb
|
37
35
|
- lib/ppcurses/menu/RadioMenu.rb
|
38
36
|
- lib/ppcurses/Screen.rb
|
39
37
|
- lib/ppcurses.rb
|
40
|
-
- test/compositeMenu.rb
|
41
|
-
- test/displayMenu.rb
|
42
38
|
- test/getBooleanAction.rb
|
43
39
|
- test/getDataAction.rb
|
44
40
|
- test/getEnumStringAction.rb
|
45
41
|
- test/getIntegerAction.rb
|
46
42
|
- test/getStringAction.rb
|
47
43
|
- test/insertSQLAction.rb
|
48
|
-
- test/
|
44
|
+
- test/menu/changeMenuBorder.rb
|
45
|
+
- test/menu/compositeMenu.rb
|
46
|
+
- test/menu/displayMenu.rb
|
47
|
+
- test/menu/menuInMenu.rb
|
48
|
+
- test/menu/menuWmenuItems.rb
|
49
49
|
- LICENCE.txt
|
50
50
|
- README.rdoc
|
51
51
|
homepage: https://github.com/mcormier/ppcurses
|
52
|
-
licenses:
|
52
|
+
licenses:
|
53
53
|
- MIT
|
54
54
|
metadata: {}
|
55
|
-
|
56
|
-
|
55
|
+
post_install_message: "\n ( ) ( ) )\n ) ( ) ( (\n ( ) ( )
|
56
|
+
)\n _____________\n <_____________> ___\n | |/ _ \\\n |
|
57
|
+
\ mmm | | |\n | coffee |_| |\n ___| |\\___/ \n
|
58
|
+
/ \\___________/ \\\n \\_____________________/\n\n"
|
57
59
|
rdoc_options: []
|
58
|
-
|
59
|
-
require_paths:
|
60
|
+
require_paths:
|
60
61
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
-
requirements:
|
63
|
-
-
|
64
|
-
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
70
72
|
requirements: []
|
71
|
-
|
72
73
|
rubyforge_project:
|
73
74
|
rubygems_version: 2.0.3
|
74
75
|
signing_key:
|
75
76
|
specification_version: 4
|
76
77
|
summary: Convenience classes when using curses
|
77
78
|
test_files: []
|
78
|
-
|
data/test/displayMenu.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require_relative '../lib/ppcurses.rb'
|
5
|
-
|
6
|
-
def display_menu
|
7
|
-
main_menu = PPCurses::Menu.new( [ 'Press', '<ESCAPE>', 'to Quit'], nil )
|
8
|
-
main_menu.show()
|
9
|
-
main_menu.menu_selection()
|
10
|
-
main_menu.close()
|
11
|
-
end
|
12
|
-
|
13
|
-
screen = PPCurses::Screen.new()
|
14
|
-
screen.run { display_menu() }
|
15
|
-
|