objc2_app_kit/generated/
NSTextSelectionNavigation.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextselectionnavigationdirection?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSTextSelectionNavigationDirection(pub NSInteger);
17impl NSTextSelectionNavigationDirection {
18    #[doc(alias = "NSTextSelectionNavigationDirectionForward")]
19    pub const Forward: Self = Self(0);
20    #[doc(alias = "NSTextSelectionNavigationDirectionBackward")]
21    pub const Backward: Self = Self(1);
22    #[doc(alias = "NSTextSelectionNavigationDirectionRight")]
23    pub const Right: Self = Self(2);
24    #[doc(alias = "NSTextSelectionNavigationDirectionLeft")]
25    pub const Left: Self = Self(3);
26    #[doc(alias = "NSTextSelectionNavigationDirectionUp")]
27    pub const Up: Self = Self(4);
28    #[doc(alias = "NSTextSelectionNavigationDirectionDown")]
29    pub const Down: Self = Self(5);
30}
31
32unsafe impl Encode for NSTextSelectionNavigationDirection {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for NSTextSelectionNavigationDirection {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextselectionnavigationdestination?language=objc)
41// NS_ENUM
42#[repr(transparent)]
43#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
44pub struct NSTextSelectionNavigationDestination(pub NSInteger);
45impl NSTextSelectionNavigationDestination {
46    #[doc(alias = "NSTextSelectionNavigationDestinationCharacter")]
47    pub const Character: Self = Self(0);
48    #[doc(alias = "NSTextSelectionNavigationDestinationWord")]
49    pub const Word: Self = Self(1);
50    #[doc(alias = "NSTextSelectionNavigationDestinationLine")]
51    pub const Line: Self = Self(2);
52    #[doc(alias = "NSTextSelectionNavigationDestinationSentence")]
53    pub const Sentence: Self = Self(3);
54    #[doc(alias = "NSTextSelectionNavigationDestinationParagraph")]
55    pub const Paragraph: Self = Self(4);
56    #[doc(alias = "NSTextSelectionNavigationDestinationContainer")]
57    pub const Container: Self = Self(5);
58    #[doc(alias = "NSTextSelectionNavigationDestinationDocument")]
59    pub const Document: Self = Self(6);
60}
61
62unsafe impl Encode for NSTextSelectionNavigationDestination {
63    const ENCODING: Encoding = NSInteger::ENCODING;
64}
65
66unsafe impl RefEncode for NSTextSelectionNavigationDestination {
67    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
68}
69
70/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextselectionnavigationmodifier?language=objc)
71// NS_OPTIONS
72#[repr(transparent)]
73#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
74pub struct NSTextSelectionNavigationModifier(pub NSUInteger);
75bitflags::bitflags! {
76    impl NSTextSelectionNavigationModifier: NSUInteger {
77        #[doc(alias = "NSTextSelectionNavigationModifierExtend")]
78        const Extend = 1<<0;
79        #[doc(alias = "NSTextSelectionNavigationModifierVisual")]
80        const Visual = 1<<1;
81        #[doc(alias = "NSTextSelectionNavigationModifierMultiple")]
82        const Multiple = 1<<2;
83    }
84}
85
86unsafe impl Encode for NSTextSelectionNavigationModifier {
87    const ENCODING: Encoding = NSUInteger::ENCODING;
88}
89
90unsafe impl RefEncode for NSTextSelectionNavigationModifier {
91    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
92}
93
94/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextselectionnavigationwritingdirection?language=objc)
95// NS_ENUM
96#[repr(transparent)]
97#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
98pub struct NSTextSelectionNavigationWritingDirection(pub NSInteger);
99impl NSTextSelectionNavigationWritingDirection {
100    #[doc(alias = "NSTextSelectionNavigationWritingDirectionLeftToRight")]
101    pub const LeftToRight: Self = Self(0);
102    #[doc(alias = "NSTextSelectionNavigationWritingDirectionRightToLeft")]
103    pub const RightToLeft: Self = Self(1);
104}
105
106unsafe impl Encode for NSTextSelectionNavigationWritingDirection {
107    const ENCODING: Encoding = NSInteger::ENCODING;
108}
109
110unsafe impl RefEncode for NSTextSelectionNavigationWritingDirection {
111    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
112}
113
114/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextselectionnavigationlayoutorientation?language=objc)
115// NS_ENUM
116#[repr(transparent)]
117#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
118pub struct NSTextSelectionNavigationLayoutOrientation(pub NSInteger);
119impl NSTextSelectionNavigationLayoutOrientation {
120    #[doc(alias = "NSTextSelectionNavigationLayoutOrientationHorizontal")]
121    pub const Horizontal: Self = Self(0);
122    #[doc(alias = "NSTextSelectionNavigationLayoutOrientationVertical")]
123    pub const Vertical: Self = Self(1);
124}
125
126unsafe impl Encode for NSTextSelectionNavigationLayoutOrientation {
127    const ENCODING: Encoding = NSInteger::ENCODING;
128}
129
130unsafe impl RefEncode for NSTextSelectionNavigationLayoutOrientation {
131    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
132}
133
134extern_class!(
135    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextselectionnavigation?language=objc)
136    #[unsafe(super(NSObject))]
137    #[derive(Debug, PartialEq, Eq, Hash)]
138    pub struct NSTextSelectionNavigation;
139);
140
141unsafe impl NSObjectProtocol for NSTextSelectionNavigation {}
142
143impl NSTextSelectionNavigation {
144    extern_methods!(
145        #[unsafe(method(initWithDataSource:))]
146        #[unsafe(method_family = init)]
147        pub unsafe fn initWithDataSource(
148            this: Allocated<Self>,
149            data_source: &ProtocolObject<dyn NSTextSelectionDataSource>,
150        ) -> Retained<Self>;
151
152        #[unsafe(method(new))]
153        #[unsafe(method_family = new)]
154        pub unsafe fn new() -> Retained<Self>;
155
156        #[unsafe(method(init))]
157        #[unsafe(method_family = init)]
158        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
159
160        #[unsafe(method(textSelectionDataSource))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn textSelectionDataSource(
163            &self,
164        ) -> Option<Retained<ProtocolObject<dyn NSTextSelectionDataSource>>>;
165
166        #[unsafe(method(allowsNonContiguousRanges))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn allowsNonContiguousRanges(&self) -> bool;
169
170        /// Setter for [`allowsNonContiguousRanges`][Self::allowsNonContiguousRanges].
171        #[unsafe(method(setAllowsNonContiguousRanges:))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn setAllowsNonContiguousRanges(&self, allows_non_contiguous_ranges: bool);
174
175        #[unsafe(method(rotatesCoordinateSystemForLayoutOrientation))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn rotatesCoordinateSystemForLayoutOrientation(&self) -> bool;
178
179        /// Setter for [`rotatesCoordinateSystemForLayoutOrientation`][Self::rotatesCoordinateSystemForLayoutOrientation].
180        #[unsafe(method(setRotatesCoordinateSystemForLayoutOrientation:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn setRotatesCoordinateSystemForLayoutOrientation(
183            &self,
184            rotates_coordinate_system_for_layout_orientation: bool,
185        );
186
187        #[unsafe(method(flushLayoutCache))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn flushLayoutCache(&self);
190
191        #[cfg(feature = "NSTextSelection")]
192        #[unsafe(method(destinationSelectionForTextSelection:direction:destination:extending:confined:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn destinationSelectionForTextSelection_direction_destination_extending_confined(
195            &self,
196            text_selection: &NSTextSelection,
197            direction: NSTextSelectionNavigationDirection,
198            destination: NSTextSelectionNavigationDestination,
199            extending: bool,
200            confined: bool,
201        ) -> Option<Retained<NSTextSelection>>;
202
203        #[cfg(all(
204            feature = "NSTextRange",
205            feature = "NSTextSelection",
206            feature = "objc2-core-foundation"
207        ))]
208        #[unsafe(method(textSelectionsInteractingAtPoint:inContainerAtLocation:anchors:modifiers:selecting:bounds:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn textSelectionsInteractingAtPoint_inContainerAtLocation_anchors_modifiers_selecting_bounds(
211            &self,
212            point: CGPoint,
213            container_location: &ProtocolObject<dyn NSTextLocation>,
214            anchors: &NSArray<NSTextSelection>,
215            modifiers: NSTextSelectionNavigationModifier,
216            selecting: bool,
217            bounds: CGRect,
218        ) -> Retained<NSArray<NSTextSelection>>;
219
220        #[cfg(feature = "NSTextSelection")]
221        #[unsafe(method(textSelectionForSelectionGranularity:enclosingTextSelection:))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn textSelectionForSelectionGranularity_enclosingTextSelection(
224            &self,
225            selection_granularity: NSTextSelectionGranularity,
226            text_selection: &NSTextSelection,
227        ) -> Retained<NSTextSelection>;
228
229        #[cfg(all(
230            feature = "NSTextRange",
231            feature = "NSTextSelection",
232            feature = "objc2-core-foundation"
233        ))]
234        #[unsafe(method(textSelectionForSelectionGranularity:enclosingPoint:inContainerAtLocation:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn textSelectionForSelectionGranularity_enclosingPoint_inContainerAtLocation(
237            &self,
238            selection_granularity: NSTextSelectionGranularity,
239            point: CGPoint,
240            location: &ProtocolObject<dyn NSTextLocation>,
241        ) -> Option<Retained<NSTextSelection>>;
242
243        #[cfg(all(feature = "NSTextRange", feature = "NSTextSelection"))]
244        #[unsafe(method(resolvedInsertionLocationForTextSelection:writingDirection:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn resolvedInsertionLocationForTextSelection_writingDirection(
247            &self,
248            text_selection: &NSTextSelection,
249            writing_direction: NSTextSelectionNavigationWritingDirection,
250        ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
251
252        #[cfg(all(feature = "NSTextRange", feature = "NSTextSelection"))]
253        #[unsafe(method(deletionRangesForTextSelection:direction:destination:allowsDecomposition:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn deletionRangesForTextSelection_direction_destination_allowsDecomposition(
256            &self,
257            text_selection: &NSTextSelection,
258            direction: NSTextSelectionNavigationDirection,
259            destination: NSTextSelectionNavigationDestination,
260            allows_decomposition: bool,
261        ) -> Retained<NSArray<NSTextRange>>;
262    );
263}
264
265extern_protocol!(
266    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextselectiondatasource?language=objc)
267    pub unsafe trait NSTextSelectionDataSource: NSObjectProtocol {
268        #[cfg(feature = "NSTextRange")]
269        #[unsafe(method(documentRange))]
270        #[unsafe(method_family = none)]
271        unsafe fn documentRange(&self) -> Retained<NSTextRange>;
272
273        #[cfg(all(feature = "NSTextRange", feature = "block2"))]
274        #[unsafe(method(enumerateSubstringsFromLocation:options:usingBlock:))]
275        #[unsafe(method_family = none)]
276        unsafe fn enumerateSubstringsFromLocation_options_usingBlock(
277            &self,
278            location: &ProtocolObject<dyn NSTextLocation>,
279            options: NSStringEnumerationOptions,
280            block: &block2::Block<
281                dyn Fn(*mut NSString, NonNull<NSTextRange>, *mut NSTextRange, NonNull<Bool>) + '_,
282            >,
283        );
284
285        #[cfg(all(feature = "NSTextRange", feature = "NSTextSelection"))]
286        #[unsafe(method(textRangeForSelectionGranularity:enclosingLocation:))]
287        #[unsafe(method_family = none)]
288        unsafe fn textRangeForSelectionGranularity_enclosingLocation(
289            &self,
290            selection_granularity: NSTextSelectionGranularity,
291            location: &ProtocolObject<dyn NSTextLocation>,
292        ) -> Option<Retained<NSTextRange>>;
293
294        #[cfg(feature = "NSTextRange")]
295        #[unsafe(method(locationFromLocation:withOffset:))]
296        #[unsafe(method_family = none)]
297        unsafe fn locationFromLocation_withOffset(
298            &self,
299            location: &ProtocolObject<dyn NSTextLocation>,
300            offset: NSInteger,
301        ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
302
303        #[cfg(feature = "NSTextRange")]
304        #[unsafe(method(offsetFromLocation:toLocation:))]
305        #[unsafe(method_family = none)]
306        unsafe fn offsetFromLocation_toLocation(
307            &self,
308            from: &ProtocolObject<dyn NSTextLocation>,
309            to: &ProtocolObject<dyn NSTextLocation>,
310        ) -> NSInteger;
311
312        #[cfg(feature = "NSTextRange")]
313        #[unsafe(method(baseWritingDirectionAtLocation:))]
314        #[unsafe(method_family = none)]
315        unsafe fn baseWritingDirectionAtLocation(
316            &self,
317            location: &ProtocolObject<dyn NSTextLocation>,
318        ) -> NSTextSelectionNavigationWritingDirection;
319
320        #[cfg(all(
321            feature = "NSTextRange",
322            feature = "block2",
323            feature = "objc2-core-foundation"
324        ))]
325        #[unsafe(method(enumerateCaretOffsetsInLineFragmentAtLocation:usingBlock:))]
326        #[unsafe(method_family = none)]
327        unsafe fn enumerateCaretOffsetsInLineFragmentAtLocation_usingBlock(
328            &self,
329            location: &ProtocolObject<dyn NSTextLocation>,
330            block: &block2::Block<
331                dyn Fn(CGFloat, NonNull<ProtocolObject<dyn NSTextLocation>>, Bool, NonNull<Bool>)
332                    + '_,
333            >,
334        );
335
336        #[cfg(all(feature = "NSTextRange", feature = "objc2-core-foundation"))]
337        #[unsafe(method(lineFragmentRangeForPoint:inContainerAtLocation:))]
338        #[unsafe(method_family = none)]
339        unsafe fn lineFragmentRangeForPoint_inContainerAtLocation(
340            &self,
341            point: CGPoint,
342            location: &ProtocolObject<dyn NSTextLocation>,
343        ) -> Option<Retained<NSTextRange>>;
344
345        #[cfg(all(feature = "NSTextRange", feature = "block2"))]
346        #[optional]
347        #[unsafe(method(enumerateContainerBoundariesFromLocation:reverse:usingBlock:))]
348        #[unsafe(method_family = none)]
349        unsafe fn enumerateContainerBoundariesFromLocation_reverse_usingBlock(
350            &self,
351            location: &ProtocolObject<dyn NSTextLocation>,
352            reverse: bool,
353            block: &block2::Block<
354                dyn Fn(NonNull<ProtocolObject<dyn NSTextLocation>>, NonNull<Bool>) + '_,
355            >,
356        );
357
358        #[cfg(feature = "NSTextRange")]
359        #[optional]
360        #[unsafe(method(textLayoutOrientationAtLocation:))]
361        #[unsafe(method_family = none)]
362        unsafe fn textLayoutOrientationAtLocation(
363            &self,
364            location: &ProtocolObject<dyn NSTextLocation>,
365        ) -> NSTextSelectionNavigationLayoutOrientation;
366    }
367);