mirror of
https://github.com/kepler155c/opus
synced 2025-10-24 12:17:40 +00:00
format and installer branches
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
_G.requireInjector()
|
||||
_G.requireInjector(_ENV)
|
||||
|
||||
local Event = require('event')
|
||||
local Socket = require('socket')
|
||||
@@ -14,73 +14,73 @@ local options, args = Util.args({ ... })
|
||||
|
||||
local remoteId = tonumber(table.remove(args, 1) or '')
|
||||
if not remoteId then
|
||||
print('Enter host ID')
|
||||
remoteId = tonumber(read())
|
||||
print('Enter host ID')
|
||||
remoteId = tonumber(read())
|
||||
end
|
||||
|
||||
if not remoteId then
|
||||
error('Syntax: telnet [-title TITLE] ID [PROGRAM]')
|
||||
error('Syntax: telnet [-title TITLE] ID [PROGRAM]')
|
||||
end
|
||||
|
||||
if options.title and multishell then
|
||||
multishell.setTitle(multishell.getCurrent(), options.title)
|
||||
multishell.setTitle(multishell.getCurrent(), options.title)
|
||||
end
|
||||
|
||||
local socket, msg = Socket.connect(remoteId, 23)
|
||||
|
||||
if not socket then
|
||||
error(msg)
|
||||
error(msg)
|
||||
end
|
||||
|
||||
local ct = Util.shallowCopy(term.current())
|
||||
if not ct.isColor() then
|
||||
Terminal.toGrayscale(ct)
|
||||
Terminal.toGrayscale(ct)
|
||||
end
|
||||
|
||||
local w, h = ct.getSize()
|
||||
socket:write({
|
||||
width = w,
|
||||
height = h,
|
||||
isColor = ct.isColor(),
|
||||
program = args,
|
||||
pos = { ct.getCursorPos() },
|
||||
width = w,
|
||||
height = h,
|
||||
isColor = ct.isColor(),
|
||||
program = args,
|
||||
pos = { ct.getCursorPos() },
|
||||
})
|
||||
|
||||
Event.addRoutine(function()
|
||||
while true do
|
||||
local data = socket:read()
|
||||
if not data then
|
||||
break
|
||||
end
|
||||
for _,v in ipairs(data) do
|
||||
ct[v.f](table.unpack(v.args))
|
||||
end
|
||||
end
|
||||
while true do
|
||||
local data = socket:read()
|
||||
if not data then
|
||||
break
|
||||
end
|
||||
for _,v in ipairs(data) do
|
||||
ct[v.f](table.unpack(v.args))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--ct.clear()
|
||||
--ct.setCursorPos(1, 1)
|
||||
|
||||
local filter = Util.transpose {
|
||||
'char', 'paste', 'key', 'key_up', 'terminate',
|
||||
'mouse_scroll', 'mouse_click', 'mouse_drag', 'mouse_up',
|
||||
'char', 'paste', 'key', 'key_up', 'terminate',
|
||||
'mouse_scroll', 'mouse_click', 'mouse_drag', 'mouse_up',
|
||||
}
|
||||
|
||||
while true do
|
||||
local e = { os.pullEventRaw() }
|
||||
local event = e[1]
|
||||
local e = { os.pullEventRaw() }
|
||||
local event = e[1]
|
||||
|
||||
if filter[event] then
|
||||
socket:write(e)
|
||||
else
|
||||
Event.processEvent(e)
|
||||
end
|
||||
if filter[event] then
|
||||
socket:write(e)
|
||||
else
|
||||
Event.processEvent(e)
|
||||
end
|
||||
|
||||
if not socket.connected then
|
||||
if not socket.connected then
|
||||
-- print()
|
||||
-- print('Connection lost')
|
||||
-- print('Press enter to exit')
|
||||
-- pcall(read)
|
||||
break
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user