objc2_app_kit/generated/
NSTextContentManager.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextcontentmanagerenumerationoptions?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSTextContentManagerEnumerationOptions(pub NSUInteger);
15bitflags::bitflags! {
16    impl NSTextContentManagerEnumerationOptions: NSUInteger {
17        #[doc(alias = "NSTextContentManagerEnumerationOptionsNone")]
18        const None = 0;
19        #[doc(alias = "NSTextContentManagerEnumerationOptionsReverse")]
20        const Reverse = 1<<0;
21    }
22}
23
24unsafe impl Encode for NSTextContentManagerEnumerationOptions {
25    const ENCODING: Encoding = NSUInteger::ENCODING;
26}
27
28unsafe impl RefEncode for NSTextContentManagerEnumerationOptions {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_protocol!(
33    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextelementprovider?language=objc)
34    pub unsafe trait NSTextElementProvider: NSObjectProtocol {
35        #[cfg(feature = "NSTextRange")]
36        #[unsafe(method(documentRange))]
37        #[unsafe(method_family = none)]
38        unsafe fn documentRange(&self) -> Retained<NSTextRange>;
39
40        #[cfg(all(feature = "NSTextElement", feature = "NSTextRange", feature = "block2"))]
41        #[unsafe(method(enumerateTextElementsFromLocation:options:usingBlock:))]
42        #[unsafe(method_family = none)]
43        unsafe fn enumerateTextElementsFromLocation_options_usingBlock(
44            &self,
45            text_location: Option<&ProtocolObject<dyn NSTextLocation>>,
46            options: NSTextContentManagerEnumerationOptions,
47            block: &block2::Block<dyn Fn(NonNull<NSTextElement>) -> Bool + '_>,
48        ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
49
50        #[cfg(all(feature = "NSTextElement", feature = "NSTextRange"))]
51        #[unsafe(method(replaceContentsInRange:withTextElements:))]
52        #[unsafe(method_family = none)]
53        unsafe fn replaceContentsInRange_withTextElements(
54            &self,
55            range: &NSTextRange,
56            text_elements: Option<&NSArray<NSTextElement>>,
57        );
58
59        #[cfg(feature = "block2")]
60        #[unsafe(method(synchronizeToBackingStore:))]
61        #[unsafe(method_family = none)]
62        unsafe fn synchronizeToBackingStore(
63            &self,
64            completion_handler: Option<&block2::Block<dyn Fn(*mut NSError)>>,
65        );
66
67        #[cfg(feature = "NSTextRange")]
68        #[optional]
69        #[unsafe(method(locationFromLocation:withOffset:))]
70        #[unsafe(method_family = none)]
71        unsafe fn locationFromLocation_withOffset(
72            &self,
73            location: &ProtocolObject<dyn NSTextLocation>,
74            offset: NSInteger,
75        ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
76
77        #[cfg(feature = "NSTextRange")]
78        #[optional]
79        #[unsafe(method(offsetFromLocation:toLocation:))]
80        #[unsafe(method_family = none)]
81        unsafe fn offsetFromLocation_toLocation(
82            &self,
83            from: &ProtocolObject<dyn NSTextLocation>,
84            to: &ProtocolObject<dyn NSTextLocation>,
85        ) -> NSInteger;
86
87        #[cfg(feature = "NSTextRange")]
88        #[optional]
89        #[unsafe(method(adjustedRangeFromRange:forEditingTextSelection:))]
90        #[unsafe(method_family = none)]
91        unsafe fn adjustedRangeFromRange_forEditingTextSelection(
92            &self,
93            text_range: &NSTextRange,
94            for_editing_text_selection: bool,
95        ) -> Option<Retained<NSTextRange>>;
96    }
97);
98
99extern_class!(
100    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextcontentmanager?language=objc)
101    #[unsafe(super(NSObject))]
102    #[derive(Debug, PartialEq, Eq, Hash)]
103    pub struct NSTextContentManager;
104);
105
106unsafe impl NSCoding for NSTextContentManager {}
107
108unsafe impl NSObjectProtocol for NSTextContentManager {}
109
110unsafe impl NSSecureCoding for NSTextContentManager {}
111
112unsafe impl NSTextElementProvider for NSTextContentManager {}
113
114impl NSTextContentManager {
115    extern_methods!(
116        #[unsafe(method(init))]
117        #[unsafe(method_family = init)]
118        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
119
120        #[unsafe(method(initWithCoder:))]
121        #[unsafe(method_family = init)]
122        pub unsafe fn initWithCoder(
123            this: Allocated<Self>,
124            coder: &NSCoder,
125        ) -> Option<Retained<Self>>;
126
127        #[unsafe(method(delegate))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn delegate(
130            &self,
131        ) -> Option<Retained<ProtocolObject<dyn NSTextContentManagerDelegate>>>;
132
133        /// This is a [weak property][objc2::topics::weak_property].
134        /// Setter for [`delegate`][Self::delegate].
135        #[unsafe(method(setDelegate:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setDelegate(
138            &self,
139            delegate: Option<&ProtocolObject<dyn NSTextContentManagerDelegate>>,
140        );
141
142        #[cfg(feature = "NSTextLayoutManager")]
143        #[unsafe(method(textLayoutManagers))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn textLayoutManagers(&self) -> Retained<NSArray<NSTextLayoutManager>>;
146
147        #[cfg(feature = "NSTextLayoutManager")]
148        #[unsafe(method(addTextLayoutManager:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn addTextLayoutManager(&self, text_layout_manager: &NSTextLayoutManager);
151
152        #[cfg(feature = "NSTextLayoutManager")]
153        #[unsafe(method(removeTextLayoutManager:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn removeTextLayoutManager(&self, text_layout_manager: &NSTextLayoutManager);
156
157        #[cfg(feature = "NSTextLayoutManager")]
158        #[unsafe(method(primaryTextLayoutManager))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn primaryTextLayoutManager(&self) -> Option<Retained<NSTextLayoutManager>>;
161
162        #[cfg(feature = "NSTextLayoutManager")]
163        /// Setter for [`primaryTextLayoutManager`][Self::primaryTextLayoutManager].
164        #[unsafe(method(setPrimaryTextLayoutManager:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setPrimaryTextLayoutManager(
167            &self,
168            primary_text_layout_manager: Option<&NSTextLayoutManager>,
169        );
170
171        #[cfg(feature = "block2")]
172        #[unsafe(method(synchronizeTextLayoutManagers:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn synchronizeTextLayoutManagers(
175            &self,
176            completion_handler: Option<&block2::Block<dyn Fn(*mut NSError)>>,
177        );
178
179        #[cfg(all(feature = "NSTextElement", feature = "NSTextRange"))]
180        #[unsafe(method(textElementsForRange:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn textElementsForRange(
183            &self,
184            range: &NSTextRange,
185        ) -> Retained<NSArray<NSTextElement>>;
186
187        #[unsafe(method(hasEditingTransaction))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn hasEditingTransaction(&self) -> bool;
190
191        #[cfg(feature = "block2")]
192        #[unsafe(method(performEditingTransactionUsingBlock:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn performEditingTransactionUsingBlock(
195            &self,
196            transaction: &block2::Block<dyn Fn() + '_>,
197        );
198
199        #[cfg(feature = "NSTextRange")]
200        #[unsafe(method(recordEditActionInRange:newTextRange:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn recordEditActionInRange_newTextRange(
203            &self,
204            original_text_range: &NSTextRange,
205            new_text_range: &NSTextRange,
206        );
207
208        #[unsafe(method(automaticallySynchronizesTextLayoutManagers))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn automaticallySynchronizesTextLayoutManagers(&self) -> bool;
211
212        /// Setter for [`automaticallySynchronizesTextLayoutManagers`][Self::automaticallySynchronizesTextLayoutManagers].
213        #[unsafe(method(setAutomaticallySynchronizesTextLayoutManagers:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn setAutomaticallySynchronizesTextLayoutManagers(
216            &self,
217            automatically_synchronizes_text_layout_managers: bool,
218        );
219
220        #[unsafe(method(automaticallySynchronizesToBackingStore))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn automaticallySynchronizesToBackingStore(&self) -> bool;
223
224        /// Setter for [`automaticallySynchronizesToBackingStore`][Self::automaticallySynchronizesToBackingStore].
225        #[unsafe(method(setAutomaticallySynchronizesToBackingStore:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn setAutomaticallySynchronizesToBackingStore(
228            &self,
229            automatically_synchronizes_to_backing_store: bool,
230        );
231    );
232}
233
234/// Methods declared on superclass `NSObject`.
235impl NSTextContentManager {
236    extern_methods!(
237        #[unsafe(method(new))]
238        #[unsafe(method_family = new)]
239        pub unsafe fn new() -> Retained<Self>;
240    );
241}
242
243extern_protocol!(
244    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextcontentmanagerdelegate?language=objc)
245    pub unsafe trait NSTextContentManagerDelegate: NSObjectProtocol {
246        #[cfg(all(feature = "NSTextElement", feature = "NSTextRange"))]
247        #[optional]
248        #[unsafe(method(textContentManager:textElementAtLocation:))]
249        #[unsafe(method_family = none)]
250        unsafe fn textContentManager_textElementAtLocation(
251            &self,
252            text_content_manager: &NSTextContentManager,
253            location: &ProtocolObject<dyn NSTextLocation>,
254        ) -> Option<Retained<NSTextElement>>;
255
256        #[cfg(feature = "NSTextElement")]
257        #[optional]
258        #[unsafe(method(textContentManager:shouldEnumerateTextElement:options:))]
259        #[unsafe(method_family = none)]
260        unsafe fn textContentManager_shouldEnumerateTextElement_options(
261            &self,
262            text_content_manager: &NSTextContentManager,
263            text_element: &NSTextElement,
264            options: NSTextContentManagerEnumerationOptions,
265        ) -> bool;
266    }
267);
268
269extern_protocol!(
270    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextcontentstoragedelegate?language=objc)
271    pub unsafe trait NSTextContentStorageDelegate: NSTextContentManagerDelegate {
272        #[cfg(feature = "NSTextElement")]
273        #[optional]
274        #[unsafe(method(textContentStorage:textParagraphWithRange:))]
275        #[unsafe(method_family = none)]
276        unsafe fn textContentStorage_textParagraphWithRange(
277            &self,
278            text_content_storage: &NSTextContentStorage,
279            range: NSRange,
280        ) -> Option<Retained<NSTextParagraph>>;
281    }
282);
283
284extern_class!(
285    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextcontentstorage?language=objc)
286    #[unsafe(super(NSTextContentManager, NSObject))]
287    #[derive(Debug, PartialEq, Eq, Hash)]
288    pub struct NSTextContentStorage;
289);
290
291unsafe impl NSCoding for NSTextContentStorage {}
292
293unsafe impl NSObjectProtocol for NSTextContentStorage {}
294
295unsafe impl NSSecureCoding for NSTextContentStorage {}
296
297unsafe impl NSTextElementProvider for NSTextContentStorage {}
298
299#[cfg(feature = "NSTextStorage")]
300unsafe impl NSTextStorageObserving for NSTextContentStorage {}
301
302impl NSTextContentStorage {
303    extern_methods!(
304        #[unsafe(method(delegate))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn delegate(
307            &self,
308        ) -> Option<Retained<ProtocolObject<dyn NSTextContentStorageDelegate>>>;
309
310        /// This is a [weak property][objc2::topics::weak_property].
311        /// Setter for [`delegate`][Self::delegate].
312        #[unsafe(method(setDelegate:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn setDelegate(
315            &self,
316            delegate: Option<&ProtocolObject<dyn NSTextContentStorageDelegate>>,
317        );
318
319        #[unsafe(method(attributedString))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn attributedString(&self) -> Option<Retained<NSAttributedString>>;
322
323        /// Setter for [`attributedString`][Self::attributedString].
324        #[unsafe(method(setAttributedString:))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn setAttributedString(&self, attributed_string: Option<&NSAttributedString>);
327
328        #[cfg(feature = "NSTextElement")]
329        #[unsafe(method(attributedStringForTextElement:))]
330        #[unsafe(method_family = none)]
331        pub unsafe fn attributedStringForTextElement(
332            &self,
333            text_element: &NSTextElement,
334        ) -> Option<Retained<NSAttributedString>>;
335
336        #[cfg(feature = "NSTextElement")]
337        #[unsafe(method(textElementForAttributedString:))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn textElementForAttributedString(
340            &self,
341            attributed_string: &NSAttributedString,
342        ) -> Option<Retained<NSTextElement>>;
343
344        #[cfg(feature = "NSTextRange")]
345        #[unsafe(method(locationFromLocation:withOffset:))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn locationFromLocation_withOffset(
348            &self,
349            location: &ProtocolObject<dyn NSTextLocation>,
350            offset: NSInteger,
351        ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
352
353        #[cfg(feature = "NSTextRange")]
354        #[unsafe(method(offsetFromLocation:toLocation:))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn offsetFromLocation_toLocation(
357            &self,
358            from: &ProtocolObject<dyn NSTextLocation>,
359            to: &ProtocolObject<dyn NSTextLocation>,
360        ) -> NSInteger;
361
362        #[cfg(feature = "NSTextRange")]
363        #[unsafe(method(adjustedRangeFromRange:forEditingTextSelection:))]
364        #[unsafe(method_family = none)]
365        pub unsafe fn adjustedRangeFromRange_forEditingTextSelection(
366            &self,
367            text_range: &NSTextRange,
368            for_editing_text_selection: bool,
369        ) -> Option<Retained<NSTextRange>>;
370    );
371}
372
373/// Methods declared on superclass `NSTextContentManager`.
374impl NSTextContentStorage {
375    extern_methods!(
376        #[unsafe(method(init))]
377        #[unsafe(method_family = init)]
378        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
379
380        #[unsafe(method(initWithCoder:))]
381        #[unsafe(method_family = init)]
382        pub unsafe fn initWithCoder(
383            this: Allocated<Self>,
384            coder: &NSCoder,
385        ) -> Option<Retained<Self>>;
386    );
387}
388
389/// Methods declared on superclass `NSObject`.
390impl NSTextContentStorage {
391    extern_methods!(
392        #[unsafe(method(new))]
393        #[unsafe(method_family = new)]
394        pub unsafe fn new() -> Retained<Self>;
395    );
396}
397
398extern "C" {
399    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextcontentstorageunsupportedattributeaddednotification?language=objc)
400    pub static NSTextContentStorageUnsupportedAttributeAddedNotification:
401        &'static NSNotificationName;
402}