drag fix and fixed settings for compat so now we have autocomplete in the terminal hooray, and a better wallpaper (imo)
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
0000000000000055555555d0000000000000000000000000000
|
||||
00000000055555d00555555d000000000000000000000000000
|
||||
000000005555555d00055555d00000000000000000000000000
|
||||
0000000055555555d05055555d3d30000000000000033300000
|
||||
00000000055555555d05555555d3d3000000000003333300000
|
||||
30000000300055555555d555555d3d333333303333333333330
|
||||
000000000000000000000000000000000000000000000000000
|
||||
00000000000555d0000000000555d0000000000000000000000
|
||||
000000000005555dd05050505555d0000000000000000000000
|
||||
00000000000055555d050555555d00000000000000033300000
|
||||
000000000005055555d5555555d0d3300000000000333330000
|
||||
30000000300055555555d555555d3d333333303333333333300
|
||||
3303333333353555555d5d555555d3333033333333330330000
|
||||
033330303035355555555555555d3d333033033033333300000
|
||||
003030333333555ffff555ffff55d3303333333333303300007
|
||||
0033333033035555555555555555d3333303330330333000877
|
||||
78830333333535555555f555555d3d303333333333037787787
|
||||
78830333333535555555f55555dd3d303333333333037787778
|
||||
87844bb0b0bb55b5555555555dbddbbbbbb0bbbb44407878887
|
||||
0780044bbbb0bb5b55555555dbdbb0b0bbbbbb4440778888877
|
||||
7870040b0b0bbbbb55555555dbbbbbbb0bb0b44407888808788
|
||||
78080044bbbbb0bb55555555db0bb0bb0bbbb40077870878087
|
||||
78788004bbb0bbb5555555555dbbbbbbbbbb440078788887787
|
||||
778788004b0bbbb5555555555dbbbb0bbb04408878888088777
|
||||
777888004bbbbb555555555555dbbbbbbbb4008878088878877
|
||||
0780044bbbb0bb5b55556555dbdbb0b0bbbbbb4440778888887
|
||||
7870040b0b0bbbbb55556555dbbbbbbb0bb0b44407888808788
|
||||
78080044bbbbb0bb55556555db0bb0bb0bbbb40077870878078
|
||||
78788004bbb0bbb5555555555dbbbbbbbbbb440078788887887
|
||||
778788004b0bbbb5555555555dbbbb0bbb04408878888088787
|
||||
777888004bbbbb555555555555dbbbbbbbb4008878088878878
|
||||
|
||||
200
libs/compat.lua
200
libs/compat.lua
@@ -99,8 +99,97 @@ function lib.setupENV(win)
|
||||
term[k] = wrap(k)
|
||||
end
|
||||
end
|
||||
term.redirect(win)
|
||||
local function read(_sReplaceChar, _tHistory, _fnComplete, _sDefault)
|
||||
|
||||
function write(sText)
|
||||
expect(1, sText, "string", "number")
|
||||
|
||||
local w, h = term.getSize()
|
||||
local x, y = term.getCursorPos()
|
||||
|
||||
local nLinesPrinted = 0
|
||||
local function newLine()
|
||||
if y + 1 <= h then
|
||||
term.setCursorPos(1, y + 1)
|
||||
else
|
||||
term.setCursorPos(1, h)
|
||||
term.scroll(1)
|
||||
end
|
||||
x, y = term.getCursorPos()
|
||||
nLinesPrinted = nLinesPrinted + 1
|
||||
end
|
||||
|
||||
-- Print the line with proper word wrapping
|
||||
sText = tostring(sText)
|
||||
while #sText > 0 do
|
||||
local whitespace = string.match(sText, "^[ \t]+")
|
||||
if whitespace then
|
||||
-- Print whitespace
|
||||
term.write(whitespace)
|
||||
x, y = term.getCursorPos()
|
||||
sText = string.sub(sText, #whitespace + 1)
|
||||
end
|
||||
|
||||
local newline = string.match(sText, "^\n")
|
||||
if newline then
|
||||
-- Print newlines
|
||||
newLine()
|
||||
sText = string.sub(sText, 2)
|
||||
end
|
||||
|
||||
local text = string.match(sText, "^[^ \t\n]+")
|
||||
if text then
|
||||
sText = string.sub(sText, #text + 1)
|
||||
if #text > w then
|
||||
-- Print a multiline word
|
||||
while #text > 0 do
|
||||
if x > w then
|
||||
newLine()
|
||||
end
|
||||
term.write(text)
|
||||
text = string.sub(text, w - x + 2)
|
||||
x, y = term.getCursorPos()
|
||||
end
|
||||
else
|
||||
-- Print a word normally
|
||||
if x + #text - 1 > w then
|
||||
newLine()
|
||||
end
|
||||
term.write(text)
|
||||
x, y = term.getCursorPos()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nLinesPrinted
|
||||
end
|
||||
|
||||
function print(...)
|
||||
local nLinesPrinted = 0
|
||||
local nLimit = select("#", ...)
|
||||
for n = 1, nLimit do
|
||||
local s = tostring(select(n, ...))
|
||||
if n < nLimit then
|
||||
s = s .. "\t"
|
||||
end
|
||||
nLinesPrinted = nLinesPrinted + write(s)
|
||||
end
|
||||
nLinesPrinted = nLinesPrinted + write("\n")
|
||||
return nLinesPrinted
|
||||
end
|
||||
|
||||
function printError(...)
|
||||
local oldColour
|
||||
if term.isColour() then
|
||||
oldColour = term.getTextColour()
|
||||
term.setTextColour(colors.red)
|
||||
end
|
||||
print(...)
|
||||
if term.isColour() then
|
||||
term.setTextColour(oldColour)
|
||||
end
|
||||
end
|
||||
|
||||
function read(_sReplaceChar, _tHistory, _fnComplete, _sDefault)
|
||||
expect(1, _sReplaceChar, "string", "nil")
|
||||
expect(2, _tHistory, "table", "nil")
|
||||
expect(3, _fnComplete, "function", "nil")
|
||||
@@ -217,6 +306,7 @@ function lib.setupENV(win)
|
||||
nPos = nPos + 1
|
||||
recomplete()
|
||||
redraw()
|
||||
|
||||
elseif sEvent == "paste" then
|
||||
-- Pasted text
|
||||
clear()
|
||||
@@ -224,6 +314,7 @@ function lib.setupENV(win)
|
||||
nPos = nPos + #param
|
||||
recomplete()
|
||||
redraw()
|
||||
|
||||
elseif sEvent == "key" then
|
||||
if param == keys.enter or param == keys.numPadEnter then
|
||||
-- Enter/Numpad Enter
|
||||
@@ -233,6 +324,7 @@ function lib.setupENV(win)
|
||||
redraw()
|
||||
end
|
||||
break
|
||||
|
||||
elseif param == keys.left then
|
||||
-- Left
|
||||
if nPos > 0 then
|
||||
@@ -241,6 +333,7 @@ function lib.setupENV(win)
|
||||
recomplete()
|
||||
redraw()
|
||||
end
|
||||
|
||||
elseif param == keys.right then
|
||||
-- Right
|
||||
if nPos < #sLine then
|
||||
@@ -253,6 +346,7 @@ function lib.setupENV(win)
|
||||
-- Accept autocomplete
|
||||
acceptCompletion()
|
||||
end
|
||||
|
||||
elseif param == keys.up or param == keys.down then
|
||||
-- Up or down
|
||||
if nCompletion then
|
||||
@@ -270,6 +364,7 @@ function lib.setupENV(win)
|
||||
end
|
||||
end
|
||||
redraw()
|
||||
|
||||
elseif _tHistory then
|
||||
-- Cycle history
|
||||
clear()
|
||||
@@ -299,7 +394,9 @@ function lib.setupENV(win)
|
||||
end
|
||||
uncomplete()
|
||||
redraw()
|
||||
|
||||
end
|
||||
|
||||
elseif param == keys.backspace then
|
||||
-- Backspace
|
||||
if nPos > 0 then
|
||||
@@ -310,6 +407,7 @@ function lib.setupENV(win)
|
||||
recomplete()
|
||||
redraw()
|
||||
end
|
||||
|
||||
elseif param == keys.home then
|
||||
-- Home
|
||||
if nPos > 0 then
|
||||
@@ -318,6 +416,7 @@ function lib.setupENV(win)
|
||||
recomplete()
|
||||
redraw()
|
||||
end
|
||||
|
||||
elseif param == keys.delete then
|
||||
-- Delete
|
||||
if nPos < #sLine then
|
||||
@@ -326,6 +425,7 @@ function lib.setupENV(win)
|
||||
recomplete()
|
||||
redraw()
|
||||
end
|
||||
|
||||
elseif param == keys["end"] then
|
||||
-- End
|
||||
if nPos < #sLine then
|
||||
@@ -334,10 +434,13 @@ function lib.setupENV(win)
|
||||
recomplete()
|
||||
redraw()
|
||||
end
|
||||
|
||||
elseif param == keys.tab then
|
||||
-- Tab (accept autocomplete)
|
||||
acceptCompletion()
|
||||
|
||||
end
|
||||
|
||||
elseif sEvent == "mouse_click" or sEvent == "mouse_drag" and param == 1 then
|
||||
local _, cy = term.getCursorPos()
|
||||
if param1 >= sx and param1 <= w and param2 == cy then
|
||||
@@ -345,10 +448,12 @@ function lib.setupENV(win)
|
||||
nPos = math.min(math.max(nScroll + param1 - sx, 0), #sLine)
|
||||
redraw()
|
||||
end
|
||||
|
||||
elseif sEvent == "term_resize" then
|
||||
-- Terminal resized
|
||||
w = term.getSize()
|
||||
redraw()
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -360,94 +465,6 @@ function lib.setupENV(win)
|
||||
return sLine
|
||||
end
|
||||
|
||||
|
||||
local function write(sText)
|
||||
expect(1, sText, "string", "number")
|
||||
|
||||
local w, h = term.getSize()
|
||||
local x, y = term.getCursorPos()
|
||||
|
||||
local nLinesPrinted = 0
|
||||
local function newLine()
|
||||
if y + 1 <= h then
|
||||
term.setCursorPos(1, y + 1)
|
||||
else
|
||||
term.setCursorPos(1, h)
|
||||
term.scroll(1)
|
||||
end
|
||||
x, y = term.getCursorPos()
|
||||
nLinesPrinted = nLinesPrinted + 1
|
||||
end
|
||||
|
||||
-- Print the line with proper word wrapping
|
||||
sText = tostring(sText)
|
||||
while #sText > 0 do
|
||||
local whitespace = string.match(sText, "^[ \t]+")
|
||||
if whitespace then
|
||||
-- Print whitespace
|
||||
term.write(whitespace)
|
||||
x, y = term.getCursorPos()
|
||||
sText = string.sub(sText, #whitespace + 1)
|
||||
end
|
||||
|
||||
local newline = string.match(sText, "^\n")
|
||||
if newline then
|
||||
-- Print newlines
|
||||
newLine()
|
||||
sText = string.sub(sText, 2)
|
||||
end
|
||||
|
||||
local text = string.match(sText, "^[^ \t\n]+")
|
||||
if text then
|
||||
sText = string.sub(sText, #text + 1)
|
||||
if #text > w then
|
||||
-- Print a multiline word
|
||||
while #text > 0 do
|
||||
if x > w then
|
||||
newLine()
|
||||
end
|
||||
term.write(text)
|
||||
text = string.sub(text, w - x + 2)
|
||||
x, y = term.getCursorPos()
|
||||
end
|
||||
else
|
||||
-- Print a word normally
|
||||
if x + #text - 1 > w then
|
||||
newLine()
|
||||
end
|
||||
term.write(text)
|
||||
x, y = term.getCursorPos()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nLinesPrinted
|
||||
end
|
||||
function print(...)
|
||||
local nLinesPrinted = 0
|
||||
local nLimit = select("#", ...)
|
||||
for n = 1, nLimit do
|
||||
local s = tostring(select(n, ...))
|
||||
if n < nLimit then
|
||||
s = s .. "\t"
|
||||
end
|
||||
nLinesPrinted = nLinesPrinted + write(s)
|
||||
end
|
||||
nLinesPrinted = nLinesPrinted + write("\n")
|
||||
return nLinesPrinted
|
||||
end
|
||||
|
||||
local function printError(...)
|
||||
local oldColour
|
||||
if term.isColour() then
|
||||
oldColour = term.getTextColour()
|
||||
term.setTextColour(colors.red)
|
||||
end
|
||||
print(...)
|
||||
if term.isColour() then
|
||||
term.setTextColour(oldColour)
|
||||
end
|
||||
end
|
||||
local tAPIsLoading = {}
|
||||
|
||||
local bAPIError = false
|
||||
@@ -521,9 +538,10 @@ function lib.setupENV(win)
|
||||
if turtle then load_apis("rom/apis/turtle") end
|
||||
if pocket then load_apis("rom/apis/pocket") end
|
||||
env.shell = shell
|
||||
env.settings = settings
|
||||
env._ENV = env
|
||||
env._G = env
|
||||
|
||||
term.redirect(win)
|
||||
return env
|
||||
end
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ while true do
|
||||
dragging = win
|
||||
resizing = true
|
||||
bringtofront(indx)
|
||||
elseif ((win.y - 1 == data[4] and win.x + 1 <= data[3] and win.x + win.w >= data[3] and data[2] == 1 and win.decorations) or (win.y <= data[4] and win.x <= data[3] and win.y + win.h > data[4] and win.x + win.w > data[3] and key[keys["leftAlt"] and win.draggable])) then
|
||||
elseif ((win.y - 1 == data[4] and win.x + 1 <= data[3] and win.x + win.w >= data[3] and data[2] == 1 and win.decorations) or (win.y <= data[4] and win.x <= data[3] and win.y + win.h > data[4] and win.x + win.w > data[3] and key[keys["leftAlt"]] and win.draggable)) then
|
||||
dragging = win
|
||||
offsetX = win.x - data[3]
|
||||
offsetY = win.y - data[4]
|
||||
@@ -63,7 +63,7 @@ while true do
|
||||
threading.addThread(function()dragging.resized(dragging.w,dragging.h)end)
|
||||
else
|
||||
dragging.x = data[3] + offsetX
|
||||
dragging.y = data[4] + offsetY
|
||||
dragging.y = math.max(data[4] + offsetY,3)
|
||||
end
|
||||
else
|
||||
for indx = #_G.windows, 1, -1 do
|
||||
|
||||
Reference in New Issue
Block a user