objc2_ui_kit/generated/
UIWritingToolsCoordinator.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::*;
9
10use crate::*;
11
12/// Constants that specify the reason you updated your view’s content
13/// outside of the Writing Tools workflow.
14///
15/// If you modify your view’s text storage while Writing Tools is active,
16/// report those changes to your ``UIWritingToolsCoordinator`` object
17/// so it can track them correctly. Call the
18/// ``UIWritingToolsCoordinator/updateRange(_:with:reason:forContextWithIdentifier:)``
19/// method to report changes that occur inside one of your context objects. Call the
20/// ``UIWritingToolsCoordinator/updateForReflowedTextInContextWithIdentifier(_:)``
21/// method for changes that affect the layout of your text, such as text insertions
22/// before a context object or changes to your view’s frame rectangle.
23///
24/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwritingtoolscoordinatortextupdatereason?language=objc)
25// NS_ENUM
26#[repr(transparent)]
27#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
28pub struct UIWritingToolsCoordinatorTextUpdateReason(pub NSInteger);
29impl UIWritingToolsCoordinatorTextUpdateReason {
30    /// An operation that involved a person editing the text in your view.
31    ///
32    /// Specify this option when the changes come from the text input system.
33    #[doc(alias = "UIWritingToolsCoordinatorTextUpdateReasonTyping")]
34    pub const Typing: Self = Self(0);
35    /// An operation that changed the view’s text as part of an undo or
36    /// redo command.
37    ///
38    /// Specify this option when an undo or redo command initiated the
39    /// change to your view.
40    #[doc(alias = "UIWritingToolsCoordinatorTextUpdateReasonUndoRedo")]
41    pub const UndoRedo: Self = Self(1);
42}
43
44unsafe impl Encode for UIWritingToolsCoordinatorTextUpdateReason {
45    const ENCODING: Encoding = NSInteger::ENCODING;
46}
47
48unsafe impl RefEncode for UIWritingToolsCoordinatorTextUpdateReason {
49    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
50}
51
52/// The states that indicate the current activity, if any, Writing Tools
53/// is performing in your view.
54///
55/// Making changes to your view requires several different levels of
56/// interaction. Initially, Writing Tools displays its UI and collects
57/// information about what the person wants to do. When the person selects
58/// an operation, Writing Tools sends the relevant details to a large language
59/// model (LLM) and processes the results. It then works with the custom view to
60/// integrate any changes into the view’s text storage. During each
61/// of these activities, the coordinator reflects what’s happening in
62/// its ``UIWritingToolsCoordinator/state`` property. You can use
63/// the current state as a guide to making decisions in other parts of your view.
64///
65/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwritingtoolscoordinatorstate?language=objc)
66// NS_ENUM
67#[repr(transparent)]
68#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
69pub struct UIWritingToolsCoordinatorState(pub NSInteger);
70impl UIWritingToolsCoordinatorState {
71    /// A state that indicates Writing Tools isn’t currently performing
72    /// any work on your view’s content.
73    ///
74    /// The coordinator starts in the `inactive` state, and transitions
75    /// immediately to the ``noninteractive`` or ``interactiveResting``
76    /// state when someone chooses an option from the Writing Tools UI.
77    /// After the coordinator finishes incorporating any changes for the
78    /// current operation, it returns to the `inactive` state and waits
79    /// for the person to choose a different option or dismiss the Writing Tools UI.
80    #[doc(alias = "UIWritingToolsCoordinatorStateInactive")]
81    pub const Inactive: Self = Self(0);
82    /// A state that indicates Writing Tools is handling interactions in
83    /// the system UI, instead of in your view.
84    ///
85    /// Writing Tools transitions to this state when the coordinator uses
86    /// the ``UIWritingToolsBehavior/limited`` experience or when someone chooses an
87    /// option that displays its results in the Writing Tools UI. When
88    /// the person accepts the changes from the tool or dismisses the
89    /// Writing Tools UI, the coordinator returns to the ``inactive``
90    /// state. If the person discards the change and selects a tool with
91    /// an interactive experience instead, the coordinator transitions
92    /// to the ``interactiveResting`` state.
93    #[doc(alias = "UIWritingToolsCoordinatorStateNoninteractive")]
94    pub const Noninteractive: Self = Self(1);
95    /// A state that indicates Writing Tools is in the resting state
96    /// for an inline editing experience.
97    ///
98    /// When someone initially selects a tool with an interactive experience,
99    /// the coordinator transitions briefly to this state and starts the
100    /// operation. The coordinator transitions swiftly to the ``interactiveStreaming``
101    /// state when it submits the request and delivers the results to your
102    /// view. When it finishes delivering the results, it transitions back
103    /// to the `interactiveResting` state and awaits further commands. If
104    /// the person accepts the changes or dismisses the Writing Tools UI,
105    /// the coordinator transitions from this state to the ``inactive`` state.
106    #[doc(alias = "UIWritingToolsCoordinatorStateInteractiveResting")]
107    pub const InteractiveResting: Self = Self(2);
108    /// A state that indicates Writing Tools is processing a request and
109    /// incorporating changes interactively into your view.
110    ///
111    /// The coordinator transitions swiftly from the ``interactiveResting``
112    /// state to this state at the start of an operation. In this state,
113    /// the coordinator submits the request for processing and delivers
114    /// the results back to your view. When the coordinator finishes delivering
115    /// the results, it transitions back to the ``interactiveResting`` state.
116    #[doc(alias = "UIWritingToolsCoordinatorStateInteractiveStreaming")]
117    pub const InteractiveStreaming: Self = Self(3);
118}
119
120unsafe impl Encode for UIWritingToolsCoordinatorState {
121    const ENCODING: Encoding = NSInteger::ENCODING;
122}
123
124unsafe impl RefEncode for UIWritingToolsCoordinatorState {
125    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
126}
127
128extern_class!(
129    /// An object that manages interactions between Writing Tools and
130    /// your custom text view.
131    ///
132    /// Add a `UIWritingToolsCoordinator` object to a custom view when you
133    /// want to add Writing Tools support to that view. The coordinator manages
134    /// interactions between your view and the Writing Tools UI and back-end
135    /// capabilities. When creating a coordinator, you supply a delegate object
136    /// to respond to requests from the system and provide needed information.
137    /// Your delegate delivers your view’s text to Writing Tools, incorporates
138    /// suggested changes back into your text storage, and supports the animations
139    /// that Writing Tools creates to show the state of an operation.
140    ///
141    /// Create the `UIWritingToolsCoordinator` object when setting up your UI, and
142    /// initialize it with a custom object that adopts the ``UIWritingToolsCoordinator/Delegate``
143    /// protocol. Add the coordinator to your view using the ``UIView/addInteraction(_:)``
144    /// method. When a coordinator is present on a view, the system adds UI elements
145    /// to initiate Writing Tools operations.
146    ///
147    /// When defining the delegate, choose an object from your app that has access
148    /// to your view and its text storage. You can adopt the ``UIWritingToolsCoordinator/Delegate``
149    /// protocol in the view itself, or in another type that your view uses to
150    /// manage content. During the interactions with Writing Tools, the delegate
151    /// gets and sets the contents of the view’s text storage and supports Writing Tools behaviors.
152    ///
153    /// > Note: You don’t need to create an `UIWritingToolsCoordinator`  object
154    /// if you display text using a ``UITextView``,
155    /// <doc
156    /// ://com.apple.documentation/documentation/appkit/nstextview>,
157    /// <doc
158    /// ://com.apple.documentation/documentation/swiftui/text>,
159    /// <doc
160    /// ://com.apple.documentation/documentation/swiftui/textfield>, or
161    /// <doc
162    /// ://com.apple.documentation/documentation/swiftui/texteditor> view.
163    /// Those views already include the required support to handle Writing Tools
164    /// interactions.
165    ///
166    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwritingtoolscoordinator?language=objc)
167    #[unsafe(super(NSObject))]
168    #[thread_kind = MainThreadOnly]
169    #[derive(Debug, PartialEq, Eq, Hash)]
170    pub struct UIWritingToolsCoordinator;
171);
172
173extern_conformance!(
174    unsafe impl NSObjectProtocol for UIWritingToolsCoordinator {}
175);
176
177#[cfg(feature = "UIInteraction")]
178extern_conformance!(
179    unsafe impl UIInteraction for UIWritingToolsCoordinator {}
180);
181
182impl UIWritingToolsCoordinator {
183    extern_methods!(
184        /// A Boolean value that indicates whether Writing Tools features are
185        /// currently available.
186        ///
187        /// The value of this property is `true` when Writing Tools features are
188        /// available, and `false` when they aren’t. Writing Tools support might
189        /// be unavailable because of device constraints or because the system isn’t
190        /// ready to process Writing Tools requests.
191        #[unsafe(method(isWritingToolsAvailable))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn isWritingToolsAvailable(mtm: MainThreadMarker) -> bool;
194
195        /// Creates a writing tools coordinator and assigns the specified
196        /// delegate object to it.
197        ///
198        /// - Parameters:
199        /// - delegate: An object capable of handling Writing Tools interactions
200        /// for your view. The delegate must be able to modify your view’s text
201        /// storage and refresh the view’s layout and appearance.
202        ///
203        /// Create the coordinator object during your view’s initialization, and assign
204        /// the object to your view. Use the ``UIView/addInteraction(_:)``
205        /// method to add the object to your view.
206        #[unsafe(method(initWithDelegate:))]
207        #[unsafe(method_family = init)]
208        pub unsafe fn initWithDelegate(
209            this: Allocated<Self>,
210            delegate: Option<&ProtocolObject<dyn UIWritingToolsCoordinatorDelegate>>,
211        ) -> Retained<Self>;
212
213        /// The object that handles Writing Tools interactions for your view.
214        ///
215        /// Specify this object at initialization time when creating your `UIWritingToolsCoordinator`
216        /// object. The object must adopt the ``UIWritingToolsCoordinator/Delegate``
217        /// protocol, and be capable of modifying your view’s text storage and
218        /// refreshing the view’s layout and appearance.
219        #[unsafe(method(delegate))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn delegate(
222            &self,
223        ) -> Option<Retained<ProtocolObject<dyn UIWritingToolsCoordinatorDelegate>>>;
224
225        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
226        /// The view that Writing Tools uses to display visual effects during
227        /// the text-rewriting process.
228        ///
229        /// Writing Tools uses the view in this property to host the visual effects
230        /// it creates when making interactive changes to your view’s content.
231        /// These visual effects let people know the state of the text and provide
232        /// feedback about what’s happening to it. Set this property to a subview
233        /// that sits visually above, and covers, all of the text in your custom
234        /// text view. If you don’t assign a value to this property, the coordinator
235        /// uses the object in its ``UIInteraction/view`` property to host any visual effects.
236        ///
237        /// If you display your view’s text using multiple text containers, implement the
238        /// ``UIWritingToolsCoordinator/Delegate/writingToolsCoordinator(_:requestsSingleContainerSubrangesOf:in:completion:)``
239        /// method to request multiple previews.
240        #[unsafe(method(effectContainerView))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn effectContainerView(&self) -> Option<Retained<UIView>>;
243
244        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
245        /// This is a [weak property][objc2::topics::weak_property].
246        /// Setter for [`effectContainerView`][Self::effectContainerView].
247        #[unsafe(method(setEffectContainerView:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn setEffectContainerView(&self, effect_container_view: Option<&UIView>);
250
251        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
252        /// The view that Writing Tools uses to display background decorations
253        /// such as proofreading marks.
254        ///
255        /// Writing Tools uses the view in this property to host proofreading marks
256        /// and other visual elements that show any suggested changes. Set this
257        /// property to a subview situated visibly below the text in your custom
258        /// text view. It's also satisfactory to place this view visually in front
259        /// of the text. Make sure the size of the view is big enough to
260        /// cover all of the affected text. If you don’t assign a value to
261        /// this property, the coordinator uses the object in its ``UIInteraction/view``
262        /// property to host any visual elements.
263        ///
264        /// If you display your view’s text using multiple text containers, implement the
265        /// ``UIWritingToolsCoordinator/Delegate/writingToolsCoordinator(_:requestsSingleContainerSubrangesOf:in:completion:)``
266        /// and ``UIWritingToolsCoordinator/Delegate/writingToolsCoordinator(_:requestsDecorationContainerViewFor:in:completion:)``
267        /// methods to provide separate decoration views for each container.
268        #[unsafe(method(decorationContainerView))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn decorationContainerView(&self) -> Option<Retained<UIView>>;
271
272        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
273        /// This is a [weak property][objc2::topics::weak_property].
274        /// Setter for [`decorationContainerView`][Self::decorationContainerView].
275        #[unsafe(method(setDecorationContainerView:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn setDecorationContainerView(&self, decoration_container_view: Option<&UIView>);
278
279        /// The current level of Writing Tools activity in your view.
280        ///
281        /// Use this property to determine when Writing Tools is actively making
282        /// changes to your view. During the course of Writing Tools interactions,
283        /// the system reports state changes to the delegate’s
284        /// ``UIWritingToolsCoordinator/Delegate/writingToolsCoordinator(_:willChangeTo:completion:)``
285        /// method and updates this property accordingly.
286        #[unsafe(method(state))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn state(&self) -> UIWritingToolsCoordinatorState;
289
290        /// Stops the current Writing Tools operation and dismisses the system UI.
291        ///
292        /// Call this method to abort the current Writing Tools operation. This
293        /// method dismisses the system’s Writing Tools UI and stops any in-flight
294        /// interactions with your view. This method does not undo any changes that
295        /// Writing Tools already made to your view’s content.
296        #[unsafe(method(stopWritingTools))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn stopWritingTools(&self);
299
300        #[cfg(feature = "UITextInputTraits")]
301        /// The level of Writing Tools support you want the system to provide
302        /// for your view.
303        ///
304        /// Use this property to request an inline or panel-based experience,
305        /// or to disable Writing Tools for your view altogether. The default
306        /// value of this property is ``UIWritingToolsBehavior/default``.
307        #[unsafe(method(preferredBehavior))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn preferredBehavior(&self) -> UIWritingToolsBehavior;
310
311        #[cfg(feature = "UITextInputTraits")]
312        /// Setter for [`preferredBehavior`][Self::preferredBehavior].
313        #[unsafe(method(setPreferredBehavior:))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn setPreferredBehavior(&self, preferred_behavior: UIWritingToolsBehavior);
316
317        #[cfg(feature = "UITextInputTraits")]
318        /// The actual level of Writing Tools support the system provides for your view.
319        ///
320        /// The system chooses this value based on the device capabilities, and takes
321        /// the value in the ``preferredBehavior`` property into consideration when
322        /// making the choice. The value in this property is never the default option,
323        /// and is instead one of the specific options such as ``UIWritingToolsBehavior/none``,
324        /// ``UIWritingToolsBehavior/limited``, or ``UIWritingToolsBehavior/complete``.
325        #[unsafe(method(behavior))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn behavior(&self) -> UIWritingToolsBehavior;
328
329        #[cfg(feature = "UITextInputTraits")]
330        /// The type of content you allow Writing Tools to generate for your custom
331        /// text view.
332        ///
333        /// Writing Tools can create plain text or rich text, and it can format text
334        /// using lists or tables as needed. If your view doesn’t support specific
335        /// types of content, specify the types you do support in this property.
336        /// The default value of this property is ``UIWritingToolsResultOptions/default``,
337        /// which lets the system determine the type of content to generate.
338        #[unsafe(method(preferredResultOptions))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn preferredResultOptions(&self) -> UIWritingToolsResultOptions;
341
342        #[cfg(feature = "UITextInputTraits")]
343        /// Setter for [`preferredResultOptions`][Self::preferredResultOptions].
344        #[unsafe(method(setPreferredResultOptions:))]
345        #[unsafe(method_family = none)]
346        pub unsafe fn setPreferredResultOptions(
347            &self,
348            preferred_result_options: UIWritingToolsResultOptions,
349        );
350
351        #[cfg(feature = "UITextInputTraits")]
352        /// The type of content the system generates for your custom text view.
353        ///
354        /// This property contains the set of options that Writing Tools outputs
355        /// for your view. Writing Tools takes the value in the
356        /// ``UIWritingToolsCoordinator/preferredResultOptions`` property into
357        /// consideration when determining this value.
358        #[unsafe(method(resultOptions))]
359        #[unsafe(method_family = none)]
360        pub unsafe fn resultOptions(&self) -> UIWritingToolsResultOptions;
361
362        /// Informs the coordinator about changes your app made to the text
363        /// in the specified context object.
364        ///
365        /// - Parameters:
366        /// - range: The range of text to replace. This range is relative to
367        /// the starting location of the specified context object’s text in
368        /// your view’s text storage. If you initialized the context object
369        /// with the entire contents of your view’s text storage, specify the
370        /// range of text you’re replacing in your text storage. However, if
371        /// you initialized the context object with only a portion of your
372        /// view’s text, specify a range that is relative to the starting
373        /// location of the context object’s text.
374        /// - replacementText: The text that replaces the previous content in
375        /// `range`. Specify an empty string to delete the text in the specified range.
376        /// - reason: The reason you updated the text.
377        /// - contextID: The unique identifier of the context object that
378        /// contains the text you modified.
379        ///
380        /// If you make any changes to the text Writing Tools is evaluating, call
381        /// this method to report those changes to your view’s coordinator object.
382        /// You might make changes in response to an undo command or when someone
383        /// types into the same part of your view’s text. Calling this method
384        /// keeps the coordinator object informed of any changes, and ensures
385        /// it delivers accurate information to its delegate. In response, the
386        /// coordinator refreshes previews and other information related to your
387        /// view. If the scope of the update is significantly large, the coordinator
388        /// can optionally cancel the Writing Tools session altogether.
389        ///
390        /// Use this method to report changes that precisely intersect your context
391        /// object’s text. The first time you call this method for a context object,
392        /// report changes only to the original attributed string in that object.
393        /// If you call this method more than once, report changes to the newly
394        /// modified version of that string. Don’t use this method to report changes
395        /// to text that comes before or after the context object. If you make
396        /// changes before your context object, report those changes separately using the
397        /// ``UIWritingToolsCoordinator/updateForReflowedTextInContextWithIdentifier(_:)`` method.
398        ///
399        /// > Warning: Failure to call this method for a change can cause Writing Tools
400        /// to deliver inaccurate information to your delegate and lead to data loss.
401        #[unsafe(method(updateRange:withText:reason:forContextWithIdentifier:))]
402        #[unsafe(method_family = none)]
403        pub unsafe fn updateRange_withText_reason_forContextWithIdentifier(
404            &self,
405            range: NSRange,
406            replacement_text: &NSAttributedString,
407            reason: UIWritingToolsCoordinatorTextUpdateReason,
408            context_id: &NSUUID,
409        );
410
411        /// Informs the coordinator that a change occurred to the view or its text
412        /// that requires a layout update.
413        ///
414        /// - Parameters:
415        /// - contextID: The unique identifier of the context object affected
416        /// by the change. Pass the identifier for the context object that comes
417        /// after the changes.
418        ///
419        /// Use this method to inform Writing Tools when the geometry of your view
420        /// changes, or when the text that precedes one of your context objects changes.
421        /// Changes to the view’s geometry or text can affect the flow of any remaining
422        /// text, and require a layout update. Writing Tools uses this method to
423        /// refresh any layout-dependent information it’s currently tracking. For
424        /// example, it uses it to refresh the location of proofreading marks it’s
425        /// displaying in your view.
426        ///
427        /// If a text change affects the text inside a context object, call the
428        /// ``updateRange(_:with:reason:forContextWithIdentifier:)`` method to report
429        /// that change instead.
430        #[unsafe(method(updateForReflowedTextInContextWithIdentifier:))]
431        #[unsafe(method_family = none)]
432        pub unsafe fn updateForReflowedTextInContextWithIdentifier(&self, context_id: &NSUUID);
433    );
434}
435
436/// Methods declared on superclass `NSObject`.
437impl UIWritingToolsCoordinator {
438    extern_methods!(
439        #[unsafe(method(init))]
440        #[unsafe(method_family = init)]
441        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
442
443        #[unsafe(method(new))]
444        #[unsafe(method_family = new)]
445        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
446    );
447}
448
449/// Options that indicate whether Writing Tools is animating changes to
450/// your view’s text.
451///
452/// During an operation, Writing Tools delivers replacement text to the
453/// delegate of the active ``UIWritingToolsCoordinator`` object. Depending
454/// on the configured experience for your view, it delivers these changes
455/// as either interactive or noninteractive replacements. For interactive
456/// replacements, Writing Tools animates the change automatically and provides
457/// you with the information you need to perform any related animations.
458///
459/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwritingtoolscoordinatortextreplacementreason?language=objc)
460// NS_ENUM
461#[repr(transparent)]
462#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
463pub struct UIWritingToolsCoordinatorTextReplacementReason(pub NSInteger);
464impl UIWritingToolsCoordinatorTextReplacementReason {
465    /// An option to animate the replacement of text in your view.
466    ///
467    /// When Writing Tools requests an interactive change in your delegate’s
468    /// ``UIWritingToolsCoordinator/Delegate/writingToolsCoordinator(_:replaceRange:inContext:proposedText:reason:animationParameters:completion:)``
469    /// method, it passes a valid set of animation parameters to that method.
470    /// Update your view’s text storage and use the provided ``UIWritingToolsCoordinator/AnimationParameters``
471    /// type to create any view-specific animations you need to support the
472    /// animated replacement of the text.
473    #[doc(alias = "UIWritingToolsCoordinatorTextReplacementReasonInteractive")]
474    pub const Interactive: Self = Self(0);
475    /// An option to replace the text in your view without animating the change.
476    ///
477    /// When Writing Tools requests a noninteractive change in your delegate’s
478    /// ``UIWritingToolsCoordinator/Delegate/writingToolsCoordinator(_:replaceRange:inContext:proposedText:reason:animationParameters:completion:)``
479    /// method, update your view’s text storage without animating the change.
480    #[doc(alias = "UIWritingToolsCoordinatorTextReplacementReasonNoninteractive")]
481    pub const Noninteractive: Self = Self(1);
482}
483
484unsafe impl Encode for UIWritingToolsCoordinatorTextReplacementReason {
485    const ENCODING: Encoding = NSInteger::ENCODING;
486}
487
488unsafe impl RefEncode for UIWritingToolsCoordinatorTextReplacementReason {
489    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
490}
491
492/// Options that indicate how much of your content Writing Tools requested.
493///
494/// At the start of any Writing Tools interaction, you provide the text for
495/// the system to evaluate from your ``UIWritingToolsCoordinator/Delegate``
496/// object. The request for your content comes with a scope constant that
497/// indicates how much of your view’s text to provide.
498///
499/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwritingtoolscoordinatorcontextscope?language=objc)
500// NS_ENUM
501#[repr(transparent)]
502#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
503pub struct UIWritingToolsCoordinatorContextScope(pub NSInteger);
504impl UIWritingToolsCoordinatorContextScope {
505    /// An option to provide only the view’s currently selected text.
506    ///
507    /// With this option, include the selected text in your context object,
508    /// along with some additional text before and after the selection. When
509    /// performing changes inline with your view’s content, Writing Tools
510    /// applies animations only to the selected text.
511    #[doc(alias = "UIWritingToolsCoordinatorContextScopeUserSelection")]
512    pub const UserSelection: Self = Self(0);
513    /// An option to provide all of your view’s text.
514    ///
515    /// With this option, include all of the text your view manages.
516    /// If your view has multiple text storage objects, create a separate
517    /// context object for each one.
518    #[doc(alias = "UIWritingToolsCoordinatorContextScopeFullDocument")]
519    pub const FullDocument: Self = Self(1);
520    /// An option to provide only the text in the currently visible portion
521    /// of your view.
522    ///
523    /// With this option, include only the currently visible text, along
524    /// with some additional text before and after the visible text.
525    #[doc(alias = "UIWritingToolsCoordinatorContextScopeVisibleArea")]
526    pub const VisibleArea: Self = Self(2);
527}
528
529unsafe impl Encode for UIWritingToolsCoordinatorContextScope {
530    const ENCODING: Encoding = NSInteger::ENCODING;
531}
532
533unsafe impl RefEncode for UIWritingToolsCoordinatorContextScope {
534    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
535}
536
537/// The types of animations that Writing Tools performs during an interactive
538/// update of your view.
539///
540/// Use the `UIWritingToolsCoordinator/TextAnimation` constants to determine
541/// the type of animation that is occurring. During an interactive change to
542/// your view, Writing Tools creates animations to provide feedback about what’s
543/// happening. During the setup for each animation, Writing Tools reports the
544/// type of animation to the coordinator’s delegate, so that you can perform
545/// additional actions related to that animation. For example, during an insertion
546/// animation, you might animate changes to other views in your interface.
547///
548/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwritingtoolscoordinatortextanimation?language=objc)
549// NS_ENUM
550#[repr(transparent)]
551#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
552pub struct UIWritingToolsCoordinatorTextAnimation(pub NSInteger);
553impl UIWritingToolsCoordinatorTextAnimation {
554    /// The animation that Writing Tools performs when waiting to receive
555    /// results from the large language model.
556    ///
557    /// This type of animation applies a visual effect to the text that
558    /// Writing Tools is evaluating. When preparing for this animation, hide
559    /// the text that Writing Tools is about to evaluate. In the same space
560    /// where that text appears, Writing Tools displays a preview image that
561    /// you provide and animates changes to that image.
562    #[doc(alias = "UIWritingToolsCoordinatorTextAnimationAnticipate")]
563    pub const Anticipate: Self = Self(0);
564    /// The animation that Writing Tools performs when removing text from your view.
565    ///
566    /// This type of animation shows the removal of text from your view. When
567    /// preparing for this animation, hide the text in the provided range if
568    /// you haven’t already. If you support animating the reflow of your view’s
569    /// text, you can also prepare any other animations you need. Writing Tools
570    /// uses a preview object you provide to animate the removal of the text.
571    #[doc(alias = "UIWritingToolsCoordinatorTextAnimationRemove")]
572    pub const Remove: Self = Self(1);
573    /// The animation that Writing Tools performs when inserting text into your view.
574    ///
575    /// This type of animation shows the insertion of text to your view. When preparing
576    /// for this animation, hide the text in the provided range if you haven’t
577    /// already. If you support animating the reflow of your view’s text, you can
578    /// also prepare any other animations you need. Writing Tools uses a preview
579    /// object you provide to animate the insertion of the text.
580    #[doc(alias = "UIWritingToolsCoordinatorTextAnimationInsert")]
581    pub const Insert: Self = Self(2);
582}
583
584unsafe impl Encode for UIWritingToolsCoordinatorTextAnimation {
585    const ENCODING: Encoding = NSInteger::ENCODING;
586}
587
588unsafe impl RefEncode for UIWritingToolsCoordinatorTextAnimation {
589    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
590}
591
592impl UIWritingToolsCoordinatorTextAnimation {
593    #[doc(alias = "UIWritingToolsCoordinatorTextAnimationDebugDescription")]
594    #[inline]
595    pub unsafe fn debug_description(
596        self: UIWritingToolsCoordinatorTextAnimation,
597    ) -> Retained<NSString> {
598        extern "C-unwind" {
599            fn UIWritingToolsCoordinatorTextAnimationDebugDescription(
600                animation_type: UIWritingToolsCoordinatorTextAnimation,
601            ) -> *mut NSString;
602        }
603        let ret = unsafe { UIWritingToolsCoordinatorTextAnimationDebugDescription(self) };
604        unsafe { Retained::retain_autoreleased(ret) }
605            .expect("function was marked as returning non-null, but actually returned NULL")
606    }
607}
608
609extern_protocol!(
610    /// An interface that you use to manage interactions between Writing Tools
611    /// and your custom text view.
612    ///
613    /// Adopt the `UIWritingToolsCoordinator.Delegate` protocol in the type you
614    /// use to manage your custom text view. When you add a ``UIWritingToolsCoordinator``
615    /// object to your view, the coordinator uses this protocol to communicate
616    /// with that view. The protocol lets Writing Tools fetch your view’s text,
617    /// report suggested changes back to your view, and deliver visual feedback
618    /// when Writing Tools features are active. Make sure the type that adopts
619    /// this protocol has access to your view’s text storage and can perform
620    /// relevant tasks on behalf of the view.
621    ///
622    /// Writing Tools expects you to call the provided handler blocks at the end
623    /// of your delegate methods. It’s crucial that you execute these blocks in a
624    /// timely manner to allow Writing Tools to perform subsequent tasks. For example,
625    /// Writing Tools waits for you to execute the handlers for animation-related methods
626    /// before moving on to the next stage of the animations.
627    ///
628    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwritingtoolscoordinatordelegate?language=objc)
629    pub unsafe trait UIWritingToolsCoordinatorDelegate: NSObjectProtocol {
630        #[cfg(all(feature = "UIWritingToolsCoordinatorContext", feature = "block2"))]
631        /// Asks your delegate to provide the text to evaluate during the Writing Tools
632        /// operation.
633        ///
634        /// - Parameters:
635        /// - writingToolsCoordinator: The coordinator object requesting information
636        /// from your custom view.
637        /// - scope: The amount of text the coordinator requested. Use this property
638        /// to determine if Writing Tools is evaluating all of your text or only a subset.
639        /// - completion: A completion block to execute with the required information.
640        /// You must execute this block once at end of your method's implementation.
641        /// The block has no return value and takes an array of
642        /// ``UIWritingToolsCoordinator/Context`` objects that contain the requested information.
643        ///
644        /// At the start of every operation, the ``UIWritingToolsCoordinator`` object calls
645        /// this method to request the text to evaluate. Use this method to create one or
646        /// more ``UIWritingToolsCoordinator/Context`` objects with your view’s text.
647        /// Create only one ``UIWritingToolsCoordinator/Context`` object if your view has
648        /// only one text storage object. If your view contains multiple text storage objects,
649        /// create separate ``UIWritingToolsCoordinator/Context`` objects for each
650        /// text storage object. Writing Tools returns updates for each context object
651        /// separately, making it easier for you to incorporate changes into the correct
652        /// text storage object. Don’t create multiple context objects if your view has
653        /// only one text storage object.
654        ///
655        /// The `scope` parameter tells you what content Writing Tools expects you to provide
656        /// in your context object. For example, Writing Tools expects you to provide the
657        /// selected text when the parameter contains the ``UIWritingToolsCoordinator/ContextScope/userSelection``
658        /// option. When Writing Tools requests a subset of your overall text, include
659        /// some of the surrounding text in your context object too. Writing Tools can
660        /// use the extra text you provide to improve the results of its evaluation. For
661        /// example, it might use an entire paragraph, instead of only the selected sentence,
662        /// to evaluate ways to rewrite that sentence. It’s best to include the text up
663        /// to the nearest paragraph boundary before and after the selection. If you
664        /// include extra text in your context object, set the ``UIWritingToolsCoordinator/Context/range``
665        /// property to the range of the selected text.
666        ///
667        /// > Note: When a context object stores only a subset of your view’s text, record
668        /// additional information to map the location of that text to the correct location
669        /// in your view’s text storage. Keep that information up-to-date throughout the
670        /// Writing Tools session.
671        ///
672        /// Pass the context objects you create to the provided completion handler before
673        /// your method returns. Writing Tools waits for you to call the completion
674        /// handler before proceeding with the operation.
675        #[unsafe(method(writingToolsCoordinator:requestsContextsForScope:completion:))]
676        #[unsafe(method_family = none)]
677        unsafe fn writingToolsCoordinator_requestsContextsForScope_completion(
678            &self,
679            writing_tools_coordinator: &UIWritingToolsCoordinator,
680            scope: UIWritingToolsCoordinatorContextScope,
681            completion: &block2::DynBlock<
682                dyn Fn(NonNull<NSArray<UIWritingToolsCoordinatorContext>>),
683            >,
684        );
685
686        #[cfg(all(
687            feature = "UIWritingToolsCoordinatorAnimationParameters",
688            feature = "UIWritingToolsCoordinatorContext",
689            feature = "block2"
690        ))]
691        /// Tells the delegate that there are text changes to incorporate into the view.
692        ///
693        /// - Parameters:
694        /// - writingToolsCoordinator: The coordinator object providing the changes
695        /// to your custom view.
696        /// - range: A range of text to update. This range is relative to the text
697        /// in your context object, and it’s your responsibility to match that location
698        /// to the correct location in your text storage. If you initialized the
699        /// context object with the entire contents of your view’s text storage,
700        /// you can use `range` as-is to access that text storage. However, if you
701        /// initialized the context object with only a portion of your view’s text,
702        /// add the starting location of your context object’s text to this value
703        /// to get the correct range for that text storage.
704        /// - context: The context object that contains the original text to modify.
705        /// Use this object to locate the correct text storage object for your view.
706        /// - replacementText: The text to insert in place of the current text at `range`.
707        /// You can insert this text as-is, insert a modified version of this string,
708        /// or reject the replacement text altogether.
709        /// - reason: The type of replacement Writing Tools performs. This parameter
710        /// indicates whether Writing Tools is replacing the text with or without animations.
711        /// - animationParameters: The animation parameters for any interactive changes,
712        /// or `nil` if the changes aren’t interactive. Use this object to create any
713        /// additional animations for the system to run alongside the changes Writing Tools
714        /// makes. For example, use it to update other views that contain related information.
715        /// - completion: A completion handler to execute with the results of the operation.
716        /// The handler has no return value and takes an optional attributed string as
717        /// a parameter. If you incorporate the replacement text, either as-is or with
718        /// modifications, pass the actual string you incorporated to the completion
719        /// block. If you reject the suggested change and leave the original text
720        /// unchanged, specify `nil` for this parameter.
721        ///
722        /// Use this method to update your view’s text storage with the proposed changes.
723        /// Writing Tools can call this method multiple times during the course of a
724        /// session to notify you of changes to different ranges of text. Incorporate
725        /// the changes into your view’s text storage and notify your layout manager
726        /// so it can refresh the view.
727        ///
728        /// > Important: When integrating changes, remember to update `range.location` as needed
729        /// to get the correct location in your view’s text storage.
730        ///
731        /// Remove the text in the appropriate range of your text storage, and replace
732        /// it with the contents of `replacementText`. When you finish, call the completion
733        /// handler and pass in the replacement text you inserted. If you change the
734        /// string in `replacementText` before incorporating it into your text storage,
735        /// return your modified string instead. Returning the string lets Writing Tools
736        /// track any alterations you made to it. You can also pass `nil` to the
737        /// completion handler if you don’t incorporate the replacement text.
738        ///
739        /// For interactive changes, Writing Tools works with your delegate to animate
740        /// the removal of the old text and the insertion of any replacement text. If
741        /// you need to modify other parts of your interface to reflect the changes,
742        /// use the provided ``UIWritingToolsCoordinator/AnimationParameters`` object
743        /// to create additional animations to run at the same time as the system-provided animations.
744        #[unsafe(method(writingToolsCoordinator:replaceRange:inContext:proposedText:reason:animationParameters:completion:))]
745        #[unsafe(method_family = none)]
746        unsafe fn writingToolsCoordinator_replaceRange_inContext_proposedText_reason_animationParameters_completion(
747            &self,
748            writing_tools_coordinator: &UIWritingToolsCoordinator,
749            range: NSRange,
750            context: &UIWritingToolsCoordinatorContext,
751            replacement_text: &NSAttributedString,
752            reason: UIWritingToolsCoordinatorTextReplacementReason,
753            animation_parameters: Option<&UIWritingToolsCoordinatorAnimationParameters>,
754            completion: &block2::DynBlock<dyn Fn(*mut NSAttributedString)>,
755        );
756
757        #[cfg(all(feature = "UIWritingToolsCoordinatorContext", feature = "block2"))]
758        /// Asks the delegate to update your view’s current text selection.
759        ///
760        /// - Parameters:
761        /// - writingToolsCoordinator: The coordinator object making the change
762        /// to your view.
763        /// - ranges: One or more ranges of text to select. Each range is relative
764        /// to the text in your context object, and it’s your responsibility to
765        /// match each location to the correct location in your text storage. If
766        /// you initialized the context object with the entire contents of your
767        /// view’s text storage, you can use the ranges as-is to access that text
768        /// storage. However, if you initialized the context object with only a
769        /// portion of your view’s text, add the starting location of your context
770        /// object’s text to each value to get the correct range for that text storage.
771        /// - context: The context object you use to identify the associated text storage.
772        /// - completion: The completion handler to execute when your delegate finishes updating
773        /// the selection. The handler has no parameters or return value. You must
774        /// call this handler at some point during the implementation of your method.
775        ///
776        /// As Writing Tools suggests changes to your view’s text, it calls this method
777        /// to update the text selection accordingly. Use this method to update the
778        /// current selection in your view’s text storage. When you finish making the
779        /// changes, call the provided completion block to let Writing Tools know you’re finished.
780        #[unsafe(method(writingToolsCoordinator:selectRanges:inContext:completion:))]
781        #[unsafe(method_family = none)]
782        unsafe fn writingToolsCoordinator_selectRanges_inContext_completion(
783            &self,
784            writing_tools_coordinator: &UIWritingToolsCoordinator,
785            ranges: &NSArray<NSValue>,
786            context: &UIWritingToolsCoordinatorContext,
787            completion: &block2::DynBlock<dyn Fn()>,
788        );
789
790        #[cfg(all(
791            feature = "UIBezierPath",
792            feature = "UIWritingToolsCoordinatorContext",
793            feature = "block2"
794        ))]
795        /// Asks the delegate to provide the bounding paths for the specified
796        /// text in your view.
797        ///
798        /// - Parameters:
799        /// - writingToolsCoordinator: The coordinator object requesting information
800        /// from your custom view.
801        /// - range: The range of text to evaluate. This range is relative to the
802        /// text in your context object, and it’s your responsibility to match that
803        /// location to the correct location in your text storage. If you initialized
804        /// the context object with the entire contents of your view’s text storage,
805        /// you can use `range` as-is to access that text storage. However, if you
806        /// initialized the context object with only a portion of your view’s text,
807        /// add the starting location of your context object’s text to this value to
808        /// get the correct range for that text storage.
809        /// - context: The context object with the target text. Use this object to
810        /// find the text in your view’s text storage.
811        /// - completion: A handler to execute with the required information. The
812        /// handler has no return value and takes an array of Bezier paths as a
813        /// parameter. You must call this handler at some point during your method’s implementation.
814        ///
815        /// After applying proofreading marks to your view’s text, Writing Tools lets
816        /// the person accept or reject individual suggestions. To facilitate interactions,
817        /// the coordinator asks your delegate to provide one or more Bezier paths that
818        /// surround those proofreading suggestions. For each distinct range of text
819        /// with a suggestion, it calls this method to get the Bezier paths that surround
820        /// the corresponding text.
821        ///
822        /// After you determine the location of the specified range of text in your view’s
823        /// text storage, call the
824        /// <doc
825        /// ://com.apple.documentation/documentation/uikit/nstextlayoutmanager/3809995-enumeratetextsegments>
826        /// method of your view’s
827        /// <doc
828        /// ://com.apple.documentation/documentation/uikit/nstextlayoutmanager>
829        /// to compute the selection rectangles for that text. That method finds the text
830        /// segments that contain the text and returns the frame rectangle for each one.
831        /// Create a Bezier path for each rectangle, and convert the coordinates of each path
832        /// to the coordinate space of the view in your coordinator's ``UIWritingToolsCoordinator/decorationContainerView``
833        /// property. Pass the resulting paths to the completion handler.
834        #[unsafe(method(writingToolsCoordinator:requestsBoundingBezierPathsForRange:inContext:completion:))]
835        #[unsafe(method_family = none)]
836        unsafe fn writingToolsCoordinator_requestsBoundingBezierPathsForRange_inContext_completion(
837            &self,
838            writing_tools_coordinator: &UIWritingToolsCoordinator,
839            range: NSRange,
840            context: &UIWritingToolsCoordinatorContext,
841            completion: &block2::DynBlock<dyn Fn(NonNull<NSArray<UIBezierPath>>)>,
842        );
843
844        #[cfg(all(
845            feature = "UIBezierPath",
846            feature = "UIWritingToolsCoordinatorContext",
847            feature = "block2"
848        ))]
849        /// Asks the delegate to provide an underline shape for the specified text
850        /// during a proofreading session.
851        ///
852        /// - Parameters:
853        /// - writingToolsCoordinator: The coordinator object requesting information
854        /// from your custom view.
855        /// - range: The range of text to evaluate. This range is relative to the
856        /// text in your context object, and it’s your responsibility to match that
857        /// location to the correct location in your text storage. If you initialized
858        /// the context object with the entire contents of your view’s text storage,
859        /// you can use `range` as-is to access that text storage. However, if you
860        /// initialized the context object with only a portion of your view’s text,
861        /// add the starting location of your context object’s text to this value
862        /// to get the correct range for that text storage.
863        /// - context: The context object with the target text. Use this object to
864        /// find the text in your view’s text storage.
865        /// - completion: A handler to execute with the required information. The
866        /// handler has no return value and takes an array of Bezier paths as a
867        /// parameter. You must call this handler at some point during your method’s implementation.
868        ///
869        /// When applying proofreading marks to your view’s content, the coordinator
870        /// calls this method to retrieve a shape to draw under the specified text.
871        /// You provide the shape using one or more Bezier paths, and the coordinator
872        /// draws and animates that shape during the proofreading session.
873        ///
874        /// After you determine the location of the specified range of text in your
875        /// view’s text storage, find the rectangle around that text. If you're using
876        /// TextKit, you can call the
877        /// <doc
878        /// ://com.apple.documentation/documentation/uikit/nstextlayoutmanager/3809995-enumeratetextsegments>
879        /// method of your view’s
880        /// <doc
881        /// ://com.apple.documentation/documentation/uikit/nstextlayoutmanager>
882        /// to get the rectangles for a range of text. Convert the coordinates of each rectangle
883        /// to the coordinate space of the view in your coordinator's ``UIWritingToolsCoordinator/decorationContainerView``
884        /// property. Use those rectangles to create the Bezier paths for your text.
885        /// For example, you might create a path with a straight or wavy line at the
886        /// bottom of the rectangle.
887        #[unsafe(method(writingToolsCoordinator:requestsUnderlinePathsForRange:inContext:completion:))]
888        #[unsafe(method_family = none)]
889        unsafe fn writingToolsCoordinator_requestsUnderlinePathsForRange_inContext_completion(
890            &self,
891            writing_tools_coordinator: &UIWritingToolsCoordinator,
892            range: NSRange,
893            context: &UIWritingToolsCoordinatorContext,
894            completion: &block2::DynBlock<dyn Fn(NonNull<NSArray<UIBezierPath>>)>,
895        );
896
897        #[cfg(all(feature = "UIWritingToolsCoordinatorContext", feature = "block2"))]
898        /// Prepare for animations for the content that Writing Tools is evaluating.
899        ///
900        /// - Parameters:
901        /// - writingToolsCoordinator: The coordinator object notifying you that
902        /// animations are about to begin.
903        /// - textAnimation: The type of animation Writing Tools is preparing.
904        /// - range: The range of text affected by the animation. This range is
905        /// relative to the text in your context object, and it’s your responsibility
906        /// to match that location to the correct location in your text storage.
907        /// If you initialized the context object with the entire contents of your
908        /// view’s text storage, you can use `range` as-is to access that text
909        /// storage. However, if you initialized the context object with only a portion
910        /// of your view’s text, add the starting location of your context object’s
911        /// text to this value to get the correct range for that text storage.
912        /// - context: The context object that contains the original text. Use this
913        /// object to fetch the current text, and to match that text to your underlying
914        /// text storage.
915        /// - completion: A completion handler to execute when you are done. The handler
916        /// has no return value and takes no parameters. You must call this handler
917        /// at some point during your implementation.
918        ///
919        /// During an interactive evaluation of your view’s text, Writing Tools creates
920        /// different animations to provide feedback on what’s happening. For example, it
921        /// creates an ``UIWritingToolsCoordinator/TextAnimation/anticipate`` animation to
922        /// let people know the system is evaluating the text. The `textAnimation` parameter
923        /// tells you what type of animation to prepare for.
924        ///
925        /// Use this method to prepare for the system-provided animations of your view’s
926        /// content. For interactive animations, hide the text in the specified range temporarily
927        /// while the system animations run. For non-interactive animations, dim the text
928        /// for the duration of the animation to indicate it’s not editable. For animations
929        /// to remove or insert text, you can also use this method to set up animations
930        /// to reflow your view’s content to match the changes. At the end of a given animation,
931        /// use your delegate’s ``writingToolsCoordinator(_:finish:for:in:completion:)``
932        /// method to undo any changes you make to your content.
933        ///
934        /// For a single animation type, the system calls the
935        /// ``writingToolsCoordinator(_:requestsPreviewFor:range:context:completion:)`` method,
936        /// followed sequentially by this method and the ``writingToolsCoordinator(_:finish:for:in:completion:)``
937        /// method. Each method executes asynchronously, but the system calls the next
938        /// method in the sequence only after you call the completion handler of the previous
939        /// method. However, multiple animations can run simultaneously, so check the
940        /// `textAnimation` and `range` parameters to differentiate sequences.
941        #[unsafe(method(writingToolsCoordinator:prepareForTextAnimation:forRange:inContext:completion:))]
942        #[unsafe(method_family = none)]
943        unsafe fn writingToolsCoordinator_prepareForTextAnimation_forRange_inContext_completion(
944            &self,
945            writing_tools_coordinator: &UIWritingToolsCoordinator,
946            text_animation: UIWritingToolsCoordinatorTextAnimation,
947            range: NSRange,
948            context: &UIWritingToolsCoordinatorContext,
949            completion: &block2::DynBlock<dyn Fn()>,
950        );
951
952        #[cfg(all(
953            feature = "UITargetedPreview",
954            feature = "UIWritingToolsCoordinatorContext",
955            feature = "block2"
956        ))]
957        /// Asks the delegate for a preview image and layout information for the
958        /// specified text.
959        ///
960        /// - Parameters:
961        /// - writingToolsCoordinator: The coordinator object notifying you that
962        /// animations are about to begin.
963        /// - textAnimation: The type of animation Writing Tools is preparing.
964        /// - range: The range of text that requires a preview image. This range
965        /// is relative to the text in your context object, and it’s your responsibility
966        /// to match that location to the correct location in your text storage.
967        /// If you initialized the context object with the entire contents of
968        /// your view’s text storage, you can use `range` as-is to access that
969        /// text storage. However, if you initialized the context object with only
970        /// a portion of your view’s text, add the starting location of your
971        /// context object’s text to this value to get the correct range for that
972        /// text storage.
973        /// - context: The context object that contains the original text. Use this
974        /// object to fetch the current text, and to match that text to your
975        /// underlying text storage.
976        /// - completion: A completion handler to execute when you are done. The
977        /// handler has no return value and takes a ``UITargetedPreview`` object
978        /// as a parameter. You must call this handler at some point during your implementation.
979        ///
980        /// During an interactive evaluation of your view’s text, Writing Tools creates
981        /// different animations to provide feedback on what’s happening. As part of
982        /// the preparation for those animations, Writing Tools asks you to provide
983        /// a preview of the affected content in your view. Writing Tools uses this
984        /// preview to build and execute the animations in the view stored in the
985        /// ``UIWritingToolsCoordinator/effectContainerView`` property of the coordinator object.
986        ///
987        /// To build a preview of your content in iOS, render the specified range of
988        /// text into an image with a transparent background. Install the image in a
989        /// ``UIImageView`` and use that to build your preview object. Set the frame
990        /// rectangle of your image view to the rectangle in your view’s coordinate
991        /// space that contains the text you captured. When creating the ``UITargetedPreview``
992        /// object, include both a ``UIPreviewParameters`` and a ``UIPreviewTarget``
993        /// object. Create the ``UIPreviewTarget`` object with your text view as the
994        /// container, and set the center point to the center of your text view.
995        /// Create the ``UIPreviewParameters`` object using the selection rectangles
996        /// for the text, which you get from your view’s layout manager. Writing Tools
997        /// uses this information to place your image directly above the text in your view.
998        ///
999        /// For a single animation type, the system calls this method, followed sequentially
1000        /// by the ``writingToolsCoordinator(_:prepareFor:range:context:completion:)`` and
1001        /// ``writingToolsCoordinator(_:finish:for:in:completion:)``
1002        /// methods. Each method executes asynchronously, but the system calls the next
1003        /// method in the sequence only after you call the completion handler of the
1004        /// previous method. However, multiple animations can run simultaneously, so
1005        /// check the `textAnimation` parameter to differentiate sequences.
1006        #[unsafe(method(writingToolsCoordinator:requestsPreviewForTextAnimation:ofRange:inContext:completion:))]
1007        #[unsafe(method_family = none)]
1008        unsafe fn writingToolsCoordinator_requestsPreviewForTextAnimation_ofRange_inContext_completion(
1009            &self,
1010            writing_tools_coordinator: &UIWritingToolsCoordinator,
1011            text_animation: UIWritingToolsCoordinatorTextAnimation,
1012            range: NSRange,
1013            context: &UIWritingToolsCoordinatorContext,
1014            completion: &block2::DynBlock<dyn Fn(*mut UITargetedPreview)>,
1015        );
1016
1017        #[cfg(all(feature = "UIWritingToolsCoordinatorContext", feature = "block2"))]
1018        /// Asks the delegate to clean up any state related to the specified
1019        /// Writing Tools animation.
1020        ///
1021        /// - Parameters:
1022        /// - writingToolsCoordinator: The coordinator object notifying you
1023        /// that animations are about to begin.
1024        /// - textAnimation: The type of animation Writing Tools finished.
1025        /// - range: The range of text that finished animating. This range is
1026        /// relative to the text in your context object, and it’s your responsibility
1027        /// to match that location to the correct location in your text storage. If
1028        /// you initialized the context object with the entire contents of your
1029        /// view’s text storage, you can use `range` as-is to access that text storage.
1030        /// However, if you initialized the context object with only a portion of
1031        /// your view’s text, add the starting location of your context object’s
1032        /// text to this value to get the correct range for that text storage.
1033        /// - context: The context object that contains the original text.
1034        /// - completion: A completion handler to execute when you are done.
1035        /// The handler has no return value and takes no parameters. You must
1036        /// call this handler at some point during your implementation.
1037        ///
1038        /// Use this method to clean up any data structures you created to support
1039        /// the specified type of Writing Tools animation. You can also use this
1040        /// method to restore the visibility of any text you hid previously. When
1041        /// you finish your cleanup work, call the completion handler to notify Writing Tools.
1042        ///
1043        /// Writing Tools calls this method only after previous calls to the
1044        /// ``writingToolsCoordinator(_:requestsPreviewFor:range:context:completion:)``
1045        /// and ``writingToolsCoordinator(_:prepareFor:range:context:completion:)``
1046        /// methods for the same animation type. However, Writing Tools can interleave
1047        /// calls to this method with calls to prepare an animation of a different
1048        /// type. In your implementation of this method, make sure the actions you
1049        /// take don’t interfere with other in-flight animations.
1050        #[unsafe(method(writingToolsCoordinator:finishTextAnimation:forRange:inContext:completion:))]
1051        #[unsafe(method_family = none)]
1052        unsafe fn writingToolsCoordinator_finishTextAnimation_forRange_inContext_completion(
1053            &self,
1054            writing_tools_coordinator: &UIWritingToolsCoordinator,
1055            text_animation: UIWritingToolsCoordinatorTextAnimation,
1056            range: NSRange,
1057            context: &UIWritingToolsCoordinatorContext,
1058            completion: &block2::DynBlock<dyn Fn()>,
1059        );
1060
1061        #[cfg(all(feature = "UIWritingToolsCoordinatorContext", feature = "block2"))]
1062        /// Asks the delegate to divide the specified range of text into the separate
1063        /// containers that render that text.
1064        ///
1065        /// - Parameters:
1066        /// - writingToolsCoordinator: The coordinator object requesting information
1067        /// from your custom view.
1068        /// - range: The range of text to consider in the specified `context` object.
1069        /// The location value of this range is relative to the beginning of the text
1070        /// in your context object, and it’s your responsibility to match that location
1071        /// to the correct location in your text storage. If you initialized the
1072        /// context object with the entire contents of your view’s text storage,
1073        /// you can use `range` as-is to access that text storage. However, if you
1074        /// initialized the context object with only a portion of your view’s text,
1075        /// add the starting location of your context object’s text to this value
1076        /// to get the correct range for that text storage.
1077        /// - context: The context object that contains the text to consider. Use this
1078        /// object to locate the appropriate text storage object for your view.
1079        /// - completion: A completion handler to execute when you are done. The handler
1080        /// has no return value and takes an array of
1081        /// <doc
1082        /// ://com.apple.documentation/documentation/foundation/nsvalue>
1083        /// types, each of which contains an
1084        /// <doc
1085        /// ://com.apple.documentation/documentation/foundation/nsrange>.
1086        /// The union of the ranges you pass to this handler must equal all of the
1087        /// text in `range`. The order of the ranges in the array must be sequential,
1088        /// with each new range's starting location coming after the previous one.
1089        /// There must also not be any gaps or overlap between ranges.
1090        /// You must call this handler at some point during your implementation.
1091        ///
1092        /// If your view uses multiple ``NSTextContainer`` objects to draw text in different
1093        /// regions, use this method to tell Writing Tools about the containers that display
1094        /// the specified text. In your implementation, subdivide `range` to create one new
1095        /// range for each portion of text that resides in a different container object.
1096        /// For example, if the text in `range` is split between two containers, provide
1097        /// two new
1098        /// <doc
1099        /// ://com.apple.documentation/documentation/foundation/nsrange> types
1100        /// that reflect the portion of the total text in each container. If `range` resides completely
1101        /// within one container, call the completion handler with `range` as the only value
1102        /// in the array.
1103        ///
1104        /// When configuring animations for your view, Writing Tools asks your delegate to
1105        /// provide separate previews for each of your view’s container object. Specifically,
1106        /// it calls your delegate’s ``writingToolsCoordinator(_:requestsPreviewFor:range:context:completion:)``
1107        /// method separately for each range of text you return in the completion handler.
1108        /// Your implementation of that method must create a preview suitable for animating
1109        /// the content from the underlying text container.
1110        #[optional]
1111        #[unsafe(method(writingToolsCoordinator:requestsSingleContainerSubrangesOfRange:inContext:completion:))]
1112        #[unsafe(method_family = none)]
1113        unsafe fn writingToolsCoordinator_requestsSingleContainerSubrangesOfRange_inContext_completion(
1114            &self,
1115            writing_tools_coordinator: &UIWritingToolsCoordinator,
1116            range: NSRange,
1117            context: &UIWritingToolsCoordinatorContext,
1118            completion: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSValue>>)>,
1119        );
1120
1121        #[cfg(all(
1122            feature = "UIResponder",
1123            feature = "UIView",
1124            feature = "UIWritingToolsCoordinatorContext",
1125            feature = "block2"
1126        ))]
1127        /// Asks the delegate to provide a decoration view for the specified range of text.
1128        ///
1129        /// - Parameters:
1130        /// - writingToolsCoordinator: The coordinator object requesting information
1131        /// from your custom view.
1132        /// - range: The range of text to consider in the specified `context` object.
1133        /// The location value of this range is relative to the beginning of the text
1134        /// in your context object, and it’s your responsibility to match that location
1135        /// to the correct location in your text storage. If you initialized the
1136        /// context object with the entire contents of your view’s text storage, you
1137        /// can use `range` as-is to access that text storage. However, if you initialized
1138        /// the context object with only a portion of your view’s text, add the starting
1139        /// location of your context object’s text to this value to get the correct
1140        /// range for that text storage.
1141        /// - context: The context object that contains the text to consider. Use this
1142        /// object to locate the appropriate text storage object for your view.
1143        /// - completion: A completion handler to execute when you are done. The handler
1144        /// has no return value and takes a ``UIView`` object as a parameter. You must call
1145        /// this handler at some point during your implementation.
1146        ///
1147        /// If your view uses multiple ``NSTextContainer`` objects to draw text in different
1148        /// regions, use this method to provide Writing Tools with the view to use for the
1149        /// specified range of text. After calling your delegate’s ``writingToolsCoordinator(_:requestsSingleContainerSubrangesOf:in:completion:)``
1150        /// method, Writing Tools calls this method for each subrange of text you provided.
1151        /// Find or provide a view situated visibly below the specified text in your text
1152        /// view. It's also satisfactory to provide a view that’s visually in front of the
1153        /// text. Writing Tools uses the provided view to host any proofreading marks for
1154        /// the specified range of text.
1155        ///
1156        /// If your view has only one text container, use the coordinator’s ``UIWritingToolsCoordinator/decorationContainerView``
1157        /// property to specify the view to use for proofreading marks.
1158        #[optional]
1159        #[unsafe(method(writingToolsCoordinator:requestsDecorationContainerViewForRange:inContext:completion:))]
1160        #[unsafe(method_family = none)]
1161        unsafe fn writingToolsCoordinator_requestsDecorationContainerViewForRange_inContext_completion(
1162            &self,
1163            writing_tools_coordinator: &UIWritingToolsCoordinator,
1164            range: NSRange,
1165            context: &UIWritingToolsCoordinatorContext,
1166            completion: &block2::DynBlock<dyn Fn(NonNull<UIView>)>,
1167        );
1168
1169        #[cfg(feature = "block2")]
1170        /// Notifies your delegate of relevant state changes when Writing Tools
1171        /// is running in your view.
1172        ///
1173        /// - Parameters:
1174        /// - writingToolsCoordinator: The coordinator object providing
1175        /// information to your custom view.
1176        /// - state: The new state for the Writing Tools session. For information
1177        /// about the possible states, see ``UIWritingToolsCoordinator/State``.
1178        /// - text: The current text for your context object.
1179        /// - reason: The reason for the state change.
1180        /// - context: The context object that contains the original text for
1181        /// Writing Tools to evaluate.
1182        /// - completion: A handler to execute when your delegate finishes processing
1183        /// the change of state. The handler has no parameters or return value. You
1184        /// must call this handler at some point during the implementation of your method.
1185        ///
1186        /// Use state transitions to perform actions related to your view or text storage.
1187        /// When Writing Tools is active, it updates its state to indicate what task
1188        /// it’s currently performing. Writing Tools starts in the ``UIWritingToolsCoordinator/State/inactive``
1189        /// state and moves to other states as it presents UI and starts interacting with
1190        /// your view’s content. For example, it moves to the ``UIWritingToolsCoordinator/State/interactiveStreaming``
1191        /// state when it’s making changes to your view’s text storage.
1192        #[optional]
1193        #[unsafe(method(writingToolsCoordinator:willChangeToState:completion:))]
1194        #[unsafe(method_family = none)]
1195        unsafe fn writingToolsCoordinator_willChangeToState_completion(
1196            &self,
1197            writing_tools_coordinator: &UIWritingToolsCoordinator,
1198            new_state: UIWritingToolsCoordinatorState,
1199            completion: &block2::DynBlock<dyn Fn()>,
1200        );
1201
1202        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
1203        /// Asks the delegate to provide the location of the character at the
1204        /// specified point in your view’s coordinate system.
1205        ///
1206        /// - Parameters:
1207        /// - writingToolsCoordinator: The coordinator object requesting
1208        /// information from your custom view.
1209        /// - point: A point in your view’s coordinate space. Find the
1210        /// location of the text under this point, if any.
1211        /// - completion: A handler to execute with the required information.
1212        /// This handler has no return value and takes an
1213        /// <doc
1214        /// ://com.apple.documentation/documentation/foundation/nsrange>
1215        /// and
1216        /// <doc
1217        /// ://com.apple.documentation/documentation/foundation/uuid>
1218        /// as parameters. Set the range to the character’s location in one of your
1219        /// ``UIWritingToolsCoordinator/Context`` objects, which you specify using
1220        /// the
1221        /// <doc
1222        /// ://com.apple.documentation/documentation/foundation/uuid> parameter.
1223        /// You must call this handler at some point during your method’s implementation.
1224        ///
1225        /// When someone interacts with your view during a proofreading operation, Writing Tools
1226        /// calls this method to get the location of the interaction. If the interaction
1227        /// occurs in the text of one of your ``UIWritingToolsCoordinator/Context`` objects,
1228        /// configure an
1229        /// <doc
1230        /// ://com.apple.documentation/documentation/foundation/nsrange>
1231        /// with the character’s location in that context object and a length of `1`. If
1232        /// the interaction occurs outside of the text of your context objects, configure
1233        /// the range with a location of `NSNotFound`.
1234        ///
1235        /// When specifying the location of a character in your context object, provide a
1236        /// location relative to the start of your context object’s text. The first character
1237        /// in a context object’s text is always at location `0`, and it’s your responsibility
1238        /// to track the location of the context object’s text in your text storage object.
1239        /// When the context object’s text begins in the middle of your text storage,
1240        /// subtract the starting location of the context object’s text from the location
1241        /// you specify in your range value. For example, if the context object’s text
1242        /// starts at character `100` in your text storage, and an interaction occurs
1243        /// with the character at location `102`, specify a range with a location of
1244        /// `2` and a length of `1`.
1245        #[deprecated = "In iOS 18.4 and later and visionOS 2.4 and later, UIWritingToolsCoordinator automatically determines the location of the character at the specified point in your view's coordinate system and no longer calls this method."]
1246        #[optional]
1247        #[unsafe(method(writingToolsCoordinator:requestsRangeInContextWithIdentifierForPoint:completion:))]
1248        #[unsafe(method_family = none)]
1249        unsafe fn writingToolsCoordinator_requestsRangeInContextWithIdentifierForPoint_completion(
1250            &self,
1251            writing_tools_coordinator: &UIWritingToolsCoordinator,
1252            point: CGPoint,
1253            completion: &block2::DynBlock<dyn Fn(NSRange, NonNull<NSUUID>)>,
1254        );
1255    }
1256);
1257
1258#[deprecated = "renamed to `UIWritingToolsCoordinatorTextAnimation::debug_description`"]
1259#[inline]
1260pub unsafe extern "C-unwind" fn UIWritingToolsCoordinatorTextAnimationDebugDescription(
1261    animation_type: UIWritingToolsCoordinatorTextAnimation,
1262) -> Retained<NSString> {
1263    extern "C-unwind" {
1264        fn UIWritingToolsCoordinatorTextAnimationDebugDescription(
1265            animation_type: UIWritingToolsCoordinatorTextAnimation,
1266        ) -> *mut NSString;
1267    }
1268    let ret = unsafe { UIWritingToolsCoordinatorTextAnimationDebugDescription(animation_type) };
1269    unsafe { Retained::retain_autoreleased(ret) }
1270        .expect("function was marked as returning non-null, but actually returned NULL")
1271}