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