1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

pub type UITextSearchDocumentIdentifier = TodoProtocols;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITextSearchFoundTextStyle(pub NSInteger);
impl UITextSearchFoundTextStyle {
    #[doc(alias = "UITextSearchFoundTextStyleNormal")]
    pub const Normal: Self = Self(0);
    #[doc(alias = "UITextSearchFoundTextStyleFound")]
    pub const Found: Self = Self(1);
    #[doc(alias = "UITextSearchFoundTextStyleHighlighted")]
    pub const Highlighted: Self = Self(2);
}

unsafe impl Encode for UITextSearchFoundTextStyle {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UITextSearchFoundTextStyle {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    pub unsafe trait UITextSearchAggregator: NSObjectProtocol + IsMainThreadOnly {
        #[cfg(feature = "UITextInput")]
        #[method_id(@__retain_semantics Other allFoundRanges)]
        unsafe fn allFoundRanges(&self) -> Retained<NSOrderedSet<UITextRange>>;

        #[cfg(feature = "UITextInput")]
        #[method(foundRange:forSearchString:inDocument:)]
        unsafe fn foundRange_forSearchString_inDocument(
            &self,
            range: &UITextRange,
            string: &NSString,
            document: Option<&UITextSearchDocumentIdentifier>,
        );

        #[cfg(feature = "UITextInput")]
        #[method(invalidateFoundRange:inDocument:)]
        unsafe fn invalidateFoundRange_inDocument(
            &self,
            range: &UITextRange,
            document: Option<&UITextSearchDocumentIdentifier>,
        );

        #[method(invalidate)]
        unsafe fn invalidate(&self);

        #[method(finishedSearching)]
        unsafe fn finishedSearching(&self);
    }

    unsafe impl ProtocolType for dyn UITextSearchAggregator {}
);

extern_protocol!(
    pub unsafe trait UITextSearching: NSObjectProtocol + IsMainThreadOnly {
        #[cfg(feature = "UITextInput")]
        #[method_id(@__retain_semantics Other selectedTextRange)]
        unsafe fn selectedTextRange(&self) -> Option<Retained<UITextRange>>;

        #[cfg(feature = "UITextInput")]
        #[method(compareFoundRange:toRange:inDocument:)]
        unsafe fn compareFoundRange_toRange_inDocument(
            &self,
            found_range: &UITextRange,
            to_range: &UITextRange,
            document: Option<&UITextSearchDocumentIdentifier>,
        ) -> NSComparisonResult;

        #[cfg(feature = "UIFindSession")]
        #[method(performTextSearchWithQueryString:usingOptions:resultAggregator:)]
        unsafe fn performTextSearchWithQueryString_usingOptions_resultAggregator(
            &self,
            string: &NSString,
            options: &UITextSearchOptions,
            aggregator: &ProtocolObject<dyn UITextSearchAggregator>,
        );

        #[cfg(feature = "UITextInput")]
        #[method(decorateFoundTextRange:inDocument:usingStyle:)]
        unsafe fn decorateFoundTextRange_inDocument_usingStyle(
            &self,
            range: &UITextRange,
            document: Option<&UITextSearchDocumentIdentifier>,
            style: UITextSearchFoundTextStyle,
        );

        #[method(clearAllDecoratedFoundText)]
        unsafe fn clearAllDecoratedFoundText(&self);

        #[optional]
        #[method(supportsTextReplacement)]
        unsafe fn supportsTextReplacement(&self) -> bool;

        #[cfg(feature = "UITextInput")]
        #[optional]
        #[method(shouldReplaceFoundTextInRange:inDocument:withText:)]
        unsafe fn shouldReplaceFoundTextInRange_inDocument_withText(
            &self,
            range: &UITextRange,
            document: Option<&UITextSearchDocumentIdentifier>,
            replacement_text: &NSString,
        ) -> bool;

        #[cfg(feature = "UITextInput")]
        #[optional]
        #[method(replaceFoundTextInRange:inDocument:withText:)]
        unsafe fn replaceFoundTextInRange_inDocument_withText(
            &self,
            range: &UITextRange,
            document: Option<&UITextSearchDocumentIdentifier>,
            replacement_text: &NSString,
        );

        #[cfg(feature = "UIFindSession")]
        #[optional]
        #[method(replaceAllOccurrencesOfQueryString:usingOptions:withText:)]
        unsafe fn replaceAllOccurrencesOfQueryString_usingOptions_withText(
            &self,
            query_string: &NSString,
            options: &UITextSearchOptions,
            replacement_text: &NSString,
        );

        #[cfg(feature = "UITextInput")]
        #[optional]
        #[method(willHighlightFoundTextRange:inDocument:)]
        unsafe fn willHighlightFoundTextRange_inDocument(
            &self,
            range: &UITextRange,
            document: Option<&UITextSearchDocumentIdentifier>,
        );

        #[cfg(feature = "UITextInput")]
        #[optional]
        #[method(scrollRangeToVisible:inDocument:)]
        unsafe fn scrollRangeToVisible_inDocument(
            &self,
            range: &UITextRange,
            document: Option<&UITextSearchDocumentIdentifier>,
        );

        #[optional]
        #[method_id(@__retain_semantics Other selectedTextSearchDocument)]
        unsafe fn selectedTextSearchDocument(
            &self,
        ) -> Option<Retained<UITextSearchDocumentIdentifier>>;

        #[optional]
        #[method(compareOrderFromDocument:toDocument:)]
        unsafe fn compareOrderFromDocument_toDocument(
            &self,
            from_document: &UITextSearchDocumentIdentifier,
            to_document: &UITextSearchDocumentIdentifier,
        ) -> NSComparisonResult;
    }

    unsafe impl ProtocolType for dyn UITextSearching {}
);