#!/bin/rc

rm /srv/^(vncmousein vnccursor vncwinname drawdev wrapslave cursor mouse)

# following symmetric components are needed so we can both read and write to all terminal devices, and sync possible state for detach/attach functionality.

#	kbd (bidirectional, symmetric in or out file)
# kbdfs is symmetric already, clients can already just write into kbdin from all clients (vncs does the same)
# as state needn't be synced, being bidirectional for once makes our life easier.

#	mouse (bidirectional state via 1 file; resize events piggyback this, too)
# receive N mice via pipe
# need resize stuff
# need to decide which of N clients should also receive the other direction's mouse warp events
bind '#|' /n/mouse
#cat /dev/mouse > /n/mouse/data1 &
#sleep 1
bind /n/mouse/data /dev/mouse
srvfs mouse /n/mouse

#	cursor (unidirectional for our usage, supports reading and writing state via 1 file, but we only implement the natural direction)
# for whoever might want cursor events, we put them into a pipe. right now this is broken for N readers (N clients), 
# because pipes will only forward to ONE random reader.
bind '#|' /n/cursor
bind /n/cursor/data /dev/cursor
srvfs cursor /n/cursor

#	winname (unidirectional, needs to be read on mouse resize events)
# winname support isn't there yet, also see mouse resize event!
echo /dev/winname is `{cat /dev/winname}
#bind /n/drawdev/winname /dev/winname

#	snarf (bidirectional, also with drawterm it is multiple OS specific)
# might need like cursor a decision and limit to 1:1 operation with re-routing events based on mouse? keyboard? events.
# not done yet. from cons device normally.
#bind /n/drawdev/snarf /dev/snarf

#	draw
# draw is now symmetric for our purposes of allowing N mirrored terminals: on one side there are normal graphical clients, i.e. rio, on the other side we expose a draw replicator file that can be piped into another devdraw so we would become a draw client, replicating what we otherwise store in local devdraw and display via VNC. Detach and attach supported via some trickery, too.
# might need to implement a manual clipping and transformation thingy for draw clients so we can have viewboxes.

#wsys=/srv/rio.hiro.1271135357 window -m

rio -i test-rio &


{ 	
	<> /n/cursor/data1 { 
		while(sleep 1){} 
	} 
}& 
{ 	
	echo mouse keep open start >> /tmp/t.log
	<> /n/mouse/data1 { 
		while(sleep 1){} 
	} 
	echo mouse keep open end >> /tmp/t.log

}& 

