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
39unsafe impl NSCoding for NSTextStorage {}
40
41unsafe impl NSObjectProtocol for NSTextStorage {}
42
43unsafe impl NSSecureCoding for NSTextStorage {}
44
45impl NSTextStorage {
46 extern_methods!(
47 #[cfg(feature = "NSLayoutManager")]
48 #[unsafe(method(layoutManagers))]
50 #[unsafe(method_family = none)]
51 pub unsafe fn layoutManagers(&self) -> Retained<NSArray<NSLayoutManager>>;
52
53 #[cfg(feature = "NSLayoutManager")]
54 #[unsafe(method(addLayoutManager:))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn addLayoutManager(&self, a_layout_manager: &NSLayoutManager);
57
58 #[cfg(feature = "NSLayoutManager")]
59 #[unsafe(method(removeLayoutManager:))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn removeLayoutManager(&self, a_layout_manager: &NSLayoutManager);
62
63 #[unsafe(method(editedMask))]
65 #[unsafe(method_family = none)]
66 pub unsafe fn editedMask(&self) -> NSTextStorageEditActions;
67
68 #[unsafe(method(editedRange))]
69 #[unsafe(method_family = none)]
70 pub unsafe fn editedRange(&self) -> NSRange;
71
72 #[unsafe(method(changeInLength))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn changeInLength(&self) -> NSInteger;
75
76 #[unsafe(method(delegate))]
78 #[unsafe(method_family = none)]
79 pub unsafe fn delegate(
80 &self,
81 ) -> Option<Retained<ProtocolObject<dyn NSTextStorageDelegate>>>;
82
83 #[unsafe(method(setDelegate:))]
86 #[unsafe(method_family = none)]
87 pub unsafe fn setDelegate(
88 &self,
89 delegate: Option<&ProtocolObject<dyn NSTextStorageDelegate>>,
90 );
91
92 #[unsafe(method(edited:range:changeInLength:))]
94 #[unsafe(method_family = none)]
95 pub unsafe fn edited_range_changeInLength(
96 &self,
97 edited_mask: NSTextStorageEditActions,
98 edited_range: NSRange,
99 delta: NSInteger,
100 );
101
102 #[unsafe(method(processEditing))]
103 #[unsafe(method_family = none)]
104 pub unsafe fn processEditing(&self);
105
106 #[unsafe(method(fixesAttributesLazily))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn fixesAttributesLazily(&self) -> bool;
110
111 #[unsafe(method(invalidateAttributesInRange:))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn invalidateAttributesInRange(&self, range: NSRange);
114
115 #[unsafe(method(ensureAttributesAreFixedInRange:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn ensureAttributesAreFixedInRange(&self, range: NSRange);
118
119 #[unsafe(method(textStorageObserver))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn textStorageObserver(
123 &self,
124 ) -> Option<Retained<ProtocolObject<dyn NSTextStorageObserving>>>;
125
126 #[unsafe(method(setTextStorageObserver:))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn setTextStorageObserver(
131 &self,
132 text_storage_observer: Option<&ProtocolObject<dyn NSTextStorageObserving>>,
133 );
134 );
135}
136
137impl NSTextStorage {
139 extern_methods!(
140 #[unsafe(method(init))]
141 #[unsafe(method_family = init)]
142 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
143
144 #[unsafe(method(new))]
145 #[unsafe(method_family = new)]
146 pub unsafe fn new() -> Retained<Self>;
147 );
148}
149
150extern_protocol!(
151 pub unsafe trait NSTextStorageDelegate: NSObjectProtocol {
155 #[optional]
156 #[unsafe(method(textStorage:willProcessEditing:range:changeInLength:))]
157 #[unsafe(method_family = none)]
158 unsafe fn textStorage_willProcessEditing_range_changeInLength(
159 &self,
160 text_storage: &NSTextStorage,
161 edited_mask: NSTextStorageEditActions,
162 edited_range: NSRange,
163 delta: NSInteger,
164 );
165
166 #[optional]
167 #[unsafe(method(textStorage:didProcessEditing:range:changeInLength:))]
168 #[unsafe(method_family = none)]
169 unsafe fn textStorage_didProcessEditing_range_changeInLength(
170 &self,
171 text_storage: &NSTextStorage,
172 edited_mask: NSTextStorageEditActions,
173 edited_range: NSRange,
174 delta: NSInteger,
175 );
176 }
177);
178
179extern "C" {
180 pub static NSTextStorageWillProcessEditingNotification: &'static NSNotificationName;
184}
185
186extern "C" {
187 pub static NSTextStorageDidProcessEditingNotification: &'static NSNotificationName;
189}
190
191extern_protocol!(
192 pub unsafe trait NSTextStorageObserving: NSObjectProtocol {
194 #[unsafe(method(textStorage))]
195 #[unsafe(method_family = none)]
196 unsafe fn textStorage(&self) -> Option<Retained<NSTextStorage>>;
197
198 #[unsafe(method(setTextStorage:))]
200 #[unsafe(method_family = none)]
201 unsafe fn setTextStorage(&self, text_storage: Option<&NSTextStorage>);
202
203 #[unsafe(method(processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:))]
204 #[unsafe(method_family = none)]
205 unsafe fn processEditingForTextStorage_edited_range_changeInLength_invalidatedRange(
206 &self,
207 text_storage: &NSTextStorage,
208 edit_mask: NSTextStorageEditActions,
209 new_char_range: NSRange,
210 delta: NSInteger,
211 invalidated_char_range: NSRange,
212 );
213
214 #[cfg(feature = "block2")]
215 #[unsafe(method(performEditingTransactionForTextStorage:usingBlock:))]
216 #[unsafe(method_family = none)]
217 unsafe fn performEditingTransactionForTextStorage_usingBlock(
218 &self,
219 text_storage: &NSTextStorage,
220 transaction: &block2::Block<dyn Fn() + '_>,
221 );
222 }
223);
224
225pub type NSTextStorageEditedOptions = NSUInteger;