diff --git a/Applications/MineCode IDE.app/Localizations/English.lang b/Applications/MineCode IDE.app/Localizations/English.lang index 3f5d4470..57b5dcb3 100755 --- a/Applications/MineCode IDE.app/Localizations/English.lang +++ b/Applications/MineCode IDE.app/Localizations/English.lang @@ -1,6 +1,7 @@ { - enableSyntaxHighlight = "Enable syntax highlighting", - disableSyntaxHighlight = "Disable syntax highlighting", + toggleSyntaxHighlight = "Toggle syntax highlighting", + toggleAutocompletion = "Toggle autocompletion", + toggleAutoBrackets = "Toggle autobrackets", toUpperCase = "To upper", toLowerCase = "To lower", convertCase = "Convert case", @@ -13,11 +14,7 @@ continueDebug = "Continue", gotoLine = "Goto line", lineNumber = "Line", - enableAutocompletion = "Enable autocompletion", - disableAutocompletion = "Disable autocompletion", selectAndPasteColor = "Select and paste color", - enableAutoBrackets = "Enable autobrackets", - disableAutoBrackets = "Disable autobrackets", url = "http://example.com/something.lua", getFromWeb = "Open from URL", downloading = "Downloading file...", diff --git a/Applications/MineCode IDE.app/Localizations/French.lang b/Applications/MineCode IDE.app/Localizations/French.lang index c1668276..8d5512b1 100644 --- a/Applications/MineCode IDE.app/Localizations/French.lang +++ b/Applications/MineCode IDE.app/Localizations/French.lang @@ -1,6 +1,7 @@ { - enableSyntaxHighlight = "Activer la coloration syntaxique", - disableSyntaxHighlight = "Désactiver la coloration syntaxique", + toggleSyntaxHighlight = "Toggle syntax highlighting", + toggleAutocompletion = "Toggle autocompletion", + toggleAutoBrackets = "Toggle autobrackets", toUpperCase = "Monter", toLowerCase = "Baisser", convertCase = "Convertir le cas", @@ -13,11 +14,7 @@ continueDebug = "Continuer", gotoLine = "Aller à la ligne", lineNumber = "Ligne", - enableAutocompletion = "Activer l'auto-complétion", - disableAutocompletion = "Désactiver l'auto-complétion", selectAndPasteColor = "Sélectionnez et collez la couleur", - enableAutoBrackets = "Activer le crochetage automatiques", - disableAutoBrackets = "Désactiver le crochetage automatiques", url = "http://example.org/quelquechose.lua", getFromWeb = "Télécharger depuis une URL", downloading = "Téléchargement du fichier...", diff --git a/Applications/MineCode IDE.app/Localizations/German.lang b/Applications/MineCode IDE.app/Localizations/German.lang index edc06682..a27ccc6d 100644 --- a/Applications/MineCode IDE.app/Localizations/German.lang +++ b/Applications/MineCode IDE.app/Localizations/German.lang @@ -1,6 +1,7 @@ { - enableSyntaxHighlight = "Syntaxhervorhebung aktivieren", - disableSyntaxHighlight = "Syntaxhervorhebung deaktivieren", + toggleSyntaxHighlight = "Toggle syntax highlighting", + toggleAutocompletion = "Toggle autocompletion", + toggleAutoBrackets = "Toggle autobrackets", toUpperCase = "Nach oben", toLowerCase = "Senken", convertCase = "Konvertieren Fall", @@ -13,11 +14,7 @@ continueDebug = "Weiterhin", gotoLine = "Gehe zu Zeile", lineNumber = "Linie", - enableAutocompletion = "Autovervollständigung aktivieren", - disableAutocompletion = "Autovervollständigung deaktivieren", selectAndPasteColor = "Farbe auswählen und einfügen", - enableAutoBrackets = "Automatische Klammern aktivieren", - disableAutoBrackets = "Automatische Klammern deaktivieren", url = "http://example.com/something.lua", getFromWeb = "Von URL öffnen", downloading = "Herunterladenzeit...", diff --git a/Applications/MineCode IDE.app/Localizations/Italian.lang b/Applications/MineCode IDE.app/Localizations/Italian.lang index e6898eb9..e84d85e2 100644 --- a/Applications/MineCode IDE.app/Localizations/Italian.lang +++ b/Applications/MineCode IDE.app/Localizations/Italian.lang @@ -1,6 +1,7 @@ { - enableSyntaxHighlight = "Attiva evidenziazione sintassi", - disableSyntaxHighlight = "Disabilita evidenziazione sintassi", + toggleSyntaxHighlight = "Toggle syntax highlighting", + toggleAutocompletion = "Toggle autocompletion", + toggleAutoBrackets = "Toggle autobrackets", toUpperCase = "In alto", toLowerCase = "Abbassare", convertCase = "Converti maiuscole / minuscole", @@ -13,11 +14,7 @@ continueDebug = "Continuare", gotoLine = "Va alla riga", lineNumber = "Linea", - enableAutocompletion = "Abilita completamento automatico", - disableAutocompletion = "Disabilita completamento automatico", selectAndPasteColor = "Seleziona e incolla colore", - enableAutoBrackets = "Abilita parentesi automatiche", - disableAutoBrackets = "Disabilita parentesi automatiche", url = "http://example.com/something.lua", getFromWeb = "Apri DALL'URL", downloading = "Scaricamento file...", diff --git a/Applications/MineCode IDE.app/Localizations/Russian.lang b/Applications/MineCode IDE.app/Localizations/Russian.lang index a806275c..6dd4c130 100755 --- a/Applications/MineCode IDE.app/Localizations/Russian.lang +++ b/Applications/MineCode IDE.app/Localizations/Russian.lang @@ -1,6 +1,7 @@ { - enableSyntaxHighlight = "Включить подсветку синтаксиса", - disableSyntaxHighlight = "Отключить подсветку синтаксиса", + toggleSyntaxHighlight = "Вкл/выкл подсветку синтаксиса", + toggleAutocompletion = "Вкл/выкл автодополнение", + toggleAutoBrackets = "Вкл/выкл автоскобки", toUpperCase = "В верхний", toLowerCase = "В нижний", convertCase = "Преобразовать регистр", @@ -13,11 +14,7 @@ continueDebug = "Продолжить", gotoLine = "Перейти к строке", lineNumber = "Номер строки", - enableAutocompletion = "Включить автодополнение", - disableAutocompletion = "Отключить автодополнение", selectAndPasteColor = "Выбрать и вставить цвет", - enableAutoBrackets = "Включить авто-скобки", - disableAutoBrackets = "Отключить авто-скобки", url = "http://example.com/something.lua", getFromWeb = "Открыть по URL", downloading = "Идет загрузка файла...", diff --git a/Applications/MineCode IDE.app/Localizations/Ukrainian.lang b/Applications/MineCode IDE.app/Localizations/Ukrainian.lang index 8804063b..db5f0883 100755 --- a/Applications/MineCode IDE.app/Localizations/Ukrainian.lang +++ b/Applications/MineCode IDE.app/Localizations/Ukrainian.lang @@ -1,6 +1,7 @@ { - enableSyntaxHighlight = "Включити підсвічування синтаксису", - disableSyntaxHighlight = "Відключити підсвічування синтаксису", + toggleSyntaxHighlight = "Toggle syntax highlighting", + toggleAutocompletion = "Toggle autocompletion", + toggleAutoBrackets = "Toggle autobrackets", toUpperCase = "У верхній", toLowerCase = "У нижній", convertCase = "Перетворити регістр", @@ -13,11 +14,7 @@ continueDebug = "Продовжити", gotoLine = "Перейти до рядка", lineNumber = "Номер рядка", - enableAutocompletion = "Включити автодоповнення", - disableAutocompletion = "Відключити автодоповнення", selectAndPasteColor = "Вибрати і вставити колір", - enableAutoBrackets = "Включити авто-дужки", - disableAutoBrackets = "Відключити авто-дужки", url = "http://example.com/something.lua", getFromWeb = "Завантажити з URL", debugging = "Отладчик на рядку", diff --git a/Applications/MineCode IDE.app/Main.lua b/Applications/MineCode IDE.app/Main.lua index 43b72193..8e0f3831 100755 --- a/Applications/MineCode IDE.app/Main.lua +++ b/Applications/MineCode IDE.app/Main.lua @@ -111,24 +111,11 @@ codeView.draw = function(...) x >= codeView.codeAreaPosition + 1 and y >= codeView.y and x <= codeView.codeAreaPosition + codeView.codeAreaWidth - 2 and - y <= codeView.y + codeView.height - 2 + y <= codeView.y + codeView.height - (codeView.horizontalScrollBar.hidden and 1 or 2) then screen.drawText(x, y, config.cursorColor, config.cursorSymbol) end end - - -- if autocompleteDatabase then - -- local w = 30 - -- local x, y = codeView.x + codeView.width - w, codeView.y - -- screen.drawRectangle(x, y, w, codeView.height, 0x0, 0xFFFFFF, " ") - -- for key, value in pairs(autocompleteDatabase) do - -- screen.drawText(x + 1, y, 0xFFFFFF, key .. ": " .. value) - -- y = y + 1 - -- if y > codeView.y + codeView.height - 1 then - -- break - -- end - -- end - -- end end local function saveConfig() @@ -408,10 +395,11 @@ local function addBreakpoint() end local function fixFromLineByCursorPosition() + local offset = codeView.horizontalScrollBar.hidden and 1 or 2 if codeView.fromLine > cursorPositionLine then codeView.fromLine = cursorPositionLine - elseif codeView.fromLine + codeView.height - 2 < cursorPositionLine then - codeView.fromLine = cursorPositionLine - codeView.height + 2 + elseif codeView.fromLine + codeView.height - offset < cursorPositionLine then + codeView.fromLine = cursorPositionLine - codeView.height + offset end end @@ -437,7 +425,7 @@ local function fixCursorPosition(symbol, line) symbol = lineLength + 1 end - return symbol, line + return math.floor(symbol), math.floor(line) end local function setCursorPosition(symbol, line) @@ -469,7 +457,7 @@ local function moveCursor(symbolOffset, lineOffset, ignoreHidden) newLine, newSymbol = newLine + 1, 1 end - setCursorPositionAndClearSelection(newSymbol, newLine) + setCursorPosition(newSymbol, newLine) end end end @@ -1366,9 +1354,13 @@ local function createEditOrRightClickMenu(menu) end end +local function checkScrollbar(y) + return codeView.horizontalScrollBar.hidden or y < codeView.y + codeView.height - 1 +end + local uptime = computer.uptime() codeView.eventHandler = function(workspace, object, e1, e2, e3, e4, e5) - if e1 == "touch" then + if e1 == "touch" and checkScrollbar(e4) then if e5 == 1 then createEditOrRightClickMenu(GUI.addContextMenu(workspace, e3, e4)) else @@ -1379,19 +1371,17 @@ codeView.eventHandler = function(workspace, object, e1, e2, e3, e4, e5) elseif e1 == "double_touch" then selectWord() tick(true) - elseif e1 == "drag" then - if e5 ~= 1 then - codeView.selections[1] = codeView.selections[1] or {from = {}, to = {}} - codeView.selections[1].from.symbol, codeView.selections[1].from.line = cursorPositionSymbol, cursorPositionLine - codeView.selections[1].to.symbol, codeView.selections[1].to.line = fixCursorPosition(convertScreenCoordinatesToTextPosition(e3, e4)) - - if codeView.selections[1].from.line > codeView.selections[1].to.line then - codeView.selections[1].from.line, codeView.selections[1].to.line = codeView.selections[1].to.line, codeView.selections[1].from.line + elseif e1 == "drag" and checkScrollbar(e4) then + codeView.selections[1] = codeView.selections[1] or {from = {}, to = {}} + codeView.selections[1].from.symbol, codeView.selections[1].from.line = cursorPositionSymbol, cursorPositionLine + codeView.selections[1].to.symbol, codeView.selections[1].to.line = fixCursorPosition(convertScreenCoordinatesToTextPosition(e3, e4)) + + if codeView.selections[1].from.line > codeView.selections[1].to.line then + codeView.selections[1].from.line, codeView.selections[1].to.line = codeView.selections[1].to.line, codeView.selections[1].from.line + codeView.selections[1].from.symbol, codeView.selections[1].to.symbol = codeView.selections[1].to.symbol, codeView.selections[1].from.symbol + elseif codeView.selections[1].from.line == codeView.selections[1].to.line then + if codeView.selections[1].from.symbol > codeView.selections[1].to.symbol then codeView.selections[1].from.symbol, codeView.selections[1].to.symbol = codeView.selections[1].to.symbol, codeView.selections[1].from.symbol - elseif codeView.selections[1].from.line == codeView.selections[1].to.line then - if codeView.selections[1].from.symbol > codeView.selections[1].to.symbol then - codeView.selections[1].from.symbol, codeView.selections[1].to.symbol = codeView.selections[1].to.symbol, codeView.selections[1].from.symbol - end end end @@ -1753,17 +1743,17 @@ end propertiesContextMenu:addSeparator() -propertiesContextMenu:addItem(config.syntaxHighlight and localization.disableSyntaxHighlight or localization.enableSyntaxHighlight).onTouch = function() +propertiesContextMenu:addItem(localization.toggleSyntaxHighlight).onTouch = function() syntaxHighlightingButton.pressed = not syntaxHighlightingButton.pressed syntaxHighlightingButton.onTouch() end -propertiesContextMenu:addItem(config.enableAutoBrackets and localization.disableAutoBrackets or localization.enableAutoBrackets, false, "^]").onTouch = function() +propertiesContextMenu:addItem(localization.toggleAutoBrackets, false, "^]").onTouch = function() config.enableAutoBrackets = not config.enableAutoBrackets saveConfig() end -propertiesContextMenu:addItem(config.enableAutocompletion and localization.disableAutocompletion or localization.enableAutocompletion, false, "^I").onTouch = function() +propertiesContextMenu:addItem(localization.toggleAutocompletion, false, "^I").onTouch = function() toggleEnableAutocompleteDatabase() end diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index 4973e636..72e00939 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -979,55 +979,66 @@ end -------------------------------------------------------------------------------- local function codeViewDraw(codeView) - local toLine, colorScheme, patterns = codeView.fromLine + codeView.height - 1, codeView.syntaxColorScheme, codeView.syntaxPatterns + local y, toLine, colorScheme, patterns = codeView.y, codeView.fromLine + codeView.height - 1, codeView.syntaxColorScheme, codeView.syntaxPatterns + -- Line numbers bar and code area codeView.lineNumbersWidth = unicode.len(tostring(toLine)) + 2 codeView.codeAreaPosition = codeView.x + codeView.lineNumbersWidth codeView.codeAreaWidth = codeView.width - codeView.lineNumbersWidth + -- Line numbers - screen.drawRectangle(codeView.x, codeView.y, codeView.lineNumbersWidth, codeView.height, colorScheme.lineNumbersBackground, colorScheme.lineNumbersText, " ") + screen.drawRectangle(codeView.x, y, codeView.lineNumbersWidth, codeView.height, colorScheme.lineNumbersBackground, colorScheme.lineNumbersText, " ") + -- Background - screen.drawRectangle(codeView.codeAreaPosition, codeView.y, codeView.codeAreaWidth, codeView.height, colorScheme.background, colorScheme.text, " ") + screen.drawRectangle(codeView.codeAreaPosition, y, codeView.codeAreaWidth, codeView.height, colorScheme.background, colorScheme.text, " ") + -- Line numbers texts - local y = codeView.y + local text for line = codeView.fromLine, toLine do if codeView.lines[line] then - local text = tostring(line) + text = line .. "" if codeView.highlights[line] then screen.drawRectangle(codeView.x, y, codeView.lineNumbersWidth, 1, codeView.highlights[line], colorScheme.text, " ", 0.3) screen.drawRectangle(codeView.codeAreaPosition, y, codeView.codeAreaWidth, 1, codeView.highlights[line], colorScheme.text, " ") end + screen.drawText(codeView.codeAreaPosition - unicode.len(text) - 1, y, colorScheme.lineNumbersText, text) + y = y + 1 else break end end - - local function drawUpperSelection(y, selectionIndex) - screen.drawRectangle( - codeView.codeAreaPosition + codeView.selections[selectionIndex].from.symbol - codeView.fromSymbol + 1, - y + codeView.selections[selectionIndex].from.line - codeView.fromLine, - codeView.codeAreaWidth - codeView.selections[selectionIndex].from.symbol + codeView.fromSymbol - 1, - 1, - codeView.selections[selectionIndex].color or colorScheme.selection, colorScheme.text, " " - ) - end - - local function drawLowerSelection(y, selectionIndex) - screen.drawRectangle( - codeView.codeAreaPosition, - y + codeView.selections[selectionIndex].from.line - codeView.fromLine, - codeView.selections[selectionIndex].to.symbol - codeView.fromSymbol + 2, - 1, - codeView.selections[selectionIndex].color or colorScheme.selection, colorScheme.text, " " - ) - end - + if #codeView.selections > 0 then + local function drawUpperSelection(y, selectionIndex) + screen.drawRectangle( + math.max(codeView.codeAreaPosition, codeView.codeAreaPosition + codeView.selections[selectionIndex].from.symbol - codeView.fromSymbol + 1), + y + codeView.selections[selectionIndex].from.line - codeView.fromLine, + codeView.codeAreaWidth - codeView.selections[selectionIndex].from.symbol + codeView.fromSymbol - 1, + 1, + codeView.selections[selectionIndex].color or colorScheme.selection, + colorScheme.text, + " " + ) + end + + local function drawLowerSelection(y, selectionIndex) + screen.drawRectangle( + codeView.codeAreaPosition, + y + codeView.selections[selectionIndex].from.line - codeView.fromLine, + codeView.selections[selectionIndex].to.symbol - codeView.fromSymbol + 2, + 1, + codeView.selections[selectionIndex].color or colorScheme.selection, + colorScheme.text, + " " + ) + end + for selectionIndex = 1, #codeView.selections do y = codeView.y local dy = codeView.selections[selectionIndex].to.line - codeView.selections[selectionIndex].from.line + if dy == 0 then screen.drawRectangle( codeView.codeAreaPosition + codeView.selections[selectionIndex].from.symbol - codeView.fromSymbol + 1, @@ -1037,12 +1048,26 @@ local function codeViewDraw(codeView) codeView.selections[selectionIndex].color or colorScheme.selection, colorScheme.text, " " ) elseif dy == 1 then - drawUpperSelection(y, selectionIndex); y = y + 1 + drawUpperSelection(y, selectionIndex) + y = y + 1 + drawLowerSelection(y, selectionIndex) else - drawUpperSelection(y, selectionIndex); y = y + 1 + drawUpperSelection(y, selectionIndex) + y = y + 1 + for i = 1, dy - 1 do - screen.drawRectangle(codeView.codeAreaPosition, y + codeView.selections[selectionIndex].from.line - codeView.fromLine, codeView.codeAreaWidth, 1, codeView.selections[selectionIndex].color or colorScheme.selection, colorScheme.text, " "); y = y + 1 + screen.drawRectangle( + codeView.codeAreaPosition, + y + codeView.selections[selectionIndex].from.line - codeView.fromLine, + codeView.codeAreaWidth, + 1, + codeView.selections[selectionIndex].color or colorScheme.selection, + colorScheme.text, + " " + ) + + y = y + 1 end drawLowerSelection(y, selectionIndex) @@ -1052,7 +1077,6 @@ local function codeViewDraw(codeView) -- Code strings y = codeView.y - for i = codeView.fromLine, toLine do if codeView.lines[i] then if codeView.syntaxHighlight then @@ -1066,7 +1090,16 @@ local function codeViewDraw(codeView) codeView.lines[i] ) else - screen.drawText(codeView.codeAreaPosition - codeView.fromSymbol + 2, y, colorScheme.text, codeView.lines[i]) + screen.drawText( + codeView.codeAreaPosition + 1, + y, + colorScheme.text, + unicode.sub( + codeView.lines[i], + codeView.fromSymbol, + codeView.fromSymbol + codeView.codeAreaWidth - 3 + ) + ) end y = y + 1 @@ -1075,6 +1108,7 @@ local function codeViewDraw(codeView) end end + -- Scrollbars if #codeView.lines > codeView.height then codeView.verticalScrollBar.colors.background, codeView.verticalScrollBar.colors.foreground = colorScheme.scrollBarBackground, colorScheme.scrollBarForeground codeView.verticalScrollBar.minimumValue, codeView.verticalScrollBar.maximumValue, codeView.verticalScrollBar.value, codeView.verticalScrollBar.shownValueCount = 1, #codeView.lines, codeView.fromLine, codeView.height @@ -3690,9 +3724,13 @@ function GUI.highlightString(x, y, fromChar, indentationWidth, patterns, colorSc x = x1 end - local toChar, endX = stringLength, x + stringLength - 1 - if endX > x2 then - toChar = toChar - endX + x2 + -- local toChar, endX = stringLength, x + stringLength - 1 + -- if endX > x2 then + -- toChar = toChar - endX + x2 + -- end + local toChar = fromChar + x2 - x + if toChar > stringLength then + toChar = stringLength end local counter, symbols, colors, bufferIndex, newFrameBackgrounds, newFrameForegrounds, newFrameSymbols, searchFrom, starting, ending = indentationWidth, {}, {}, screen.getIndex(x, y), screen.getNewFrameTables() diff --git a/Screensavers/Space.lua b/Screensavers/Space.lua index 2853d578..f4bc616a 100755 --- a/Screensavers/Space.lua +++ b/Screensavers/Space.lua @@ -1,8 +1,10 @@ -local screen = require("Screen") +-- This's a copy-paste of orignal software from https://github.com/Maxu5/ ------------------------------------------------------------------------------------- +local screen = require("Screen") + local starAmount, colors, copyright, braille1, braille2, braille3, braille4, braille5, braille6, braille7, braille8, braille9, braille10 = 200, { @@ -28,19 +30,13 @@ local starAmount, colors, copyright, braille1, braille2, braille3, braille4, bra "⠁", "⠈", "⠂", "⠐", "⠄", "⠠", "⡀", "⢀", "⠛", "⣤" -- Faster access without tables indexing -local computerPullSignal, tableRemove, mathSin, mathCos, mathRandom, screenDrawRectangle, screenSet, screenUpdate, screenGetIndex = +local computerPullSignal, tableRemove, mathSin, mathCos, mathRandom, screenUpdate = computer.pullSignal, table.remove, math.sin, math.cos, math.random, - screen.drawRectangle, - screen.set, - screen.update, - screen.getIndex - --- Other variables, nil by default -local stars, i, star, rotationAngle, targetX, targetY, startWay, x, y, xmod, ymod, prevX, prevY, signalType, screenIndex, color = {} + screen.update -- Screen resolution in pixels local screenWidth, screenHeight = screen.getResolution() @@ -63,6 +59,9 @@ for i = 1, screenTablesLength do newFrameBackgrounds[i], newFrameForegrounds[i], newFrameSymbols[i] = 0x0, 0x0, " " end +-- Other variables, nil by default +local stars, i, star, rotationAngle, targetX, targetY, startWay, x, y, xmod, ymod, prevX, prevY, signalType, screenIndex, color = {} + -- Main loop while true do -- Spawing stars