Sha256: 5f9e443ae58a8402198691a9f1ab8f3d71be9020a23a8bec5d2e4c6d6de39eab

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require 'curses'
require 'active_support/concern'
require_relative 'views/top_bar'

module Daigaku
  module Views
    extend ActiveSupport::Concern

    included do
      include Curses

      def reset_menu_position
        @position = 0
      end

      private

      def default_window(height = nil, width = nil, top = 0, left = 0)
        init_screen

        noecho
        crmode
        curs_set(0) # invisible cursor

        height ||= lines
        width ||= cols + 1

        window = Daigaku::Window.new(height, width, top, left)

        Curses.lines.times do |line|
          window.setpos(line, 0)
          window.clear_line
        end

        window.keypad(true)
        window.scrollok(true)
        window.refresh
        window
      end

      def top_bar(window)
        TopBar.new(window)
      end

      def main_panel(window)
        top_bar(window).show
        yield(window) if block_given?
      end

      def sub_window_below_top_bar(window)
        top = top_bar(window).height
        sub_window = window.subwin(window.maxy - top, window.maxx, top, 0)
        sub_window.keypad(true)
        sub_window
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
daigaku-0.0.2 lib/daigaku/views.rb
daigaku-0.0.1 lib/daigaku/views.rb