Sha256: 19c745ed35f50a3c255af4520cf1dc1e1e42dae71bd6ad056c76602d14596ba4

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'amun/object'
require 'forwardable'
require 'curses'

module Amun
  module Windows
    # based on amun object, means it has event manager inside
    # and respond to all event manager methods (bind, undind, trigger...etc)
    # and has a size (Rect instance), it also expose the methods of the size
    # to the public, it also creates a subwindow from the curses standard screen
    # and resizes it whenever you set a new (size) value
    class Base < Object
      extend Forwardable

      attr_reader :size
      def_delegators :size, :top, :left, :width, :height

      def initialize(size)
        super()
        @size = size
        @curses_window = Curses.stdscr.subwin(height, width, top, left)
      end

      # change the object size
      # the internal curses window will be
      # resized and moved along with it
      def size=(size)
        @size = size
        resize
      end

      private

      attr_accessor :curses_window

      def resize
        curses_window.resize(height, width)
        curses_window.move(top, left)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amun-0.2.0 lib/amun/windows/base.rb