ppcurses 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,60 +1,63 @@
1
- require "curses"
1
+ require 'ppcurses/actions/BaseAction.rb'
2
2
 
3
- class GetEnumeratedStringAction < PromptAction
3
+ module PPCurses
4
4
 
5
- # enumeration is a list of possible values
6
- # i.e. CD, Vinyl, MP3
7
- def initialize(prompt, enumeration)
8
- super(prompt)
5
+ class GetEnumeratedStringAction < PromptAction
9
6
 
10
- # verify enumeration is an array
11
- if ( enumeration.respond_to?('each_with_index') == false ) then
12
- raise
13
- end
14
- @options = enumeration
15
- @currOption = 0
16
- end
7
+ # enumeration is a list of possible values
8
+ # i.e. CD, Vinyl, MP3
9
+ def initialize(prompt, enumeration)
10
+ super(prompt)
17
11
 
18
- def printPrompt()
19
- super()
20
- @options.each_with_index do |option, index|
21
- @win.addstr(option)
22
- if ( index == @currOption ) then
23
- @win.addstr(" [X] ")
24
- else
25
- @win.addstr(" [ ] ")
12
+ # verify enumeration is an array
13
+ if ( enumeration.respond_to?('each_with_index') == false ) then
14
+ raise
26
15
  end
16
+ @options = enumeration
17
+ @currOption = 0
18
+ end
19
+
20
+ def printPrompt()
21
+ super()
22
+ @options.each_with_index do |option, index|
23
+ @win.addstr(option)
24
+ if ( index == @currOption ) then
25
+ @win.addstr(" [X] ")
26
+ else
27
+ @win.addstr(" [ ] ")
28
+ end
27
29
 
30
+ end
28
31
  end
29
- end
30
32
 
31
- def execute()
32
- printPrompt()
33
- # Enables reading arrow keys in getch
34
- @win.keypad(true)
35
- while(1)
36
- noecho
37
- c = @win.getch
33
+ def execute()
34
+ printPrompt()
35
+ # Enables reading arrow keys in getch
36
+ @win.keypad(true)
37
+ while(1)
38
+ noecho
39
+ c = @win.getch
38
40
 
39
- if c == KEY_LEFT then @currOption = @currOption-1 end
40
- if c == KEY_RIGHT then @currOption= @currOption+1 end
41
- if c == 10 then break end
41
+ if c == KEY_LEFT then @currOption = @currOption-1 end
42
+ if c == KEY_RIGHT then @currOption= @currOption+1 end
43
+ if c == 10 then break end
42
44
 
43
- if (@currOption < 0 ) then @currOption = @options.length-1 end
44
- if (@currOption > @options.length-1 ) then @currOption = 0 end
45
+ if (@currOption < 0 ) then @currOption = @options.length-1 end
46
+ if (@currOption > @options.length-1 ) then @currOption = 0 end
45
47
 
48
+ echo
49
+ printPrompt()
50
+ end
46
51
  echo
47
- printPrompt()
52
+ # Go to next line so that further actions to overwrite
53
+ # the choice
54
+ @win.setpos(@win.cury() + 1, xPadding())
48
55
  end
49
- echo
50
- # Go to next line so that further actions to overwrite
51
- # the choice
52
- @win.setpos(@win.cury() + 1, @parent.winPadding())
53
- end
54
56
 
55
- def data
56
- @options[@currOption]
57
- end
57
+ def data
58
+ @options[@currOption]
59
+ end
58
60
 
59
- end
61
+ end
60
62
 
63
+ end
data/lib/ppcurses.rb CHANGED
@@ -10,6 +10,7 @@ module PPCurses
10
10
  require 'ppcurses/actions/GetStringAction.rb'
11
11
  require 'ppcurses/actions/GetBooleanAction.rb'
12
12
  require 'ppcurses/actions/GetIntegerAction.rb'
13
+ require 'ppcurses/actions/GetEnumeratedStringAction.rb'
13
14
  end
14
15
 
15
16
 
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: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 12
10
- version: 0.0.12
9
+ - 13
10
+ version: 0.0.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthieu Cormier