Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-mt.1288.mcz ==================== Summary ==================== Name: Kernel-mt.1288 Author: mt Time: 16 December 2019, 9:06:49.662845 am UUID: 3e88e0c8-27ef-dc4a-9017-227b63e2ce72 Ancestors: Kernel-mt.1286 Clean up documentation and code of latest key-code fix. Thanks Nicolas (nice) for the tip! =============== Diff against Kernel-mt.1286 =============== Item was changed: ----- Method: EventSensor class>>installDuplicateKeyEntryFor: (in category 'key decode table') ----- + installDuplicateKeyEntryFor: aPrintableCharacter + "Updates the key-decode table, which maps between pairs of {character code . modifier code}. See the class comment for more information. + Note that the bitmask 16r9F removes the high bits, which subtracts 64 from the key code for (upper) $A to $Z and 96 for (lower) $a to $z. The VM sends non-printable control characters for [ctrl]+[A-Za-Z] in ASCII < 32, but the given character is expected to be ASCII >= 32 and thus printable. So we have to convert printable characters to control characters in this mapping table." - installDuplicateKeyEntryFor: c - "Updates key-decode table. The table maps pairs of {character code . modifier code}. See the class comment for more information. Note that the bitmask 16r9F is used to convert control characters (ascii 0 to 31) to printable characters." | upper lower | + upper := aPrintableCharacter asUppercase asInteger. + lower := aPrintableCharacter asLowercase asInteger. - upper := c asUppercase asInteger. - lower := c asLowercase asInteger. KeyDecodeTable at: { lower bitAnd: 16r9F . 2 "ctrl" } put: { lower . 8 "cmd/alt" }. KeyDecodeTable at: { upper bitAnd: 16r9F . 2 bitOr: 1 "ctrl+shift" } put: { upper . 8 bitOr: 1 "cmd/alt+shift" }. ! Item was changed: ----- Method: EventSensor class>>installSwappedKeyEntryFor: (in category 'key decode table') ----- + installSwappedKeyEntryFor: aPrintableCharacter + "Updates the key-decode table, which maps between pairs of {character code . modifier code}. See the class comment for more information. + Note that the bitmask 16r9F removes the high bits, which subtracts 64 from the key code for (upper) $A to $Z and 96 for (lower) $a to $z. The VM sends non-printable control characters for [ctrl]+[A-Za-Z] in ASCII < 32, but the given character is expected to be ASCII >= 32 and thus printable. So we have to convert printable characters to control characters in this mapping table." - installSwappedKeyEntryFor: c - "Updates key-decode table. The table maps pairs of {character code . modifier code}. See the class comment for more information. Note that the bitmask 16r9F is used to convert control characters (ascii 0 to 31) to printable characters." | upper lower | + upper := aPrintableCharacter asUppercase asInteger. + lower := aPrintableCharacter asLowercase asInteger. - upper := c asUppercase asInteger. - lower := c asLowercase asInteger. KeyDecodeTable at: { lower bitAnd: 16r9F . 2 "ctrl" } put: { lower . 8 "cmd/alt" }. KeyDecodeTable at: { lower . 8 "cmd/alt" } put: { lower bitAnd: 16r9F . 2 "ctrl" }. KeyDecodeTable at: { upper bitAnd: 16r9F . 2 bitOr: 1 "ctrl+shift" } put: { upper . 8 bitOr: 1 "cmd/alt+shift" }. KeyDecodeTable at: { upper . 8 bitOr: 1 "cmd/alt+shift" } put: { upper bitAnd: 16r9F . 2 bitOr: 1 "ctrl+shift" }.! Item was changed: ----- Method: EventSensor>>processEvent: (in category 'private-I/O') ----- processEvent: evt "Process a single event. This method is run at high priority." | type buttons window | type := evt at: 1. "Only process main window events, forward others to host window proxies" window := evt at: 8. (window isNil or: [window isZero]) ifTrue: [window := 1. evt at: 8 put: window]. window = 1 ifFalse: [ ^Smalltalk at: #HostWindowProxy ifPresent: [:w | w processEvent: evt]]. "Tackle mouse events and mouse wheel events first" (type = EventTypeMouse or: [type = EventTypeMouseWheel]) ifTrue: [buttons := (ButtonDecodeTable at: (evt at: 5) + 1). evt at: 5 put: (Smalltalk platformName = 'Mac OS' ifTrue: [ buttons ] ifFalse: [ self mapButtons: buttons modifiers: (evt at: 6) ]). self queueEvent: evt. type = EventTypeMouse ifTrue: [self processMouseEvent: evt]. type = EventTypeMouseWheel ifTrue: [self processMouseWheelEvent: evt]. ^self]. "Store the event in the queue if there's any" type = EventTypeKeyboard ifTrue: [ "Check if the event is a user interrupt" + ((evt at: 4) = EventKeyChar - ((evt at: 4) = 0 and: [((evt at: 3) bitOr: (((evt at: 5) bitAnd: 8) bitShift: 8)) = interruptKey]) ifTrue: ["interrupt key is meta - not reported as event" ^ interruptSemaphore signal]. + "Decode keys for characters (i.e., duplicate or swap, ctrl <-> alt/cmd)." + (evt at: 4) = EventKeyChar + ifTrue: [ + KeyDecodeTable "Unicode character first" + at: {evt at: 6. evt at: 5} + ifPresent: [:a | evt at: 6 put: a first; + at: 5 put: a second]. + KeyDecodeTable "ASCII character second" + at: {evt at: 3. evt at: 5} + ifPresent: [:a | evt at: 3 put: a first; + at: 5 put: a second]]. - "Else swap ctrl/alt keys if neeeded. - Look at the Unicode char first, then ascii." - (evt at: 4) = 0 "key stroke only" ifTrue: [ - KeyDecodeTable - at: {evt at: 6. evt at: 5} - ifPresent: [:a | evt at: 6 put: a first; - at: 5 put: a second]. - KeyDecodeTable - at: {evt at: 3. evt at: 5} - ifPresent: [:a | evt at: 3 put: a first; - at: 5 put: a second]]. self queueEvent: evt. self processKeyboardEvent: evt . ^self ]. + "Handle all events other than Keyboard or Mouse." - "Handle all events other than Keyborad or Mouse." self queueEvent: evt. ! |
Free forum by Nabble | Edit this page |