objc2_ui_kit/generated/
UIWritingToolsCoordinatorContext.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// A data object that you use to share your custom view’s text with Writing Tools.
11    ///
12    /// At the start of every Writing Tools operation, you create one or more
13    /// `UIWritingToolsCoordinator.Context` objects with a copy of the text you want Writing Tools
14    /// to evaluate. Each Writing Tools operation starts with a call to the
15    /// ``UIWritingToolsCoordinator/Delegate/writingToolsCoordinator(_:requestsContextsFor:completion:)``
16    /// method of your ``UIWritingToolsCoordinator/Delegate`` object. Use the parameters
17    /// of that method to determine how much of your view’s text to provide. For
18    /// some operations, Writing Tools asks for all of your view’s text, but in
19    /// others it asks for only a portion of the text. When Writing Tools finishes
20    /// its evaluation, it reports changes back to your delegate relative to the
21    /// context objects you provided.
22    ///
23    /// When Writing Tools asks for your view’s text, create one or more
24    /// `UIWritingToolsCoordinator.Context` objects with the requested content. If your view
25    /// contains only one text storage object, create only one context object for
26    /// the request. However, if you use multiple text storage objects to manage
27    /// different parts of your view’s content, you might need to create multiple
28    /// context objects. The actual number depends on how much of your text Writing
29    /// Tools asks for. For example, when Writing Tools asks for all of your view’s
30    /// content, you return one context object for each text storage object in your
31    /// view. However, if Writing Tools asks for the current selection, and one
32    /// text storage object contains all of the selected text, you create only
33    /// one context object for the content.
34    ///
35    /// Writing Tools uses your context objects as the starting point for its
36    /// evaluations, and as a reference point for any changes. Because Writing
37    /// Tools doesn’t know anything about your view or its content, it makes
38    /// suggestions only relative to your context objects. It’s your responsibility
39    /// to take those suggestions and incorporate them back into your view’s
40    /// text storage. In some cases, you might need to store additional information
41    /// to update your storage correctly. For example, you might need to store,
42    /// and update as needed, the offset from the start of your document to the
43    /// start of the text in your context object.
44    ///
45    /// When Writing Tools asks for the currently selected text in your view,
46    /// include some of the surrounding text in your context object as well.
47    /// Supply a string that includes the selection and any text up to the nearest
48    /// paragraph boundary. When creating your context object, specify a range
49    /// value that represents the portion of that string that corresponds to the
50    /// text selection. Providing some additional text in your context object can
51    /// help Writing Tools improve its evaluation of your content. Writing Tools
52    /// uses the ``resolvedRange`` property of your context object to indicate
53    /// what text it considered.
54    ///
55    /// If your context object includes text that you don’t want Writing Tools to
56    /// evaluate, add the `excludeFromWritingTools` attribute to the corresponding
57    /// characters of your
58    /// <doc
59    /// ://com.apple.documentation/documentation/foundation/nsattributedstring>
60    /// object. You might add this attribute if the text string includes a code
61    /// listing or readonly content that you don’t want Writing Tools to change.
62    ///
63    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwritingtoolscoordinatorcontext?language=objc)
64    #[unsafe(super(NSObject))]
65    #[derive(Debug, PartialEq, Eq, Hash)]
66    pub struct UIWritingToolsCoordinatorContext;
67);
68
69unsafe impl Send for UIWritingToolsCoordinatorContext {}
70
71unsafe impl Sync for UIWritingToolsCoordinatorContext {}
72
73extern_conformance!(
74    unsafe impl NSObjectProtocol for UIWritingToolsCoordinatorContext {}
75);
76
77impl UIWritingToolsCoordinatorContext {
78    extern_methods!(
79        /// Creates a context object with the specified attributed string and range
80        /// information.
81        ///
82        /// - Parameters:
83        /// - attributedString: A string that contains some or all of the content
84        /// from your view’s text storage. This initializer makes a copy of the
85        /// string you provide, so you can discard the original when you’re done.
86        /// - range: The portion of `attributedString` you want Writing Tools to
87        /// evaluate. If you want Writing Tools to evaluate the entire string you
88        /// provided, specify a range with a location of `0` and a length equal to
89        /// your string’s length. If you want Writing Tools to evaluate only part
90        /// of the string, provide the appropriate range in this parameter. Writing
91        /// Tools suggests changes only to the range of text you specify, but it
92        /// can consider text outside that range during the evaluation process.
93        ///
94        /// When Writing Tools asks for your view’s current selection, it’s best to
95        /// create a string that includes text before and after that selection. During
96        /// the evaluation process, Writing Tools can use the additional text you
97        /// provided to improve the results it delivers. If you do provide additional
98        /// text, set the `range` parameter to the portion of `attributedString` with
99        /// the current selection. Don’t use the `range` parameter to specify the
100        /// location of the text in your view’s text storage.
101        #[unsafe(method(initWithAttributedString:range:))]
102        #[unsafe(method_family = init)]
103        pub unsafe fn initWithAttributedString_range(
104            this: Allocated<Self>,
105            attributed_string: &NSAttributedString,
106            range: NSRange,
107        ) -> Retained<Self>;
108
109        #[unsafe(method(init))]
110        #[unsafe(method_family = init)]
111        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
112
113        /// The portion of your view’s text to evaluate.
114        ///
115        /// The `UIWritingToolsCoordinator/Context` object initializes the value of this
116        /// property at creation time and doesn’t change it during the course of an operation.
117        /// Instead, it suggests changes to the text in the indicated range and reports
118        /// those changes to your ``UIWritingToolsCoordinator/Delegate`` object. Use the methods
119        /// of your delegate object to integrate those changes back into your view’s text storage.
120        ///
121        /// It’s your responsibility to track the location of this text in your
122        /// view’s text storage object. When Writing Tools reports changes,
123        /// it provides range values relative to this string. If you initialize
124        /// this property with a subset of your view’s content, you must adjust
125        /// any ranges that Writing Tools provides to get the correct location
126        /// in your text storage.
127        #[unsafe(method(attributedString))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn attributedString(&self) -> Retained<NSAttributedString>;
130
131        /// The unique identifier of the context object.
132        ///
133        /// The ``UIWritingToolsCoordinator/Context`` object initializes the value of this property
134        /// at creation time. Use this value to identify the context object within your app.
135        #[unsafe(method(range))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn range(&self) -> NSRange;
138
139        /// The unique identifier of the context object.
140        ///
141        /// The ``UIWritingToolsCoordinator/Context`` object initializes the value of
142        /// this property at creation time. Use this value to identify the
143        /// context object within your app.
144        #[unsafe(method(identifier))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn identifier(&self) -> Retained<NSUUID>;
147
148        /// The actual range of text that Writing Tools might change, which can
149        /// be different than the range of text you supplied.
150        ///
151        /// After analyzing the text in your context object, Writing Tools sets
152        /// this property to the portion of ``attributedString`` it might modify.
153        /// Initially, this property has a location of
154        /// <doc
155        /// ://com.apple.documentation/documentation/foundation/nsnotfound> and a length
156        /// of `0`, but Writing Tools updates those values before making any changes
157        /// to the text.
158        ///
159        /// While the Writing Tools operation is active, make sure Writing Tools has
160        /// exclusive access to the text in this range. Your ``UIWritingToolsCoordinator/Delegate``
161        /// object can make changes to the text as part of incorporating Writing Tools
162        /// results, but don’t allow changes to come from other sources. For example,
163        /// don’t let someone edit the text in this range directly until Writing Tools finishes.
164        #[unsafe(method(resolvedRange))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn resolvedRange(&self) -> NSRange;
167    );
168}
169
170/// Methods declared on superclass `NSObject`.
171impl UIWritingToolsCoordinatorContext {
172    extern_methods!(
173        #[unsafe(method(new))]
174        #[unsafe(method_family = new)]
175        pub unsafe fn new() -> Retained<Self>;
176    );
177}