Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local w, h = term.getSize()
- local lChanged = false
- local pChanged = true
- local mChanged = true
- local numlength = 1
- local type = 1
- local tabNum = 0
- local mode = "edit"
- local clickStart, clickEnd, prevline, currentLine, currentPos
- local cTables, cComTab, program, colTab = {}, {}, {}, {}
- cParTab = {}
- if mode == "edit" then
- colTab[1] = colors.lightGray
- colTab[2] = colors.green
- colTab[3] = colors.red
- colTab[4] = colors.orange
- colTab[5] = colors.lightBlue
- colTab[6] = colors.white
- elseif mode == "read" then
- colTab[1] = colors.white
- colTab[2] = colors.white
- colTab[3] = colors.white
- colTab[4] = colors.white
- colTab[5] = colors.white
- colTab[6] = colors.white
- end
- local location = {
- ["x"] = 1,
- ["y"] = 1
- }
- local position = {
- ["x"] = 1,
- ["y"] = 1
- }
- local conditionals = {
- ["if"] = {"end", colors.red, colors.pink},
- ["while"] = {"end", colors.red, colors.pink},
- ["for"] = {"end", colors.red, colors.pink},
- ["function"] = {"end", colors.red, colors.pink}
- }
- local keywords = {
- ["if"] = colors.yellow,
- ["then"] = colors.yellow,
- ["else"] = colors.yellow,
- ["elseif"] = colors.yellow,
- ["end"] = colors.yellow,
- ["function"] = colors.yellow,
- ["while"] = colors.yellow,
- ["for"] = colors.yellow,
- ["in"] = colors.yellow,
- ["do"] = colors.yellow,
- ["local"] = colors.yellow,
- ["repeat"] = colors.yellow,
- ["until"] = colors.yellow,
- ["next"] = colors.yellow,
- ["and"] = colors.orange,
- ["or"] = colors.orange,
- ["not"] = colors.orange,
- ["true"] = colors.orange,
- ["false"] = colors.orange,
- ["nil"] = colors.gray,
- ["break"] = colors.purple,
- ["return"] = colors.purple,
- ["print"] = colors.pink,
- ["write"] = colors.pink,
- ["pairs"] = colors.pink,
- ["ipairs"] = colors.pink,
- ["type"] = colors.blue,
- ["tostring"] = colors.blue,
- ["tonumber"] = colors.blue,
- ["assert"] = colors.blue,
- ["setmetatable"] = colors.blue
- }
- if tArgs[1] and fs.exists(tArgs[1]) then
- for line in io.lines(tArgs[1]) do
- program[#program + 1] = tostring(line)
- program[#program] = program[#program]:gsub(" ", "$___")
- end
- if #program == 0 then
- program[1] = ""
- end
- elseif tArgs[1] then
- program[1] = ""
- end
- local function draw(string, xPos, yPos, txtcol, bakcol)
- local string = string or ""
- local txtcol = txtcol or colors.white
- local bakcol = bakcol or colors.black
- term.setCursorPos(xPos, yPos)
- term.setBackgroundColor(bakcol)
- term.setTextColor(txtcol)
- term.write(string)
- end
- local function codeDraw(string, xPos, yPos)
- local string = string or ""
- local xPos = xPos - location["x"] + 1
- local sStart, sEnd = 1, 1 + w - numlength
- local tabDraw = true
- local multiComment = false
- while #string > 0 and xPos <= sEnd do
- --[[for i in pairs(cComTab) do
- if mode == "edit" then
- if not multiComment and (yPos-1 == cComTab[i][1][2]-location["y"] + 1 and xPos-3 >= cComTab[i][1][1]-location["x"] + 1) or (yPos-1 == cComTab[i][2][2]-location["y"]+1 and xPos-2 <= cComTab[i][2][1]-location["x"]+1) or (yPos-1 > cComTab[i][1][2]-location["y"]+1 and yPos-1 < cComTab[i][2][2]-location["y"]+1) then
- colTab[1] = colors.green
- colTab[2] = colors.green
- colTab[3] = colors.green
- colTab[4] = colors.green
- colTab[5] = colors.green
- colTab[6] = colors.green
- multiComment = true
- break
- elseif multiComment then
- colTab[1] = colors.lightGray
- colTab[2] = colors.green
- colTab[3] = colors.red
- colTab[4] = colors.orange
- colTab[5] = colors.lightBlue
- colTab[6] = colors.white
- multiComment = false
- end
- end
- end]]--
- if string:find("^%$___") then
- local _, en = string:find("^%$___")
- if en >= sStart and xPos <= sEnd then
- if tabDraw and not multiComment then
- draw(" |", xPos, yPos, colTab[1], colors.black)
- else
- draw(" ", xPos, yPos, colTab[1], colors.black)
- end
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^%-%-.*") then
- tabDraw = false
- local _, en = string:find("^%-%-.*")
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, colTab[2], colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^\".-[^\\]\"") then
- tabDraw = false
- local _, en = string:find("^\".-[^\\]\"")
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, colTab[3], colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^\'.-[^\\]\'") then
- tabDraw = false
- local _, en = string:find("^\'.-[^\\]\'")
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, colTab[3], colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^\"\"") then
- tabDraw = false
- local _, en = string:find("^\"\"")
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, colTab[3], colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^\'\'") then
- tabDraw = false
- local _, en = string:find("^\'\'")
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, colTab[3], colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^%[%[.-%]%]") then
- tabDraw = false
- local _, en = string:find("^%[%[.-%]%]")
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, colTab[3], colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^%d+") then
- tabDraw = false
- local _, en = string:find("^%d+")
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, colTab[4], colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^%p") then
- tabDraw = false
- local _, en = string:find("^%p")
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, colTab[5], colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^[%a_]+") then
- tabDraw = false
- local _, en = string:find("^[%a_]+")
- local test = string:sub(1, en)
- local color = colors.white
- if keywords[test] and mode == "edit" then
- color = keywords[test]
- end
- if multiComment then
- color = colors.green
- end
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, color, colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- elseif string:find("^[^%w_]") then
- tabDraw = false
- local _, en = string:find("^[^%w_]")
- if en >= sStart and xPos <= sEnd then
- draw(string:sub(1, en), xPos, yPos, colTab[6], colors.black)
- end
- string = string:sub(en + 1)
- xPos = xPos + en
- end
- end
- end
- local function printMenu()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.lightGray)
- term.clearLine()
- draw("Press CTRL for menu...", 1, 1, colors.gray, colors.lightGray)
- end
- local function saveFile(codeTable, filename)
- local tempFile = {}
- for i, v in ipairs(codeTable) do
- tempFile[i] = v:gsub("$___", " ")
- end
- local sFile = fs.open(filename, "w")
- for _, v in ipairs(tempFile) do
- sFile.writeLine(v)
- end
- sFile.close()
- end
- local function showProgram()
- multiComment = false
- numlength = #tostring(#program - location["y"] + 1 >= h and location["y"] + h - 1 or #program)
- for y = location["y"], #program - location["y"] + 1 >= h - 1 and location["y"] + h - 2 or #program do
- codeDraw(program[y], 1 + numlength, y - location["y"] + 2)
- end
- end
- local function showProgramLine(line)
- numlength = #tostring(#program - location["y"] + 1 >= h and location["y"] + h - 1 or #program)
- codeDraw(program[line], 1 + numlength, line - location["y"] + 2)
- end
- local function showNumbers()
- local activeLoops = {}
- local up, down
- for _, v in pairs(cTables) do
- if currentLine >= v[1] and currentLine <= v[2] then
- activeLoops[#activeLoops + 1] = {v[1], v[2]}
- end
- end
- if #activeLoops > 0 then
- local key, mini = 0, #program
- for i, v in pairs(activeLoops) do
- if v[2] - v[1] < mini then
- key, mini = i, v[2] - v[1]
- end
- end
- if key > 0 then
- up, down = activeLoops[key][1], activeLoops[key][2]
- end
- end
- for y = location["y"], #program - location["y"] + 1 >= h - 1 and location["y"] + h - 2 or #program do
- local text, back = colors.gray, colors.lightGray
- if up and down and y > up and y < down then
- text, back = colors.red, colors.pink
- elseif up and down and (y == up or y == down) then
- text, back = colors.pink, colors.red
- end
- draw(tostring(y), 1, y - location["y"] + 2, text, back)
- if #tostring(y) < numlength then
- write(" ")
- end
- end
- end
- local function checkParenthesis()
- local cancelNum = 0
- local pString = ""
- pBreaks = {}
- local cBrackets = {}
- pBreaks[1] = 0
- for y = 1, #program do
- pString = pString .. program[y]
- pBreaks[y+1] = #program[y] + pBreaks[y]
- end
- while pString:find("[%[%{%(]") do
- local oppChar
- local st, en = pString:find("[%[%{%(]")
- term.setBackgroundColor(colors.magenta)
- local char = pString:sub(st, st)
- if char == "[" then oppChar = "]"
- elseif char == "{" then oppChar = "}"
- elseif char == "(" then oppChar = ")" end
- st, en = pString:find("%b" .. char .. oppChar)
- if st and en then
- local x1, y1, x2, y2
- local active = true
- for i, v in pairs(pBreaks) do
- if st <= v and active then
- x1 = st - pBreaks[i - 1]
- y1 = i - 1
- active = false
- end
- if en <= v then
- x2 = en - pBreaks[i - 1]
- y2 = i - 1
- end
- if x1 and y1 and x2 and y2 then
- cBrackets[#cBrackets + 1] = {x1, y1, x2, y2, char, oppChar}
- break
- end
- end
- pString = pString:sub(1, st - 1) .. " " .. pString:sub(st + 1)
- pString = pString:sub(1, en - 1) .. " " .. pString:sub(en + 1)
- else
- st, en = pString:find("[%[%{%(]")
- pString = pString:sub(1, st - 1) .. " " .. pString:sub(st + 1)
- end
- end
- return cBrackets
- end
- local function checkConditionals()
- local cWords = {}
- local active = false
- local cancelNum = 0
- local cConditional = {}
- for y = 1, #program do
- for i in pairs(conditionals) do
- local test = program[y]:gsub(" ", "")
- local st = test:find(i)
- local _, en = program[y]:find(i)
- if st and en then
- if st == 1 and (en == #program[y] or program[y]:sub(en + 1, en + 1) == " ") then
- cWords[#cWords + 1] = {}
- cWords[#cWords][1] = y
- cancelNum = cancelNum + 1
- cConditional[cancelNum] = #cWords
- active = true
- end
- end
- end
- if active and program[y]:find("end") then
- cWords[cConditional[cancelNum]][2] = y
- cancelNum = cancelNum - 1
- if cancelNum == 0 then
- active = false
- if y > location["y"] + h - 2 then
- break
- end
- end
- end
- end
- local rem = {}
- for i = 1, #cWords do
- if not (cWords[i][1] and cWords[i][2]) then
- rem[#rem + 1] = i
- end
- end
- for i, v in pairs(rem) do
- table.remove(cWords, v - i + 1)
- end
- return cWords
- end
- function checkMultiComments()
- local cComments = {}
- local active = false
- local cancelNum = 0
- local cConditional = {}
- for y = 1, #program do
- if program[y]:find("%-%-%[%[") and not active then
- active = true
- local st = program[y]:find("%-%-%[%[")
- cComments[#cComments + 1] = {}
- cComments[#cComments][1]= {st, y}
- elseif program[y]:find("%]%]") and active then
- active = false
- local _, en = program[y]:find("%]%]")
- cComments[#cComments][2] = {en, y}
- end
- end
- local rem = {}
- for i = 1, #cComments do
- if #cComments[i] < 2 then
- rem[#rem + 1] = i
- end
- end
- for i, v in pairs(rem) do
- table.remove(cComments, v - i + 1)
- end
- return cComments
- end
- local function addLetter(char, str, pos)
- return str:sub(0, pos - 1) .. tostring(char) .. str:sub(pos)
- end
- local function removeLetter(str, pos)
- return str:sub(0, pos) .. str:sub(pos + 2)
- end
- local function fixCursorPos()
- if position["y"] < 1 then
- pChanged = true
- location["y"] = location["y"] + position["y"] - 1
- position["y"] = 1
- elseif position["y"] > h - 1 then
- pChanged = true
- location["y"] = location["y"] + position["y"] - (h-1)
- position["y"] = h - 1
- end
- if location["y"] < 1 then
- pChanged = false
- location["y"] = 1
- elseif location["y"] + h - 1 > #program then
- pChanged = false
- location["y"] = #program - h + 1
- end
- local dollarNum
- if program[location["y"] + position["y"] - 1]:sub(location["x"] + position["x"] - 1, location["x"] + position["x"] - 1) == "_" then
- for i = 1, 3 do
- if program[location["y"] + position["y"] - 1]:sub(location["x"] + position["x"] - 1 - i, location["x"] + position["x"] - 1 - i) ~= "_" then
- if program[location["y"] + position["y"] - 1]:sub(location["x"] + position["x"] - 1 - i, location["x"] + position["x"] - 1 - i) == "$" then
- dollarNum = i
- break
- end
- break
- end
- end
- if dollarNum and dollarNum < 3 then
- for i = 1, 3 - dollarNum do
- if program[location["y"] + position["y"] - 1]:sub(location["x"] + position["x"] - 1 + i, location["x"] + position["x"] - 1 + i) ~= "_" then
- dollarNum = nil
- break
- end
- end
- end
- if dollarNum then
- position["x"] = position["x"] - numlength - dollarNum + 2
- end
- end
- if position["x"] + location["x"] - 1 > #program[position["y"] + location["y"] - 1] then
- position["x"] = #program[position["y"] + location["y"] - 1] - location["x"] + 2
- end
- if position["x"] < 1 then
- pChanged = true
- location["x"] = location["x"] + position["x"] - 1
- position["x"] = 1
- elseif position["x"] > w - numlength then
- pChanged = true
- location["x"] = location["x"] + position["x"] - (w-numlength)
- position["x"] = w - numlength
- end
- if location["x"] < 1 then
- pChanged = false
- location["x"] = 1
- elseif location["x"] + w - numlength > #program then
- pChanged = false
- location["x"] = #program - w + numlength
- end
- if mode == "read" and location["x"] < 3 then
- location["x"] = 3
- elseif mode == "edit" and location["x"] < 1 then
- location["x"] = 1
- end
- currentLine = location["y"] + position["y"] - 1
- currentPos = position["x"] + location["x"] - 1
- end
- term.setCursorBlink(true)
- while true do
- if mode == "edit" then
- numlength = #tostring(#program - location["y"] + 1 >= h and location["y"] + h - 1 or #program)
- elseif mode == "read" then
- numlength = 0
- end
- fixCursorPos()
- --cComTab = checkMultiComments()
- if pChanged or program[currentLine]:sub(currentPos - 2, currentPos - 1) == "]]" then
- --cTables = checkConditionals()
- term.setBackgroundColor(colors.black)
- term.clear()
- showProgram()
- pChanged = false
- lChanged = false
- elseif lChanged then
- --cTables = checkConditionals()
- term.setBackgroundColor(colors.black)
- term.clearLine()
- showProgramLine(currentLine)
- lChanged = false
- end
- if mChanged then
- printMenu()
- mChanged = false
- end
- --[[if prevline then
- showProgramLine(prevline[1])
- showProgramLine(prevline[2])
- prevline = nil
- end
- if mode == "edit" then
- cParTab = checkParenthesis()
- end
- for i, v in pairs(cParTab) do
- if (currentPos == cParTab[i][1] and currentLine == cParTab[i][2]) or (currentPos == cParTab[i][3] and currentLine == cParTab[i][4]) then
- draw(cParTab[i][5], cParTab[i][1] + numlength - location["x"] + 1, cParTab[i][2] - location["y"] + 2, colors.blue, colors.lightBlue)
- draw(cParTab[i][6], cParTab[i][3] + numlength - location["x"] + 1, cParTab[i][4] - location["y"] + 2, colors.blue, colors.lightBlue)
- prevline = {cParTab[i][2], cParTab[i][4]}
- end
- end]]
- if mode == "edit" then
- showNumbers()
- end
- term.setTextColor(colors.white)
- term.setCursorPos(position["x"] + numlength, position["y"] + 1)
- local events = {os.pullEvent()}
- if events[1] == "char" and mode == "edit" then
- lChanged = true
- program[currentLine] = addLetter(events[2], program[currentLine], position["x"] + location["x"] - 1)
- position["x"] = position["x"] + 1
- elseif events[1] == "key" then
- if events[2] == keys.up then --^
- position["y"] = position["y"] - 1
- elseif events[2] == keys.down then --v
- position["y"] = position["y"] + 1
- elseif events[2] == keys.right then -->
- if (position["x"] + location["x"] - 1) % 4 == 1 and position["x"] + location["x"] - 1 < #program[currentLine] and program[currentLine]:sub(position["x"] + location["x"] - 1, position["x"] + location["x"] + 2) == "$___" then
- position["x"] = position["x"] + 4
- elseif currentLine < #program and currentPos > #program[currentLine] then
- position["x"] = 1 - location["x"] + 1
- position["y"] = position["y"] + 1
- else
- position["x"] = position["x"] + 1
- end
- elseif events[2] == keys.left then --<
- if (position["x"] + location["x"] - 1) % 4 == 1 and position["x"] + location["x"] - 1 > 4 and program[currentLine]:sub(position["x"] + location["x"] - 5, position["x"] + location["x"] - 2) == "$___" then
- position["x"] = position["x"] - 4
- elseif currentLine > 1 and currentPos == 1 then
- position["x"] = #program[currentLine - 1] + 1
- position["y"] = position["y"] - 1
- else
- position["x"] = position["x"] - 1
- end
- end
- if events[2] == keys.backspace and mode == "edit" then
- lChanged = true
- if (position["x"] + location["x"] - 1) % 4 == 1 and position["x"] + location["x"] - 1 > 4 and program[currentLine]:sub(position["x"] + location["x"] - 5, position["x"] + location["x"] - 2) == "$___" then
- for i = 1, 4 do
- program[currentLine] = removeLetter(program[currentLine], location["x"] + position["x"] - 6)
- position["x"] = position["x"] - 4
- end
- elseif currentLine > 1 and currentPos == 1 then
- position["y"] = position["y"] - 1
- location["x"] = (location["x"] > #program[currentLine - 1] or location["x"] + w - #tostring(currentLine - 1) < #program[currentLine - 1]) and #program[currentLine - 1] + 1 or location["x"]
- position["x"] = #program[currentLine - 1] - location["x"] + 2
- program[currentLine - 1] = program[currentLine - 1] .. (table.remove(program, currentLine))
- pChanged = true
- else
- program[currentLine] = removeLetter(program[currentLine], currentPos - 2)
- position["x"] = position["x"] - 1
- end
- end
- if events[2] == keys.enter and mode == "edit" then
- pChanged = true
- table.insert(program, currentLine + 1, program[currentLine]:sub(position["x"] + location["x"] - 1))
- program[currentLine] = program[currentLine]:sub(1, position["x"] + location["x"] - 2)
- program[currentLine + 1] = string.rep("$___", tabNum) .. program[currentLine + 1]
- position["y"] = position["y"] + 1
- position["x"] = 1 + tabNum * 4
- end
- if events[2] == keys.tab and mode == "edit" then
- lChanged = true
- if (position["x"] + location["x"] - 1) % 4 == 1 then
- program[currentLine] = addLetter("$___", program[currentLine], position["x"] + location["x"] - 1)
- else
- local num = (position["x"] + location["x"] - 1) % 4 + 1
- if num == 4 then num = 2 end
- program[currentLine] = addLetter(string.rep(" ", num), program[currentLine], position["x"] + location["x"] - 1)
- end
- position["x"] = position["x"] + 4
- end
- if events[2] == keys.leftCtrl then
- mChanged = true
- term.setCursorBlink(false)
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.lightGray)
- term.clearLine()
- local broken = false
- while true do
- if type == 1 then
- draw("Save", 1, 1, colors.gray, colors.white)
- draw("Exit", 8, 1, colors.gray, colors.lightGray)
- draw("Funcs", 15, 1, colors.gray, colors.lightGray)
- elseif type == 2 then
- draw("Save", 1, 1, colors.gray, colors.lightGray)
- draw("Exit", 8, 1, colors.gray, colors.white)
- draw("Funcs", 15, 1, colors.gray, colors.lightGray)
- elseif type == 3 then
- draw("Save", 1, 1, colors.gray, colors.lightGray)
- draw("Exit", 8, 1, colors.gray, colors.lightGray)
- draw("Funcs", 15, 1, colors.gray, colors.white)
- end
- local events = {os.pullEvent()}
- if events[1] == "key" then
- if events[2] == keys.enter then
- if type == 1 then
- draw("Save", 1, 1, colors.gray, colors.yellow)
- saveFile(program, tArgs[1])
- sleep(.2)
- elseif type == 2 then
- draw("Exit", 8, 1, colors.gray, colors.yellow)
- broken = true
- sleep(.2)
- break
- elseif type == 3 then
- draw("Funcs", 15, 1, colors.gray, colors.yellow)
- sleep(.1)
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.lightGray)
- term.clearLine()
- local choice = 1
- local brokenIn = false
- while true do
- if choice == 1 then
- draw("Move", 1, 1, colors.gray, colors.white)
- draw("Mode", 8, 1, colors.gray, colors.lightGray)
- elseif choice == 2 then
- draw("Move", 1, 1, colors.gray, colors.lightGray)
- draw("Mode", 8, 1, colors.gray, colors.white)
- end
- local events = {os.pullEvent()}
- if events[1] == "key" then
- if events[2] == keys.leftCtrl then
- break
- end
- if events[2] == keys.left then
- choice = choice - 1
- elseif events[2] == keys.right then
- choice = choice + 1
- end
- if choice == 3 then choice = 2 end
- if choice == 0 then choice = 1 end
- if events[2] == keys.enter then
- if choice == 1 then
- draw("Move", 1, 1, colors.gray, colors.yellow)
- draw(" ", 1, 2, colors.gray, colors.white)
- term.setCursorPos(1, 2)
- local line = read()
- if tonumber(line) and tonumber(line) > 0 then
- if tonumber(line) < #program - h + 2 then
- location["y"] = tonumber(line)
- else
- location["y"] = #program - h + 2
- end
- pChanged = true
- end
- brokenIn = true
- break
- elseif choice == 2 then
- pChanged = true
- draw("Mode", 8, 1, colors.gray, colors.yellow)
- local tempmode = mode
- while true do
- if mode == "edit" then
- draw("Edit", 8, 2, colors.white, colors.lime)
- draw("Read", 8, 3, colors.gray, colors.white)
- elseif mode == "read" then
- draw("Edit", 8, 2, colors.gray, colors.white)
- draw("Read", 8, 3, colors.white, colors.lime)
- end
- local events = {os.pullEvent()}
- if events[1] == "key" then
- if events[2] == keys.leftCtrl then
- break
- end
- if events[2] == keys.up then
- mode = "edit"
- elseif events[2] == keys.down then
- mode = "read"
- end
- if events[2] == keys.enter then
- if mode == "edit" and tempmode == "read" then
- location["x"] = 1
- end
- if mode == "edit" then
- colTab[1] = colors.lightGray
- colTab[2] = colors.green
- colTab[3] = colors.red
- colTab[4] = colors.orange
- colTab[5] = colors.lightBlue
- colTab[6] = colors.white
- elseif mode == "read" then
- colTab[1] = colors.white
- colTab[2] = colors.white
- colTab[3] = colors.white
- colTab[4] = colors.white
- colTab[5] = colors.white
- colTab[6] = colors.white
- end
- break
- end
- end
- end
- brokenIn = true
- break
- end
- end
- end
- end
- if brokenIn then break end
- end
- end
- if events[2] == keys.leftCtrl then
- break
- end
- if events[2] == keys.left then
- type = type - 1
- elseif events[2] == keys.right then
- type = type + 1
- end
- end
- if type == 4 then type = 3 end
- if type == 0 then type = 1 end
- end
- term.setCursorBlink(true)
- if broken then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- break
- end
- end
- end
- if events[1] == "mouse_click" and events[2] == 1 and #program >= events[4] + location["y"] - 2 and events[4] > 1 then
- position["y"] = events[4] - 1
- position["x"] = events[3] - numlength
- elseif events[1] == "mouse_drag" and events[2] == 1 then
- clickEnd = {events[3] + location["x"] - 1, events[4] + location["y"] - 1}
- end
- if events[1] == "mouse_scroll" then
- pChanged = true
- location["y"] = location["y"] + events[2]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement