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