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