mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 03:05:30 -04:00
added support for setting cursor position in edit by clicking
This commit is contained in:
parent
9e555a58de
commit
5c975fb1c6
@ -297,6 +297,16 @@ local function onClipboard(value)
|
|||||||
term.setCursorBlink(true) -- force toggle to caret
|
term.setCursorBlink(true) -- force toggle to caret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function onClick(x, y)
|
||||||
|
local w, h = getSize()
|
||||||
|
x = math.max(1, math.min(w, x))
|
||||||
|
y = math.max(1, math.min(h, #buffer, y))
|
||||||
|
setCursor(x, y)
|
||||||
|
if getCursor() > unicode.len(line()) then
|
||||||
|
ende()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -327,12 +337,14 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
while running do
|
while running do
|
||||||
local event, address, charOrValue, code = event.pull()
|
local event, address, arg1, arg2 = event.pull()
|
||||||
if type(address) == "string" and component.isPrimary(address) then
|
if type(address) == "string" and component.isPrimary(address) then
|
||||||
if event == "key_down" then
|
if event == "key_down" then
|
||||||
onKeyDown(charOrValue, code)
|
onKeyDown(arg1, arg2)
|
||||||
elseif event == "clipboard" then
|
elseif event == "clipboard" then
|
||||||
onClipboard(charOrValue)
|
onClipboard(arg1)
|
||||||
|
elseif event == "click" then
|
||||||
|
onClick(arg1, arg2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user