· 9 years ago · Jan 09, 2017, 08:10 PM
1function readLines(path)
2 local file = fs.open(path, "r")
3 local lines = {}
4 local line = file.readLine()
5 while line ~= nil do
6 table.insert( lines, line )
7 line = file.readLine()
8 end
9 file.close()
10 return lines
11end
12
13lines = readLines("startup")
14local file
15i = 1
16while string.find( lines[i], string.gsub("--#end;install;file#",";","_") ) == nil do
17 if string.find( lines[i], string.gsub("--#install;file;path#:",";","_") ) ~= nil then
18 if file ~= nil then file.close() end
19 file = fs.open(string.sub(lines[i], string.len("--#install;file;path#:")), "w")
20 else
21 if file ~= nil then
22 file.writeLine(string.sub(lines[i],3))
23 end
24 end
25 i = i + 1
26end
27if file ~= nil then file.close() end
28shell.run("reboot")
29
30
31
32--#install_file_path#:api/button
33---- Button API by FileStriker
34--
35--function create(anyButton, event, par1, par2, par3 ,size, isSelected, stringOptions , triggerButtons, colorOptions)
36-- if anyButton then
37-- return false, true
38-- end
39-- local bracketStart = ""
40-- local bracketEnd = ""
41-- local text = string.rep(" ",size)
42-- local ending = ""
43-- if stringOptions[1] ~= nil then
44-- text = stringOptions[1]
45-- end
46-- if stringOptions[6] ~= nil then
47-- ending = stringOptions[6]
48-- end
49--
50-- local oldTextCol = term.getTextColor()
51-- local oldBeckgroundCol = term.getBackgroundColor()
52--
53-- local posXStart, posYStart = term.getCursorPos()
54-- if isSelected then
55-- if stringOptions[4] ~= nil then
56-- bracketStart = stringOptions[4]
57-- end
58-- if stringOptions[5] ~= nil then
59-- bracketEnd = stringOptions[5]
60-- end
61--
62-- if colorOptions[3] ~= nul then
63-- screen.setTextColor(colorOptions[3])
64-- end
65-- if colorOptions[4] ~= nil then
66-- screen.setBackgroundColor(colorOptions[4])
67-- end
68--
69-- if size == 0 then
70-- size = string.len( text ) + string.len ( bracketStart ) + string.len ( bracketEnd )
71-- end
72--
73-- term.write(bracketStart .. stringN.cutRight(text, ending, size - string.len ( bracketStart ) - string.len ( bracketEnd ) ) .. bracketEnd)
74-- else
75-- if stringOptions[2] ~= nil then
76-- bracketStart = stringOptions[2]
77-- end
78-- if stringOptions[3] ~= nil then
79-- bracketEnd = stringOptions[3]
80-- end
81--
82-- if colorOptions[1] ~= nil then
83-- screen.setTextColor(colorOptions[1])
84-- end
85-- if colorOptions[2] ~= nil then
86-- screen.setBackgroundColor(colorOptions[2])
87-- end
88--
89-- if size == 0 then
90-- size = string.len( text ) + string.len ( bracketStart ) + string.len ( bracketEnd )
91-- end
92--
93-- term.write(bracketStart .. stringN.cutRight(text, ending, size - string.len ( bracketStart ) - string.len ( bracketEnd ) ) .. bracketEnd)
94-- end
95-- local posXEnd , posYEnd = term.getCursorPos()
96--
97-- screen.setTextColor(oldTextCol)
98-- screen.setBackgroundColor(oldBeckgroundCol)
99--
100-- if event == "mouse_up" then
101-- if par2 >= posXStart and par2 <= posXEnd and par3 == posYStart then
102-- return true , true
103-- end
104-- elseif event == "monitor_touch" then
105-- if par1 >= posXStart and par1 <= posXEnd and par2 == posYStart then
106-- return true , true
107-- end
108-- elseif isSelected and event == "key_up" then
109-- for i=1, #triggerButtons do
110-- if par1 == triggerButtons[i] then
111-- if anyButton then
112-- return false , true
113-- else
114-- return true , true
115-- end
116-- end
117-- end
118-- end
119-- return false , false
120--end
121--
122--function createGroupTable(buttonGroups)
123-- buttonGroups = {}
124-- buttonGroups.count = 0
125-- buttonGroups.current = 0
126-- buttonGroups.size = {}
127-- buttonGroups.selected = {}
128-- return buttonGroups
129--end
130--
131--function addGroup(size, current, buttonGroups)
132-- buttonGroups.count = buttonGroups.count + 1
133-- table.insert(buttonGroups.size,size)
134-- table.insert(buttonGroups.selected,current)
135-- return buttonGroups
136--end
137--
138--function isSelected(index, selection, buttonGroups)
139-- if index == buttonGroups.current then
140-- if buttonGroups.selected[index] == selection then
141-- return true
142-- end
143-- end
144-- return false
145--end
146--#install_file_path#:api/fileN
147--function readLines(path)
148-- local file = fs.open(path, "r")
149-- local lines = {}
150-- local line = file.readLine()
151-- while line ~= nil do
152-- table.insert( lines, line )
153-- line = file.readLine()
154-- end
155-- file.close()
156-- return lines
157--end
158--
159--function contains(content,lines)
160-- for i=1,#lines do
161-- if lines[i] == content then return true end
162-- end
163-- return false
164--end
165--#install_file_path#:api/list
166---- List API by FileStriker
167--
168--function list(intHight, intItems, intSelected)
169-- if intHight >= intItems then
170-- return 1, intItems
171-- end
172-- local intStart = math.floor(intHight / 2)
173-- local intEnd = intSelected + intHight - intStart - 1
174-- intStart = intSelected - intStart
175-- if intEnd > intItems then
176-- intStart = intItems - intHight + 1
177-- intEnd = intItems
178-- end
179-- if intStart < 1 then
180-- intEnd = intHight
181-- intStart = 1
182-- end
183-- return intStart, intEnd
184--end
185--
186--function scrollbar(intHight, intDisplay, intItems, intSelected)
187--
188-- local intPosX , intPosY = term.getCursorPos()
189--
190-- local intStart = 1
191-- local intEnd = intHight
192-- if intItems > intHight then
193-- local intSize = math.floor(intDisplay / intItems * intHight)
194-- local p = (intHight - intSize) / intItems
195-- intStart = math.ceil(intSelected * p)
196-- intEnd = intStart + intSize
197-- end
198-- for i = 1 ,intHight do
199-- term.setCursorPos(intPosX,i + intPosY - 1)
200-- if i >= intStart and i <= intEnd then
201-- term.write("#")
202-- else
203-- term.write("|")
204-- end
205-- end
206--end
207--#install_file_path#:api/screen
208---- Screen API by FileStriker
209--
210--function clear(colColor)
211-- width , height = term.getSize()
212-- term.setCursorPos(1,1)
213-- if term.isColor() then
214-- term.setBackgroundColor(colColor)
215-- end
216-- for i=1,height do
217-- term.setCursorPos(1,i)
218-- term.write(string.rep(" ", width))
219-- end
220-- term.setCursorPos(1,1)
221--end
222--
223--function clearLine(colColor)
224-- local width , height = term.getSize()
225-- local intPosX, intPosY = term.getCursorPos()
226-- term.setCursorPos(1,intPosY)
227-- if term.isColor() then
228-- term.setBackgroundColor(colColor)
229-- end
230-- term.write(string.rep(" ", width))
231-- term.setCursorPos(1,intPosY);
232--end
233--
234--function setTextColor(colColor)
235-- if term.isColor() then
236-- term.setTextColor(colColor)
237-- end
238--end
239--
240--function setBackgroundColor(colColor)
241-- if term.isColor() then
242-- term.setBackgroundColor(colColor)
243-- end
244--end
245--
246--function inputField(event, par1 , strText ,intEditPos, intOffset, intSize, numberMode)
247-- if event == "key" then
248-- if par1 == keys.backspace then
249-- if intEditPos > 0 then
250-- strText = stringN.removeAt(strText, intEditPos)
251-- intEditPos = intEditPos -1
252-- if intEditPos < 0 then
253-- intEditPos = 0
254-- end
255-- end
256-- elseif par1 == keys.left then
257-- intEditPos = intEditPos - 1
258-- if intEditPos < 0 then
259-- intEditPos = 0
260-- end
261-- elseif par1 == keys.right then
262-- intEditPos = intEditPos + 1
263-- if intEditPos > string.len( strText ) then
264-- intEditPos = string.len( strText )
265-- end
266-- end
267-- end
268-- if event == "char" then
269-- if numberMode then
270-- c = tonumber(par1)
271-- if c ~= nil then
272-- strText = stringN.insertAt(strText,c, intEditPos)
273-- intEditPos = intEditPos + 1
274-- end
275-- else
276-- strText = stringN.insertAt(strText,par1, intEditPos)
277-- intEditPos = intEditPos + 1
278-- end
279-- end
280-- write , intOffset = stringN.getFocus (strText , intOffset , intEditPos , intSize )
281-- term.write(write)
282-- return strText, intEditPos, intOffset
283--end
284--
285--local function waitInput()
286-- while true do
287-- event, par1, par2, par3, par4, par5 = os.pullEvent()
288-- if event == "mouse_up" or event == "monitor_touch" or event == "key_up" then
289-- break
290-- end
291-- end
292--end
293--
294--local wTime = 0
295--local function waitTime()
296-- sleep(wTime)
297--end
298--
299--function infoPopup(text,time)
300-- if string.len(text) > 0 then
301-- local width , height = term.getSize()
302-- local part = stringN.split(text,"\n")
303-- local start = math.max( math.floor( height / 2 - #part / 2) , 0 )
304-- local oldColor = term.getBackgroundColor()
305-- term.setCursorPos(2,start)
306-- screen.setBackgroundColor(colors.yellow)
307-- term.write( "+" .. string.rep( "-" , width - 4 ) .. "+" )
308-- for i=1,#part do
309-- term.setCursorPos(2,start + i)
310-- term.write("|")
311-- screen.setBackgroundColor(oldColor)
312-- term.write(stringN.setCenter(part[i],"",width - 4))
313-- screen.setBackgroundColor(colors.yellow)
314-- term.write("|")
315-- end
316-- term.setCursorPos(2,start + #part + 1)
317-- term.write( "+" .. string.rep( "-" , width - 4 ) .. "+" )
318-- screen.setBackgroundColor(colors.white)
319-- end
320-- wTime = time
321-- parallel.waitForAny(waitInput,waitTime)
322--end
323--#install_file_path#:api/startN
324--function setAsStartup (path, arguments)
325-- local file = fs.open("lightOS/startup/start", "w")
326-- file.writeLine(path)
327-- for i=1,#arguments do
328-- file.writeLine(arguments[i])
329-- end
330-- file.close()
331--end
332--
333--function getStartupPath ()
334-- if fs.exists("lightOS/startup/start") then
335-- local file = fs.open("lightOS/startup/start", "r")
336-- line = file.readLine()
337-- file.close()
338-- return line
339-- end
340-- return nil
341--end
342--
343--function removeStartup()
344-- if fs.exists("lightOS/startup/start") then
345-- fs.delete("lightOS/startup/start")
346-- return true
347-- end
348-- return false
349--end
350--#install_file_path#:api/stringN
351--function split(strText,char)
352-- t = {}
353-- if string.len( strText ) > 0 then
354-- for s in string.gmatch(strText, "([^" .. char .. "]+)") do
355-- table.insert( t, s )
356-- end
357-- end
358-- return t
359--end
360--
361--function insertAt(strText,char,index)
362-- local strStart = string.sub( strText,1, index)
363-- local strEnd = string.sub( strText,index + 1)
364-- return strStart .. char .. strEnd
365--end
366--
367--function removeAt(strText, index)
368-- local strStart = string.sub( strText,1, index - 1)
369-- local strEnd = string.sub( strText,index + 1)
370-- return strStart .. strEnd
371--end
372--
373--function cutRight(strText, strEnding, size)
374-- intTextLenght = string.len( strText )
375-- strFinalText = strText
376-- if intTextLenght < size then
377-- intSpace = size - intTextLenght
378-- for i = 1, intSpace do
379-- strFinalText = strFinalText .. " "
380-- end
381-- elseif intTextLenght > size then
382-- local intMaxLenght = size - string.len(strEnding)
383-- if intMaxLenght < 0 then
384-- strFinalText = string.sub( strText, 1, size)
385-- else
386-- strFinalText = string.sub( strText, 1, intMaxLenght) .. strEnding
387-- end
388-- end
389-- return strFinalText
390--end
391--
392--function setCenter( strText , strEnding , size)
393-- if string.len( strText ) > size then
394-- strText = string.sub ( strText , 1 , size - string.len ( strEnding ) ) .. strEnding
395-- end
396-- strText = string.sub ( strText , 1 , math.min( string.len( strText ) , size ) )
397-- intTextLenght = string.len( strText )
398-- local intRight = size - intTextLenght
399-- local intLeft = math.floor( intRight / 2 )
400-- intRight = intRight - intLeft
401-- return string.rep ( " " , intLeft ) .. strText .. string.rep ( " " , intRight )
402--end
403--
404--function getFocus( strText , intOffset , intCurrent , size )
405-- size = size - 2
406-- local intTextLenght = string.len ( strText )
407-- if intOffset + size + 1 > intTextLenght then
408-- intOffset = intTextLenght - size - 1
409-- end
410-- if intCurrent > intOffset + size then
411-- intOffset = intCurrent - size
412-- end
413-- if intCurrent < intOffset + math.min ( math.floor ( size / 2 ) , 5) then
414-- intOffset = intCurrent - math.min ( math.floor ( size / 2 ) , 5)
415-- end
416-- if intOffset < 0 then
417-- intOffset = 0
418-- intCurrent = 0
419-- end
420-- return string.sub ( strText , intOffset , intOffset + size + 1 ), intOffset
421--end
422--
423--function cutLeft(strText, strBegin, size)
424-- local intTextLenght = string.len( strText )
425-- local strFinalText = strText
426-- if intTextLenght < size then
427-- local intSpace = size - intTextLenght
428-- for i = 1, intSpace do
429-- strFinalText = strFinalText .. " "
430-- end
431-- elseif intTextLenght > size then
432-- local intMaxLenght = size - string.len(strBegin)
433-- if intMaxLenght < 0 then
434-- strFinalText = string.sub( strText, 1, size)
435-- else
436-- strFinalText = strBegin .. string.sub( strText, - intMaxLenght)
437-- end
438-- end
439-- return strFinalText
440--end
441--
442--function endsWith(text,ending)
443-- local textLenght = string.len( text )
444-- local endingLenght = string.len( ending )
445-- if textLenght < endingLenght then
446-- return false
447-- elseif textLenght == endingLenght then
448-- return (text == ending)
449-- else
450-- return (string.sub(text,textLenght - endingLenght + 1,textLenght) == ending)
451-- end
452--end
453--#install_file_path#:lightOS/browser/browser
454--if fs.exists("lightOS/browser/download") then
455-- fs.delete("lightOS/browser/download")
456--end
457--screen.clear(colors.white)
458--screen.setTextColor(colors.black)
459--shell.run("pastebin","get","ZbWvc7x9","lightOS/browser/download")
460--
461--local width, height = term.getSize()
462--
463--local anyButton = false
464--local isClick = false
465--local event
466--local par1
467--local par2
468--local par3
469--local par4
470--local par5
471--
472--
473--local buttonGroups
474--
475--local selection = 2
476--
477--local programs
478--
479--local function isType(types)
480-- local parts = stringN.split(types,",")
481-- for i=1,#parts do
482-- if parts[i] == "computer" then
483-- if turtle == false and pocket == false then
484-- return true
485-- end
486-- elseif parts[i] == "turtle" then
487-- if turtle then
488-- return true
489-- end
490-- elseif parts[i] == "pocket" then
491-- if pocket then
492-- return true
493-- end
494-- end
495--
496-- if (parts[i] == "computer" and computer )
497-- or (parts[i] == "turtle" and turtle)
498-- or (parts[i] == "pocket" and pocket) then
499-- return true
500-- end
501-- end
502-- return false
503--end
504--
505--local function initialize()
506-- lastCurrent = 2
507-- lastSelected = 1
508-- if buttonGroups ~= nil then
509-- lastCurrent = buttonGroups.current
510-- lastSelected = buttonGroups.selected[lastCurrent]
511-- elseif term.isColor() then
512-- lastCurrent = 0
513-- end
514--
515-- local lines = fileN.readLines("lightOS/browser/download")
516-- programs = {}
517-- programs.name = {}
518-- programs.version = {}
519-- programs.types = {}
520-- programs.pastebin = {}
521-- programs.pack = {}
522-- programs.info = {}
523-- for i=1,#lines do
524-- local parts = stringN.split(lines[i],"$")
525-- table.insert(programs.name , parts[1])
526-- table.insert(programs.version , parts[2])
527-- table.insert(programs.types , isType(parts[3]))
528-- table.insert(programs.pastebin , parts[4])
529-- table.insert(programs.pack , parts[5])
530-- table.insert(programs.info , parts[6])
531-- end
532--
533-- buttonGroups = {}
534-- buttonGroups = button.createGroupTable(buttonGroups)
535-- buttonGroups = button.addGroup(1,1,buttonGroups)
536-- buttonGroups = button.addGroup(#programs.name,1,buttonGroups)
537-- buttonGroups = button.addGroup(#programs.name,1,buttonGroups)
538--
539-- buttonGroups.current = lastCurrent
540-- if lastCurrent > 1 then
541-- buttonGroups.selected[2] = math.min(lastSelected, buttonGroups.size[2])
542-- buttonGroups.selected[3] = buttonGroups.selected[2]
543-- elseif lastCurrent == 1 then
544-- buttonGroups.selected[1] = lastSelected
545-- end
546--end
547--
548---- if term.isColor() then
549---- selected = 0
550---- end
551--
552--local function header()
553-- screen.clear(colors.white)
554-- screen.setTextColor(colors.black)
555-- screen.clearLine(colors.lime)
556-- term.write(stringN.setCenter("Browser","",width - 3))
557-- screen.setBackgroundColor(colors.white)
558--end
559--
560--if fs.exists("lightOS/browser/download") then
561-- initialize()
562-- header()
563-- while true do
564-- if event == "key" then
565-- if buttonGroups.current == 0 then
566-- buttonGroups.current = 1
567-- elseif buttonGroups.current == 1 then
568-- if par1 == keys.tab then
569-- buttonGroups.current = selection
570-- end
571-- else
572-- if par1 == keys.up or par1 == keys.w then
573-- buttonGroups.selected[2] = math.max(1, buttonGroups.selected[2] - 1)
574-- buttonGroups.selected[3] = buttonGroups.selected[2]
575-- elseif par1 == keys.down or par1 == keys.s then
576-- buttonGroups.selected[2] = math.min(buttonGroups.size[2], buttonGroups.selected[2] + 1)
577-- buttonGroups.selected[3] = buttonGroups.selected[2]
578-- elseif par1 == keys.left or par1 == keys.a then
579-- buttonGroups.current = math.max(2, buttonGroups.current - 1)
580-- elseif par1 == keys.right or par1 == keys.d then
581-- buttonGroups.current = math.min(3, buttonGroups.current + 1)
582-- elseif par1 == keys.tab then
583-- selection = buttonGroups.current
584-- buttonGroups.current = 1
585-- end
586-- end
587-- elseif event == "mouse_scroll" then
588-- if buttonGroups.current < 2 then
589-- buttonGroups.current = 2
590-- else
591-- if par1 == -1 then
592-- buttonGroups.selected[2] = math.max(1, buttonGroups.selected[2] - 1)
593-- buttonGroups.selected[3] = buttonGroups.selected[2]
594-- end
595-- if par1 == 1 then
596-- buttonGroups.selected[2] = math.min(buttonGroups.size[2], buttonGroups.selected[2] + 1)
597-- buttonGroups.selected[3] = buttonGroups.selected[2]
598-- end
599-- end
600-- end
601--
602--
603-- if buttonGroups.current > 1 and #programs.name == 0 then
604-- buttonGroups.current = 1
605-- end
606--
607-- term.setCursorPos(width - 2,1)
608-- isClick , anyButton = button.create(anyButton , event, par1,par2,par3,0, button.isSelected(1,1,buttonGroups), {"X"," "," ","[","]"},{keys.enter,keys.space},{colors.black,colors.red,colors.white,colors.red})
609-- if isClick then
610-- screen.clear(colors.black)
611-- screen.setTextColor(colors.white)
612-- break
613-- end
614--
615-- --Up
616-- term.setCursorPos(width, 2)
617-- isClick , anyButton = button.create(anyButton , event, par1,par2,par3,0,false, {"-"}, {keys.enter,keys.space} , {colors.black,colors.lightBlue})
618-- if isClick then
619-- if buttonGroups.current < 2 then
620-- buttonGroups.current = 2
621-- end
622-- buttonGroups.selected[2] = math.max(1, buttonGroups.selected[2] - 1)
623-- buttonGroups.selected[3] = buttonGroups.selected[2]
624-- end
625--
626-- --Down
627-- term.setCursorPos(width, height)
628-- isClick , anyButton = button.create(anyButton , event, par1,par2,par3,0,false, {"+"}, {keys.enter,keys.space} , {colors.black,colors.lightBlue})
629-- if isClick then
630-- if buttonGroups.current < 2 then
631-- buttonGroups.current = 2
632-- end
633-- buttonGroups.selected[2] = math.min(buttonGroups.size[2], buttonGroups.selected[2] + 1)
634-- buttonGroups.selected[3] = buttonGroups.selected[2]
635-- end
636--
637-- local start, ending = list.list(height - 1, buttonGroups.size[2], buttonGroups.selected[2])
638-- local line = 2
639-- local linecolor = {}
640-- for i = start, ending do
641-- term.setCursorPos(1,line)
642-- if programs.types[i] then
643-- linecolor = {colors.black,colors.white,colors.black,colors.white}
644-- else
645-- linecolor = {colors.lightGray,colors.white,colors.lightGray,colors.white}
646-- end
647-- isClick , anyButton = button.create(anyButton, event,par1,par2,par3,width - 12, button.isSelected(2,i,buttonGroups), {programs.name[i]," "," ",">"," ",".."},{keys.enter,keys.space},linecolor)
648-- if isClick then
649-- local name = programs.name[i]
650-- if programs.pack[i] == "true" then
651-- name = name .. ".install"
652-- end
653-- screen.clear(colors.white)
654-- screen.setTextColor(colors.black)
655-- shell.run("rom/programs/http/pastebin","get",programs.pastebin[i],"programs/"..name)
656-- if programs.pack == "true" then
657-- assert(loadfile("lightOS/explorer/open/open.install"))("programs/"..name)
658-- end
659-- end
660-- term.write("|".. stringN.cutLeft(programs.version[i],"",5).."|")
661-- isClick , anyButton = button.create(anyButton, event,par1,par2,par3,0, button.isSelected(3,i,buttonGroups), {"i"," "," ","[","]"},{keys.enter,keys.space},{colors.cyan,colors.white,colors.cyan,colors.white})
662-- if isClick then
663-- if startUpPath == programs.path[i] then
664-- startN.removeStartup()
665-- startUpPath = startN.getStartupPath()
666-- else
667-- os.run({}, "lightOS/startup/setAsStartup", programs.path[i])
668-- startUpPath = startN.getStartupPath()
669-- header()
670-- end
671-- end
672-- term.write("|")
673-- line = line + 1
674-- end
675--
676-- for i=2,height do
677-- term.setCursorPos(width - 11,i)
678-- term.write("|")
679-- term.setCursorPos(width - 5,i)
680-- term.write("|")
681-- term.setCursorPos(width - 1,i)
682-- term.write("|")
683-- end
684-- term.setCursorPos(width,3)
685-- list.scrollbar(height - 3 , height - 2 ,buttonGroups.size[2], buttonGroups.selected[1])
686--
687-- if anyButton then
688-- anyButton = false
689-- event = nil
690-- par1 = nil
691-- par2 = nil
692-- par3 = nil
693-- par4 = nil
694-- par5 = nil
695-- else
696-- while true do
697-- event, par1, par2, par3, par4, par5 = os.pullEvent()
698-- if event == "mouse_click" or event == "mouse_scroll" or event == "mouse_up" or event == "monitor_touch" or event == "key" or event == "key_up" then
699-- break
700-- end
701-- end
702-- end
703--
704-- if event == "mouse_up" then
705-- selected = 0
706-- end
707--
708-- end
709--
710--end
711--#install_file_path#:lightOS/browser/download
712--lightOS$03.27$computer,turtle,pocket$615JssrK$true$The base of all my programs
713--itemList$02.01$turtle$JmeF1Cq7$true$A program that creates a list of items, that should be used / ignored in other programs
714--advancedExcavate $02.07$turtle$reLWQC9y$true$Continue mining on world restart.
715--#install_file_path#:lightOS/explorer/edit
716---- Get file to edit
717--local tArgs = { ... }
718--if #tArgs == 0 then
719-- print( "Usage: edit <path>" )
720-- return
721--end
722--
723---- Error checking
724--local sPath = tArgs[1]
725--local bReadOnly = fs.isReadOnly( sPath )
726--if fs.exists( sPath ) and fs.isDir( sPath ) then
727-- print( "Cannot edit a directory." )
728-- return
729--end
730--
731--local x,y = 1,1
732--local w,h = term.getSize()
733--local scrollX, scrollY = 0,0
734--
735--local tLines = {}
736--local bRunning = true
737--
738---- Colours
739--local highlightColour, keywordColour, commentColour, textColour, bgColour, stringColour
740--if term.isColour() then
741-- bgColour = colours.black
742-- textColour = colours.white
743-- highlightColour = colours.yellow
744-- keywordColour = colours.yellow
745-- commentColour = colours.green
746-- stringColour = colours.red
747--else
748-- bgColour = colours.black
749-- textColour = colours.white
750-- highlightColour = colours.white
751-- keywordColour = colours.white
752-- commentColour = colours.white
753-- stringColour = colours.white
754--end
755--
756---- Menus
757--local bMenu = false
758--local nMenuItem = 1
759--local tMenuItems = {}
760--if not bReadOnly then
761-- table.insert( tMenuItems, "Save" )
762--end
763--if peripheral.find( "printer" ) then
764-- table.insert( tMenuItems, "Print" )
765--end
766--table.insert( tMenuItems, "Exit" )
767--
768--local sStatus = "Press Ctrl to access menu"
769--if string.len( sStatus ) > w - 5 then
770-- sStatus = "Press Ctrl for menu"
771--end
772--
773--local function load( _sPath )
774-- tLines = {}
775-- if fs.exists( _sPath ) then
776-- local file = io.open( _sPath, "r" )
777-- local sLine = file:read()
778-- while sLine do
779-- table.insert( tLines, sLine )
780-- sLine = file:read()
781-- end
782-- file:close()
783-- end
784--
785-- if #tLines == 0 then
786-- table.insert( tLines, "" )
787-- end
788--end
789--
790--local function save( _sPath )
791-- -- Create intervening folder
792-- local sDir = _sPath:sub(1, _sPath:len() - fs.getName(_sPath):len() )
793-- if not fs.exists( sDir ) then
794-- fs.makeDir( sDir )
795-- end
796--
797-- -- Save
798-- local file = nil
799-- local function innerSave()
800-- file = fs.open( _sPath, "w" )
801-- if file then
802-- for n, sLine in ipairs( tLines ) do
803-- file.write( sLine .. "\n" )
804-- end
805-- else
806-- error( "Failed to open ".._sPath )
807-- end
808-- end
809--
810-- local ok, err = pcall( innerSave )
811-- if file then
812-- file.close()
813-- end
814-- return ok, err
815--end
816--
817--local tKeywords = {
818-- ["and"] = true,
819-- ["break"] = true,
820-- ["do"] = true,
821-- ["else"] = true,
822-- ["elseif"] = true,
823-- ["end"] = true,
824-- ["false"] = true,
825-- ["for"] = true,
826-- ["function"] = true,
827-- ["if"] = true,
828-- ["in"] = true,
829-- ["local"] = true,
830-- ["nil"] = true,
831-- ["not"] = true,
832-- ["or"] = true,
833-- ["repeat"] = true,
834-- ["return"] = true,
835-- ["then"] = true,
836-- ["true"] = true,
837-- ["until"]= true,
838-- ["while"] = true,
839--}
840--
841--local function tryWrite( sLine, regex, colour )
842-- local match = string.match( sLine, regex )
843-- if match then
844-- if type(colour) == "number" then
845-- term.setTextColour( colour )
846-- else
847-- term.setTextColour( colour(match) )
848-- end
849-- term.write( match )
850-- term.setTextColour( textColour )
851-- return string.sub( sLine, string.len(match) + 1 )
852-- end
853-- return nil
854--end
855--
856--local function writeHighlighted( sLine )
857-- while string.len(sLine) > 0 do
858-- sLine =
859-- tryWrite( sLine, "^%-%-%[%[.-%]%]", commentColour ) or
860-- tryWrite( sLine, "^%-%-.*", commentColour ) or
861-- tryWrite( sLine, "^\"\"", stringColour ) or
862-- tryWrite( sLine, "^\".-[^\\]\"", stringColour ) or
863-- tryWrite( sLine, "^\'\'", stringColour ) or
864-- tryWrite( sLine, "^\'.-[^\\]\'", stringColour ) or
865-- tryWrite( sLine, "^%[%[.-%]%]", stringColour ) or
866-- tryWrite( sLine, "^[%w_]+", function( match )
867-- if tKeywords[ match ] then
868-- return keywordColour
869-- end
870-- return textColour
871-- end ) or
872-- tryWrite( sLine, "^[^%w_]", textColour )
873-- end
874--end
875--
876--local tCompletions
877--local nCompletion
878--
879--local tCompleteEnv = _ENV
880--local function complete( sLine )
881-- -- if settings.get( "edit.autocomplete" ) then
882-- -- local nStartPos = string.find( sLine, "[a-zA-Z0-9_%.]+$" )
883-- -- if nStartPos then
884-- -- sLine = string.sub( sLine, nStartPos )
885-- -- end
886-- -- if #sLine > 0 then
887-- -- return textutils.complete( sLine, tCompleteEnv )
888-- -- end
889-- -- end
890-- return nil
891--end
892--
893--local function recomplete()
894-- local sLine = tLines[y]
895-- if not bMenu and not bReadOnly and x == string.len(sLine) + 1 then
896-- tCompletions = complete( sLine )
897-- if tCompletions and #tCompletions > 0 then
898-- nCompletion = 1
899-- else
900-- nCompletion = nil
901-- end
902-- else
903-- tCompletions = nil
904-- nCompletion = nil
905-- end
906--end
907--
908--local function writeCompletion( sLine )
909-- if nCompletion then
910-- local sCompletion = tCompletions[ nCompletion ]
911-- term.setTextColor( colours.white )
912-- term.setBackgroundColor( colours.grey )
913-- term.write( sCompletion )
914-- term.setTextColor( textColour )
915-- term.setBackgroundColor( bgColour )
916-- end
917--end
918--
919--local function redrawText()
920-- local cursorX, cursorY = x, y
921-- for y=1,h-1 do
922-- term.setCursorPos( 1 - scrollX, y )
923-- term.clearLine()
924--
925-- local sLine = tLines[ y + scrollY ]
926-- if sLine ~= nil then
927-- writeHighlighted( sLine )
928-- if cursorY == y and cursorX == #sLine + 1 then
929-- writeCompletion()
930-- end
931-- end
932-- end
933-- term.setCursorPos( x - scrollX, y - scrollY )
934--end
935--
936--local function redrawLine(_nY)
937-- local sLine = tLines[_nY]
938-- if sLine then
939-- term.setCursorPos( 1 - scrollX, _nY - scrollY )
940-- term.clearLine()
941-- writeHighlighted( sLine )
942-- if _nY == y and x == #sLine + 1 then
943-- writeCompletion()
944-- end
945-- term.setCursorPos( x - scrollX, _nY - scrollY )
946-- end
947--end
948--
949--local function redrawMenu()
950-- -- Clear line
951-- term.setCursorPos( 1, h )
952-- term.clearLine()
953--
954-- -- Draw line numbers
955-- term.setCursorPos( w - string.len( "Ln "..y ) + 1, h )
956-- term.setTextColour( highlightColour )
957-- term.write( "Ln " )
958-- term.setTextColour( textColour )
959-- term.write( y )
960--
961-- term.setCursorPos( 1, h )
962-- if bMenu then
963-- -- Draw menu
964-- term.setTextColour( textColour )
965-- for nItem,sItem in pairs( tMenuItems ) do
966-- if nItem == nMenuItem then
967-- term.setTextColour( highlightColour )
968-- term.write( "[" )
969-- term.setTextColour( textColour )
970-- term.write( sItem )
971-- term.setTextColour( highlightColour )
972-- term.write( "]" )
973-- term.setTextColour( textColour )
974-- else
975-- term.write( " "..sItem.." " )
976-- end
977-- end
978-- else
979-- -- Draw status
980-- term.setTextColour( highlightColour )
981-- term.write( sStatus )
982-- term.setTextColour( textColour )
983-- end
984--
985-- -- Reset cursor
986-- term.setCursorPos( x - scrollX, y - scrollY )
987--end
988--
989--local tMenuFuncs = {
990-- Save = function()
991-- if bReadOnly then
992-- sStatus = "Access denied"
993-- else
994-- local ok, err = save( sPath )
995-- if ok then
996-- sStatus="Saved to "..sPath
997-- else
998-- sStatus="Error saving to "..sPath
999-- end
1000-- end
1001-- redrawMenu()
1002-- end,
1003-- Print = function()
1004-- local printer = peripheral.find( "printer" )
1005-- if not printer then
1006-- sStatus = "No printer attached"
1007-- return
1008-- end
1009--
1010-- local nPage = 0
1011-- local sName = fs.getName( sPath )
1012-- if printer.getInkLevel() < 1 then
1013-- sStatus = "Printer out of ink"
1014-- return
1015-- elseif printer.getPaperLevel() < 1 then
1016-- sStatus = "Printer out of paper"
1017-- return
1018-- end
1019--
1020-- local screenTerminal = term.current()
1021-- local printerTerminal = {
1022-- getCursorPos = printer.getCursorPos,
1023-- setCursorPos = printer.setCursorPos,
1024-- getSize = printer.getPageSize,
1025-- write = printer.write,
1026-- }
1027-- printerTerminal.scroll = function()
1028-- if nPage == 1 then
1029-- printer.setPageTitle( sName.." (page "..nPage..")" )
1030-- end
1031--
1032-- while not printer.newPage() do
1033-- if printer.getInkLevel() < 1 then
1034-- sStatus = "Printer out of ink, please refill"
1035-- elseif printer.getPaperLevel() < 1 then
1036-- sStatus = "Printer out of paper, please refill"
1037-- else
1038-- sStatus = "Printer output tray full, please empty"
1039-- end
1040--
1041-- term.redirect( screenTerminal )
1042-- redrawMenu()
1043-- term.redirect( printerTerminal )
1044--
1045-- local timer = os.startTimer(0.5)
1046-- sleep(0.5)
1047-- end
1048--
1049-- nPage = nPage + 1
1050-- if nPage == 1 then
1051-- printer.setPageTitle( sName )
1052-- else
1053-- printer.setPageTitle( sName.." (page "..nPage..")" )
1054-- end
1055-- end
1056--
1057-- bMenu = false
1058-- term.redirect( printerTerminal )
1059-- local ok, error = pcall( function()
1060-- term.scroll()
1061-- for n, sLine in ipairs( tLines ) do
1062-- print( sLine )
1063-- end
1064-- end )
1065-- term.redirect( screenTerminal )
1066-- if not ok then
1067-- print( error )
1068-- end
1069--
1070-- while not printer.endPage() do
1071-- sStatus = "Printer output tray full, please empty"
1072-- redrawMenu()
1073-- sleep( 0.5 )
1074-- end
1075-- bMenu = true
1076--
1077-- if nPage > 1 then
1078-- sStatus = "Printed "..nPage.." Pages"
1079-- else
1080-- sStatus = "Printed 1 Page"
1081-- end
1082-- redrawMenu()
1083-- end,
1084-- Exit = function()
1085-- bRunning = false
1086-- end
1087--}
1088--
1089--local function doMenuItem( _n )
1090-- tMenuFuncs[tMenuItems[_n] ]()
1091-- if bMenu then
1092-- bMenu = false
1093-- term.setCursorBlink( true )
1094-- end
1095-- redrawMenu()
1096--end
1097--
1098--local function setCursor( newX, newY )
1099-- local oldX, oldY = x, y
1100-- x, y = newX, newY
1101-- local screenX = x - scrollX
1102-- local screenY = y - scrollY
1103--
1104-- local bRedraw = false
1105-- if screenX < 1 then
1106-- scrollX = x - 1
1107-- screenX = 1
1108-- bRedraw = true
1109-- elseif screenX > w then
1110-- scrollX = x - w
1111-- screenX = w
1112-- bRedraw = true
1113-- end
1114--
1115-- if screenY < 1 then
1116-- scrollY = y - 1
1117-- screenY = 1
1118-- bRedraw = true
1119-- elseif screenY > h-1 then
1120-- scrollY = y - (h-1)
1121-- screenY = h-1
1122-- bRedraw = true
1123-- end
1124--
1125-- recomplete()
1126-- if bRedraw then
1127-- redrawText()
1128-- elseif y ~= oldY then
1129-- redrawLine( oldY )
1130-- redrawLine( y )
1131-- else
1132-- redrawLine( y )
1133-- end
1134-- term.setCursorPos( screenX, screenY )
1135--
1136-- redrawMenu()
1137--end
1138--
1139---- Actual program functionality begins
1140--load(sPath)
1141--
1142--term.setBackgroundColour( bgColour )
1143--term.clear()
1144--term.setCursorPos(x,y)
1145--term.setCursorBlink( true )
1146--
1147--recomplete()
1148--redrawText()
1149--redrawMenu()
1150--
1151--local function acceptCompletion()
1152-- if nCompletion then
1153-- -- Append the completion
1154-- local sCompletion = tCompletions[ nCompletion ]
1155-- tLines[y] = tLines[y] .. sCompletion
1156-- setCursor( x + string.len( sCompletion ), y )
1157-- end
1158--end
1159--
1160---- Handle input
1161--while bRunning do
1162-- local sEvent, param, param2, param3 = os.pullEvent()
1163-- if sEvent == "key" then
1164-- local oldX, oldY = x, y
1165-- if param == keys.up then
1166-- -- Up
1167-- if not bMenu then
1168-- if nCompletion then
1169-- -- Cycle completions
1170-- nCompletion = nCompletion - 1
1171-- if nCompletion < 1 then
1172-- nCompletion = #tCompletions
1173-- end
1174-- redrawLine(y)
1175--
1176-- elseif y > 1 then
1177-- -- Move cursor up
1178-- setCursor(
1179-- math.min( x, string.len( tLines[y - 1] ) + 1 ),
1180-- y - 1
1181-- )
1182-- end
1183-- end
1184--
1185-- elseif param == keys.down then
1186-- -- Down
1187-- if not bMenu then
1188-- -- Move cursor down
1189-- if nCompletion then
1190-- -- Cycle completions
1191-- nCompletion = nCompletion + 1
1192-- if nCompletion > #tCompletions then
1193-- nCompletion = 1
1194-- end
1195-- redrawLine(y)
1196--
1197-- elseif y < #tLines then
1198-- -- Move cursor down
1199-- setCursor(
1200-- math.min( x, string.len( tLines[y + 1] ) + 1 ),
1201-- y + 1
1202-- )
1203-- end
1204-- end
1205--
1206-- elseif param == keys.tab then
1207-- -- Tab
1208-- if not bMenu and not bReadOnly then
1209-- if nCompletion and x == string.len(tLines[y]) + 1 then
1210-- -- Accept autocomplete
1211-- acceptCompletion()
1212-- else
1213-- -- Indent line
1214-- local sLine = tLines[y]
1215-- tLines[y] = string.sub(sLine,1,x-1) .. " " .. string.sub(sLine,x)
1216-- setCursor( x + 2, y )
1217-- end
1218-- end
1219--
1220-- elseif param == keys.pageUp then
1221-- -- Page Up
1222-- if not bMenu then
1223-- -- Move up a page
1224-- local newY
1225-- if y - (h - 1) >= 1 then
1226-- newY = y - (h - 1)
1227-- else
1228-- newY = 1
1229-- end
1230-- setCursor(
1231-- math.min( x, string.len( tLines[newY] ) + 1 ),
1232-- newY
1233-- )
1234-- end
1235--
1236-- elseif param == keys.pageDown then
1237-- -- Page Down
1238-- if not bMenu then
1239-- -- Move down a page
1240-- local newY
1241-- if y + (h - 1) <= #tLines then
1242-- newY = y + (h - 1)
1243-- else
1244-- newY = #tLines
1245-- end
1246-- local newX = math.min( x, string.len( tLines[newY] ) + 1 )
1247-- setCursor( newX, newY )
1248-- end
1249--
1250-- elseif param == keys.home then
1251-- -- Home
1252-- if not bMenu then
1253-- -- Move cursor to the beginning
1254-- if x > 1 then
1255-- setCursor(1,y)
1256-- end
1257-- end
1258--
1259-- elseif param == keys["end"] then
1260-- -- End
1261-- if not bMenu then
1262-- -- Move cursor to the end
1263-- local nLimit = string.len( tLines[y] ) + 1
1264-- if x < nLimit then
1265-- setCursor( nLimit, y )
1266-- end
1267-- end
1268--
1269-- elseif param == keys.left then
1270-- -- Left
1271-- if not bMenu then
1272-- if x > 1 then
1273-- -- Move cursor left
1274-- setCursor( x - 1, y )
1275-- elseif x==1 and y>1 then
1276-- setCursor( string.len( tLines[y-1] ) + 1, y - 1 )
1277-- end
1278-- else
1279-- -- Move menu left
1280-- nMenuItem = nMenuItem - 1
1281-- if nMenuItem < 1 then
1282-- nMenuItem = #tMenuItems
1283-- end
1284-- redrawMenu()
1285-- end
1286--
1287-- elseif param == keys.right then
1288-- -- Right
1289-- if not bMenu then
1290-- local nLimit = string.len( tLines[y] ) + 1
1291-- if x < nLimit then
1292-- -- Move cursor right
1293-- setCursor( x + 1, y )
1294-- elseif nCompletion and x == string.len(tLines[y]) + 1 then
1295-- -- Accept autocomplete
1296-- acceptCompletion()
1297-- elseif x==nLimit and y<#tLines then
1298-- -- Go to next line
1299-- setCursor( 1, y + 1 )
1300-- end
1301-- else
1302-- -- Move menu right
1303-- nMenuItem = nMenuItem + 1
1304-- if nMenuItem > #tMenuItems then
1305-- nMenuItem = 1
1306-- end
1307-- redrawMenu()
1308-- end
1309--
1310-- elseif param == keys.delete then
1311-- -- Delete
1312-- if not bMenu and not bReadOnly then
1313-- local nLimit = string.len( tLines[y] ) + 1
1314-- if x < nLimit then
1315-- local sLine = tLines[y]
1316-- tLines[y] = string.sub(sLine,1,x-1) .. string.sub(sLine,x+1)
1317-- recomplete()
1318-- redrawLine(y)
1319-- elseif y<#tLines then
1320-- tLines[y] = tLines[y] .. tLines[y+1]
1321-- table.remove( tLines, y+1 )
1322-- recomplete()
1323-- redrawText()
1324-- end
1325-- end
1326--
1327-- elseif param == keys.backspace then
1328-- -- Backspace
1329-- if not bMenu and not bReadOnly then
1330-- if x > 1 then
1331-- -- Remove character
1332-- local sLine = tLines[y]
1333-- tLines[y] = string.sub(sLine,1,x-2) .. string.sub(sLine,x)
1334-- setCursor( x - 1, y )
1335-- elseif y > 1 then
1336-- -- Remove newline
1337-- local sPrevLen = string.len( tLines[y-1] )
1338-- tLines[y-1] = tLines[y-1] .. tLines[y]
1339-- table.remove( tLines, y )
1340-- setCursor( sPrevLen + 1, y - 1 )
1341-- redrawText()
1342-- end
1343-- end
1344--
1345-- elseif param == keys.enter then
1346-- -- Enter
1347-- if not bMenu and not bReadOnly then
1348-- -- Newline
1349-- local sLine = tLines[y]
1350-- local _,spaces=string.find(sLine,"^[ ]+")
1351-- if not spaces then
1352-- spaces=0
1353-- end
1354-- tLines[y] = string.sub(sLine,1,x-1)
1355-- table.insert( tLines, y+1, string.rep(' ',spaces)..string.sub(sLine,x) )
1356-- setCursor( spaces + 1, y + 1 )
1357-- redrawText()
1358--
1359-- elseif bMenu then
1360-- -- Menu selection
1361-- doMenuItem( nMenuItem )
1362--
1363-- end
1364--
1365-- elseif param == keys.leftCtrl or param == keys.rightCtrl or param == keys.rightAlt then
1366-- -- Menu toggle
1367-- bMenu = not bMenu
1368-- if bMenu then
1369-- term.setCursorBlink( false )
1370-- else
1371-- term.setCursorBlink( true )
1372-- end
1373-- redrawMenu()
1374--
1375-- end
1376--
1377-- elseif sEvent == "char" then
1378-- if not bMenu and not bReadOnly then
1379-- -- Input text
1380-- local sLine = tLines[y]
1381-- tLines[y] = string.sub(sLine,1,x-1) .. param .. string.sub(sLine,x)
1382-- setCursor( x + 1, y )
1383--
1384-- elseif bMenu then
1385-- -- Select menu items
1386-- for n,sMenuItem in ipairs( tMenuItems ) do
1387-- if string.lower(string.sub(sMenuItem,1,1)) == string.lower(param) then
1388-- doMenuItem( n )
1389-- break
1390-- end
1391-- end
1392-- end
1393--
1394-- elseif sEvent == "paste" then
1395-- if not bMenu and not bReadOnly then
1396-- -- Input text
1397-- local sLine = tLines[y]
1398-- tLines[y] = string.sub(sLine,1,x-1) .. param .. string.sub(sLine,x)
1399-- setCursor( x + string.len( param ), y )
1400-- end
1401--
1402-- elseif sEvent == "mouse_click" then
1403-- if not bMenu then
1404-- if param == 1 then
1405-- -- Left click
1406-- local cx,cy = param2, param3
1407-- if cy < h then
1408-- local newY = math.min( math.max( scrollY + cy, 1 ), #tLines )
1409-- local newX = math.min( math.max( scrollX + cx, 1 ), string.len( tLines[newY] ) + 1 )
1410-- setCursor( newX, newY )
1411-- end
1412-- end
1413-- end
1414--
1415-- elseif sEvent == "mouse_scroll" then
1416-- if not bMenu then
1417-- if param == -1 then
1418-- -- Scroll up
1419-- if scrollY > 0 then
1420-- -- Move cursor up
1421-- scrollY = scrollY - 1
1422-- redrawText()
1423-- end
1424--
1425-- elseif param == 1 then
1426-- -- Scroll down
1427-- local nMaxScroll = #tLines - (h-1)
1428-- if scrollY < nMaxScroll then
1429-- -- Move cursor down
1430-- scrollY = scrollY + 1
1431-- redrawText()
1432-- end
1433--
1434-- end
1435-- end
1436--
1437-- elseif sEvent == "term_resize" then
1438-- w,h = term.getSize()
1439-- setCursor( x, y )
1440-- redrawMenu()
1441-- redrawText()
1442--
1443-- end
1444--end
1445--
1446---- Cleanup
1447--term.clear()
1448--term.setCursorBlink( false )
1449--term.setCursorPos( 1, 1 )
1450--#install_file_path#:lightOS/explorer/editFile
1451--path = ...
1452--if path == nil then
1453-- path = ""
1454--end
1455--local startUpPath = startN.getStartupPath()
1456--
1457--local text = fs.getName(path)
1458--local intEditPos = string.len( text )
1459--local intOffset = 0
1460--
1461--local intSelected = 6
1462--
1463--local width, intHight = term.getSize()
1464--
1465--local clicked = false
1466--local anyButtonClicked = false
1467--
1468--local event = nil
1469--local par1 = nil
1470--local par2 = nil
1471--local par3 = nil
1472--local par4 = nil
1473--local par5 = nil
1474--
1475--
1476--function header()
1477-- screen.clear(colors.white)
1478-- screen.setTextColor(colors.black)
1479-- screen.setBackgroundColor(colors.lime)
1480-- term.write ( stringN.setCenter ( fs.getName(path), ".." , width - 3 ) )
1481-- screen.setBackgroundColor(colors.white)
1482-- term.setCursorPos(1,2)
1483-- term.write("Path: ")
1484-- if string.len( path ) == 0 then
1485-- term.write("Root")
1486-- else
1487-- term.write(stringN.cutLeft(path, "..", width - 6))
1488-- end
1489-- screen.setBackgroundColor(colors.blue)
1490-- term.setCursorPos(1,4)
1491-- term.write("+" .. string.rep("-" , width - 2) .. "+")
1492-- term.setCursorPos(1,5)
1493-- term.write(string.rep("|" , width))
1494-- term.setCursorPos(1,6)
1495-- term.write("+" .. string.rep("-" , width - 2) .. "+")
1496-- screen.setBackgroundColor(colors.white)
1497--end
1498--
1499--header()
1500--
1501--while true do
1502-- if event == "key" then
1503-- if intSelected == 0 then
1504-- intSelected = 4
1505-- elseif intSelected == 1 then
1506-- if par1 == keys.tab then
1507-- intSelected = 8
1508-- elseif par1 == keys.down or par1 == keys.s then
1509-- intSelected = 2
1510-- end
1511-- elseif intSelected == 2 then
1512-- if par1 == keys.up or par1 == keys.tab then
1513-- intSelected = 1
1514-- elseif par1 == keys.down then
1515-- intSelected = 3
1516-- end
1517-- elseif intSelected == 3 then
1518-- if par1 == keys.up or par1 == keys.w or par1 == keys.tab then
1519-- intSelected = 2
1520-- elseif par1 == keys.down or par1 == keys.s then
1521-- intSelected = 6
1522-- elseif par1 == keys.right or par1 == keys.d then
1523-- intSelected = 4
1524-- end
1525-- elseif intSelected == 4 then
1526-- if par1 == keys.up or par1 == keys.w then
1527-- intSelected = 2
1528-- elseif par1 == keys.down or par1 == keys.s then
1529-- intSelected = 7
1530-- elseif par1 == keys.left or par1 == keys.a or par1 == keys.tab then
1531-- intSelected = 3
1532-- elseif par1 == keys.right or par1 == keys.d then
1533-- intSelected = 5
1534-- end
1535-- elseif intSelected == 5 then
1536-- if par1 == keys.up or par1 == keys.w then
1537-- intSelected = 2
1538-- elseif par1 == keys.left or par1 == keys.a or par1 == keys.tab then
1539-- intSelected = 4
1540-- elseif par1 == keys.down or par1 == keys.s then
1541-- intSelected = 8
1542-- end
1543-- elseif intSelected == 6 then
1544-- if par1 == keys.up or par1 == keys.w then
1545-- intSelected = 3
1546-- elseif par1 == keys.tab then
1547-- intSelected = 5
1548-- elseif par1 == keys.right or par1 == keys.d then
1549-- intSelected = 7
1550-- end
1551-- elseif intSelected == 7 then
1552-- if par1 == keys.up or par1 == keys.w then
1553-- intSelected = 4
1554-- elseif par1 == keys.left or par1 == keys.a or par1 == keys.tab then
1555-- intSelected = 6
1556-- elseif par1 == keys.right or par1 == keys.d then
1557-- intSelected = 8
1558-- end
1559-- elseif intSelected == 8 then
1560-- if par1 == keys.up or par1 == keys.w then
1561-- intSelected = 5
1562-- elseif par1 == keys.left or par1 == keys.a or par1 == keys.tab then
1563-- intSelected = 7
1564-- end
1565-- end
1566-- elseif event == "mouse_click" then
1567-- intSelected = 0
1568-- end
1569--
1570-- screen.setBackgroundColor(colors.white)
1571-- screen.setTextColor(colors.black)
1572--
1573-- screen.setBackgroundColor(colors.white)
1574-- screen.setTextColor(colors.black)
1575--
1576-- term.setCursorPos(width - 2, 1)
1577-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 1), {"X"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.red,colors.white,colors.red})
1578-- if clicked then
1579-- term.setCursorBlink(false)
1580-- screen.clear(colors.black)
1581-- screen.setTextColor(colors.white)
1582-- break
1583-- end
1584--
1585-- if event == "mouse_click" then
1586-- if par2 >= 1 and par2 <= width and par3 >= 4 and par3 <= 6 then
1587-- clicked = true
1588-- anyButtonClicked = true
1589-- end
1590-- elseif event == "monitor_touch" then
1591-- if par1 >= 1 and par1 <= width and par2 >= 4 and par2 <= 6 then
1592-- clicked = true
1593-- anyButtonClicked = true
1594-- end
1595-- elseif event == "key_up" and intSelected == 2 then
1596-- if par1 == keys.enter then
1597-- clicked = true
1598-- anyButtonClicked = true
1599-- end
1600-- end
1601-- if clicked then
1602-- if par1 == keys.enter then
1603-- term.setCursorBlink(false)
1604-- local newPath = string.sub(path,0, - string.len( fs.getName( path ) ) - 1 ) .. text
1605-- if fs.exists(newPath) then
1606-- screen.infoPopup("File allreayd exists!",5)
1607-- text = fs.getName(path)
1608-- intEditPos = string.len( fs.getName(path) )
1609-- intOffset = 0
1610-- header()
1611-- else
1612-- fs.move(path, newPath)
1613-- term.setCursorBlink(false)
1614-- screen.clear(colors.black)
1615-- screen.setTextColor(colors.white)
1616-- break
1617-- end
1618-- else
1619-- intSelected = 2
1620-- end
1621-- end
1622--
1623-- term.setCursorPos(2, 8)
1624-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 3), {"Move"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
1625-- if clicked then
1626-- ret = assert(loadfile("lightOS/explorer/explorer"))("open_folder",string.sub(path,0, - string.len( fs.getName( path ) ) - 1 ))
1627-- if ret ~= nil then
1628-- if fs.exists(ret) then
1629-- screen.setBackgroundColor(colors.white)
1630-- screen.infoPopup("Unable to move the File.\nFile allready exists in\nthe selected Folder",5)
1631-- else
1632-- fs.move(path,ret .. fs.getName(path))
1633-- screen.infoPopup("Moved the File!",5)
1634-- screen.clear(colors.white)
1635-- screen.setTextColor(colors.black)
1636-- term.setCursorBlink(false)
1637-- break
1638-- end
1639-- end
1640-- header()
1641-- end
1642--
1643-- term.setCursorPos(10, 8)
1644-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 4), {"Copy"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
1645-- if clicked then
1646-- ret = assert(loadfile("lightOS/explorer/explorer"))("open_folder",string.sub(path,0, - string.len( fs.getName( path ) ) - 1 ),"openFolder")
1647-- if ret ~= nil then
1648-- ret = ret .. fs.getName(path)
1649-- if fs.exists(ret) then
1650-- ret = ret .. " copy"
1651-- if fs.exists(ret) then
1652-- i = 2
1653-- while fs.exists(ret .. "(" .. i .. ")") do
1654-- i = i + 1
1655-- end
1656-- ret = ret .. "(" .. i .. ")"
1657-- end
1658-- end
1659-- fs.copy(path,ret)
1660-- term.setCursorBlink(false)
1661-- screen.infoPopup("Copy created!",5)
1662-- screen.clear(colors.black)
1663-- screen.setTextColor(colors.white)
1664-- break
1665-- end
1666-- header()
1667-- end
1668--
1669-- term.setCursorPos(18, 8)
1670-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 5), {"Delete"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
1671-- if clicked then
1672-- fs.delete(path)
1673-- term.setCursorBlink(false)
1674-- screen.clear(colors.black)
1675-- screen.setTextColor(colors.white)
1676-- break
1677-- end
1678--
1679-- term.setCursorPos(2, 10)
1680-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 6), {"Exit"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
1681-- if clicked then
1682-- term.setCursorBlink(false)
1683-- screen.clear(colors.black)
1684-- screen.setTextColor(colors.white)
1685-- break
1686-- end
1687--
1688-- term.setCursorPos(10, 10)
1689-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 7), {"Edit"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
1690-- if clicked then
1691-- screen.clear(colors.black)
1692-- screen.setTextColor(colors.white)
1693-- os.run({},"lightOS/explorer/edit", path)
1694-- header()
1695-- end
1696--
1697-- if startUpPath == path then
1698-- term.setCursorPos(18, 10)
1699-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 8), {"Remove"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
1700-- if clicked then
1701-- startN.removeStartup()
1702-- startUpPath = startN.getStartupPath()
1703-- screen.setBackgroundColor(colors.white)
1704-- end
1705-- term.write(" ")
1706-- else
1707-- term.setCursorPos(18, 10)
1708-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 8), {"Startup"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
1709-- if clicked then
1710-- os.run({},"lightOS/startup/setAsStartup",path)
1711-- header()
1712-- startUpPath = startN.getStartupPath()
1713-- end
1714-- end
1715--
1716-- if intSelected == 2 then
1717-- term.setCursorBlink(true)
1718-- screen.setTextColor(colors.white)
1719-- screen.setBackgroundColor(colors.blue)
1720-- term.setCursorPos(1,4)
1721-- term.write("+[Rename]" .. string.rep("-" , width - 10) .. "+")
1722-- term.setCursorPos(1,5)
1723-- term.write(string.rep("|" , width))
1724-- term.setCursorPos(1,6)
1725-- term.write("+" .. string.rep("-" , width - 2) .. "+")
1726-- screen.setBackgroundColor(colors.white)
1727-- screen.setTextColor(colors.black)
1728-- term.setCursorPos(2,5)
1729-- term.write(string.rep(" ", width - 2))
1730-- term.setCursorPos(2,5)
1731-- text , intEditPos, intOffset = screen.inputField ( event, par1, text , intEditPos, intOffset, width - 2)
1732-- text = string.gsub( text, " ","_" )
1733-- else
1734-- term.setCursorBlink(false)
1735-- screen.setTextColor(colors.black)
1736-- screen.setBackgroundColor(colors.blue)
1737-- term.setCursorPos(1,4)
1738-- term.write("+-Rename" .. string.rep("-" , width - 9) .. "+")
1739-- term.setCursorPos(1,5)
1740-- term.write(string.rep("|" , width))
1741-- term.setCursorPos(1,6)
1742-- term.write("+" .. string.rep("-" , width - 2) .. "+")
1743-- screen.setBackgroundColor(colors.white)
1744--
1745-- term.setCursorPos(2,5)
1746-- term.write(stringN.cutRight(text,"..",width - 2))
1747-- end
1748--
1749-- if intSelected == 2 and ((text ~= fs.getName(path) and fs.exists(string.sub(path,0, - string.len( fs.getName( path ) ) - 1 ) .. text)) or string.len( string.gsub(text, " ", "") ) < 1) then
1750-- screen.setBackgroundColor(colors.red)
1751-- screen.setTextColor(colors.black)
1752-- term.setCursorPos(1,12)
1753-- term.write("+-Problem:" .. string.rep("-" , width - 11) .. "+")
1754-- term.setCursorPos(1,13)
1755-- term.write(string.rep("|" , width))
1756-- term.setCursorPos(1,14)
1757-- term.write(string.rep("|" , width))
1758-- term.setCursorPos(1,15)
1759-- term.write("+" .. string.rep("-" , width - 2) .. "+")
1760-- screen.setBackgroundColor(colors.white)
1761-- term.setCursorPos(2,13)
1762-- term.write(stringN.setCenter("File already exist", "",width - 2))
1763-- term.setCursorPos(2,14)
1764-- term.write(stringN.setCenter("enter another Name", "",width - 2))
1765-- else
1766-- term.setCursorPos(1,12)
1767-- term.write( string.rep(" ",width))
1768-- term.setCursorPos(1,13)
1769-- term.write( string.rep(" ",width))
1770-- term.setCursorPos(1,14)
1771-- term.write( string.rep(" ",width))
1772-- term.setCursorPos(1,15)
1773-- term.write( string.rep(" ",width))
1774-- end
1775--
1776-- term.setCursorPos(intEditPos - intOffset + 2, 5)
1777--
1778-- if anyButtonClicked then
1779-- anyButtonClicked = false
1780-- event = nil
1781-- par1 = nil
1782-- par2 = nil
1783-- par3 = nil
1784-- par4 = nil
1785-- par5 = nil
1786-- else
1787-- while true do
1788-- event, par1, par2, par3, par4, par5 = os.pullEvent()
1789-- if event == "mouse_click" or event == "mouse_up" or event == "mouse_scroll" or event == "monitor_touch" or event == "key" or event == "key_up" or event == "char" then
1790-- break
1791-- end
1792-- end
1793-- end
1794--end
1795--#install_file_path#:lightOS/explorer/editFolder
1796--path = ...
1797--if path == nil then
1798-- path = ""
1799--end
1800--local startUpPath = startN.getStartupPath()
1801--
1802--local text = fs.getName(path)
1803--local intEditPos = string.len( text )
1804--local intOffset = 0
1805--
1806--local intSelected = 6
1807--
1808--local width, intHight = term.getSize()
1809--
1810--local clicked = false
1811--local anyButtonClicked = false
1812--
1813--local event = nil
1814--local par1 = nil
1815--local par2 = nil
1816--local par3 = nil
1817--local par4 = nil
1818--local par5 = nil
1819--
1820--function header()
1821-- screen.clear(colors.white)
1822-- screen.setTextColor(colors.black)
1823-- screen.setBackgroundColor(colors.lime)
1824-- term.write ( stringN.setCenter ( fs.getName(path), ".." , width - 3 ) )
1825-- screen.setBackgroundColor(colors.white)
1826-- term.setCursorPos(1,2)
1827-- term.write("Path: ")
1828-- if string.len( path ) == 0 then
1829-- term.write("Root")
1830-- else
1831-- term.write(stringN.cutLeft(path, "..", width - 6))
1832-- end
1833-- screen.setBackgroundColor(colors.blue)
1834-- term.setCursorPos(1,4)
1835-- term.write("+" .. string.rep("-" , width - 2) .. "+")
1836-- term.setCursorPos(1,5)
1837-- term.write(string.rep("|" , width))
1838-- term.setCursorPos(1,6)
1839-- term.write("+" .. string.rep("-" , width - 2) .. "+")
1840-- screen.setBackgroundColor(colors.white)
1841--end
1842--
1843--header()
1844--
1845--while true do
1846-- if event == "key" then
1847-- if intSelected == 0 then
1848-- intSelected = 4
1849-- elseif intSelected == 1 then
1850-- if par1 == keys.tab then
1851-- intSelected = 6
1852-- elseif par1 == keys.down or par1 == keys.s then
1853-- intSelected = 2
1854-- end
1855-- elseif intSelected == 2 then
1856-- if par1 == keys.up or par1 == keys.tab then
1857-- intSelected = 1
1858-- elseif par1 == keys.down then
1859-- intSelected = 3
1860-- end
1861-- elseif intSelected == 3 then
1862-- if par1 == keys.up or par1 == keys.w or par1 == keys.tab then
1863-- intSelected = 2
1864-- elseif par1 == keys.down or par1 == keys.s then
1865-- intSelected = 6
1866-- elseif par1 == keys.right or par1 == keys.d then
1867-- intSelected = 4
1868-- end
1869-- elseif intSelected == 4 then
1870-- if par1 == keys.up or par1 == keys.w then
1871-- intSelected = 2
1872-- elseif par1 == keys.down or par1 == keys.s then
1873-- intSelected = 6
1874-- elseif par1 == keys.left or par1 == keys.a or par1 == keys.tab then
1875-- intSelected = 3
1876-- elseif par1 == keys.right or par1 == keys.d then
1877-- intSelected = 5
1878-- end
1879-- elseif intSelected == 5 then
1880-- if par1 == keys.up or par1 == keys.w then
1881-- intSelected = 2
1882-- elseif par1 == keys.left or par1 == keys.a or par1 == keys.tab then
1883-- intSelected = 4
1884-- elseif par1 == keys.down or par1 == keys.s then
1885-- intSelected = 6
1886-- end
1887-- elseif intSelected == 6 then
1888-- if par1 == keys.up or par1 == keys.w then
1889-- intSelected = 3
1890-- elseif par1 == keys.tab then
1891-- intSelected = 5
1892-- end
1893-- end
1894-- elseif event == "mouse_click" then
1895-- intSelected = 0
1896-- end
1897--
1898-- screen.setBackgroundColor(colors.white)
1899-- screen.setTextColor(colors.black)
1900--
1901-- screen.setBackgroundColor(colors.white)
1902-- screen.setTextColor(colors.black)
1903--
1904-- term.setCursorPos(width - 2, 1)
1905-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 1), {"X"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.red,colors.white,colors.red})
1906-- if clicked then
1907-- term.setCursorBlink(false)
1908-- screen.clear(colors.black)
1909-- screen.setTextColor(colors.white)
1910-- break
1911-- end
1912--
1913-- if event == "mouse_click" then
1914-- if par2 >= 1 and par2 <= width and par3 >= 4 and par3 <= 6 then
1915-- clicked = true
1916-- anyButtonClicked = true
1917-- end
1918-- elseif event == "monitor_touch" then
1919-- if par1 >= 1 and par1 <= width and par2 >= 4 and par2 <= 6 then
1920-- clicked = true
1921-- anyButtonClicked = true
1922-- end
1923-- elseif event == "key_up" and intSelected == 2 then
1924-- if par1 == keys.enter then
1925-- clicked = true
1926-- anyButtonClicked = true
1927-- end
1928-- end
1929-- if clicked then
1930-- if par1 == keys.enter then
1931-- term.setCursorBlink(false)
1932-- local newPath = string.sub(path,0, - string.len( fs.getName( path ) ) - 2 ) .. text .. "/"
1933-- if fs.exists(newPath) then
1934-- screen.infoPopup("Folder allreayd exists!",5)
1935-- text = fs.getName(path)
1936-- intEditPos = string.len( fs.getName(path) )
1937-- intOffset = 0
1938-- header()
1939-- else
1940-- fs.move(path, newPath)
1941-- term.setCursorBlink(false)
1942-- screen.clear(colors.black)
1943-- screen.setTextColor(colors.white)
1944-- break
1945-- end
1946-- else
1947-- intSelected = 2
1948-- end
1949-- end
1950--
1951-- term.setCursorPos(2, 8)
1952-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 3), {"Move"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
1953-- if clicked then
1954-- ret = assert(loadfile("lightOS/explorer/explorer"))("open_folder",string.sub(path,0, - string.len( fs.getName( path ) ) - 2 ))
1955-- ret = ret .. fs.getName( path ) .. "/"
1956-- if ret ~= nil then
1957-- if fs.exists(ret) then
1958-- screen.setBackgroundColor(colors.white)
1959-- screen.infoPopup("Unable to move the Folder.\nFolder allready exists in\nthe selected Folder",5)
1960-- else
1961-- fs.move(path,ret .. fs.getName(path) .. "/")
1962-- screen.infoPopup("Moved the Folder!",5)
1963-- term.setCursorBlink(false)
1964-- screen.clear(colors.white)
1965-- screen.setTextColor(colors.black)
1966-- break
1967-- end
1968-- end
1969-- header()
1970-- end
1971--
1972-- term.setCursorPos(10, 8)
1973-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 4), {"Copy"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
1974-- if clicked then
1975-- ret = assert(loadfile("lightOS/explorer/explorer"))("open_folder",string.sub(path,0, - string.len( fs.getName( path ) ) - 2 ))
1976-- if ret ~= nil then
1977-- ret = ret .. fs.getName(path) .. "/"
1978-- if fs.exists(ret) then
1979-- ret = string.sub(ret,0,string.len(ret) - 1) .. " copy"
1980-- if fs.exists(ret .. "/") then
1981-- i = 2
1982-- while fs.exists(ret .. "(" .. i .. ")/") do
1983-- i = i + 1
1984-- end
1985-- ret = ret .. "(" .. i .. ")/"
1986-- end
1987-- end
1988-- fs.copy(path,ret)
1989-- screen.infoPopup("Copy created!",5)
1990-- term.setCursorBlink(false)
1991-- screen.clear(colors.black)
1992-- screen.setTextColor(colors.white)
1993-- break
1994-- end
1995-- header()
1996-- end
1997--
1998-- term.setCursorPos(18, 8)
1999-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 5), {"Delete"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
2000-- if clicked then
2001-- fs.delete(path)
2002-- term.setCursorBlink(false)
2003-- screen.clear(colors.black)
2004-- screen.setTextColor(colors.white)
2005-- break
2006-- end
2007--
2008-- term.setCursorPos(2, 10)
2009-- clicked , anyButtonClicked = button.create(anyButtonClicked , event, par1,par2,par3,0,(intSelected == 6), {"Exit"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.gray,colors.orange,colors.gray})
2010-- if clicked then
2011-- term.setCursorBlink(false)
2012-- screen.clear(colors.black)
2013-- screen.setTextColor(colors.white)
2014-- break
2015-- end
2016--
2017-- if intSelected == 2 then
2018-- term.setCursorBlink(true)
2019-- screen.setTextColor(colors.white)
2020-- screen.setBackgroundColor(colors.blue)
2021-- term.setCursorPos(1,4)
2022-- term.write("+[Rename]" .. string.rep("-" , width - 10) .. "+")
2023-- term.setCursorPos(1,5)
2024-- term.write(string.rep("|" , width))
2025-- term.setCursorPos(1,6)
2026-- term.write("+" .. string.rep("-" , width - 2) .. "+")
2027-- screen.setBackgroundColor(colors.white)
2028-- screen.setTextColor(colors.black)
2029-- term.setCursorPos(2,5)
2030-- term.write(string.rep(" ", width - 2))
2031-- term.setCursorPos(2,5)
2032-- text , intEditPos, intOffset = screen.inputField ( event, par1, text , intEditPos, intOffset, width - 2)
2033-- text = string.gsub( text, " ","_" )
2034-- else
2035-- term.setCursorBlink(false)
2036-- screen.setTextColor(colors.black)
2037-- screen.setBackgroundColor(colors.blue)
2038-- term.setCursorPos(1,4)
2039-- term.write("+-Rename" .. string.rep("-" , width - 9) .. "+")
2040-- term.setCursorPos(1,5)
2041-- term.write(string.rep("|" , width))
2042-- term.setCursorPos(1,6)
2043-- term.write("+" .. string.rep("-" , width - 2) .. "+")
2044-- screen.setBackgroundColor(colors.white)
2045--
2046-- term.setCursorPos(2,5)
2047-- term.write(stringN.cutRight(text,"..",width - 2))
2048-- end
2049--
2050-- if intSelected == 2 and ((text ~= fs.getName(path) and fs.exists(string.sub(path,0, - string.len( fs.getName( path ) ) - 1 ) .. text)) or string.len( string.gsub(text, " ", "") ) < 1) then
2051-- screen.setBackgroundColor(colors.red)
2052-- screen.setTextColor(colors.black)
2053-- term.setCursorPos(1,12)
2054-- term.write("+-Problem:" .. string.rep("-" , width - 11) .. "+")
2055-- term.setCursorPos(1,13)
2056-- term.write(string.rep("|" , width))
2057-- term.setCursorPos(1,14)
2058-- term.write(string.rep("|" , width))
2059-- term.setCursorPos(1,15)
2060-- term.write("+" .. string.rep("-" , width - 2) .. "+")
2061-- screen.setBackgroundColor(colors.white)
2062-- term.setCursorPos(2,13)
2063-- term.write(stringN.setCenter("Folder already exist", "",width - 2))
2064-- term.setCursorPos(2,14)
2065-- term.write(stringN.setCenter("enter another Name", "",width - 2))
2066-- else
2067-- term.setCursorPos(1,12)
2068-- term.write( string.rep(" ",width))
2069-- term.setCursorPos(1,13)
2070-- term.write( string.rep(" ",width))
2071-- term.setCursorPos(1,14)
2072-- term.write( string.rep(" ",width))
2073-- term.setCursorPos(1,15)
2074-- term.write( string.rep(" ",width))
2075-- end
2076--
2077-- term.setCursorPos(intEditPos - intOffset + 2, 5)
2078--
2079-- if anyButtonClicked then
2080-- anyButtonClicked = false
2081-- event = nil
2082-- par1 = nil
2083-- par2 = nil
2084-- par3 = nil
2085-- par4 = nil
2086-- par5 = nil
2087-- else
2088-- while true do
2089-- event, par1, par2, par3, par4, par5 = os.pullEvent()
2090-- if event == "mouse_click" or event == "mouse_up" or event == "mouse_scroll" or event == "monitor_touch" or event == "key" or event == "key_up" or event == "char" then
2091-- break
2092-- end
2093-- end
2094-- end
2095--end
2096--#install_file_path#:lightOS/explorer/explorer
2097---- Explorer by FileStriker
2098--local mode, path, type = ...
2099--local projectPath = "lightOS/explorer"
2100--
2101--if path == nil then
2102-- path = ""
2103--end
2104--
2105--local hiddenPaths = fileN.readLines("lightOS/explorer/hiddenPaths")
2106--local itemPaths = {}
2107--local files = {}
2108--local filesData = {}
2109--local directorys = {}
2110--local itemCount = 0
2111--
2112--local buttonGroups = {}
2113--local headerButtons = 2
2114--local tabFileTypes = {}
2115--
2116--local boolCreate
2117--local boolReturnFolder
2118--local boolReturnFile
2119--local boolSeeFiles
2120--local boolSeeAll
2121--
2122--local intOptionButtonCount = 0
2123--
2124--local event
2125--local par1
2126--local par2
2127--local par3
2128--local par4
2129--local par5
2130--
2131--local boolClick = false
2132--local boolButton = false
2133--
2134--local width, height = term.getSize()
2135--
2136--local function getFileTypes()
2137-- tabTypeFiles = {}
2138-- tabTypeFiles = fs.list(projectPath .. "/Open/")
2139-- tabFileTypes.tabEnding = {}
2140-- tabFileTypes.tabChar = {}
2141-- tabFileTypes.tabCharColor = {}
2142-- tabFileTypes.tabBackgroundColor = {}
2143--
2144-- for i=1,#tabTypeFiles do
2145-- t1 = stringN.split(tabTypeFiles[i],".")
2146-- if #t1 > 1 then
2147-- table.insert(tabFileTypes.tabEnding, t1[#t1])
2148-- file = fs.open( projectPath .. "/Open/" .. tabTypeFiles[i], "r" )
2149-- line = file.readLine()
2150-- while line ~= nil do
2151-- if string.find( line, "--Info") ~= nil then
2152-- t2 = {}
2153-- t2 = stringN.split(line,";")
2154-- table.insert(tabFileTypes.tabChar, t2[2])
2155-- table.insert(tabFileTypes.tabCharColor, tonumber(t2[3]))
2156-- table.insert(tabFileTypes.tabBackgroundColor, tonumber(t2[4]))
2157-- end
2158-- line = file.readLine()
2159-- end
2160-- file.close()
2161-- end
2162-- end
2163--end
2164--
2165--local function GetFileData(strFile)
2166-- intFileLenght = string.len( strFile )
2167-- for i=1,#tabFileTypes.tabEnding do
2168-- intLenght = string.len(tabFileTypes.tabEnding[i]) + 1
2169-- if intFileLenght > intLenght then
2170-- if "."..tabFileTypes.tabEnding[i] == string.sub( strFile, - intLenght ) then
2171-- return tabFileTypes.tabEnding[i], tabFileTypes.tabChar[i], tabFileTypes.tabCharColor[i], tabFileTypes.tabBackgroundColor[i]
2172-- end
2173-- end
2174-- end
2175-- return nil
2176--end
2177--
2178--local function initialize(strStartPath)
2179-- local intLastSelection = 0
2180-- local intLastCurrent = 1
2181-- if buttonGroups.current ~= nil then
2182-- intLastSelection = buttonGroups.current
2183-- intLastCurrent = buttonGroups.selected[intLastSelection]
2184-- end
2185--
2186-- itemCount = 0
2187-- path = strStartPath
2188-- itemPaths = fs.list(path)
2189-- tabFiles = {}
2190-- tabDirs = {}
2191--
2192-- tabFilesData = {}
2193-- tabFilesData.tabType = {}
2194-- tabFilesData.tabChar = {}
2195-- tabFilesData.tabCharColor = {}
2196-- tabFilesData.tabBackgroundColor = {}
2197-- -- fill File/Folder Table
2198-- for i = 1, #itemPaths do
2199-- if fileN.contains(path .. itemPaths[i], hiddenPaths) == false then
2200-- if fs.isDir(path .. itemPaths[i]) == true then
2201-- table.insert( tabDirs, itemPaths[i] )
2202-- itemCount = itemCount + 1
2203-- elseif boolSeeFiles then
2204-- if type == nil or stringN.endsWith(itemPaths[i],"."..type) then
2205-- table.insert( tabFiles, itemPaths[i] )
2206-- par1, par2, par3, par4 = GetFileData(itemPaths[i])
2207-- if par1 == nil then
2208-- table.insert(tabFilesData.tabType, "" )
2209-- table.insert( tabFilesData.tabChar, "~" )
2210-- table.insert( tabFilesData.tabCharColor, colors.black )
2211-- table.insert(tabFilesData.tabBackgroundColor, colors.lightGray)
2212-- else
2213-- table.insert(tabFilesData.tabType, par1 )
2214-- table.insert( tabFilesData.tabChar, par2 )
2215-- table.insert( tabFilesData.tabCharColor, par3 )
2216-- table.insert(tabFilesData.tabBackgroundColor, par4)
2217-- end
2218-- itemCount = itemCount + 1
2219-- end
2220-- end
2221-- end
2222-- end
2223--
2224-- buttonGroups = {}
2225-- buttonGroups = button.createGroupTable(buttonGroups)
2226-- buttonGroups = button.addGroup(itemCount,1,buttonGroups)
2227-- buttonGroups = button.addGroup(4,1,buttonGroups)
2228-- buttonGroups.current = intLastSelection
2229-- buttonGroups.selected[intLastSelection] = intLastCurrent
2230-- buttonGroups.selected[1] = 1
2231-- if term.isColor() == false and buttonGroups.current == 0 then
2232-- buttonGroups.current = 1
2233-- end
2234--end
2235--
2236--local function GoBack()
2237-- tabSplitPath={}
2238-- for pathPart in string.gmatch(path, "([^/]+)") do
2239-- table.insert(tabSplitPath,pathPart)
2240-- end
2241-- strNewPath = ""
2242-- if (#tabSplitPath > 1) then
2243-- for i = 1, #tabSplitPath - 1 do
2244-- strNewPath = strNewPath .. tabSplitPath[i] .. "/"
2245-- end
2246-- end
2247-- initialize(strNewPath)
2248--end
2249--
2250--if mode == "browse_files" then
2251-- boolOptions = true
2252-- boolCreate = true
2253-- boolReturnFolder = false
2254-- boolReturnFile = false
2255-- boolSeeFiles = true
2256-- boolSeeAll = false
2257-- headerButtons = 2
2258--elseif mode == "open_file" then
2259-- boolOptions = false
2260-- boolCreate = false
2261-- boolReturnFolder = false
2262-- boolReturnFile = true
2263-- boolSeeFiles = true
2264-- boolSeeAll = false
2265-- headerButtons = 0
2266--elseif mode == "open_folder" then
2267-- boolOptions = false
2268-- boolCreate = false
2269-- boolReturnFolder = true
2270-- boolReturnFile = false
2271-- boolSeeFiles = false
2272-- boolSeeAll = false
2273-- headerButtons = 1
2274--elseif mode == "save_file" then
2275-- boolOptions = false
2276-- boolCreate = true
2277-- boolReturnFolder = false
2278-- boolReturnFile = true
2279-- boolSeeFiles = true
2280-- boolSeeAll = false
2281-- headerButtons = 2
2282--elseif mode == "save_folder" then
2283-- boolOptions = false
2284-- boolCreate = true
2285-- boolReturnFolder = true
2286-- boolReturnFile = false
2287-- boolSeeFiles = false
2288-- boolSeeAll = false
2289-- headerButtons = 2
2290--elseif mode == "super" then
2291-- boolOptions = false
2292-- boolCreate = true
2293-- boolReturnFolder = false
2294-- boolReturnFile = false
2295-- boolSeeFiles = true
2296-- boolSeeAll = true
2297-- headerButtons = 2
2298--else
2299-- screen.clear(colors.black)
2300-- screen.setTextColor(colors.red)
2301-- print("Error Mode is missing")
2302-- screen.setTextColor(colors.white)
2303-- return nil
2304--end
2305--
2306--getFileTypes()
2307--initialize(path)
2308--
2309--function header()
2310-- screen.clear(colors.white)
2311-- screen.setTextColor(colors.black)
2312-- screen.clearLine(colors.lime)
2313-- term.setCursorPos(5,1)
2314--
2315-- if string.len ( path ) > 1 then
2316-- term.write(stringN.setCenter ( fs.getName ( path ) , ".." , width - 7 ))
2317-- else
2318-- term.write(stringN.setCenter ( "Root" , ".." , width - 7 ))
2319-- end
2320-- term.setCursorPos(1,height)
2321-- screen.setBackgroundColor(colors.white)
2322-- screen.setTextColor(colors.black)
2323-- term.write("-+-" .. string.rep("-", width - 3 - string.len("mode: " .. mode)) )
2324-- term.write("MODE: " .. string.upper( mode))
2325--end
2326--header()
2327--
2328--while true do
2329-- if event == "key" then
2330-- if par1 == keys.backspace then
2331-- GoBack()
2332-- end
2333-- if buttonGroups.current == 1 then
2334-- if par1 == keys.up or par1 == keys.w then
2335-- buttonGroups.selected[1] = math.max(1, buttonGroups.selected[1] - 1)
2336-- end
2337-- if par1 == keys.down or par1 == keys.s then
2338-- buttonGroups.selected[1] = math.min(itemCount, buttonGroups.selected[1] + 1)
2339-- end
2340-- if par1 == keys.tab then
2341-- buttonGroups.current = 2
2342-- end
2343-- elseif buttonGroups.current == 2 then
2344-- if buttonGroups.selected[2] == 1 then
2345-- if par1 == keys.right or par1 ==keys.d then
2346-- buttonGroups.selected[2] = 2
2347-- end
2348-- if par1 == keys.down or par1 == keys.s then
2349-- buttonGroups.selected[2] = 3
2350-- end
2351-- end
2352-- if buttonGroups.selected[2] == 2 then
2353-- if par1 == keys.left or par1 ==keys.a then
2354-- buttonGroups.selected[2] = 1
2355-- end
2356-- if par1 == keys.down or par1 == keys.s then
2357-- buttonGroups.selected[2] = math.min(4,headerButtons + 2)
2358-- end
2359-- end
2360--
2361-- if buttonGroups.selected[2] == 3 then
2362-- if (par1 == keys.right or par1 ==keys.d) and headerButtons == 2 then
2363-- buttonGroups.selected[2] = 4
2364-- end
2365-- if par1 == keys.up or par1 == keys.w then
2366-- buttonGroups.selected[2] = 1
2367-- end
2368-- end
2369-- if buttonGroups.selected[2] == 4 then
2370-- if par1 == keys.left or par1 ==keys.a then
2371-- buttonGroups.selected[2] = 3
2372-- end
2373-- if boolCreate then
2374-- if par1 == keys.up or par1 == keys.w then
2375-- buttonGroups.selected[2] = 2
2376-- end
2377-- end
2378-- end
2379--
2380-- if par1 == keys.tab then
2381-- buttonGroups.current = 1
2382-- end
2383-- end
2384-- elseif event == "key_up" then
2385-- if buttonGroups.current == 0 then
2386-- buttonGroups.current = 1
2387-- end
2388-- elseif event == "mouse_scroll" then
2389-- if buttonGroups.current ~= 1 then
2390-- buttonGroups.current = 1
2391-- else
2392-- if par1 == -1 then
2393-- buttonGroups.selected[1] = math.max(1, buttonGroups.selected[1] - 1)
2394-- end
2395-- if par1 == 1 then
2396-- buttonGroups.selected[1] = math.min(itemCount, buttonGroups.selected[1] + 1)
2397-- end
2398-- end
2399-- end
2400--
2401-- local clickKeys = {keys.enter,keys.space, keys.leftCtrl}
2402-- if boolOptions == false then
2403-- clickKeys = {keys.enter,keys.space}
2404-- end
2405--
2406-- local intStart, intEnd = list.list(height - 3, itemCount, buttonGroups.selected[1])
2407-- local line = 3
2408-- for i = intStart, math.min(itemCount, intEnd) do
2409-- term.setCursorPos(1,line)
2410-- if i <= #tabDirs then
2411-- screen.setBackgroundColor(colors.yellow)
2412-- term.write("#")
2413-- else
2414-- screen.setTextColor(tabFilesData.tabCharColor[ i - #tabDirs])
2415-- screen.setBackgroundColor(tabFilesData.tabBackgroundColor[ i - #tabDirs])
2416-- term.write(tabFilesData.tabChar[ i - #tabDirs])
2417-- end
2418--
2419-- screen.setBackgroundColor(colors.white)
2420-- screen.setTextColor(colors.black)
2421-- term.write("|")
2422--
2423-- if i <= #tabDirs then
2424-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,width - 4, button.isSelected(1, i, buttonGroups), {tabDirs[i]," ","",">","",".."},clickKeys,{})
2425-- if boolClick then
2426-- if ((event == "mouse_up" and par1 == 2 and boolOptions) or (event == "key_up" and par1 == keys.leftCtrl)) then
2427-- os.run({},projectPath .. "/editFolder", path .. tabDirs[i] .. "/")
2428-- initialize(path)
2429-- else
2430-- initialize(path .. tabDirs[i] .. "/")
2431-- end
2432-- header()
2433-- break
2434-- end
2435-- else
2436-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,width - 4, button.isSelected(1, i, buttonGroups), {tabFiles[ i - #tabDirs ]," ","",">","",".."},clickKeys,{})
2437-- if boolClick then
2438-- if ((event == "mouse_up" and par1 == 2 and boolOptions) or (event == "key_up" and par1 == keys.leftCtrl)) then
2439-- os.run({},projectPath .. "/editFile", path .. tabFiles[i - #tabDirs])
2440-- else
2441-- if boolReturnFile then
2442-- return path .. tabFiles[i - #tabDirs]
2443-- else
2444-- if tabFilesData.tabType[i - #tabDirs] == "" then
2445-- os.run({},projectPath .. "/openUnknownFile", path .. tabFiles[i - #tabDirs])
2446-- else
2447-- shell.run(projectPath .. "/Open/open." .. tabFilesData.tabType[i - #tabDirs], path .. tabFiles[i - #tabDirs] )
2448-- end
2449-- end
2450-- end
2451-- initialize(path)
2452-- header()
2453-- break
2454-- end
2455-- end
2456-- term.write("|")
2457-- line = line +1
2458-- end
2459--
2460-- --Close
2461-- term.setCursorPos(width - 2, 1)
2462-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,button.isSelected(2, 2, buttonGroups), {"X"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.red,colors.white,colors.red})
2463-- if boolClick then
2464-- screen.clear(colors.black)
2465-- screen.setTextColor(colors.white)
2466-- return nil
2467-- end
2468--
2469-- --Back
2470-- term.setCursorPos(1, 1)
2471-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,button.isSelected(2, 1, buttonGroups), {"<-"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.green,colors.white,colors.green})
2472-- if boolClick then
2473-- GoBack()
2474-- header()
2475-- end
2476--
2477-- --Up
2478-- term.setCursorPos(width, 3)
2479-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,false, {"-"}, {keys.enter,keys.space} , {colors.black,colors.lightBlue})
2480-- if boolClick then
2481-- if buttonGroups.current ~= 1 then
2482-- buttonGroups.current = 1
2483-- end
2484-- buttonGroups.selected[1] = math.max(1, buttonGroups.selected[1] - 1)
2485-- end
2486--
2487-- --Down
2488-- term.setCursorPos(width, height -1)
2489-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,false, {"+"}, {keys.enter,keys.space} , {colors.black,colors.lightBlue})
2490-- if boolClick then
2491-- if buttonGroups.current ~= 1 then
2492-- buttonGroups.current = 1
2493-- end
2494-- buttonGroups.selected[1] = math.min(itemCount, buttonGroups.selected[1] + 1)
2495-- end
2496--
2497-- term.setCursorPos(1, 2)
2498-- screen.clearLine(colors.blue)
2499-- --New Folder
2500-- if boolCreate then
2501-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,button.isSelected(2, 3, buttonGroups), {"New Folder"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.blue,colors.white,colors.blue})
2502-- if boolClick then
2503-- os.run({},projectPath .. "/newFolder", path)
2504-- initialize(path)
2505-- header()
2506-- end
2507-- term.write(" ")
2508-- end
2509-- -- Open Folder
2510-- if boolReturnFolder then
2511-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,button.isSelected(2, 3, buttonGroups), {"Open Folder"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.blue,colors.white,colors.blue})
2512-- if boolClick then
2513-- return path
2514-- end
2515-- term.write(" ")
2516-- end
2517-- --New File
2518-- if boolCreate and boolSeeFiles then
2519-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,button.isSelected(2, 4, buttonGroups), {"New File"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.blue,colors.white,colors.blue})
2520-- if boolClick then
2521-- local ret
2522-- if type ~= nil then
2523-- ret = assert(loadfile(projectPath .. "/newFile"))(path, type)
2524-- else
2525-- ret = assert(loadfile(projectPath .. "/newFile"))(path)
2526-- end
2527-- if boolReturnFile then
2528-- return ret
2529-- end
2530-- initialize(path)
2531-- header()
2532-- end
2533-- term.write(" ")
2534-- end
2535--
2536-- screen.setBackgroundColor(colors.white)
2537-- for i=3,height - 1 do
2538-- term.setCursorPos(2,i)
2539-- term.write("|")
2540-- term.setCursorPos(width - 1,i)
2541-- term.write("|")
2542-- end
2543-- term.setCursorPos(width, 4)
2544-- list.scrollbar(height - 5 , height - 3 ,itemCount, buttonGroups.selected[1])
2545--
2546--
2547--
2548-- if boolButton then
2549-- boolButton = false
2550-- event = nil
2551-- par1 = nil
2552-- par2 = nil
2553-- par3 = nil
2554-- par4 = nil
2555-- par5 = nil
2556-- else
2557-- while true do
2558-- event, par1, par2, par3, par4, par5 = os.pullEvent()
2559-- if event == "mouse_click" or event == "mouse_up" or event == "mouse_scroll" or event == "monitor_touch" or event == "key" or event == "key_up" then
2560-- break
2561-- end
2562-- end
2563-- end
2564--
2565-- if event == "mouse_up" then
2566-- buttonGroups.current = 0
2567-- end
2568--end
2569--#install_file_path#:lightOS/explorer/hiddenPaths
2570----lightOS
2571----startup
2572--#install_file_path#:lightOS/explorer/newFile
2573--local path , ending = ...
2574--
2575--if path == nil then
2576-- path = ""
2577--end
2578--
2579--if ending == nil then
2580-- ending = ""
2581--else
2582-- ending = "." .. ending
2583--end
2584--
2585--local text = ""
2586--local intEditPos = 0
2587--local intOffset = 0
2588--
2589--local intSelected = 2
2590--
2591--local intWidth, intHight = term.getSize()
2592--
2593--local boolClick = false
2594--local boolButton = false
2595--
2596--local event = nil
2597--local par1 = nil
2598--local par2 = nil
2599--local par3 = nil
2600--local par4 = nil
2601--local par5 = nil
2602--
2603--term.setCursorBlink(true)
2604--
2605--screen.clear(colors.white)
2606--screen.setTextColor(colors.black)
2607--screen.setBackgroundColor(colors.lime)
2608--term.write ( stringN.cutRight ( "Create New File" , ".." , intWidth - 3 ) )
2609--screen.setBackgroundColor(colors.white)
2610--term.setCursorPos(1,2)
2611--term.write("Path: ")
2612--if string.len( path ) == 0 then
2613-- term.write("Root")
2614--else
2615-- term.write(stringN.cutLeft(path, "..", intWidth - 6))
2616--end
2617--term.setCursorPos(1,4)
2618--term.write("+-Name" .. string.rep("-" , intWidth - 7) .. "+")
2619--term.setCursorPos(1,5)
2620--term.write(string.rep("|" , intWidth))
2621--term.setCursorPos(1,6)
2622--term.write("+" .. string.rep("-" , intWidth - 2) .. "+")
2623--
2624--
2625--
2626--while true do
2627--
2628-- if event == "key" then
2629-- if par1 == keys.up then
2630-- if intSelected == 1 then
2631-- intSelected = 2
2632-- elseif intSelected ==2 then
2633-- intSelected = 3
2634-- else
2635-- intSelected = 1
2636-- end
2637-- end
2638-- if par1 == keys.down or par1 == keys.tab then
2639-- if intSelected == 1 then
2640-- intSelected = 3
2641-- elseif intSelected ==2 then
2642-- intSelected = 1
2643-- else
2644-- intSelected = 2
2645-- end
2646-- end
2647--
2648-- if intSelected == 0 then
2649-- intSelected = 2
2650-- end
2651-- elseif event == "mouse_click" then
2652-- intSelected = 0
2653-- end
2654--
2655-- screen.setBackgroundColor(colors.white)
2656-- screen.setTextColor(colors.black)
2657-- term.setCursorPos(2,5)
2658-- term.write(string.rep(" ", intWidth - 2))
2659-- term.setCursorPos(2,5)
2660-- text , intEditPos, intOffset = screen.inputField ( event, par1, text , intEditPos, intOffset, intWidth - 2)
2661--
2662-- screen.setBackgroundColor(colors.white)
2663-- screen.setTextColor(colors.black)
2664--
2665-- term.setCursorPos(intWidth - 2, 1)
2666-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 3), {"X"," ", " ", "[","]"}, {keys.enter} , {colors.black,colors.red,colors.white,colors.red})
2667-- if boolClick then
2668-- term.setCursorBlink(false)
2669-- screen.clear(colors.black)
2670-- screen.setTextColor(colors.white)
2671-- return nil
2672-- end
2673--
2674-- term.setCursorPos(2, 8)
2675-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 2), {"Save"," ", " ", "[","]"}, {keys.enter} , {colors.black,colors.gray,colors.orange,colors.gray})
2676-- if boolClick then
2677-- if string.len( text ) == 0 then
2678-- screen.clear(colors.black)
2679-- screen.setTextColor(colors.white)
2680-- return nil
2681-- end
2682-- if fs.exists(path .. text .. ending) then
2683-- text = ""
2684-- intEditPos = 0
2685-- intOffset = 0
2686-- else
2687-- term.setCursorBlink(false)
2688-- print(path..text)
2689-- local file = fs.open(path..text .. ending, "w")
2690-- file.close()
2691-- screen.clear(colors.black)
2692-- screen.setTextColor(colors.white)
2693-- return path .. text .. ending
2694-- end
2695-- end
2696--
2697-- term.setCursorPos(2, 10)
2698-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 1), {"Exit"," ", " ", "[","]"}, {keys.enter} , {colors.black,colors.gray,colors.orange,colors.gray})
2699-- if boolClick then
2700-- term.setCursorBlink(false)
2701-- screen.clear(colors.black)
2702-- screen.setTextColor(colors.white)
2703-- return nil
2704-- end
2705--
2706-- if fs.exists(path .. text .. ending) and string.len( string.gsub(text, " ", "") ) > 0 then
2707-- screen.setBackgroundColor(colors.red)
2708-- screen.setTextColor(colors.black)
2709-- term.setCursorPos(1,12)
2710-- term.write("+-Problem:" .. string.rep("-" , intWidth - 11) .. "+")
2711-- term.setCursorPos(1,13)
2712-- term.write(string.rep("|" , intWidth))
2713-- term.setCursorPos(1,14)
2714-- term.write(string.rep("|" , intWidth))
2715-- term.setCursorPos(1,15)
2716-- term.write("+" .. string.rep("-" , intWidth - 2) .. "+")
2717-- screen.setBackgroundColor(colors.white)
2718-- term.setCursorPos(2,13)
2719-- term.write(stringN.cutRight("File already exist", "",intWidth - 2))
2720-- term.setCursorPos(2,14)
2721-- term.write(stringN.cutRight("enter another Name", "",intWidth - 2))
2722-- else
2723-- term.setCursorPos(1,12)
2724-- term.write( string.rep(" ",intWidth))
2725-- term.setCursorPos(1,13)
2726-- term.write( string.rep(" ",intWidth))
2727-- term.setCursorPos(1,14)
2728-- term.write( string.rep(" ",intWidth))
2729-- term.setCursorPos(1,15)
2730-- term.write( string.rep(" ",intWidth))
2731-- end
2732--
2733-- term.setCursorPos(intEditPos - intOffset + 2, 5)
2734--
2735-- if boolButton then
2736-- boolButton = false
2737-- event = nil
2738-- par1 = nil
2739-- par2 = nil
2740-- par3 = nil
2741-- par4 = nil
2742-- par5 = nil
2743-- else
2744-- while true do
2745-- event, par1, par2, par3, par4, par5 = os.pullEvent()
2746-- if event == "mouse_click" or event == "mouse_up" or event == "mouse_scroll" or event == "monitor_touch" or event == "key" or event == "key_up" or event == "char" then
2747-- break
2748-- end
2749-- end
2750-- end
2751--end
2752--#install_file_path#:lightOS/explorer/newFolder
2753--local strPath = ...
2754--
2755--if strPath == nil then
2756-- strPath = ""
2757--else
2758-- local p, a = string.gsub(strPath,"#SPACE#"," ")
2759-- strPath = p
2760--end
2761--
2762--local strText = ""
2763--local intEditPos = 0
2764--local intOffset = 0
2765--
2766--local intSelected = 2
2767--
2768--local intWidth, intHight = term.getSize()
2769--
2770--local boolClick = false
2771--local boolButton = false
2772--
2773--local event = nil
2774--local par1 = nil
2775--local par2 = nil
2776--local par3 = nil
2777--local par4 = nil
2778--local par5 = nil
2779--term.setCursorBlink(true)
2780--screen.clear(colors.white)
2781--screen.setTextColor(colors.black)
2782--screen.setBackgroundColor(colors.lime)
2783--term.write ( stringN.setCenter ( "Create New Folder" , ".." , intWidth - 3 ) )
2784--screen.setBackgroundColor(colors.white)
2785--term.setCursorPos(1,2)
2786--term.write("Path: ")
2787--if string.len( strPath ) == 0 then
2788-- term.write("Root")
2789--else
2790-- term.write(stringN.cutLeft(strPath, "..", intWidth - 6))
2791--end
2792--term.setCursorPos(1,4)
2793--term.write("+-Name" .. string.rep("-" , intWidth - 7) .. "+")
2794--term.setCursorPos(1,5)
2795--term.write(string.rep("|" , intWidth))
2796--term.setCursorPos(1,6)
2797--term.write("+" .. string.rep("-" , intWidth - 2) .. "+")
2798--
2799--
2800--
2801--while true do
2802--
2803-- if event == "key" then
2804-- if par1 == keys.up then
2805-- if intSelected == 1 then
2806-- intSelected = 2
2807-- elseif intSelected ==2 then
2808-- intSelected = 3
2809-- else
2810-- intSelected = 1
2811-- end
2812-- end
2813-- if par1 == keys.down or par1 == keys.tab then
2814-- if intSelected == 1 then
2815-- intSelected = 3
2816-- elseif intSelected ==2 then
2817-- intSelected = 1
2818-- else
2819-- intSelected = 2
2820-- end
2821-- end
2822--
2823-- if intSelected == 0 then
2824-- intSelected = 2
2825-- end
2826-- elseif event == "mouse_click" then
2827-- intSelected = 0
2828-- end
2829--
2830-- screen.setBackgroundColor(colors.white)
2831-- screen.setTextColor(colors.black)
2832-- term.setCursorPos(2,5)
2833-- term.write(string.rep(" ", intWidth - 2))
2834-- term.setCursorPos(2,5)
2835-- strText , intEditPos, intOffset = screen.inputField ( event, par1, strText , intEditPos, intOffset, intWidth - 2)
2836--
2837-- screen.setBackgroundColor(colors.white)
2838-- screen.setTextColor(colors.black)
2839--
2840-- term.setCursorPos(intWidth - 2, 1)
2841-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 3), {"X"," ", " ", "[","]"}, {keys.enter} , {colors.black,colors.red,colors.white,colors.red})
2842-- if boolClick then
2843-- term.setCursorBlink(false)
2844-- screen.clear(colors.black)
2845-- screen.setTextColor(colors.white)
2846-- break
2847-- end
2848--
2849-- term.setCursorPos(2, 8)
2850-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 2), {"Save"," ", " ", "[","]"}, {keys.enter} , {colors.black,colors.gray,colors.orange,colors.gray})
2851-- if boolClick then
2852-- if string.len( strText ) == 0 then
2853-- term.setCursorBlink(false)
2854-- screen.clear(colors.black)
2855-- screen.setTextColor(colors.white)
2856-- break
2857-- end
2858-- if fs.exists(strPath .. strText .. "/") then
2859-- strText = ""
2860-- intEditPos = 0
2861-- intOffset = 0
2862-- else
2863-- term.setCursorBlink(false)
2864-- fs.makeDir(strPath .. strText .. "/")
2865-- screen.setTextColor(colors.white)
2866-- break
2867-- end
2868-- end
2869--
2870-- term.setCursorPos(2, 10)
2871-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 1), {"Exit"," ", " ", "[","]"}, {keys.enter} , {colors.black,colors.gray,colors.orange,colors.gray})
2872-- if boolClick then
2873-- term.setCursorBlink(false)
2874-- screen.clear(colors.black)
2875-- screen.setTextColor(colors.white)
2876-- break
2877-- end
2878--
2879-- if fs.exists(strPath .. strText .. "/") and string.len( string.gsub(strText, " ", "") ) > 0 then
2880-- screen.setBackgroundColor(colors.red)
2881-- screen.setTextColor(colors.black)
2882-- term.setCursorPos(1,12)
2883-- term.write("+-Problem:" .. string.rep("-" , intWidth - 11) .. "+")
2884-- term.setCursorPos(1,13)
2885-- term.write(string.rep("|" , intWidth))
2886-- term.setCursorPos(1,14)
2887-- term.write(string.rep("|" , intWidth))
2888-- term.setCursorPos(1,15)
2889-- term.write("+" .. string.rep("-" , intWidth - 2) .. "+")
2890-- screen.setBackgroundColor(colors.white)
2891-- term.setCursorPos(2,13)
2892-- term.write(stringN.setCenter("Folder already exist", "",intWidth - 2))
2893-- term.setCursorPos(2,14)
2894-- term.write(stringN.setCenter("enter another Name", "",intWidth - 2))
2895-- else
2896-- term.setCursorPos(1,12)
2897-- term.write( string.rep(" ",intWidth))
2898-- term.setCursorPos(1,13)
2899-- term.write( string.rep(" ",intWidth))
2900-- term.setCursorPos(1,14)
2901-- term.write( string.rep(" ",intWidth))
2902-- term.setCursorPos(1,15)
2903-- term.write( string.rep(" ",intWidth))
2904-- end
2905--
2906-- term.setCursorPos(intEditPos - intOffset + 2, 5)
2907--
2908-- if boolButton then
2909-- boolButton = false
2910-- event = nil
2911-- par1 = nil
2912-- par2 = nil
2913-- par3 = nil
2914-- par4 = nil
2915-- par5 = nil
2916-- else
2917-- while true do
2918-- event, par1, par2, par3, par4, par5 = os.pullEvent()
2919-- if event == "mouse_click" or event == "mouse_up" or event == "mouse_scroll" or event == "monitor_touch" or event == "key" or event == "key_up" or event == "char" then
2920-- break
2921-- end
2922-- end
2923-- end
2924--end
2925--#install_file_path#:lightOS/explorer/open/open.install
2926----Info;>;8;512
2927--local strPath = ...
2928--
2929--function readLines(path)
2930-- local file = fs.open(path, "r")
2931-- local lines = {}
2932-- local line = file.readLine()
2933-- while line ~= nil do
2934-- table.insert( lines, line )
2935-- line = file.readLine()
2936-- end
2937-- file.close()
2938-- return lines
2939--end
2940--
2941--lines = readLines(strPath)
2942--local file
2943--i = 1
2944--while string.find( lines[i], string.gsub("--#end;install;file#",";","_") ) == nil do
2945-- if string.find( lines[i], string.gsub("--#install;file;path#:",";","_") ) ~= nil then
2946-- if file ~= nil then file.close() end
2947-- file = fs.open(string.sub(lines[i], string.len("--#install;file;path#:")), "w")
2948-- else
2949-- if file ~= nil then
2950-- file.writeLine(string.sub(lines[i],3))
2951-- end
2952-- end
2953-- i = i + 1
2954--end
2955--if file ~= nil then file.close() end
2956--fs.delete(strPath)
2957--#install_file_path#:lightOS/explorer/openUnknownFile
2958----Info;X;16384;8192
2959--local strPath = ...
2960--
2961--if strPath == nil then
2962-- strPath = ""
2963--end
2964--
2965--local strText = ""
2966--local intEditPos = 0
2967--local intOffset = 0
2968--
2969--local intSelected = 1
2970--
2971--local intWidth, intHight = term.getSize()
2972--
2973--local boolClick = false
2974--local boolButton = false
2975--
2976--local event = nil
2977--local par1 = nil
2978--local par2 = nil
2979--local par3 = nil
2980--local par4 = nil
2981--local par5 = nil
2982--
2983--term.setCursorBlink(true)
2984--screen.clear(colors.white)
2985--screen.setTextColor(colors.black)
2986--screen.setBackgroundColor(colors.lime)
2987--term.write ( stringN.setCenter ( fs.getName ( strPath ) , ".." , intWidth - 3 ) )
2988--screen.setBackgroundColor(colors.white)
2989--term.setCursorPos(1,2)
2990--term.write("Path: ")
2991--if string.len( strPath ) == 0 then
2992-- term.write("Root")
2993--else
2994-- term.write(stringN.cutLeft(strPath, "..", intWidth - 6))
2995--end
2996--term.setCursorPos(1,4)
2997--term.write("+-Arguments" .. string.rep("-" , intWidth - 12) .. "+")
2998--term.setCursorPos(1,5)
2999--term.write(string.rep("|" , intWidth))
3000--term.setCursorPos(1,6)
3001--term.write("+" .. string.rep("-" , intWidth - 2) .. "+")
3002--
3003--
3004--
3005--while true do
3006--
3007-- if event == "key" then
3008-- if par1 == keys.up or par1 == keys.down or par1 == keys.tab then
3009-- if intSelected == 1 then
3010-- intSelected = 2
3011-- else
3012-- intSelected = 0
3013-- end
3014-- end
3015--
3016-- if intSelected == 0 then
3017-- intSelected = 1
3018-- end
3019-- elseif event == "mouse_click" then
3020-- intSelected = 0
3021-- end
3022--
3023-- screen.setBackgroundColor(colors.white)
3024-- screen.setTextColor(colors.black)
3025-- term.setCursorPos(2,5)
3026-- term.write(string.rep(" ", intWidth - 2))
3027-- term.setCursorPos(2,5)
3028-- strText , intEditPos, intOffset = screen.inputField ( event, par1, strText , intEditPos, intOffset, intWidth - 2)
3029--
3030-- term.setCursorPos(intWidth - 2, 1)
3031-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 2), {"X"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.red,colors.white,colors.red})
3032-- if boolClick then
3033-- term.setCursorBlink(false)
3034-- screen.clear(colors.black)
3035-- screen.setTextColor(colors.white)
3036-- break
3037-- end
3038--
3039-- term.setCursorPos(2, 8)
3040-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 1), {"Run"," ", " ", "[","]"}, {keys.enter} , {colors.black,colors.gray,colors.orange,colors.gray})
3041-- if boolClick then
3042-- term.setCursorBlink(false)
3043-- screen.clear(colors.black)
3044-- screen.setTextColor(colors.white)
3045-- if string.len( strText ) > 0 then
3046-- if shell.run(strPath, strText) == false then
3047-- print("Something went wrong")
3048-- print("press any Button or wait...")
3049-- screen.infoPopup("",10)
3050-- else
3051-- print("Exing Program")
3052-- print("press any Button or wait...")
3053-- screen.infoPopup("",10)
3054-- end
3055-- else
3056-- if shell.run(strPath) == false then
3057-- print("Something went wrong")
3058-- print("press any Button or wait...")
3059-- screen.infoPopup("",10)
3060-- else
3061-- print("Exing Program")
3062-- print("press any Button or wait...")
3063-- screen.infoPopup("",10)
3064-- end
3065-- end
3066-- break
3067-- end
3068--
3069-- term.setCursorPos(intEditPos - intOffset + 2, 5)
3070--
3071-- if boolButton then
3072-- Initialize(strPath)
3073-- boolButton = false
3074-- event = nil
3075-- par1 = nil
3076-- par2 = nil
3077-- par3 = nil
3078-- par4 = nil
3079-- par5 = nil
3080-- else
3081-- while true do
3082-- event, par1, par2, par3, par4, par5 = os.pullEvent()
3083-- if event == "mouse_click" or event == "mouse_up" or event == "mouse_scroll" or event == "monitor_touch" or event == "key" or event == "key_up" or event == "char" then
3084-- break
3085-- end
3086-- end
3087-- end
3088--end
3089--#install_file_path#:lightOS/lightOS
3090--
3091--local width, height = term.getSize()
3092--
3093--local anyButton = false
3094--local isClick = false
3095--local event
3096--local par1
3097--local par2
3098--local par3
3099--local par4
3100--local par5
3101--
3102--local startUpPath = startN.getStartupPath()
3103--
3104--if fs.exists("programs/") == false then
3105-- fs.makeDir("programs/")
3106--end
3107--
3108--local buttonGroups
3109--local files
3110--local programs
3111--
3112--local selection = 2
3113--
3114--local function initialize()
3115-- lastCurrent = 2
3116-- lastSelected = 1
3117-- if buttonGroups ~= nil then
3118-- lastCurrent = buttonGroups.current
3119-- lastSelected = buttonGroups.selected[lastCurrent]
3120-- elseif term.isColor() then
3121-- lastCurrent = 0
3122-- end
3123--
3124--
3125-- files = fs.list("programs")
3126--
3127-- programs = {}
3128-- programs.path = {}
3129-- programs.name = {}
3130-- programs.outDir = {}
3131--
3132-- for i=1,#files do
3133-- if fs.isDir("programs/" .. files[i]) then
3134-- local path = "programs/" .. fs.getName(files[i]) .. "/" .. fs.getName(files[i])
3135-- if fs.exists(path) then
3136-- table.insert( programs.path, path )
3137-- table.insert( programs.name, fs.getName(path) )
3138-- table.insert( programs.outDir, true )
3139-- end
3140-- else
3141-- table.insert( programs.path, "programs/" .. files[i] )
3142-- table.insert( programs.name, fs.getName("programs/" .. files[i]) )
3143-- table.insert( programs.outDir, false )
3144-- end
3145-- end
3146--
3147-- buttonGroups = {}
3148-- buttonGroups = button.createGroupTable(buttonGroups)
3149-- buttonGroups = button.addGroup(4,3,buttonGroups)
3150-- buttonGroups = button.addGroup(#programs.path,1,buttonGroups)
3151-- buttonGroups = button.addGroup(#programs.path,1,buttonGroups)
3152-- buttonGroups = button.addGroup(#programs.path,1,buttonGroups)
3153--
3154-- buttonGroups.current = lastCurrent
3155-- if lastCurrent > 1 then
3156-- buttonGroups.selected[2] = math.min(lastSelected, buttonGroups.size[2])
3157-- buttonGroups.selected[3] = buttonGroups.selected[2]
3158-- buttonGroups.selected[4] = buttonGroups.selected[2]
3159-- elseif lastCurrent == 1 then
3160-- buttonGroups.selected[1] = lastSelected
3161-- end
3162--end
3163--initialize()
3164--
3165---- if term.isColor() then
3166---- selected = 0
3167---- end
3168--
3169--local function header()
3170-- screen.clear(colors.white)
3171-- screen.setTextColor(colors.black)
3172-- screen.clearLine(colors.lime)
3173-- term.write(stringN.setCenter("LightOS","",width - 3))
3174-- term.setCursorPos(1,2)
3175-- screen.clearLine(colors.blue)
3176-- screen.setBackgroundColor(colors.white)
3177--end
3178--
3179--header()
3180--while true do
3181-- if event == "key" then
3182-- if buttonGroups.current == 0 then
3183-- buttonGroups.current = 1
3184-- elseif buttonGroups.current == 1 then
3185-- if par1 == keys.tab then
3186-- buttonGroups.current = selection
3187-- elseif buttonGroups.selected[1] == 1 then
3188-- if par1 == keys.down or par1 == keys.s then
3189-- buttonGroups.selected[1] = 4
3190-- end
3191-- elseif buttonGroups.selected[1] == 2 then
3192-- if par1 == keys.up or par1 == keys.w then
3193-- buttonGroups.selected[1] = 1
3194-- elseif par1 == keys.right or par1 == keys.d then
3195-- buttonGroups.selected[1] = 3
3196-- end
3197-- elseif buttonGroups.selected[1] == 3 then
3198-- if par1 == keys.up or par1 == keys.w then
3199-- buttonGroups.selected[1] = 1
3200-- elseif par1 == keys.left or par1 == keys.a then
3201-- buttonGroups.selected[1] = 2
3202-- elseif par1 == keys.right or par1 == keys.d then
3203-- buttonGroups.selected[1] = 4
3204-- end
3205-- elseif buttonGroups.selected[1] == 4 then
3206-- if par1 == keys.up or par1 == keys.w then
3207-- buttonGroups.selected[1] = 1
3208-- elseif par1 == keys.left or par1 == keys.a then
3209-- buttonGroups.selected[1] = 3
3210-- end
3211-- end
3212-- else
3213-- if par1 == keys.up or par1 == keys.w then
3214-- buttonGroups.selected[2] = math.max(1, buttonGroups.selected[2] - 1)
3215-- buttonGroups.selected[3] = buttonGroups.selected[2]
3216-- buttonGroups.selected[4] = buttonGroups.selected[2]
3217-- elseif par1 == keys.down or par1 == keys.s then
3218-- buttonGroups.selected[2] = math.min(buttonGroups.size[2], buttonGroups.selected[2] + 1)
3219-- buttonGroups.selected[3] = buttonGroups.selected[2]
3220-- buttonGroups.selected[4] = buttonGroups.selected[2]
3221-- elseif par1 == keys.left or par1 == keys.a then
3222-- buttonGroups.current = math.max(2, buttonGroups.current - 1)
3223-- elseif par1 == keys.right or par1 == keys.d then
3224-- buttonGroups.current = math.min(4, buttonGroups.current + 1)
3225-- elseif par1 == keys.tab then
3226-- selection = buttonGroups.current
3227-- buttonGroups.current = 1
3228-- end
3229-- end
3230-- elseif event == "mouse_scroll" then
3231-- if buttonGroups.current < 2 then
3232-- buttonGroups.current = 2
3233-- else
3234-- if par1 == -1 then
3235-- buttonGroups.selected[2] = math.max(1, buttonGroups.selected[2] - 1)
3236-- buttonGroups.selected[3] = buttonGroups.selected[2]
3237-- buttonGroups.selected[4] = buttonGroups.selected[2]
3238-- end
3239-- if par1 == 1 then
3240-- buttonGroups.selected[2] = math.min(buttonGroups.size[2], buttonGroups.selected[2] + 1)
3241-- buttonGroups.selected[3] = buttonGroups.selected[2]
3242-- buttonGroups.selected[4] = buttonGroups.selected[2]
3243-- end
3244-- end
3245-- end
3246--
3247--
3248-- if buttonGroups.current > 1 and #programs.path == 0 then
3249-- buttonGroups.current = 1
3250-- end
3251--
3252--
3253-- term.setCursorPos(width - 2,1)
3254-- isClick , anyButton = button.create(anyButton , event, par1,par2,par3,0, button.isSelected(1,1,buttonGroups), {"X"," "," ","[","]"},{keys.enter,keys.space},{colors.black,colors.red,colors.white,colors.red})
3255-- if isClick then
3256-- screen.clear(colors.black)
3257-- screen.setTextColor(colors.white)
3258-- break
3259-- end
3260--
3261-- term.setCursorPos(1,2)
3262-- isClick , anyButton = button.create(anyButton , event, par1,par2,par3,0, button.isSelected(1,2,buttonGroups), {"Browser"," "," ","[","]"},{keys.enter,keys.space},{colors.black,colors.blue,colors.white,colors.blue})
3263-- if isClick then
3264-- shell.run("lightOS/browser/browser")
3265-- initialize()
3266-- header()
3267-- end
3268--
3269-- term.setCursorPos(12,2)
3270-- isClick , anyButton = button.create(anyButton , event, par1,par2,par3,0, button.isSelected(1,3,buttonGroups), {"Explporer"," "," ","[","]"},{keys.enter,keys.space},{colors.black,colors.blue,colors.white,colors.blue})
3271-- if isClick then
3272-- shell.run(unpack{"lightOS/explorer/explorer","browse_files",""})
3273-- startUpPath = startN.getStartupPath()
3274-- initialize()
3275-- header()
3276-- end
3277--
3278-- term.setCursorPos(width - 2,2)
3279-- isClick , anyButton = button.create(anyButton , event, par1,par2,par3,0, button.isSelected(1,4,buttonGroups), {"O"," "," ","[","]"},{keys.enter,keys.space},{colors.black,colors.blue,colors.white,colors.blue})
3280-- if isClick then
3281-- screen.infoPopup("Options will be coming soon!\nCheck the Browser for updates!",5)
3282-- header()
3283-- end
3284--
3285-- --Up
3286-- term.setCursorPos(width, 3)
3287-- isClick , anyButton = button.create(anyButton , event, par1,par2,par3,0,false, {"-"}, {keys.enter,keys.space} , {colors.black,colors.lightBlue})
3288-- if isClick then
3289-- if buttonGroups.current < 2 then
3290-- buttonGroups.current = 2
3291-- end
3292-- buttonGroups.selected[2] = math.max(1, buttonGroups.selected[2] - 1)
3293-- buttonGroups.selected[3] = buttonGroups.selected[2]
3294-- buttonGroups.selected[4] = buttonGroups.selected[2]
3295-- end
3296--
3297----Down
3298-- term.setCursorPos(width, height)
3299-- isClick , anyButton = button.create(anyButton , event, par1,par2,par3,0,false, {"+"}, {keys.enter,keys.space} , {colors.black,colors.lightBlue})
3300-- if isClick then
3301-- if buttonGroups.current < 2 then
3302-- buttonGroups.current = 2
3303-- end
3304-- buttonGroups.selected[2] = math.min(buttonGroups.size[2], buttonGroups.selected[2] + 1)
3305-- buttonGroups.selected[3] = buttonGroups.selected[2]
3306-- buttonGroups.selected[4] = buttonGroups.selected[2]
3307-- end
3308--
3309-- local start, ending = list.list(height - 2, buttonGroups.size[2], buttonGroups.selected[2])
3310-- local line = 3
3311-- local linecolor = {}
3312-- for i = start, ending do
3313-- term.setCursorPos(1,line)
3314-- isClick , anyButton = button.create(anyButton, event,par1,par2,par3,width - 12, button.isSelected(2,i,buttonGroups), {programs.name[i]," "," ",">"," ",".."},{keys.enter,keys.space},{})
3315-- if isClick then
3316-- shell.run("lightOS/explorer/openUnknownFile",programs.path[i])
3317-- sleep(3)
3318-- header()
3319-- end
3320-- term.write("|")
3321-- if startUpPath == programs.path[i] then
3322-- linecolor = {colors.black,colors.orange,colors.red,colors.orange}
3323-- else
3324-- linecolor = {colors.black,colors.lime,colors.blue,colors.lime}
3325-- end
3326-- isClick , anyButton = button.create(anyButton, event,par1,par2,par3,0, button.isSelected(3,i,buttonGroups), {">"," "," ","[","]"},{keys.enter,keys.space},linecolor)
3327-- if isClick then
3328-- if startUpPath == programs.path[i] then
3329-- startN.removeStartup()
3330-- startUpPath = startN.getStartupPath()
3331-- else
3332-- shell.run("lightOS/startup/setAsStartup", programs.path[i])
3333-- startUpPath = startN.getStartupPath()
3334-- header()
3335-- end
3336-- end
3337-- term.write("|")
3338-- isClick , anyButton = button.create(anyButton, event,par1,par2,par3,0, button.isSelected(4,i,buttonGroups), {"del"," "," ","[","]"},{keys.enter,keys.space},{colors.black,colors.red,colors.white,colors.red})
3339-- if isClick then
3340-- if programs.outDir[i] == true then
3341-- fs.delete( fs.getDir(programs.path[i]))
3342-- else
3343-- fs.delete( programs.path[i])
3344-- end
3345-- initialize()
3346-- header()
3347-- break
3348-- end
3349-- term.write("|")
3350-- line = line + 1
3351-- end
3352--
3353-- for i=3,height do
3354-- term.setCursorPos(width - 11,i)
3355-- term.write("|")
3356-- term.setCursorPos(width - 7,i)
3357-- term.write("|")
3358-- term.setCursorPos(width - 1,i)
3359-- term.write("|")
3360-- end
3361-- term.setCursorPos(width,4)
3362-- list.scrollbar(height - 4 , height - 2 ,buttonGroups.size[2], buttonGroups.selected[2])
3363--
3364-- if anyButton then
3365-- anyButton = false
3366-- event = nil
3367-- par1 = nil
3368-- par2 = nil
3369-- par3 = nil
3370-- par4 = nil
3371-- par5 = nil
3372-- else
3373-- while true do
3374-- event, par1, par2, par3, par4, par5 = os.pullEvent()
3375-- if event == "mouse_click" or event == "mouse_scroll" or event == "mouse_up" or event == "monitor_touch" or event == "key" or event == "key_up" then
3376-- break
3377-- end
3378-- end
3379-- end
3380--
3381-- if event == "mouse_up" then
3382-- buttonGroups.current = 0
3383-- end
3384--
3385--end
3386--#install_file_path#:lightOS/startup/setAsStartup
3387--local strPath = ...
3388--
3389--if strPath == nil then
3390-- strPath = ""
3391--else
3392-- local p, a = string.gsub(strPath,"#SPACE#"," ")
3393-- strPath = p
3394--end
3395--
3396--local strText = ""
3397--local intEditPos = 0
3398--local intOffset = 0
3399--
3400--local intSelected = 1
3401--
3402--local intWidth, intHight = term.getSize()
3403--
3404--local boolClick = false
3405--local boolButton = false
3406--
3407--local event = nil
3408--local par1 = nil
3409--local par2 = nil
3410--local par3 = nil
3411--local par4 = nil
3412--local par5 = nil
3413--
3414--screen.clear(colors.white)
3415--screen.setTextColor(colors.black)
3416--screen.setBackgroundColor(colors.lime)
3417--term.write ( stringN.setCenter ( fs.getName ( strPath ) , ".." , intWidth - 3 ) )
3418--screen.setBackgroundColor(colors.white)
3419--term.setCursorPos(1,2)
3420--term.write("Path: ")
3421--if string.len( strPath ) == 0 then
3422-- term.write("Root")
3423--else
3424-- term.write(stringN.cutLeft(strPath, "..", intWidth - 6))
3425--end
3426--term.setCursorPos(1,4)
3427--term.write("+-Arguments" .. string.rep("-" , intWidth - 12) .. "+")
3428--term.setCursorPos(1,5)
3429--term.write(string.rep("|" , intWidth))
3430--term.setCursorPos(1,6)
3431--term.write("+" .. string.rep("-" , intWidth - 2) .. "+")
3432--
3433--
3434--
3435--while true do
3436--
3437-- if event == "key" then
3438-- if par1 == keys.up or par1 == keys.down or par1 == keys.tab then
3439-- if intSelected == 1 then
3440-- intSelected = 2
3441-- else
3442-- intSelected = 0
3443-- end
3444-- end
3445--
3446-- if intSelected == 0 then
3447-- intSelected = 1
3448-- end
3449-- elseif event == "mouse_click" then
3450-- intSelected = 0
3451-- end
3452--
3453-- screen.setBackgroundColor(colors.white)
3454-- screen.setTextColor(colors.black)
3455-- term.setCursorPos(2,5)
3456-- term.write(string.rep(" ", intWidth - 2))
3457-- term.setCursorPos(2,5)
3458-- strText , intEditPos, intOffset = screen.inputField ( event, par1, strText , intEditPos, intOffset, intWidth - 2)
3459--
3460-- term.setCursorPos(intWidth - 2, 1)
3461-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 2), {"X"," ", " ", "[","]"}, {keys.enter,keys.space} , {colors.black,colors.red,colors.white,colors.red})
3462-- if boolClick then
3463-- screen.clear(colors.black)
3464-- screen.setTextColor(colors.white)
3465-- break
3466-- end
3467--
3468-- term.setCursorPos(2, 8)
3469-- boolClick , boolButton = button.create(boolButton , event, par1,par2,par3,0,(intSelected == 1), {"Set As Startup"," ", " ", "[","]"}, {keys.enter} , {colors.black,colors.gray,colors.orange,colors.gray})
3470-- if boolClick then
3471-- screen.clear(colors.black)
3472-- screen.setTextColor(colors.white)
3473-- print("text: " .. strText)
3474-- startN.setAsStartup(strPath, {strText} )
3475-- break
3476-- end
3477--
3478-- if boolButton then
3479-- Initialize(strPath)
3480-- boolButton = false
3481-- event = nil
3482-- par1 = nil
3483-- par2 = nil
3484-- par3 = nil
3485-- par4 = nil
3486-- par5 = nil
3487-- else
3488-- while true do
3489-- event, par1, par2, par3, par4, par5 = os.pullEvent()
3490-- if event == "mouse_click" or event == "mouse_up" or event == "mouse_scroll" or event == "monitor_touch" or event == "key" or event == "key_up" or event == "char" then
3491-- break
3492-- end
3493-- end
3494-- end
3495--end
3496--#install_file_path#:startup
3497----Initialize lightOS
3498----lightOS by FileStriker
3499--
3500----load Apis
3501--local apiFiles = fs.list("api")
3502--for i = 1 , #apiFiles do
3503-- if fs.isDir(apiFiles[i]) == false then
3504-- os.loadAPI("api/" .. apiFiles[i])
3505-- end
3506--end
3507--
3508--if fs.exists("lightOS/startup/start") then
3509-- if shell.run(unpack( fileN.readLines("lightOS/startup/start") )) == false then
3510-- fs.delete("lightOS/startup/start")
3511-- end
3512--end
3513--
3514--screen.clear(colors.black)
3515--screen.setTextColor(colors.white)
3516--shell.run("lightOS/lightOS")
3517--#end_install_file#