objc2_app_kit/generated/
NSTextStorage.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/nstextstorageeditactions?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSTextStorageEditActions(pub NSUInteger);
15bitflags::bitflags! {
16    impl NSTextStorageEditActions: NSUInteger {
17        #[doc(alias = "NSTextStorageEditedAttributes")]
18        const EditedAttributes = 1<<0;
19        #[doc(alias = "NSTextStorageEditedCharacters")]
20        const EditedCharacters = 1<<1;
21    }
22}
23
24unsafe impl Encode for NSTextStorageEditActions {
25    const ENCODING: Encoding = NSUInteger::ENCODING;
26}
27
28unsafe impl RefEncode for NSTextStorageEditActions {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_class!(
33    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextstorage?language=objc)
34    #[unsafe(super(NSMutableAttributedString, NSAttributedString, NSObject))]
35    #[derive(Debug, PartialEq, Eq, Hash)]
36    pub struct NSTextStorage;
37);
38
39extern_conformance!(
40    unsafe impl NSCoding for NSTextStorage {}
41);
42
43extern_conformance!(
44    unsafe impl NSObjectProtocol for NSTextStorage {}
45);
46
47extern_conformance!(
48    unsafe impl NSSecureCoding for NSTextStorage {}
49);
50
51impl NSTextStorage {
52    extern_methods!(
53        #[cfg(feature = "NSLayoutManager")]
54        /// ************************** Layout manager ***************************
55        #[unsafe(method(layoutManagers))]
56        #[unsafe(method_family = none)]
57        pub fn layoutManagers(&self) -> Retained<NSArray<NSLayoutManager>>;
58
59        #[cfg(feature = "NSLayoutManager")]
60        #[unsafe(method(addLayoutManager:))]
61        #[unsafe(method_family = none)]
62        pub fn addLayoutManager(&self, a_layout_manager: &NSLayoutManager);
63
64        #[cfg(feature = "NSLayoutManager")]
65        #[unsafe(method(removeLayoutManager:))]
66        #[unsafe(method_family = none)]
67        pub fn removeLayoutManager(&self, a_layout_manager: &NSLayoutManager);
68
69        /// ************************** Pending edit info ***************************
70        #[unsafe(method(editedMask))]
71        #[unsafe(method_family = none)]
72        pub fn editedMask(&self) -> NSTextStorageEditActions;
73
74        #[unsafe(method(editedRange))]
75        #[unsafe(method_family = none)]
76        pub fn editedRange(&self) -> NSRange;
77
78        #[unsafe(method(changeInLength))]
79        #[unsafe(method_family = none)]
80        pub fn changeInLength(&self) -> NSInteger;
81
82        /// ************************** Delegate ***************************
83        #[unsafe(method(delegate))]
84        #[unsafe(method_family = none)]
85        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSTextStorageDelegate>>>;
86
87        /// Setter for [`delegate`][Self::delegate].
88        ///
89        /// This is a [weak property][objc2::topics::weak_property].
90        #[unsafe(method(setDelegate:))]
91        #[unsafe(method_family = none)]
92        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSTextStorageDelegate>>);
93
94        /// ************************** Edit management ***************************
95        #[unsafe(method(edited:range:changeInLength:))]
96        #[unsafe(method_family = none)]
97        pub fn edited_range_changeInLength(
98            &self,
99            edited_mask: NSTextStorageEditActions,
100            edited_range: NSRange,
101            delta: NSInteger,
102        );
103
104        #[unsafe(method(processEditing))]
105        #[unsafe(method_family = none)]
106        pub fn processEditing(&self);
107
108        /// ************************** Attribute fixing ***************************
109        #[unsafe(method(fixesAttributesLazily))]
110        #[unsafe(method_family = none)]
111        pub fn fixesAttributesLazily(&self) -> bool;
112
113        #[unsafe(method(invalidateAttributesInRange:))]
114        #[unsafe(method_family = none)]
115        pub fn invalidateAttributesInRange(&self, range: NSRange);
116
117        #[unsafe(method(ensureAttributesAreFixedInRange:))]
118        #[unsafe(method_family = none)]
119        pub fn ensureAttributesAreFixedInRange(&self, range: NSRange);
120
121        /// ************************** NSTextStorageObserving ***************************
122        #[unsafe(method(textStorageObserver))]
123        #[unsafe(method_family = none)]
124        pub fn textStorageObserver(
125            &self,
126        ) -> Option<Retained<ProtocolObject<dyn NSTextStorageObserving>>>;
127
128        /// Setter for [`textStorageObserver`][Self::textStorageObserver].
129        ///
130        /// This is a [weak property][objc2::topics::weak_property].
131        #[unsafe(method(setTextStorageObserver:))]
132        #[unsafe(method_family = none)]
133        pub fn setTextStorageObserver(
134            &self,
135            text_storage_observer: Option<&ProtocolObject<dyn NSTextStorageObserving>>,
136        );
137    );
138}
139
140/// Methods declared on superclass `NSObject`.
141impl NSTextStorage {
142    extern_methods!(
143        #[unsafe(method(init))]
144        #[unsafe(method_family = init)]
145        pub fn init(this: Allocated<Self>) -> Retained<Self>;
146
147        #[unsafe(method(new))]
148        #[unsafe(method_family = new)]
149        pub fn new() -> Retained<Self>;
150    );
151}
152
153impl DefaultRetained for NSTextStorage {
154    #[inline]
155    fn default_retained() -> Retained<Self> {
156        Self::new()
157    }
158}
159
160extern_protocol!(
161    /// **  NSTextStorage delegate methods ***
162    ///
163    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextstoragedelegate?language=objc)
164    pub unsafe trait NSTextStorageDelegate: NSObjectProtocol {
165        #[optional]
166        #[unsafe(method(textStorage:willProcessEditing:range:changeInLength:))]
167        #[unsafe(method_family = none)]
168        fn textStorage_willProcessEditing_range_changeInLength(
169            &self,
170            text_storage: &NSTextStorage,
171            edited_mask: NSTextStorageEditActions,
172            edited_range: NSRange,
173            delta: NSInteger,
174        );
175
176        #[optional]
177        #[unsafe(method(textStorage:didProcessEditing:range:changeInLength:))]
178        #[unsafe(method_family = none)]
179        fn textStorage_didProcessEditing_range_changeInLength(
180            &self,
181            text_storage: &NSTextStorage,
182            edited_mask: NSTextStorageEditActions,
183            edited_range: NSRange,
184            delta: NSInteger,
185        );
186    }
187);
188
189extern "C" {
190    /// ** Notifications ***
191    ///
192    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextstoragewillprocesseditingnotification?language=objc)
193    pub static NSTextStorageWillProcessEditingNotification: &'static NSNotificationName;
194}
195
196extern "C" {
197    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextstoragedidprocesseditingnotification?language=objc)
198    pub static NSTextStorageDidProcessEditingNotification: &'static NSNotificationName;
199}
200
201extern_protocol!(
202    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextstorageobserving?language=objc)
203    pub unsafe trait NSTextStorageObserving: NSObjectProtocol {
204        #[unsafe(method(textStorage))]
205        #[unsafe(method_family = none)]
206        fn textStorage(&self) -> Option<Retained<NSTextStorage>>;
207
208        /// Setter for [`textStorage`][Self::textStorage].
209        #[unsafe(method(setTextStorage:))]
210        #[unsafe(method_family = none)]
211        fn setTextStorage(&self, text_storage: Option<&NSTextStorage>);
212
213        #[unsafe(method(processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:))]
214        #[unsafe(method_family = none)]
215        fn processEditingForTextStorage_edited_range_changeInLength_invalidatedRange(
216            &self,
217            text_storage: &NSTextStorage,
218            edit_mask: NSTextStorageEditActions,
219            new_char_range: NSRange,
220            delta: NSInteger,
221            invalidated_char_range: NSRange,
222        );
223
224        #[cfg(feature = "block2")]
225        #[unsafe(method(performEditingTransactionForTextStorage:usingBlock:))]
226        #[unsafe(method_family = none)]
227        fn performEditingTransactionForTextStorage_usingBlock(
228            &self,
229            text_storage: &NSTextStorage,
230            transaction: &block2::DynBlock<dyn Fn() + '_>,
231        );
232    }
233);
234
235/// ** Deprecations ***
236///
237/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextstorageeditedoptions?language=objc)
238pub type NSTextStorageEditedOptions = NSUInteger;