objc2_app_kit/generated/NSWritingToolsCoordinatorContext.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 /// `NSWritingToolsCoordinator.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 /// ``NSWritingToolsCoordinator/Delegate/writingToolsCoordinator(_:requestsContextsFor:completion:)``
16 /// method of your ``NSWritingToolsCoordinator/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 /// `NSWritingToolsCoordinator.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/appkit/nswritingtoolscoordinatorcontext?language=objc)
64 #[unsafe(super(NSObject))]
65 #[derive(Debug, PartialEq, Eq, Hash)]
66 pub struct NSWritingToolsCoordinatorContext;
67);
68
69unsafe impl Send for NSWritingToolsCoordinatorContext {}
70
71unsafe impl Sync for NSWritingToolsCoordinatorContext {}
72
73unsafe impl NSObjectProtocol for NSWritingToolsCoordinatorContext {}
74
75impl NSWritingToolsCoordinatorContext {
76 extern_methods!(
77 /// Creates a context object with the specified attributed string and range
78 /// information.
79 ///
80 /// - Parameters:
81 /// - attributedString: A string that contains some or all of the content
82 /// from your view’s text storage. This initializer makes a copy of the
83 /// string you provide, so you can discard the original when you’re done.
84 /// - range: The portion of `attributedString` you want Writing Tools to
85 /// evaluate. If you want Writing Tools to evaluate the entire string you
86 /// provided, specify a range with a location of `0` and a length equal to
87 /// your string’s length. If you want Writing Tools to evaluate only part
88 /// of the string, provide the appropriate range in this parameter. Writing
89 /// Tools suggests changes only to the range of text you specify, but it
90 /// can consider text outside that range during the evaluation process.
91 ///
92 /// When Writing Tools asks for your view’s current selection, it’s best to
93 /// create a string that includes text before and after that selection. During
94 /// the evaluation process, Writing Tools can use the additional text you
95 /// provided to improve the results it delivers. If you do provide additional
96 /// text, set the `range` parameter to the portion of `attributedString` with
97 /// the current selection. Don’t use the `range` parameter to specify the
98 /// location of the text in your view’s text storage.
99 #[unsafe(method(initWithAttributedString:range:))]
100 #[unsafe(method_family = init)]
101 pub unsafe fn initWithAttributedString_range(
102 this: Allocated<Self>,
103 attributed_string: &NSAttributedString,
104 range: NSRange,
105 ) -> Retained<Self>;
106
107 #[unsafe(method(init))]
108 #[unsafe(method_family = init)]
109 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
110
111 /// The portion of your view’s text to evaluate.
112 ///
113 /// The ``NSWritingToolsCoordinator/Context`` object initializes the value of this
114 /// property at creation time and doesn’t change it during the course of an operation.
115 /// Instead, it suggests changes to the text in the indicated range and reports
116 /// those changes to your ``NSWritingToolsCoordinator/Delegate`` object. Use the methods
117 /// of your delegate object to integrate those changes back into your view’s text storage.
118 ///
119 /// It’s your responsibility to track the location of this text in your
120 /// view’s text storage object. When Writing Tools reports changes,
121 /// it provides range values relative to this string. If you initialize
122 /// this property with a subset of your view’s content, you must adjust
123 /// any ranges that Writing Tools provides to get the correct location
124 /// in your text storage.
125 #[unsafe(method(attributedString))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn attributedString(&self) -> Retained<NSAttributedString>;
128
129 /// The unique identifier of the context object.
130 ///
131 /// The ``NSWritingToolsCoordinator/Context`` object initializes the value of this property
132 /// at creation time. Use this value to identify the context object within your app.
133 #[unsafe(method(range))]
134 #[unsafe(method_family = none)]
135 pub unsafe fn range(&self) -> NSRange;
136
137 /// The unique identifier of the context object.
138 ///
139 /// The ``NSWritingToolsCoordinator/Context`` object initializes the value of
140 /// this property at creation time. Use this value to identify the
141 /// context object within your app.
142 #[unsafe(method(identifier))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn identifier(&self) -> Retained<NSUUID>;
145
146 /// The actual range of text that Writing Tools might change, which can
147 /// be different than the range of text you supplied.
148 ///
149 /// After analyzing the text in your context object, Writing Tools sets
150 /// this property to the portion of ``attributedString`` it might modify.
151 /// Initially, this property has a location of
152 /// <doc
153 /// ://com.apple.documentation/documentation/foundation/nsnotfound> and a length
154 /// of `0`, but Writing Tools updates those values before making any changes
155 /// to the text.
156 ///
157 /// While the Writing Tools operation is active, make sure Writing Tools has
158 /// exclusive access to the text in this range. Your ``NSWritingToolsCoordinator/Delegate``
159 /// object can make changes to the text as part of incorporating Writing Tools
160 /// results, but don’t allow changes to come from other sources. For example,
161 /// don’t let someone edit the text in this range directly until Writing Tools finishes.
162 #[unsafe(method(resolvedRange))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn resolvedRange(&self) -> NSRange;
165 );
166}
167
168/// Methods declared on superclass `NSObject`.
169impl NSWritingToolsCoordinatorContext {
170 extern_methods!(
171 #[unsafe(method(new))]
172 #[unsafe(method_family = new)]
173 pub unsafe fn new() -> Retained<Self>;
174 );
175}