lib/patchmaster/curses/info_window.rb in patchmaster-1.0.0 vs lib/patchmaster/curses/info_window.rb in patchmaster-1.1.2
- old
+ new
@@ -1,33 +1,40 @@
require 'curses'
module PM
-class InfoWindow
+class InfoWindow < PmWindow
CONTENTS = File.join(File.dirname(__FILE__), 'info_window_contents.txt')
include Curses
- attr_reader :win, :text
+ attr_reader :text
- TITLE = ' PatchMaster '
-
def initialize(rows, cols, row, col)
- @win = Window.new(rows, cols, row, col)
- @text = IO.read(CONTENTS)
+ super(rows, cols, row, col, nil)
+ @info_text = IO.read(CONTENTS)
+ @text = nil
end
- def draw
- @win.setpos(0, (@win.maxx() - TITLE.length) / 2)
- @win.attron(A_REVERSE) {
- @win.addstr(TITLE)
- }
- @win.addstr("\n")
- @text.each_line { |line| @win.addstr(line) }
+ def text=(str)
+ if str
+ @text = str
+ @title = 'Song Notes'
+ else
+ @text = @info_text
+ @title = 'PatchMaster Help'
+ end
end
- def refresh
- @win.refresh
+ def draw
+ super
+ i = 1
+ @text.each_line do |line|
+ break if i >= @win.maxy - 2
+ @win.setpos(i+1, 1)
+ @win.addstr(make_fit(" #{line.chomp}"))
+ i += 1
+ end
end
end
end