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.
@@ -28,7 +28,7 @@ module PPCurses
28
28
  # Empty Catch block so ruby doesn't puke out
29
29
  # a stack trace when CTRL-C is used
30
30
  ensure
31
- #close_screen
31
+ close_screen
32
32
  end
33
33
  end
34
34
 
@@ -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,5 +1,7 @@
1
- require "curses"
1
+ require 'ppcurses/actions/PromptAction.rb'
2
2
 
3
- class GetStringAction < PromptAction
3
+ module PPCurses
4
+ class GetStringAction < PromptAction
5
+ end
4
6
  end
5
7
 
@@ -1,32 +1,36 @@
1
- require "curses"
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
@@ -7,6 +7,7 @@ module PPCurses
7
7
  require 'ppcurses/menu/RadioMenu.rb'
8
8
  # Actions
9
9
  require 'ppcurses/actions/ShowMenuAction.rb'
10
+ require 'ppcurses/actions/GetStringAction.rb'
10
11
  end
11
12
 
12
13
 
@@ -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: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
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