objc2_ui_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/uikit/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/uikit/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::DynBlock<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::DynBlock<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/uikit/nstextcontentmanager?language=objc)
101    #[unsafe(super(NSObject))]
102    #[derive(Debug, PartialEq, Eq, Hash)]
103    pub struct NSTextContentManager;
104);
105
106extern_conformance!(
107    unsafe impl NSCoding for NSTextContentManager {}
108);
109
110extern_conformance!(
111    unsafe impl NSObjectProtocol for NSTextContentManager {}
112);
113
114extern_conformance!(
115    unsafe impl NSSecureCoding for NSTextContentManager {}
116);
117
118extern_conformance!(
119    unsafe impl NSTextElementProvider for NSTextContentManager {}
120);
121
122impl NSTextContentManager {
123    extern_methods!(
124        #[unsafe(method(init))]
125        #[unsafe(method_family = init)]
126        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
127
128        #[unsafe(method(initWithCoder:))]
129        #[unsafe(method_family = init)]
130        pub unsafe fn initWithCoder(
131            this: Allocated<Self>,
132            coder: &NSCoder,
133        ) -> Option<Retained<Self>>;
134
135        #[unsafe(method(delegate))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn delegate(
138            &self,
139        ) -> Option<Retained<ProtocolObject<dyn NSTextContentManagerDelegate>>>;
140
141        /// This is a [weak property][objc2::topics::weak_property].
142        /// Setter for [`delegate`][Self::delegate].
143        #[unsafe(method(setDelegate:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn setDelegate(
146            &self,
147            delegate: Option<&ProtocolObject<dyn NSTextContentManagerDelegate>>,
148        );
149
150        #[cfg(feature = "NSTextLayoutManager")]
151        #[unsafe(method(textLayoutManagers))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn textLayoutManagers(&self) -> Retained<NSArray<NSTextLayoutManager>>;
154
155        #[cfg(feature = "NSTextLayoutManager")]
156        #[unsafe(method(addTextLayoutManager:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn addTextLayoutManager(&self, text_layout_manager: &NSTextLayoutManager);
159
160        #[cfg(feature = "NSTextLayoutManager")]
161        #[unsafe(method(removeTextLayoutManager:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn removeTextLayoutManager(&self, text_layout_manager: &NSTextLayoutManager);
164
165        #[cfg(feature = "NSTextLayoutManager")]
166        #[unsafe(method(primaryTextLayoutManager))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn primaryTextLayoutManager(&self) -> Option<Retained<NSTextLayoutManager>>;
169
170        #[cfg(feature = "NSTextLayoutManager")]
171        /// Setter for [`primaryTextLayoutManager`][Self::primaryTextLayoutManager].
172        #[unsafe(method(setPrimaryTextLayoutManager:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn setPrimaryTextLayoutManager(
175            &self,
176            primary_text_layout_manager: Option<&NSTextLayoutManager>,
177        );
178
179        #[cfg(feature = "block2")]
180        #[unsafe(method(synchronizeTextLayoutManagers:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn synchronizeTextLayoutManagers(
183            &self,
184            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
185        );
186
187        #[cfg(all(feature = "NSTextElement", feature = "NSTextRange"))]
188        #[unsafe(method(textElementsForRange:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn textElementsForRange(
191            &self,
192            range: &NSTextRange,
193        ) -> Retained<NSArray<NSTextElement>>;
194
195        #[unsafe(method(hasEditingTransaction))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn hasEditingTransaction(&self) -> bool;
198
199        #[cfg(feature = "block2")]
200        #[unsafe(method(performEditingTransactionUsingBlock:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn performEditingTransactionUsingBlock(
203            &self,
204            transaction: &block2::DynBlock<dyn Fn() + '_>,
205        );
206
207        #[cfg(feature = "NSTextRange")]
208        #[unsafe(method(recordEditActionInRange:newTextRange:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn recordEditActionInRange_newTextRange(
211            &self,
212            original_text_range: &NSTextRange,
213            new_text_range: &NSTextRange,
214        );
215
216        #[unsafe(method(automaticallySynchronizesTextLayoutManagers))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn automaticallySynchronizesTextLayoutManagers(&self) -> bool;
219
220        /// Setter for [`automaticallySynchronizesTextLayoutManagers`][Self::automaticallySynchronizesTextLayoutManagers].
221        #[unsafe(method(setAutomaticallySynchronizesTextLayoutManagers:))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn setAutomaticallySynchronizesTextLayoutManagers(
224            &self,
225            automatically_synchronizes_text_layout_managers: bool,
226        );
227
228        #[unsafe(method(automaticallySynchronizesToBackingStore))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn automaticallySynchronizesToBackingStore(&self) -> bool;
231
232        /// Setter for [`automaticallySynchronizesToBackingStore`][Self::automaticallySynchronizesToBackingStore].
233        #[unsafe(method(setAutomaticallySynchronizesToBackingStore:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setAutomaticallySynchronizesToBackingStore(
236            &self,
237            automatically_synchronizes_to_backing_store: bool,
238        );
239    );
240}
241
242/// Methods declared on superclass `NSObject`.
243impl NSTextContentManager {
244    extern_methods!(
245        #[unsafe(method(new))]
246        #[unsafe(method_family = new)]
247        pub unsafe fn new() -> Retained<Self>;
248    );
249}
250
251extern_protocol!(
252    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextcontentmanagerdelegate?language=objc)
253    pub unsafe trait NSTextContentManagerDelegate: NSObjectProtocol {
254        #[cfg(all(feature = "NSTextElement", feature = "NSTextRange"))]
255        #[optional]
256        #[unsafe(method(textContentManager:textElementAtLocation:))]
257        #[unsafe(method_family = none)]
258        unsafe fn textContentManager_textElementAtLocation(
259            &self,
260            text_content_manager: &NSTextContentManager,
261            location: &ProtocolObject<dyn NSTextLocation>,
262        ) -> Option<Retained<NSTextElement>>;
263
264        #[cfg(feature = "NSTextElement")]
265        #[optional]
266        #[unsafe(method(textContentManager:shouldEnumerateTextElement:options:))]
267        #[unsafe(method_family = none)]
268        unsafe fn textContentManager_shouldEnumerateTextElement_options(
269            &self,
270            text_content_manager: &NSTextContentManager,
271            text_element: &NSTextElement,
272            options: NSTextContentManagerEnumerationOptions,
273        ) -> bool;
274    }
275);
276
277extern_protocol!(
278    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextcontentstoragedelegate?language=objc)
279    pub unsafe trait NSTextContentStorageDelegate: NSTextContentManagerDelegate {
280        #[cfg(feature = "NSTextElement")]
281        #[optional]
282        #[unsafe(method(textContentStorage:textParagraphWithRange:))]
283        #[unsafe(method_family = none)]
284        unsafe fn textContentStorage_textParagraphWithRange(
285            &self,
286            text_content_storage: &NSTextContentStorage,
287            range: NSRange,
288        ) -> Option<Retained<NSTextParagraph>>;
289    }
290);
291
292extern_class!(
293    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextcontentstorage?language=objc)
294    #[unsafe(super(NSTextContentManager, NSObject))]
295    #[derive(Debug, PartialEq, Eq, Hash)]
296    pub struct NSTextContentStorage;
297);
298
299extern_conformance!(
300    unsafe impl NSCoding for NSTextContentStorage {}
301);
302
303extern_conformance!(
304    unsafe impl NSObjectProtocol for NSTextContentStorage {}
305);
306
307extern_conformance!(
308    unsafe impl NSSecureCoding for NSTextContentStorage {}
309);
310
311extern_conformance!(
312    unsafe impl NSTextElementProvider for NSTextContentStorage {}
313);
314
315#[cfg(feature = "NSTextStorage")]
316extern_conformance!(
317    unsafe impl NSTextStorageObserving for NSTextContentStorage {}
318);
319
320impl NSTextContentStorage {
321    extern_methods!(
322        #[unsafe(method(delegate))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn delegate(
325            &self,
326        ) -> Option<Retained<ProtocolObject<dyn NSTextContentStorageDelegate>>>;
327
328        /// This is a [weak property][objc2::topics::weak_property].
329        /// Setter for [`delegate`][Self::delegate].
330        #[unsafe(method(setDelegate:))]
331        #[unsafe(method_family = none)]
332        pub unsafe fn setDelegate(
333            &self,
334            delegate: Option<&ProtocolObject<dyn NSTextContentStorageDelegate>>,
335        );
336
337        #[unsafe(method(attributedString))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn attributedString(&self) -> Option<Retained<NSAttributedString>>;
340
341        /// Setter for [`attributedString`][Self::attributedString].
342        #[unsafe(method(setAttributedString:))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn setAttributedString(&self, attributed_string: Option<&NSAttributedString>);
345
346        #[cfg(feature = "NSTextElement")]
347        #[unsafe(method(attributedStringForTextElement:))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn attributedStringForTextElement(
350            &self,
351            text_element: &NSTextElement,
352        ) -> Option<Retained<NSAttributedString>>;
353
354        #[cfg(feature = "NSTextElement")]
355        #[unsafe(method(textElementForAttributedString:))]
356        #[unsafe(method_family = none)]
357        pub unsafe fn textElementForAttributedString(
358            &self,
359            attributed_string: &NSAttributedString,
360        ) -> Option<Retained<NSTextElement>>;
361
362        #[cfg(feature = "NSTextRange")]
363        #[unsafe(method(locationFromLocation:withOffset:))]
364        #[unsafe(method_family = none)]
365        pub unsafe fn locationFromLocation_withOffset(
366            &self,
367            location: &ProtocolObject<dyn NSTextLocation>,
368            offset: NSInteger,
369        ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
370
371        #[cfg(feature = "NSTextRange")]
372        #[unsafe(method(offsetFromLocation:toLocation:))]
373        #[unsafe(method_family = none)]
374        pub unsafe fn offsetFromLocation_toLocation(
375            &self,
376            from: &ProtocolObject<dyn NSTextLocation>,
377            to: &ProtocolObject<dyn NSTextLocation>,
378        ) -> NSInteger;
379
380        #[cfg(feature = "NSTextRange")]
381        #[unsafe(method(adjustedRangeFromRange:forEditingTextSelection:))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn adjustedRangeFromRange_forEditingTextSelection(
384            &self,
385            text_range: &NSTextRange,
386            for_editing_text_selection: bool,
387        ) -> Option<Retained<NSTextRange>>;
388    );
389}
390
391/// Methods declared on superclass `NSTextContentManager`.
392impl NSTextContentStorage {
393    extern_methods!(
394        #[unsafe(method(init))]
395        #[unsafe(method_family = init)]
396        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
397
398        #[unsafe(method(initWithCoder:))]
399        #[unsafe(method_family = init)]
400        pub unsafe fn initWithCoder(
401            this: Allocated<Self>,
402            coder: &NSCoder,
403        ) -> Option<Retained<Self>>;
404    );
405}
406
407/// Methods declared on superclass `NSObject`.
408impl NSTextContentStorage {
409    extern_methods!(
410        #[unsafe(method(new))]
411        #[unsafe(method_family = new)]
412        pub unsafe fn new() -> Retained<Self>;
413    );
414}
415
416extern "C" {
417    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextcontentstorageunsupportedattributeaddednotification?language=objc)
418    pub static NSTextContentStorageUnsupportedAttributeAddedNotification:
419        &'static NSNotificationName;
420}