objc2_app_kit/generated/
NSTextStorage.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[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 #[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 #[unsafe(method(layoutManagers))]
56 #[unsafe(method_family = none)]
57 pub unsafe fn layoutManagers(&self) -> Retained<NSArray<NSLayoutManager>>;
58
59 #[cfg(feature = "NSLayoutManager")]
60 #[unsafe(method(addLayoutManager:))]
61 #[unsafe(method_family = none)]
62 pub unsafe fn addLayoutManager(&self, a_layout_manager: &NSLayoutManager);
63
64 #[cfg(feature = "NSLayoutManager")]
65 #[unsafe(method(removeLayoutManager:))]
66 #[unsafe(method_family = none)]
67 pub unsafe fn removeLayoutManager(&self, a_layout_manager: &NSLayoutManager);
68
69 #[unsafe(method(editedMask))]
71 #[unsafe(method_family = none)]
72 pub unsafe fn editedMask(&self) -> NSTextStorageEditActions;
73
74 #[unsafe(method(editedRange))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn editedRange(&self) -> NSRange;
77
78 #[unsafe(method(changeInLength))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn changeInLength(&self) -> NSInteger;
81
82 #[unsafe(method(delegate))]
84 #[unsafe(method_family = none)]
85 pub unsafe fn delegate(
86 &self,
87 ) -> Option<Retained<ProtocolObject<dyn NSTextStorageDelegate>>>;
88
89 #[unsafe(method(setDelegate:))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn setDelegate(
94 &self,
95 delegate: Option<&ProtocolObject<dyn NSTextStorageDelegate>>,
96 );
97
98 #[unsafe(method(edited:range:changeInLength:))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn edited_range_changeInLength(
102 &self,
103 edited_mask: NSTextStorageEditActions,
104 edited_range: NSRange,
105 delta: NSInteger,
106 );
107
108 #[unsafe(method(processEditing))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn processEditing(&self);
111
112 #[unsafe(method(fixesAttributesLazily))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn fixesAttributesLazily(&self) -> bool;
116
117 #[unsafe(method(invalidateAttributesInRange:))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn invalidateAttributesInRange(&self, range: NSRange);
120
121 #[unsafe(method(ensureAttributesAreFixedInRange:))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn ensureAttributesAreFixedInRange(&self, range: NSRange);
124
125 #[unsafe(method(textStorageObserver))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn textStorageObserver(
129 &self,
130 ) -> Option<Retained<ProtocolObject<dyn NSTextStorageObserving>>>;
131
132 #[unsafe(method(setTextStorageObserver:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn setTextStorageObserver(
137 &self,
138 text_storage_observer: Option<&ProtocolObject<dyn NSTextStorageObserving>>,
139 );
140 );
141}
142
143impl NSTextStorage {
145 extern_methods!(
146 #[unsafe(method(init))]
147 #[unsafe(method_family = init)]
148 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
149
150 #[unsafe(method(new))]
151 #[unsafe(method_family = new)]
152 pub unsafe fn new() -> Retained<Self>;
153 );
154}
155
156extern_protocol!(
157 pub unsafe trait NSTextStorageDelegate: NSObjectProtocol {
161 #[optional]
162 #[unsafe(method(textStorage:willProcessEditing:range:changeInLength:))]
163 #[unsafe(method_family = none)]
164 unsafe fn textStorage_willProcessEditing_range_changeInLength(
165 &self,
166 text_storage: &NSTextStorage,
167 edited_mask: NSTextStorageEditActions,
168 edited_range: NSRange,
169 delta: NSInteger,
170 );
171
172 #[optional]
173 #[unsafe(method(textStorage:didProcessEditing:range:changeInLength:))]
174 #[unsafe(method_family = none)]
175 unsafe fn textStorage_didProcessEditing_range_changeInLength(
176 &self,
177 text_storage: &NSTextStorage,
178 edited_mask: NSTextStorageEditActions,
179 edited_range: NSRange,
180 delta: NSInteger,
181 );
182 }
183);
184
185extern "C" {
186 pub static NSTextStorageWillProcessEditingNotification: &'static NSNotificationName;
190}
191
192extern "C" {
193 pub static NSTextStorageDidProcessEditingNotification: &'static NSNotificationName;
195}
196
197extern_protocol!(
198 pub unsafe trait NSTextStorageObserving: NSObjectProtocol {
200 #[unsafe(method(textStorage))]
201 #[unsafe(method_family = none)]
202 unsafe fn textStorage(&self) -> Option<Retained<NSTextStorage>>;
203
204 #[unsafe(method(setTextStorage:))]
206 #[unsafe(method_family = none)]
207 unsafe fn setTextStorage(&self, text_storage: Option<&NSTextStorage>);
208
209 #[unsafe(method(processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:))]
210 #[unsafe(method_family = none)]
211 unsafe fn processEditingForTextStorage_edited_range_changeInLength_invalidatedRange(
212 &self,
213 text_storage: &NSTextStorage,
214 edit_mask: NSTextStorageEditActions,
215 new_char_range: NSRange,
216 delta: NSInteger,
217 invalidated_char_range: NSRange,
218 );
219
220 #[cfg(feature = "block2")]
221 #[unsafe(method(performEditingTransactionForTextStorage:usingBlock:))]
222 #[unsafe(method_family = none)]
223 unsafe fn performEditingTransactionForTextStorage_usingBlock(
224 &self,
225 text_storage: &NSTextStorage,
226 transaction: &block2::DynBlock<dyn Fn() + '_>,
227 );
228 }
229);
230
231pub type NSTextStorageEditedOptions = NSUInteger;