Change how trees look and add the CLASS constant

This commit is contained in:
Talia 2018-07-13 10:19:13 +02:00
parent d37e97bdc3
commit 0b38f7295c
1 changed files with 22 additions and 22 deletions

View File

@ -1,29 +1,17 @@
-- vim: set noexpandtab :miv -- -- vim: set noexpandtab :miv --
tree = (tab, level=0, skip="") -> tree = (tab, pref='') ->
if level==0 print tab.title and tab.title or '┐'
print "┐"
pre = (lvl, skip) ->
for i=1,lvl
if skip\sub(i,i) == "y"
io.write " "
else
io.write "│ "
for idx, element in ipairs tab for idx, element in ipairs tab
last = idx == #tab last = idx == #tab
first = idx == 1
io.write pref
io.write last and "└─" or "├─"
switch type element switch type element
when "table" when "table"
pre level, skip tree element, last and ' ' or '│ '
io.write last and "└─" or "├─"
print element.title and "┬─ "..element.title or "┐"
tree element, level+1, skip .. (last and "y" or "n")
else else
pre level, skip print tostring element
if idx<#tab
print "├─ "..element
else
print "└─ "..element
import max from math import max from math
column = (col) -> column = (col) ->
@ -52,18 +40,30 @@ column = (col) ->
box = (box) -> box = (box) ->
column { box } column { box }
CLASS = [[
print vim.col {
{ 'Class' } -- Title
{
-- Members
}
{
-- Methods
}
}
]]
draw = -> draw = ->
for line in * { for line in * {
{ "─", "│", "┼" } { "─", "│", "┼" }
{ "┌", "┐", "└", "┘" } { "┌", "┐", "└", "┘" }
{ "├", "┤", "┬", "┴" } { "├", "┤", "┬", "┴" }
{ "╼" ,"╽" ,"╾" ,"╾" } { "╼", "╽", "╾", "╾" }
} }
print table.concat(line, " ") print table.concat(line, " ")
{ {
:tree, :column, :box, :draw :tree, :column, :box, :draw, :CLASS
-- Aliases -- Aliases
col: column col: column
} }