Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Minif OS Look Tool
- --Functions and Variables
- local start = 0
- local function drawWindow()
- paintutils.drawFilledBox(3,3,osScreenSizeX-2,osScreenSizeY-2,colors.white)
- paintutils.drawBox(3,3,osScreenSizeX-2,5,colors.lightGray)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(4,4)
- term.write("Open File")
- end
- local function drawFile()
- paintutils.drawFilledBox(3,6,osScreenSizeX-2,osScreenSizeY-2,colors.white)
- term.setCursorPos(osScreenSizeX-6,osScreenSizeY-3)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.green)
- term.write("New")
- term.setBackgroundColor(colors.white)
- end
- local function runThing(file)
- if fs.isDir(file) then
- drawWindow()
- osListFiles(file.."/")
- else
- paintutils.drawFilledBox(3,6,osScreenSizeX-2,osScreenSizeY-2,colors.white)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(4,7)
- term.write(file)
- term.setCursorPos(4,8)
- term.write("Open this file using...")
- term.setCursorPos(4,10)
- term.setBackgroundColor(colors.lightBlue)
- term.write("Text")
- term.setCursorPos(9,10)
- term.write("Draw")
- term.setCursorPos(4,12)
- term.write("Copy")
- term.setCursorPos(9,12)
- term.write("Rename")
- term.setCursorPos(16,12)
- term.write("Delete")
- while true do
- osPEvent, osPB, osPX, osPY = os.pullEvent()
- if osPEvent == "mouse_click" then
- if osPY == 10 and osPX >= 4 and osPX <= 7 then
- shell.run('edit "'..file..'"')
- return
- else if osPY == 10 and osPX >= 9 and osPY <= 12 then
- shell.run('paint "'..file..'"')
- return
- else if osPY == 12 and osPX >= 4 and osPX <= 7 then
- term.setCursorPos(4,osScreenSizeY-4)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- local fname = read()
- if fs.exists("/user/".. osEnteredUser.."/"..fname) then
- term.setCursorPos(4,osScreenSizeY-3)
- term.setTextColor(colors.red)
- term.write("File Exists")
- sleep(2)
- else
- fs.copy(file,"/user/".. osEnteredUser.."/"..fname)
- end
- return
- else if osPY == 12 and osPX >= 9 and osPX <= 14 then
- term.setCursorPos(4,osScreenSizeY-4)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- local fname = read()
- if fs.exists("/user/".. osEnteredUser.."/"..fname) then
- term.setCursorPos(4,osScreenSizeY-3)
- term.setTextColor(colors.red)
- term.write("File Exists")
- sleep(2)
- else
- fs.move(file,"/user/".. osEnteredUser.."/"..fname)
- end
- return
- else if osPY == 12 and osPX >= 16 and osPX <= 21 then
- fs.delete(file)
- return
- else
- return
- end
- end
- end
- end
- end
- else
- if osPEvent == "key" then
- if osPB == keys.t then
- shell.run('edit "'..file..'"')
- end
- if osPB == keys.d then
- shell.run('paint "'..file..'"')
- end
- return
- end
- end
- end
- return
- end
- end
- local function newFile(loc)
- term.setCursorPos(4,osScreenSizeY-3)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.green)
- term.write("New: ")
- local newFile = read()
- if fs.exists(loc..newFile) then
- term.setCursorPos(4,osScreenSizeY-2)
- term.setTextColor(colors.red)
- print("File Exists!")
- sleep(2)
- else
- run = false
- runThing(loc..newFile)
- end
- term.setTextColor(colors.black)
- end
- function osListFiles(location)
- if osDisableSearch == true then
- return
- end
- local run = true
- local start = 0
- local list = fs.list(location)
- drawFile()
- while run do
- for i, file in ipairs(list) do
- if i>osScreenSizeY-4-7+start then
- term.setCursorPos(4,osScreenSizeY-3)
- term.write("Next>")
- osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
- if osPX>=3 and osPX<=(osScreenSizeX-2) and osPY>=7 and osPY<=(osScreenSizeY-5) then
- for e, file in ipairs(list) do
- if e == osPY + start-6 then
- if run then
- runThing(location..file)
- run = false
- end
- end
- end
- return
- else
- if osPY == osScreenSizeY-3 and osPX >= osScreenSizeX-6 and osPX <= osScreenSizeX-3 then
- newFile(location)
- return
- else
- drawFile()
- start = i-1
- end
- end
- end
- term.setCursorPos(4,i+6-start)
- if fs.isDir(location..file) then
- term.setTextColor(colors.green)
- else
- term.setTextColor(colors.black)
- end
- print(i.." "..file)
- end
- if run then
- osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
- if osPX>=3 and osPX<=(osScreenSizeX-2) and osPY>=7 and osPY<=(osScreenSizeY-4) then
- for e, file in ipairs(list) do
- if e == osPY + start-6 then
- if run then
- runThing(location..file)
- run = false
- end
- end
- end
- return
- else
- if osPY == osScreenSizeY-3 and osPX >= osScreenSizeX-6 and osPX <= osScreenSizeX-3 then
- newFile(location)
- return
- else
- return
- end
- end
- end
- end
- end
- --Execution
- drawWindow()
- osListFiles("/user/".. osEnteredUser.."/")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement