ppcurses 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,7 @@ module PPCurses
24
24
  winPadding()/2, winPadding()/2)
25
25
  @win.clear
26
26
  @win.box("|", "-")
27
+ @win.setpos(@win.cury()+1, self.winPadding())
27
28
  end
28
29
 
29
30
  def show()
@@ -1,47 +1,47 @@
1
- require "curses"
1
+ require 'ppcurses/actions/PromptAction.rb'
2
2
 
3
- class GetBooleanAction < PromptAction
3
+ module PPCurses
4
4
 
5
- def initialize(prompt)
6
- super(prompt)
7
- @state = false;
8
- end
9
-
10
- def printPrompt()
11
- super()
12
- @win.addstr("No [")
13
- if (@state == false) then @win.addstr("X") else @win.addstr(" ") end
14
- @win.addstr("] Yes [")
15
- if (@state == true) then @win.addstr("X") else @win.addstr(" ") end
16
- @win.addstr("]")
17
- end
18
-
5
+ class GetBooleanAction < PromptAction
19
6
 
20
- def execute()
21
- printPrompt()
22
- # Enables reading arrow keys in getch
23
- @win.keypad(true)
24
- while(1)
25
- noecho
26
- c = @win.getch
7
+ def initialize(prompt)
8
+ super(prompt)
9
+ @state = false;
10
+ end
27
11
 
28
- if c == KEY_LEFT then @state = false end
29
- if c == KEY_RIGHT then @state = true end
30
- if c == 10 then break end
12
+ def printPrompt()
13
+ super()
14
+ @win.addstr("No [")
15
+ if (@state == false) then @win.addstr("X") else @win.addstr(" ") end
16
+ @win.addstr("] Yes [")
17
+ if (@state == true) then @win.addstr("X") else @win.addstr(" ") end
18
+ @win.addstr("]")
19
+ end
20
+
31
21
 
32
- echo
22
+ def execute()
33
23
  printPrompt()
24
+ # Enables reading arrow keys in getch
25
+ @win.keypad(true)
26
+ while(1)
27
+ noecho
28
+ c = @win.getch
29
+
30
+ if c == KEY_LEFT then @state = false end
31
+ if c == KEY_RIGHT then @state = true end
32
+ if c == 10 then break end
33
+
34
+ echo
35
+ printPrompt()
36
+ end
37
+ echo
34
38
  end
35
- echo
36
- # Go to next line so that further actions to overwrite
37
- # the choice
38
- @win.setpos(@win.cury() + 1, @parent.winPadding())
39
- end
40
39
 
41
- def data
42
- if @state == false then return "0" end
43
- "1"
44
- end
40
+ def data
41
+ if @state == false then return "0" end
42
+ "1"
43
+ end
45
44
 
46
- end
45
+ end
47
46
 
47
+ end
@@ -13,7 +13,7 @@ module PPCurses
13
13
 
14
14
  def printPrompt()
15
15
  if @parent.nil?
16
- @win.setpos(@win.cury() + 1, self.winPadding())
16
+ @win.setpos(@win.cury(), self.winPadding())
17
17
  else
18
18
  @win.setpos(@win.cury(), @parent.winPadding())
19
19
  end
data/lib/ppcurses.rb CHANGED
@@ -8,6 +8,7 @@ module PPCurses
8
8
  # Actions
9
9
  require 'ppcurses/actions/ShowMenuAction.rb'
10
10
  require 'ppcurses/actions/GetStringAction.rb'
11
+ require 'ppcurses/actions/GetBooleanAction.rb'
11
12
  end
12
13
 
13
14
 
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'ppcurses'
5
+
6
+ action = PPCurses::GetBooleanAction.new("Is the sky blue? ");
7
+
8
+ def doBooleanAction(action)
9
+ action.show()
10
+ action.execute()
11
+ end
12
+
13
+ screen = PPCurses::Screen.new()
14
+ screen.run { doBooleanAction(action) }
15
+
16
+ puts "Value input was: " + action.data()
@@ -10,10 +10,7 @@ def getStringAction(action)
10
10
  action.execute()
11
11
  end
12
12
 
13
- puts "HERE"
14
-
15
13
  screen = PPCurses::Screen.new()
16
14
  screen.run { getStringAction(action) }
17
15
 
18
- puts "HERE"
19
- puts action.data()
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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 10
10
- version: 0.0.10
9
+ - 11
10
+ version: 0.0.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthieu Cormier
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-04-27 00:00:00 Z
18
+ date: 2013-04-23 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Curses abstraction
@@ -47,6 +47,7 @@ files:
47
47
  - test/getStringAction.rb
48
48
  - test/menuInMenu.rb
49
49
  - test/displayMenu.rb
50
+ - test/getBooleanAction.rb
50
51
  - test/compositeMenu.rb
51
52
  - LICENCE.txt
52
53
  - README.rdoc