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