Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function e(t)if not fs.exists("button")then
- shell.run("pastebin get LTDZZZEJ button")end if not fs.exists("dsa")then
- shell.run("pastebin get J9mhuXuf dsa")end if not fs.exists("startup")then local
- a=fs.open("startup","w")a.writeLine('shell.run("npp")')a.close()end local
- o=require("button").terminal local i=require("dsa")local n={}local
- s={term.getSize()}local h=s[2]-5 local r=0.1 if not fs.exists("npp.data")then
- fs.open("npp.data","w").close()end local function d(l,u)local
- c=term.getSize()term.setCursorPos(math.ceil((c/2)-(l:len()/2)),u)term.write(l)end
- term.setCursorPos(1,1)local function
- m()term.setTextColor(colors.white)d("CC notepad+",1)term.setTextColor(colors.gray)d(string.rep("-",s[1]+1),2)term.setTextColor(colors.cyan)end
- while true do term.setBackgroundColor(colors.black)term.clear()m()if click~=nil
- then for f=1,h do n[f]=i.getLine("npp.data",f)if n[f]==""then n[f]=nil break
- end end do local w=term.getSize()local y=">create items<"if
- o.button(1,click,math.ceil((w/2)-(y:len()/2)),3,y)then if#n<=h-1 then
- d("make new item",4)d("please enter name",5)d("max length: "..w,6)local p=1 for
- v=1,#n do p=p+1 end repeat term.setCursorPos(1,7)n[p]=read()if#n[p]>=w then
- term.setCursorPos(1,7)term.write("your item is too long"..string.rep(" ",w-21))sleep(1.5)term.clearLine()end
- until(#n[p]<=w-1 and#n[p]>0)or n[p]=="__exit"if n[p]=="__exit"then
- n[p]=string.rep("-",w+1)end i.writeLine("npp.data",p,n[p])else
- d("you reached",4)d("max item count",5)sleep(1.5)end end
- term.setTextColor(colors.white)end for b,g in ipairs(n)do local
- k=term.getSize()local q=i.getLine("npp.data",b)if
- q:gsub(string.sub(q,2),"")=="\127"then term.setTextColor(colors.orange)end
- local j=q:gsub("\127","")if
- o.button(1,click,math.ceil((k/2)-(string.len(j)/2)),b+4,j)then n[b]=nil
- n=i.ser(n)fs.open("npp.data","w").close()for x=1,#n do
- i.writeLine("npp.data",x,n[x])end end term.setTextColor(colors.white)end for
- z,E in ipairs(n)do local T=term.getSize()local A=i.getLine("npp.data",z)if
- A:gsub(string.sub(A,2),"")=="\127"then term.setTextColor(colors.orange)end
- local O=A:gsub("\127","")if
- o.button(2,click,math.ceil((T/2)-(string.len(O)/2)),z+4,O)then if
- A:gsub(string.sub(A,2),"")~="\127"then i.writeLine("npp.data",z,"\127"..A)else
- i.writeLine("npp.data",z,A:gsub("\127",""))end end
- term.setTextColor(colors.white)end local
- I={term.getSize()}term.setTextColor(colors.red)if
- o.button(1,click,1,I[2],">exit<")then term.clear()term.setCursorPos(1,1)break
- end term.setTextColor(colors.yellow)if
- o.button(1,click,I[1]-11,I[2],">update npp<")then
- shell.run("rename npp npp.old")shell.run("pastebin get dRMEt5t1 npp")shell.run("rm npp.old")shell.run("npp")break
- end if o.button(1,click,I[1]-4,1,">\16\b<")then shell.run("edit npp.data")end
- if o.button(2,click,I[1]-4,1,">\16\b<")then term.clear()m()local
- N,S=loadfile("npp.data","bt",_ENV)if not S then ok,S=pcall(N)end if not ok then
- local H=term.getSize()for R=3,H-1 do
- term.setCursorPos(term.getCursorPos(),R)term.clearLine()end
- m()d("your code has crashed",4)d("reason:",5)term.setCursorPos(1,6)print(S
- or"unknown")sleep(1.5)end sleep(1)end end click=o.timetouch(r)end end local
- D=...if D=="update"then
- shell.run("rename npp npp.old")shell.run("pastebin get dRMEt5t1 npp")shell.run("rm npp.old")shell.run("npp")end
- local L,U=pcall(e)if not L then term.clear()term.setCursorPos(1,1)if
- string.sub(U,9)~="invalid pattern capture"then
- print("CC notepad+ has crashed\nreason:\n"..U.."\nhold Q for 1 second to start again\n or press anything else\nto exit")local
- C,M=os.pullEvent("char")if M=="q"then sleep(1)local C,M=os.pullEvent("char")if
- M=="q"then shell.run("npp")end end else
- print("data storage corruted\nmaking copy\nand deleting")shell.run("copy npp.data npp.data."..tostring(math.random(1,100000)))shell.run("rm npp.data")sleep(2)shell.run("npp")end
- end
Add Comment
Please, Sign In to add comment