1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-07 07:50:27 +00:00

Merge branch 'master' into mc-1.14.x

This commit is contained in:
SquidDev 2019-11-29 20:23:56 +00:00
commit 92567b4d7e
4 changed files with 30 additions and 27 deletions

View File

@ -1,5 +1,5 @@
# Mod properties # Mod properties
mod_version=1.85.1 mod_version=1.85.2
# Minecraft properties (update mods.toml when changing) # Minecraft properties (update mods.toml when changing)
mc_version=1.14.4 mc_version=1.14.4

View File

@ -291,7 +291,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
sLine = "" sLine = ""
end end
local nHistoryPos local nHistoryPos
local nPos = #sLine local nPos, nScroll = #sLine, 0
if _sReplaceChar then if _sReplaceChar then
_sReplaceChar = string.sub( _sReplaceChar, 1, 1 ) _sReplaceChar = string.sub( _sReplaceChar, 1, 1 )
end end
@ -321,16 +321,20 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
local sx = term.getCursorPos() local sx = term.getCursorPos()
local function redraw( _bClear ) local function redraw( _bClear )
local nScroll = 0 local cursor_pos = nPos - nScroll
if sx + nPos >= w then if sx + cursor_pos >= w then
nScroll = (sx + nPos) - w -- We've moved beyond the RHS, ensure we're on the edge.
nScroll = sx + nPos - w
elseif cursor_pos < 0 then
-- We've moved beyond the LHS, ensure we're on the edge.
nScroll = nPos
end end
local _, cy = term.getCursorPos() local _, cy = term.getCursorPos()
term.setCursorPos( sx, cy ) term.setCursorPos( sx, cy )
local sReplace = (_bClear and " ") or _sReplaceChar local sReplace = (_bClear and " ") or _sReplaceChar
if sReplace then if sReplace then
term.write( string.rep( sReplace, math.max( string.len(sLine) - nScroll, 0 ) ) ) term.write( string.rep( sReplace, math.max( #sLine - nScroll, 0 ) ) )
else else
term.write( string.sub( sLine, nScroll + 1 ) ) term.write( string.sub( sLine, nScroll + 1 ) )
end end
@ -345,7 +349,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
term.setBackgroundColor( colors.gray ) term.setBackgroundColor( colors.gray )
end end
if sReplace then if sReplace then
term.write( string.rep( sReplace, string.len( sCompletion ) ) ) term.write( string.rep( sReplace, #sCompletion ) )
else else
term.write( sCompletion ) term.write( sCompletion )
end end
@ -373,7 +377,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
-- Find the common prefix of all the other suggestions which start with the same letter as the current one -- Find the common prefix of all the other suggestions which start with the same letter as the current one
local sCompletion = tCompletions[ nCompletion ] local sCompletion = tCompletions[ nCompletion ]
sLine = sLine .. sCompletion sLine = sLine .. sCompletion
nPos = string.len( sLine ) nPos = #sLine
-- Redraw -- Redraw
recomplete() recomplete()
@ -381,7 +385,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
end end
end end
while true do while true do
local sEvent, param = os.pullEvent() local sEvent, param, param1, param2 = os.pullEvent()
if sEvent == "char" then if sEvent == "char" then
-- Typed key -- Typed key
clear() clear()
@ -394,7 +398,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
-- Pasted text -- Pasted text
clear() clear()
sLine = string.sub( sLine, 1, nPos ) .. param .. string.sub( sLine, nPos + 1 ) sLine = string.sub( sLine, 1, nPos ) .. param .. string.sub( sLine, nPos + 1 )
nPos = nPos + string.len( param ) nPos = nPos + #param
recomplete() recomplete()
redraw() redraw()
@ -419,7 +423,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
elseif param == keys.right then elseif param == keys.right then
-- Right -- Right
if nPos < string.len(sLine) then if nPos < #sLine then
-- Move right -- Move right
clear() clear()
nPos = nPos + 1 nPos = nPos + 1
@ -470,10 +474,10 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
end end
if nHistoryPos then if nHistoryPos then
sLine = _tHistory[nHistoryPos] sLine = _tHistory[nHistoryPos]
nPos = string.len( sLine ) nPos, nScroll = #sLine, 0
else else
sLine = "" sLine = ""
nPos = 0 nPos, nScroll = 0, 0
end end
uncomplete() uncomplete()
redraw() redraw()
@ -486,6 +490,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
clear() clear()
sLine = string.sub( sLine, 1, nPos - 1 ) .. string.sub( sLine, nPos + 1 ) sLine = string.sub( sLine, 1, nPos - 1 ) .. string.sub( sLine, nPos + 1 )
nPos = nPos - 1 nPos = nPos - 1
if nScroll > 0 then nScroll = nScroll - 1 end
recomplete() recomplete()
redraw() redraw()
end end
@ -501,7 +506,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
elseif param == keys.delete then elseif param == keys.delete then
-- Delete -- Delete
if nPos < string.len(sLine) then if nPos < #sLine then
clear() clear()
sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 ) sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 )
recomplete() recomplete()
@ -510,9 +515,9 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
elseif param == keys["end"] then elseif param == keys["end"] then
-- End -- End
if nPos < string.len(sLine ) then if nPos < #sLine then
clear() clear()
nPos = string.len(sLine) nPos = #sLine
recomplete() recomplete()
redraw() redraw()
end end
@ -525,9 +530,9 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
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 param2 >= sx and param2 <= w and param2 == cy then if param1 >= sx and param1 <= w and param2 == cy then
-- Then ensure we don't scroll beyond the current line -- Ensure we don't scroll beyond the current line
nPos = math.min(math.max(nScroll + x - sx, 0), #sLine) nPos = math.min(math.max(nScroll + param1 - sx, 0), #sLine)
redraw() redraw()
end end

View File

@ -1,3 +1,7 @@
# New features in CC: Tweaked 1.85.2
* Fix crashes when using the mouse with advanced computers.
# New features in CC: Tweaked 1.85.1 # New features in CC: Tweaked 1.85.1
* Add basic mouse support to `read` * Add basic mouse support to `read`

View File

@ -1,11 +1,5 @@
New features in CC: Tweaked 1.85.1 New features in CC: Tweaked 1.85.2
* Add basic mouse support to `read` * Fix crashes when using the mouse with advanced computers.
And several bug fixes:
* Fix turtles not having breaking particles.
* Correct rendering of monitors when underwater.
* Adjust the position from where turtle performs actions, correcting the behaviour of some interactions.
* Fix several crashes when the turtle performs some action.
Type "help changelog" to see the full version history. Type "help changelog" to see the full version history.