Getting accents into Squeak

Torge Husfeldt jean-jacques.gelee at gmx.de
Sun Sep 30 22:04:35 UTC 2001


Hi John,

I don't think you're right with your observation that locale's aren't an
option in your case. Most non US/UK-keyboards are somewhat
internationalized in a way that you can access Characters from foreign
countries with little effort. The simplest way to do this is the
"DeadCharacters" support. Now this can be rather annoying because you
have to type $^ $  to make the caret appear because the caret is a dead
Character and the logic cannot decide wheater it will be combined to a
%eacute; or not before the next key is pressed. The other solution I saw
was the Sun-keyboards wich use a dedicated combine-key. Once this key is
pressed the next two characters will be combined to one within the
possibilities of the codepage used. This on the other hand will take
three keystrokes instead of two for every character that is not on the
keyboard, and that can be very annoying too.

No matter, I implemented a very simple but effective "DeadCharacter"
suport for squeak based on 2.8alpha-1789 - I hope it wont break to many
things when filed in. Feel free to modify the code or the bindings as
you pleases. 

John Hinsley wrote:
> 
> I've just noticed this (the localisation stuff may have some kind of
> bearing on it, but......).
> 
> There I was trying to put a name with "ü" (that's u with a dieresis, I
> think) in my Rolodex. Of course, you can copy and paste into a workspace
> and it'll appear correctly, but you can't copy and paste into a Text or
> ShowEmptyText morph (maybe I should take a look at that -- I think it
> would be useful). But is there any way (and here I'm working in Linux --
> I guess the old number pad method works in Windows) of typing it in
> directly, given a UK keyboard? (Here, locales or foreign keyboards are
> not really a viable option: I'd need some bizzare combination of
> Italian, German and Spanish.
> 
> Cheers
> 
> John
> 
> --
> Can't cope anymore? Desperate for help?
> Join the 12 step program for those who yearn to give up Microsoft:
> http://home.earthlink.net/~penguinrox/index.html

P.S.: I think the french keyboard is the best starting point. they
already have most of the characters there and the diaresis is a separate
key so you can combine all the umlauts and tremata.
-------------- next part --------------
'From Squeak2.7 of 5 January 2000 [latest update: #1789] on 30 September 2001 at 11:57:46 pm'!
"Change Set:		DeadCharacterSupport-th
Date:			30 September 2001
Author:			Your Name

Adds dead character support in ParagraphEditors and their heirs.

ToDo: 
1 - make it a preference.
2 - think of ways to produce the remainig characters as well
3 - maybe switch to compose-key logic
4 - general cleanup of code

Dead characters are a relatively straightforward way to type in Characters that are not directly available on the keyboard. This approach is being used by several Keyboard-drivers. In this simplistic approach there is plenty of room for improvement. 
Here is a list of characters that i have not been able to map to the given dead/character/character combinations. If you find a way to map them, go on.
'$§ $® $¯ $¾ $¿ $Î $Ï '
A more thorough approach would surely make use of a combine-key (cf Sun-keyboards)"!

Magnitude subclass: #Character
	instanceVariableNames: 'value '
	classVariableNames: 'CharacterTable DeadCharacters '
	poolDictionaries: ''
	category: 'Collections-Text'!
ScrollController subclass: #ParagraphEditor
	instanceVariableNames: 'paragraph startBlock stopBlock beginTypeInBlock emphasisHere initialText selectionShowing otherInterval lastDeadCharacter '
	classVariableNames: 'ChangeText CmdActions CurrentSelection FindText Keyboard ShiftCmdActions TextEditorYellowButtonMenu TextEditorYellowButtonMessages UndoInterval UndoMessage UndoParagraph UndoSelection Undone '
	poolDictionaries: 'TextConstants '
	category: 'Kernel-ST80 Remnants'!

!Character methodsFor: 'converting' stamp: 'th 9/30/2001 22:20'!
combineWith: aCharacter
	"Dead Character support"
	self isDeadCharacter ifFalse:[^ String with: self with: aCharacter].
	^(self class deadCharacters at: self) at: aCharacter ifAbsent: [String with: self with: aCharacter]! !

!Character methodsFor: 'converting' stamp: 'th 9/30/2001 22:22'!
isDeadCharacter
	^ self class deadCharacters includesKey: self! !


!Character class methodsFor: 'constants' stamp: 'th 9/30/2001 23:36'!
deadCharacters
	"Dead characters are a relatively straightforward way to type in Characters that are not directly available on the keyboard. This approach is being used by several Keyboard-drivers."
	"In this simplistic approach there is plenty room for improvement. For a beginning you might want to implement this as a class variable so it wont get re-built from scratch on each invocation."
	"second: here is a list of characters that i have not been able to map to the given dead/character/character combinations. If you find a way to map them, go on."
	"$§ $® $¯ $¾ $¿ $Î $Ï "
	"A more thorough approach would surely make use of a combine-key (cf Sun-keyboards)"
	^DeadCharacters 
		ifNotNil:[DeadCharacters] 
		ifNil: [DeadCharacters _ Dictionary newFrom:
   {	$~ -> (Dictionary newFrom:{$n -> '-'. $A ->'Ì'. $O -> 'Í'. $N -> '?'. $a -> '<'.  $o -> '>' }).
	$^ -> (Dictionary newFrom:{$a -> '?'. $e -> '?'. $i -> '?'. $o -> '?'. $u -> '?' }).
	$¡ -> (Dictionary newFrom:{$A -> '?'. $a -> '?' }).
	$« -> (Dictionary newFrom:{$a -> '?'. $C -> ','. $E -> 'f'. $c -> '?'. $e -> '?'. $i -> '?'. $o -> '-'. $u -> '?' }).
	$` -> (Dictionary newFrom:{$A -> 'Ë'. $a -> '^'. $e -> '?'. $i -> '?'.  $o -> '~'. $u -> '?' }).
	$¬ -> (Dictionary newFrom:{$a -> 'S'. $A -> '?'. $O -> '?'. $U -> '?'. $e -> '?'. $i -> '*'. $o -> 's'. $u -> 'Y'. $y -> 'Ø' })
   }]! !


!ParagraphEditor methodsFor: 'typing/selecting keys' stamp: 'th 9/30/2001 23:40'!
normalCharacter: t1 
	| nextChar |
	nextChar _ sensor keyboard.
	lastDeadCharacter isNil
		ifTrue:[nextChar isDeadCharacter
			ifTrue:[lastDeadCharacter _ nextChar]
			ifFalse:[t1 nextPut: nextChar]]
		ifFalse:[
			t1 nextPutAll: (lastDeadCharacter combineWith: nextChar).
			lastDeadCharacter _ nil].
	
	"t1 nextPut: sensor keyboard."
	^ false! !




More information about the Squeak-dev mailing list