objc2_app_kit/generated/
NSTextFinder.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/nstextfinderaction?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSTextFinderAction(pub NSInteger);
15impl NSTextFinderAction {
16    #[doc(alias = "NSTextFinderActionShowFindInterface")]
17    pub const ShowFindInterface: Self = Self(1);
18    #[doc(alias = "NSTextFinderActionNextMatch")]
19    pub const NextMatch: Self = Self(2);
20    #[doc(alias = "NSTextFinderActionPreviousMatch")]
21    pub const PreviousMatch: Self = Self(3);
22    #[doc(alias = "NSTextFinderActionReplaceAll")]
23    pub const ReplaceAll: Self = Self(4);
24    #[doc(alias = "NSTextFinderActionReplace")]
25    pub const Replace: Self = Self(5);
26    #[doc(alias = "NSTextFinderActionReplaceAndFind")]
27    pub const ReplaceAndFind: Self = Self(6);
28    #[doc(alias = "NSTextFinderActionSetSearchString")]
29    pub const SetSearchString: Self = Self(7);
30    #[doc(alias = "NSTextFinderActionReplaceAllInSelection")]
31    pub const ReplaceAllInSelection: Self = Self(8);
32    #[doc(alias = "NSTextFinderActionSelectAll")]
33    pub const SelectAll: Self = Self(9);
34    #[doc(alias = "NSTextFinderActionSelectAllInSelection")]
35    pub const SelectAllInSelection: Self = Self(10);
36    #[doc(alias = "NSTextFinderActionHideFindInterface")]
37    pub const HideFindInterface: Self = Self(11);
38    #[doc(alias = "NSTextFinderActionShowReplaceInterface")]
39    pub const ShowReplaceInterface: Self = Self(12);
40    #[doc(alias = "NSTextFinderActionHideReplaceInterface")]
41    pub const HideReplaceInterface: Self = Self(13);
42}
43
44unsafe impl Encode for NSTextFinderAction {
45    const ENCODING: Encoding = NSInteger::ENCODING;
46}
47
48unsafe impl RefEncode for NSTextFinderAction {
49    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
50}
51
52/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nspasteboardtypetextfinderoptionkey?language=objc)
53// NS_TYPED_ENUM
54pub type NSPasteboardTypeTextFinderOptionKey = NSString;
55
56extern "C" {
57    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfindercaseinsensitivekey?language=objc)
58    pub static NSTextFinderCaseInsensitiveKey: &'static NSPasteboardTypeTextFinderOptionKey;
59}
60
61extern "C" {
62    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfindermatchingtypekey?language=objc)
63    pub static NSTextFinderMatchingTypeKey: &'static NSPasteboardTypeTextFinderOptionKey;
64}
65
66/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfindermatchingtype?language=objc)
67// NS_ENUM
68#[repr(transparent)]
69#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
70pub struct NSTextFinderMatchingType(pub NSInteger);
71impl NSTextFinderMatchingType {
72    #[doc(alias = "NSTextFinderMatchingTypeContains")]
73    pub const Contains: Self = Self(0);
74    #[doc(alias = "NSTextFinderMatchingTypeStartsWith")]
75    pub const StartsWith: Self = Self(1);
76    #[doc(alias = "NSTextFinderMatchingTypeFullWord")]
77    pub const FullWord: Self = Self(2);
78    #[doc(alias = "NSTextFinderMatchingTypeEndsWith")]
79    pub const EndsWith: Self = Self(3);
80}
81
82unsafe impl Encode for NSTextFinderMatchingType {
83    const ENCODING: Encoding = NSInteger::ENCODING;
84}
85
86unsafe impl RefEncode for NSTextFinderMatchingType {
87    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
88}
89
90extern_class!(
91    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfinder?language=objc)
92    #[unsafe(super(NSObject))]
93    #[derive(Debug, PartialEq, Eq, Hash)]
94    pub struct NSTextFinder;
95);
96
97unsafe impl NSCoding for NSTextFinder {}
98
99unsafe impl NSObjectProtocol for NSTextFinder {}
100
101impl NSTextFinder {
102    extern_methods!(
103        #[unsafe(method(init))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
106
107        #[unsafe(method(initWithCoder:))]
108        #[unsafe(method_family = init)]
109        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
110
111        #[unsafe(method(client))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn client(&self) -> Option<Retained<ProtocolObject<dyn NSTextFinderClient>>>;
114
115        /// Setter for [`client`][Self::client].
116        #[unsafe(method(setClient:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn setClient(&self, client: Option<&ProtocolObject<dyn NSTextFinderClient>>);
119
120        #[unsafe(method(performAction:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn performAction(&self, op: NSTextFinderAction);
123
124        #[unsafe(method(validateAction:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn validateAction(&self, op: NSTextFinderAction) -> bool;
127
128        #[unsafe(method(findBarContainer))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn findBarContainer(
131            &self,
132        ) -> Option<Retained<ProtocolObject<dyn NSTextFinderBarContainer>>>;
133
134        /// Setter for [`findBarContainer`][Self::findBarContainer].
135        #[unsafe(method(setFindBarContainer:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setFindBarContainer(
138            &self,
139            find_bar_container: Option<&ProtocolObject<dyn NSTextFinderBarContainer>>,
140        );
141
142        #[unsafe(method(cancelFindIndicator))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn cancelFindIndicator(&self);
145
146        #[unsafe(method(findIndicatorNeedsUpdate))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn findIndicatorNeedsUpdate(&self) -> bool;
149
150        /// Setter for [`findIndicatorNeedsUpdate`][Self::findIndicatorNeedsUpdate].
151        #[unsafe(method(setFindIndicatorNeedsUpdate:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn setFindIndicatorNeedsUpdate(&self, find_indicator_needs_update: bool);
154
155        #[unsafe(method(isIncrementalSearchingEnabled))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn isIncrementalSearchingEnabled(&self) -> bool;
158
159        /// Setter for [`isIncrementalSearchingEnabled`][Self::isIncrementalSearchingEnabled].
160        #[unsafe(method(setIncrementalSearchingEnabled:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setIncrementalSearchingEnabled(&self, incremental_searching_enabled: bool);
163
164        #[unsafe(method(incrementalSearchingShouldDimContentView))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn incrementalSearchingShouldDimContentView(&self) -> bool;
167
168        /// Setter for [`incrementalSearchingShouldDimContentView`][Self::incrementalSearchingShouldDimContentView].
169        #[unsafe(method(setIncrementalSearchingShouldDimContentView:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn setIncrementalSearchingShouldDimContentView(
172            &self,
173            incremental_searching_should_dim_content_view: bool,
174        );
175
176        #[unsafe(method(incrementalMatchRanges))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn incrementalMatchRanges(&self) -> Retained<NSArray<NSValue>>;
179
180        #[unsafe(method(drawIncrementalMatchHighlightInRect:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn drawIncrementalMatchHighlightInRect(rect: NSRect);
183
184        #[unsafe(method(noteClientStringWillChange))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn noteClientStringWillChange(&self);
187    );
188}
189
190/// Methods declared on superclass `NSObject`.
191impl NSTextFinder {
192    extern_methods!(
193        #[unsafe(method(new))]
194        #[unsafe(method_family = new)]
195        pub unsafe fn new() -> Retained<Self>;
196    );
197}
198
199extern_protocol!(
200    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfinderclient?language=objc)
201    pub unsafe trait NSTextFinderClient: NSObjectProtocol {
202        #[optional]
203        #[unsafe(method(isSelectable))]
204        #[unsafe(method_family = none)]
205        unsafe fn isSelectable(&self) -> bool;
206
207        #[optional]
208        #[unsafe(method(allowsMultipleSelection))]
209        #[unsafe(method_family = none)]
210        unsafe fn allowsMultipleSelection(&self) -> bool;
211
212        #[optional]
213        #[unsafe(method(isEditable))]
214        #[unsafe(method_family = none)]
215        unsafe fn isEditable(&self) -> bool;
216
217        #[optional]
218        #[unsafe(method(string))]
219        #[unsafe(method_family = none)]
220        unsafe fn string(&self) -> Retained<NSString>;
221
222        #[optional]
223        #[unsafe(method(stringAtIndex:effectiveRange:endsWithSearchBoundary:))]
224        #[unsafe(method_family = none)]
225        unsafe fn stringAtIndex_effectiveRange_endsWithSearchBoundary(
226            &self,
227            character_index: NSUInteger,
228            out_range: NSRangePointer,
229            out_flag: NonNull<Bool>,
230        ) -> Retained<NSString>;
231
232        #[optional]
233        #[unsafe(method(stringLength))]
234        #[unsafe(method_family = none)]
235        unsafe fn stringLength(&self) -> NSUInteger;
236
237        #[optional]
238        #[unsafe(method(firstSelectedRange))]
239        #[unsafe(method_family = none)]
240        unsafe fn firstSelectedRange(&self) -> NSRange;
241
242        #[optional]
243        #[unsafe(method(selectedRanges))]
244        #[unsafe(method_family = none)]
245        unsafe fn selectedRanges(&self) -> Retained<NSArray<NSValue>>;
246
247        /// Setter for [`selectedRanges`][Self::selectedRanges].
248        #[optional]
249        #[unsafe(method(setSelectedRanges:))]
250        #[unsafe(method_family = none)]
251        unsafe fn setSelectedRanges(&self, selected_ranges: &NSArray<NSValue>);
252
253        #[optional]
254        #[unsafe(method(scrollRangeToVisible:))]
255        #[unsafe(method_family = none)]
256        unsafe fn scrollRangeToVisible(&self, range: NSRange);
257
258        #[optional]
259        #[unsafe(method(shouldReplaceCharactersInRanges:withStrings:))]
260        #[unsafe(method_family = none)]
261        unsafe fn shouldReplaceCharactersInRanges_withStrings(
262            &self,
263            ranges: &NSArray<NSValue>,
264            strings: &NSArray<NSString>,
265        ) -> bool;
266
267        #[optional]
268        #[unsafe(method(replaceCharactersInRange:withString:))]
269        #[unsafe(method_family = none)]
270        unsafe fn replaceCharactersInRange_withString(&self, range: NSRange, string: &NSString);
271
272        #[optional]
273        #[unsafe(method(didReplaceCharacters))]
274        #[unsafe(method_family = none)]
275        unsafe fn didReplaceCharacters(&self);
276
277        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
278        #[optional]
279        #[unsafe(method(contentViewAtIndex:effectiveCharacterRange:))]
280        #[unsafe(method_family = none)]
281        unsafe fn contentViewAtIndex_effectiveCharacterRange(
282            &self,
283            index: NSUInteger,
284            out_range: NSRangePointer,
285            mtm: MainThreadMarker,
286        ) -> Retained<NSView>;
287
288        #[optional]
289        #[unsafe(method(rectsForCharacterRange:))]
290        #[unsafe(method_family = none)]
291        unsafe fn rectsForCharacterRange(
292            &self,
293            range: NSRange,
294        ) -> Option<Retained<NSArray<NSValue>>>;
295
296        #[optional]
297        #[unsafe(method(visibleCharacterRanges))]
298        #[unsafe(method_family = none)]
299        unsafe fn visibleCharacterRanges(&self) -> Retained<NSArray<NSValue>>;
300
301        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
302        #[optional]
303        #[unsafe(method(drawCharactersInRange:forContentView:))]
304        #[unsafe(method_family = none)]
305        unsafe fn drawCharactersInRange_forContentView(&self, range: NSRange, view: &NSView);
306    }
307);
308
309extern_protocol!(
310    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfinderbarcontainer?language=objc)
311    pub unsafe trait NSTextFinderBarContainer: NSObjectProtocol {
312        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
313        #[unsafe(method(findBarView))]
314        #[unsafe(method_family = none)]
315        unsafe fn findBarView(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
316
317        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
318        /// Setter for [`findBarView`][Self::findBarView].
319        #[unsafe(method(setFindBarView:))]
320        #[unsafe(method_family = none)]
321        unsafe fn setFindBarView(&self, find_bar_view: Option<&NSView>);
322
323        #[unsafe(method(isFindBarVisible))]
324        #[unsafe(method_family = none)]
325        unsafe fn isFindBarVisible(&self) -> bool;
326
327        /// Setter for [`isFindBarVisible`][Self::isFindBarVisible].
328        #[unsafe(method(setFindBarVisible:))]
329        #[unsafe(method_family = none)]
330        unsafe fn setFindBarVisible(&self, find_bar_visible: bool);
331
332        #[unsafe(method(findBarViewDidChangeHeight))]
333        #[unsafe(method_family = none)]
334        unsafe fn findBarViewDidChangeHeight(&self);
335
336        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
337        #[optional]
338        #[unsafe(method(contentView))]
339        #[unsafe(method_family = none)]
340        unsafe fn contentView(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
341    }
342);