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