hlfw.ca

9hkd

ref: 7e6be8df4f6faa0f2d2748aa079d02513153d01b
dir: /riow/

View raw version
#!/bin/rc
rfork ne

alt=0
ctl=0
glenda=0
shift=0

fn handle {
	# remember old states
	oalt=$alt
	octl=$ctl
	oglenda=$glenda
	oshift=$shift

	m=$1
	state=0
	if(~ $1 k)
		state=1
	shift

	key=''
	if(~ $state K && ~ $#* 0){
		alt=0
		ctl=0
		glenda=0
		shift=0
	}
	if not {
		while(! ~ $#* 0){
			if(~ $1 alt || ~ $1 ctl || ~ $1 glenda || ~ $1 shift){
				eval '$1=$state'
			}
			if not {
				# only react to 'c'
				if(~ $m c) 
					key=$1
			}
			shift
		}
	}
	if(! ~ $key '')
		echo 'shift='^$shift 'alt='^$alt 'ctl='^$ctl 'glenda='^$glenda 'key='^$key
}

while(s=`{read}){
	handle $s
}