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