Class: Pppt::PresentationWindow
- Inherits:
-
Object
- Object
- Pppt::PresentationWindow
- Defined in:
- lib/pppt/presentation_window.rb
Instance Method Summary collapse
-
#index ⇒ Object
目次ページ.
-
#initialize(data) ⇒ PresentationWindow
constructor
A new instance of PresentationWindow.
- #next ⇒ Object
- #prev ⇒ Object
- #show(page = nil) ⇒ Object
Constructor Details
#initialize(data) ⇒ PresentationWindow
Returns a new instance of PresentationWindow.
2 3 4 5 6 7 |
# File 'lib/pppt/presentation_window.rb', line 2 def initialize(data) @pages = Pppt::PresentationPages.new(data) @current = 0 @max = @pages.size init_screen end |
Instance Method Details
#index ⇒ Object
目次ページ
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pppt/presentation_window.rb', line 24 def index w = Curses.stdscr current = @current start_point = current - w.maxy / 2 loop do height = w.maxy - 5 w.clear w.setpos(1, 0) w.addstr(' -- index --'.center(w.maxx - 1)) vindex = 3 start_point = current if start_point > current start_point = current - height if current - start_point >= height start_point = 0 if start_point < 0 @pages.data.each_with_index do |page, i| next if i < start_point w.setpos(vindex, 0) w.addstr(' ' * w.maxx) w.setpos(vindex, 3) w.standout if i == current page_number_string = Pppt::Helpers.format_page_number(page) w.addstr(page_number_string + (' ' * (w.maxx - Pppt::Helpers.screen_width(page_number_string) - 4))) vindex += 1 w.standend if i == current break if i >= start_point + height end w.refresh Curses.timeout = -1 c = w.getch Curses.timeout = 1000 case c when 27, 8 return current when Curses::KEY_UP, 'k' current -= 1 if current > 0 when Curses::KEY_DOWN, 'j' current += 1 if current < @pages.data.length - 1 when 10, ' ' @current = current return current end end end |
#next ⇒ Object
9 10 11 |
# File 'lib/pppt/presentation_window.rb', line 9 def next @current += 1 if @pages.data.length - 1 > @current end |
#prev ⇒ Object
13 14 15 |
# File 'lib/pppt/presentation_window.rb', line 13 def prev @current -= 1 if @current > 0 end |
#show(page = nil) ⇒ Object
17 18 19 20 21 |
# File 'lib/pppt/presentation_window.rb', line 17 def show(page = nil) @current = page || @current page_data = @pages.data[@current] update_window(Curses.stdscr, page_data) end |