mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Fixed screen buffer overlap for syntax highlighting
This commit is contained in:
parent
5b2e4b2a11
commit
628e9f4012
@ -28,7 +28,7 @@ module.onTouch = function()
|
||||
if text == placeholder then
|
||||
screen.drawText(x, y, color, text)
|
||||
else
|
||||
GUI.highlightString(x, y, input.width - 2, 1, 2, GUI.LUA_SYNTAX_PATTERNS, GUI.LUA_SYNTAX_COLOR_SCHEME, text)
|
||||
GUI.highlightString(x, y, 1, 2, GUI.LUA_SYNTAX_PATTERNS, GUI.LUA_SYNTAX_COLOR_SCHEME, text)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ input.historyEnabled = true
|
||||
-- if text == input.placeholderText then
|
||||
-- screen.drawText(x, y, color, text)
|
||||
-- else
|
||||
-- GUI.highlightString(x, y, input.width - 2, 1, 2, GUI.LUA_SYNTAX_PATTERNS, GUI.LUA_SYNTAX_COLOR_SCHEME, text)
|
||||
-- GUI.highlightString(x, y, 1, 2, GUI.LUA_SYNTAX_PATTERNS, GUI.LUA_SYNTAX_COLOR_SCHEME, text)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
@ -1024,9 +1024,6 @@ local function codeViewDraw(codeView)
|
||||
)
|
||||
end
|
||||
|
||||
local oldDrawLimitX1, oldDrawLimitY1, oldDrawLimitX2, oldDrawLimitY2 = screen.getDrawLimit()
|
||||
screen.setDrawLimit(codeView.codeAreaPosition, codeView.y, codeView.codeAreaPosition + codeView.codeAreaWidth - 1, codeView.y + codeView.height - 1)
|
||||
|
||||
if #codeView.selections > 0 then
|
||||
for selectionIndex = 1, #codeView.selections do
|
||||
y = codeView.y
|
||||
@ -1055,14 +1052,13 @@ local function codeViewDraw(codeView)
|
||||
|
||||
-- Code strings
|
||||
y = codeView.y
|
||||
screen.setDrawLimit(codeView.codeAreaPosition + 1, y, codeView.codeAreaPosition + codeView.codeAreaWidth - 2, y + codeView.height - 1)
|
||||
|
||||
for i = codeView.fromLine, toLine do
|
||||
if codeView.lines[i] then
|
||||
if codeView.syntaxHighlight then
|
||||
GUI.highlightString(codeView.codeAreaPosition + 1,
|
||||
GUI.highlightString(
|
||||
codeView.codeAreaPosition + 1,
|
||||
y,
|
||||
codeView.codeAreaWidth - 2,
|
||||
codeView.fromSymbol,
|
||||
codeView.indentationWidth,
|
||||
patterns,
|
||||
@ -1079,8 +1075,6 @@ local function codeViewDraw(codeView)
|
||||
end
|
||||
end
|
||||
|
||||
screen.setDrawLimit(oldDrawLimitX1, oldDrawLimitY1, oldDrawLimitX2, oldDrawLimitY2)
|
||||
|
||||
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
|
||||
@ -3687,11 +3681,21 @@ end
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
function GUI.highlightString(x, y, width, fromChar, indentationWidth, patterns, colorScheme, s)
|
||||
fromChar = fromChar or 1
|
||||
function GUI.highlightString(x, y, fromChar, indentationWidth, patterns, colorScheme, s)
|
||||
local stringLength, x1, y1, x2, y2 = unicode.len(s), screen.getDrawLimit()
|
||||
|
||||
local counter, symbols, colors, stringLength, bufferIndex, newFrameBackgrounds, newFrameForegrounds, newFrameSymbols, searchFrom, starting, ending = indentationWidth, {}, {}, unicode.len(s), screen.getIndex(x, y), screen.getNewFrameTables()
|
||||
local toChar = math.min(stringLength, fromChar + width - 1)
|
||||
fromChar = fromChar or 1
|
||||
if x < x1 then
|
||||
fromChar = fromChar + x1 - x
|
||||
x = x1
|
||||
end
|
||||
|
||||
local toChar, endX = stringLength, x + stringLength - 1
|
||||
if endX > x2 then
|
||||
toChar = toChar - endX + x2
|
||||
end
|
||||
|
||||
local counter, symbols, colors, bufferIndex, newFrameBackgrounds, newFrameForegrounds, newFrameSymbols, searchFrom, starting, ending = indentationWidth, {}, {}, screen.getIndex(x, y), screen.getNewFrameTables()
|
||||
|
||||
-- Пидорасим на символы
|
||||
for i = fromChar, toChar do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user