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
97extern_conformance!(
98    unsafe impl NSCoding for NSTextFinder {}
99);
100
101extern_conformance!(
102    unsafe impl NSObjectProtocol for NSTextFinder {}
103);
104
105impl NSTextFinder {
106    extern_methods!(
107        #[unsafe(method(init))]
108        #[unsafe(method_family = init)]
109        pub fn init(this: Allocated<Self>) -> Retained<Self>;
110
111        /// # Safety
112        ///
113        /// `coder` possibly has further requirements.
114        #[unsafe(method(initWithCoder:))]
115        #[unsafe(method_family = init)]
116        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
117
118        /// # Safety
119        ///
120        /// This is not retained internally, you must ensure the object is still alive.
121        #[unsafe(method(client))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn client(&self) -> Option<Retained<ProtocolObject<dyn NSTextFinderClient>>>;
124
125        /// Setter for [`client`][Self::client].
126        ///
127        /// # Safety
128        ///
129        /// This is unretained, you must ensure the object is kept alive while in use.
130        #[unsafe(method(setClient:))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn setClient(&self, client: Option<&ProtocolObject<dyn NSTextFinderClient>>);
133
134        #[unsafe(method(performAction:))]
135        #[unsafe(method_family = none)]
136        pub fn performAction(&self, op: NSTextFinderAction);
137
138        #[unsafe(method(validateAction:))]
139        #[unsafe(method_family = none)]
140        pub fn validateAction(&self, op: NSTextFinderAction) -> bool;
141
142        /// # Safety
143        ///
144        /// This is not retained internally, you must ensure the object is still alive.
145        #[unsafe(method(findBarContainer))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn findBarContainer(
148            &self,
149        ) -> Option<Retained<ProtocolObject<dyn NSTextFinderBarContainer>>>;
150
151        /// Setter for [`findBarContainer`][Self::findBarContainer].
152        ///
153        /// # Safety
154        ///
155        /// This is unretained, you must ensure the object is kept alive while in use.
156        #[unsafe(method(setFindBarContainer:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn setFindBarContainer(
159            &self,
160            find_bar_container: Option<&ProtocolObject<dyn NSTextFinderBarContainer>>,
161        );
162
163        #[unsafe(method(cancelFindIndicator))]
164        #[unsafe(method_family = none)]
165        pub fn cancelFindIndicator(&self);
166
167        #[unsafe(method(findIndicatorNeedsUpdate))]
168        #[unsafe(method_family = none)]
169        pub fn findIndicatorNeedsUpdate(&self) -> bool;
170
171        /// Setter for [`findIndicatorNeedsUpdate`][Self::findIndicatorNeedsUpdate].
172        #[unsafe(method(setFindIndicatorNeedsUpdate:))]
173        #[unsafe(method_family = none)]
174        pub fn setFindIndicatorNeedsUpdate(&self, find_indicator_needs_update: bool);
175
176        #[unsafe(method(isIncrementalSearchingEnabled))]
177        #[unsafe(method_family = none)]
178        pub fn isIncrementalSearchingEnabled(&self) -> bool;
179
180        /// Setter for [`isIncrementalSearchingEnabled`][Self::isIncrementalSearchingEnabled].
181        #[unsafe(method(setIncrementalSearchingEnabled:))]
182        #[unsafe(method_family = none)]
183        pub fn setIncrementalSearchingEnabled(&self, incremental_searching_enabled: bool);
184
185        #[unsafe(method(incrementalSearchingShouldDimContentView))]
186        #[unsafe(method_family = none)]
187        pub fn incrementalSearchingShouldDimContentView(&self) -> bool;
188
189        /// Setter for [`incrementalSearchingShouldDimContentView`][Self::incrementalSearchingShouldDimContentView].
190        #[unsafe(method(setIncrementalSearchingShouldDimContentView:))]
191        #[unsafe(method_family = none)]
192        pub fn setIncrementalSearchingShouldDimContentView(
193            &self,
194            incremental_searching_should_dim_content_view: bool,
195        );
196
197        #[unsafe(method(incrementalMatchRanges))]
198        #[unsafe(method_family = none)]
199        pub fn incrementalMatchRanges(&self) -> Retained<NSArray<NSValue>>;
200
201        #[unsafe(method(drawIncrementalMatchHighlightInRect:))]
202        #[unsafe(method_family = none)]
203        pub fn drawIncrementalMatchHighlightInRect(rect: NSRect);
204
205        #[unsafe(method(noteClientStringWillChange))]
206        #[unsafe(method_family = none)]
207        pub fn noteClientStringWillChange(&self);
208    );
209}
210
211/// Methods declared on superclass `NSObject`.
212impl NSTextFinder {
213    extern_methods!(
214        #[unsafe(method(new))]
215        #[unsafe(method_family = new)]
216        pub fn new() -> Retained<Self>;
217    );
218}
219
220impl DefaultRetained for NSTextFinder {
221    #[inline]
222    fn default_retained() -> Retained<Self> {
223        Self::new()
224    }
225}
226
227extern_protocol!(
228    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfinderclient?language=objc)
229    pub unsafe trait NSTextFinderClient: NSObjectProtocol {
230        #[optional]
231        #[unsafe(method(isSelectable))]
232        #[unsafe(method_family = none)]
233        fn isSelectable(&self) -> bool;
234
235        #[optional]
236        #[unsafe(method(allowsMultipleSelection))]
237        #[unsafe(method_family = none)]
238        fn allowsMultipleSelection(&self) -> bool;
239
240        #[optional]
241        #[unsafe(method(isEditable))]
242        #[unsafe(method_family = none)]
243        fn isEditable(&self) -> bool;
244
245        #[optional]
246        #[unsafe(method(string))]
247        #[unsafe(method_family = none)]
248        fn string(&self) -> Retained<NSString>;
249
250        /// # Safety
251        ///
252        /// - `out_range` must be a valid pointer.
253        /// - `out_flag` must be a valid pointer.
254        #[optional]
255        #[unsafe(method(stringAtIndex:effectiveRange:endsWithSearchBoundary:))]
256        #[unsafe(method_family = none)]
257        unsafe fn stringAtIndex_effectiveRange_endsWithSearchBoundary(
258            &self,
259            character_index: NSUInteger,
260            out_range: NSRangePointer,
261            out_flag: NonNull<Bool>,
262        ) -> Retained<NSString>;
263
264        #[optional]
265        #[unsafe(method(stringLength))]
266        #[unsafe(method_family = none)]
267        fn stringLength(&self) -> NSUInteger;
268
269        #[optional]
270        #[unsafe(method(firstSelectedRange))]
271        #[unsafe(method_family = none)]
272        fn firstSelectedRange(&self) -> NSRange;
273
274        #[optional]
275        #[unsafe(method(selectedRanges))]
276        #[unsafe(method_family = none)]
277        fn selectedRanges(&self) -> Retained<NSArray<NSValue>>;
278
279        /// Setter for [`selectedRanges`][Self::selectedRanges].
280        ///
281        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
282        #[optional]
283        #[unsafe(method(setSelectedRanges:))]
284        #[unsafe(method_family = none)]
285        fn setSelectedRanges(&self, selected_ranges: &NSArray<NSValue>);
286
287        #[optional]
288        #[unsafe(method(scrollRangeToVisible:))]
289        #[unsafe(method_family = none)]
290        fn scrollRangeToVisible(&self, range: NSRange);
291
292        #[optional]
293        #[unsafe(method(shouldReplaceCharactersInRanges:withStrings:))]
294        #[unsafe(method_family = none)]
295        fn shouldReplaceCharactersInRanges_withStrings(
296            &self,
297            ranges: &NSArray<NSValue>,
298            strings: &NSArray<NSString>,
299        ) -> bool;
300
301        #[optional]
302        #[unsafe(method(replaceCharactersInRange:withString:))]
303        #[unsafe(method_family = none)]
304        fn replaceCharactersInRange_withString(&self, range: NSRange, string: &NSString);
305
306        #[optional]
307        #[unsafe(method(didReplaceCharacters))]
308        #[unsafe(method_family = none)]
309        fn didReplaceCharacters(&self);
310
311        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
312        /// # Safety
313        ///
314        /// `out_range` must be a valid pointer.
315        #[optional]
316        #[unsafe(method(contentViewAtIndex:effectiveCharacterRange:))]
317        #[unsafe(method_family = none)]
318        unsafe fn contentViewAtIndex_effectiveCharacterRange(
319            &self,
320            index: NSUInteger,
321            out_range: NSRangePointer,
322            mtm: MainThreadMarker,
323        ) -> Retained<NSView>;
324
325        #[optional]
326        #[unsafe(method(rectsForCharacterRange:))]
327        #[unsafe(method_family = none)]
328        fn rectsForCharacterRange(&self, range: NSRange) -> Option<Retained<NSArray<NSValue>>>;
329
330        #[optional]
331        #[unsafe(method(visibleCharacterRanges))]
332        #[unsafe(method_family = none)]
333        fn visibleCharacterRanges(&self) -> Retained<NSArray<NSValue>>;
334
335        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
336        #[optional]
337        #[unsafe(method(drawCharactersInRange:forContentView:))]
338        #[unsafe(method_family = none)]
339        fn drawCharactersInRange_forContentView(&self, range: NSRange, view: &NSView);
340    }
341);
342
343extern_protocol!(
344    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextfinderbarcontainer?language=objc)
345    pub unsafe trait NSTextFinderBarContainer: NSObjectProtocol {
346        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
347        #[unsafe(method(findBarView))]
348        #[unsafe(method_family = none)]
349        fn findBarView(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
350
351        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
352        /// Setter for [`findBarView`][Self::findBarView].
353        #[unsafe(method(setFindBarView:))]
354        #[unsafe(method_family = none)]
355        fn setFindBarView(&self, find_bar_view: Option<&NSView>);
356
357        #[unsafe(method(isFindBarVisible))]
358        #[unsafe(method_family = none)]
359        fn isFindBarVisible(&self) -> bool;
360
361        /// Setter for [`isFindBarVisible`][Self::isFindBarVisible].
362        #[unsafe(method(setFindBarVisible:))]
363        #[unsafe(method_family = none)]
364        fn setFindBarVisible(&self, find_bar_visible: bool);
365
366        #[unsafe(method(findBarViewDidChangeHeight))]
367        #[unsafe(method_family = none)]
368        fn findBarViewDidChangeHeight(&self);
369
370        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
371        #[optional]
372        #[unsafe(method(contentView))]
373        #[unsafe(method_family = none)]
374        fn contentView(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
375    }
376);