GitHunt
SA

saikyun/freja-layout

layouting library for freja

freja-layouting

layouting library for freja

ascii-example

No extra dependencies needed. Needs a terminal with support for ansi escape codes.

Turn strings into columns

git clone https://github.com/Saikyun/freja-layouting
cd freja-layouting

janet test/ascii-layouting.janet \
'there was a little girl, who liked to eat the world. but then a mad guy came, and shouted "NO!"' \
'she was so distraught, that she started running toward the man. he understood that he had made a mistake.' \
'this was not any little girl, I mean, she could eat the world. so he bailed.'

# prints


 there was a little      she was so distraught,   this was not any little
 girl, who liked to eat  that she started         girl, I mean, she could
 the world. but then a   running toward the man.  eat the world. so he
 mad guy came, and       he understood that he    bailed.
 shouted "NO!"           had made a mistake.




The important bits of the code, resulting in the above:

(defn main
  [& args]
  
  (def props @{:columns (drop 1 args)})

  (defn hiccup
    # props are fed in as an argument
    [{:columns cs}]
    # :row layouts horizontally
    [:row {}
     ;(seq [c :in cs]
        [:block {:weight 1}
         [:padding {:all 1}
          c]])])
          
  # ...compilation & rendering (printing)
)

Languages

Janet100.0%

Contributors

Created June 29, 2021
Updated March 5, 2023