objc2_app_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/appkit/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/appkit/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/appkit/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 fn initWithRanges_affinity_granularity(
83            this: Allocated<Self>,
84            text_ranges: &NSArray<NSTextRange>,
85            affinity: NSTextSelectionAffinity,
86            granularity: NSTextSelectionGranularity,
87        ) -> Retained<Self>;
88
89        /// # Safety
90        ///
91        /// `coder` possibly has further requirements.
92        #[unsafe(method(initWithCoder:))]
93        #[unsafe(method_family = init)]
94        pub unsafe fn initWithCoder(
95            this: Allocated<Self>,
96            coder: &NSCoder,
97        ) -> Option<Retained<Self>>;
98
99        #[cfg(feature = "NSTextRange")]
100        #[unsafe(method(initWithRange:affinity:granularity:))]
101        #[unsafe(method_family = init)]
102        pub fn initWithRange_affinity_granularity(
103            this: Allocated<Self>,
104            range: &NSTextRange,
105            affinity: NSTextSelectionAffinity,
106            granularity: NSTextSelectionGranularity,
107        ) -> Retained<Self>;
108
109        #[cfg(feature = "NSTextRange")]
110        #[unsafe(method(initWithLocation:affinity:))]
111        #[unsafe(method_family = init)]
112        pub fn initWithLocation_affinity(
113            this: Allocated<Self>,
114            location: &ProtocolObject<dyn NSTextLocation>,
115            affinity: NSTextSelectionAffinity,
116        ) -> Retained<Self>;
117
118        #[unsafe(method(init))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
121
122        #[cfg(feature = "NSTextRange")]
123        #[unsafe(method(textRanges))]
124        #[unsafe(method_family = none)]
125        pub fn textRanges(&self) -> Retained<NSArray<NSTextRange>>;
126
127        #[unsafe(method(granularity))]
128        #[unsafe(method_family = none)]
129        pub fn granularity(&self) -> NSTextSelectionGranularity;
130
131        #[unsafe(method(affinity))]
132        #[unsafe(method_family = none)]
133        pub fn affinity(&self) -> NSTextSelectionAffinity;
134
135        #[unsafe(method(isTransient))]
136        #[unsafe(method_family = none)]
137        pub fn isTransient(&self) -> bool;
138
139        #[cfg(feature = "objc2-core-foundation")]
140        #[unsafe(method(anchorPositionOffset))]
141        #[unsafe(method_family = none)]
142        pub fn anchorPositionOffset(&self) -> CGFloat;
143
144        #[cfg(feature = "objc2-core-foundation")]
145        /// Setter for [`anchorPositionOffset`][Self::anchorPositionOffset].
146        #[unsafe(method(setAnchorPositionOffset:))]
147        #[unsafe(method_family = none)]
148        pub fn setAnchorPositionOffset(&self, anchor_position_offset: CGFloat);
149
150        #[unsafe(method(isLogical))]
151        #[unsafe(method_family = none)]
152        pub fn isLogical(&self) -> bool;
153
154        /// Setter for [`isLogical`][Self::isLogical].
155        #[unsafe(method(setLogical:))]
156        #[unsafe(method_family = none)]
157        pub fn setLogical(&self, logical: bool);
158
159        #[cfg(feature = "NSTextRange")]
160        #[unsafe(method(secondarySelectionLocation))]
161        #[unsafe(method_family = none)]
162        pub fn secondarySelectionLocation(
163            &self,
164        ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
165
166        #[cfg(feature = "NSTextRange")]
167        /// Setter for [`secondarySelectionLocation`][Self::secondarySelectionLocation].
168        #[unsafe(method(setSecondarySelectionLocation:))]
169        #[unsafe(method_family = none)]
170        pub fn setSecondarySelectionLocation(
171            &self,
172            secondary_selection_location: Option<&ProtocolObject<dyn NSTextLocation>>,
173        );
174
175        #[unsafe(method(typingAttributes))]
176        #[unsafe(method_family = none)]
177        pub fn typingAttributes(&self) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
178
179        /// Setter for [`typingAttributes`][Self::typingAttributes].
180        ///
181        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
182        ///
183        /// # Safety
184        ///
185        /// `typing_attributes` generic should be of the correct type.
186        #[unsafe(method(setTypingAttributes:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn setTypingAttributes(
189            &self,
190            typing_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
191        );
192
193        #[cfg(feature = "NSTextRange")]
194        #[unsafe(method(textSelectionWithTextRanges:))]
195        #[unsafe(method_family = none)]
196        pub fn textSelectionWithTextRanges(
197            &self,
198            text_ranges: &NSArray<NSTextRange>,
199        ) -> Retained<NSTextSelection>;
200    );
201}
202
203/// Methods declared on superclass `NSObject`.
204impl NSTextSelection {
205    extern_methods!(
206        #[unsafe(method(new))]
207        #[unsafe(method_family = new)]
208        pub unsafe fn new() -> Retained<Self>;
209    );
210}