Archived
1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
cli-old/lib/widgets/chat.rb
2017-07-21 18:22:36 +00:00

34 lines
670 B
Ruby

# frozen_string_literal: true
module Widgets
class Chat
attr_reader :focused
def initialize(x, y, width, height)
@focused = false
@history = History.new x, y, width, height - 1
@message = NewMessage.new x, y + height - 1, width, 1
end
def render
@history.render
@message.render
end
def trigger(event)
case event
when Events::Panel::Base
@history.trigger event
when Events::Text::Base
@message.trigger event
end
end
def focused=(value)
@focused = !!value
@history.focused = focused
@message.focused = focused
end
end
end