ppcurses 0.0.13 → 0.0.14

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.
@@ -1,5 +1,11 @@
1
- require "curses"
1
+ require 'ppcurses/actions/BaseAction.rb'
2
2
 
3
+ module PPCurses
4
+
5
+
6
+ # An action that contains an array of prompt actions.
7
+ # It can be used to group together multiple prompt actions.
8
+ #
3
9
  class GetDataAction < BaseAction
4
10
 
5
11
  def initialize( actions )
@@ -9,7 +15,6 @@ class GetDataAction < BaseAction
9
15
  action.setParentAction(self)
10
16
  end
11
17
  end
12
-
13
18
  end
14
19
 
15
20
  def beforeActions()
@@ -20,30 +25,23 @@ class GetDataAction < BaseAction
20
25
  # Stub for classes that extend
21
26
  end
22
27
 
23
- def winPadding()
24
- return 2
25
- end
26
-
27
- def winWidth()
28
- Curses.cols - winPadding()
29
- end
30
28
 
31
- def winHeight()
32
- Curses.lines - winPadding()
29
+ def data()
30
+ values = []
31
+ @actions.each do |action|
32
+ values.push(action.data())
33
+ end
34
+ return values
33
35
  end
34
36
 
35
37
  def createWindow()
36
- @win = Window.new( winHeight(), winWidth(),
37
- winPadding()/2, winPadding()/2)
38
-
38
+ super()
39
39
  # Assign window to actions
40
40
  unless @actions.nil?
41
41
  @actions.each do |action|
42
42
  action.setWindow(@win)
43
43
  end
44
44
  end
45
- @win.clear
46
- @win.box("|", "-")
47
45
  end
48
46
 
49
47
  def execute()
@@ -51,14 +49,12 @@ class GetDataAction < BaseAction
51
49
  echo
52
50
 
53
51
  y = @win.cury + 1
54
- @win.setpos(y,winPadding())
52
+ @win.setpos(y,xPadding())
55
53
 
56
54
  self.beforeActions()
57
55
 
58
56
  @actions.each do |action|
59
57
  action.execute
60
- #y = @win.cury + 1
61
- #@win.setpos(y,winPadding())
62
58
  end
63
59
 
64
60
  self.afterActions()
@@ -118,3 +114,5 @@ class GetDataAction < BaseAction
118
114
 
119
115
  end
120
116
 
117
+ end
118
+
data/lib/ppcurses.rb CHANGED
@@ -11,6 +11,7 @@ module PPCurses
11
11
  require 'ppcurses/actions/GetBooleanAction.rb'
12
12
  require 'ppcurses/actions/GetIntegerAction.rb'
13
13
  require 'ppcurses/actions/GetEnumeratedStringAction.rb'
14
+ require 'ppcurses/actions/GetDataAction.rb'
14
15
  end
15
16
 
16
17
 
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'ppcurses'
5
+
6
+ intAction = PPCurses::GetIntegerAction.new("Input Integer : ");
7
+ stringAction = PPCurses::GetStringAction.new("Input your nme: ");
8
+
9
+ action = PPCurses::GetDataAction.new( [intAction, stringAction] )
10
+
11
+ def doIntegerAction(action)
12
+ action.show()
13
+ action.execute()
14
+ end
15
+
16
+ screen = PPCurses::Screen.new()
17
+ screen.run { doIntegerAction(action) }
18
+
19
+ puts "Value input was: " + action.data().to_s()
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'ppcurses'
5
+
6
+ action = PPCurses::GetEnumeratedStringAction.new("Media Type? ",
7
+ ["CD", "Vinyl", "MP3"] );
8
+
9
+ def doAction(action)
10
+ action.show()
11
+ action.execute()
12
+ end
13
+
14
+ screen = PPCurses::Screen.new()
15
+ screen.run { doAction(action) }
16
+
17
+ puts "Value input was: " + action.data()
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ppcurses
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 13
10
- version: 0.0.13
9
+ - 14
10
+ version: 0.0.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthieu Cormier
@@ -46,6 +46,8 @@ files:
46
46
  - lib/ppcurses/actions/GetEnumeratedStringAction.rb
47
47
  - test/getStringAction.rb
48
48
  - test/menuInMenu.rb
49
+ - test/getEnumStringAction.rb
50
+ - test/getDataAction.rb
49
51
  - test/displayMenu.rb
50
52
  - test/getIntegerAction.rb
51
53
  - test/getBooleanAction.rb