jgtrosh

testprint.lua

Aug 6th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. t = {
  2.     ["title"] =
  3.     "a nice title on top of the restehheh",
  4.     "a not as nice subtitle to fol",
  5.     "this",
  6.     "is",
  7.     "some really really really long text",
  8.     "more of it here",
  9.     "would you care to read this ?",
  10.     "this is some really really really long text"
  11.     }
  12.  
  13. tlen = string.len(t.title)
  14. len = 0
  15. for i = 1, table.maxn(t) do
  16.     if string.len(t[i])>len then len = string.len(t[i]) end
  17. end
  18. print(" "..string.rep("_", math.min(tlen, 50)+2))
  19. print("|"..string.rep(" ", math.min(tlen, 50)+2).."|")
  20. a = "| "
  21. for i = 1, math.min(tlen, 50) do
  22.     a = a..string.sub(t.title, i, i)
  23. end
  24. print(a..string.rep(" ", math.max(-string.len(a)+math.min(tlen, 50)+3, 0)).."|")
  25. print(
  26.     "|"..string.rep("_", math.min(len, 50, tlen)+2)..
  27.     string.sub("_|", (tlen-len)/math.abs(tlen-len), (tlen-len)/math.abs(tlen-len))..
  28.     string.rep("_", math.min(50, math.max(len, tlen))-math.min(len, tlen)-1)..
  29.     string.sub(" |", (len-tlen)/math.abs(len-tlen), (len-tlen)/math.abs(len-tlen))
  30.     )
  31. print("|"..string.rep(" ", math.min(len, 50)+2).."|")
  32. for i = 1, table.maxn(t) do
  33.     a = "| "
  34.     for ii = 1, math.min(string.len(t[i]), 50) do
  35.         a = a..string.sub(t[i], ii, ii)
  36.     end
  37.     print(a..string.rep(" ", math.max(-string.len(a)+math.min(len, 50)+3, 0)).."|")
  38. end
  39. print("|"..string.rep("_", math.min(len, 50)+2).."|")
  40. print("")
  41. ======================================
  42.  ______________________________________
  43. |                                      |
  44. | a nice title on top of the restehheh |
  45. |______________________________________|______
  46. |                                             |
  47. | a not as nice subtitle to fol               |
  48. | this                                        |
  49. | is                                          |
  50. | some really really really long text         |
  51. | more of it here                             |
  52. | would you care to read this ?               |
  53. | this is some really really really long text |
  54. |_____________________________________________|
Advertisement
Add Comment
Please, Sign In to add comment