Advertisement
Agent_Silence

Crimson OS

Oct 8th, 2014 (edited)
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.10 KB | None | 0 0
  1. shell.setDir("/")
  2. version = "Static 1.1"
  3.  
  4. while true do
  5. shell.setDir("/")
  6. listItems = fs.list(shell.dir())
  7. function Blank()
  8. term.setBackgroundColor(colors.white)
  9. term.clear()
  10. end
  11.  
  12. function info(item)
  13. term.setCursorPos(1,6)
  14. for i=6,13 do
  15. term.setCursorPos(1,i)
  16. term.clearLine()
  17. end
  18. term.setCursorPos(1,6)
  19. print("Info Bar Coming Soon!")
  20. end
  21.  
  22. function periphs()
  23. local tPeri = {}
  24. for i,v in pairs(peripheral.getNames()) do
  25. table.insert(tPeri,peripheral.getType(v))
  26. end
  27. return table.concat(tPeri, "|")
  28. end
  29.  
  30. function newItem(x, y, text)
  31. term.setCursorPos(x, y)
  32. term.write(text)
  33. end
  34. function exists(number)
  35. if listItems[number] ~= nil then
  36. return true else return false end
  37. end
  38. -- Variables
  39.  
  40. Blank()
  41. maxX, maxY = term.getSize()
  42. curItem = 1
  43. table.insert(listItems,1,"edit")
  44. table.insert(listItems,"New File")
  45. -- Main Functions
  46. function Update()
  47. term.clear()
  48. paintutils.drawLine(1,4, maxX, 4, colors.red)
  49. term.setBackgroundColor(colors.white)
  50. term.setTextColor(colors.black)
  51. term.setCursorPos(4,2)
  52.  
  53. if exists(curItem -3) then
  54. if fs.isDir(shell.dir().."/"..listItems[curItem - 3]) then
  55. term.setTextColor(colors.red)
  56. else
  57. term.setTextColor(colors.black)
  58. end
  59. term.write(listItems[curItem - 3].." ")
  60. else
  61. end
  62.  
  63. if exists(curItem - 2) then
  64. if fs.isDir(shell.dir().."/"..listItems[curItem - 2]) then
  65. term.setTextColor(colors.red)
  66. else
  67. term.setTextColor(colors.black)
  68. end
  69. term.write(listItems[curItem - 2].." ")
  70. else
  71. end
  72.  
  73. if exists(curItem - 1) then
  74. if fs.isDir(shell.dir().."/"..listItems[curItem - 1]) then
  75. term.setTextColor(colors.red)
  76. else
  77. term.setTextColor(colors.black)
  78. end
  79. term.write(listItems[curItem - 1].." ")
  80. else
  81. end
  82.  
  83. if exists(curItem) then
  84. if fs.isDir(shell.dir().."/"..listItems[curItem]) then
  85. term.setTextColor(colors.red)
  86. else
  87. term.setTextColor(colors.black)
  88. end
  89. term.setBackgroundColor(colors.gray)
  90. term.write(listItems[curItem].." ")
  91. term.setBackgroundColor(colors.white)
  92. end
  93.  
  94. if exists(curItem + 1) then
  95. if fs.isDir(shell.dir().."/"..listItems[curItem + 1]) then
  96. term.setTextColor(colors.red)
  97. else
  98. term.setTextColor(colors.black)
  99. end
  100. term.write(listItems[curItem + 1].." ")
  101. end
  102.  
  103. if exists(curItem + 2) then
  104. if fs.isDir(shell.dir().."/"..listItems[curItem + 2]) then
  105. term.setTextColor(colors.red)
  106. else
  107. term.setTextColor(colors.black)
  108. end
  109. term.write(listItems[curItem + 2].." ")
  110. end
  111.  
  112. if exists(curItem + 3) then
  113. if fs.isDir(shell.dir().."/"..listItems[curItem + 3]) then
  114. term.setTextColor(colors.red)
  115. else
  116. term.setTextColor(colors.black)
  117. end
  118. term.write(listItems[curItem + 3].." ")
  119. end
  120.  
  121. if curItem == 1 and exists(curItem + 4) and exists(curItem + 5) and exists(curItem + 6) then
  122. if fs.isDir(shell.dir().."/"..shell.dir().."/"..listItems[curItem + 4]) then
  123. term.setTextColor(colors.red)
  124. else
  125. term.setTextColor(colors.black)
  126. end
  127. term.write(listItems[curItem + 4].." ")
  128. if fs.isDir(shell.dir().."/"..shell.dir().."/"..listItems[curItem + 5]) then
  129. term.setTextColor(colors.red)
  130. else
  131. term.setTextColor(colors.black)
  132. end
  133. term.write(listItems[curItem + 5].." ")
  134. if fs.isDir(shell.dir().."/"..shell.dir().."/"..listItems[curItem + 6]) then
  135. term.setTextColor(colors.red)
  136. else
  137. term.setTextColor(colors.black)
  138. end
  139. term.write(listItems[curItem + 6].." ")
  140. end
  141.  
  142. if curItem == 2 and exists(curItem + 4) and exists(curItem + 5) then
  143. if fs.isDir(shell.dir().."/"..shell.dir().."/"..listItems[curItem + 4]) then
  144. term.setTextColor(colors.red)
  145. else
  146. term.setTextColor(colors.black)
  147. end
  148. term.write(listItems[curItem + 4].." ")
  149. if fs.isDir(shell.dir().."/"..shell.dir().."/"..listItems[curItem + 5]) then
  150. term.setTextColor(colors.red)
  151. else
  152. term.setTextColor(colors.black)
  153. end
  154. term.write(listItems[curItem + 5].." ")
  155. end
  156.  
  157. if curItem == 3 and exists(curItem + 4) then
  158. if fs.isDir(shell.dir().."/"..listItems[curItem + 4]) then
  159. term.setTextColor(colors.red)
  160. else
  161. term.setTextColor(colors.black)
  162. end
  163. term.write(listItems[curItem + 4].." ")
  164. end
  165.  
  166. term.setTextColor(colors.black)
  167. term.setCursorPos(1,6)
  168. print("ID : "..os.getComputerID())
  169. term.setCursorPos(1,8)
  170. print("Connected Peripherals : ")
  171. print(periphs())
  172. term.setCursorPos(1,10)
  173. print("Version : "..version)
  174. term.setCursorPos(1,12)
  175. print("Files/Folders : "..#listItems)
  176. end
  177. function List()
  178. repeat
  179. event, key = os.pullEvent("key")
  180. if key == 205 or key == 32 then
  181. curItem = curItem + 1
  182. if curItem > #listItems then
  183. curItem = #listItems
  184. Update()
  185. end
  186. Update()
  187. elseif key == 203 or key == 30 then
  188. curItem = curItem - 1
  189. if curItem < 1 then
  190. curItem = 1
  191. Update()
  192. end
  193. Update()
  194. end
  195. until key == 28 or key == 210 or key == 14 or key == 211
  196. if key == 28 then
  197. Info()
  198. elseif key == 210 then
  199. shell.run("edit "..listItems[curItem])
  200. elseif key == 14 then
  201. shell.setDir("/")
  202. listItems = fs.list("/")
  203. elseif key == 211 then
  204. fs.delete(listItems[curItem])
  205. end
  206. end
  207.  
  208. function Info()
  209. info(shell.dir().."/"..listItems[curItem])
  210. local event, key = os.pullEvent("key")
  211. if key == keys.enter then
  212. if listItems[curItem] ~= "New File" then
  213. if fs.isDir(shell.dir().."/"..listItems[curItem]) == false then
  214. term.setBackgroundColor(colors.white)
  215. term.clear()
  216. term.setCursorPos(1,1)
  217. term.setTextColor(colors.black)
  218. term.write("Arguments :")
  219. term.setTextColor(colors.red)
  220. term.setBackgroundColor(colors.gray)
  221. term.setCursorPos(1,2)
  222. term.clearLine()
  223. term.setCursorPos(1,4)
  224. term.clearLine()
  225. term.setCursorPos(1,6)
  226. term.clearLine()
  227. term.setCursorPos(1,2)
  228. local arg1 = read()
  229. term.setCursorPos(1,4)
  230. local arg2 = read()
  231. term.setCursorPos(1,6)
  232. local arg3 = read()
  233. term.setTextColor(colors.white)
  234. term.setBackgroundColor(colors.black)
  235. term.setCursorPos(1,1)
  236. term.clear()
  237. shell.run(listItems[curItem],arg1,arg2,arg3)
  238. os.pullEvent()
  239. else
  240. shell.setDir(shell.dir().."/"..listItems[curItem])
  241. listItems = fs.list(shell.dir())
  242. curItem = 1
  243. Update()
  244. List()
  245. end
  246. else
  247. term.setBackgroundColor(colors.lightGray)
  248. term.clear()
  249. term.setCursorPos(1,1)
  250. term.setTextColor(colors.red)
  251. term.write("File Name :")
  252. term.setCursorPos(1,2)
  253. term.setBackgroundColor(colors.gray)
  254. term.clearLine()
  255. term.setTextColor(colors.red)
  256. local input = read()
  257. shell.run("edit "..input)
  258. end
  259. end
  260. Update()
  261. List()
  262. end
  263. Update()
  264. List()
  265. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement