MineCode fixes

This commit is contained in:
Igor Timofeev 2019-02-24 12:33:55 +03:00
parent c7b62da6a8
commit 2bc0c4d1d3
9 changed files with 122 additions and 113 deletions

View File

@ -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...",

View File

@ -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...",

View File

@ -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...",

View File

@ -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...",

View File

@ -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 = "Идет загрузка файла...",

View File

@ -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 = "Отладчик на рядку",

View File

@ -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,8 +1371,7 @@ 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
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))
@ -1393,7 +1384,6 @@ codeView.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
codeView.selections[1].from.symbol, codeView.selections[1].to.symbol = codeView.selections[1].to.symbol, codeView.selections[1].from.symbol
end
end
end
tick(true)
elseif e1 == "key_down" then
@ -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

View File

@ -979,38 +979,47 @@ 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
if #codeView.selections > 0 then
local function drawUpperSelection(y, selectionIndex)
screen.drawRectangle(
codeView.codeAreaPosition + codeView.selections[selectionIndex].from.symbol - codeView.fromSymbol + 1,
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, " "
codeView.selections[selectionIndex].color or colorScheme.selection,
colorScheme.text,
" "
)
end
@ -1020,14 +1029,16 @@ local function codeViewDraw(codeView)
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, " "
codeView.selections[selectionIndex].color or colorScheme.selection,
colorScheme.text,
" "
)
end
if #codeView.selections > 0 then
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()

View File

@ -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