ppcurses 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,10 @@ module PPCurses
7
7
  @win = win
8
8
  end
9
9
 
10
+ def xPadding()
11
+ return self.winPadding()
12
+ end
13
+
10
14
  def winPadding()
11
15
  return 2
12
16
  end
@@ -24,7 +28,7 @@ module PPCurses
24
28
  winPadding()/2, winPadding()/2)
25
29
  @win.clear
26
30
  @win.box("|", "-")
27
- @win.setpos(@win.cury()+1, self.winPadding())
31
+ @win.setpos(@win.cury()+1, xPadding() )
28
32
  end
29
33
 
30
34
  def show()
@@ -1,17 +1,21 @@
1
- require "curses"
1
+ require 'ppcurses/actions/PromptAction.rb'
2
2
 
3
- class GetIntegerAction < PromptAction
3
+ module PPCurses
4
+
5
+ class GetIntegerAction < PromptAction
6
+
7
+ def execute()
8
+ y = @win.cury()
9
+ begin
10
+ @win.setpos(y,xPadding())
11
+ @win.clrtoeol()
12
+ @win.addstr(@prompt)
13
+ echo
14
+ @data = @win.getstr()
15
+ noecho
16
+ end while not @data =~ /^\d+$/
17
+ end
4
18
 
5
- def execute()
6
- x = @parent.winPadding()
7
- y = @win.cury()
8
- begin
9
- @win.setpos(y,x)
10
- @win.clrtoeol()
11
- @win.addstr(@prompt)
12
- @data = @win.getstr()
13
- end while not @data =~ /^\d+$/
14
19
  end
15
20
 
16
21
  end
17
-
@@ -11,12 +11,16 @@ module PPCurses
11
11
  @parent = action
12
12
  end
13
13
 
14
- def printPrompt()
14
+ def xPadding()
15
15
  if @parent.nil?
16
- @win.setpos(@win.cury(), self.winPadding())
16
+ return self.winPadding()
17
17
  else
18
- @win.setpos(@win.cury(), @parent.winPadding())
18
+ return @parent.winPadding()
19
19
  end
20
+ end
21
+
22
+ def printPrompt()
23
+ @win.setpos(@win.cury(), xPadding())
20
24
  @win.addstr(@prompt)
21
25
  end
22
26
 
data/lib/ppcurses.rb CHANGED
@@ -9,6 +9,7 @@ module PPCurses
9
9
  require 'ppcurses/actions/ShowMenuAction.rb'
10
10
  require 'ppcurses/actions/GetStringAction.rb'
11
11
  require 'ppcurses/actions/GetBooleanAction.rb'
12
+ require 'ppcurses/actions/GetIntegerAction.rb'
12
13
  end
13
14
 
14
15
 
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'ppcurses'
5
+
6
+ action = PPCurses::GetIntegerAction.new("Input Integer : ");
7
+
8
+ def doIntegerAction(action)
9
+ action.show()
10
+ action.execute()
11
+ end
12
+
13
+ screen = PPCurses::Screen.new()
14
+ screen.run { doIntegerAction(action) }
15
+
16
+ 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: 9
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 11
10
- version: 0.0.11
9
+ - 12
10
+ version: 0.0.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthieu Cormier
@@ -47,6 +47,7 @@ files:
47
47
  - test/getStringAction.rb
48
48
  - test/menuInMenu.rb
49
49
  - test/displayMenu.rb
50
+ - test/getIntegerAction.rb
50
51
  - test/getBooleanAction.rb
51
52
  - test/compositeMenu.rb
52
53
  - LICENCE.txt