lib/ppcurses/actions/PromptAction.rb in ppcurses-0.0.9 vs lib/ppcurses/actions/PromptAction.rb in ppcurses-0.0.10

- old
+ new

@@ -1,32 +1,36 @@ -require "curses" +require 'ppcurses/actions/BaseAction.rb' +module PPCurses + class PromptAction < BaseAction -class PromptAction < BaseAction + def initialize(prompt) + @prompt = prompt + end - def initialize(prompt) - @prompt = prompt - end + def setParentAction(action) + @parent = action + end - def setWindow(win) - @win = win - end + def printPrompt() + if @parent.nil? + @win.setpos(@win.cury() + 1, self.winPadding()) + else + @win.setpos(@win.cury(), @parent.winPadding()) + end + @win.addstr(@prompt) + end - def setParentAction(action) - @parent = action - end + def execute() + printPrompt() + echo + @data = @win.getstr() + noecho + end - def printPrompt() - @win.setpos(@win.cury(), @parent.winPadding()) - @win.addstr(@prompt) - end + def data + @data + end - def execute() - printPrompt() - @data = @win.getstr() end - def data - @data - end end -