Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local c,d=term.getSize()local e,f,g,h=term.clear,term.setCursorPos,term.setTextColor,term.setBackgroundColor;local function i(j)local k;if _CC_VERSION then k=j<=_CC_VERSION elseif not _HOST then k=j<=os.version:gsub("CraftOS ","")else k=j<=_HOST:match("ComputerCraft ([0-9%.]+)")end;assert(k,"This program requires ComputerCraft "..j.." or later.")end;i("1.85.0")if not term.isColor()then print("Advanced Computer Required.")return end;local l={bar=colors.cyan,home=colors.white,home_background=colors.white,numbers=colors.white,selectedWindow=colors.lightGray}local m={{color=colors.black,time=0},{color=colors.lightGray,time=2},{color=colors.orange,time=6},{color=colors.yellow,time=12},{color=colors.orange,time=16},{color=colors.lightGray,time=20}}local n=term.current()local o=window.create(n,1,1,c,d-1)local p,q;local r="PED Loaded."local s,t,u,v=true,false,true,false;local function w()if t then return false end;if s then o.reposition(1,1,c,d)else o.reposition(1,1,c,d-1)end;o.redraw()o.restoreCursor()s=not s;u=true end;local function z(A)local A=A or nil;local function B(C,D)local E={}local F=0;while true do F=string.find(C,D,F+1)if F==nil then break end;table.insert(E,F)end;return#E end;if type(A)~="string"then g(colors.white)h(colors.black)write("File location: ")A=read()end;if fs.exists(A)then if fs.isDir(A)then printError("Cannot scan a directory.")return end;local G=fs.open(A,"r")if not G then printError("Failed to open "..A.."\46")return end;local H=G.readAll()G.close()local I={{"bit",colors.white},{"colors",colors.white},{"commands",colors.purple},{"coroutine",colors.white},{"disk",colors.white},{"fs",colors.red},{"gps",colors.white},{"http",colors.red},{"keys",colors.white},{"math",colors.white},{"multishell",colors.orange},{"os",colors.yellow},{"paintutils",colors.white},{"parallel",colors.white},{"peripheral",colors.white},{"rednet",colors.orange},{"redstone",colors.white},{"settings",colors.red},{"shell",colors.white},{"string",colors.white},{"table",colors.white},{"term",colors.white},{"textutils",colors.white},{"turtle",colors.lime},{"vector",colors.white},{"window",colors.yellow}}local J={"virus","pastebin"}for F=1,#I do local C=B(H,I[F][1].."%.")if C~=0 then g(I[F][2])write(I[F][1])g(colors.white)print(": "..C)sleep(0.1)end end;for F=1,#J do local C=B(H,J[F])if C~=0 then g(colors.red)write("found mention of ")g(colors.white)write(J[F])write(": "..C)g(colors.red)print("!")sleep(0.1)end end else printError("File does not exists.")end end;local function K()p,q=pcall(function()local L,M,N=true,{},0;while L do local function O()local P=""local Q={exit=function()L=false end,togglebar=w,scanfile=function(a)z(a)end}local R,S,u;while L do g(colors.lightBlue)if shell.dir()==""then write("/")else write(shell.dir())end;g(colors.yellow)write(" > ")g(colors.white)P,aCommand,N="",{},0;R,S=term.getCursorPos()term.setCursorBlink(true)while true do if u then f(R,S)write(P.." ")f(R+string.len(P),S)u=false end;a,b=os.pullEvent()if not t or v then if a=="char"then P=P..b;u=true elseif a=="key"then if b==keys.enter then break elseif b==keys.backspace then P=string.sub(P,1,string.len(P)-1)u=true elseif b==keys.up then N=math.min(N+1,#M)local x,y=term.getCursorPos()f(x-string.len(P)-3,y)if N>=1 then g(colors.gray)write(string.char(N+96))g(colors.yellow)write("> ")g(colors.lightGray)else g(colors.yellow)write(" > ")g(colors.white)end;for F=1,string.len(P)do write(" ")end;P=M[N]or P;u=true elseif b==keys.down then N=math.max(N-1,0)local x,y=term.getCursorPos()f(x-string.len(P)-3,y)if N>=1 then g(colors.gray)write(string.char(N+96))g(colors.yellow)write("> ")g(colors.lightGray)else g(colors.yellow)write(" > ")g(colors.white)end;for F=1,string.len(P)do write(" ")end;P=M[N]or""u=true end elseif a=="paste"then P=P..b;u=true end end end;local E=""for F=1,string.len(P)do if string.sub(P,F,F)==" "and aCommand[#aCommand]~=" "then aCommand[#aCommand+1]=E;E=""else E=E..string.sub(P,F,F)end end;aCommand[#aCommand+1]=E;if string.gsub(P," ","")~=""and M[#M]~=P then if#M>=26 then M[1]=P else M[#M+1]=P end end;print("")if Q[string.lower(aCommand[1])]then Q[string.lower(aCommand[1])](aCommand[2])else shell.run(P)end end end;term.redirect(o)O()end end)end;local function T()if s then term.setCursorBlink(false)g(colors.white)h(l.bar)f(c-string.len(" "..textutils.formatTime(os.time()).."."),d)write(" "..textutils.formatTime(os.time()))for F=1,#m do if m[F].time<os.time()then g(m[F].color)end end;write("\7")local U=math.ceil((fs.getCapacity("/")-fs.getFreeSpace("/"))/fs.getCapacity("/")*100)if U>80 then g(colors.red)else g(colors.white)end;f(2,d)write(U.."%")end end;local function V()p,q=pcall(function()while true do term.redirect(n)local E,W,X=term.getCursorBlink(),term.getTextColor(),term.getBackgroundColor()local Y,Z=term.getCursorPos()T()term.setCursorBlink(E)g(W)h(X)f(Y,Z)term.redirect(o)sleep(1)end end)end;local function _()p,q=pcall(function()local O=true;local a0={{name="Reboot",namecolor=colors.black,icon="\177",iconcolor=colors.yellow,process=function()os.reboot()end},{name="Shutdown",namecolor=colors.black,icon="\177",iconcolor=colors.red,process=function()os.shutdown()end},{name="CraftOS",namecolor=colors.black,icon="\169",iconcolor=colors.orange,process=function()O=false end}}local a1=math.max(6,math.floor(c/4))local function a2()if s then term.redirect(n)paintutils.drawLine(1,d,c,d,l.bar)T()if t then f(1,d)g(l.home)write("\6")paintutils.drawLine(1,d-(#a0+1),a1,d-(#a0+1),l.bar)paintutils.drawFilledBox(1,d-#a0,a1,d-1,l.home_background)f(1,d-#a0)for F=1,#a0 do g(a0[#a0-F+1].iconcolor)write(a0[#a0-F+1].icon)g(a0[#a0-F+1].namecolor)print(a0[#a0-F+1].name)end else f(1,d)g(l.home)write("\7")o.redraw()term.redirect(o)o.restoreCursor()end end end;while O do if u then a2()u=false end;a,b,x,y=os.pullEvent()r=a;if a=="mouse_click"and s then if t then if x==1 and y==d then t=false;u=true elseif x<=a1 and y>=d-#a0 and y~=d then if not a0[d-y]then error("Failed to find proccess "..d-y..".")end;a0[d-y].process()else t=false;u=true end else if x==1 and y==d then t=true;u=true end end elseif a=="key"then if t then t=false;u=true end;if b==keys.leftCtrl or b==keys.rightCtrl and not t then local a,b=os.pullEvent("key")if b==keys.f then w()end end elseif a=="term_resize"then if t then t=false;u=true end;term.redirect(n)c,d=term.getSize()if not s then o.reposition(1,1,c,d)else o.reposition(1,1,c,d-1)end;a1=math.max(6,math.floor(c/4))u=true;term.redirect(o)o.redraw()end end end)end;local function a3()p,q=pcall(function()local a4=""while true do if s then a,b,x,y=os.pullEvent()if a~="timer"and a~="key_up"and a~="mouse_up"then if s then term.redirect(n)f(6,d)g(colors.gray)h(l.bar)if a=="char"then write(b.." ")elseif a=="key"then if b==keys.right then write("\16")elseif b==keys.left then write("\17")elseif b==keys.up then write("\30")elseif b==keys.down then write("\31")elseif b==keys.enter then write("\26")elseif b==keys.backspace then write("\171")else write(keys.getName(b))end;write(" ")elseif a=="mouse_click"or a=="mouse_drag"then write(x..","..y.." ")else write(a.." ")end;term.redirect(o)o.restoreCursor()end end else sleep(0.1)end end end)end;local a5={"Console","Time","Bar","PED"}local a6=parallel.waitForAny(K,V,_,a3)term.redirect(n)term.setCursorBlink(false)if not p then g(colors.orange)h(colors.black)e()f(1,1)print("PCM crashed!")write("PID: ")g(colors.white)print(a6 .." ("..a5[a6]..")")g(colors.orange)write("Error: ")g(colors.white)print(q)g(colors.gray)sleep(5)f(1,d)write("Press and key to exit.")os.pullEvent()end;g(colors.white)h(colors.black)e()f(1,1)
Add Comment
Please, Sign In to add comment