UnicodeUtilities.pas 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. {
  2. File: CarbonCore/UnicodeUtilities.h
  3. Contains: Types, constants, prototypes for Unicode Utilities (Unicode input and text utils)
  4. Copyright: © 1997-2011 by Apple Inc. All rights reserved.
  5. Bugs?: For bug reports, consult the following page on
  6. the World Wide Web:
  7. http://bugs.freepascal.org
  8. }
  9. {
  10. Modified for use with Free Pascal
  11. Version 308
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  15. {$mode macpas}
  16. {$packenum 1}
  17. {$macro on}
  18. {$inline on}
  19. {$calling mwpascal}
  20. unit UnicodeUtilities;
  21. interface
  22. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  23. {$setc GAP_INTERFACES_VERSION := $0308}
  24. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  25. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  26. {$endc}
  27. {$ifc defined CPUPOWERPC and defined CPUI386}
  28. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  29. {$endc}
  30. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  31. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  32. {$endc}
  33. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  34. {$setc __ppc__ := 1}
  35. {$elsec}
  36. {$setc __ppc__ := 0}
  37. {$endc}
  38. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  39. {$setc __ppc64__ := 1}
  40. {$elsec}
  41. {$setc __ppc64__ := 0}
  42. {$endc}
  43. {$ifc not defined __i386__ and defined CPUI386}
  44. {$setc __i386__ := 1}
  45. {$elsec}
  46. {$setc __i386__ := 0}
  47. {$endc}
  48. {$ifc not defined __x86_64__ and defined CPUX86_64}
  49. {$setc __x86_64__ := 1}
  50. {$elsec}
  51. {$setc __x86_64__ := 0}
  52. {$endc}
  53. {$ifc not defined __arm__ and defined CPUARM}
  54. {$setc __arm__ := 1}
  55. {$elsec}
  56. {$setc __arm__ := 0}
  57. {$endc}
  58. {$ifc not defined __arm64__ and defined CPUAARCH64}
  59. {$setc __arm64__ := 1}
  60. {$elsec}
  61. {$setc __arm64__ := 0}
  62. {$endc}
  63. {$ifc defined cpu64}
  64. {$setc __LP64__ := 1}
  65. {$elsec}
  66. {$setc __LP64__ := 0}
  67. {$endc}
  68. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  69. {$error Conflicting definitions for __ppc__ and __i386__}
  70. {$endc}
  71. {$ifc defined __ppc__ and __ppc__}
  72. {$setc TARGET_CPU_PPC := TRUE}
  73. {$setc TARGET_CPU_PPC64 := FALSE}
  74. {$setc TARGET_CPU_X86 := FALSE}
  75. {$setc TARGET_CPU_X86_64 := FALSE}
  76. {$setc TARGET_CPU_ARM := FALSE}
  77. {$setc TARGET_CPU_ARM64 := FALSE}
  78. {$setc TARGET_OS_MAC := TRUE}
  79. {$setc TARGET_OS_IPHONE := FALSE}
  80. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  81. {$setc TARGET_OS_EMBEDDED := FALSE}
  82. {$elifc defined __ppc64__ and __ppc64__}
  83. {$setc TARGET_CPU_PPC := FALSE}
  84. {$setc TARGET_CPU_PPC64 := TRUE}
  85. {$setc TARGET_CPU_X86 := FALSE}
  86. {$setc TARGET_CPU_X86_64 := FALSE}
  87. {$setc TARGET_CPU_ARM := FALSE}
  88. {$setc TARGET_CPU_ARM64 := FALSE}
  89. {$setc TARGET_OS_MAC := TRUE}
  90. {$setc TARGET_OS_IPHONE := FALSE}
  91. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  92. {$setc TARGET_OS_EMBEDDED := FALSE}
  93. {$elifc defined __i386__ and __i386__}
  94. {$setc TARGET_CPU_PPC := FALSE}
  95. {$setc TARGET_CPU_PPC64 := FALSE}
  96. {$setc TARGET_CPU_X86 := TRUE}
  97. {$setc TARGET_CPU_X86_64 := FALSE}
  98. {$setc TARGET_CPU_ARM := FALSE}
  99. {$setc TARGET_CPU_ARM64 := FALSE}
  100. {$ifc defined(iphonesim)}
  101. {$setc TARGET_OS_MAC := FALSE}
  102. {$setc TARGET_OS_IPHONE := TRUE}
  103. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  104. {$elsec}
  105. {$setc TARGET_OS_MAC := TRUE}
  106. {$setc TARGET_OS_IPHONE := FALSE}
  107. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  108. {$endc}
  109. {$setc TARGET_OS_EMBEDDED := FALSE}
  110. {$elifc defined __x86_64__ and __x86_64__}
  111. {$setc TARGET_CPU_PPC := FALSE}
  112. {$setc TARGET_CPU_PPC64 := FALSE}
  113. {$setc TARGET_CPU_X86 := FALSE}
  114. {$setc TARGET_CPU_X86_64 := TRUE}
  115. {$setc TARGET_CPU_ARM := FALSE}
  116. {$setc TARGET_CPU_ARM64 := FALSE}
  117. {$ifc defined(iphonesim)}
  118. {$setc TARGET_OS_MAC := FALSE}
  119. {$setc TARGET_OS_IPHONE := TRUE}
  120. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  121. {$elsec}
  122. {$setc TARGET_OS_MAC := TRUE}
  123. {$setc TARGET_OS_IPHONE := FALSE}
  124. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  125. {$endc}
  126. {$setc TARGET_OS_EMBEDDED := FALSE}
  127. {$elifc defined __arm__ and __arm__}
  128. {$setc TARGET_CPU_PPC := FALSE}
  129. {$setc TARGET_CPU_PPC64 := FALSE}
  130. {$setc TARGET_CPU_X86 := FALSE}
  131. {$setc TARGET_CPU_X86_64 := FALSE}
  132. {$setc TARGET_CPU_ARM := TRUE}
  133. {$setc TARGET_CPU_ARM64 := FALSE}
  134. { will require compiler define when/if other Apple devices with ARM cpus ship }
  135. {$setc TARGET_OS_MAC := FALSE}
  136. {$setc TARGET_OS_IPHONE := TRUE}
  137. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  138. {$setc TARGET_OS_EMBEDDED := TRUE}
  139. {$elifc defined __arm64__ and __arm64__}
  140. {$setc TARGET_CPU_PPC := FALSE}
  141. {$setc TARGET_CPU_PPC64 := FALSE}
  142. {$setc TARGET_CPU_X86 := FALSE}
  143. {$setc TARGET_CPU_X86_64 := FALSE}
  144. {$setc TARGET_CPU_ARM := FALSE}
  145. {$setc TARGET_CPU_ARM64 := TRUE}
  146. { will require compiler define when/if other Apple devices with ARM cpus ship }
  147. {$setc TARGET_OS_MAC := FALSE}
  148. {$setc TARGET_OS_IPHONE := TRUE}
  149. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  150. {$setc TARGET_OS_EMBEDDED := TRUE}
  151. {$elsec}
  152. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  153. {$endc}
  154. {$ifc defined __LP64__ and __LP64__ }
  155. {$setc TARGET_CPU_64 := TRUE}
  156. {$elsec}
  157. {$setc TARGET_CPU_64 := FALSE}
  158. {$endc}
  159. {$ifc defined FPC_BIG_ENDIAN}
  160. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  161. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  162. {$elifc defined FPC_LITTLE_ENDIAN}
  163. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  164. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  165. {$elsec}
  166. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  167. {$endc}
  168. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  169. {$setc CALL_NOT_IN_CARBON := FALSE}
  170. {$setc OLDROUTINENAMES := FALSE}
  171. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  172. {$setc OPAQUE_UPP_TYPES := TRUE}
  173. {$setc OTCARBONAPPLICATION := TRUE}
  174. {$setc OTKERNEL := FALSE}
  175. {$setc PM_USE_SESSION_APIS := TRUE}
  176. {$setc TARGET_API_MAC_CARBON := TRUE}
  177. {$setc TARGET_API_MAC_OS8 := FALSE}
  178. {$setc TARGET_API_MAC_OSX := TRUE}
  179. {$setc TARGET_CARBON := TRUE}
  180. {$setc TARGET_CPU_68K := FALSE}
  181. {$setc TARGET_CPU_MIPS := FALSE}
  182. {$setc TARGET_CPU_SPARC := FALSE}
  183. {$setc TARGET_OS_UNIX := FALSE}
  184. {$setc TARGET_OS_WIN32 := FALSE}
  185. {$setc TARGET_RT_MAC_68881 := FALSE}
  186. {$setc TARGET_RT_MAC_CFM := FALSE}
  187. {$setc TARGET_RT_MAC_MACHO := TRUE}
  188. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  189. {$setc TYPE_BOOL := FALSE}
  190. {$setc TYPE_EXTENDED := FALSE}
  191. {$setc TYPE_LONGLONG := TRUE}
  192. uses MacTypes,MacLocales,TextCommon,CFBase;
  193. {$endc} {not MACOSALLINCLUDE}
  194. {$ifc TARGET_OS_MAC}
  195. {$ALIGN MAC68K}
  196. {
  197. -------------------------------------------------------------------------------------------------
  198. CONSTANTS & DATA STRUCTURES for UCKeyTranslate & UCKeyboardLayout ('uchr' resource)
  199. -------------------------------------------------------------------------------------------------
  200. }
  201. {
  202. -------------------------------------------------------------------------------------------------
  203. UCKeyOutput & related stuff
  204. The interpretation of UCKeyOutput depends on bits 15-14.
  205. If they are 01, then bits 0-13 are an index in UCKeyStateRecordsIndex (resource-wide list).
  206. If they are 10, then bits 0-13 are an index in UCKeySequenceDataIndex (resource-wide list),
  207. or if UCKeySequenceDataIndex is not present or the index is beyond the end of the list,
  208. then bits 0-15 are a single Unicode character.
  209. Otherwise, bits 0-15 are a single Unicode character; a value of 0xFFFE-0xFFFF means no character
  210. output.
  211. UCKeyCharSeq is similar, but does not support indices in UCKeyStateRecordsIndex. For bits 15-14:
  212. If they are 10, then bits 0-13 are an index in UCKeySequenceDataIndex (resource-wide list),
  213. or if UCKeySequenceDataIndex is not present or the index is beyond the end of the list,
  214. then bits 0-15 are a single Unicode character.
  215. Otherwise, bits 0-15 are a single Unicode character; a value of 0xFFFE-0xFFFF means no character
  216. output.
  217. -------------------------------------------------------------------------------------------------
  218. }
  219. type
  220. UCKeyOutput = UInt16;
  221. UCKeyCharSeq = UInt16;
  222. const
  223. kUCKeyOutputStateIndexMask = $4000;
  224. kUCKeyOutputSequenceIndexMask = $8000;
  225. kUCKeyOutputTestForIndexMask = $C000; { test bits 14-15}
  226. kUCKeyOutputGetIndexMask = $3FFF; { get bits 0-13}
  227. {
  228. -------------------------------------------------------------------------------------------------
  229. UCKeyStateRecord & related stuff
  230. The UCKeyStateRecord information is used as follows. If the current state is zero,
  231. output stateZeroCharData and set the state to stateZeroNextState. If the current state
  232. is non-zero and there is an entry for it in stateEntryData, then output the corresponding
  233. charData and set the state to nextState. Otherwise, output the state terminator from
  234. UCKeyStateTerminators for the current state (or nothing if there is no UCKeyStateTerminators
  235. table or it has no entry for the current state), then output stateZeroCharData and set the
  236. state to stateZeroNextState.
  237. -------------------------------------------------------------------------------------------------
  238. }
  239. type
  240. UCKeyStateRecord = record
  241. stateZeroCharData: UCKeyCharSeq;
  242. stateZeroNextState: UInt16;
  243. stateEntryCount: UInt16;
  244. stateEntryFormat: UInt16;
  245. { This is followed by an array of stateEntryCount elements}
  246. { in the specified format. Here we just show a dummy array.}
  247. stateEntryData: array [0..0] of UInt32;
  248. end;
  249. {
  250. Here are the codes for entry formats currently defined.
  251. Each entry maps from curState to charData and nextState.
  252. }
  253. const
  254. kUCKeyStateEntryTerminalFormat = $0001;
  255. kUCKeyStateEntryRangeFormat = $0002;
  256. {
  257. For UCKeyStateEntryTerminal -
  258. nextState is always 0, so we don't have a field for it
  259. }
  260. type
  261. UCKeyStateEntryTerminalPtr = ^UCKeyStateEntryTerminal;
  262. UCKeyStateEntryTerminal = record
  263. curState: UInt16;
  264. charData: UCKeyCharSeq;
  265. end;
  266. {
  267. For UCKeyStateEntryRange -
  268. If curState >= curStateStart and curState <= curStateStart+curStateRange,
  269. then it matches the entry, and we transform charData and nextState as follows:
  270. If charData < 0xFFFE, then charData += (curState-curStateStart)*deltaMultiplier
  271. If nextState != 0, then nextState += (curState-curStateStart)*deltaMultiplier
  272. }
  273. type
  274. UCKeyStateEntryRangePtr = ^UCKeyStateEntryRange;
  275. UCKeyStateEntryRange = record
  276. curStateStart: UInt16;
  277. curStateRange: UInt8;
  278. deltaMultiplier: UInt8;
  279. charData: UCKeyCharSeq;
  280. nextState: UInt16;
  281. end;
  282. {
  283. -------------------------------------------------------------------------------------------------
  284. UCKeyboardLayout & related stuff
  285. The UCKeyboardLayout struct given here is only for the resource header. It specifies
  286. offsets to the various subtables which each have their own structs, given below.
  287. The keyboardTypeHeadList array selects table offsets that depend on keyboardType. The
  288. first entry in keyboardTypeHeadList is the default entry, which will be used if the
  289. keyboardType passed to UCKeyTranslate does not match any other entry - i.e. does not fall
  290. within the range keyboardTypeFirst..keyboardTypeLast for some entry. The first entry
  291. should have keyboardTypeFirst = keyboardTypeLast = 0.
  292. -------------------------------------------------------------------------------------------------
  293. }
  294. type
  295. UCKeyboardTypeHeaderPtr = ^UCKeyboardTypeHeader;
  296. UCKeyboardTypeHeader = record
  297. keyboardTypeFirst: UInt32; { first keyboardType in this entry}
  298. keyboardTypeLast: UInt32; { last keyboardType in this entry}
  299. keyModifiersToTableNumOffset: UInt32; { required}
  300. keyToCharTableIndexOffset: UInt32; { required}
  301. keyStateRecordsIndexOffset: UInt32; { 0 => no table}
  302. keyStateTerminatorsOffset: UInt32; { 0 => no table}
  303. keySequenceDataIndexOffset: UInt32; { 0 => no table}
  304. end;
  305. type
  306. UCKeyboardLayoutPtr = ^UCKeyboardLayout;
  307. UCKeyboardLayout = record
  308. { header only; other tables accessed via offsets}
  309. keyLayoutHeaderFormat: UInt16; { =kUCKeyLayoutHeaderFormat}
  310. keyLayoutDataVersion: UInt16; { 0x0100 = 1.0, 0x0110 = 1.1, etc.}
  311. keyLayoutFeatureInfoOffset: UInt32; { may be 0 }
  312. keyboardTypeCount: UInt32; { Dimension for keyboardTypeHeadList[] }
  313. keyboardTypeList: array [0..0] of UCKeyboardTypeHeader;
  314. end;
  315. { -------------------------------------------------------------------------------------------------}
  316. type
  317. UCKeyLayoutFeatureInfoPtr = ^UCKeyLayoutFeatureInfo;
  318. UCKeyLayoutFeatureInfo = record
  319. keyLayoutFeatureInfoFormat: UInt16; { =kUCKeyLayoutFeatureInfoFormat}
  320. reserved: UInt16;
  321. maxOutputStringLength: UInt32; { longest possible output string}
  322. end;
  323. { -------------------------------------------------------------------------------------------------}
  324. type
  325. UCKeyModifiersToTableNumPtr = ^UCKeyModifiersToTableNum;
  326. UCKeyModifiersToTableNum = record
  327. keyModifiersToTableNumFormat: UInt16; { =kUCKeyModifiersToTableNumFormat}
  328. defaultTableNum: UInt16; { For modifier combos not in tableNum[]}
  329. modifiersCount: UInt32; { Dimension for tableNum[]}
  330. tableNum: array [0..0] of UInt8;
  331. { Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.}
  332. end;
  333. { -------------------------------------------------------------------------------------------------}
  334. type
  335. UCKeyToCharTableIndexPtr = ^UCKeyToCharTableIndex;
  336. UCKeyToCharTableIndex = record
  337. keyToCharTableIndexFormat: UInt16; { =kUCKeyToCharTableIndexFormat}
  338. keyToCharTableSize: UInt16; { Max keyCode (128 for ADB keyboards)}
  339. keyToCharTableCount: UInt32; { Dimension for keyToCharTableOffsets[] (usually 6 to 12 tables)}
  340. keyToCharTableOffsets: array [0..0] of ByteOffset;
  341. { Each offset in keyToCharTableOffsets is from the beginning of the resource to a}
  342. { table as follows:}
  343. { UCKeyOutput keyToCharData[keyToCharTableSize];}
  344. { These tables follow the UCKeyToCharTableIndex.}
  345. { Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.}
  346. end;
  347. { -------------------------------------------------------------------------------------------------}
  348. type
  349. UCKeyStateRecordsIndexPtr = ^UCKeyStateRecordsIndex;
  350. UCKeyStateRecordsIndex = record
  351. keyStateRecordsIndexFormat: UInt16; { =kUCKeyStateRecordsIndexFormat}
  352. keyStateRecordCount: UInt16; { Dimension for keyStateRecordOffsets[]}
  353. keyStateRecordOffsets: array [0..0] of ByteOffset;
  354. { Each offset in keyStateRecordOffsets is from the beginning of the resource to a}
  355. { UCKeyStateRecord. These UCKeyStateRecords follow the keyStateRecordOffsets[] array.}
  356. { Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.}
  357. end;
  358. { -------------------------------------------------------------------------------------------------}
  359. type
  360. UCKeyStateTerminatorsPtr = ^UCKeyStateTerminators;
  361. UCKeyStateTerminators = record
  362. keyStateTerminatorsFormat: UInt16; { =kUCKeyStateTerminatorsFormat}
  363. keyStateTerminatorCount: UInt16; { Dimension for keyStateTerminators[] (# of nonzero states)}
  364. keyStateTerminators: array [0..0] of UCKeyCharSeq;
  365. { Note: keyStateTerminators[0] is terminator for state 1, etc.}
  366. { Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.}
  367. end;
  368. { -------------------------------------------------------------------------------------------------}
  369. type
  370. UCKeySequenceDataIndexPtr = ^UCKeySequenceDataIndex;
  371. UCKeySequenceDataIndex = record
  372. keySequenceDataIndexFormat: UInt16; { =kUCKeySequenceDataIndexFormat}
  373. charSequenceCount: UInt16; { Dimension of charSequenceOffsets[] is charSequenceCount+1}
  374. charSequenceOffsets: array [0..0] of UInt16;
  375. { Each offset in charSequenceOffsets is in bytes, from the beginning of}
  376. { UCKeySequenceDataIndex to a sequence of UniChars; the next offset indicates the}
  377. { end of the sequence. The UniChar sequences follow the UCKeySequenceDataIndex.}
  378. { Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.}
  379. end;
  380. { -------------------------------------------------------------------------------------------------}
  381. { Current format codes for the various tables (bits 12-15 indicate which table)}
  382. const
  383. kUCKeyLayoutHeaderFormat = $1002;
  384. kUCKeyLayoutFeatureInfoFormat = $2001;
  385. kUCKeyModifiersToTableNumFormat = $3001;
  386. kUCKeyToCharTableIndexFormat = $4001;
  387. kUCKeyStateRecordsIndexFormat = $5001;
  388. kUCKeyStateTerminatorsFormat = $6001;
  389. kUCKeySequenceDataIndexFormat = $7001;
  390. {
  391. -------------------------------------------------------------------------------------------------
  392. Constants for keyAction parameter in UCKeyTranslate()
  393. -------------------------------------------------------------------------------------------------
  394. }
  395. const
  396. kUCKeyActionDown = 0; { key is going down}
  397. kUCKeyActionUp = 1; { key is going up}
  398. kUCKeyActionAutoKey = 2; { auto-key down}
  399. kUCKeyActionDisplay = 3; { get information for key display (as in Key Caps) }
  400. {
  401. -------------------------------------------------------------------------------------------------
  402. Bit assignments & masks for keyTranslateOptions parameter in UCKeyTranslate()
  403. -------------------------------------------------------------------------------------------------
  404. }
  405. const
  406. kUCKeyTranslateNoDeadKeysBit = 0; { Prevents setting any new dead-key states}
  407. const
  408. kUCKeyTranslateNoDeadKeysMask = 1 shl kUCKeyTranslateNoDeadKeysBit;
  409. {
  410. -------------------------------------------------------------------------------------------------
  411. CONSTANTS & DATA STRUCTURES for Unicode Collation
  412. -------------------------------------------------------------------------------------------------
  413. }
  414. { constant for LocaleOperationClass}
  415. const
  416. kUnicodeCollationClass = FourCharCode('ucol');
  417. type
  418. CollatorRef = ^SInt32; { an opaque type }
  419. CollatorRefPtr = ^CollatorRef; { when a var xx:CollatorRef parameter can be nil, it is changed to xx: CollatorRefPtr }
  420. UCCollateOptions = UInt32;
  421. const
  422. { Sensitivity options}
  423. kUCCollateComposeInsensitiveMask = 1 shl 1;
  424. kUCCollateWidthInsensitiveMask = 1 shl 2;
  425. kUCCollateCaseInsensitiveMask = 1 shl 3;
  426. kUCCollateDiacritInsensitiveMask = 1 shl 4; { Other general options }
  427. kUCCollatePunctuationSignificantMask = 1 shl 15; { Number-handling options }
  428. kUCCollateDigitsOverrideMask = 1 shl 16;
  429. kUCCollateDigitsAsNumberMask = 1 shl 17;
  430. const
  431. kUCCollateStandardOptions = kUCCollateComposeInsensitiveMask or kUCCollateWidthInsensitiveMask;
  432. {
  433. Special values to specify various invariant orders for UCCompareTextNoLocale.
  434. These values use the high 8 bits of UCCollateOptions.
  435. }
  436. const
  437. kUCCollateTypeHFSExtended = 1;
  438. { These constants are used for masking and shifting the invariant order type.}
  439. const
  440. kUCCollateTypeSourceMask = $000000FF;
  441. kUCCollateTypeShiftBits = 24;
  442. const
  443. kUCCollateTypeMask = kUCCollateTypeSourceMask shl kUCCollateTypeShiftBits;
  444. type
  445. UCCollationValue = UInt32;
  446. UCCollationValuePtr = ^UCCollationValue;
  447. {
  448. -------------------------------------------------------------------------------------------------
  449. CONSTANTS & DATA STRUCTURES for Unicode TypeSelect
  450. -------------------------------------------------------------------------------------------------
  451. }
  452. {
  453. UCTypeSelectRef
  454. This is the single opaque object needed to implement the Unicode TypeSelect
  455. utilities. It is created and initialized via a call to UCTypeSelectCreateSelector
  456. }
  457. type
  458. UCTypeSelectRef = ^OpaqueUCTypeSelectRef; { an opaque type }
  459. OpaqueUCTypeSelectRef = record end;
  460. {
  461. UCTypeSelectCompareResult
  462. Used as the return value for UCTypeSelectCompare()
  463. }
  464. type
  465. UCTypeSelectCompareResult = SInt32;
  466. {
  467. UCTSWalkDirection
  468. Used for UCTypeSelectWalkList to determine the direction of the walk
  469. }
  470. type
  471. UCTSWalkDirection = UInt16;
  472. UCTSWalkDirectionPtr = ^UCTSWalkDirection;
  473. const
  474. kUCTSDirectionNext = 0;
  475. kUCTSDirectionPrevious = 1;
  476. {
  477. UCTypeSelectOptions
  478. These constants may be returned from an IndexToUCString callback function
  479. in the location pointed to by the tsOptions parameter. *tsOptions is pre-
  480. initialized to zero before the callback function is called. A callback
  481. function does not need to set *tsOptions unless it wants behavior different
  482. from the default.
  483. kUCTSOptionsReleaseStringMask: indicates that UCTypeSelectFindItem should
  484. release the CFStringRef returned by the IndexToUCString callback function
  485. once it is done with the string. If this bit is not set, the string will
  486. not be released.
  487. kUCTSOptionsDataIsOrderedMask: indicates that the data being returned by the
  488. IndexToUCString callback is already in the correct alphabetical order. If so,
  489. UCTypeSelectFindItem can optimize its search through the data to find the closest
  490. matching item.
  491. }
  492. type
  493. UCTypeSelectOptions = UInt16;
  494. UCTypeSelectOptionsPtr = ^UCTypeSelectOptions;
  495. const
  496. kUCTSOptionsNoneMask = 0;
  497. kUCTSOptionsReleaseStringMask = 1;
  498. kUCTSOptionsDataIsOrderedMask = 2;
  499. {
  500. IndexToUCStringProcPtr
  501. This is the type used to define the user's IndexToUCString callback
  502. }
  503. type
  504. IndexToUCStringProcPtr = function( index: UInt32; listDataPtr: UnivPtr; refcon: UnivPtr; var outString: CFStringRef; var tsOptions: UCTypeSelectOptions ): Boolean;
  505. type
  506. IndexToUCStringUPP = IndexToUCStringProcPtr;
  507. {
  508. * NewIndexToUCStringUPP()
  509. *
  510. * Availability:
  511. * Mac OS X: in version 10.4 and later in CoreServices.framework
  512. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.4 and later
  513. * Non-Carbon CFM: available as macro/inline
  514. }
  515. function NewIndexToUCStringUPP( userRoutine: IndexToUCStringProcPtr ): IndexToUCStringUPP; external name '_NewIndexToUCStringUPP';
  516. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  517. {
  518. * DisposeIndexToUCStringUPP()
  519. *
  520. * Availability:
  521. * Mac OS X: in version 10.4 and later in CoreServices.framework
  522. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.4 and later
  523. * Non-Carbon CFM: available as macro/inline
  524. }
  525. procedure DisposeIndexToUCStringUPP( userUPP: IndexToUCStringUPP ); external name '_DisposeIndexToUCStringUPP';
  526. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  527. {
  528. * InvokeIndexToUCStringUPP()
  529. *
  530. * Availability:
  531. * Mac OS X: in version 10.4 and later in CoreServices.framework
  532. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.4 and later
  533. * Non-Carbon CFM: available as macro/inline
  534. }
  535. function InvokeIndexToUCStringUPP( index: UInt32; listDataPtr: UnivPtr; refcon: UnivPtr; var outString: CFStringRef; var tsOptions: UCTypeSelectOptions; userUPP: IndexToUCStringUPP ): Boolean; external name '_InvokeIndexToUCStringUPP';
  536. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  537. {
  538. kUCTypeSelectMaxListSize can be used for any listSize arguement
  539. when the length of the list is unknown.
  540. }
  541. const
  542. kUCTypeSelectMaxListSize = $FFFFFFFF;
  543. {
  544. -------------------------------------------------------------------------------------------------
  545. CONSTANTS & DATA STRUCTURES for Unicode TextBreak
  546. -------------------------------------------------------------------------------------------------
  547. }
  548. { constant for LocaleOperationClass}
  549. const
  550. kUnicodeTextBreakClass = FourCharCode('ubrk');
  551. type
  552. TextBreakLocatorRef = ^OpaqueTextBreakLocatorRef; { an opaque type }
  553. OpaqueTextBreakLocatorRef = record end;
  554. {
  555. * UCTextBreakType
  556. *
  557. * Discussion:
  558. * Specifies kinds of text boundaries.
  559. }
  560. type
  561. UCTextBreakType = UInt32;
  562. const
  563. {
  564. * If the bit specified by this mask is set, boundaries of characters
  565. * may be located (with surrogate pairs treated as a single
  566. * character).
  567. }
  568. kUCTextBreakCharMask = 1 shl 0;
  569. {
  570. * If the bit specified by this mask is set, boundaries of character
  571. * clusters may be located. A cluster is a group of characters that
  572. * should be treated as single text element for editing operations
  573. * such as cursor movement. Typically this includes groups such as a
  574. * base character followed by a sequence of combining characters, for
  575. * example, a Hangul syllable represented as a sequence of conjoining
  576. * jamo characters or an Indic consonant cluster.
  577. }
  578. kUCTextBreakClusterMask = 1 shl 2;
  579. {
  580. * If the bit specified by this mask is set, boundaries of words may
  581. * be located. This can be used to determine what to highlight as the
  582. * result of a double-click.
  583. }
  584. kUCTextBreakWordMask = 1 shl 4;
  585. kUCTextBreakLineMask = 1 shl 6;
  586. {
  587. * If the bit specified by this mask is set, boundaries of paragraphs
  588. * may be located. This just finds the next hard-line break as
  589. * defined by the Unicode standard.
  590. }
  591. kUCTextBreakParagraphMask = 1 shl 8;
  592. type
  593. UCTextBreakOptions = UInt32;
  594. const
  595. kUCTextBreakLeadingEdgeMask = 1 shl 0;
  596. kUCTextBreakGoBackwardsMask = 1 shl 1;
  597. kUCTextBreakIterateMask = 1 shl 2;
  598. {
  599. -------------------------------------------------------------------------------------------------
  600. FUNCTION PROTOTYPES
  601. -------------------------------------------------------------------------------------------------
  602. }
  603. {
  604. * UCKeyTranslate()
  605. *
  606. * Availability:
  607. * Mac OS X: in version 10.0 and later in CoreServices.framework
  608. * CarbonLib: in CarbonLib 1.0 and later
  609. * Non-Carbon CFM: in UnicodeUtilitiesCoreLib 8.5 and later
  610. }
  611. function UCKeyTranslate( const (*var*) keyLayoutPtr: UCKeyboardLayout; virtualKeyCode: UInt16; keyAction: UInt16; modifierKeyState: UInt32; keyboardType: UInt32; keyTranslateOptions: OptionBits; var deadKeyState: UInt32; maxStringLength: UniCharCount; var actualStringLength: UniCharCount; unicodeString: {variable-size-array} UniCharPtr ): OSStatus; external name '_UCKeyTranslate';
  612. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  613. { Standard collation functions}
  614. {
  615. * UCCreateCollator()
  616. *
  617. * Availability:
  618. * Mac OS X: in version 10.0 and later in CoreServices.framework
  619. * CarbonLib: in CarbonLib 1.0 and later
  620. * Non-Carbon CFM: in UnicodeUtilitiesLib 8.6 and later
  621. }
  622. function UCCreateCollator( locale: LocaleRef; opVariant: LocaleOperationVariant; options: UCCollateOptions; var collatorRef_: CollatorRef ): OSStatus; external name '_UCCreateCollator';
  623. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  624. {
  625. * UCGetCollationKey()
  626. *
  627. * Availability:
  628. * Mac OS X: in version 10.0 and later in CoreServices.framework
  629. * CarbonLib: in CarbonLib 1.0 and later
  630. * Non-Carbon CFM: in UnicodeUtilitiesLib 8.6 and later
  631. }
  632. function UCGetCollationKey( collatorRef_: CollatorRef; textPtr: ConstUniCharPtr; textLength: UniCharCount; maxKeySize: ItemCount; var actualKeySize: ItemCount; collationKey: {variable-size-array} UCCollationValuePtr ): OSStatus; external name '_UCGetCollationKey';
  633. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  634. {
  635. * UCCompareCollationKeys()
  636. *
  637. * Availability:
  638. * Mac OS X: in version 10.0 and later in CoreServices.framework
  639. * CarbonLib: in CarbonLib 1.0 and later
  640. * Non-Carbon CFM: in UnicodeUtilitiesCoreLib 8.6 and later
  641. }
  642. function UCCompareCollationKeys( key1Ptr: UCCollationValuePtr; key1Length: ItemCount; key2Ptr: UCCollationValuePtr; key2Length: ItemCount; var equivalent: Boolean; var order: SInt32 ): OSStatus; external name '_UCCompareCollationKeys';
  643. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  644. {
  645. * UCCompareText()
  646. *
  647. * Availability:
  648. * Mac OS X: in version 10.0 and later in CoreServices.framework
  649. * CarbonLib: in CarbonLib 1.0 and later
  650. * Non-Carbon CFM: in UnicodeUtilitiesLib 8.6 and later
  651. }
  652. function UCCompareText( collatorRef_: CollatorRef; text1Ptr: ConstUniCharPtr; text1Length: UniCharCount; text2Ptr: ConstUniCharPtr; text2Length: UniCharCount; var equivalent: Boolean; var order: SInt32 ): OSStatus; external name '_UCCompareText';
  653. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  654. {
  655. * UCDisposeCollator()
  656. *
  657. * Availability:
  658. * Mac OS X: in version 10.0 and later in CoreServices.framework
  659. * CarbonLib: in CarbonLib 1.0 and later
  660. * Non-Carbon CFM: in UnicodeUtilitiesLib 8.6 and later
  661. }
  662. function UCDisposeCollator( var collatorRef_: CollatorRef ): OSStatus; external name '_UCDisposeCollator';
  663. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  664. { Simple collation using default locale}
  665. {
  666. * UCCompareTextDefault()
  667. *
  668. * Availability:
  669. * Mac OS X: in version 10.0 and later in CoreServices.framework
  670. * CarbonLib: in CarbonLib 1.0 and later
  671. * Non-Carbon CFM: in UnicodeUtilitiesLib 8.6 and later
  672. }
  673. function UCCompareTextDefault( options: UCCollateOptions; text1Ptr: ConstUniCharPtr; text1Length: UniCharCount; text2Ptr: ConstUniCharPtr; text2Length: UniCharCount; var equivalent: Boolean; var order: SInt32 ): OSStatus; external name '_UCCompareTextDefault';
  674. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  675. { Simple locale-independent collation}
  676. {
  677. * UCCompareTextNoLocale()
  678. *
  679. * Availability:
  680. * Mac OS X: in version 10.0 and later in CoreServices.framework
  681. * CarbonLib: in CarbonLib 1.0 and later
  682. * Non-Carbon CFM: in UnicodeUtilitiesCoreLib 8.6 and later
  683. }
  684. function UCCompareTextNoLocale( options: UCCollateOptions; text1Ptr: ConstUniCharPtr; text1Length: UniCharCount; text2Ptr: ConstUniCharPtr; text2Length: UniCharCount; var equivalent: Boolean; var order: SInt32 ): OSStatus; external name '_UCCompareTextNoLocale';
  685. (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
  686. {
  687. *===============================================================================
  688. * Text break (text boundary) functions
  689. *
  690. * These are deprecated. Replacements are as follows:
  691. *
  692. * 1. To determine locale-sensitive text breaks for word, line, sentence and
  693. * paragraph boundaries, use the CFStringTokenizer functions:
  694. * CFStringTokenizerCreate (balanced by CFRelease), CFStringTokenizerAdvanceToNextToken
  695. * or CFStringTokenizerGoToTokenAtIndex, then CFStringTokenizerGetCurrentTokenRange...
  696. *
  697. * 2. To determine cluster breaks, use CFStringGetRangeOfComposedCharactersAtIndex.
  698. *
  699. * 3. For handling character boundaries / surrogate pairs in UTF16 text, the
  700. * following inline functions are available in CFString.h:
  701. * CFStringIsSurrogateHighCharacter, CFStringIsSurrogateLowCharacter,
  702. * CFStringGetLongCharacterForSurrogatePair, and CFStringGetSurrogatePairForLongCharacter.
  703. * However, CFString clients do not usually need to worry about handling surrogate pairs
  704. * directly.
  705. *
  706. *===============================================================================
  707. }
  708. {
  709. * UCCreateTextBreakLocator() *** DEPRECATED ***
  710. *
  711. * Deprecated:
  712. * Use CFStringTokenizer functions or
  713. * CFStringGetRangeOfComposedCharactersAtIndex, see discussion above
  714. * for details.
  715. *
  716. * Availability:
  717. * Mac OS X: in version 10.0 and later in CoreServices.framework but deprecated in 10.6
  718. * CarbonLib: in CarbonLib 1.0 and later
  719. * Non-Carbon CFM: in UnicodeUtilitiesLib 9.0 and later
  720. }
  721. function UCCreateTextBreakLocator( locale: LocaleRef; opVariant: LocaleOperationVariant; breakTypes: UCTextBreakType; var breakRef: TextBreakLocatorRef ): OSStatus; external name '_UCCreateTextBreakLocator';
  722. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6, __IPHONE_NA, __IPHONE_NA) *)
  723. {
  724. * UCFindTextBreak() *** DEPRECATED ***
  725. *
  726. * Deprecated:
  727. * Use CFStringTokenizer functions or
  728. * CFStringGetRangeOfComposedCharactersAtIndex, see discussion above
  729. * for details.
  730. *
  731. * Availability:
  732. * Mac OS X: in version 10.0 and later in CoreServices.framework but deprecated in 10.6
  733. * CarbonLib: in CarbonLib 1.0 and later
  734. * Non-Carbon CFM: in UnicodeUtilitiesLib 9.0 and later
  735. }
  736. function UCFindTextBreak( breakRef: TextBreakLocatorRef; breakType: UCTextBreakType; options: UCTextBreakOptions; textPtr: ConstUniCharPtr; textLength: UniCharCount; startOffset: UniCharArrayOffset; var breakOffset: UniCharArrayOffset ): OSStatus; external name '_UCFindTextBreak';
  737. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6, __IPHONE_NA, __IPHONE_NA) *)
  738. {
  739. * UCDisposeTextBreakLocator() *** DEPRECATED ***
  740. *
  741. * Deprecated:
  742. * Use CFStringTokenizer functions or
  743. * CFStringGetRangeOfComposedCharactersAtIndex, see discussion above
  744. * for details.
  745. *
  746. * Availability:
  747. * Mac OS X: in version 10.0 and later in CoreServices.framework but deprecated in 10.6
  748. * CarbonLib: in CarbonLib 1.0 and later
  749. * Non-Carbon CFM: in UnicodeUtilitiesLib 9.0 and later
  750. }
  751. function UCDisposeTextBreakLocator( var breakRef: TextBreakLocatorRef ): OSStatus; external name '_UCDisposeTextBreakLocator';
  752. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6, __IPHONE_NA, __IPHONE_NA) *)
  753. {
  754. -------------------------------------------------------------------------------------------------
  755. UNICODE TYPESELECT - FUNCTION APIs
  756. -------------------------------------------------------------------------------------------------
  757. }
  758. {
  759. * UCTypeSelectCreateSelector()
  760. *
  761. * Summary:
  762. * Responsible for creating the opaque UCTypeSelectRef object.
  763. *
  764. * Parameters:
  765. *
  766. * locale:
  767. * LocaleRef obtained by client from a call such as
  768. * LocaleRefFromLangOrRegionCode. This can be set to NULL if the
  769. * default system locale is desired.
  770. *
  771. * opVariant:
  772. * Variant of the locale. Specify 0 if no variant is needed.
  773. *
  774. * options:
  775. * Any collation options the client wishes to specify. These will
  776. * have an impact on the order in which selection will occur.
  777. * Specify kUCCollateStandardOptions for the default options.
  778. *
  779. * newSelector:
  780. * The newly created UCTypeSelectRef object.
  781. *
  782. * Result:
  783. * Will return paramErr if newSelector is NULL, or any other error
  784. * that may be returned by an internal function call.
  785. *
  786. * Availability:
  787. * Mac OS X: in version 10.4 and later in CoreServices.framework
  788. * CarbonLib: not available in CarbonLib 1.x
  789. * Non-Carbon CFM: not available
  790. }
  791. function UCTypeSelectCreateSelector( locale: LocaleRef { can be NULL }; opVariant: LocaleOperationVariant; options: UCCollateOptions; var newSelector: UCTypeSelectRef ): OSStatus; external name '_UCTypeSelectCreateSelector';
  792. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  793. {
  794. * UCTypeSelectFlushSelectorData()
  795. *
  796. * Summary:
  797. * Flushes the key list and resets the timeout timer for the
  798. * UCTypeSelectRef.
  799. *
  800. * Parameters:
  801. *
  802. * ref:
  803. * UCTypeSelectRef to be flushed.
  804. *
  805. * Result:
  806. * Returns paramErr if ref is invalid.
  807. *
  808. * Availability:
  809. * Mac OS X: in version 10.4 and later in CoreServices.framework
  810. * CarbonLib: not available in CarbonLib 1.x
  811. * Non-Carbon CFM: not available
  812. }
  813. function UCTypeSelectFlushSelectorData( ref: UCTypeSelectRef ): OSStatus; external name '_UCTypeSelectFlushSelectorData';
  814. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  815. {
  816. * UCTypeSelectReleaseSelector()
  817. *
  818. * Summary:
  819. * Cleans up and disposes of any temporary memory acquired by the
  820. * UCTypeSelectRef object.
  821. *
  822. * Parameters:
  823. *
  824. * ref:
  825. * A pointer to the UCTypeSelectRef to be disposed of. On exit,
  826. * the UCTypeSelectRef to which this parameter points will be set
  827. * to NULL.
  828. *
  829. * Result:
  830. * Returns paramErr if ref is invalid.
  831. *
  832. * Availability:
  833. * Mac OS X: in version 10.4 and later in CoreServices.framework
  834. * CarbonLib: not available in CarbonLib 1.x
  835. * Non-Carbon CFM: not available
  836. }
  837. function UCTypeSelectReleaseSelector( var ref: UCTypeSelectRef ): OSStatus; external name '_UCTypeSelectReleaseSelector';
  838. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  839. {
  840. * UCTypeSelectWouldResetBuffer()
  841. *
  842. * Summary:
  843. * Indicates whether, if the specified text were added to the
  844. * buffer, the current text in the buffer would be discarded.
  845. *
  846. * Parameters:
  847. *
  848. * inRef:
  849. * The type-selection object.
  850. *
  851. * inText:
  852. * The text that would be added to the buffer. Some text (such as
  853. * Backspace, Enter, and Clear keys) always causes the buffer to
  854. * be reset. May be NULL; in that case, the implementation only
  855. * considers the event time.
  856. *
  857. * inEventTime:
  858. * The time in seconds since boot (as returned by
  859. * GetCurrentEventTime) that the text event occurred. If the event
  860. * occurred at a time greater than the type-select timeout, then
  861. * the current buffered text would be discarded.
  862. *
  863. * Result:
  864. * Whether the current text in the buffer would be discarded while
  865. * processing the specified text.
  866. *
  867. * Availability:
  868. * Mac OS X: in version 10.4 and later in CoreServices.framework
  869. * CarbonLib: not available in CarbonLib 1.x
  870. * Non-Carbon CFM: not available
  871. }
  872. function UCTypeSelectWouldResetBuffer( inRef: UCTypeSelectRef; inText: CFStringRef { can be NULL }; inEventTime: Float64 ): Boolean; external name '_UCTypeSelectWouldResetBuffer';
  873. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  874. {
  875. * UCTypeSelectAddKeyToSelector()
  876. *
  877. * Summary:
  878. * Appends the given Unicode values to the selector's internal
  879. * buffer of keystrokes. It also handles timeouts and delete/clear
  880. * keys. If the key sent is a delete/clear/esc code, the key buffer
  881. * will be flushed and false will be returned.
  882. *
  883. * Parameters:
  884. *
  885. * inRef:
  886. * The type-selection object.
  887. *
  888. * inText:
  889. * A CFString that contains the keystroke to be added.
  890. *
  891. * inEventTime:
  892. * The time in seconds since boot (as returned by
  893. * GetCurrentEventTime) that the text event occurred. If zero is
  894. * passed, then the current time is used automatically.
  895. *
  896. * updateFlag:
  897. * On exit, notifies the client if it needs to update its current
  898. * selection, as follows:
  899. *
  900. * TRUE - indicates that the client needs to update its selection
  901. * based on the keystroke passed in. A call to UCTypeSelectCompare
  902. * or UCTypeSelectFindItem should be made to find the new item to
  903. * select based on the new keys added.
  904. *
  905. * FALSE - indicates that the client does not need to update its
  906. * selection. This would occur if a delete/clear/esc key was
  907. * passed in.
  908. *
  909. * Result:
  910. * returns paramErr if ref or textPtr are invalid. Can also return
  911. * other errors from intermediate function calls.
  912. *
  913. * Availability:
  914. * Mac OS X: in version 10.4 and later in CoreServices.framework
  915. * CarbonLib: not available in CarbonLib 1.x
  916. * Non-Carbon CFM: not available
  917. }
  918. function UCTypeSelectAddKeyToSelector( inRef: UCTypeSelectRef; inText: CFStringRef; inEventTime: Float64; var updateFlag: Boolean ): OSStatus; external name '_UCTypeSelectAddKeyToSelector';
  919. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  920. {
  921. * UCTypeSelectCompare()
  922. *
  923. * Summary:
  924. * Compares the Unicode text buffer passed in inText with the
  925. * keystroke buffer stored in the UCTypeSelectRef. This function
  926. * works the same as the non-Unicode TypeSelectCompare() call.
  927. *
  928. * Parameters:
  929. *
  930. * ref:
  931. * UCTypeSelectRef to which the Unicode text sent in inText will
  932. * be compared.
  933. *
  934. * inText:
  935. * A reference to the text to be compared
  936. *
  937. * result:
  938. * Just as in TypeSelectCompare(), the following values are
  939. * returned: -1 if characters in UCTypeSelectRefÕs keystroke
  940. * buffer sort before those in inText, 0 if characters in
  941. * UCTypeSelectRefÕs keystroke buffer are the same as those in
  942. * inText, and 1 if the characters in UCTypeSelectRefÕs keystroke
  943. * buffer sort after those in inText.
  944. *
  945. * Result:
  946. * This function can return three different types of values. First,
  947. * it will return paramErr if ref, inText, or result are invalid.
  948. * Second, if there have been no keys added to the UCTypeSelectRef
  949. * via calls to UCTypeSelectAddKeyToSelectorData(),
  950. * kUCTSNoKeysAddedToObjectErr will be returned. Finally, it can
  951. * also return other errors should any be encountered by
  952. * intermediate function calls.
  953. *
  954. * Availability:
  955. * Mac OS X: in version 10.4 and later in CoreServices.framework
  956. * CarbonLib: not available in CarbonLib 1.x
  957. * Non-Carbon CFM: not available
  958. }
  959. function UCTypeSelectCompare( ref: UCTypeSelectRef; inText: CFStringRef; var result: UCTypeSelectCompareResult ): OSStatus; external name '_UCTypeSelectCompare';
  960. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  961. {
  962. * UCTypeSelectFindItem()
  963. *
  964. * Summary:
  965. * In a given list, pointed to by listDataPtr, find the closest
  966. * match to the keystrokes stored in the UCTypeSelectRef. The
  967. * closest matchÕs index will be returned in closestItem. The list
  968. * to be searched may be ordered or unordered. In order for this
  969. * call to work, the client needs to provide a an IndexToUCString
  970. * callback UPP. This callback is necessary in order to provide the
  971. * client with data structure independence through client-side
  972. * indexing.
  973. *
  974. * Parameters:
  975. *
  976. * ref:
  977. * UCTypeSelectRef holding the state and keystrokes to be compared.
  978. *
  979. * listSize:
  980. * Size of the list to be searched through. If the size of the
  981. * list is unknown, pass in kUCTypeSelectMaxListSize (0xFFFFFFFF)
  982. * and have the IndexToUCString function return false after it has
  983. * reached the last item in the list.
  984. *
  985. * listDataPtr:
  986. * Pointer to the head or first node of the clientÕs data
  987. * structure. This will be passed into to the clientÕs
  988. * IndexToUCString function. Can be NULL, depending on the
  989. * clientÕs IndexToUCString implementation.
  990. *
  991. * refcon:
  992. * Any parameter the calling function wishes to pass as a
  993. * reference into its IndexToUCString callback function. This
  994. * parameter can be set to NULL if not needed.
  995. *
  996. * userUPP:
  997. * The UPP pointing to the clientÕs IndexToUCString callback
  998. * function.
  999. *
  1000. * closestItem:
  1001. * Upon return, this will contain the index of the item that
  1002. * matches the text in the keystroke buffer of UCTypeSelectRef.
  1003. *
  1004. * Result:
  1005. * This function has four possibilities for return values. First,
  1006. * paramErr will be returned if ref or closestItem are invalid.
  1007. * Second, if the search list is empty or if the first item cannot
  1008. * be read, kUCTSSearchListErr will be returned. Third, if there
  1009. * have been no keys added to the UCTypeSelectRef via calls to
  1010. * UCTypeSelectAddKeyToSelectorData(), kUCTSNoKeysAddedToObjectErr
  1011. * will be returned. Finally, this function can return other OS
  1012. * errors should any be encountered by an internal function call.
  1013. *
  1014. * Availability:
  1015. * Mac OS X: in version 10.4 and later in CoreServices.framework
  1016. * CarbonLib: not available in CarbonLib 1.x
  1017. * Non-Carbon CFM: not available
  1018. }
  1019. function UCTypeSelectFindItem( ref: UCTypeSelectRef; listSize: UInt32; listDataPtr: UnivPtr { can be NULL }; refcon: UnivPtr { can be NULL }; userUPP: IndexToUCStringUPP; var closestItem: UInt32 ): OSStatus; external name '_UCTypeSelectFindItem';
  1020. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  1021. {
  1022. * UCTypeSelectWalkList()
  1023. *
  1024. * Summary:
  1025. * UCTypeSelectWalkList can perform an in-order alphabetical walk of
  1026. * an unsorted list. To do this, the client passes a pointer to the
  1027. * current selectionÕs text in the currSelect parameter.
  1028. * UCTypeSelectWalkList will then search the list pointed to by
  1029. * listDataPtr for the closest item that is lexicographically either
  1030. * right before or right after the selected item. The client can
  1031. * choose which one to be returned by setting the direction
  1032. * parameter to kUCTSDirectionPrevious or kUCTSDirectionNext to get
  1033. * the item either lexicographically right before or after
  1034. * respectively. This call will not walk off the end of the list or
  1035. * do any wraparound searching. That is, if the item selected is the
  1036. * last item in the list and kUCDirectionNext is specified for the
  1037. * direction, that same item will be returned. Likewise for the case
  1038. * where the first item is selected nd kUCTSDirectionPrevious is
  1039. * specified. In order for this call to work, the client needs to
  1040. * provide an IndexToUCString callback UPP. This callback is
  1041. * necessary in order to provide the client with data structure
  1042. * independence through client-side indexing.
  1043. *
  1044. * Parameters:
  1045. *
  1046. * ref:
  1047. * UCTypeSelectRef holding state information as well as the
  1048. * function pointer needed to call the clientÕs IndexToUCString
  1049. * function
  1050. *
  1051. * currSelect:
  1052. * CFString reference to the current selectionÕs text.
  1053. *
  1054. * direction:
  1055. * The direction of the walk. The valid values for this parameter
  1056. * are:
  1057. *
  1058. * kUCTSDirectionNext - find the next item in the list
  1059. * kUCTSDirectionPrevious - find the previous item in the list
  1060. *
  1061. *
  1062. * If kUCTSDirectionNext is specified and the selected item is the
  1063. * last item in the list or if kUCTSDirectionPrevious is specified
  1064. * and the selected item is the first item in the list, the index
  1065. * of the selected item will be returned in closestItem.
  1066. *
  1067. * listSize:
  1068. * Size of the list to be searched through. If the size of the
  1069. * list is unknown, pass in kUCTypeSelectMaxListSize (0xFFFFFFFF)
  1070. * and have the IndexToUCString function return false after it has
  1071. * reached the last item in the list.
  1072. *
  1073. * listDataPtr:
  1074. * Pointer to the head or first node of the clientÕs data
  1075. * structure. This will be passed into to the clientÕs
  1076. * IndexToUCString function. Can be NULL, depending on the
  1077. * clientÕs IndexToUCString implementation.
  1078. *
  1079. * refcon:
  1080. * Any parameter the calling function wishes to pass as a
  1081. * reference into its IndexToUCString callback function. This
  1082. * parameter can be set to NULL if not needed.
  1083. *
  1084. * userUPP:
  1085. * The UPP pointing to the clientÕs IndexToUCString callback
  1086. * function.
  1087. *
  1088. * closestItem:
  1089. * Upon return, this will contain the index of the item that
  1090. * matches the text in the keystroke buffer of UCTypeSelectRef.
  1091. *
  1092. * Result:
  1093. * This function has three possibilities for return values. First,
  1094. * paramErr will be returned if ref, currSelect, or closestItem are
  1095. * invalid. Second, if the search list is empty or if the first item
  1096. * cannot be read, kUCTSSearchListErr will be returned. Finally,
  1097. * this function can return other OS errors should any be
  1098. * encountered by an internal function call.
  1099. *
  1100. * Availability:
  1101. * Mac OS X: in version 10.4 and later in CoreServices.framework
  1102. * CarbonLib: not available in CarbonLib 1.x
  1103. * Non-Carbon CFM: not available
  1104. }
  1105. function UCTypeSelectWalkList( ref: UCTypeSelectRef; currSelect: CFStringRef; direction: UCTSWalkDirection; listSize: UInt32; listDataPtr: UnivPtr { can be NULL }; refcon: UnivPtr { can be NULL }; userUPP: IndexToUCStringUPP; var closestItem: UInt32 ): OSStatus; external name '_UCTypeSelectWalkList';
  1106. (* __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_NA) *)
  1107. {$endc} {TARGET_OS_MAC}
  1108. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  1109. end.
  1110. {$endc} {not MACOSALLINCLUDE}