objc2_app_kit/generated/NSTextRange.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_protocol!(
10 /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextlocation?language=objc)
11 pub unsafe trait NSTextLocation: NSObjectProtocol {
12 #[unsafe(method(compare:))]
13 #[unsafe(method_family = none)]
14 fn compare(&self, location: &ProtocolObject<dyn NSTextLocation>) -> NSComparisonResult;
15 }
16);
17
18extern_class!(
19 /// A class that represents a contiguous range between two locations inside document contents.
20 ///
21 /// An `NSTextRange` consists of the starting and terminating locations. There
22 /// the two basic properties: ``location`` and ``endLocation``, respectively.
23 /// The terminating ``location``, ``endLocation``, is directly following the
24 /// last location in the range. For example, a location contains a range if
25 /// `(range.location
26 /// <
27 /// = location)
28 /// &
29 /// &
30 /// (location
31 /// <
32 /// range.endLocation)` is `true`.
33 ///
34 /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextrange?language=objc)
35 #[unsafe(super(NSObject))]
36 #[derive(Debug, PartialEq, Eq, Hash)]
37 pub struct NSTextRange;
38);
39
40extern_conformance!(
41 unsafe impl NSObjectProtocol for NSTextRange {}
42);
43
44impl NSTextRange {
45 extern_methods!(
46 /// Creates a new text range with the starting and ending locations you specify.
47 ///
48 /// - Parameters:
49 /// - location: The starting location.
50 /// - endLocation: The ending location.
51 #[unsafe(method(initWithLocation:endLocation:))]
52 #[unsafe(method_family = init)]
53 pub fn initWithLocation_endLocation(
54 this: Allocated<Self>,
55 location: &ProtocolObject<dyn NSTextLocation>,
56 end_location: Option<&ProtocolObject<dyn NSTextLocation>>,
57 ) -> Option<Retained<Self>>;
58
59 /// Creates a new text range at the location you specify.
60 ///
61 /// - Parameters:
62 /// - location: An ``NSTextLocation``.
63 #[unsafe(method(initWithLocation:))]
64 #[unsafe(method_family = init)]
65 pub fn initWithLocation(
66 this: Allocated<Self>,
67 location: &ProtocolObject<dyn NSTextLocation>,
68 ) -> Retained<Self>;
69
70 #[unsafe(method(init))]
71 #[unsafe(method_family = init)]
72 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
73
74 #[unsafe(method(new))]
75 #[unsafe(method_family = new)]
76 pub unsafe fn new() -> Retained<Self>;
77
78 /// Returns whether the text range is empty.
79 #[unsafe(method(isEmpty))]
80 #[unsafe(method_family = none)]
81 pub fn isEmpty(&self) -> bool;
82
83 /// The starting location of the text range.
84 #[unsafe(method(location))]
85 #[unsafe(method_family = none)]
86 pub fn location(&self) -> Retained<ProtocolObject<dyn NSTextLocation>>;
87
88 /// The ending location of the text range.
89 #[unsafe(method(endLocation))]
90 #[unsafe(method_family = none)]
91 pub fn endLocation(&self) -> Retained<ProtocolObject<dyn NSTextLocation>>;
92
93 /// Compares two text ranges.
94 ///
95 /// - Parameters:
96 /// - textRange: The range used to compare against the current range to evaluate for differences.
97 ///
98 /// - Returns: Returns `true` if the ranges are equal.
99 #[unsafe(method(isEqualToTextRange:))]
100 #[unsafe(method_family = none)]
101 pub fn isEqualToTextRange(&self, text_range: &NSTextRange) -> bool;
102
103 /// Determines if the text location you specify is in the current text range.
104 ///
105 /// - Parameters:
106 /// - location: An ``NSTextLocation``.
107 ///
108 /// - Returns: Returns `true` if the location is in the range otherwise `false` .
109 #[unsafe(method(containsLocation:))]
110 #[unsafe(method_family = none)]
111 pub fn containsLocation(&self, location: &ProtocolObject<dyn NSTextLocation>) -> bool;
112
113 /// Determines if the text range you specify is in the current text range.
114 ///
115 /// - Parameters:
116 /// - textRange: An ``NSTextRange``.
117 ///
118 /// - Returns: Returns `true` if the range you provide is in the current range; otherwise `false`.
119 #[unsafe(method(containsRange:))]
120 #[unsafe(method_family = none)]
121 pub fn containsRange(&self, text_range: &NSTextRange) -> bool;
122
123 /// Determines if two ranges intersect.
124 ///
125 /// - Parameters:
126 /// - textRange: The range used to compare against the current range to evaluate for differences.
127 ///
128 /// - Returns: Returns `true` if the ranges intersect.
129 #[unsafe(method(intersectsWithTextRange:))]
130 #[unsafe(method_family = none)]
131 pub fn intersectsWithTextRange(&self, text_range: &NSTextRange) -> bool;
132
133 /// Returns the range, if any, where two text ranges intersect.
134 ///
135 /// - Parameters:
136 /// - textRange: The range used to compare against the current range to evaluate for differences.
137 ///
138 /// - Returns: An
139 /// <doc
140 /// ://com.apple.documentation/documentation/foundation/nsrange> that
141 /// represents the intersection of the ranges, or `nil` if they don't
142 /// intersect.
143 #[unsafe(method(textRangeByIntersectingWithTextRange:))]
144 #[unsafe(method_family = none)]
145 pub fn textRangeByIntersectingWithTextRange(
146 &self,
147 text_range: &NSTextRange,
148 ) -> Option<Retained<Self>>;
149
150 /// Returns a new text range by forming the union with the text range you provide.
151 ///
152 /// - Parameters:
153 /// - textRange: The range to use to create the union.
154 ///
155 /// - Returns: An ``NSTextRange`` that represent the union of the two ranges.
156 #[unsafe(method(textRangeByFormingUnionWithTextRange:))]
157 #[unsafe(method_family = none)]
158 pub fn textRangeByFormingUnionWithTextRange(
159 &self,
160 text_range: &NSTextRange,
161 ) -> Retained<Self>;
162 );
163}