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