shithub: gridchat

ref: 6e888a6b82b18cfcbcd80e5bde6edd29fd083231
dir: /chat/

View raw version
#!/bin/rc
user=be0ba

fn chatg{
	label chatg
	grep -i '[^a-z0-9]'$user'([^a-z0-9]|$)' /n/chatbuf/chat | grep -v '^'$user' →' | chat-fmt
}

fn chati{
	label chati
	while(){
		echo -n '→ ' >> /dev/text
		read | sed '1s/^/'$user' → /' >>/n/chat/chat
	}
}

fn chatv{
	label chatv
	</n/chatbuf/chat chat-fmt
}

fn chatstart{
	srv tcp!chat.tcp80.org!9990 chat.$pid
	mount /srv/chat.$pid /n/chat tail:0

	dims=`{read -c60 /dev/window}
	height=`{echo $dims(5) - $dims(3) | hoc}
	width=`{echo $dims(4) - $dims(2)| hoc}
	hchat=`{echo $height - 200 | hoc}

	mq -c -m /n/chatbuf -s mq.$pid
	cat /n/chat/chat > /n/chatbuf/chat &
	window -m -r 0     0    $width     100 -scroll rc -c chatg
	window -m -r 0   100    $width  $hchat -scroll rc -c chatv
	window -m -r 0  $hchat  $width $height -scroll rc -c chati
}

rfork ne
window 0,0,620,1033 newsrv 'rio -b -i ''rc -c chatstart'''