--- a/DoWhatIMeanSupport.st Tue May 20 13:06:46 2003 +0200
+++ b/DoWhatIMeanSupport.st Fri May 23 11:30:18 2003 +0200
@@ -178,8 +178,50 @@
^ nil
! !
+!DoWhatIMeanSupport class methodsFor:'typing distance'!
+
+isKey:k1 nextTo:k2
+ "return true, if k1 and k2 are adjacent keys on the keybaord.
+ CAVEAT: hard coded us-keyboard here"
+
+ |keys|
+
+ "/ for now: hardcoded US keyboard (should be language dependent)
+ keys := #( 'qwertyuiop'
+ 'asdfghjkl'
+ 'zxcvbnm' ).
+
+ ^ self isKey:k1 nextTo:k2 onKeyboard:keys
+
+ "
+ self isKey:$a nextTo:$s
+ self isKey:$a nextTo:$e
+ "
+!
+
+isKey:k1 nextTo:k2 onKeyboard:keys
+ "return true, if k1 and k2 are adjacent keys on the keybaord.
+ CAVEAT: hard coded us-keyboard here"
+
+ |row1 row2 col1 col2|
+
+ row1 := keys findFirst:[:row | row includes:k1].
+ row2 := keys findFirst:[:row | row includes:k2].
+
+ (row1-row2) abs <= 1 ifFalse:[^ false].
+
+ col1 := (keys at:row1) indexOf:k1.
+ col2 := (keys at:row2) indexOf:k2.
+
+ ^ (col1-col2) abs <= 1
+
+ "
+ self isKey:k1 nextTo:k2
+ "
+! !
+
!DoWhatIMeanSupport class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.6 2003-05-20 11:06:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.7 2003-05-23 09:30:18 cg Exp $'
! !