objc2_app_kit/generated/
NSTextSelection.rs1use 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#[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#[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 #[unsafe(super(NSObject))]
61 #[derive(Debug, PartialEq, Eq, Hash)]
62 pub struct NSTextSelection;
63);
64
65unsafe impl NSCoding for NSTextSelection {}
66
67unsafe impl NSObjectProtocol for NSTextSelection {}
68
69unsafe impl NSSecureCoding for NSTextSelection {}
70
71impl NSTextSelection {
72 extern_methods!(
73 #[cfg(feature = "NSTextRange")]
74 #[unsafe(method(initWithRanges:affinity:granularity:))]
75 #[unsafe(method_family = init)]
76 pub unsafe fn initWithRanges_affinity_granularity(
77 this: Allocated<Self>,
78 text_ranges: &NSArray<NSTextRange>,
79 affinity: NSTextSelectionAffinity,
80 granularity: NSTextSelectionGranularity,
81 ) -> Retained<Self>;
82
83 #[unsafe(method(initWithCoder:))]
84 #[unsafe(method_family = init)]
85 pub unsafe fn initWithCoder(
86 this: Allocated<Self>,
87 coder: &NSCoder,
88 ) -> Option<Retained<Self>>;
89
90 #[cfg(feature = "NSTextRange")]
91 #[unsafe(method(initWithRange:affinity:granularity:))]
92 #[unsafe(method_family = init)]
93 pub unsafe fn initWithRange_affinity_granularity(
94 this: Allocated<Self>,
95 range: &NSTextRange,
96 affinity: NSTextSelectionAffinity,
97 granularity: NSTextSelectionGranularity,
98 ) -> Retained<Self>;
99
100 #[cfg(feature = "NSTextRange")]
101 #[unsafe(method(initWithLocation:affinity:))]
102 #[unsafe(method_family = init)]
103 pub unsafe fn initWithLocation_affinity(
104 this: Allocated<Self>,
105 location: &ProtocolObject<dyn NSTextLocation>,
106 affinity: NSTextSelectionAffinity,
107 ) -> Retained<Self>;
108
109 #[unsafe(method(init))]
110 #[unsafe(method_family = init)]
111 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
112
113 #[cfg(feature = "NSTextRange")]
114 #[unsafe(method(textRanges))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn textRanges(&self) -> Retained<NSArray<NSTextRange>>;
117
118 #[unsafe(method(granularity))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn granularity(&self) -> NSTextSelectionGranularity;
121
122 #[unsafe(method(affinity))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn affinity(&self) -> NSTextSelectionAffinity;
125
126 #[unsafe(method(isTransient))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn isTransient(&self) -> bool;
129
130 #[cfg(feature = "objc2-core-foundation")]
131 #[unsafe(method(anchorPositionOffset))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn anchorPositionOffset(&self) -> CGFloat;
134
135 #[cfg(feature = "objc2-core-foundation")]
136 #[unsafe(method(setAnchorPositionOffset:))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn setAnchorPositionOffset(&self, anchor_position_offset: CGFloat);
140
141 #[unsafe(method(isLogical))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn isLogical(&self) -> bool;
144
145 #[unsafe(method(setLogical:))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn setLogical(&self, logical: bool);
149
150 #[cfg(feature = "NSTextRange")]
151 #[unsafe(method(secondarySelectionLocation))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn secondarySelectionLocation(
154 &self,
155 ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
156
157 #[cfg(feature = "NSTextRange")]
158 #[unsafe(method(setSecondarySelectionLocation:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn setSecondarySelectionLocation(
162 &self,
163 secondary_selection_location: Option<&ProtocolObject<dyn NSTextLocation>>,
164 );
165
166 #[unsafe(method(typingAttributes))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn typingAttributes(
169 &self,
170 ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
171
172 #[unsafe(method(setTypingAttributes:))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn setTypingAttributes(
176 &self,
177 typing_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
178 );
179
180 #[cfg(feature = "NSTextRange")]
181 #[unsafe(method(textSelectionWithTextRanges:))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn textSelectionWithTextRanges(
184 &self,
185 text_ranges: &NSArray<NSTextRange>,
186 ) -> Retained<NSTextSelection>;
187 );
188}
189
190impl NSTextSelection {
192 extern_methods!(
193 #[unsafe(method(new))]
194 #[unsafe(method_family = new)]
195 pub unsafe fn new() -> Retained<Self>;
196 );
197}