Advertisement
ben_mkiv

borders.lua

Apr 24th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. -- ─  ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏
  2. --
  3. -- ┐  ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟
  4. --
  5. -- ┠  ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯
  6. --
  7. -- ┰  ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿
  8. --
  9. -- ╀  ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏
  10. --
  11. -- ═  ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟
  12. --
  13. -- ╠  ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬
  14. --
  15. --  ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿
  16.  
  17. local borders = {}
  18.  
  19. borders.groups = {
  20.     slim_round = { "╭", "╮", "╰", "╯", "│", "─", "├", "┤" },
  21.     slim_double = { "╔", "╗", "╚", "╝", "║", "═", "╠", "╣" },
  22.     bold = { "┏", "┓", "┗", "┛", "┃", "━", "┣", "┫" }
  23. }
  24.  
  25. borders.draw = function(x, y, w, h, fg, bg, type, gpu) 
  26.     local b = borders.groups[type]
  27.     gpu.setForeground(fg)
  28.     gpu.setBackground(bg)  
  29.     gpu.set(x, y, b[1])     -- corner top left
  30.     gpu.set(x+w, y, b[2])   -- corner top right
  31.        
  32.     for i=1,(h-2) do
  33.         gpu.set(x, y+i, b[5])   -- frame left
  34.         gpu.set(x+w, y+i, b[5]) -- frame right
  35.     end
  36.  
  37.     for i=1,(w-1) do
  38.         gpu.set(x+i, y, b[6])   -- frame top
  39.         gpu.set(x+i, y+h-1, b[6])   -- frame bottom
  40.     end
  41.        
  42.     gpu.set(x, y+h-1, b[3]) -- corner bottom left
  43.     gpu.set(x+w, y+h-1, b[4]) -- corner bottom right   
  44. end
  45.  
  46. borders.addDivLine = function(x, y, w, fg, bg, type, gpu)
  47.     local b = borders.groups[type]
  48.     gpu.set(x, y, b[7])     -- frame left (division)
  49.     gpu.set(x+w, y, b[8])   -- frame right (division)
  50.    
  51.     for i=1,(w-1) do
  52.         gpu.set(x+i, y, b[6]) -- frame line
  53.     end
  54. end
  55.  
  56. return borders
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement