local tArgs = {...}
local path = fs.combine(fs.getDir(shell.getRunningProgram()),"edit.sgui")
if not tArgs[1] then
	lOS.execute(path)
elseif not fs.isDir(tArgs[1]) then
	local isPresent = false
	local pID
	if lOS.slime and lOS.slime.win then
		for k,v in pairs(lOS.processes) do
			if v == lOS.slime.win then
				isPresent = true
				pID = k
			end
		end
	end
	if isPresent then
		os.queueEvent("window_focus",pID,tostring(lOS.slime.win))
		os.queueEvent("slime_open",tArgs[1])
	else
		local files
		if fs.exists("AppData/Slime_Text/data.txt") then
			files = lUtils.asset.load("AppData/Slime_Text/data.txt")
		end
		if not files then
			files = {sFile=0}
		end
		local isOpen = false
		for t=1,#files do
			if files[t].path and files[t].path == tArgs[1] then
				isOpen = true
				files.sFile = t
			end
		end
		if not isOpen then
			if fs.exists(tArgs[1]) then
				table.insert(files,files.sFile+1,{content=lUtils.fread(tArgs[1]),path=tArgs[1],saved=true,name=lUtils.getFileName(tArgs[1],true),cursor={a=1,x=1,y=1},scrollX=0,scrollY=0})
			else
				table.insert(files,files.sFile+1,{content="",path=tArgs[1],saved=false,name=lUtils.getFileName(tArgs[1],true),cursor={a=1,x=1,y=1},scrollX=0,scrollY=0})
			end
			files.sFile = files.sFile+1
		end
		lUtils.asset.save(files,"AppData/Slime_Text/data.txt")
		lOS.execute(path)
        -- this is a comment
	end
else
	error("Can't edit a folder",0)
end -- bruh