Sha256: 5315a28259dfc7a8614d9fe74bb8dbbcc33828a7be361a4050c911c321df3cc0
Contents?: true
Size: 1.69 KB
Versions: 5
Compression:
Stored size: 1.69 KB
Contents
require "tty-box" require "tty-screen" require "tty-reader" require "tty-cursor" require "tty-pager" require "pastel" require "todo-txt" module Intent module UI class Panel def initialize(x, y, width, height) @x = x @y = y @width = width @height = height end def draw TTY::Box.frame( left: @x, top: @y, width: @width, height: @height, align: :center, border: :light, style: { fg: :white, border: { fg: :white, } } ) end end class Window def initialize @width = TTY::Screen.width @height = TTY::Screen.height-1 @panels = [Panel.new(0, 0, @width, @height)] @cursor = TTY::Cursor end 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 def split_horizontal(view1=nil, view2=nil) width = @width - 2 height = (@height / 2) - 2 end def box_frame TTY::Box.frame( width: @width, height: @height, align: :center, border: :thick, style: { fg: :blue, border: { fg: :white, } } ) end def draw @cursor.clear_screen print box_frame @panels.each do |panel| @cursor.move_to print panel.draw end end end end end win = Intent::UI::Window.new win.split_vertical win.draw
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
intent-0.8.1 | lib/intent/ui/ttyui.rb |
intent-0.8.0 | lib/intent/ui/ttyui.rb |
intent-0.7.1 | lib/intent/ui/ttyui.rb |
intent-0.7.0 | lib/intent/ui/ttyui.rb |
intent-0.6.0 | lib/intent/ui/ttyui.rb |