objc2_ui_kit/generated/
UIFindSession.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/uikit/uifindsessionsearchresultdisplaystyle?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UIFindSessionSearchResultDisplayStyle(pub NSInteger);
15impl UIFindSessionSearchResultDisplayStyle {
16    /// Displays the total number of reported results, and which result index is currently highlighted (i.e., "1 of 5").
17    #[doc(alias = "UIFindSessionSearchResultDisplayStyleCurrentAndTotal")]
18    pub const CurrentAndTotal: Self = Self(0);
19    /// Displays only the total number of reported results (i.e., "5 results").
20    #[doc(alias = "UIFindSessionSearchResultDisplayStyleTotal")]
21    pub const Total: Self = Self(1);
22    /// Do not display number of reported results.
23    #[doc(alias = "UIFindSessionSearchResultDisplayStyleNone")]
24    pub const None: Self = Self(2);
25}
26
27unsafe impl Encode for UIFindSessionSearchResultDisplayStyle {
28    const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for UIFindSessionSearchResultDisplayStyle {
32    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextsearchmatchmethod?language=objc)
36// NS_ENUM
37#[repr(transparent)]
38#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
39pub struct UITextSearchMatchMethod(pub NSInteger);
40impl UITextSearchMatchMethod {
41    /// Word contains search string.
42    #[doc(alias = "UITextSearchMatchMethodContains")]
43    pub const Contains: Self = Self(0);
44    /// Word contains the search string as a prefix.
45    #[doc(alias = "UITextSearchMatchMethodStartsWith")]
46    pub const StartsWith: Self = Self(1);
47    /// Word is an exact match for the search string.
48    #[doc(alias = "UITextSearchMatchMethodFullWord")]
49    pub const FullWord: Self = Self(2);
50}
51
52unsafe impl Encode for UITextSearchMatchMethod {
53    const ENCODING: Encoding = NSInteger::ENCODING;
54}
55
56unsafe impl RefEncode for UITextSearchMatchMethod {
57    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
58}
59
60extern_class!(
61    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextsearchoptions?language=objc)
62    #[unsafe(super(NSObject))]
63    #[thread_kind = MainThreadOnly]
64    #[derive(Debug, PartialEq, Eq, Hash)]
65    pub struct UITextSearchOptions;
66);
67
68extern_conformance!(
69    unsafe impl NSObjectProtocol for UITextSearchOptions {}
70);
71
72impl UITextSearchOptions {
73    extern_methods!(
74        /// See UITextSearchMatchMethod above.
75        #[unsafe(method(wordMatchMethod))]
76        #[unsafe(method_family = none)]
77        pub fn wordMatchMethod(&self) -> UITextSearchMatchMethod;
78
79        /// Comparison options to use when searching for strings.
80        #[unsafe(method(stringCompareOptions))]
81        #[unsafe(method_family = none)]
82        pub fn stringCompareOptions(&self) -> NSStringCompareOptions;
83    );
84}
85
86/// Methods declared on superclass `NSObject`.
87impl UITextSearchOptions {
88    extern_methods!(
89        #[unsafe(method(init))]
90        #[unsafe(method_family = init)]
91        pub fn init(this: Allocated<Self>) -> Retained<Self>;
92
93        #[unsafe(method(new))]
94        #[unsafe(method_family = new)]
95        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
96    );
97}
98
99extern_class!(
100    /// An abstract base class for managing a find session.
101    ///
102    /// A UIFindSession instance is returned by UIFindInteractionDelegate when a find session is initiated
103    /// by the user. You can choose to implement a subclass of UIFindSession to handle all state, decoration,
104    /// and behavior yourself. This would be the preferred choice if the view your find interaction is attached to
105    /// is very custom in the way it handles the presentation of found results. Other clients are encouraged to
106    /// instead use UISearchableObjectFindSession and the UITextSearching protocol, which manages the
107    /// state of a find session automatically using behavior consistent with the rest of the system.
108    ///
109    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uifindsession?language=objc)
110    #[unsafe(super(NSObject))]
111    #[thread_kind = MainThreadOnly]
112    #[derive(Debug, PartialEq, Eq, Hash)]
113    pub struct UIFindSession;
114);
115
116extern_conformance!(
117    unsafe impl NSObjectProtocol for UIFindSession {}
118);
119
120impl UIFindSession {
121    extern_methods!(
122        /// Returns the total number of results.
123        /// You may call UIFindInteraction's
124        /// `updateResultCount`to update the system find panel's UI if already visible.
125        #[unsafe(method(resultCount))]
126        #[unsafe(method_family = none)]
127        pub fn resultCount(&self) -> NSInteger;
128
129        /// Returns the index of the currently highlighted result, out of
130        /// `resultCount.`If no result is currently highlighted, return NSNotFound.
131        /// You may call UIFindInteraction's
132        /// `updateResultCount`to update the system find panel's UI if already visible.
133        #[unsafe(method(highlightedResultIndex))]
134        #[unsafe(method_family = none)]
135        pub fn highlightedResultIndex(&self) -> NSInteger;
136
137        /// Defines how results are reported through the find panel's UI. The default style is
138        /// `CurrentAndTotal.`
139        #[unsafe(method(searchResultDisplayStyle))]
140        #[unsafe(method_family = none)]
141        pub fn searchResultDisplayStyle(&self) -> UIFindSessionSearchResultDisplayStyle;
142
143        /// Setter for [`searchResultDisplayStyle`][Self::searchResultDisplayStyle].
144        #[unsafe(method(setSearchResultDisplayStyle:))]
145        #[unsafe(method_family = none)]
146        pub fn setSearchResultDisplayStyle(
147            &self,
148            search_result_display_style: UIFindSessionSearchResultDisplayStyle,
149        );
150
151        /// Return YES if replacement is supported. This gates the appearance of replace UI in the find navigator panel. Default is NO.
152        #[unsafe(method(supportsReplacement))]
153        #[unsafe(method_family = none)]
154        pub fn supportsReplacement(&self) -> bool;
155
156        /// Return YES if replacement is allowed for the currently highlighted item. This property controls the enabled state
157        /// of the "replace" button in the find navigator, as well as various hardware keyboard shortcuts involving replacement.
158        /// Default is YES, if supportsReplacement is YES.
159        #[unsafe(method(allowsReplacementForCurrentlyHighlightedResult))]
160        #[unsafe(method_family = none)]
161        pub fn allowsReplacementForCurrentlyHighlightedResult(&self) -> bool;
162
163        /// Called when the user requests a search to be performed for
164        /// `query,`using
165        /// `options.`
166        ///
167        /// Parameter `query`: The search string entered into the search text field in the system find panel.
168        ///
169        /// Parameter `options`: Object representing all configured search options for this search.
170        #[unsafe(method(performSearchWithQuery:options:))]
171        #[unsafe(method_family = none)]
172        pub fn performSearchWithQuery_options(
173            &self,
174            query: &NSString,
175            options: Option<&UITextSearchOptions>,
176        );
177
178        /// Called when the user requests a single replacement to occur given
179        /// `searchQuery`and
180        /// `replacementString.`
181        ///
182        /// Parameter `searchQuery`: The search string entered into the search text field in the system find panel.
183        ///
184        /// Parameter `replacementString`: The replacement string entered into the replace text field in the system find panel.
185        ///
186        /// Parameter `options`: Object representing all configured search options for this replacement.
187        #[unsafe(method(performSingleReplacementWithSearchQuery:replacementString:options:))]
188        #[unsafe(method_family = none)]
189        pub fn performSingleReplacementWithSearchQuery_replacementString_options(
190            &self,
191            search_query: &NSString,
192            replacement_string: &NSString,
193            options: Option<&UITextSearchOptions>,
194        );
195
196        /// Called when the user requests a document-wide replacement to occur.
197        ///
198        ///
199        /// Parameter `searchQuery`: The search string entered into the search text field in the system find panel.
200        ///
201        /// Parameter `replacementString`: The replacement string entered into the replace text field in the system find panel.
202        ///
203        /// Parameter `options`: Object representing all configured search options for this replacement.
204        #[unsafe(method(replaceAllInstancesOfSearchQuery:withReplacementString:options:))]
205        #[unsafe(method_family = none)]
206        pub fn replaceAllInstancesOfSearchQuery_withReplacementString_options(
207            &self,
208            search_query: &NSString,
209            replacement_string: &NSString,
210            options: Option<&UITextSearchOptions>,
211        );
212
213        #[cfg(feature = "UITextInput")]
214        /// Called when either the next or previous button is activated, or when return or shift+return is pressed in the search field.
215        ///
216        ///
217        /// Parameter `direction`: Which direction the user intends to move, either forward or backward.
218        #[unsafe(method(highlightNextResultInDirection:))]
219        #[unsafe(method_family = none)]
220        pub fn highlightNextResultInDirection(&self, direction: UITextStorageDirection);
221
222        /// This method will be called whenever the current find session's found/highlighted results are to be invalidated. For instance,
223        /// when the search query is cleared, options changed, or any other event where we may not perform another search right away.
224        #[unsafe(method(invalidateFoundResults))]
225        #[unsafe(method_family = none)]
226        pub fn invalidateFoundResults(&self);
227
228        #[deprecated]
229        #[unsafe(method(allowsReplacement))]
230        #[unsafe(method_family = none)]
231        pub fn allowsReplacement(&self) -> bool;
232    );
233}
234
235/// Methods declared on superclass `NSObject`.
236impl UIFindSession {
237    extern_methods!(
238        #[unsafe(method(init))]
239        #[unsafe(method_family = init)]
240        pub fn init(this: Allocated<Self>) -> Retained<Self>;
241
242        #[unsafe(method(new))]
243        #[unsafe(method_family = new)]
244        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
245    );
246}
247
248extern_class!(
249    /// A
250    /// `UIFindSession`implementation for clients who adopt the
251    /// `UITextSearching`protocol.
252    ///
253    /// `UITextSearchingFindSession`is a concrete implementation of
254    /// `UIFindSession`which manages
255    /// all of the state associated with a find session (i.e., the way results are presented to the user, the
256    /// order in which they are cycled through, etc.). A
257    /// `UITextSearchingFindSession`would be ideal
258    /// for clients who already implement the
259    /// `UITextInput`protocol, since many of the concepts defined there are
260    /// compatible with this class.
261    ///
262    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextsearchingfindsession?language=objc)
263    #[unsafe(super(UIFindSession, NSObject))]
264    #[thread_kind = MainThreadOnly]
265    #[derive(Debug, PartialEq, Eq, Hash)]
266    pub struct UITextSearchingFindSession;
267);
268
269extern_conformance!(
270    unsafe impl NSObjectProtocol for UITextSearchingFindSession {}
271);
272
273impl UITextSearchingFindSession {
274    extern_methods!(
275        #[cfg(feature = "UITextSearching")]
276        /// The object responsible for actually performing the search operation and decorating found text results.
277        /// See `UITextSearching.h` for more information.
278        #[unsafe(method(searchableObject))]
279        #[unsafe(method_family = none)]
280        pub fn searchableObject(&self) -> Option<Retained<ProtocolObject<dyn UITextSearching>>>;
281
282        #[cfg(feature = "UITextSearching")]
283        #[unsafe(method(initWithSearchableObject:))]
284        #[unsafe(method_family = init)]
285        pub fn initWithSearchableObject(
286            this: Allocated<Self>,
287            searchable_object: &ProtocolObject<dyn UITextSearching>,
288        ) -> Retained<Self>;
289
290        #[unsafe(method(init))]
291        #[unsafe(method_family = init)]
292        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
293
294        #[unsafe(method(new))]
295        #[unsafe(method_family = new)]
296        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
297    );
298}