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