Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.09 KB | None | 0 0
  1. --[[
  2. STD Graphical User Interface! (STDGUI)
  3. Made by LDDestroier/EldidiStroyrr (same guy)
  4.  
  5. This program is a standalone GUI for Super Text Downloader, or STD for short.
  6. It has category sorting, program searching, smooth scrolling, and run support (not just download)
  7. This will tell you if you're overwriting a file, so no worry.
  8.  
  9. As of May 15th (my goddamn birthday), STDGUI now lets you install SimSoft applications in the store interface!
  10.  
  11. pastebin get P9dDhQ2m stdgui
  12. std pb P9dDhQ2m stdgui
  13. std ld stdgui stdgui
  14. --]]
  15.  
  16. stdList = ".std_list"
  17. local scr_x, scr_y = term.getSize()
  18.  
  19. local doDisplayTitle = false
  20. local relativePath = false
  21.  
  22. local overrideNoSimSoft = false --prevent SimSoft functions, even if it's installed
  23. local isSimSoft = false --special integration into SimSoft!
  24.  
  25. if (fs.isDir("SimSoft/Daten/SappS") and fs.isDir("SimSoft/SappS")) and (not overrideNoSimSoft) then --checks if SimSoft is installed
  26. isSimSoft = true
  27. end
  28.  
  29. cprint = function(txt,y)
  30. local cX,cY = term.getCursorPos()
  31. term.setCursorPos(math.ceil(scr_x/2)-math.floor(#txt/2),y or cY)
  32. print(txt)
  33. end
  34.  
  35. scroll = 1 --one is the loneliest number...weaboo
  36. scrollX = 1 --to view longer program names
  37. std_version = 100 --to prevent updating to std command line
  38.  
  39. setMaxScroll = function(catagory)
  40. output = 0
  41. for k,v in pairs(storeURLs) do
  42. if (v.catagory == catagory) or catagory == 0 then
  43. output = output + 1
  44. end
  45. end
  46. return (output*4)-(scr_y-4)
  47. end
  48. local catag = 0
  49.  
  50. local setDefaultColors = function()
  51. term.setBackgroundColor(colors.gray)
  52. term.setTextColor(colors.white)
  53. end
  54.  
  55. local displayHelp = function(cli)
  56. local helptext = [[
  57. This is a graphical interface to the STD downloader program.
  58. Use 'stdgui update' to update the list, or use 'F5'.
  59. If you want your program on it, PM LDDestroier on the CC forums.
  60. Hotkeys:
  61. 'Q' quit or back
  62. 'F5' refresh
  63. 'F1' menu
  64. 'F' or 'F6' search
  65. 'F12' update stdgui
  66. ]]
  67. if cli then
  68. return print(helptext)
  69. else
  70. setDefaultColors()
  71. term.clear()
  72. term.setCursorPos(2,2)
  73. print(helptext)
  74. sleep(0)
  75. print("\nPress a key to go back.")
  76. os.pullEvent("key")
  77. return
  78. end
  79. end
  80.  
  81. local getTableSize = function(tbl)
  82. local amnt = 0
  83. for k,v in pairs(tbl) do
  84. amnt = amnt + 1
  85. end
  86. return amnt
  87. end
  88.  
  89. function runURL(url, ...)
  90. local program = http.get(url)
  91. if not program then return false end
  92. program = program.readAll()
  93. local func = loadstring(program)
  94. setfenv(func, getfenv())
  95. return func(...)
  96. end
  97.  
  98. bow = function()
  99. term.setBackgroundColor(colors.white)
  100. term.setTextColor(colors.black)
  101. end
  102.  
  103. getFile = function(filename,url)
  104. if fs.isReadOnly(filename) then
  105. return false, "access denied"
  106. end
  107. local prog = http.get(url)
  108. if not prog then
  109. return false, "could not connect"
  110. end
  111. prog = prog.readAll()
  112. local fyle = fs.open(filename,"w")
  113. fyle.write(prog)
  114. fyle.close()
  115. return true, fs.getSize(filename)
  116. end
  117. runFile = function(path)
  118. if not fs.exists(path) then
  119. return false, "No such file!"
  120. end
  121. local file = fs.open(path,"r")
  122. local contents = file.readAll()
  123. file.close()
  124. local func = loadstring(contents)
  125. setfenv(func, getfenv())
  126. func()
  127. return true
  128. end
  129. getSTDList = function()
  130. local url = "http://pastebin.com/raw/FSCzZRUk" --URL of URL list.
  131. local contents = http.get(url)
  132. if not contents then
  133. if shell then
  134. print("Couldn't update list!")
  135. end
  136. return false, "Couldn't update list!"
  137. else
  138. local uut
  139. if fs.exists(stdList) then
  140. uut = runFile(stdList)
  141. end
  142. if not uut then storeURLs = {} end
  143. local beforeSize = getTableSize(storeURLs or {})
  144. if not fs.isReadOnly(stdList) then
  145. local program = contents.readAll()
  146. local file = fs.open(stdList,"w")
  147. file.writeLine(program)
  148. file.close()
  149. runFile(stdList)
  150. else
  151. runURL(url)
  152. end
  153. local afterSize = getTableSize(storeURLs or {})
  154. local diff = afterSize-beforeSize
  155. local output
  156. if not fs.isReadOnly(stdList) then
  157. output = "Downloaded to "..stdList
  158. else
  159. output = "Got store codes."
  160. end
  161. if diff > 0 then
  162. output = output.." (got "..diff.." new store entries)"
  163. end
  164. return true, output
  165. end
  166. end
  167.  
  168. local cisf = function(str,fin)
  169. return string.find(str:lower(),fin:lower())
  170. end
  171.  
  172. local simSoftInstall = function(obj,objname,livesys)
  173. pFname = obj.title:gsub(" ","-")
  174. local pF = {
  175. name = pFname,
  176. folder = objname,
  177. colorCode = math.random(1,20),
  178. liveSystem = livesys or "",
  179. files = {
  180. [pFname] = obj.url, --I can't use pastebin codes for this
  181. }
  182. }
  183.  
  184. local getFromPastebin = function(code,path) --modified to work with URLs as well
  185. if not type(code) == "string" then
  186. error("Expected pastebin code")
  187. elseif not type(path) == "string" then
  188. error("Expected file path")
  189. end
  190. local prog
  191. if #code == 8 then
  192. prog = http.get("http://pastebin.com/raw/"..code)
  193. else
  194. prog = http.get(code)
  195. end
  196. if not code then
  197. return false, "Could not connect."
  198. end
  199. prog = prog.readAll()
  200. if fs.exists(fs.getName(path)) and not fs.isDir(fs.getName(path)) then
  201. return false, "There's already a file there"
  202. end
  203. if not fs.exists(fs.getDir(path)) then
  204. fs.makeDir(fs.getDir(path))
  205. end
  206. local file = fs.open(path,"w")
  207. file.write(prog)
  208. file.close()
  209. return true, fs.getSize(path)
  210. end
  211.  
  212. local function appInstaller(name,farbe,ver,loesch,LiveJaNein,LivePfad)
  213. term.setBackgroundColor(128)
  214. term.setTextColor(1)
  215. term.clear()
  216. term.setCursorPos(2,3)
  217. print("Starting installation...")
  218. local file = fs.open("SimSoft/Daten/SappS/A","r")
  219. local fileData = {}
  220. local line = file.readLine()
  221. repeat
  222. table.insert(fileData,line)
  223. line = file.readLine()
  224. until line == nil
  225. file.close()
  226. anz = tonumber(fileData[1])
  227. if anz >= 15 then
  228. return false, "App limit has been reached! Delete one to make space. Sorry."
  229. else
  230. anz = (anz+1)
  231. local file = fs.open("SimSoft/Daten/SappS/A","w")
  232. file.write(anz)
  233. file.close()
  234. local file = fs.open("SimSoft/Daten/SappS/"..anz,"w")
  235. file.writeLine(name)
  236. file.writeLine(anz)
  237. file.writeLine(farbe.."\n")
  238. file.writeLine(ver)
  239. file.writeLine(loesch)
  240. if LiveJaNein ~= "" then
  241. file.writeLine("t")
  242. file.writeLine(LiveJaNein)
  243. else
  244. file.writeLine("f\n")
  245. end
  246. file.close()
  247. end
  248. return true, "Installed!"
  249. end
  250. for k,v in pairs(pF.files) do
  251. getFromPastebin(v,fs.combine(fs.combine("SimSoft/SappS",pF.folder),k))
  252. end
  253. return appInstaller(string.sub(pF.name,1,6),tostring(pF.colorCode)..".0",fs.combine(pF.folder,pF.name),pF.folder,pF.liveSystem)
  254. end
  255.  
  256. getFindList = function(name)
  257. local output = {}
  258. for k,v in pairs(storeURLs) do
  259. if cisf(k,name) or cisf(v.title,name) or cisf(v.creator,name) then
  260. output[k] = v
  261. end
  262. if output[k] ~= v and v.keywords then
  263. for a = 1, #v.keywords do
  264. if cisf(v.keywords[a],name) then
  265. output[k] = v
  266. break
  267. end
  268. end
  269. end
  270. end
  271. return output
  272. end
  273.  
  274. doFindFunc = function(name)
  275. scroll = 1
  276. maxScroll = setMaxScroll(catag)
  277. renderStore(getFindList(name),catag,scroll,scrollX)
  278. term.setCursorPos(1,1)
  279. bow()
  280. term.clearLine()
  281. write("Find: ")
  282. end
  283.  
  284. funcread = function(repchar,rHistory,doFunc,noNewLine)
  285. local scr_x,scr_y = term.getSize()
  286. local sx,sy = term.getCursorPos()
  287. local cursor = 1
  288. local output = ""
  289. term.setCursorBlink(true)
  290. while true do
  291. local evt,key = os.pullEvent()
  292. if evt == "key" then
  293. if key == keys.enter then
  294. if not noNewLine then
  295. write("\n")
  296. end
  297. term.setCursorBlink(false)
  298. return output
  299. elseif key == keys.left then
  300. if cursor-1 >= 1 then
  301. cursor = cursor - 1
  302. end
  303. elseif key == keys.right then
  304. if cursor+1 <= #output then
  305. cursor = cursor + 1
  306. end
  307. elseif key == keys.backspace then
  308. if cursor > 1 and #output > 0 then
  309. output = output:sub(1,cursor-2)..output:sub(cursor)
  310. cursor = cursor - 1
  311. pleaseDoFunc = true
  312. end
  313. elseif key == keys.delete then
  314. if #output:sub(cursor,cursor) == 1 then
  315. output = output:sub(1,cursor-1)..output:sub(cursor+1)
  316. pleaseDoFunc = true
  317. end
  318. end
  319. elseif evt == "char" then
  320. output = output..key
  321. cursor = cursor + 1
  322. pleaseDoFunc = true
  323. end
  324. if pleaseDoFunc then
  325. pleaseDoFunc = false
  326. if doFunc then
  327. doFunc(output)
  328. end
  329. term.setCursorPos(sx,sy)
  330. local pOut = output
  331. if #output >= scr_x-(sx-2) then
  332. pOut = output:sub((#output+(sx))-scr_x)
  333. end
  334. if repchar then
  335. term.write(repchar:sub(1,1):rep(#pOut).." ")
  336. else
  337. term.write(pOut.." ")
  338. end
  339. local cx,cy = term.getCursorPos()
  340. term.setCursorPos(cx-1,cy)
  341. end
  342. end
  343. end
  344.  
  345.  
  346. local findPrompt = function()
  347. local cX,cY = term.getCursorPos()
  348. sleep(0)
  349. doFindFunc("")
  350. storeURLs = getFindList(funcread(nil,{},doFindFunc,false))
  351. term.setCursorBlink(false)
  352. maxScroll = setMaxScroll(catag)
  353. end
  354.  
  355. local clearMostline = function(length)
  356. local pX,pY = term.getCursorPos()
  357. term.setCursorPos(1,pY)
  358. term.write(string.rep(" ",length or (scr_x-1)))
  359. term.setCursorPos(pX,pY)
  360. end
  361.  
  362. local displayTitle = function()
  363. local title = {{},{},{},{},{0,0,0,0,0,1,1,1,1,1,0,0,2,2,2,2,2,2,2,0,2,2,2,2,0,0,32768,},{0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,2,0,0,0,0,0,2,0,2,2,0,32768,},{0,0,0,0,1,0,0,0,0,0,1,0,0,0,2,2,0,0,0,0,2,2,0,0,2,0,32768,},{0,0,0,0,1,1,0,0,0,0,0,0,0,0,2,0,0,0,0,0,2,0,0,0,2,0,32768,},{0,0,0,0,0,1,1,1,1,1,0,0,0,0,2,0,0,0,0,2,2,0,0,2,2,0,32768,},{0,0,0,0,0,0,0,0,0,1,0,0,0,2,2,0,0,0,2,2,0,0,2,2,0,0,32768,},{0,0,0,1,1,0,0,0,1,1,0,0,2,2,0,0,0,2,2,0,0,2,2,0,0,32768,1,},{0,0,0,0,1,1,1,1,1,0,0,0,2,0,0,0,2,2,2,2,2,2,0,0,32768,1,1,},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32768,1,1,1,},{0,0,0,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,1,1,1,1,},}
  364. setDefaultColors()
  365. term.clear()
  366. paintutils.drawImage(title,-1,1)
  367. setDefaultColors()
  368. term.setCursorPos(4,16)
  369. term.write("STD-GUI appstore")
  370. sleep(0)
  371. local evt
  372. repeat
  373. evt = os.pullEvent()
  374. until evt == "mouse_click" or evt == "key"
  375. sleep(0)
  376. end
  377.  
  378. local dotY
  379. local doScrollBar = false
  380. local fixDotY
  381.  
  382. renderStoreItem = function(obj)
  383. if not obj.title then return false end
  384. setDefaultColors()
  385. term.clear()
  386. term.setCursorPos(2,2)
  387. term.setTextColor(colors.yellow)
  388. print(obj.title)
  389. term.setTextColor(colors.white)
  390. write(" by ")
  391. print(obj.creator)
  392. write(" Catagory: ")
  393. if (catag ~= 0) then term.setTextColor(colors.lightGray) end
  394. print(storeCatagoryNames[obj.catagory])
  395. term.setTextColor(colors.white)
  396. print("\n "..obj.description)
  397. term.setTextColor(colors.lightGray)
  398. local post = " "..obj.forumPost:gsub("http://www.",""):sub(1,-2)
  399. local fy = (scr_y-1)-math.floor(#post / scr_x)
  400. term.setCursorPos(1,fy-1)
  401. print("Forum URL:")
  402. write(post)
  403. term.setTextColor(colors.white)
  404. term.setCursorPos(1,scr_y)
  405. term.setBackgroundColor(colors.red)
  406. term.clearLine()
  407. term.write("CLOSE")
  408. term.setCursorPos((scr_x-11),scr_y)
  409. term.setBackgroundColor(colors.green)
  410. term.write("RUN")
  411. term.setCursorPos((scr_x-7),scr_y)
  412. if isSimSoft then
  413. term.write("INSTALL!")
  414. else
  415. term.write("DOWNLOAD")
  416. end
  417. return true
  418. end
  419.  
  420. renderCatagoryMenu = function(expanded)
  421. if expanded then
  422. term.setCursorPos(1,1)
  423. term.setBackgroundColor(colors.gray)
  424. term.clearLine()
  425. term.setBackgroundColor(colors.white)
  426. term.setTextColor(colors.gray)
  427. term.write("Select category:")
  428. term.setTextColor(colors.black)
  429. local yposes = {}
  430. local longestLen = 0
  431. for a = 1, #storeCatagoryNames do
  432. if #storeCatagoryNames[a]+2 > longestLen then
  433. longestLen = #storeCatagoryNames[a]+2
  434. end
  435. end
  436. for a = 1, #storeCatagoryNames do
  437. term.setCursorPos(2,a+1)
  438. clearMostline(longestLen+2)
  439. term.write("@ "..storeCatagoryNames[a])
  440. table.insert(yposes,a+1)
  441. end
  442. return yposes,longestLen+2
  443. else
  444. term.setCursorPos(1,1)
  445. term.setTextColor(colors.lightGray)
  446. term.setBackgroundColor(colors.gray)
  447. if not storeCatagoryNames[catag] then
  448. if pocket then
  449. term.write("Set category")
  450. else
  451. term.write("Click to set category")
  452. end
  453. else
  454. if pocket then
  455. term.write(storeCatagoryNames[catag])
  456. else
  457. term.write("Category: "..storeCatagoryNames[catag])
  458. end
  459. end
  460. end
  461. term.setCursorPos(scr_x-4,1)
  462. term.setBackgroundColor(colors.red)
  463. term.setTextColor(colors.white)
  464. term.write("CLOSE")
  465. setDefaultColors()
  466. end
  467.  
  468. renderStore = function(list,filter,scrollY,namescroll,fixedDotY)
  469. local fullrend = {}
  470. local visiblerend = {}
  471. local amnt = 0
  472. local output = {}
  473. local num = 0
  474. term.current().setVisible(false)
  475. for k,v in pairs(list) do
  476. if (v.catagory == filter) or filter == 0 then
  477. table.insert(fullrend,{string.sub(" *"..v.title,namescroll),v})
  478. table.insert(fullrend,{" by "..v.creator,v})
  479. if filter == 0 then
  480. table.insert(fullrend,{" Catagory: "..storeCatagoryNames[v.catagory],v})
  481. else
  482. table.insert(fullrend,{"",v,k})
  483. end
  484. table.insert(fullrend,"nilline")
  485. end
  486. end
  487. dotY = fixedDotY or math.floor((scr_y-2)*((scroll-1)/(maxScroll-1)))+2
  488. for a = scrollY, (scr_y+scrollY)-1 do
  489. if type(fullrend[a]) == "table" then
  490. table.insert(visiblerend,fullrend[a][1])
  491. table.insert(output,fullrend[a][2])
  492. else
  493. table.insert(visiblerend,fullrend[a])
  494. table.insert(output,{})
  495. end
  496. end
  497. setDefaultColors()
  498. term.clear()
  499. for a = 1, #visiblerend do
  500. term.setCursorPos(1,a+1)
  501. if visiblerend[a] == "nilline" then
  502. setDefaultColors()
  503. clearMostline()
  504. else
  505. term.setBackgroundColor(colors.lightGray)
  506. term.setTextColor(colors.black)
  507. clearMostline()
  508. term.write(visiblerend[a])
  509. end
  510. end
  511. for a = 2, scr_y do
  512. term.setCursorPos(scr_x,a)
  513. if a == dotY then
  514. term.blit(" ","f","f")
  515. else
  516. term.blit(" ","0","0")
  517. end
  518. end
  519. term.current().setVisible(true)
  520. return output
  521. end
  522.  
  523. local tArg = {...}
  524.  
  525. function explode(div,str)
  526. if (div=='') then return false end
  527. local pos,arr = 0,{}
  528. for st,sp in function() return string.find(str,div,pos,true) end do
  529. table.insert(arr,string.sub(str,pos,st-1))
  530. pos = sp + 1
  531. end
  532. table.insert(arr,string.sub(str,pos))
  533. return arr
  534. end
  535.  
  536. if tArg[1] == "update" then
  537. local res, outcome = getSTDList()
  538. print(outcome)
  539. return
  540. elseif tArg[1] == "help" then
  541. return displayHelp(true)
  542. elseif tArg[1] == "upgrade" then
  543. local res, outcome = getFile(shell.getRunningProgram(),"http://pastebin.com/raw/P9dDhQ2m")
  544. if not res then
  545. error(outcome)
  546. else
  547. print("Updated STD-GUI to latest version ("..outcome.." bytes)")
  548. return
  549. end
  550. end
  551.  
  552. cleanExit = function()
  553. term.setTextColor(colors.white)
  554. term.setBackgroundColor(colors.black)
  555. term.clear()
  556. local out
  557. if pocket then
  558. out = "Thanks for using STD!"
  559. else
  560. out = "Thank you for using STD-GUI!"
  561. end
  562. if isSimSoft then
  563. term.setCursorBlink(false)
  564. end
  565. cprint(out,scr_y/2)
  566. term.setCursorPos(1,scr_y)
  567. sleep(0)
  568. error()
  569. end
  570. STDdownloadPrompt = function(item)
  571. term.setCursorPos(1,scr_y)
  572. bow()
  573. term.clearLine()
  574. write("Save as: ")
  575. local savepath = funcread(nil,{},nil,true)
  576. term.setCursorBlink(false)
  577. if savepath:gsub(" ","") == "" then
  578. sleep(0)
  579. return
  580. else
  581. if fs.exists(savepath) then
  582. term.setCursorPos(1,scr_y)
  583. term.clearLine()
  584. write("Overwrite? (Y/N)")
  585. local key
  586. repeat
  587. _,key = os.pullEvent("char")
  588. until string.find("yn",key)
  589. if key == "n" then
  590. sleep(0)
  591. return
  592. end
  593. end
  594. if relativePath then
  595. savepath = fs.combine(shell.dir(),savepath)
  596. end
  597. term.setCursorPos(1,scr_y)
  598. term.clearLine()
  599. term.write("Downloading...")
  600. local res, outcome = getFile(savepath,item.url)
  601. term.setCursorPos(1,scr_y)
  602. term.clearLine()
  603. if not res then
  604. term.write(outcome)
  605. sleep(0.6)
  606. else
  607. term.write("Downloaded! ("..outcome.." bytes)")
  608. sleep(0.7)
  609. end
  610. end
  611. return
  612. end
  613.  
  614. doEverything = function() --do I have to do EVERYTHING?
  615. if fs.exists(stdList) then
  616. shell.run(stdList)
  617. else
  618. if not storeURLs then
  619. getSTDList()
  620. end
  621. end
  622. maxScroll = setMaxScroll(catag)
  623. while true do
  624. if scroll > maxScroll then
  625. scroll = maxScroll
  626. end
  627. if scroll < 1 then
  628. scroll = 1
  629. end
  630. local yposes = renderStore(storeURLs,catag,scroll,scrollX,fixDotY)
  631. renderCatagoryMenu(false)
  632. local evt = {os.pullEvent()}
  633. if evt[1] == "mouse_scroll" then
  634. if scroll+evt[2] >= 1 and scroll+evt[2] <= maxScroll then
  635. scroll = scroll+evt[2]
  636. end
  637. elseif evt[1] == "mouse_click" then
  638. if evt[3] == scr_x and evt[4] == dotY then
  639. doScrollBar = true
  640. end
  641. if evt[4] == 1 then
  642. if evt[3] >= scr_x-4 then
  643. return cleanExit()
  644. end
  645. local cats,longth = renderCatagoryMenu(true)
  646. local evt,butt,x,y
  647. while true do
  648. local evt,butt,x,y = os.pullEvent()
  649. if evt == "mouse_click" or (evt == "mouse_up" and y ~= 1) then
  650. if y == 1 then
  651. catag = 0
  652. break
  653. else
  654. for a = 1, #cats do
  655. if cats[a] == y and x <= longth then
  656. catag = a
  657. scroll = 1
  658. end
  659. end
  660. break
  661. end
  662. elseif evt == "key" then
  663. if butt == keys.f1 then
  664. break
  665. end
  666. end
  667. end
  668. maxScroll = setMaxScroll(catag)
  669. elseif yposes[evt[4]-1] and evt[3] ~= scr_x then
  670. local y = evt[4]-1
  671. local guud = renderStoreItem(yposes[y])
  672. scrollX = 1
  673. while true do
  674. if not guud then break end
  675. local event,butt,cx,cy = os.pullEvent()
  676. if event == "key" then
  677. if butt == keys.q then
  678. sleep(0)
  679. break
  680. elseif butt == keys.d then
  681. sleep(0)
  682. STDdownloadPrompt(yposes[y])
  683. break
  684. end
  685. elseif event == "mouse_click" then
  686. if cy == scr_y then
  687. if (cx < scr_x-7) or (cx > scr_x) then
  688. if cx >= scr_x-11 and cx < scr_x-8 then
  689. term.setCursorPos(1,scr_y)
  690. bow()
  691. term.clearLine()
  692. if pocket then
  693. write("Args.: ")
  694. else
  695. write("Arguments:")
  696. end
  697. local arguments = explode(" ",funcread(nil,{},nil,true)) or {}
  698. term.setTextColor(colors.white)
  699. term.setBackgroundColor(colors.black)
  700. term.clear()
  701. term.setCursorPos(1,1)
  702. if #arguments == 0 then
  703. runURL(yposes[y].url)
  704. else
  705. runURL(yposes[y].url,unpack(arguments))
  706. end
  707. sleep(0)
  708. write("[press a key]")
  709. os.pullEvent("key")
  710. end
  711. sleep(0)
  712. break
  713. else
  714. term.setCursorPos(1,scr_y)
  715. bow()
  716. term.clearLine()
  717. if isSimSoft then
  718. local itname
  719. for k,v in pairs(storeURLs) do
  720. if yposes[y].url == v.url then
  721. itname = k
  722. break
  723. end
  724. end
  725. term.setCursorPos(1,scr_y)
  726. term.clearLine()
  727. term.write("Downloading...")
  728. local res, outcome = simSoftInstall(yposes[y],itname or yposes[y].title,lspath)
  729. term.setCursorPos(1,scr_y)
  730. term.write(outcome)
  731. sleep(#outcome/13)
  732. break
  733. else
  734. STDdownloadPrompt(yposes[y])
  735. break
  736. end
  737. end
  738. end
  739. end
  740. end
  741. end
  742. elseif evt[1] == "mouse_up" then
  743. doScrollBar = false
  744. fixDotY = nil
  745. elseif evt[1] == "mouse_drag" then
  746. if doScrollBar then
  747. local my = evt[4]
  748. if my > 1 then
  749. scroll = math.floor( (my-2)/(scr_y-2) * (maxScroll)) + 1
  750. fixDotY = my
  751. end
  752. end
  753. elseif evt[1] == "key" then
  754. if evt[2] == keys.q then
  755. return cleanExit()
  756. elseif evt[2] == keys.down then
  757. scroll = scroll + 4
  758. elseif evt[2] == keys.up then
  759. scroll = scroll - 4
  760. elseif evt[2] == keys.pageDown then
  761. scroll = scroll + (scr_y-1)
  762. elseif evt[2] == keys.pageUp then
  763. scroll = scroll - (scr_y-1)
  764. elseif evt[2] == keys.home then
  765. scroll = 1
  766. elseif evt[2] == keys['end'] then
  767. scroll = maxScroll
  768. elseif evt[2] == keys.h then --help screen!
  769. displayHelp(false)
  770. elseif evt[2] == keys.right then
  771. scrollX = scrollX + 1
  772. elseif evt[2] == keys.left then
  773. if scrollX > 1 then
  774. scrollX = scrollX - 1
  775. end
  776. elseif evt[2] == keys.numPadAdd then
  777. catag = catag + 1
  778. if catag > #storeCatagoryNames then
  779. catag = 0
  780. end
  781. scroll = 1
  782. maxScroll = setMaxScroll(catag)
  783. elseif evt[2] == keys.minus then
  784. catag = catag - 1
  785. if catag < 0 then
  786. catag = #storeCatagoryNames
  787. end
  788. scroll = 1
  789. maxScroll = setMaxScroll(catag)
  790. elseif evt[2] == keys.f5 then
  791. getSTDList()
  792. elseif evt[2] == keys.f12 then
  793. getFile(shell.getRunningProgram(),"http://pastebin.com/raw/P9dDhQ2m")
  794. local flashes = {
  795. colors.black,
  796. colors.white,
  797. colors.lightGray,
  798. colors.red,
  799. colors.gray,
  800. colors.black,
  801. }
  802. for a = 1, #flashes do
  803. term.setBackgroundColor(flashes[a])
  804. term.clear()
  805. sleep(0)
  806. end
  807. return
  808. elseif evt[2] == keys.f1 then
  809. os.queueEvent("mouse_click",1,1,1)
  810. elseif evt[2] == keys.f or evt[2] == keys.f6 then
  811. runFile(stdList)
  812. findPrompt()
  813. end
  814. end
  815. end
  816. end
  817.  
  818. if doDisplayTitle then
  819. displayTitle()
  820. end
  821.  
  822. if storeURLs then storeURLs = getFindList("") end
  823.  
  824. doEverything()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement