1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_protocol!(
13 #[cfg(feature = "UITextInputTraits")]
15 pub unsafe trait UIKeyInput: UITextInputTraits + MainThreadOnly {
16 #[unsafe(method(hasText))]
17 #[unsafe(method_family = none)]
18 unsafe fn hasText(&self) -> bool;
19
20 #[unsafe(method(insertText:))]
21 #[unsafe(method_family = none)]
22 unsafe fn insertText(&self, text: &NSString);
23
24 #[unsafe(method(deleteBackward))]
25 #[unsafe(method_family = none)]
26 unsafe fn deleteBackward(&self);
27 }
28);
29
30#[repr(transparent)]
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
34pub struct UITextStorageDirection(pub NSInteger);
35impl UITextStorageDirection {
36 #[doc(alias = "UITextStorageDirectionForward")]
37 pub const Forward: Self = Self(0);
38 #[doc(alias = "UITextStorageDirectionBackward")]
39 pub const Backward: Self = Self(1);
40}
41
42unsafe impl Encode for UITextStorageDirection {
43 const ENCODING: Encoding = NSInteger::ENCODING;
44}
45
46unsafe impl RefEncode for UITextStorageDirection {
47 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
48}
49
50#[repr(transparent)]
53#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
54pub struct UITextLayoutDirection(pub NSInteger);
55impl UITextLayoutDirection {
56 #[doc(alias = "UITextLayoutDirectionRight")]
57 pub const Right: Self = Self(2);
58 #[doc(alias = "UITextLayoutDirectionLeft")]
59 pub const Left: Self = Self(3);
60 #[doc(alias = "UITextLayoutDirectionUp")]
61 pub const Up: Self = Self(4);
62 #[doc(alias = "UITextLayoutDirectionDown")]
63 pub const Down: Self = Self(5);
64}
65
66unsafe impl Encode for UITextLayoutDirection {
67 const ENCODING: Encoding = NSInteger::ENCODING;
68}
69
70unsafe impl RefEncode for UITextLayoutDirection {
71 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74pub type UITextDirection = NSInteger;
77
78#[repr(transparent)]
81#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
82pub struct UITextGranularity(pub NSInteger);
83impl UITextGranularity {
84 #[doc(alias = "UITextGranularityCharacter")]
85 pub const Character: Self = Self(0);
86 #[doc(alias = "UITextGranularityWord")]
87 pub const Word: Self = Self(1);
88 #[doc(alias = "UITextGranularitySentence")]
89 pub const Sentence: Self = Self(2);
90 #[doc(alias = "UITextGranularityParagraph")]
91 pub const Paragraph: Self = Self(3);
92 #[doc(alias = "UITextGranularityLine")]
93 pub const Line: Self = Self(4);
94 #[doc(alias = "UITextGranularityDocument")]
95 pub const Document: Self = Self(5);
96}
97
98unsafe impl Encode for UITextGranularity {
99 const ENCODING: Encoding = NSInteger::ENCODING;
100}
101
102unsafe impl RefEncode for UITextGranularity {
103 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
104}
105
106extern_class!(
107 #[unsafe(super(NSObject))]
109 #[thread_kind = MainThreadOnly]
110 #[derive(Debug, PartialEq, Eq, Hash)]
111 pub struct UIDictationPhrase;
112);
113
114unsafe impl NSObjectProtocol for UIDictationPhrase {}
115
116impl UIDictationPhrase {
117 extern_methods!(
118 #[unsafe(method(text))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn text(&self) -> Retained<NSString>;
121
122 #[unsafe(method(alternativeInterpretations))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn alternativeInterpretations(&self) -> Option<Retained<NSArray<NSString>>>;
125 );
126}
127
128impl UIDictationPhrase {
130 extern_methods!(
131 #[unsafe(method(init))]
132 #[unsafe(method_family = init)]
133 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
134
135 #[unsafe(method(new))]
136 #[unsafe(method_family = new)]
137 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
138 );
139}
140
141extern_class!(
142 #[unsafe(super(NSObject))]
144 #[thread_kind = MainThreadOnly]
145 #[derive(Debug, PartialEq, Eq, Hash)]
146 pub struct UITextInputAssistantItem;
147);
148
149unsafe impl NSObjectProtocol for UITextInputAssistantItem {}
150
151impl UITextInputAssistantItem {
152 extern_methods!(
153 #[unsafe(method(allowsHidingShortcuts))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn allowsHidingShortcuts(&self) -> bool;
157
158 #[unsafe(method(setAllowsHidingShortcuts:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn setAllowsHidingShortcuts(&self, allows_hiding_shortcuts: bool);
162
163 #[cfg(feature = "UIBarButtonItemGroup")]
164 #[unsafe(method(leadingBarButtonGroups))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn leadingBarButtonGroups(&self) -> Retained<NSArray<UIBarButtonItemGroup>>;
168
169 #[cfg(feature = "UIBarButtonItemGroup")]
170 #[unsafe(method(setLeadingBarButtonGroups:))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn setLeadingBarButtonGroups(
174 &self,
175 leading_bar_button_groups: &NSArray<UIBarButtonItemGroup>,
176 );
177
178 #[cfg(feature = "UIBarButtonItemGroup")]
179 #[unsafe(method(trailingBarButtonGroups))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn trailingBarButtonGroups(&self) -> Retained<NSArray<UIBarButtonItemGroup>>;
183
184 #[cfg(feature = "UIBarButtonItemGroup")]
185 #[unsafe(method(setTrailingBarButtonGroups:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn setTrailingBarButtonGroups(
189 &self,
190 trailing_bar_button_groups: &NSArray<UIBarButtonItemGroup>,
191 );
192
193 #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
194 #[unsafe(method(keyboardActionButtonItem))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn keyboardActionButtonItem(&self) -> Option<Retained<UIBarButtonItem>>;
198
199 #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
200 #[unsafe(method(setKeyboardActionButtonItem:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn setKeyboardActionButtonItem(
204 &self,
205 keyboard_action_button_item: Option<&UIBarButtonItem>,
206 );
207 );
208}
209
210impl UITextInputAssistantItem {
212 extern_methods!(
213 #[unsafe(method(init))]
214 #[unsafe(method_family = init)]
215 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
216
217 #[unsafe(method(new))]
218 #[unsafe(method_family = new)]
219 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
220 );
221}
222
223extern_class!(
224 #[unsafe(super(NSObject))]
226 #[thread_kind = MainThreadOnly]
227 #[derive(Debug, PartialEq, Eq, Hash)]
228 pub struct UITextPlaceholder;
229);
230
231unsafe impl NSObjectProtocol for UITextPlaceholder {}
232
233impl UITextPlaceholder {
234 extern_methods!(
235 #[unsafe(method(rects))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn rects(&self) -> Retained<NSArray<UITextSelectionRect>>;
238 );
239}
240
241impl UITextPlaceholder {
243 extern_methods!(
244 #[unsafe(method(init))]
245 #[unsafe(method_family = init)]
246 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
247
248 #[unsafe(method(new))]
249 #[unsafe(method_family = new)]
250 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
251 );
252}
253
254#[repr(transparent)]
257#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
258pub struct UITextAlternativeStyle(pub NSInteger);
259impl UITextAlternativeStyle {
260 #[doc(alias = "UITextAlternativeStyleNone")]
261 pub const None: Self = Self(0);
262 #[doc(alias = "UITextAlternativeStyleLowConfidence")]
263 pub const LowConfidence: Self = Self(1);
264}
265
266unsafe impl Encode for UITextAlternativeStyle {
267 const ENCODING: Encoding = NSInteger::ENCODING;
268}
269
270unsafe impl RefEncode for UITextAlternativeStyle {
271 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
272}
273
274extern_protocol!(
275 #[cfg(feature = "UITextInputTraits")]
277 pub unsafe trait UITextInput: UIKeyInput + MainThreadOnly {
278 #[unsafe(method(textInRange:))]
279 #[unsafe(method_family = none)]
280 unsafe fn textInRange(&self, range: &UITextRange) -> Option<Retained<NSString>>;
281
282 #[unsafe(method(replaceRange:withText:))]
283 #[unsafe(method_family = none)]
284 unsafe fn replaceRange_withText(&self, range: &UITextRange, text: &NSString);
285
286 #[unsafe(method(selectedTextRange))]
287 #[unsafe(method_family = none)]
288 unsafe fn selectedTextRange(&self) -> Option<Retained<UITextRange>>;
289
290 #[unsafe(method(setSelectedTextRange:))]
292 #[unsafe(method_family = none)]
293 unsafe fn setSelectedTextRange(&self, selected_text_range: Option<&UITextRange>);
294
295 #[unsafe(method(markedTextRange))]
296 #[unsafe(method_family = none)]
297 unsafe fn markedTextRange(&self) -> Option<Retained<UITextRange>>;
298
299 #[unsafe(method(markedTextStyle))]
300 #[unsafe(method_family = none)]
301 unsafe fn markedTextStyle(
302 &self,
303 ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
304
305 #[unsafe(method(setMarkedTextStyle:))]
307 #[unsafe(method_family = none)]
308 unsafe fn setMarkedTextStyle(
309 &self,
310 marked_text_style: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
311 );
312
313 #[unsafe(method(setMarkedText:selectedRange:))]
314 #[unsafe(method_family = none)]
315 unsafe fn setMarkedText_selectedRange(
316 &self,
317 marked_text: Option<&NSString>,
318 selected_range: NSRange,
319 );
320
321 #[unsafe(method(unmarkText))]
322 #[unsafe(method_family = none)]
323 unsafe fn unmarkText(&self);
324
325 #[unsafe(method(beginningOfDocument))]
326 #[unsafe(method_family = none)]
327 unsafe fn beginningOfDocument(&self) -> Retained<UITextPosition>;
328
329 #[unsafe(method(endOfDocument))]
330 #[unsafe(method_family = none)]
331 unsafe fn endOfDocument(&self) -> Retained<UITextPosition>;
332
333 #[unsafe(method(textRangeFromPosition:toPosition:))]
334 #[unsafe(method_family = none)]
335 unsafe fn textRangeFromPosition_toPosition(
336 &self,
337 from_position: &UITextPosition,
338 to_position: &UITextPosition,
339 ) -> Option<Retained<UITextRange>>;
340
341 #[unsafe(method(positionFromPosition:offset:))]
342 #[unsafe(method_family = none)]
343 unsafe fn positionFromPosition_offset(
344 &self,
345 position: &UITextPosition,
346 offset: NSInteger,
347 ) -> Option<Retained<UITextPosition>>;
348
349 #[unsafe(method(positionFromPosition:inDirection:offset:))]
350 #[unsafe(method_family = none)]
351 unsafe fn positionFromPosition_inDirection_offset(
352 &self,
353 position: &UITextPosition,
354 direction: UITextLayoutDirection,
355 offset: NSInteger,
356 ) -> Option<Retained<UITextPosition>>;
357
358 #[unsafe(method(comparePosition:toPosition:))]
359 #[unsafe(method_family = none)]
360 unsafe fn comparePosition_toPosition(
361 &self,
362 position: &UITextPosition,
363 other: &UITextPosition,
364 ) -> NSComparisonResult;
365
366 #[unsafe(method(offsetFromPosition:toPosition:))]
367 #[unsafe(method_family = none)]
368 unsafe fn offsetFromPosition_toPosition(
369 &self,
370 from: &UITextPosition,
371 to_position: &UITextPosition,
372 ) -> NSInteger;
373
374 #[unsafe(method(inputDelegate))]
375 #[unsafe(method_family = none)]
376 unsafe fn inputDelegate(&self)
377 -> Option<Retained<ProtocolObject<dyn UITextInputDelegate>>>;
378
379 #[unsafe(method(setInputDelegate:))]
382 #[unsafe(method_family = none)]
383 unsafe fn setInputDelegate(
384 &self,
385 input_delegate: Option<&ProtocolObject<dyn UITextInputDelegate>>,
386 );
387
388 #[unsafe(method(tokenizer))]
389 #[unsafe(method_family = none)]
390 unsafe fn tokenizer(&self) -> Retained<ProtocolObject<dyn UITextInputTokenizer>>;
391
392 #[unsafe(method(positionWithinRange:farthestInDirection:))]
393 #[unsafe(method_family = none)]
394 unsafe fn positionWithinRange_farthestInDirection(
395 &self,
396 range: &UITextRange,
397 direction: UITextLayoutDirection,
398 ) -> Option<Retained<UITextPosition>>;
399
400 #[unsafe(method(characterRangeByExtendingPosition:inDirection:))]
401 #[unsafe(method_family = none)]
402 unsafe fn characterRangeByExtendingPosition_inDirection(
403 &self,
404 position: &UITextPosition,
405 direction: UITextLayoutDirection,
406 ) -> Option<Retained<UITextRange>>;
407
408 #[cfg(feature = "NSText")]
409 #[unsafe(method(baseWritingDirectionForPosition:inDirection:))]
410 #[unsafe(method_family = none)]
411 unsafe fn baseWritingDirectionForPosition_inDirection(
412 &self,
413 position: &UITextPosition,
414 direction: UITextStorageDirection,
415 ) -> NSWritingDirection;
416
417 #[cfg(feature = "NSText")]
418 #[unsafe(method(setBaseWritingDirection:forRange:))]
419 #[unsafe(method_family = none)]
420 unsafe fn setBaseWritingDirection_forRange(
421 &self,
422 writing_direction: NSWritingDirection,
423 range: &UITextRange,
424 );
425
426 #[cfg(feature = "objc2-core-foundation")]
427 #[unsafe(method(firstRectForRange:))]
428 #[unsafe(method_family = none)]
429 unsafe fn firstRectForRange(&self, range: &UITextRange) -> CGRect;
430
431 #[cfg(feature = "objc2-core-foundation")]
432 #[unsafe(method(caretRectForPosition:))]
433 #[unsafe(method_family = none)]
434 unsafe fn caretRectForPosition(&self, position: &UITextPosition) -> CGRect;
435
436 #[unsafe(method(selectionRectsForRange:))]
437 #[unsafe(method_family = none)]
438 unsafe fn selectionRectsForRange(
439 &self,
440 range: &UITextRange,
441 ) -> Retained<NSArray<UITextSelectionRect>>;
442
443 #[cfg(feature = "objc2-core-foundation")]
444 #[unsafe(method(closestPositionToPoint:))]
445 #[unsafe(method_family = none)]
446 unsafe fn closestPositionToPoint(&self, point: CGPoint)
447 -> Option<Retained<UITextPosition>>;
448
449 #[cfg(feature = "objc2-core-foundation")]
450 #[unsafe(method(closestPositionToPoint:withinRange:))]
451 #[unsafe(method_family = none)]
452 unsafe fn closestPositionToPoint_withinRange(
453 &self,
454 point: CGPoint,
455 range: &UITextRange,
456 ) -> Option<Retained<UITextPosition>>;
457
458 #[cfg(feature = "objc2-core-foundation")]
459 #[unsafe(method(characterRangeAtPoint:))]
460 #[unsafe(method_family = none)]
461 unsafe fn characterRangeAtPoint(&self, point: CGPoint) -> Option<Retained<UITextRange>>;
462
463 #[optional]
464 #[unsafe(method(shouldChangeTextInRange:replacementText:))]
465 #[unsafe(method_family = none)]
466 unsafe fn shouldChangeTextInRange_replacementText(
467 &self,
468 range: &UITextRange,
469 text: &NSString,
470 ) -> bool;
471
472 #[optional]
473 #[unsafe(method(textStylingAtPosition:inDirection:))]
474 #[unsafe(method_family = none)]
475 unsafe fn textStylingAtPosition_inDirection(
476 &self,
477 position: &UITextPosition,
478 direction: UITextStorageDirection,
479 ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
480
481 #[optional]
482 #[unsafe(method(positionWithinRange:atCharacterOffset:))]
483 #[unsafe(method_family = none)]
484 unsafe fn positionWithinRange_atCharacterOffset(
485 &self,
486 range: &UITextRange,
487 offset: NSInteger,
488 ) -> Option<Retained<UITextPosition>>;
489
490 #[optional]
491 #[unsafe(method(characterOffsetOfPosition:withinRange:))]
492 #[unsafe(method_family = none)]
493 unsafe fn characterOffsetOfPosition_withinRange(
494 &self,
495 position: &UITextPosition,
496 range: &UITextRange,
497 ) -> NSInteger;
498
499 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
500 #[optional]
501 #[unsafe(method(textInputView))]
502 #[unsafe(method_family = none)]
503 unsafe fn textInputView(&self) -> Retained<UIView>;
504
505 #[optional]
506 #[unsafe(method(selectionAffinity))]
507 #[unsafe(method_family = none)]
508 unsafe fn selectionAffinity(&self) -> UITextStorageDirection;
509
510 #[optional]
512 #[unsafe(method(setSelectionAffinity:))]
513 #[unsafe(method_family = none)]
514 unsafe fn setSelectionAffinity(&self, selection_affinity: UITextStorageDirection);
515
516 #[optional]
517 #[unsafe(method(insertDictationResult:))]
518 #[unsafe(method_family = none)]
519 unsafe fn insertDictationResult(&self, dictation_result: &NSArray<UIDictationPhrase>);
520
521 #[optional]
522 #[unsafe(method(dictationRecordingDidEnd))]
523 #[unsafe(method_family = none)]
524 unsafe fn dictationRecordingDidEnd(&self);
525
526 #[optional]
527 #[unsafe(method(dictationRecognitionFailed))]
528 #[unsafe(method_family = none)]
529 unsafe fn dictationRecognitionFailed(&self);
530
531 #[optional]
532 #[unsafe(method(insertDictationResultPlaceholder))]
533 #[unsafe(method_family = none)]
534 unsafe fn insertDictationResultPlaceholder(&self) -> Retained<AnyObject>;
535
536 #[cfg(feature = "objc2-core-foundation")]
537 #[optional]
538 #[unsafe(method(frameForDictationResultPlaceholder:))]
539 #[unsafe(method_family = none)]
540 unsafe fn frameForDictationResultPlaceholder(&self, placeholder: &AnyObject) -> CGRect;
541
542 #[optional]
543 #[unsafe(method(removeDictationResultPlaceholder:willInsertResult:))]
544 #[unsafe(method_family = none)]
545 unsafe fn removeDictationResultPlaceholder_willInsertResult(
546 &self,
547 placeholder: &AnyObject,
548 will_insert_result: bool,
549 );
550
551 #[optional]
552 #[unsafe(method(insertText:alternatives:style:))]
553 #[unsafe(method_family = none)]
554 unsafe fn insertText_alternatives_style(
555 &self,
556 text: &NSString,
557 alternatives: &NSArray<NSString>,
558 style: UITextAlternativeStyle,
559 );
560
561 #[optional]
562 #[unsafe(method(setAttributedMarkedText:selectedRange:))]
563 #[unsafe(method_family = none)]
564 unsafe fn setAttributedMarkedText_selectedRange(
565 &self,
566 marked_text: Option<&NSAttributedString>,
567 selected_range: NSRange,
568 );
569
570 #[cfg(feature = "objc2-core-foundation")]
571 #[optional]
572 #[unsafe(method(insertTextPlaceholderWithSize:))]
573 #[unsafe(method_family = none)]
574 unsafe fn insertTextPlaceholderWithSize(&self, size: CGSize)
575 -> Retained<UITextPlaceholder>;
576
577 #[optional]
578 #[unsafe(method(removeTextPlaceholder:))]
579 #[unsafe(method_family = none)]
580 unsafe fn removeTextPlaceholder(&self, text_placeholder: &UITextPlaceholder);
581
582 #[cfg(feature = "objc2-core-foundation")]
583 #[optional]
584 #[unsafe(method(beginFloatingCursorAtPoint:))]
585 #[unsafe(method_family = none)]
586 unsafe fn beginFloatingCursorAtPoint(&self, point: CGPoint);
587
588 #[cfg(feature = "objc2-core-foundation")]
589 #[optional]
590 #[unsafe(method(updateFloatingCursorAtPoint:))]
591 #[unsafe(method_family = none)]
592 unsafe fn updateFloatingCursorAtPoint(&self, point: CGPoint);
593
594 #[optional]
595 #[unsafe(method(endFloatingCursor))]
596 #[unsafe(method_family = none)]
597 unsafe fn endFloatingCursor(&self);
598
599 #[cfg(feature = "objc2-core-foundation")]
600 #[optional]
603 #[unsafe(method(caretTransformForPosition:))]
604 #[unsafe(method_family = none)]
605 unsafe fn caretTransformForPosition(&self, position: &UITextPosition) -> CGAffineTransform;
606
607 #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
608 #[optional]
619 #[unsafe(method(editMenuForTextRange:suggestedActions:))]
620 #[unsafe(method_family = none)]
621 unsafe fn editMenuForTextRange_suggestedActions(
622 &self,
623 text_range: &UITextRange,
624 suggested_actions: &NSArray<UIMenuElement>,
625 ) -> Option<Retained<UIMenu>>;
626
627 #[cfg(feature = "UIEditMenuInteraction")]
628 #[optional]
629 #[unsafe(method(willPresentEditMenuWithAnimator:))]
630 #[unsafe(method_family = none)]
631 unsafe fn willPresentEditMenuWithAnimator(
632 &self,
633 animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
634 );
635
636 #[cfg(feature = "UIEditMenuInteraction")]
637 #[optional]
638 #[unsafe(method(willDismissEditMenuWithAnimator:))]
639 #[unsafe(method_family = none)]
640 unsafe fn willDismissEditMenuWithAnimator(
641 &self,
642 animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
643 );
644
645 #[optional]
646 #[unsafe(method(supportsAdaptiveImageGlyph))]
647 #[unsafe(method_family = none)]
648 unsafe fn supportsAdaptiveImageGlyph(&self) -> bool;
649
650 #[optional]
652 #[unsafe(method(setSupportsAdaptiveImageGlyph:))]
653 #[unsafe(method_family = none)]
654 unsafe fn setSupportsAdaptiveImageGlyph(&self, supports_adaptive_image_glyph: bool);
655
656 #[cfg(feature = "NSAdaptiveImageGlyph")]
657 #[optional]
658 #[unsafe(method(insertAdaptiveImageGlyph:replacementRange:))]
659 #[unsafe(method_family = none)]
660 unsafe fn insertAdaptiveImageGlyph_replacementRange(
661 &self,
662 adaptive_image_glyph: &NSAdaptiveImageGlyph,
663 replacement_range: &UITextRange,
664 );
665
666 #[optional]
667 #[unsafe(method(isEditable))]
668 #[unsafe(method_family = none)]
669 unsafe fn isEditable(&self) -> bool;
670
671 #[optional]
672 #[unsafe(method(insertAttributedText:))]
673 #[unsafe(method_family = none)]
674 unsafe fn insertAttributedText(&self, string: &NSAttributedString);
675
676 #[optional]
677 #[unsafe(method(attributedTextInRange:))]
678 #[unsafe(method_family = none)]
679 unsafe fn attributedTextInRange(&self, range: &UITextRange)
680 -> Retained<NSAttributedString>;
681
682 #[optional]
683 #[unsafe(method(replaceRange:withAttributedText:))]
684 #[unsafe(method_family = none)]
685 unsafe fn replaceRange_withAttributedText(
686 &self,
687 range: &UITextRange,
688 attributed_text: &NSAttributedString,
689 );
690
691 #[optional]
692 #[unsafe(method(willPresentWritingTools))]
693 #[unsafe(method_family = none)]
694 unsafe fn willPresentWritingTools(&self);
695
696 #[optional]
697 #[unsafe(method(didDismissWritingTools))]
698 #[unsafe(method_family = none)]
699 unsafe fn didDismissWritingTools(&self);
700 }
701);
702
703extern "C" {
704 pub static UITextInputTextBackgroundColorKey: &'static NSString;
706}
707
708extern "C" {
709 pub static UITextInputTextColorKey: &'static NSString;
711}
712
713extern "C" {
714 pub static UITextInputTextFontKey: &'static NSString;
716}
717
718extern_class!(
719 #[unsafe(super(NSObject))]
721 #[thread_kind = MainThreadOnly]
722 #[derive(Debug, PartialEq, Eq, Hash)]
723 pub struct UITextPosition;
724);
725
726unsafe impl NSObjectProtocol for UITextPosition {}
727
728impl UITextPosition {
729 extern_methods!();
730}
731
732impl UITextPosition {
734 extern_methods!(
735 #[unsafe(method(init))]
736 #[unsafe(method_family = init)]
737 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
738
739 #[unsafe(method(new))]
740 #[unsafe(method_family = new)]
741 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
742 );
743}
744
745extern_class!(
746 #[unsafe(super(NSObject))]
748 #[thread_kind = MainThreadOnly]
749 #[derive(Debug, PartialEq, Eq, Hash)]
750 pub struct UITextRange;
751);
752
753unsafe impl NSObjectProtocol for UITextRange {}
754
755impl UITextRange {
756 extern_methods!(
757 #[unsafe(method(isEmpty))]
758 #[unsafe(method_family = none)]
759 pub unsafe fn isEmpty(&self) -> bool;
760
761 #[unsafe(method(start))]
762 #[unsafe(method_family = none)]
763 pub unsafe fn start(&self) -> Retained<UITextPosition>;
764
765 #[unsafe(method(end))]
766 #[unsafe(method_family = none)]
767 pub unsafe fn end(&self) -> Retained<UITextPosition>;
768 );
769}
770
771impl UITextRange {
773 extern_methods!(
774 #[unsafe(method(init))]
775 #[unsafe(method_family = init)]
776 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
777
778 #[unsafe(method(new))]
779 #[unsafe(method_family = new)]
780 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
781 );
782}
783
784extern_class!(
785 #[unsafe(super(NSObject))]
787 #[thread_kind = MainThreadOnly]
788 #[derive(Debug, PartialEq, Eq, Hash)]
789 pub struct UITextSelectionRect;
790);
791
792unsafe impl NSObjectProtocol for UITextSelectionRect {}
793
794impl UITextSelectionRect {
795 extern_methods!(
796 #[cfg(feature = "objc2-core-foundation")]
797 #[unsafe(method(rect))]
798 #[unsafe(method_family = none)]
799 pub unsafe fn rect(&self) -> CGRect;
800
801 #[cfg(feature = "NSText")]
802 #[unsafe(method(writingDirection))]
803 #[unsafe(method_family = none)]
804 pub unsafe fn writingDirection(&self) -> NSWritingDirection;
805
806 #[unsafe(method(containsStart))]
807 #[unsafe(method_family = none)]
808 pub unsafe fn containsStart(&self) -> bool;
809
810 #[unsafe(method(containsEnd))]
811 #[unsafe(method_family = none)]
812 pub unsafe fn containsEnd(&self) -> bool;
813
814 #[unsafe(method(isVertical))]
815 #[unsafe(method_family = none)]
816 pub unsafe fn isVertical(&self) -> bool;
817
818 #[cfg(feature = "objc2-core-foundation")]
819 #[unsafe(method(transform))]
823 #[unsafe(method_family = none)]
824 pub unsafe fn transform(&self) -> CGAffineTransform;
825 );
826}
827
828impl UITextSelectionRect {
830 extern_methods!(
831 #[unsafe(method(init))]
832 #[unsafe(method_family = init)]
833 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
834
835 #[unsafe(method(new))]
836 #[unsafe(method_family = new)]
837 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
838 );
839}
840
841extern_protocol!(
842 pub unsafe trait UITextInputDelegate: NSObjectProtocol + MainThreadOnly {
844 #[cfg(feature = "UITextInputTraits")]
845 #[unsafe(method(selectionWillChange:))]
846 #[unsafe(method_family = none)]
847 unsafe fn selectionWillChange(&self, text_input: Option<&ProtocolObject<dyn UITextInput>>);
848
849 #[cfg(feature = "UITextInputTraits")]
850 #[unsafe(method(selectionDidChange:))]
851 #[unsafe(method_family = none)]
852 unsafe fn selectionDidChange(&self, text_input: Option<&ProtocolObject<dyn UITextInput>>);
853
854 #[cfg(feature = "UITextInputTraits")]
855 #[unsafe(method(textWillChange:))]
856 #[unsafe(method_family = none)]
857 unsafe fn textWillChange(&self, text_input: Option<&ProtocolObject<dyn UITextInput>>);
858
859 #[cfg(feature = "UITextInputTraits")]
860 #[unsafe(method(textDidChange:))]
861 #[unsafe(method_family = none)]
862 unsafe fn textDidChange(&self, text_input: Option<&ProtocolObject<dyn UITextInput>>);
863 }
864);
865
866extern_protocol!(
867 pub unsafe trait UITextInputTokenizer: NSObjectProtocol + MainThreadOnly {
869 #[unsafe(method(rangeEnclosingPosition:withGranularity:inDirection:))]
870 #[unsafe(method_family = none)]
871 unsafe fn rangeEnclosingPosition_withGranularity_inDirection(
872 &self,
873 position: &UITextPosition,
874 granularity: UITextGranularity,
875 direction: UITextDirection,
876 ) -> Option<Retained<UITextRange>>;
877
878 #[unsafe(method(isPosition:atBoundary:inDirection:))]
879 #[unsafe(method_family = none)]
880 unsafe fn isPosition_atBoundary_inDirection(
881 &self,
882 position: &UITextPosition,
883 granularity: UITextGranularity,
884 direction: UITextDirection,
885 ) -> bool;
886
887 #[unsafe(method(positionFromPosition:toBoundary:inDirection:))]
888 #[unsafe(method_family = none)]
889 unsafe fn positionFromPosition_toBoundary_inDirection(
890 &self,
891 position: &UITextPosition,
892 granularity: UITextGranularity,
893 direction: UITextDirection,
894 ) -> Option<Retained<UITextPosition>>;
895
896 #[unsafe(method(isPosition:withinTextUnit:inDirection:))]
897 #[unsafe(method_family = none)]
898 unsafe fn isPosition_withinTextUnit_inDirection(
899 &self,
900 position: &UITextPosition,
901 granularity: UITextGranularity,
902 direction: UITextDirection,
903 ) -> bool;
904 }
905);
906
907extern_class!(
908 #[unsafe(super(NSObject))]
910 #[thread_kind = MainThreadOnly]
911 #[derive(Debug, PartialEq, Eq, Hash)]
912 pub struct UITextInputStringTokenizer;
913);
914
915unsafe impl NSObjectProtocol for UITextInputStringTokenizer {}
916
917unsafe impl UITextInputTokenizer for UITextInputStringTokenizer {}
918
919impl UITextInputStringTokenizer {
920 extern_methods!(
921 #[cfg(all(feature = "UIResponder", feature = "UITextInputTraits"))]
922 #[unsafe(method(initWithTextInput:))]
923 #[unsafe(method_family = init)]
924 pub unsafe fn initWithTextInput(
925 this: Allocated<Self>,
926 text_input: &UIResponder,
927 ) -> Retained<Self>;
928 );
929}
930
931impl UITextInputStringTokenizer {
933 extern_methods!(
934 #[unsafe(method(init))]
935 #[unsafe(method_family = init)]
936 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
937
938 #[unsafe(method(new))]
939 #[unsafe(method_family = new)]
940 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
941 );
942}
943
944extern_class!(
945 #[unsafe(super(NSObject))]
947 #[thread_kind = MainThreadOnly]
948 #[derive(Debug, PartialEq, Eq, Hash)]
949 pub struct UITextInputMode;
950);
951
952unsafe impl NSCoding for UITextInputMode {}
953
954unsafe impl NSObjectProtocol for UITextInputMode {}
955
956unsafe impl NSSecureCoding for UITextInputMode {}
957
958impl UITextInputMode {
959 extern_methods!(
960 #[unsafe(method(primaryLanguage))]
961 #[unsafe(method_family = none)]
962 pub unsafe fn primaryLanguage(&self) -> Option<Retained<NSString>>;
963
964 #[deprecated]
965 #[unsafe(method(currentInputMode))]
966 #[unsafe(method_family = none)]
967 pub unsafe fn currentInputMode(mtm: MainThreadMarker) -> Option<Retained<UITextInputMode>>;
968
969 #[unsafe(method(activeInputModes))]
970 #[unsafe(method_family = none)]
971 pub unsafe fn activeInputModes(mtm: MainThreadMarker)
972 -> Retained<NSArray<UITextInputMode>>;
973 );
974}
975
976impl UITextInputMode {
978 extern_methods!(
979 #[unsafe(method(init))]
980 #[unsafe(method_family = init)]
981 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
982
983 #[unsafe(method(new))]
984 #[unsafe(method_family = new)]
985 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
986 );
987}
988
989extern "C" {
990 pub static UITextInputCurrentInputModeDidChangeNotification: &'static NSNotificationName;
992}