ppcurses 0.0.9 → 0.0.10
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.
- data/lib/ppcurses/Screen.rb +1 -1
- data/lib/ppcurses/actions/BaseAction.rb +32 -0
- data/lib/ppcurses/actions/GetStringAction.rb +4 -2
- data/lib/ppcurses/actions/PromptAction.rb +32 -28
- data/lib/ppcurses.rb +1 -0
- data/test/getStringAction.rb +19 -0
- metadata +4 -3
data/lib/ppcurses/Screen.rb
CHANGED
@@ -3,5 +3,37 @@ require "curses"
|
|
3
3
|
module PPCurses
|
4
4
|
class BaseAction
|
5
5
|
|
6
|
+
def setWindow(win)
|
7
|
+
@win = win
|
8
|
+
end
|
9
|
+
|
10
|
+
def winPadding()
|
11
|
+
return 2
|
12
|
+
end
|
13
|
+
|
14
|
+
def winWidth()
|
15
|
+
Curses.cols - winPadding()
|
16
|
+
end
|
17
|
+
|
18
|
+
def winHeight()
|
19
|
+
Curses.lines - winPadding()
|
20
|
+
end
|
21
|
+
|
22
|
+
def createWindow()
|
23
|
+
@win = Window.new( winHeight(), winWidth(),
|
24
|
+
winPadding()/2, winPadding()/2)
|
25
|
+
@win.clear
|
26
|
+
@win.box("|", "-")
|
27
|
+
end
|
28
|
+
|
29
|
+
def show()
|
30
|
+
if @win.nil?
|
31
|
+
self.createWindow()
|
32
|
+
end
|
33
|
+
|
34
|
+
@win.refresh
|
35
|
+
end
|
36
|
+
|
6
37
|
end
|
38
|
+
|
7
39
|
end
|
@@ -1,32 +1,36 @@
|
|
1
|
-
require
|
1
|
+
require 'ppcurses/actions/BaseAction.rb'
|
2
|
+
|
3
|
+
module PPCurses
|
4
|
+
class PromptAction < BaseAction
|
5
|
+
|
6
|
+
def initialize(prompt)
|
7
|
+
@prompt = prompt
|
8
|
+
end
|
9
|
+
|
10
|
+
def setParentAction(action)
|
11
|
+
@parent = action
|
12
|
+
end
|
13
|
+
|
14
|
+
def printPrompt()
|
15
|
+
if @parent.nil?
|
16
|
+
@win.setpos(@win.cury() + 1, self.winPadding())
|
17
|
+
else
|
18
|
+
@win.setpos(@win.cury(), @parent.winPadding())
|
19
|
+
end
|
20
|
+
@win.addstr(@prompt)
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute()
|
24
|
+
printPrompt()
|
25
|
+
echo
|
26
|
+
@data = @win.getstr()
|
27
|
+
noecho
|
28
|
+
end
|
29
|
+
|
30
|
+
def data
|
31
|
+
@data
|
32
|
+
end
|
2
33
|
|
3
|
-
|
4
|
-
class PromptAction < BaseAction
|
5
|
-
|
6
|
-
def initialize(prompt)
|
7
|
-
@prompt = prompt
|
8
|
-
end
|
9
|
-
|
10
|
-
def setWindow(win)
|
11
|
-
@win = win
|
12
|
-
end
|
13
|
-
|
14
|
-
def setParentAction(action)
|
15
|
-
@parent = action
|
16
34
|
end
|
17
35
|
|
18
|
-
def printPrompt()
|
19
|
-
@win.setpos(@win.cury(), @parent.winPadding())
|
20
|
-
@win.addstr(@prompt)
|
21
|
-
end
|
22
|
-
|
23
|
-
def execute()
|
24
|
-
printPrompt()
|
25
|
-
@data = @win.getstr()
|
26
|
-
end
|
27
|
-
|
28
|
-
def data
|
29
|
-
@data
|
30
|
-
end
|
31
36
|
end
|
32
|
-
|
data/lib/ppcurses.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'ppcurses'
|
5
|
+
|
6
|
+
action = PPCurses::GetStringAction.new("Input your name: ");
|
7
|
+
|
8
|
+
def getStringAction(action)
|
9
|
+
action.show()
|
10
|
+
action.execute()
|
11
|
+
end
|
12
|
+
|
13
|
+
puts "HERE"
|
14
|
+
|
15
|
+
screen = PPCurses::Screen.new()
|
16
|
+
screen.run { getStringAction(action) }
|
17
|
+
|
18
|
+
puts "HERE"
|
19
|
+
puts 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:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthieu Cormier
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- lib/ppcurses/actions/GetIntegerAction.rb
|
45
45
|
- lib/ppcurses/actions/ShowMenuAction.rb
|
46
46
|
- lib/ppcurses/actions/GetEnumeratedStringAction.rb
|
47
|
+
- test/getStringAction.rb
|
47
48
|
- test/menuInMenu.rb
|
48
49
|
- test/displayMenu.rb
|
49
50
|
- test/compositeMenu.rb
|