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