Sha256: 2b7aeb97646ec3ac60e24f8eca492de17bc7e4083ad893ef67cc9a7c573cf09d

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module RubyJard
  ##
  # A screen is a unit of information drawing on the terminal. Each screen is
  # generated based on input layout specifiation, screen data, and top-left
  # corner cordination.
  class Screen
    attr_reader :output

    def initialize(layout:, output:, session:, row:, col:)
      @output = output
      @session = session
      @layout = layout
      @row = row
      @col = col
      @color_decorator = Pastel.new
    end

    def draw(_row, _col, _size)
      raise NotImplementedError, "#{self.class} must implement #draw method"
    end

    def decorate_text
      # TODO: this interface is ugly as fuck
      RubyJard::Decorators::TextDecorator.new(@color_decorator)
    end

    def decorate_path(path, lineno)
      # TODO: this interface is ugly as fuck
      RubyJard::Decorators::PathDecorator.new(path, lineno)
    end

    def decorate_source(file, lineno, window)
      # TODO: this interface is ugly as fuck
      RubyJard::Decorators::SourceDecorator.new(file, lineno, window)
    end

    def decorate_loc(loc, highlighted)
      # TODO: this interface is ugly as fuck
      RubyJard::Decorators::LocDecorator.new(@color_decorator, loc, highlighted)
    end

    private

    def default_frame_styles
      {
        style: {
          fg: :white
        },
        border: {
          bottom_left: false,
          bottom_right: false,
          bottom: false,
          left: :line,
          right: false
        }
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_jard-0.1.0 lib/ruby_jard/screen.rb