ppcurses 0.0.10 → 0.0.11
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,47 +1,47 @@
|
|
1
|
-
require
|
1
|
+
require 'ppcurses/actions/PromptAction.rb'
|
2
2
|
|
3
|
-
|
3
|
+
module PPCurses
|
4
4
|
|
5
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
while(1)
|
25
|
-
noecho
|
26
|
-
c = @win.getch
|
7
|
+
def initialize(prompt)
|
8
|
+
super(prompt)
|
9
|
+
@state = false;
|
10
|
+
end
|
27
11
|
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
data/lib/ppcurses.rb
CHANGED
@@ -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()
|
data/test/getStringAction.rb
CHANGED
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:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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-
|
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
|