plan 9 kernel history: overview | file list | diff list

1991/1211/ss/screen.c (diff list | history)

1991/1108/sys/src/9/ss/screen.c:244,3091991/1211/sys/src/9/ss/screen.c:244,327 (short | long | prev | next)
1990/1231    
	static caps = 0; 
	static long startclick; 
1991/0713    
	static int repeatc; 
1991/0112    
	static int kbdstate, k1, k2; 
1990/1231    
	int tc; 
1991/1211    
	static int lstate; 
	static uchar kc[4]; 
	uchar ch, code; 
	int i, nk; 
1990/1231    
 
	tc = kbdmap[shift][c&0x7F]; 
1991/1211    
	ch = kbdmap[shift][c&0x7F]; 
1990/1231    
	if(c==0x7F){	/* all keys up */ 
1991/0713    
    norepeat: 
		kbdrepeat(0); 
1990/1231    
		return; 
	} 
	if(tc == 0xFF)	/* shouldn't happen; ignore */ 
1991/1211    
	if(ch == 0xFF)	/* shouldn't happen; ignore */ 
1990/1231    
		return; 
	if(c & 0x80){	/* key went up */ 
		if(tc == 0xF0){		/* control */ 
1991/1211    
		if(ch == 0xF0){		/* control */ 
1990/1231    
			shift &= ~2; 
1991/0713    
			goto norepeat; 
1990/1223    
		} 
1990/1231    
		if(tc == 0xF1){	/* shift */ 
1991/1211    
		if(ch == 0xF1){	/* shift */ 
1990/1231    
			shift &= ~1; 
1991/0713    
			goto norepeat; 
1990/1231    
		} 
		if(tc == 0xF2){	/* caps */ 
1991/1211    
		if(ch == 0xF2){	/* caps */ 
1991/0713    
			goto norepeat; 
1990/1231    
		} 
1991/0713    
		goto norepeat; 
1990/1223    
	} 
1990/1231    
	if(tc == 0xF0){		/* control */ 
1991/1211    
	if(ch == 0xF0){		/* control */ 
1990/1231    
		shift |= 2; 
1991/0713    
		goto norepeat; 
1990/1223    
	} 
1990/1231    
	if(tc==0xF1){	/* shift */ 
1991/1211    
	if(ch==0xF1){	/* shift */ 
1990/1231    
		shift |= 1; 
1991/0713    
		goto norepeat; 
1990/1231    
	} 
	if(tc==0xF2){	/* caps */ 
1991/1211    
	if(ch==0xF2){	/* caps */ 
1990/1231    
		caps ^= 1; 
1991/0713    
		goto norepeat; 
1990/1231    
	} 
	if(caps && 'a'<=tc && tc<='z') 
		tc |= ' '; 
	repeatc = tc; 
1991/1211    
	if(caps && 'a'<=ch && ch<='z') 
		ch |= ' '; 
	repeatc = ch; 
1991/0713    
	kbdrepeat(1); 
1991/0112    
	if(tc == 0xB6)	/* Compose */ 
		kbdstate = 1; 
1991/1211    
	if(ch == 0xB6)	/* Compose */ 
		lstate = 1; 
1991/0112    
	else{ 
		switch(kbdstate){ 
1991/1211    
		switch(lstate){ 
1991/0112    
		case 1: 
			k1 = tc; 
			kbdstate = 2; 
1991/1211    
			kc[0] = ch; 
			lstate = 2; 
			if(ch == 'X') 
				lstate = 3; 
1991/0112    
			break; 
		case 2: 
			k2 = tc; 
			tc = latin1(k1, k2); 
			if(c == 0){ 
1991/0604    
				kbdputc(&kbdq, k1); 
1991/0112    
				tc = k2; 
			} 
			/* fall through */ 
1991/1211    
			kc[1] = ch; 
			c = latin1(kc); 
			nk = 2; 
		putit: 
			lstate = 0; 
			if(c != -1) 
				kbdputc(&kbdq, c); 
			else for(i=0; i<nk; i++) 
				kbdputc(&kbdq, kc[i]); 
			break; 
		case 3: 
		case 4: 
		case 5: 
			kc[lstate-2] = ch; 
			lstate++; 
			break; 
		case 6: 
			kc[4] = ch; 
			c = unicode(kc); 
			nk = 5; 
			goto putit; 
1991/0112    
		default: 
			kbdstate = 0; 
1991/0604    
			kbdputc(&kbdq, tc); 
1991/1211    
			kbdputc(&kbdq, ch); 
			break; 
1991/0112    
		} 
	} 
1991/0604    
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)