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/base.rb

41 lines
647 B
Ruby
Raw Normal View History

2017-07-22 05:00:28 -04:00
# frozen_string_literal: true
module Widgets
class Base
2017-07-24 07:54:00 -04:00
attr_reader :parent
2017-07-24 06:08:53 -04:00
attr_reader :window
attr_reader :width, :height
2017-07-22 05:00:28 -04:00
attr_accessor :focused
2017-07-24 07:54:00 -04:00
def initialize(parent, x, y, width, height)
@parent = parent
2017-07-24 06:08:53 -04:00
@window = Curses::Window.new height, width, y, x
2017-07-22 05:00:28 -04:00
@width = width
@height = height
@focused = false
end
def trigger(event); end
def render
2017-07-22 09:03:10 -04:00
draw
2017-07-24 06:08:53 -04:00
window.refresh
2017-07-22 09:03:10 -04:00
end
def draw
raise NotImplementedError, "#{self.class}#draw"
2017-07-22 05:00:28 -04:00
end
2017-07-22 10:27:14 -04:00
def setpos(x, y)
2017-07-24 06:08:53 -04:00
window.setpos y, x
2017-07-22 10:27:14 -04:00
end
2017-07-22 14:46:50 -04:00
def addstr(s)
2017-07-24 05:52:42 -04:00
window.addstr s
2017-07-22 14:46:50 -04:00
end
2017-07-22 05:00:28 -04:00
end
end