class WindowTerminal::WindowManager
Makes handling and switching between Window
objects simpler by creating an API that allows for objects to be assigned to pages, which can, in turn, be displayed, hidden, or deleted at leisure.
Attributes
pages[R]
Public Class Methods
new()
click to toggle source
Initializes a WindowManager
object.
# File lib/accu-window.rb, line 450 def initialize() @pages = [] @displayed_page = nil end
Public Instance Methods
display_page(num=1)
click to toggle source
Displays the page at the number specified; defaults to one.
# File lib/accu-window.rb, line 470 def display_page(num=1) raise(ArgumentError, "Argument 1 must be a valid integer!") if (not (num.is_a? Fixnum)) hide_page(@displayed_page) @pages[num-1].each { |item| WindowTerminal.add_window(item) } @displayed_page = num end
get_page_text(num)
click to toggle source
Gets all Text
and Text
subclass objects on the page given and returns them all as an array.
# File lib/accu-window.rb, line 518 def get_page_text(num) raise(ArgumentError, "Argument 1 must be a valid integer!") if (not (num.is_a? Fixnum)) array = [] @pages[num-1].each {|window| array << window.objects.dup array[-1].each {|item| if (not (item.respond_to? :set_text)) then array[-1].delete(item) end } } return array end
hide()
click to toggle source
An alias for hide_page
which always passes the current displayed page number, if it exists.
# File lib/accu-window.rb, line 502 def hide() if @displayed_page then hide_page(@displayed_page) end end
hide_page(num=nil)
click to toggle source
Hides a page by a number, defaults to doing nothing.
# File lib/accu-window.rb, line 486 def hide_page(num=nil) if num then raise(ArgumentError, "Argument 1 must be a valid integer!") if (not (num.is_a? Fixnum)) if num == @displayed_page then @pages[num-1].each { |item| WindowTerminal.remove_window(item) } @displayed_page = nil end end end
new_page(*items)
click to toggle source
Creates a new page with the passed arguments and returns the page number.
# File lib/accu-window.rb, line 458 def new_page(*items) @pages << [] items.each { |item| if item.is_a? Window then @pages[-1] << item end } return @pages.length end
remove_page(num)
click to toggle source
Delete a page by page number.
# File lib/accu-window.rb, line 509 def remove_page(num) raise(ArgumentError, "Argument 1 must be a valid integer!") if (not (num.is_a? Fixnum)) hide_page(num) @pages.delete_at(num-1) end
render()
click to toggle source
An alias for the WindowTerminal
method screen_render.
# File lib/accu-window.rb, line 534 def render() WindowTerminal.screen_render end
show(num=1)
click to toggle source
Alias for display_page.
# File lib/accu-window.rb, line 480 def show(num=1) display_page(num) end