shithub: gridchat

ref: c5437c71ae33a1623057e1db393adb4a938c03db
dir: gridchat/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{
	9fs tcp!chat.9p.zone!9990 /n/chat

	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 -m /n/chatbuf
	cat /n/chat/chat > /n/chatbuf/chat &
	window -m -r 0     0    $width     200 -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
rio -i 'rc -c chatstart'