Advertisement
Guest User

Untitled

a guest
May 24th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.07 KB | None | 0 0
  1. function colored(n) term.setTextColor(n[2]) term.setBackgroundColor(n[1]) end function line() return { ['continue'] = function(data, other) io.write(tostring(other)) return data end, ['cont'] = function(data, other) print(other) return data end, ['brk'] = function(d) print() return d end, ['colored'] = function(d, n) term.setTextColor(n[2]) term.setBackgroundColor(n[1]) return function(data) io.write(data) term.setTextColor(colors.white) term.setBackgroundColor(colors.black) return d end end, ['colors'] = function(_, n) return function(o) term.setTextColor(colors[o]) term.setBackgroundColor(colors[n]) return _ end end, ['stop'] = function() print() end, ['center'] = function(self, sText) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#sText / 2)), 0) term.setCursorPos(x, y) print(sText) return self end, ['colorcenter'] = function(d, n) term.setTextColor(n[2]) term.setBackgroundColor(n[1]) return function(data) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#data / 2)), 0) term.setCursorPos(x, y) print(data) return d end end, ['slow'] = function(j, ...) textutils.slowPrint(...) return j end, ['slowcenter'] = function(j, data) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#data / 2)), 0) term.setCursorPos(x, y) textutils.slowPrint(data) return j end, ['print'] = function(j, ...) print(...) end, } end function clear() term.clear() term.setCursorPos(1,1)local _G = {} function colored(n) term.setTextColor(n[2]) term.setBackgroundColor(n[1]) end function line() return { ['continue'] = function(data, other) io.write(tostring(other)) return data end, ['cont'] = function(data, other) print(other) return data end, ['brk'] = function(d) print() return d end, ['colored'] = function(d, n) term.setTextColor(n[2]) term.setBackgroundColor(n[1]) return function(data) io.write(data) term.setTextColor(colors.white) term.setBackgroundColor(colors.black) return d end end, ['colors'] = function(_, n) return function(o) term.setTextColor(colors[o]) term.setBackgroundColor(colors[n]) return _ end end, ['stop'] = function() print() end, ['center'] = function(self, sText) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#sText / 2)), 0) term.setCursorPos(x, y) print(sText) return self end, ['colorcenter'] = function(d, n) term.setTextColor(n[2]) term.setBackgroundColor(n[1]) return function(data) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#data / 2)), 0) term.setCursorPos(x, y) print(data) return d end end, ['slow'] = function(j, ...) textutils.slowPrint(...) return j end, ['slowcenter'] = function(j, data) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#data / 2)), 0) term.setCursorPos(x, y) textutils.slowPrint(data) return j end, ['print'] = function(j, ...) print(...) return j end, ['write'] = function(j, ...) io.write(...) return j end, } end function clear() term.clear() term.setCursorPos(1,1) end function slow(data) textutils.slowPrint(data) end function center(sText) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#sText / 2)), 0) term.setCursorPos(x, y) print(sText) end function colorcenter(n) term.setTextColor(n[2]) term.setBackgroundColor(n[1]) return function(data) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#data / 2)), 0) term.setCursorPos(x, y) print(data) end end function wait() term.setTextColor(colors.orange) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#('Press any key to continue.') / 2)), 0) term.setCursorPos(x, h-1) print('Press any key to continue.') coroutine.yield('key') end function clear() term.setCursorPos(1,1) term.clear() end function exit() term.setCursorPos(1,1) term.clear() printError('End of TS document.') end end function slow(data) textutils.slowPrint(data) end function center(sText) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#sText / 2)), 0) term.setCursorPos(x, y) print(sText) end function colorcenter(n) term.setTextColor(n[2]) term.setBackgroundColor(n[1]) return function(data) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#data / 2)), 0) term.setCursorPos(x, y) print(data) end end function wait() term.setTextColor(colors.orange) local w, h = term.getSize() local x, y = term.getCursorPos() x = math.max(math.floor((w / 2) - (#('Press any key to continue.') / 2)), 0) term.setCursorPos(x, h-1) print('Press any key to continue.') coroutine.yield('key') end function clear() term.setCursorPos(1,1) term.clear() end function exit() term.setCursorPos(1,1) term.clear() printError('End of TS document.') end for k, v in pairs(colors) do _G[k] = v end for k, v in pairs(colours) do _G[k] = v end function loadpack(pack) if fs.exists('/usr/lib/ts/'..pack..'-ts.lua') then _G[pack] = {} for k, v in pairs(run.dailin.link('/usr/lib/ts/'..pack..'-ts.lua')) do _G[pack][k] = v end elseif fs.exists('/usr/local/lib/ts/'..pack..'-ts.lua') then _G[pack] = {} for k, v in pairs(run.dailin.link('/usr/local/lib/ts/'..pack..'-ts.lua')) do _G[pack][k] = v end else printError('unknown pack ' .. pack) end end
  2.  
  3. function main(...)
  4. colored {black, lightBlue}
  5. clear()
  6.  
  7. colorcenter {black, orange} '-- TYPE SETTER --'
  8.  
  9. line()
  10. :slowcenter 'Hello, world!'
  11.  
  12. colored {black, white}
  13.  
  14. line()
  15. : center '^ That text was written using slow.' : stop()
  16. line()
  17. : center 'This is a demo of '
  18. line()
  19. : colorcenter {black, red} 'Chameleon\'s '
  20. : colorcenter {black, blue} 'typesetter '
  21. : colorcenter {black, orange} 'program.'
  22. : brk()
  23.  
  24. : colorcenter {black, red} 'As you can see, it is very powerful.'
  25. : stop()
  26.  
  27. wait()
  28.  
  29. clear()
  30.  
  31. line()
  32. :slowcenter '-- TypeSetter Guide --'
  33.  
  34. line()
  35. : colored {black, orange} 'The chameleon typesetter is a piece of software designed to make documentation writers (such as me) happy.\n'
  36. : print 'It is very simple to use, consisting of a lua environment override only\n'
  37. : print 'TypeSetter can be used as a command line utility, as a library, or to generate stand-alone programs usable anywhere.\n'
  38. : print 'Seeing as it is only text, it does not require an advanced computer.\n'
  39.  
  40. wait()
  41. clear()
  42.  
  43. line()
  44. :slowcenter '-- Line Function --'
  45.  
  46. line()
  47. : colored {black, red} ':: '
  48. : print 'The Line function\n'
  49.  
  50. line()
  51. : colored {black, orange} 'The line function is used to start a new paragraph.'
  52. : write 'It can be used to insert line breaks, generate colored text, and manipulate text in a wide range of ways.\n'
  53. : colorcenter {black, orange} 'Simply put, it'
  54. : colorcenter {black, orange} 'is the most powerful function.\n'
  55.  
  56. line()
  57. : colorcenter {black, orange} 'Follows an example'
  58. : colorcenter {black, orange} 'of the Line function: \n'
  59. : colored {black, blue} [[
  60. line()
  61. : colorcenter {black, orange} 'Hello, world!'
  62. ]]
  63. wait()
  64. exit()
  65. end
  66. if not run and not run.dailin then main(...) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement