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