Class: Intent::UI::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/intent/ui/ttyui.rb

Instance Method Summary collapse

Constructor Details

#initializeWindow

Returns a new instance of Window.



38
39
40
41
42
43
# File 'lib/intent/ui/ttyui.rb', line 38

def initialize
  @width = TTY::Screen.width
  @height = TTY::Screen.height-1
  @panels = [Panel.new(0, 0, @width, @height)]
  @cursor = TTY::Cursor
end

Instance Method Details

#box_frameObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/intent/ui/ttyui.rb', line 58

def box_frame
  TTY::Box.frame(
    width: @width,
    height: @height,
    align: :center,
    border: :thick,
    style: {
      fg: :blue,
      border: {
        fg: :white,
      }
    }
  )
end

#drawObject



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/intent/ui/ttyui.rb', line 73

def draw
  @cursor.clear_screen

  print box_frame

  @panels.each do |panel|
    @cursor.move_to

    print panel.draw
  end
end

#split_horizontal(view1 = nil, view2 = nil) ⇒ Object



53
54
55
56
# File 'lib/intent/ui/ttyui.rb', line 53

def split_horizontal(view1=nil, view2=nil)
  width = @width - 2
  height = (@height / 2) - 2
end

#split_vertical(view1 = nil, view2 = nil) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/intent/ui/ttyui.rb', line 45

def split_vertical(view1=nil, view2=nil)
  width = (@width / 2) - 1
  height = @height - 2

  @panels << Panel.new(1, 1, width, height)
  @panels << Panel.new(width + 1, 1, width, height)
end