home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / AIncludes / UnicodeUtilities.a < prev    next >
Encoding:
Text File  |  1998-08-17  |  12.4 KB  |  262 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        UnicodeUtilities.a
  3. ;
  4. ;    Contains:    Types, constants, prototypes for Unicode Utilities (Unicode input and text utils)
  5. ;
  6. ;    Version:    Technology:    Allegro
  7. ;                Release:    Universal Interfaces 3.2
  8. ;
  9. ;    Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  10. ;
  11. ;    Bugs?:        For bug reports, consult the following page on
  12. ;                the World Wide Web:
  13. ;
  14. ;                    http://developer.apple.com/bugreporter/
  15. ;
  16. ;
  17.     IF &TYPE('__UNICODEUTILITIES__') = 'UNDEFINED' THEN
  18. __UNICODEUTILITIES__ SET 1
  19.  
  20.     IF &TYPE('__MACTYPES__') = 'UNDEFINED' THEN
  21.     include 'MacTypes.a'
  22.     ENDIF
  23.  
  24.  
  25. ;   -------------------------------------------------------------------------------------------------
  26. ;   CONSTANTS & DATA STRUCTURES
  27. ;   -------------------------------------------------------------------------------------------------
  28.  
  29.  
  30.  
  31. ;   -------------------------------------------------------------------------------------------------
  32. ;   UCKeyOutput & related stuff
  33. ;   The interpretation of UCKeyOutput depends on bits 15-14.
  34. ;   If they are 01, then bits 0-13 are an index in UCKeyStateRecordsIndex (resource-wide list).
  35. ;   If they are 10, then bits 0-13 are an index in UCKeySequenceDataIndex (resource-wide list),
  36. ;     or if UCKeySequenceDataIndex is not present or the index is beyond the end of the list,
  37. ;     then bits 0-15 are a single Unicode character.
  38. ;   Otherwise, bits 0-15 are a single Unicode character; a value of 0xFFFE-0xFFFF means no character
  39. ;     output.
  40. ;   UCKeyCharSeq is similar, but does not support indices in UCKeyStateRecordsIndex. For bits 15-14:
  41. ;   If they are 10, then bits 0-13 are an index in UCKeySequenceDataIndex (resource-wide list),
  42. ;     or if UCKeySequenceDataIndex is not present or the index is beyond the end of the list,
  43. ;     then bits 0-15 are a single Unicode character.
  44. ;   Otherwise, bits 0-15 are a single Unicode character; a value of 0xFFFE-0xFFFF means no character
  45. ;     output.
  46. ;   -------------------------------------------------------------------------------------------------
  47.  
  48.  
  49.  
  50. ; typedef UInt16                         UCKeyOutput
  51.  
  52. ; typedef UInt16                         UCKeyCharSeq
  53.  
  54.  
  55. kUCKeyOutputStateIndexMask        EQU        $4000
  56. kUCKeyOutputSequenceIndexMask    EQU        $8000
  57. kUCKeyOutputTestForIndexMask    EQU        $C000                ; test bits 14-15
  58. kUCKeyOutputGetIndexMask        EQU        $3FFF                ; get bits 0-13
  59.  
  60. ;   -------------------------------------------------------------------------------------------------
  61. ;   UCKeyStateRecord & related stuff
  62. ;   The UCKeyStateRecord information is used as follows. If the current state is zero,
  63. ;   output stateZeroCharData and set the state to stateZeroNextState. If the current state
  64. ;   is non-zero and there is an entry for it in stateEntryData, then output the corresponding
  65. ;   charData and set the state to nextState. Otherwise, output the state terminator from
  66. ;   UCKeyStateTerminators for the current state (or nothing if there is no UCKeyStateTerminators
  67. ;   table or it has no entry for the current state), then output stateZeroCharData and set the
  68. ;   state to stateZeroNextState.
  69. ;   -------------------------------------------------------------------------------------------------
  70.  
  71.  
  72.  
  73. UCKeyStateRecord        RECORD 0
  74. stateZeroCharData         ds.w    1                ; offset: $0 (0)
  75. stateZeroNextState         ds.w    1                ; offset: $2 (2)
  76. stateEntryCount             ds.w    1                ; offset: $4 (4)
  77. stateEntryFormat         ds.w    1                ; offset: $6 (6)
  78. ;  This is followed by an array of stateEntryCount elements
  79. ;  in the specified format. Here we just show a dummy array.
  80. stateEntryData             ds.l    1                ; offset: $8 (8) <-- really an array of length one
  81. sizeof                     EQU *                    ; size:   $C (12)
  82.                         ENDR
  83.  
  84. ;   Here are the codes for entry formats currently defined.
  85. ;   Each entry maps from curState to charData and nextState.
  86.  
  87.  
  88.  
  89. kUCKeyStateEntryTerminalFormat    EQU        $0001
  90. kUCKeyStateEntryRangeFormat        EQU        $0002
  91.  
  92. ;   For UCKeyStateEntryTerminal -
  93. ;   nextState is always 0, so we don't have a field for it
  94.  
  95.  
  96.  
  97. UCKeyStateEntryTerminal    RECORD 0
  98. curState                 ds.w    1                ; offset: $0 (0)
  99. charData                 ds.w    1                ; offset: $2 (2)
  100. sizeof                     EQU *                    ; size:   $4 (4)
  101.                         ENDR
  102.  
  103. ;   For UCKeyStateEntryRange -
  104. ;   If curState >= curStateStart and curState <= curStateStart+curStateRange,
  105. ;   then it matches the entry, and we transform charData and nextState as follows:
  106. ;   If charData < 0xFFFE, then charData += (curState-curStateStart)*deltaMultiplier
  107. ;   If nextState != 0, then nextState += (curState-curStateStart)*deltaMultiplier
  108.  
  109.  
  110. UCKeyStateEntryRange    RECORD 0
  111. curStateStart             ds.w    1                ; offset: $0 (0)
  112. curStateRange             ds.b    1                ; offset: $2 (2)
  113. deltaMultiplier             ds.b    1                ; offset: $3 (3)
  114. charData                 ds.w    1                ; offset: $4 (4)
  115. nextState                 ds.w    1                ; offset: $6 (6)
  116. sizeof                     EQU *                    ; size:   $8 (8)
  117.                         ENDR
  118.  
  119. ;   -------------------------------------------------------------------------------------------------
  120. ;   UCKeyboardLayout & related stuff
  121. ;   The UCKeyboardLayout struct given here is only for the resource header. It specifies
  122. ;   offsets to the various subtables which each have their own structs, given below.
  123. ;   The keyboardTypeHeadList array selects table offsets that depend on keyboardType. The
  124. ;   first entry in keyboardTypeHeadList is the default entry, which will be used if the
  125. ;   keyboardType passed to UCKeyTranslate does not match any other entry - i.e. does not fall
  126. ;   within the range keyboardTypeFirst..keyboardTypeLast for some entry. The first entry
  127. ;   should have keyboardTypeFirst = keyboardTypeLast = 0.
  128. ;   -------------------------------------------------------------------------------------------------
  129.  
  130.  
  131. UCKeyboardTypeHeader    RECORD 0
  132. keyboardTypeFirst         ds.l    1                ; offset: $0 (0)        ;  first keyboardType in this entry
  133. keyboardTypeLast         ds.l    1                ; offset: $4 (4)        ;  last keyboardType in this entry
  134. keyModifiersToTableNumOffset  ds.l 1            ; offset: $8 (8)        ;  required
  135. keyToCharTableIndexOffset  ds.l    1                ; offset: $C (12)        ;  required
  136. keyStateRecordsIndexOffset  ds.l 1                ; offset: $10 (16)        ;  0 => no table
  137. keyStateTerminatorsOffset  ds.l    1                ; offset: $14 (20)        ;  0 => no table
  138. keySequenceDataIndexOffset  ds.l 1                ; offset: $18 (24)        ;  0 => no table
  139. sizeof                     EQU *                    ; size:   $1C (28)
  140.                         ENDR
  141. UCKeyboardLayout        RECORD 0
  142. ;  header only; other tables accessed via offsets
  143. keyLayoutHeaderFormat     ds.w    1                ; offset: $0 (0)        ;  =kUCKeyLayoutHeaderFormat
  144. keyLayoutDataVersion     ds.w    1                ; offset: $2 (2)        ;  0x0100 = 1.0, 0x0110 = 1.1, etc.
  145. keyLayoutFeatureInfoOffset  ds.l 1                ; offset: $4 (4)        ;  may be 0                                    
  146. keyboardTypeCount         ds.l    1                ; offset: $8 (8)        ;  Dimension for keyboardTypeHeadList[]        
  147. keyboardTypeList         ds        UCKeyboardTypeHeader ; offset: $C (12) <-- really an array of length one
  148. sizeof                     EQU *                    ; size:   $28 (40)
  149.                         ENDR
  150. ;  -------------------------------------------------------------------------------------------------
  151. UCKeyLayoutFeatureInfo    RECORD 0
  152. keyLayoutFeatureInfoFormat  ds.w 1                ; offset: $0 (0)        ;  =kUCKeyLayoutFeatureInfoFormat
  153. reserved                 ds.w    1                ; offset: $2 (2)
  154. maxOutputStringLength     ds.l    1                ; offset: $4 (4)        ;  longest possible output string
  155. sizeof                     EQU *                    ; size:   $8 (8)
  156.                         ENDR
  157. ;  -------------------------------------------------------------------------------------------------
  158. UCKeyModifiersToTableNum RECORD 0
  159. keyModifiersToTableNumFormat  ds.w 1            ; offset: $0 (0)        ;  =kUCKeyModifiersToTableNumFormat
  160. defaultTableNum             ds.w    1                ; offset: $2 (2)        ;  For modifier combos not in tableNum[]
  161. modifiersCount             ds.l    1                ; offset: $4 (4)        ;  Dimension for tableNum[]
  162. tableNum                 ds.b    1                ; offset: $8 (8) <-- really an array of length one
  163. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  164.                          ORG 10
  165. sizeof                     EQU *                    ; size:   $A (10)
  166.                         ENDR
  167. ;  -------------------------------------------------------------------------------------------------
  168. UCKeyToCharTableIndex    RECORD 0
  169. keyToCharTableIndexFormat  ds.w    1                ; offset: $0 (0)        ;  =kUCKeyToCharTableIndexFormat
  170. keyToCharTableSize         ds.w    1                ; offset: $2 (2)        ;  Max keyCode (128 for ADB keyboards)
  171. keyToCharTableCount         ds.l    1                ; offset: $4 (4)        ;  Dimension for keyToCharTableOffsets[] (usually 6 to 12 tables)
  172. keyToCharTableOffsets     ds.l    1                ; offset: $8 (8) <-- really an array of length one
  173. ;  Each offset in keyToCharTableOffsets is from the beginning of the resource to a
  174. ;  table as follows:
  175. ;     UCKeyOutput        keyToCharData[keyToCharTableSize];
  176. ;  These tables follow the UCKeyToCharTableIndex.
  177. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  178. sizeof                     EQU *                    ; size:   $C (12)
  179.                         ENDR
  180. ;  -------------------------------------------------------------------------------------------------
  181. UCKeyStateRecordsIndex    RECORD 0
  182. keyStateRecordsIndexFormat  ds.w 1                ; offset: $0 (0)        ;  =kUCKeyStateRecordsIndexFormat
  183. keyStateRecordCount         ds.w    1                ; offset: $2 (2)        ;  Dimension for keyStateRecordOffsets[]
  184. keyStateRecordOffsets     ds.l    1                ; offset: $4 (4) <-- really an array of length one
  185. ;  Each offset in keyStateRecordOffsets is from the beginning of the resource to a
  186. ;  UCKeyStateRecord. These UCKeyStateRecords follow the UCKeyToCharTableIndex.
  187. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  188. sizeof                     EQU *                    ; size:   $8 (8)
  189.                         ENDR
  190. ;  -------------------------------------------------------------------------------------------------
  191. UCKeyStateTerminators    RECORD 0
  192. keyStateTerminatorsFormat  ds.w    1                ; offset: $0 (0)        ;  =kUCKeyStateTerminatorsFormat
  193. keyStateTerminatorCount     ds.w    1                ; offset: $2 (2)        ;  Dimension for keyStateTerminators[] (# of nonzero states)
  194. keyStateTerminators         ds.w    1                ; offset: $4 (4) <-- really an array of length one
  195. ;  Note: keyStateTerminators[0] is terminator for state 1, etc.
  196. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  197. sizeof                     EQU *                    ; size:   $6 (6)
  198.                         ENDR
  199. ;  -------------------------------------------------------------------------------------------------
  200. UCKeySequenceDataIndex    RECORD 0
  201. keySequenceDataIndexFormat  ds.w 1                ; offset: $0 (0)        ;  =kUCKeySequenceDataIndexFormat
  202. charSequenceCount         ds.w    1                ; offset: $2 (2)        ;  Dimension of charSequenceOffsets[] is charSequenceCount+1
  203. charSequenceOffsets         ds.w    1                ; offset: $4 (4) <-- really an array of length one
  204. ;  Each offset in charSequenceOffsets is in bytes, from the beginning of
  205. ;  UCKeySequenceDataIndex to a sequence of UniChars; the next offset indicates the
  206. ;  end of the sequence. The UniChar sequences follow the UCKeySequenceDataIndex.
  207. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  208. sizeof                     EQU *                    ; size:   $6 (6)
  209.                         ENDR
  210. ;  -------------------------------------------------------------------------------------------------
  211. ;  Current format codes for the various tables (bits 12-15 indicate which table)
  212.  
  213.  
  214. kUCKeyLayoutHeaderFormat        EQU        $1002
  215. kUCKeyLayoutFeatureInfoFormat    EQU        $2001
  216. kUCKeyModifiersToTableNumFormat    EQU        $3001
  217. kUCKeyToCharTableIndexFormat    EQU        $4001
  218. kUCKeyStateRecordsIndexFormat    EQU        $5001
  219. kUCKeyStateTerminatorsFormat    EQU        $6001
  220. kUCKeySequenceDataIndexFormat    EQU        $7001
  221.  
  222.  
  223. ;   -------------------------------------------------------------------------------------------------
  224. ;   Constants for keyAction parameter in UCKeyTranslate() 
  225. ;   -------------------------------------------------------------------------------------------------
  226.  
  227.  
  228.  
  229.  
  230. kUCKeyActionDown                EQU        0                    ; key is going down
  231. kUCKeyActionUp                    EQU        1                    ; key is going up
  232. kUCKeyActionAutoKey                EQU        2                    ; auto-key down
  233. kUCKeyActionDisplay                EQU        3                    ; get information for key display (as in Key Caps)            
  234.  
  235. ;   -------------------------------------------------------------------------------------------------
  236. ;   Bit assignments & masks for keyTranslateOptions parameter in UCKeyTranslate() 
  237. ;   -------------------------------------------------------------------------------------------------
  238.  
  239.  
  240.  
  241.  
  242. kUCKeyTranslateNoDeadKeysBit    EQU        0                    ; Prevents setting any new dead-key states
  243.  
  244. kUCKeyTranslateNoDeadKeysMask    EQU        $00000001
  245.  
  246. ;   -------------------------------------------------------------------------------------------------
  247. ;   FUNCTION PROTOTYPES
  248. ;   -------------------------------------------------------------------------------------------------
  249.  
  250.  
  251.  
  252. ;
  253. ; pascal OSStatus UCKeyTranslate(UCKeyboardLayout *keyLayoutPtr, UInt16 virtualKeyCode, UInt16 keyAction, UInt32 modifierKeyState, UInt32 keyboardType, OptionBits keyTranslateOptions, UInt32 *deadKeyState, UniCharCount maxStringLength, UniCharCount *actualStringLength, UniChar unicodeString[2147483647])
  254. ;
  255.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  256.         IMPORT_CFM_FUNCTION UCKeyTranslate
  257.     ENDIF
  258.  
  259.  
  260.     ENDIF ; __UNICODEUTILITIES__ 
  261.  
  262.