UnicodeUtilities.pas 47 KB

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