objc2_ui_kit/generated/
NSTextSelection.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/uikit/nstextselectiongranularity?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSTextSelectionGranularity(pub NSInteger);
17impl NSTextSelectionGranularity {
18    #[doc(alias = "NSTextSelectionGranularityCharacter")]
19    pub const Character: Self = Self(0);
20    #[doc(alias = "NSTextSelectionGranularityWord")]
21    pub const Word: Self = Self(1);
22    #[doc(alias = "NSTextSelectionGranularityParagraph")]
23    pub const Paragraph: Self = Self(2);
24    #[doc(alias = "NSTextSelectionGranularityLine")]
25    pub const Line: Self = Self(3);
26    #[doc(alias = "NSTextSelectionGranularitySentence")]
27    pub const Sentence: Self = Self(4);
28}
29
30unsafe impl Encode for NSTextSelectionGranularity {
31    const ENCODING: Encoding = NSInteger::ENCODING;
32}
33
34unsafe impl RefEncode for NSTextSelectionGranularity {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextselectionaffinity?language=objc)
39// NS_ENUM
40#[repr(transparent)]
41#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct NSTextSelectionAffinity(pub NSInteger);
43impl NSTextSelectionAffinity {
44    #[doc(alias = "NSTextSelectionAffinityUpstream")]
45    pub const Upstream: Self = Self(0);
46    #[doc(alias = "NSTextSelectionAffinityDownstream")]
47    pub const Downstream: Self = Self(1);
48}
49
50unsafe impl Encode for NSTextSelectionAffinity {
51    const ENCODING: Encoding = NSInteger::ENCODING;
52}
53
54unsafe impl RefEncode for NSTextSelectionAffinity {
55    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
56}
57
58extern_class!(
59    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextselection?language=objc)
60    #[unsafe(super(NSObject))]
61    #[derive(Debug, PartialEq, Eq, Hash)]
62    pub struct NSTextSelection;
63);
64
65extern_conformance!(
66    unsafe impl NSCoding for NSTextSelection {}
67);
68
69extern_conformance!(
70    unsafe impl NSObjectProtocol for NSTextSelection {}
71);
72
73extern_conformance!(
74    unsafe impl NSSecureCoding for NSTextSelection {}
75);
76
77impl NSTextSelection {
78    extern_methods!(
79        #[cfg(feature = "NSTextRange")]
80        #[unsafe(method(initWithRanges:affinity:granularity:))]
81        #[unsafe(method_family = init)]
82        pub unsafe fn initWithRanges_affinity_granularity(
83            this: Allocated<Self>,
84            text_ranges: &NSArray<NSTextRange>,
85            affinity: NSTextSelectionAffinity,
86            granularity: NSTextSelectionGranularity,
87        ) -> Retained<Self>;
88
89        #[unsafe(method(initWithCoder:))]
90        #[unsafe(method_family = init)]
91        pub unsafe fn initWithCoder(
92            this: Allocated<Self>,
93            coder: &NSCoder,
94        ) -> Option<Retained<Self>>;
95
96        #[cfg(feature = "NSTextRange")]
97        #[unsafe(method(initWithRange:affinity:granularity:))]
98        #[unsafe(method_family = init)]
99        pub unsafe fn initWithRange_affinity_granularity(
100            this: Allocated<Self>,
101            range: &NSTextRange,
102            affinity: NSTextSelectionAffinity,
103            granularity: NSTextSelectionGranularity,
104        ) -> Retained<Self>;
105
106        #[cfg(feature = "NSTextRange")]
107        #[unsafe(method(initWithLocation:affinity:))]
108        #[unsafe(method_family = init)]
109        pub unsafe fn initWithLocation_affinity(
110            this: Allocated<Self>,
111            location: &ProtocolObject<dyn NSTextLocation>,
112            affinity: NSTextSelectionAffinity,
113        ) -> Retained<Self>;
114
115        #[unsafe(method(init))]
116        #[unsafe(method_family = init)]
117        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
118
119        #[cfg(feature = "NSTextRange")]
120        #[unsafe(method(textRanges))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn textRanges(&self) -> Retained<NSArray<NSTextRange>>;
123
124        #[unsafe(method(granularity))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn granularity(&self) -> NSTextSelectionGranularity;
127
128        #[unsafe(method(affinity))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn affinity(&self) -> NSTextSelectionAffinity;
131
132        #[unsafe(method(isTransient))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn isTransient(&self) -> bool;
135
136        #[cfg(feature = "objc2-core-foundation")]
137        #[unsafe(method(anchorPositionOffset))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn anchorPositionOffset(&self) -> CGFloat;
140
141        #[cfg(feature = "objc2-core-foundation")]
142        /// Setter for [`anchorPositionOffset`][Self::anchorPositionOffset].
143        #[unsafe(method(setAnchorPositionOffset:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn setAnchorPositionOffset(&self, anchor_position_offset: CGFloat);
146
147        #[unsafe(method(isLogical))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn isLogical(&self) -> bool;
150
151        /// Setter for [`isLogical`][Self::isLogical].
152        #[unsafe(method(setLogical:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn setLogical(&self, logical: bool);
155
156        #[cfg(feature = "NSTextRange")]
157        #[unsafe(method(secondarySelectionLocation))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn secondarySelectionLocation(
160            &self,
161        ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
162
163        #[cfg(feature = "NSTextRange")]
164        /// Setter for [`secondarySelectionLocation`][Self::secondarySelectionLocation].
165        #[unsafe(method(setSecondarySelectionLocation:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn setSecondarySelectionLocation(
168            &self,
169            secondary_selection_location: Option<&ProtocolObject<dyn NSTextLocation>>,
170        );
171
172        #[unsafe(method(typingAttributes))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn typingAttributes(
175            &self,
176        ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
177
178        /// Setter for [`typingAttributes`][Self::typingAttributes].
179        #[unsafe(method(setTypingAttributes:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setTypingAttributes(
182            &self,
183            typing_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
184        );
185
186        #[cfg(feature = "NSTextRange")]
187        #[unsafe(method(textSelectionWithTextRanges:))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn textSelectionWithTextRanges(
190            &self,
191            text_ranges: &NSArray<NSTextRange>,
192        ) -> Retained<NSTextSelection>;
193    );
194}
195
196/// Methods declared on superclass `NSObject`.
197impl NSTextSelection {
198    extern_methods!(
199        #[unsafe(method(new))]
200        #[unsafe(method_family = new)]
201        pub unsafe fn new() -> Retained<Self>;
202    );
203}