mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-09-14 11:06:16 +05:00
aefaef
This commit is contained in:
parent
70337c2a2d
commit
1c5bb3f442
@ -300,7 +300,7 @@
|
||||
name="lib/GUI.lua",
|
||||
url="IgorTimofeev/OpenComputers/master/lib/GUI.lua",
|
||||
type="Library",
|
||||
version=1.39,
|
||||
version=1.40,
|
||||
},
|
||||
{
|
||||
name="lib/windows.lua",
|
||||
@ -360,7 +360,7 @@
|
||||
name="lib/syntax.lua",
|
||||
url="IgorTimofeev/OpenComputers/master/lib/syntax.lua",
|
||||
type="Library",
|
||||
version=1.09,
|
||||
version=1.10,
|
||||
},
|
||||
{
|
||||
name="lib/palette.lua",
|
||||
@ -517,7 +517,7 @@
|
||||
icon="IgorTimofeev/OpenComputers/master/Applications/MineCodeIDE/Icon.pic",
|
||||
createShortcut="dock",
|
||||
forceDownload=true,
|
||||
version=1.48,
|
||||
version=1.49,
|
||||
resources={
|
||||
{
|
||||
name="Localization/Russian.lang",
|
||||
|
||||
BIN
Applications/.DS_Store
vendored
BIN
Applications/.DS_Store
vendored
Binary file not shown.
@ -1,4 +1,6 @@
|
||||
{
|
||||
enableAutoBrackets = "Enable autobrackets",
|
||||
disableAutoBrackets = "Disable autobrackets",
|
||||
url = "http://example.com/something.lua",
|
||||
getFromWeb = "Download from URL",
|
||||
debugging = "Debugger on line ",
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
{
|
||||
enableAutoBrackets = "Включить авто-скобки",
|
||||
disableAutoBrackets = "Отключить авто-скобки",
|
||||
url = "http://example.com/something.lua",
|
||||
getFromWeb = "Загрузить по URL",
|
||||
debugging = "Отладчик на строке ",
|
||||
|
||||
@ -57,7 +57,7 @@ local config = {
|
||||
cursorBlinkDelay = 0.5,
|
||||
doubleClickDelay = 0.4,
|
||||
screenScale = 1,
|
||||
enableAutoBrackets = true
|
||||
enableAutoBrackets = true,
|
||||
}
|
||||
|
||||
local colors = {
|
||||
@ -95,9 +95,20 @@ local colors = {
|
||||
}
|
||||
|
||||
local possibleBrackets = {
|
||||
["{"] = "}",
|
||||
["["] = "]",
|
||||
["("] = ")",
|
||||
openers = {
|
||||
["{"] = "}",
|
||||
["["] = "]",
|
||||
["("] = ")",
|
||||
["\""] = "\"",
|
||||
["\'"] = "\'"
|
||||
},
|
||||
closers = {
|
||||
["}"] = "{",
|
||||
["]"] = "[",
|
||||
[")"] = "(",
|
||||
["\""] = "\"",
|
||||
["\'"] = "\'"
|
||||
}
|
||||
}
|
||||
|
||||
local cursor = {
|
||||
@ -734,17 +745,62 @@ local function paste(pasteLines)
|
||||
end
|
||||
end
|
||||
|
||||
local function pasteAutoBrackets(firstSymbol, secondSymbol)
|
||||
if config.enableAutoBrackets then
|
||||
paste({firstSymbol .. secondSymbol})
|
||||
setCursorPosition(cursor.position.symbol - 1, cursor.position.line)
|
||||
else
|
||||
paste({firstSymbol})
|
||||
local function pasteRegularChar(unicodeByte, char)
|
||||
if not keyboard.isControl(unicodeByte) then
|
||||
deleteSelectedData()
|
||||
paste({char})
|
||||
end
|
||||
end
|
||||
|
||||
local function backspaceAutoBrackets()
|
||||
if config.enableAutoBrackets and unicode.sub(mainWindow.codeView.lines[cursor.position.line], cursor.position.symbol - 1, cursor.position.symbol - 1):match("[%{%[%(]") then
|
||||
local function pasteAutoBrackets(unicodeByte)
|
||||
local char = unicode.char(unicodeByte)
|
||||
local currentSymbol = unicode.sub(mainWindow.codeView.lines[cursor.position.line], cursor.position.symbol, cursor.position.symbol)
|
||||
|
||||
-- Если у нас вообще врублен режим автоскобок, то чекаем их
|
||||
if config.enableAutoBrackets then
|
||||
-- Ситуация, когда курсор находится на закрывающей скобке, и нехуй ее еще раз вставлять
|
||||
if possibleBrackets.closers[char] and currentSymbol == char then
|
||||
deleteSelectedData()
|
||||
setCursorPosition(cursor.position.symbol + 1, cursor.position.line)
|
||||
-- Если нажата открывающая скобка
|
||||
elseif possibleBrackets.openers[char] then
|
||||
-- А вот тут мы берем в скобочки уже выделенный текст
|
||||
if mainWindow.codeView.selections[1] then
|
||||
local firstPart = unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].from.line], 1, mainWindow.codeView.selections[1].from.symbol - 1)
|
||||
local secondPart = unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].from.line], mainWindow.codeView.selections[1].from.symbol, -1)
|
||||
mainWindow.codeView.lines[mainWindow.codeView.selections[1].from.line] = firstPart .. char .. secondPart
|
||||
mainWindow.codeView.selections[1].from.symbol = mainWindow.codeView.selections[1].from.symbol + 1
|
||||
|
||||
if mainWindow.codeView.selections[1].to.line == mainWindow.codeView.selections[1].from.line then
|
||||
mainWindow.codeView.selections[1].to.symbol = mainWindow.codeView.selections[1].to.symbol + 1
|
||||
end
|
||||
|
||||
firstPart = unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].to.line], 1, mainWindow.codeView.selections[1].to.symbol)
|
||||
secondPart = unicode.sub(mainWindow.codeView.lines[mainWindow.codeView.selections[1].to.line], mainWindow.codeView.selections[1].to.symbol + 1, -1)
|
||||
mainWindow.codeView.lines[mainWindow.codeView.selections[1].to.line] = firstPart .. possibleBrackets.openers[char] .. secondPart
|
||||
-- А тут мы делаем двойную автоскобку, если можем
|
||||
elseif possibleBrackets.openers[char] and not currentSymbol:match("[%a%d%_]") then
|
||||
paste({char .. possibleBrackets.openers[char]})
|
||||
setCursorPosition(cursor.position.symbol - 1, cursor.position.line)
|
||||
cursor.blinkState = false
|
||||
-- Ну, и если нет ни выделений, ни можем ебануть автоскобочку по регулярке
|
||||
else
|
||||
pasteRegularChar(unicodeByte, char)
|
||||
end
|
||||
-- Если мы вообще на скобку не нажимали
|
||||
else
|
||||
pasteRegularChar(unicodeByte, char)
|
||||
end
|
||||
-- Если оффнуты афтоскобки
|
||||
else
|
||||
pasteRegularChar(unicodeByte, char)
|
||||
end
|
||||
end
|
||||
|
||||
local function backspaceAutoBrackets()
|
||||
local previousSymbol = unicode.sub(mainWindow.codeView.lines[cursor.position.line], cursor.position.symbol - 1, cursor.position.symbol - 1)
|
||||
local currentSymbol = unicode.sub(mainWindow.codeView.lines[cursor.position.line], cursor.position.symbol, cursor.position.symbol)
|
||||
if config.enableAutoBrackets and possibleBrackets.openers[previousSymbol] and possibleBrackets.openers[previousSymbol] == currentSymbol then
|
||||
deleteSpecifiedData(cursor.position.symbol, cursor.position.line, cursor.position.symbol, cursor.position.line)
|
||||
end
|
||||
end
|
||||
@ -1043,7 +1099,7 @@ local function createWindow()
|
||||
deleteLine(cursor.position.line)
|
||||
end
|
||||
menu:addSeparator()
|
||||
menu:addItem(localization.selectWord, false, "^\\").onTouch = function()
|
||||
menu:addItem(localization.selectWord).onTouch = function()
|
||||
selectWord()
|
||||
end
|
||||
menu:addItem(localization.selectAll, false, "^A").onTouch = function()
|
||||
@ -1104,11 +1160,21 @@ local function createWindow()
|
||||
end
|
||||
|
||||
if mainWindow.topToolBar.isHidden then
|
||||
menu:addSeparator()
|
||||
menu:addItem(localization.toggleTopToolBar).onTouch = function()
|
||||
toggleTopToolBar()
|
||||
end
|
||||
end
|
||||
if config.enableAutoBrackets then
|
||||
menu:addItem(localization.disableAutoBrackets, false, "^]").onTouch = function()
|
||||
config.enableAutoBrackets = false
|
||||
saveConfig()
|
||||
end
|
||||
else
|
||||
menu:addItem(localization.enableAutoBrackets, false, "^]").onTouch = function()
|
||||
config.enableAutoBrackets = true
|
||||
saveConfig()
|
||||
end
|
||||
end
|
||||
|
||||
menu:addSeparator()
|
||||
menu:addItem(localization.scalePlus, false, "^+").onTouch = function()
|
||||
@ -1236,6 +1302,9 @@ local function createWindow()
|
||||
paste(clipboard)
|
||||
end
|
||||
menu:addSeparator()
|
||||
menu:addItem(localization.selectWord).onTouch = function()
|
||||
selectWord()
|
||||
end
|
||||
menu:addItem(localization.selectAll, false, "^A").onTouch = function()
|
||||
selectAll()
|
||||
end
|
||||
@ -1269,12 +1338,13 @@ local function createWindow()
|
||||
|
||||
-- Ctrl or CMD
|
||||
if keyboard.isKeyDown(29) or keyboard.isKeyDown(219) then
|
||||
-- Backslash
|
||||
if eventData[4] == 43 then
|
||||
selectWord()
|
||||
-- Slash
|
||||
elseif eventData[4] == 53 then
|
||||
if eventData[4] == 53 then
|
||||
toggleComment()
|
||||
-- ]
|
||||
elseif eventData[4] == 27 then
|
||||
config.enableAutoBrackets = not config.enableAutoBrackets
|
||||
saveConfig()
|
||||
-- A
|
||||
elseif eventData[4] == 30 then
|
||||
selectAll()
|
||||
@ -1367,14 +1437,7 @@ local function createWindow()
|
||||
elseif eventData[4] == 211 then
|
||||
delete()
|
||||
else
|
||||
local char = unicode.char(eventData[3])
|
||||
if possibleBrackets[char] then
|
||||
pasteAutoBrackets(char, possibleBrackets[char])
|
||||
cursor.blinkState = false
|
||||
elseif not keyboard.isControl(eventData[3]) then
|
||||
deleteSelectedData()
|
||||
paste({char})
|
||||
end
|
||||
pasteAutoBrackets(eventData[3])
|
||||
end
|
||||
elseif eventData[1] == "clipboard" then
|
||||
paste(splitStringIntoLines(eventData[3]))
|
||||
|
||||
@ -1525,7 +1525,7 @@ local function codeViewDraw(codeView)
|
||||
codeView.lineNumbersWidth = unicode.len(tostring(toLine)) + 2
|
||||
codeView.codeAreaPosition = codeView.x + codeView.lineNumbersWidth
|
||||
codeView.codeAreaWidth = codeView.width - codeView.lineNumbersWidth
|
||||
buffer.square(codeView.x, codeView.y, codeView.lineNumbersWidth, codeView.height, syntax.colorScheme.lineNumbers, syntax.colorScheme.lineNumbersText, " ")
|
||||
buffer.square(codeView.x, codeView.y, codeView.lineNumbersWidth, codeView.height, syntax.colorScheme.lineNumbersBackground, syntax.colorScheme.lineNumbersText, " ")
|
||||
buffer.square(codeView.codeAreaPosition, codeView.y, codeView.codeAreaWidth, codeView.height, syntax.colorScheme.background, syntax.colorScheme.text, " ")
|
||||
|
||||
-- Line numbers texts
|
||||
|
||||
@ -20,7 +20,7 @@ syntax.colorScheme = {
|
||||
numbers = 0x66DBFF,
|
||||
functions = 0xffcc66,
|
||||
compares = 0xffff98,
|
||||
lineNumbers = 0x2D2D2D,
|
||||
lineNumbersBackground = 0x2D2D2D,
|
||||
lineNumbersText = 0xCCCCCC,
|
||||
scrollBarBackground = 0x444444,
|
||||
scrollBarForeground = 0x33B6FF,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user