class Amun::Windows::Frame
a Frame
fills all the space in terminal renders an echo area or mini buffer if it exists and an object that respond to render
and trigger
, like buffer, or another window or so
Attributes
echo_area[RW]
mini_buffer[RW]
screen[W]
window[RW]
Public Class Methods
new(size = default_size)
click to toggle source
Calls superclass method
Amun::Windows::Base::new
# File lib/amun/windows/frame.rb, line 19 def initialize(size = default_size) super(size) @window = BufferWindow.new(top_window_size) @echo_area = EchoArea.new(bottom_window_size) bind(Curses::KEY_RESIZE, self, :set_size_to_terminal) end
Public Instance Methods
render()
click to toggle source
# File lib/amun/windows/frame.rb, line 32 def render render_window(window) render_window(bottom_area) end
set_size_to_terminal(*)
click to toggle source
# File lib/amun/windows/frame.rb, line 37 def set_size_to_terminal(*) self.size = default_size end
trigger(event)
click to toggle source
# File lib/amun/windows/frame.rb, line 26 def trigger(event) EventManager.join(event, self.events, echo_area, mini_buffer || window, EventManager) rescue StandardError => error handle_exception(error) end
Private Instance Methods
bottom_area()
click to toggle source
# File lib/amun/windows/frame.rb, line 49 def bottom_area mini_buffer || echo_area end
bottom_window_size()
click to toggle source
# File lib/amun/windows/frame.rb, line 71 def bottom_window_size Rect.new( top: top + height - 1, left: left, width: width, height: 1 ) end
default_size()
click to toggle source
# File lib/amun/windows/frame.rb, line 53 def default_size Rect.new( top: 0, left: 0, width: Curses.stdscr.maxx, height: Curses.stdscr.maxy ) end
handle_exception(e)
click to toggle source
# File lib/amun/windows/frame.rb, line 87 def handle_exception(e) Buffer.messages << "#{e.message} (#{e.backtrace.first})\n" end
render_window(window)
click to toggle source
# File lib/amun/windows/frame.rb, line 80 def render_window(window) window.render mini_buffer.render if mini_buffer rescue StandardError => error handle_exception(error) end
resize()
click to toggle source
Calls superclass method
Amun::Windows::Base#resize
# File lib/amun/windows/frame.rb, line 43 def resize super window.size = top_window_size echo_area.size = bottom_window_size end
top_window_size()
click to toggle source
# File lib/amun/windows/frame.rb, line 62 def top_window_size Rect.new( top: top, left: left, width: width, height: height - 1 ) end