mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-19 16:07:38 +00:00
Allow navigating read
's input using the mouse
This commit is contained in:
@@ -326,7 +326,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
nScroll = (sx + nPos) - w
|
nScroll = (sx + nPos) - w
|
||||||
end
|
end
|
||||||
|
|
||||||
local cx,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
|
||||||
@@ -523,6 +523,14 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif sEvent == "mouse_click" or sEvent == "mouse_drag" and param == 1 then
|
||||||
|
local _, cy = term.getCursorPos()
|
||||||
|
if param2 >= sx and param2 <= w and param2 == cy then
|
||||||
|
-- Then ensure we don't scroll beyond the current line
|
||||||
|
nPos = math.min(math.max(nScroll + x - sx, 0, #sLine))
|
||||||
|
redraw()
|
||||||
|
end
|
||||||
|
|
||||||
elseif sEvent == "term_resize" then
|
elseif sEvent == "term_resize" then
|
||||||
-- Terminal resized
|
-- Terminal resized
|
||||||
w = term.getSize()
|
w = term.getSize()
|
||||||
|
Reference in New Issue
Block a user