objc2_browser_engine_kit/generated/
BETextInput.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9use objc2_ui_kit::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/bedirectionaltextrange?language=objc)
14#[repr(C)]
15#[derive(Clone, Copy, Debug, PartialEq)]
16pub struct BEDirectionalTextRange {
17    pub offset: NSInteger,
18    pub length: NSInteger,
19}
20
21unsafe impl Encode for BEDirectionalTextRange {
22    const ENCODING: Encoding =
23        Encoding::Struct("?", &[<NSInteger>::ENCODING, <NSInteger>::ENCODING]);
24}
25
26unsafe impl RefEncode for BEDirectionalTextRange {
27    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
28}
29
30/// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/betextreplacementoptions?language=objc)
31// NS_OPTIONS
32#[repr(transparent)]
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
34pub struct BETextReplacementOptions(pub NSUInteger);
35bitflags::bitflags! {
36    impl BETextReplacementOptions: NSUInteger {
37        #[doc(alias = "BETextReplacementOptionsNone")]
38        const None = 0;
39        #[doc(alias = "BETextReplacementOptionsAddUnderline")]
40        const AddUnderline = 1<<0;
41    }
42}
43
44unsafe impl Encode for BETextReplacementOptions {
45    const ENCODING: Encoding = NSUInteger::ENCODING;
46}
47
48unsafe impl RefEncode for BETextReplacementOptions {
49    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
50}
51
52/// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/bekeymodifierflags?language=objc)
53// NS_ENUM
54#[repr(transparent)]
55#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
56pub struct BEKeyModifierFlags(pub NSInteger);
57impl BEKeyModifierFlags {
58    #[doc(alias = "BEKeyModifierFlagNone")]
59    pub const None: Self = Self(0);
60    #[doc(alias = "BEKeyModifierFlagShift")]
61    pub const Shift: Self = Self(1);
62    #[doc(alias = "BEKeyModifierFlagCapsLock")]
63    pub const CapsLock: Self = Self(2);
64}
65
66unsafe impl Encode for BEKeyModifierFlags {
67    const ENCODING: Encoding = NSInteger::ENCODING;
68}
69
70unsafe impl RefEncode for BEKeyModifierFlags {
71    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
72}
73
74extern_protocol!(
75    /// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/berespondereditactions?language=objc)
76    pub unsafe trait BEResponderEditActions: UIResponderStandardEditActions {
77        /// Shares the selected content.
78        /// See corresponding share methods in BETextInteraction.
79        ///
80        /// # Safety
81        ///
82        /// `sender` should be of the correct type.
83        #[optional]
84        #[unsafe(method(share:))]
85        #[unsafe(method_family = none)]
86        unsafe fn share(&self, sender: Option<&AnyObject>);
87
88        /// Adds a text replacement shortcut to the keyboard dictionary.
89        /// See corresponding shortcut methods in BETextInteraction.
90        ///
91        /// # Safety
92        ///
93        /// `sender` should be of the correct type.
94        #[optional]
95        #[unsafe(method(addShortcut:))]
96        #[unsafe(method_family = none)]
97        unsafe fn addShortcut(&self, sender: Option<&AnyObject>);
98
99        /// Presents a dictionary definition for the selected content.
100        /// See corresponding dictionary methods in BETextInteraction.
101        ///
102        /// # Safety
103        ///
104        /// `sender` should be of the correct type.
105        #[optional]
106        #[unsafe(method(lookup:))]
107        #[unsafe(method_family = none)]
108        unsafe fn lookup(&self, sender: Option<&AnyObject>);
109
110        /// Performs a find for the selected content
111        /// See find related methods in UIResponderStandardEditActions
112        ///
113        /// # Safety
114        ///
115        /// `sender` should be of the correct type.
116        #[optional]
117        #[unsafe(method(findSelected:))]
118        #[unsafe(method_family = none)]
119        unsafe fn findSelected(&self, sender: Option<&AnyObject>);
120
121        /// Shows the replacements for the selected content.
122        /// See corresponding replacement methods in BETextInteraction.
123        ///
124        /// # Safety
125        ///
126        /// `sender` should be of the correct type.
127        #[optional]
128        #[unsafe(method(promptForReplace:))]
129        #[unsafe(method_family = none)]
130        unsafe fn promptForReplace(&self, sender: Option<&AnyObject>);
131
132        /// Inserts the selected replacement for the selected content.
133        /// See corresponding replacement methods in BETextInputDelegate
134        ///
135        /// # Safety
136        ///
137        /// `sender` should be of the correct type.
138        #[optional]
139        #[unsafe(method(replace:))]
140        #[unsafe(method_family = none)]
141        unsafe fn replace(&self, sender: Option<&AnyObject>);
142
143        /// Presents a translation view for the selected content.
144        /// See corresponding translation methods in BETextInteraction.
145        ///
146        /// # Safety
147        ///
148        /// `sender` should be of the correct type.
149        #[optional]
150        #[unsafe(method(translate:))]
151        #[unsafe(method_family = none)]
152        unsafe fn translate(&self, sender: Option<&AnyObject>);
153
154        /// Converts the selected content between traditional and simplified Chinese
155        /// See corresponding transliteration methods in BETextInteraction.
156        ///
157        /// # Safety
158        ///
159        /// `sender` should be of the correct type.
160        #[optional]
161        #[unsafe(method(transliterateChinese:))]
162        #[unsafe(method_family = none)]
163        unsafe fn transliterateChinese(&self, sender: Option<&AnyObject>);
164    }
165);
166
167extern_protocol!(
168    /// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/betextselectiondirectionnavigation?language=objc)
169    pub unsafe trait BETextSelectionDirectionNavigation {
170        /// Moves the cursor in the specified directions, such as in response to an arrow key press.
171        #[unsafe(method(moveInLayoutDirection:))]
172        #[unsafe(method_family = none)]
173        unsafe fn moveInLayoutDirection(&self, direction: UITextLayoutDirection);
174
175        /// Extends text selection in the specified directions, such as in response to an arrow key press while shift is held.
176        #[unsafe(method(extendInLayoutDirection:))]
177        #[unsafe(method_family = none)]
178        unsafe fn extendInLayoutDirection(&self, direction: UITextLayoutDirection);
179
180        /// Moves the cursor in the specified directions by granularity, in response to different key combinations:
181        ///
182        /// Option + left/right = word
183        /// Option + up/down = paragraph
184        /// Command + left/right = line
185        /// Command + up/down = document
186        #[unsafe(method(moveInStorageDirection:byGranularity:))]
187        #[unsafe(method_family = none)]
188        unsafe fn moveInStorageDirection_byGranularity(
189            &self,
190            direction: UITextStorageDirection,
191            granularity: UITextGranularity,
192        );
193
194        /// Moves the selection in the specified directions by granularity, in response to different key combinations:
195        ///
196        /// word = shift + option + left/right
197        /// paragraph = shift + option + up/down
198        /// line = shift + command + left/right
199        /// document = shift + command + up/down
200        #[unsafe(method(extendInStorageDirection:byGranularity:))]
201        #[unsafe(method_family = none)]
202        unsafe fn extendInStorageDirection_byGranularity(
203            &self,
204            direction: UITextStorageDirection,
205            granularity: UITextGranularity,
206        );
207    }
208);
209
210extern_protocol!(
211    /// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/beextendedtextinputtraits?language=objc)
212    pub unsafe trait BEExtendedTextInputTraits: UITextInputTraits {
213        /// Represents whether the active web input field is a single line document
214        #[optional]
215        #[unsafe(method(isSingleLineDocument))]
216        #[unsafe(method_family = none)]
217        unsafe fn isSingleLineDocument(&self) -> bool;
218
219        /// Disables the learning of new words and corrections and prevents their addition into the keyboard lexicon
220        #[optional]
221        #[unsafe(method(isTypingAdaptationEnabled))]
222        #[unsafe(method_family = none)]
223        unsafe fn isTypingAdaptationEnabled(&self) -> bool;
224
225        /// Customizes the color of the text cursor at the insertion point
226        #[optional]
227        #[unsafe(method(insertionPointColor))]
228        #[unsafe(method_family = none)]
229        unsafe fn insertionPointColor(&self) -> Option<Retained<UIColor>>;
230
231        /// Customizes the color of the selection handles
232        #[optional]
233        #[unsafe(method(selectionHandleColor))]
234        #[unsafe(method_family = none)]
235        unsafe fn selectionHandleColor(&self) -> Option<Retained<UIColor>>;
236
237        /// Customizes the color of the selection highlight rect
238        #[optional]
239        #[unsafe(method(selectionHighlightColor))]
240        #[unsafe(method_family = none)]
241        unsafe fn selectionHighlightColor(&self) -> Option<Retained<UIColor>>;
242    }
243);
244
245extern_protocol!(
246    /// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/betextinput?language=objc)
247    pub unsafe trait BETextInput:
248        UIKeyInput + BETextSelectionDirectionNavigation + BEResponderEditActions
249    {
250        #[cfg(feature = "BETextInputDelegate")]
251        /// A system-provided input delegate is assigned when the system is interested in input changes.
252        #[unsafe(method(asyncInputDelegate))]
253        #[unsafe(method_family = none)]
254        unsafe fn asyncInputDelegate(
255            &self,
256        ) -> Option<Retained<ProtocolObject<dyn BETextInputDelegate>>>;
257
258        #[cfg(feature = "BETextInputDelegate")]
259        /// Setter for [`asyncInputDelegate`][Self::asyncInputDelegate].
260        ///
261        /// This is a [weak property][objc2::topics::weak_property].
262        #[unsafe(method(setAsyncInputDelegate:))]
263        #[unsafe(method_family = none)]
264        unsafe fn setAsyncInputDelegate(
265            &self,
266            async_input_delegate: Option<&ProtocolObject<dyn BETextInputDelegate>>,
267        );
268
269        /// Returns whether text related actions, such those included in UIResponderStandardEditActions, can be handled
270        ///
271        /// # Safety
272        ///
273        /// - `action` must be a valid selector.
274        /// - `sender` should be of the correct type.
275        #[unsafe(method(canPerformAction:withSender:))]
276        #[unsafe(method_family = none)]
277        unsafe fn canPerformAction_withSender(
278            &self,
279            action: Sel,
280            sender: Option<&AnyObject>,
281        ) -> bool;
282
283        /// Reflects the ability to modify text
284        #[unsafe(method(isEditable))]
285        #[unsafe(method_family = none)]
286        unsafe fn isEditable(&self) -> bool;
287
288        #[cfg(all(feature = "BEKeyEntry", feature = "block2"))]
289        /// Delegates the handling for each stage of a key event (key down, press, up) and allows the BETextInput object to indicate whether it should prevent default system behaviors.
290        #[unsafe(method(handleKeyEntry:withCompletionHandler:))]
291        #[unsafe(method_family = none)]
292        unsafe fn handleKeyEntry_withCompletionHandler(
293            &self,
294            entry: &BEKeyEntry,
295            completion_handler: &block2::DynBlock<dyn Fn(NonNull<BEKeyEntry>, Bool)>,
296        );
297
298        /// Indicates a transition in shift state
299        #[unsafe(method(shiftKeyStateChangedFromState:toState:))]
300        #[unsafe(method_family = none)]
301        unsafe fn shiftKeyStateChangedFromState_toState(
302            &self,
303            old_state: BEKeyModifierFlags,
304            new_state: BEKeyModifierFlags,
305        );
306
307        /// Returns the text in the specified range.
308        #[unsafe(method(textInRange:))]
309        #[unsafe(method_family = none)]
310        unsafe fn textInRange(&self, range: &UITextRange) -> Option<Retained<NSString>>;
311
312        /// Returns the number of UTF-16 characters between one text position and another text position.
313        #[unsafe(method(offsetFromPosition:toPosition:))]
314        #[unsafe(method_family = none)]
315        unsafe fn offsetFromPosition_toPosition(
316            &self,
317            from: &UITextPosition,
318            to_position: &UITextPosition,
319        ) -> NSInteger;
320
321        /// Sets the base writing direction for a specified range of text in a document.
322        #[unsafe(method(setBaseWritingDirection:forRange:))]
323        #[unsafe(method_family = none)]
324        unsafe fn setBaseWritingDirection_forRange(
325            &self,
326            writing_direction: NSWritingDirection,
327            range: &UITextRange,
328        );
329
330        /// Deletes text by the specified direction and granularity.  Current supported combinations include:
331        ///
332        /// character backward  = delete
333        /// character forward = delete-forward
334        /// word backward = option + delete
335        /// word forward = option + delete-forward
336        /// line end = cmd + delete
337        /// line start = cmd + delete-forward
338        /// paragraph  end = ctrl + K
339        /// paragraph start = ctrl + fn + K
340        ///
341        /// (On Apple keyboards, the delete-forward key is a combination of fn + delete)
342        #[unsafe(method(deleteInDirection:toGranularity:))]
343        #[unsafe(method_family = none)]
344        unsafe fn deleteInDirection_toGranularity(
345            &self,
346            direction: UITextStorageDirection,
347            granularity: UITextGranularity,
348        );
349
350        /// Transposes the characters on either side of the caret in response to the key command, ctrl + T
351        #[unsafe(method(transposeCharactersAroundSelection))]
352        #[unsafe(method_family = none)]
353        unsafe fn transposeCharactersAroundSelection(&self);
354
355        #[cfg(feature = "block2")]
356        /// Replace the specified text preceding the current selection.
357        ///
358        /// Completion handler should be invoked with the rects representing the replacementText.  If the replaceText
359        /// could not be completed succesfully, such as when the originalText no longer matches the current text, then
360        /// the completion handler should be invoked with an empty array.
361        #[unsafe(method(replaceText:withText:options:completionHandler:))]
362        #[unsafe(method_family = none)]
363        unsafe fn replaceText_withText_options_completionHandler(
364            &self,
365            original_text: &NSString,
366            replacement_text: &NSString,
367            options: BETextReplacementOptions,
368            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<UITextSelectionRect>>)>,
369        );
370
371        #[cfg(all(feature = "BETextDocumentContext", feature = "block2"))]
372        /// Invoked by the system to gather context around the current selection.  Clients should generally include the setence
373        /// that contains the current selection and include the previous sentence if the current selection is at a boundary.
374        #[unsafe(method(requestTextContextForAutocorrectionWithCompletionHandler:))]
375        #[unsafe(method_family = none)]
376        unsafe fn requestTextContextForAutocorrectionWithCompletionHandler(
377            &self,
378            completion_handler: &block2::DynBlock<dyn Fn(NonNull<BETextDocumentContext>)>,
379        );
380
381        #[cfg(feature = "block2")]
382        /// Invoked by the system to gather context for the presentation of various text related UI's.
383        /// Completion handler should be invoked with the `UITextSelectionRect`s for the substring nearest to the caret
384        /// that matches the given `input`
385        #[unsafe(method(requestTextRectsForString:withCompletionHandler:))]
386        #[unsafe(method_family = none)]
387        unsafe fn requestTextRectsForString_withCompletionHandler(
388            &self,
389            input: &NSString,
390            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<UITextSelectionRect>>)>,
391        );
392
393        /// Controls whether the edit menu is allowed to be presented or should be suppressed.
394        #[unsafe(method(automaticallyPresentEditMenu))]
395        #[unsafe(method_family = none)]
396        unsafe fn automaticallyPresentEditMenu(&self) -> bool;
397
398        #[cfg(feature = "block2")]
399        /// Invoked by the system to gather context, including the client's preference for how the edit menu should be positioned
400        /// relative to the selected text.
401        #[unsafe(method(requestPreferredArrowDirectionForEditMenuWithCompletionHandler:))]
402        #[unsafe(method_family = none)]
403        unsafe fn requestPreferredArrowDirectionForEditMenuWithCompletionHandler(
404            &self,
405            completion_handler: &block2::DynBlock<dyn Fn(UIEditMenuArrowDirection)>,
406        );
407
408        /// Invoked by the system when it is about to present an edit menu with an animator.
409        #[unsafe(method(systemWillPresentEditMenuWithAnimator:))]
410        #[unsafe(method_family = none)]
411        unsafe fn systemWillPresentEditMenuWithAnimator(
412            &self,
413            animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
414        );
415
416        /// Invoked by the system when it is about to dismiss an edit menu with an animator.
417        #[unsafe(method(systemWillDismissEditMenuWithAnimator:))]
418        #[unsafe(method_family = none)]
419        unsafe fn systemWillDismissEditMenuWithAnimator(
420            &self,
421            animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
422        );
423
424        /// Object from which the BEExtendedTextInputTraits will be gathered.
425        #[unsafe(method(extendedTextInputTraits))]
426        #[unsafe(method_family = none)]
427        unsafe fn extendedTextInputTraits(
428            &self,
429        ) -> Option<Retained<ProtocolObject<dyn BEExtendedTextInputTraits>>>;
430
431        /// Returns a dictionary containing NSAttributedString keys represeting appearance customizations.
432        ///
433        /// For example, text styling information influence the appearance of a correction rect.
434        #[unsafe(method(textStylingAtPosition:inDirection:))]
435        #[unsafe(method_family = none)]
436        unsafe fn textStylingAtPosition_inDirection(
437            &self,
438            position: &UITextPosition,
439            direction: UITextStorageDirection,
440        ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
441
442        /// Returns whether replacement should be allowed for an editable element.
443        ///
444        /// For example, replacement shouldn't be allowed in password fields or when the selected text
445        /// is only consists of whitespace.
446        #[unsafe(method(isReplaceAllowed))]
447        #[unsafe(method_family = none)]
448        unsafe fn isReplaceAllowed(&self) -> bool;
449
450        /// Replaces the specified `text` with `replacementText`
451        ///
452        /// 1. If there is a nonzero length current selection, then replace text with replacementText.
453        /// 2. If there is zero length current selection, then replace the matching word before the selection
454        /// 3. If the zero length selection is at the start of the element, then replace the matching word after the selection
455        #[unsafe(method(replaceSelectedText:withText:))]
456        #[unsafe(method_family = none)]
457        unsafe fn replaceSelectedText_withText(&self, text: &NSString, replacement_text: &NSString);
458
459        #[cfg(all(feature = "BETextSelectionTypes", feature = "objc2-core-foundation"))]
460        /// Indicates the `point` the text interaction gesture is tracking has changed
461        ///
462        /// Indicate to the system the change was handled by invoking:
463        /// -[BETextInteraction selectionChangedWithGestureAtPoint:gesture:state:flags:]
464        #[unsafe(method(updateCurrentSelectionTo:fromGesture:inState:))]
465        #[unsafe(method_family = none)]
466        unsafe fn updateCurrentSelectionTo_fromGesture_inState(
467            &self,
468            point: CGPoint,
469            gesture_type: BEGestureType,
470            state: UIGestureRecognizerState,
471        );
472
473        #[cfg(all(feature = "BETextSelectionTypes", feature = "objc2-core-foundation"))]
474        /// Indicates the selection should change to contain the text between the
475        /// `from` and `to` points.
476        ///
477        /// For example, see the keyboard's trackpad selection gesture explained in
478        /// "Turn the onscreen keyboard into a trackpad" guide on support.apple.com
479        #[unsafe(method(setSelectionFromPoint:toPoint:gesture:state:))]
480        #[unsafe(method_family = none)]
481        unsafe fn setSelectionFromPoint_toPoint_gesture_state(
482            &self,
483            from: CGPoint,
484            to: CGPoint,
485            gesture: BEGestureType,
486            state: UIGestureRecognizerState,
487        );
488
489        #[cfg(all(feature = "BETextSelectionTypes", feature = "objc2-core-foundation"))]
490        /// Adjusts the selection's start or end boundary specified by `boundaryIsStart` to the `point`
491        ///
492        /// For example, the selection's boundary would be adjusted when the user moves the selection handles
493        ///
494        /// Indicate to the system that the change was handled by invoking:
495        /// -[BETextInteraction selectionBoundaryAdjustedToPoint:touchPhase:flags:]
496        #[unsafe(method(adjustSelectionBoundaryToPoint:touchPhase:baseIsStart:flags:))]
497        #[unsafe(method_family = none)]
498        unsafe fn adjustSelectionBoundaryToPoint_touchPhase_baseIsStart_flags(
499            &self,
500            point: CGPoint,
501            touch: BESelectionTouchPhase,
502            boundary_is_start: bool,
503            flags: BESelectionFlags,
504        );
505
506        #[cfg(all(feature = "BETextSelectionTypes", feature = "objc2-core-foundation"))]
507        /// Returns whether a gesture with the given `gestureType` should begin for the given `point`
508        #[unsafe(method(textInteractionGesture:shouldBeginAtPoint:))]
509        #[unsafe(method_family = none)]
510        unsafe fn textInteractionGesture_shouldBeginAtPoint(
511            &self,
512            gesture_type: BEGestureType,
513            point: CGPoint,
514        ) -> bool;
515
516        /// If different than the text input view, one can return a container view here for selection views
517        /// that draw _below_ text. Includes the selection highlight view. If this is unimplemented or nil
518        /// is returned, views are to be installed onto the text input view.
519        #[optional]
520        #[unsafe(method(selectionContainerViewBelowText))]
521        #[unsafe(method_family = none)]
522        unsafe fn selectionContainerViewBelowText(&self) -> Option<Retained<UIView>>;
523
524        /// If different than the text input view, one can return a container view here for selection views
525        /// that draw _above_ text. Includes selection range adjustment handles. If this is unimplemented
526        /// or nil is returned, views are to be installed onto the text input view.
527        #[optional]
528        #[unsafe(method(selectionContainerViewAboveText))]
529        #[unsafe(method_family = none)]
530        unsafe fn selectionContainerViewAboveText(&self) -> Option<Retained<UIView>>;
531
532        /// String representing the selected text.
533        #[unsafe(method(selectedText))]
534        #[unsafe(method_family = none)]
535        unsafe fn selectedText(&self) -> Option<Retained<NSString>>;
536
537        /// Range representing the selected text.
538        ///
539        /// Text may have a selection, either zero-length (a caret) or ranged.
540        /// Editing operations are always performed on the text from this selection.  nil corresponds to no selection.
541        #[unsafe(method(selectedTextRange))]
542        #[unsafe(method_family = none)]
543        unsafe fn selectedTextRange(&self) -> Option<Retained<UITextRange>>;
544
545        /// Setter for [`selectedTextRange`][Self::selectedTextRange].
546        ///
547        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
548        #[unsafe(method(setSelectedTextRange:))]
549        #[unsafe(method_family = none)]
550        unsafe fn setSelectedTextRange(&self, selected_text_range: Option<&UITextRange>);
551
552        /// Represents whether the current selection is at the beginning of the document
553        #[unsafe(method(isSelectionAtDocumentStart))]
554        #[unsafe(method_family = none)]
555        unsafe fn isSelectionAtDocumentStart(&self) -> bool;
556
557        #[cfg(feature = "objc2-core-foundation")]
558        /// Returns a rectangle to draw the caret at a specified insertion point.
559        #[unsafe(method(caretRectForPosition:))]
560        #[unsafe(method_family = none)]
561        unsafe fn caretRectForPosition(&self, position: &UITextPosition) -> CGRect;
562
563        /// Returns an array of selection rects corresponding to the range of text.
564        #[unsafe(method(selectionRectsForRange:))]
565        #[unsafe(method_family = none)]
566        unsafe fn selectionRectsForRange(
567            &self,
568            range: &UITextRange,
569        ) -> Retained<NSArray<UITextSelectionRect>>;
570
571        /// Selects a word with autocorrect replacement suggestions when it is tapped
572        #[unsafe(method(selectWordForReplacement))]
573        #[unsafe(method_family = none)]
574        unsafe fn selectWordForReplacement(&self);
575
576        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
577        /// Adjusts the selection from current text position to include text at the given `point`.
578        ///
579        /// For example, while holding shift, click a point in a text document and the current selection should adjust to include
580        /// all the text up to that point.
581        #[unsafe(method(updateSelectionWithExtentPoint:boundary:completionHandler:))]
582        #[unsafe(method_family = none)]
583        unsafe fn updateSelectionWithExtentPoint_boundary_completionHandler(
584            &self,
585            point: CGPoint,
586            granularity: UITextGranularity,
587            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
588        );
589
590        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
591        /// Updates the selection to text contained within the specified `granularity` at the given `point`
592        #[unsafe(method(selectTextInGranularity:atPoint:completionHandler:))]
593        #[unsafe(method_family = none)]
594        unsafe fn selectTextInGranularity_atPoint_completionHandler(
595            &self,
596            granularity: UITextGranularity,
597            point: CGPoint,
598            completion_handler: &block2::DynBlock<dyn Fn()>,
599        );
600
601        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
602        /// Sets the selection caret to the given point
603        #[unsafe(method(selectPositionAtPoint:completionHandler:))]
604        #[unsafe(method_family = none)]
605        unsafe fn selectPositionAtPoint_completionHandler(
606            &self,
607            point: CGPoint,
608            completion_handler: &block2::DynBlock<dyn Fn()>,
609        );
610
611        #[cfg(all(
612            feature = "BETextDocumentContext",
613            feature = "BETextDocumentRequest",
614            feature = "block2",
615            feature = "objc2-core-foundation"
616        ))]
617        /// Sets the selection caret to the given point.  Also includes a convenience document context request.
618        #[unsafe(method(selectPositionAtPoint:withContextRequest:completionHandler:))]
619        #[unsafe(method_family = none)]
620        unsafe fn selectPositionAtPoint_withContextRequest_completionHandler(
621            &self,
622            point: CGPoint,
623            request: &BETextDocumentRequest,
624            completion_handler: &block2::DynBlock<dyn Fn(NonNull<BETextDocumentContext>)>,
625        );
626
627        #[cfg(feature = "block2")]
628        /// Adjusts the selection by the moving the selected range by the given `range`, in character granularity units.
629        ///
630        /// The start of the current selection is moved by `range.offset` characters, and the length of the selection
631        /// is modified by `range.length` characters. For instance, if the current selection is the word "world" in
632        /// "Hello world" and the `range` is `{ -6, -2 }`, the selected text after adjustment will be "Hel".
633        #[unsafe(method(adjustSelectionByRange:completionHandler:))]
634        #[unsafe(method_family = none)]
635        unsafe fn adjustSelectionByRange_completionHandler(
636            &self,
637            range: BEDirectionalTextRange,
638            completion_handler: &block2::DynBlock<dyn Fn()>,
639        );
640
641        /// Adjusts the current selection by `offset` in character granularity units
642        #[unsafe(method(moveByOffset:))]
643        #[unsafe(method_family = none)]
644        unsafe fn moveByOffset(&self, offset: NSInteger);
645
646        #[cfg(feature = "block2")]
647        /// Moves the caret to relative to the current position in the `direction` to the given `granularity`.
648        /// The `direction` is "forward" or "backward" in accordance with the directionality of the language.
649        ///
650        /// This method is invoked only when -[BETextInput textInteractionGesture:shouldBeginAtPoint:] returns YES.
651        #[unsafe(method(moveSelectionAtBoundary:inStorageDirection:completionHandler:))]
652        #[unsafe(method_family = none)]
653        unsafe fn moveSelectionAtBoundary_inStorageDirection_completionHandler(
654            &self,
655            granularity: UITextGranularity,
656            direction: UITextStorageDirection,
657            completion_handler: &block2::DynBlock<dyn Fn()>,
658        );
659
660        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
661        /// Indicates the edit menu is being shown at the given location in the text input view's
662        /// coordinate space.
663        ///
664        /// The completion handler takes a BOOL indicating whether or not the menu
665        /// should be shown, a string representing the text context around the updated selection range
666        /// (generally encompassing the paragraph that contains the selection range) as well as the
667        /// range of the updated selection, relative to the paragraph context.
668        #[unsafe(method(selectTextForEditMenuWithLocationInView:completionHandler:))]
669        #[unsafe(method_family = none)]
670        unsafe fn selectTextForEditMenuWithLocationInView_completionHandler(
671            &self,
672            location_in_view: CGPoint,
673            completion_handler: &block2::DynBlock<dyn Fn(Bool, *mut NSString, NSRange)>,
674        );
675
676        /// String for the text that has been marked as part of an active input session
677        #[unsafe(method(markedText))]
678        #[unsafe(method_family = none)]
679        unsafe fn markedText(&self) -> Option<Retained<NSString>>;
680
681        /// Attributed string for the text that has been marked as part of an active input session
682        #[unsafe(method(attributedMarkedText))]
683        #[unsafe(method_family = none)]
684        unsafe fn attributedMarkedText(&self) -> Option<Retained<NSAttributedString>>;
685
686        /// Range representing the position of the markedText.
687        ///
688        /// If text can be selected, it can be marked. Marked text represents provisionally
689        /// inserted text that has yet to be confirmed by the user.  It requires unique visual
690        /// treatment in its display.  If there is any marked text, the selection, whether a
691        /// caret or an extended range, always resides within.
692        ///
693        /// Setting marked text either replaces the existing marked text or, if none is present,
694        /// inserts it from the current selection.
695        ///
696        /// Return nil if no marked text
697        #[unsafe(method(markedTextRange))]
698        #[unsafe(method_family = none)]
699        unsafe fn markedTextRange(&self) -> Option<Retained<UITextRange>>;
700
701        /// Indicates whether there any text is currently marked as part of an active input session
702        #[unsafe(method(hasMarkedText))]
703        #[unsafe(method_family = none)]
704        unsafe fn hasMarkedText(&self) -> bool;
705
706        /// Inserts the provided text and marks it to indicate that it is part of an active input session.
707        #[unsafe(method(setMarkedText:selectedRange:))]
708        #[unsafe(method_family = none)]
709        unsafe fn setMarkedText_selectedRange(
710            &self,
711            marked_text: Option<&NSString>,
712            selected_range: NSRange,
713        );
714
715        /// Inserts the provided styled text and marks it to indicate that it is part of an active input session.
716        #[unsafe(method(setAttributedMarkedText:selectedRange:))]
717        #[unsafe(method_family = none)]
718        unsafe fn setAttributedMarkedText_selectedRange(
719            &self,
720            marked_text: Option<&NSAttributedString>,
721            selected_range: NSRange,
722        );
723
724        /// Unmarks the currently marked text
725        #[unsafe(method(unmarkText))]
726        #[unsafe(method_family = none)]
727        unsafe fn unmarkText(&self);
728
729        #[cfg(feature = "objc2-core-foundation")]
730        /// Returns whether a point should be considered "near" the marked text.
731        /// Used to determine whether text interaction gestures near marked text should begin.
732        ///
733        /// For example, text interaction gestures may considered "near" if they are within 66 points.
734        #[unsafe(method(isPointNearMarkedText:))]
735        #[unsafe(method_family = none)]
736        unsafe fn isPointNearMarkedText(&self, point: CGPoint) -> bool;
737
738        #[cfg(all(
739            feature = "BETextDocumentContext",
740            feature = "BETextDocumentRequest",
741            feature = "block2"
742        ))]
743        /// Gathers context about the current document for the system
744        #[unsafe(method(requestDocumentContext:completionHandler:))]
745        #[unsafe(method_family = none)]
746        unsafe fn requestDocumentContext_completionHandler(
747            &self,
748            request: &BETextDocumentRequest,
749            completion_handler: &block2::DynBlock<dyn Fn(NonNull<BETextDocumentContext>)>,
750        );
751
752        /// Indicates the system is about to insert the final dictation result.
753        #[unsafe(method(willInsertFinalDictationResult))]
754        #[unsafe(method_family = none)]
755        unsafe fn willInsertFinalDictationResult(&self);
756
757        /// Inserts/replaces text for a dictation.
758        #[unsafe(method(replaceDictatedText:withText:))]
759        #[unsafe(method_family = none)]
760        unsafe fn replaceDictatedText_withText(&self, old_text: &NSString, new_text: &NSString);
761
762        /// Indicates system has inserted the final dictation result
763        #[unsafe(method(didInsertFinalDictationResult))]
764        #[unsafe(method_family = none)]
765        unsafe fn didInsertFinalDictationResult(&self);
766
767        #[cfg(feature = "BETextAlternatives")]
768        /// Returns the text alternatives that are available to the text input object.
769        #[unsafe(method(alternativesForSelectedText))]
770        #[unsafe(method_family = none)]
771        unsafe fn alternativesForSelectedText(
772            &self,
773        ) -> Option<Retained<NSArray<BETextAlternatives>>>;
774
775        #[cfg(feature = "BETextAlternatives")]
776        /// Adds text alternatives to the text input object for the current selection
777        #[unsafe(method(addTextAlternatives:))]
778        #[unsafe(method_family = none)]
779        unsafe fn addTextAlternatives(&self, alternatives: &BETextAlternatives);
780
781        #[cfg(feature = "BETextAlternatives")]
782        /// Inserts the given `text` or one of it's alternative texts available on `alternatives`
783        #[unsafe(method(insertTextAlternatives:))]
784        #[unsafe(method_family = none)]
785        unsafe fn insertTextAlternatives(&self, alternatives: &BETextAlternatives);
786
787        /// Removes text alternatives from the text input object for the current selection
788        #[optional]
789        #[unsafe(method(removeTextAlternatives))]
790        #[unsafe(method_family = none)]
791        unsafe fn removeTextAlternatives(&self);
792
793        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
794        /// Inserts a placeholder object to reserve visual space during text input.
795        /// If `size.height` is less than or equal to zero, then the placeholder is inline and line height.
796        /// If `size.height` is greather than zero, then the placeholder is treated as a paragraph of height `size.height`.
797        #[unsafe(method(insertTextPlaceholderWithSize:completionHandler:))]
798        #[unsafe(method_family = none)]
799        unsafe fn insertTextPlaceholderWithSize_completionHandler(
800            &self,
801            size: CGSize,
802            completion_handler: &block2::DynBlock<dyn Fn(NonNull<UITextPlaceholder>)>,
803        );
804
805        #[cfg(feature = "block2")]
806        /// Removes a placeholder object from the text input view.
807        #[unsafe(method(removeTextPlaceholder:willInsertText:completionHandler:))]
808        #[unsafe(method_family = none)]
809        unsafe fn removeTextPlaceholder_willInsertText_completionHandler(
810            &self,
811            placeholder: &UITextPlaceholder,
812            will_insert_text: bool,
813            completion_handler: &block2::DynBlock<dyn Fn()>,
814        );
815
816        #[cfg(feature = "BETextSuggestion")]
817        /// Inserts a `textSuggestion` in response to a user suggestion selection
818        #[unsafe(method(insertTextSuggestion:))]
819        #[unsafe(method_family = none)]
820        unsafe fn insertTextSuggestion(&self, text_suggestion: &BETextSuggestion);
821
822        /// An affiliated view that provides a coordinate system for all geometric values in this protocol.
823        #[unsafe(method(textInputView))]
824        #[unsafe(method_family = none)]
825        unsafe fn textInputView(&self) -> Retained<UIView>;
826
827        #[cfg(feature = "objc2-core-foundation")]
828        /// Returns a rect representing the bounds of the first line of marked text, if marked text is set.
829        ///
830        /// Otherwise, this returns a rect representing the bounds of the last word at or before the insertion point.
831        #[unsafe(method(textFirstRect))]
832        #[unsafe(method_family = none)]
833        unsafe fn textFirstRect(&self) -> CGRect;
834
835        #[cfg(feature = "objc2-core-foundation")]
836        /// Returns a rect representing the bounds of the last line of marked text, if marked text is set.
837        ///
838        /// Otherwise, this returns a rect representing the bounds of the last word at or before the insertion point.
839        /// This may have the same value of `textFirstRect`, but can differ in cases such as a word that spans two lines.
840        #[unsafe(method(textLastRect))]
841        #[unsafe(method_family = none)]
842        unsafe fn textLastRect(&self) -> CGRect;
843
844        #[cfg(feature = "objc2-core-foundation")]
845        /// Rect used to place UI (such as selection handles) in a location that isn't obscurred by app UI.
846        ///
847        /// Must return a rect in `textInputView`'s coordinate space.
848        #[unsafe(method(unobscuredContentRect))]
849        #[unsafe(method_family = none)]
850        unsafe fn unobscuredContentRect(&self) -> CGRect;
851
852        /// View representing the web content that is agnostic of zoom state.
853        /// Used to draw zoom agnostic system UI elements, such as the selection handles
854        #[unsafe(method(unscaledView))]
855        #[unsafe(method_family = none)]
856        unsafe fn unscaledView(&self) -> Retained<UIView>;
857
858        #[cfg(feature = "objc2-core-foundation")]
859        /// Rect representing the bounds of editable elements, used to ensure and UI don't overflow outside them
860        #[unsafe(method(selectionClipRect))]
861        #[unsafe(method_family = none)]
862        unsafe fn selectionClipRect(&self) -> CGRect;
863
864        #[cfg(feature = "objc2-core-foundation")]
865        /// Indicates autoscrolling has been triggered by a text interaction gesture.
866        ///
867        /// Called repeatedly during range adjustment gestures, or when placing the text cursor.
868        ///
869        /// The given point is in the coordinate space of the `textInputView`.
870        #[unsafe(method(autoscrollToPoint:))]
871        #[unsafe(method_family = none)]
872        unsafe fn autoscrollToPoint(&self, point: CGPoint);
873
874        /// Indicates autoscrolling is complete.
875        ///
876        /// There will be no more calls into`autoscrollToPoint` until a text interaction gesture starts autoscrolling.
877        #[unsafe(method(cancelAutoscroll))]
878        #[unsafe(method_family = none)]
879        unsafe fn cancelAutoscroll(&self);
880
881        /// Called when the user has requested the keyboard to dismiss itself.
882        #[optional]
883        #[unsafe(method(keyboardWillDismiss))]
884        #[unsafe(method_family = none)]
885        unsafe fn keyboardWillDismiss(&self);
886    }
887);