add a way to quit nsh sessions, ^]

This commit is contained in:
Izaya 2017-05-23 14:48:26 +00:00
parent 1994d25f5f
commit f6c61622bc
2 changed files with 7 additions and 6 deletions

View File

@ -1,5 +1,4 @@
function nshc_w(evPP,nid)
write("\f")
while true do
if ev[1] == "net_msg" then
local V,msg=false,tostring(ev[4])
@ -8,22 +7,23 @@ function nshc_w(evPP,nid)
write(msg:sub(4))
end
end
elseif ev[1] == "key" and ev[2] == tT[cT][3].sI then
elseif ev[1] == "key" and ev[2] == E().sI and ev[3] == 29 and ev[4] == 27 then
break
elseif ev[1] == "key" and ev[2] == E().sI then
ns(nid,evPP,"key"..tostring(ev[3]))
end
C.yield()
end
ns(nid,evPP,"exit")
end
function nshc(P,nid)
ns(nid,P,"initnsh")
while true do
if ev[1] == "net_msg" then
print(T.unpack(ev))
end
if ev[1] == "net_msg" and ev[2] == nid and ev[3] == P then
nshc_w(ev[4],nid)
break
end
C.yield()
end
nshc_w(ev[4],nid)
end

View File

@ -6,6 +6,7 @@ s("netsh daemon - "..tostring(sI),function() print(pcall(function()
if ev[3] == evPP and ev[2] == cA then
if msg:sub(1,3) == "key" then
h("key",tT[cT][3].sI,tonumber(msg:sub(4)),0)
elseif msg == "exit" then break
end
end
elseif ev[1] == "display" and ev[3] == tT[cT][3].sI then