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
|
000000000000000000000000000000000000000000000000000
|
||||||
00000000055555d00555555d000000000000000000000000000
|
00000000000555d0000000000555d0000000000000000000000
|
||||||
000000005555555d00055555d00000000000000000000000000
|
000000000005555dd05050505555d0000000000000000000000
|
||||||
0000000055555555d05055555d3d30000000000000033300000
|
00000000000055555d050555555d00000000000000033300000
|
||||||
00000000055555555d05555555d3d3000000000003333300000
|
000000000005055555d5555555d0d3300000000000333330000
|
||||||
30000000300055555555d555555d3d333333303333333333330
|
30000000300055555555d555555d3d333333303333333333300
|
||||||
3303333333353555555d5d555555d3333033333333330330000
|
3303333333353555555d5d555555d3333033333333330330000
|
||||||
033330303035355555555555555d3d333033033033333300000
|
033330303035355555555555555d3d333033033033333300000
|
||||||
003030333333555ffff555ffff55d3303333333333303300007
|
003030333333555ffff555ffff55d3303333333333303300007
|
||||||
0033333033035555555555555555d3333303330330333000877
|
0033333033035555555555555555d3333303330330333000877
|
||||||
78830333333535555555f555555d3d303333333333037787787
|
78830333333535555555f55555dd3d303333333333037787778
|
||||||
87844bb0b0bb55b5555555555dbddbbbbbb0bbbb44407878887
|
87844bb0b0bb55b5555555555dbddbbbbbb0bbbb44407878887
|
||||||
0780044bbbb0bb5b55555555dbdbb0b0bbbbbb4440778888877
|
0780044bbbb0bb5b55556555dbdbb0b0bbbbbb4440778888887
|
||||||
7870040b0b0bbbbb55555555dbbbbbbb0bb0b44407888808788
|
7870040b0b0bbbbb55556555dbbbbbbb0bb0b44407888808788
|
||||||
78080044bbbbb0bb55555555db0bb0bb0bbbb40077870878087
|
78080044bbbbb0bb55556555db0bb0bb0bbbb40077870878078
|
||||||
78788004bbb0bbb5555555555dbbbbbbbbbb440078788887787
|
78788004bbb0bbb5555555555dbbbbbbbbbb440078788887887
|
||||||
778788004b0bbbb5555555555dbbbb0bbb04408878888088777
|
778788004b0bbbb5555555555dbbbb0bbb04408878888088787
|
||||||
777888004bbbbb555555555555dbbbbbbbb4008878088878877
|
777888004bbbbb555555555555dbbbbbbbb4008878088878878
|
||||||
|
|||||||
200
libs/compat.lua
200
libs/compat.lua
@@ -99,8 +99,97 @@ function lib.setupENV(win)
|
|||||||
term[k] = wrap(k)
|
term[k] = wrap(k)
|
||||||
end
|
end
|
||||||
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(1, _sReplaceChar, "string", "nil")
|
||||||
expect(2, _tHistory, "table", "nil")
|
expect(2, _tHistory, "table", "nil")
|
||||||
expect(3, _fnComplete, "function", "nil")
|
expect(3, _fnComplete, "function", "nil")
|
||||||
@@ -217,6 +306,7 @@ function lib.setupENV(win)
|
|||||||
nPos = nPos + 1
|
nPos = nPos + 1
|
||||||
recomplete()
|
recomplete()
|
||||||
redraw()
|
redraw()
|
||||||
|
|
||||||
elseif sEvent == "paste" then
|
elseif sEvent == "paste" then
|
||||||
-- Pasted text
|
-- Pasted text
|
||||||
clear()
|
clear()
|
||||||
@@ -224,6 +314,7 @@ function lib.setupENV(win)
|
|||||||
nPos = nPos + #param
|
nPos = nPos + #param
|
||||||
recomplete()
|
recomplete()
|
||||||
redraw()
|
redraw()
|
||||||
|
|
||||||
elseif sEvent == "key" then
|
elseif sEvent == "key" then
|
||||||
if param == keys.enter or param == keys.numPadEnter then
|
if param == keys.enter or param == keys.numPadEnter then
|
||||||
-- Enter/Numpad Enter
|
-- Enter/Numpad Enter
|
||||||
@@ -233,6 +324,7 @@ function lib.setupENV(win)
|
|||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
break
|
break
|
||||||
|
|
||||||
elseif param == keys.left then
|
elseif param == keys.left then
|
||||||
-- Left
|
-- Left
|
||||||
if nPos > 0 then
|
if nPos > 0 then
|
||||||
@@ -241,6 +333,7 @@ function lib.setupENV(win)
|
|||||||
recomplete()
|
recomplete()
|
||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif param == keys.right then
|
elseif param == keys.right then
|
||||||
-- Right
|
-- Right
|
||||||
if nPos < #sLine then
|
if nPos < #sLine then
|
||||||
@@ -253,6 +346,7 @@ function lib.setupENV(win)
|
|||||||
-- Accept autocomplete
|
-- Accept autocomplete
|
||||||
acceptCompletion()
|
acceptCompletion()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif param == keys.up or param == keys.down then
|
elseif param == keys.up or param == keys.down then
|
||||||
-- Up or down
|
-- Up or down
|
||||||
if nCompletion then
|
if nCompletion then
|
||||||
@@ -270,6 +364,7 @@ function lib.setupENV(win)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
redraw()
|
redraw()
|
||||||
|
|
||||||
elseif _tHistory then
|
elseif _tHistory then
|
||||||
-- Cycle history
|
-- Cycle history
|
||||||
clear()
|
clear()
|
||||||
@@ -299,7 +394,9 @@ function lib.setupENV(win)
|
|||||||
end
|
end
|
||||||
uncomplete()
|
uncomplete()
|
||||||
redraw()
|
redraw()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif param == keys.backspace then
|
elseif param == keys.backspace then
|
||||||
-- Backspace
|
-- Backspace
|
||||||
if nPos > 0 then
|
if nPos > 0 then
|
||||||
@@ -310,6 +407,7 @@ function lib.setupENV(win)
|
|||||||
recomplete()
|
recomplete()
|
||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif param == keys.home then
|
elseif param == keys.home then
|
||||||
-- Home
|
-- Home
|
||||||
if nPos > 0 then
|
if nPos > 0 then
|
||||||
@@ -318,6 +416,7 @@ function lib.setupENV(win)
|
|||||||
recomplete()
|
recomplete()
|
||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif param == keys.delete then
|
elseif param == keys.delete then
|
||||||
-- Delete
|
-- Delete
|
||||||
if nPos < #sLine then
|
if nPos < #sLine then
|
||||||
@@ -326,6 +425,7 @@ function lib.setupENV(win)
|
|||||||
recomplete()
|
recomplete()
|
||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif param == keys["end"] then
|
elseif param == keys["end"] then
|
||||||
-- End
|
-- End
|
||||||
if nPos < #sLine then
|
if nPos < #sLine then
|
||||||
@@ -334,10 +434,13 @@ function lib.setupENV(win)
|
|||||||
recomplete()
|
recomplete()
|
||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif param == keys.tab then
|
elseif param == keys.tab then
|
||||||
-- Tab (accept autocomplete)
|
-- Tab (accept autocomplete)
|
||||||
acceptCompletion()
|
acceptCompletion()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif sEvent == "mouse_click" or sEvent == "mouse_drag" and param == 1 then
|
elseif sEvent == "mouse_click" or sEvent == "mouse_drag" and param == 1 then
|
||||||
local _, cy = term.getCursorPos()
|
local _, cy = term.getCursorPos()
|
||||||
if param1 >= sx and param1 <= w and param2 == cy then
|
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)
|
nPos = math.min(math.max(nScroll + param1 - sx, 0), #sLine)
|
||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif sEvent == "term_resize" then
|
elseif sEvent == "term_resize" then
|
||||||
-- Terminal resized
|
-- Terminal resized
|
||||||
w = term.getSize()
|
w = term.getSize()
|
||||||
redraw()
|
redraw()
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -360,94 +465,6 @@ function lib.setupENV(win)
|
|||||||
return sLine
|
return sLine
|
||||||
end
|
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 tAPIsLoading = {}
|
||||||
|
|
||||||
local bAPIError = false
|
local bAPIError = false
|
||||||
@@ -521,9 +538,10 @@ function lib.setupENV(win)
|
|||||||
if turtle then load_apis("rom/apis/turtle") end
|
if turtle then load_apis("rom/apis/turtle") end
|
||||||
if pocket then load_apis("rom/apis/pocket") end
|
if pocket then load_apis("rom/apis/pocket") end
|
||||||
env.shell = shell
|
env.shell = shell
|
||||||
|
env.settings = settings
|
||||||
env._ENV = env
|
env._ENV = env
|
||||||
env._G = env
|
env._G = env
|
||||||
|
term.redirect(win)
|
||||||
return env
|
return env
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ while true do
|
|||||||
dragging = win
|
dragging = win
|
||||||
resizing = true
|
resizing = true
|
||||||
bringtofront(indx)
|
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
|
dragging = win
|
||||||
offsetX = win.x - data[3]
|
offsetX = win.x - data[3]
|
||||||
offsetY = win.y - data[4]
|
offsetY = win.y - data[4]
|
||||||
@@ -63,7 +63,7 @@ while true do
|
|||||||
threading.addThread(function()dragging.resized(dragging.w,dragging.h)end)
|
threading.addThread(function()dragging.resized(dragging.w,dragging.h)end)
|
||||||
else
|
else
|
||||||
dragging.x = data[3] + offsetX
|
dragging.x = data[3] + offsetX
|
||||||
dragging.y = data[4] + offsetY
|
dragging.y = math.max(data[4] + offsetY,3)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for indx = #_G.windows, 1, -1 do
|
for indx = #_G.windows, 1, -1 do
|
||||||
|
|||||||
Reference in New Issue
Block a user