1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11#[cfg(feature = "NSString")]
14pub type NSAttributedStringKey = NSString;
15
16#[cfg(feature = "NSString")]
19pub type NSAttributedStringFormattingContextKey = NSString;
20
21extern "C" {
22 #[cfg(feature = "NSString")]
24 pub static NSInflectionConceptsKey: &'static NSAttributedStringFormattingContextKey;
25}
26
27extern_class!(
28 #[unsafe(super(NSObject))]
30 #[derive(Debug, PartialEq, Eq, Hash)]
31 pub struct NSAttributedString;
32);
33
34#[cfg(feature = "objc2-core-foundation")]
35impl AsRef<NSAttributedString> for CFAttributedString {
36 #[inline]
37 fn as_ref(&self) -> &NSAttributedString {
38 unsafe { &*((self as *const Self).cast()) }
39 }
40}
41
42#[cfg(feature = "objc2-core-foundation")]
43impl AsRef<CFAttributedString> for NSAttributedString {
44 #[inline]
45 fn as_ref(&self) -> &CFAttributedString {
46 unsafe { &*((self as *const Self).cast()) }
47 }
48}
49
50#[cfg(feature = "NSObject")]
51extern_conformance!(
52 unsafe impl NSCoding for NSAttributedString {}
53);
54
55#[cfg(feature = "NSObject")]
56extern_conformance!(
57 unsafe impl NSCopying for NSAttributedString {}
58);
59
60#[cfg(feature = "NSObject")]
61unsafe impl CopyingHelper for NSAttributedString {
62 type Result = Self;
63}
64
65#[cfg(feature = "NSObject")]
66extern_conformance!(
67 unsafe impl NSMutableCopying for NSAttributedString {}
68);
69
70#[cfg(feature = "NSObject")]
71unsafe impl MutableCopyingHelper for NSAttributedString {
72 type Result = NSMutableAttributedString;
73}
74
75extern_conformance!(
76 unsafe impl NSObjectProtocol for NSAttributedString {}
77);
78
79#[cfg(feature = "NSObject")]
80extern_conformance!(
81 unsafe impl NSSecureCoding for NSAttributedString {}
82);
83
84impl NSAttributedString {
85 extern_methods!(
86 #[cfg(feature = "NSString")]
87 #[unsafe(method(string))]
88 #[unsafe(method_family = none)]
89 pub fn string(&self) -> Retained<NSString>;
90
91 #[cfg(all(feature = "NSDictionary", feature = "NSRange", feature = "NSString"))]
92 #[unsafe(method(attributesAtIndex:effectiveRange:))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn attributesAtIndex_effectiveRange(
98 &self,
99 location: NSUInteger,
100 range: NSRangePointer,
101 ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
102 );
103}
104
105impl NSAttributedString {
107 extern_methods!(
108 #[unsafe(method(init))]
109 #[unsafe(method_family = init)]
110 pub fn init(this: Allocated<Self>) -> Retained<Self>;
111
112 #[unsafe(method(new))]
113 #[unsafe(method_family = new)]
114 pub fn new() -> Retained<Self>;
115 );
116}
117
118impl DefaultRetained for NSAttributedString {
119 #[inline]
120 fn default_retained() -> Retained<Self> {
121 Self::new()
122 }
123}
124
125#[repr(transparent)]
128#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
129pub struct NSAttributedStringEnumerationOptions(pub NSUInteger);
130bitflags::bitflags! {
131 impl NSAttributedStringEnumerationOptions: NSUInteger {
132 #[doc(alias = "NSAttributedStringEnumerationReverse")]
133 const Reverse = 1<<1;
134 #[doc(alias = "NSAttributedStringEnumerationLongestEffectiveRangeNotRequired")]
135 const LongestEffectiveRangeNotRequired = 1<<20;
136 }
137}
138
139unsafe impl Encode for NSAttributedStringEnumerationOptions {
140 const ENCODING: Encoding = NSUInteger::ENCODING;
141}
142
143unsafe impl RefEncode for NSAttributedStringEnumerationOptions {
144 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
145}
146
147impl NSAttributedString {
149 extern_methods!(
150 #[unsafe(method(length))]
151 #[unsafe(method_family = none)]
152 pub fn length(&self) -> NSUInteger;
153
154 #[cfg(all(feature = "NSRange", feature = "NSString"))]
155 #[unsafe(method(attribute:atIndex:effectiveRange:))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn attribute_atIndex_effectiveRange(
161 &self,
162 attr_name: &NSAttributedStringKey,
163 location: NSUInteger,
164 range: NSRangePointer,
165 ) -> Option<Retained<AnyObject>>;
166
167 #[cfg(feature = "NSRange")]
168 #[unsafe(method(attributedSubstringFromRange:))]
169 #[unsafe(method_family = none)]
170 pub fn attributedSubstringFromRange(&self, range: NSRange) -> Retained<NSAttributedString>;
171
172 #[cfg(all(feature = "NSDictionary", feature = "NSRange", feature = "NSString"))]
173 #[unsafe(method(attributesAtIndex:longestEffectiveRange:inRange:))]
177 #[unsafe(method_family = none)]
178 pub unsafe fn attributesAtIndex_longestEffectiveRange_inRange(
179 &self,
180 location: NSUInteger,
181 range: NSRangePointer,
182 range_limit: NSRange,
183 ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
184
185 #[cfg(all(feature = "NSRange", feature = "NSString"))]
186 #[unsafe(method(attribute:atIndex:longestEffectiveRange:inRange:))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn attribute_atIndex_longestEffectiveRange_inRange(
192 &self,
193 attr_name: &NSAttributedStringKey,
194 location: NSUInteger,
195 range: NSRangePointer,
196 range_limit: NSRange,
197 ) -> Option<Retained<AnyObject>>;
198
199 #[unsafe(method(isEqualToAttributedString:))]
200 #[unsafe(method_family = none)]
201 pub fn isEqualToAttributedString(&self, other: &NSAttributedString) -> bool;
202
203 #[cfg(feature = "NSString")]
204 #[unsafe(method(initWithString:))]
205 #[unsafe(method_family = init)]
206 pub fn initWithString(this: Allocated<Self>, str: &NSString) -> Retained<Self>;
207
208 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
209 #[unsafe(method(initWithString:attributes:))]
213 #[unsafe(method_family = init)]
214 pub unsafe fn initWithString_attributes(
215 this: Allocated<Self>,
216 str: &NSString,
217 attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
218 ) -> Retained<Self>;
219
220 #[unsafe(method(initWithAttributedString:))]
221 #[unsafe(method_family = init)]
222 pub fn initWithAttributedString(
223 this: Allocated<Self>,
224 attr_str: &NSAttributedString,
225 ) -> Retained<Self>;
226
227 #[cfg(all(
228 feature = "NSDictionary",
229 feature = "NSRange",
230 feature = "NSString",
231 feature = "block2"
232 ))]
233 #[unsafe(method(enumerateAttributesInRange:options:usingBlock:))]
234 #[unsafe(method_family = none)]
235 pub fn enumerateAttributesInRange_options_usingBlock(
236 &self,
237 enumeration_range: NSRange,
238 opts: NSAttributedStringEnumerationOptions,
239 block: &block2::DynBlock<
240 dyn Fn(
241 NonNull<NSDictionary<NSAttributedStringKey, AnyObject>>,
242 NSRange,
243 NonNull<Bool>,
244 ) + '_,
245 >,
246 );
247
248 #[cfg(all(feature = "NSRange", feature = "NSString", feature = "block2"))]
249 #[unsafe(method(enumerateAttribute:inRange:options:usingBlock:))]
250 #[unsafe(method_family = none)]
251 pub fn enumerateAttribute_inRange_options_usingBlock(
252 &self,
253 attr_name: &NSAttributedStringKey,
254 enumeration_range: NSRange,
255 opts: NSAttributedStringEnumerationOptions,
256 block: &block2::DynBlock<dyn Fn(*mut AnyObject, NSRange, NonNull<Bool>) + '_>,
257 );
258 );
259}
260
261impl NSMutableAttributedString {
265 extern_methods!(
266 #[cfg(feature = "NSString")]
267 #[unsafe(method(initWithString:))]
268 #[unsafe(method_family = init)]
269 pub fn initWithString(this: Allocated<Self>, str: &NSString) -> Retained<Self>;
270
271 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
272 #[unsafe(method(initWithString:attributes:))]
276 #[unsafe(method_family = init)]
277 pub unsafe fn initWithString_attributes(
278 this: Allocated<Self>,
279 str: &NSString,
280 attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
281 ) -> Retained<Self>;
282
283 #[unsafe(method(initWithAttributedString:))]
284 #[unsafe(method_family = init)]
285 pub fn initWithAttributedString(
286 this: Allocated<Self>,
287 attr_str: &NSAttributedString,
288 ) -> Retained<Self>;
289 );
290}
291
292extern_class!(
293 #[unsafe(super(NSAttributedString, NSObject))]
295 #[derive(Debug, PartialEq, Eq, Hash)]
296 pub struct NSMutableAttributedString;
297);
298
299#[cfg(feature = "objc2-core-foundation")]
300impl AsRef<NSMutableAttributedString> for CFMutableAttributedString {
301 #[inline]
302 fn as_ref(&self) -> &NSMutableAttributedString {
303 unsafe { &*((self as *const Self).cast()) }
304 }
305}
306
307#[cfg(feature = "objc2-core-foundation")]
308impl AsRef<CFMutableAttributedString> for NSMutableAttributedString {
309 #[inline]
310 fn as_ref(&self) -> &CFMutableAttributedString {
311 unsafe { &*((self as *const Self).cast()) }
312 }
313}
314
315#[cfg(feature = "NSObject")]
316extern_conformance!(
317 unsafe impl NSCoding for NSMutableAttributedString {}
318);
319
320#[cfg(feature = "NSObject")]
321extern_conformance!(
322 unsafe impl NSCopying for NSMutableAttributedString {}
323);
324
325#[cfg(feature = "NSObject")]
326unsafe impl CopyingHelper for NSMutableAttributedString {
327 type Result = NSAttributedString;
328}
329
330#[cfg(feature = "NSObject")]
331extern_conformance!(
332 unsafe impl NSMutableCopying for NSMutableAttributedString {}
333);
334
335#[cfg(feature = "NSObject")]
336unsafe impl MutableCopyingHelper for NSMutableAttributedString {
337 type Result = Self;
338}
339
340extern_conformance!(
341 unsafe impl NSObjectProtocol for NSMutableAttributedString {}
342);
343
344#[cfg(feature = "NSObject")]
345extern_conformance!(
346 unsafe impl NSSecureCoding for NSMutableAttributedString {}
347);
348
349impl NSMutableAttributedString {
350 extern_methods!(
351 #[cfg(all(feature = "NSRange", feature = "NSString"))]
352 #[unsafe(method(replaceCharactersInRange:withString:))]
353 #[unsafe(method_family = none)]
354 pub fn replaceCharactersInRange_withString(&self, range: NSRange, str: &NSString);
355
356 #[cfg(all(feature = "NSDictionary", feature = "NSRange", feature = "NSString"))]
357 #[unsafe(method(setAttributes:range:))]
361 #[unsafe(method_family = none)]
362 pub unsafe fn setAttributes_range(
363 &self,
364 attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
365 range: NSRange,
366 );
367 );
368}
369
370impl NSMutableAttributedString {
372 extern_methods!(
373 #[unsafe(method(init))]
374 #[unsafe(method_family = init)]
375 pub fn init(this: Allocated<Self>) -> Retained<Self>;
376
377 #[unsafe(method(new))]
378 #[unsafe(method_family = new)]
379 pub fn new() -> Retained<Self>;
380 );
381}
382
383impl DefaultRetained for NSMutableAttributedString {
384 #[inline]
385 fn default_retained() -> Retained<Self> {
386 Self::new()
387 }
388}
389
390impl NSMutableAttributedString {
392 extern_methods!(
393 #[cfg(feature = "NSString")]
394 #[unsafe(method(mutableString))]
395 #[unsafe(method_family = none)]
396 pub fn mutableString(&self) -> Retained<NSMutableString>;
397
398 #[cfg(all(feature = "NSRange", feature = "NSString"))]
399 #[unsafe(method(addAttribute:value:range:))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn addAttribute_value_range(
405 &self,
406 name: &NSAttributedStringKey,
407 value: &AnyObject,
408 range: NSRange,
409 );
410
411 #[cfg(all(feature = "NSDictionary", feature = "NSRange", feature = "NSString"))]
412 #[unsafe(method(addAttributes:range:))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn addAttributes_range(
418 &self,
419 attrs: &NSDictionary<NSAttributedStringKey, AnyObject>,
420 range: NSRange,
421 );
422
423 #[cfg(all(feature = "NSRange", feature = "NSString"))]
424 #[unsafe(method(removeAttribute:range:))]
425 #[unsafe(method_family = none)]
426 pub fn removeAttribute_range(&self, name: &NSAttributedStringKey, range: NSRange);
427
428 #[cfg(feature = "NSRange")]
429 #[unsafe(method(replaceCharactersInRange:withAttributedString:))]
430 #[unsafe(method_family = none)]
431 pub fn replaceCharactersInRange_withAttributedString(
432 &self,
433 range: NSRange,
434 attr_string: &NSAttributedString,
435 );
436
437 #[unsafe(method(insertAttributedString:atIndex:))]
438 #[unsafe(method_family = none)]
439 pub fn insertAttributedString_atIndex(
440 &self,
441 attr_string: &NSAttributedString,
442 loc: NSUInteger,
443 );
444
445 #[unsafe(method(appendAttributedString:))]
446 #[unsafe(method_family = none)]
447 pub fn appendAttributedString(&self, attr_string: &NSAttributedString);
448
449 #[cfg(feature = "NSRange")]
450 #[unsafe(method(deleteCharactersInRange:))]
451 #[unsafe(method_family = none)]
452 pub fn deleteCharactersInRange(&self, range: NSRange);
453
454 #[unsafe(method(setAttributedString:))]
455 #[unsafe(method_family = none)]
456 pub fn setAttributedString(&self, attr_string: &NSAttributedString);
457
458 #[unsafe(method(beginEditing))]
459 #[unsafe(method_family = none)]
460 pub fn beginEditing(&self);
461
462 #[unsafe(method(endEditing))]
463 #[unsafe(method_family = none)]
464 pub fn endEditing(&self);
465 );
466}
467
468#[repr(transparent)]
471#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
472pub struct NSInlinePresentationIntent(pub NSUInteger);
473bitflags::bitflags! {
474 impl NSInlinePresentationIntent: NSUInteger {
475 #[doc(alias = "NSInlinePresentationIntentEmphasized")]
476 const Emphasized = 1<<0;
477 #[doc(alias = "NSInlinePresentationIntentStronglyEmphasized")]
478 const StronglyEmphasized = 1<<1;
479 #[doc(alias = "NSInlinePresentationIntentCode")]
480 const Code = 1<<2;
481 #[doc(alias = "NSInlinePresentationIntentStrikethrough")]
482 const Strikethrough = 1<<5;
483 #[doc(alias = "NSInlinePresentationIntentSoftBreak")]
484 const SoftBreak = 1<<6;
485 #[doc(alias = "NSInlinePresentationIntentLineBreak")]
486 const LineBreak = 1<<7;
487 #[doc(alias = "NSInlinePresentationIntentInlineHTML")]
488 const InlineHTML = 1<<8;
489 #[doc(alias = "NSInlinePresentationIntentBlockHTML")]
490 const BlockHTML = 1<<9;
491 }
492}
493
494unsafe impl Encode for NSInlinePresentationIntent {
495 const ENCODING: Encoding = NSUInteger::ENCODING;
496}
497
498unsafe impl RefEncode for NSInlinePresentationIntent {
499 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
500}
501
502extern "C" {
503 #[cfg(feature = "NSString")]
505 pub static NSInlinePresentationIntentAttributeName: &'static NSAttributedStringKey;
506}
507
508extern "C" {
509 #[cfg(feature = "NSString")]
511 pub static NSAlternateDescriptionAttributeName: &'static NSAttributedStringKey;
512}
513
514extern "C" {
515 #[cfg(feature = "NSString")]
517 pub static NSImageURLAttributeName: &'static NSAttributedStringKey;
518}
519
520extern "C" {
521 #[cfg(feature = "NSString")]
523 pub static NSLanguageIdentifierAttributeName: &'static NSAttributedStringKey;
524}
525
526extern "C" {
527 #[cfg(feature = "NSString")]
529 pub static NSMarkdownSourcePositionAttributeName: &'static NSAttributedStringKey;
530}
531
532#[repr(transparent)]
535#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
536pub struct NSAttributedStringMarkdownParsingFailurePolicy(pub NSInteger);
537impl NSAttributedStringMarkdownParsingFailurePolicy {
538 #[doc(alias = "NSAttributedStringMarkdownParsingFailureReturnError")]
539 pub const ReturnError: Self = Self(0);
540 #[doc(alias = "NSAttributedStringMarkdownParsingFailureReturnPartiallyParsedIfPossible")]
541 pub const ReturnPartiallyParsedIfPossible: Self = Self(1);
542}
543
544unsafe impl Encode for NSAttributedStringMarkdownParsingFailurePolicy {
545 const ENCODING: Encoding = NSInteger::ENCODING;
546}
547
548unsafe impl RefEncode for NSAttributedStringMarkdownParsingFailurePolicy {
549 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
550}
551
552#[repr(transparent)]
555#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
556pub struct NSAttributedStringMarkdownInterpretedSyntax(pub NSInteger);
557impl NSAttributedStringMarkdownInterpretedSyntax {
558 #[doc(alias = "NSAttributedStringMarkdownInterpretedSyntaxFull")]
559 pub const Full: Self = Self(0);
560 #[doc(alias = "NSAttributedStringMarkdownInterpretedSyntaxInlineOnly")]
561 pub const InlineOnly: Self = Self(1);
562 #[doc(alias = "NSAttributedStringMarkdownInterpretedSyntaxInlineOnlyPreservingWhitespace")]
563 pub const InlineOnlyPreservingWhitespace: Self = Self(2);
564}
565
566unsafe impl Encode for NSAttributedStringMarkdownInterpretedSyntax {
567 const ENCODING: Encoding = NSInteger::ENCODING;
568}
569
570unsafe impl RefEncode for NSAttributedStringMarkdownInterpretedSyntax {
571 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
572}
573
574extern_class!(
575 #[unsafe(super(NSObject))]
577 #[derive(Debug, PartialEq, Eq, Hash)]
578 pub struct NSAttributedStringMarkdownSourcePosition;
579);
580
581#[cfg(feature = "NSObject")]
582extern_conformance!(
583 unsafe impl NSCoding for NSAttributedStringMarkdownSourcePosition {}
584);
585
586#[cfg(feature = "NSObject")]
587extern_conformance!(
588 unsafe impl NSCopying for NSAttributedStringMarkdownSourcePosition {}
589);
590
591#[cfg(feature = "NSObject")]
592unsafe impl CopyingHelper for NSAttributedStringMarkdownSourcePosition {
593 type Result = Self;
594}
595
596extern_conformance!(
597 unsafe impl NSObjectProtocol for NSAttributedStringMarkdownSourcePosition {}
598);
599
600#[cfg(feature = "NSObject")]
601extern_conformance!(
602 unsafe impl NSSecureCoding for NSAttributedStringMarkdownSourcePosition {}
603);
604
605impl NSAttributedStringMarkdownSourcePosition {
606 extern_methods!(
607 #[unsafe(method(startLine))]
608 #[unsafe(method_family = none)]
609 pub fn startLine(&self) -> NSInteger;
610
611 #[unsafe(method(startColumn))]
612 #[unsafe(method_family = none)]
613 pub fn startColumn(&self) -> NSInteger;
614
615 #[unsafe(method(endLine))]
616 #[unsafe(method_family = none)]
617 pub fn endLine(&self) -> NSInteger;
618
619 #[unsafe(method(endColumn))]
620 #[unsafe(method_family = none)]
621 pub fn endColumn(&self) -> NSInteger;
622
623 #[unsafe(method(initWithStartLine:startColumn:endLine:endColumn:))]
624 #[unsafe(method_family = init)]
625 pub fn initWithStartLine_startColumn_endLine_endColumn(
626 this: Allocated<Self>,
627 start_line: NSInteger,
628 start_column: NSInteger,
629 end_line: NSInteger,
630 end_column: NSInteger,
631 ) -> Retained<Self>;
632
633 #[cfg(all(feature = "NSRange", feature = "NSString"))]
634 #[unsafe(method(rangeInString:))]
635 #[unsafe(method_family = none)]
636 pub fn rangeInString(&self, string: &NSString) -> NSRange;
637 );
638}
639
640impl NSAttributedStringMarkdownSourcePosition {
642 extern_methods!(
643 #[unsafe(method(init))]
644 #[unsafe(method_family = init)]
645 pub fn init(this: Allocated<Self>) -> Retained<Self>;
646
647 #[unsafe(method(new))]
648 #[unsafe(method_family = new)]
649 pub fn new() -> Retained<Self>;
650 );
651}
652
653impl DefaultRetained for NSAttributedStringMarkdownSourcePosition {
654 #[inline]
655 fn default_retained() -> Retained<Self> {
656 Self::new()
657 }
658}
659
660extern_class!(
661 #[unsafe(super(NSObject))]
663 #[derive(Debug, PartialEq, Eq, Hash)]
664 pub struct NSAttributedStringMarkdownParsingOptions;
665);
666
667#[cfg(feature = "NSObject")]
668extern_conformance!(
669 unsafe impl NSCopying for NSAttributedStringMarkdownParsingOptions {}
670);
671
672#[cfg(feature = "NSObject")]
673unsafe impl CopyingHelper for NSAttributedStringMarkdownParsingOptions {
674 type Result = Self;
675}
676
677extern_conformance!(
678 unsafe impl NSObjectProtocol for NSAttributedStringMarkdownParsingOptions {}
679);
680
681impl NSAttributedStringMarkdownParsingOptions {
682 extern_methods!(
683 #[unsafe(method(init))]
684 #[unsafe(method_family = init)]
685 pub fn init(this: Allocated<Self>) -> Retained<Self>;
686
687 #[unsafe(method(allowsExtendedAttributes))]
688 #[unsafe(method_family = none)]
689 pub fn allowsExtendedAttributes(&self) -> bool;
690
691 #[unsafe(method(setAllowsExtendedAttributes:))]
693 #[unsafe(method_family = none)]
694 pub fn setAllowsExtendedAttributes(&self, allows_extended_attributes: bool);
695
696 #[unsafe(method(interpretedSyntax))]
697 #[unsafe(method_family = none)]
698 pub fn interpretedSyntax(&self) -> NSAttributedStringMarkdownInterpretedSyntax;
699
700 #[unsafe(method(setInterpretedSyntax:))]
702 #[unsafe(method_family = none)]
703 pub fn setInterpretedSyntax(
704 &self,
705 interpreted_syntax: NSAttributedStringMarkdownInterpretedSyntax,
706 );
707
708 #[unsafe(method(failurePolicy))]
709 #[unsafe(method_family = none)]
710 pub fn failurePolicy(&self) -> NSAttributedStringMarkdownParsingFailurePolicy;
711
712 #[unsafe(method(setFailurePolicy:))]
714 #[unsafe(method_family = none)]
715 pub fn setFailurePolicy(
716 &self,
717 failure_policy: NSAttributedStringMarkdownParsingFailurePolicy,
718 );
719
720 #[cfg(feature = "NSString")]
721 #[unsafe(method(languageCode))]
722 #[unsafe(method_family = none)]
723 pub fn languageCode(&self) -> Option<Retained<NSString>>;
724
725 #[cfg(feature = "NSString")]
726 #[unsafe(method(setLanguageCode:))]
730 #[unsafe(method_family = none)]
731 pub fn setLanguageCode(&self, language_code: Option<&NSString>);
732
733 #[unsafe(method(appliesSourcePositionAttributes))]
734 #[unsafe(method_family = none)]
735 pub fn appliesSourcePositionAttributes(&self) -> bool;
736
737 #[unsafe(method(setAppliesSourcePositionAttributes:))]
739 #[unsafe(method_family = none)]
740 pub fn setAppliesSourcePositionAttributes(&self, applies_source_position_attributes: bool);
741 );
742}
743
744impl NSAttributedStringMarkdownParsingOptions {
746 extern_methods!(
747 #[unsafe(method(new))]
748 #[unsafe(method_family = new)]
749 pub fn new() -> Retained<Self>;
750 );
751}
752
753impl DefaultRetained for NSAttributedStringMarkdownParsingOptions {
754 #[inline]
755 fn default_retained() -> Retained<Self> {
756 Self::new()
757 }
758}
759
760impl NSAttributedString {
762 extern_methods!(
763 #[cfg(all(feature = "NSError", feature = "NSURL"))]
764 #[unsafe(method(initWithContentsOfMarkdownFileAtURL:options:baseURL:error:_))]
765 #[unsafe(method_family = init)]
766 pub fn initWithContentsOfMarkdownFileAtURL_options_baseURL_error(
767 this: Allocated<Self>,
768 markdown_file: &NSURL,
769 options: Option<&NSAttributedStringMarkdownParsingOptions>,
770 base_url: Option<&NSURL>,
771 ) -> Result<Retained<Self>, Retained<NSError>>;
772
773 #[cfg(all(feature = "NSData", feature = "NSError", feature = "NSURL"))]
774 #[unsafe(method(initWithMarkdown:options:baseURL:error:_))]
775 #[unsafe(method_family = init)]
776 pub fn initWithMarkdown_options_baseURL_error(
777 this: Allocated<Self>,
778 markdown: &NSData,
779 options: Option<&NSAttributedStringMarkdownParsingOptions>,
780 base_url: Option<&NSURL>,
781 ) -> Result<Retained<Self>, Retained<NSError>>;
782
783 #[cfg(all(feature = "NSError", feature = "NSString", feature = "NSURL"))]
784 #[unsafe(method(initWithMarkdownString:options:baseURL:error:_))]
785 #[unsafe(method_family = init)]
786 pub fn initWithMarkdownString_options_baseURL_error(
787 this: Allocated<Self>,
788 markdown_string: &NSString,
789 options: Option<&NSAttributedStringMarkdownParsingOptions>,
790 base_url: Option<&NSURL>,
791 ) -> Result<Retained<Self>, Retained<NSError>>;
792 );
793}
794
795impl NSMutableAttributedString {
799 extern_methods!(
800 #[cfg(all(feature = "NSError", feature = "NSURL"))]
801 #[unsafe(method(initWithContentsOfMarkdownFileAtURL:options:baseURL:error:_))]
802 #[unsafe(method_family = init)]
803 pub fn initWithContentsOfMarkdownFileAtURL_options_baseURL_error(
804 this: Allocated<Self>,
805 markdown_file: &NSURL,
806 options: Option<&NSAttributedStringMarkdownParsingOptions>,
807 base_url: Option<&NSURL>,
808 ) -> Result<Retained<Self>, Retained<NSError>>;
809
810 #[cfg(all(feature = "NSData", feature = "NSError", feature = "NSURL"))]
811 #[unsafe(method(initWithMarkdown:options:baseURL:error:_))]
812 #[unsafe(method_family = init)]
813 pub fn initWithMarkdown_options_baseURL_error(
814 this: Allocated<Self>,
815 markdown: &NSData,
816 options: Option<&NSAttributedStringMarkdownParsingOptions>,
817 base_url: Option<&NSURL>,
818 ) -> Result<Retained<Self>, Retained<NSError>>;
819
820 #[cfg(all(feature = "NSError", feature = "NSString", feature = "NSURL"))]
821 #[unsafe(method(initWithMarkdownString:options:baseURL:error:_))]
822 #[unsafe(method_family = init)]
823 pub fn initWithMarkdownString_options_baseURL_error(
824 this: Allocated<Self>,
825 markdown_string: &NSString,
826 options: Option<&NSAttributedStringMarkdownParsingOptions>,
827 base_url: Option<&NSURL>,
828 ) -> Result<Retained<Self>, Retained<NSError>>;
829 );
830}
831
832#[repr(transparent)]
835#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
836pub struct NSAttributedStringFormattingOptions(pub NSUInteger);
837bitflags::bitflags! {
838 impl NSAttributedStringFormattingOptions: NSUInteger {
839 #[doc(alias = "NSAttributedStringFormattingInsertArgumentAttributesWithoutMerging")]
840 const InsertArgumentAttributesWithoutMerging = 1<<0;
841 #[doc(alias = "NSAttributedStringFormattingApplyReplacementIndexAttribute")]
842 const ApplyReplacementIndexAttribute = 1<<1;
843 }
844}
845
846unsafe impl Encode for NSAttributedStringFormattingOptions {
847 const ENCODING: Encoding = NSUInteger::ENCODING;
848}
849
850unsafe impl RefEncode for NSAttributedStringFormattingOptions {
851 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
852}
853
854impl NSAttributedString {
856 extern_methods!();
857}
858
859impl NSMutableAttributedString {
861 extern_methods!();
862}
863
864extern "C" {
865 #[cfg(feature = "NSString")]
867 pub static NSReplacementIndexAttributeName: &'static NSAttributedStringKey;
868}
869
870impl NSAttributedString {
872 extern_methods!(
873 #[unsafe(method(attributedStringByInflectingString))]
877 #[unsafe(method_family = none)]
878 pub fn attributedStringByInflectingString(&self) -> Retained<NSAttributedString>;
879 );
880}
881
882extern "C" {
883 #[cfg(feature = "NSString")]
885 pub static NSMorphologyAttributeName: &'static NSAttributedStringKey;
886}
887
888extern "C" {
889 #[cfg(feature = "NSString")]
891 pub static NSInflectionRuleAttributeName: &'static NSAttributedStringKey;
892}
893
894extern "C" {
895 #[cfg(feature = "NSString")]
897 pub static NSInflectionAgreementArgumentAttributeName: &'static NSAttributedStringKey;
898}
899
900extern "C" {
901 #[cfg(feature = "NSString")]
903 pub static NSInflectionAgreementConceptAttributeName: &'static NSAttributedStringKey;
904}
905
906extern "C" {
907 #[cfg(feature = "NSString")]
909 pub static NSInflectionReferentConceptAttributeName: &'static NSAttributedStringKey;
910}
911
912extern "C" {
913 #[cfg(feature = "NSString")]
915 pub static NSInflectionAlternativeAttributeName: &'static NSAttributedStringKey;
916}
917
918extern "C" {
919 #[cfg(feature = "NSString")]
921 pub static NSLocalizedNumberFormatAttributeName: &'static NSAttributedStringKey;
922}
923
924extern "C" {
925 #[cfg(feature = "NSString")]
927 pub static NSListItemDelimiterAttributeName: &'static NSAttributedStringKey;
928}
929
930extern "C" {
931 #[cfg(feature = "NSString")]
933 pub static NSPresentationIntentAttributeName: &'static NSAttributedStringKey;
934}
935
936#[repr(transparent)]
939#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
940pub struct NSPresentationIntentKind(pub NSInteger);
941impl NSPresentationIntentKind {
942 #[doc(alias = "NSPresentationIntentKindParagraph")]
943 pub const Paragraph: Self = Self(0);
944 #[doc(alias = "NSPresentationIntentKindHeader")]
945 pub const Header: Self = Self(1);
946 #[doc(alias = "NSPresentationIntentKindOrderedList")]
947 pub const OrderedList: Self = Self(2);
948 #[doc(alias = "NSPresentationIntentKindUnorderedList")]
949 pub const UnorderedList: Self = Self(3);
950 #[doc(alias = "NSPresentationIntentKindListItem")]
951 pub const ListItem: Self = Self(4);
952 #[doc(alias = "NSPresentationIntentKindCodeBlock")]
953 pub const CodeBlock: Self = Self(5);
954 #[doc(alias = "NSPresentationIntentKindBlockQuote")]
955 pub const BlockQuote: Self = Self(6);
956 #[doc(alias = "NSPresentationIntentKindThematicBreak")]
957 pub const ThematicBreak: Self = Self(7);
958 #[doc(alias = "NSPresentationIntentKindTable")]
959 pub const Table: Self = Self(8);
960 #[doc(alias = "NSPresentationIntentKindTableHeaderRow")]
961 pub const TableHeaderRow: Self = Self(9);
962 #[doc(alias = "NSPresentationIntentKindTableRow")]
963 pub const TableRow: Self = Self(10);
964 #[doc(alias = "NSPresentationIntentKindTableCell")]
965 pub const TableCell: Self = Self(11);
966}
967
968unsafe impl Encode for NSPresentationIntentKind {
969 const ENCODING: Encoding = NSInteger::ENCODING;
970}
971
972unsafe impl RefEncode for NSPresentationIntentKind {
973 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
974}
975
976#[repr(transparent)]
979#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
980pub struct NSPresentationIntentTableColumnAlignment(pub NSInteger);
981impl NSPresentationIntentTableColumnAlignment {
982 #[doc(alias = "NSPresentationIntentTableColumnAlignmentLeft")]
983 pub const Left: Self = Self(0);
984 #[doc(alias = "NSPresentationIntentTableColumnAlignmentCenter")]
985 pub const Center: Self = Self(1);
986 #[doc(alias = "NSPresentationIntentTableColumnAlignmentRight")]
987 pub const Right: Self = Self(2);
988}
989
990unsafe impl Encode for NSPresentationIntentTableColumnAlignment {
991 const ENCODING: Encoding = NSInteger::ENCODING;
992}
993
994unsafe impl RefEncode for NSPresentationIntentTableColumnAlignment {
995 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
996}
997
998extern_class!(
999 #[unsafe(super(NSObject))]
1001 #[derive(Debug, PartialEq, Eq, Hash)]
1002 pub struct NSPresentationIntent;
1003);
1004
1005#[cfg(feature = "NSObject")]
1006extern_conformance!(
1007 unsafe impl NSCoding for NSPresentationIntent {}
1008);
1009
1010#[cfg(feature = "NSObject")]
1011extern_conformance!(
1012 unsafe impl NSCopying for NSPresentationIntent {}
1013);
1014
1015#[cfg(feature = "NSObject")]
1016unsafe impl CopyingHelper for NSPresentationIntent {
1017 type Result = Self;
1018}
1019
1020extern_conformance!(
1021 unsafe impl NSObjectProtocol for NSPresentationIntent {}
1022);
1023
1024#[cfg(feature = "NSObject")]
1025extern_conformance!(
1026 unsafe impl NSSecureCoding for NSPresentationIntent {}
1027);
1028
1029impl NSPresentationIntent {
1030 extern_methods!(
1031 #[unsafe(method(intentKind))]
1032 #[unsafe(method_family = none)]
1033 pub fn intentKind(&self) -> NSPresentationIntentKind;
1034
1035 #[unsafe(method(init))]
1036 #[unsafe(method_family = init)]
1037 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1038
1039 #[unsafe(method(parentIntent))]
1040 #[unsafe(method_family = none)]
1041 pub fn parentIntent(&self) -> Option<Retained<NSPresentationIntent>>;
1042
1043 #[unsafe(method(paragraphIntentWithIdentity:nestedInsideIntent:))]
1044 #[unsafe(method_family = none)]
1045 pub fn paragraphIntentWithIdentity_nestedInsideIntent(
1046 identity: NSInteger,
1047 parent: Option<&NSPresentationIntent>,
1048 ) -> Retained<NSPresentationIntent>;
1049
1050 #[unsafe(method(headerIntentWithIdentity:level:nestedInsideIntent:))]
1051 #[unsafe(method_family = none)]
1052 pub fn headerIntentWithIdentity_level_nestedInsideIntent(
1053 identity: NSInteger,
1054 level: NSInteger,
1055 parent: Option<&NSPresentationIntent>,
1056 ) -> Retained<NSPresentationIntent>;
1057
1058 #[cfg(feature = "NSString")]
1059 #[unsafe(method(codeBlockIntentWithIdentity:languageHint:nestedInsideIntent:))]
1060 #[unsafe(method_family = none)]
1061 pub fn codeBlockIntentWithIdentity_languageHint_nestedInsideIntent(
1062 identity: NSInteger,
1063 language_hint: Option<&NSString>,
1064 parent: Option<&NSPresentationIntent>,
1065 ) -> Retained<NSPresentationIntent>;
1066
1067 #[unsafe(method(thematicBreakIntentWithIdentity:nestedInsideIntent:))]
1068 #[unsafe(method_family = none)]
1069 pub fn thematicBreakIntentWithIdentity_nestedInsideIntent(
1070 identity: NSInteger,
1071 parent: Option<&NSPresentationIntent>,
1072 ) -> Retained<NSPresentationIntent>;
1073
1074 #[unsafe(method(orderedListIntentWithIdentity:nestedInsideIntent:))]
1075 #[unsafe(method_family = none)]
1076 pub fn orderedListIntentWithIdentity_nestedInsideIntent(
1077 identity: NSInteger,
1078 parent: Option<&NSPresentationIntent>,
1079 ) -> Retained<NSPresentationIntent>;
1080
1081 #[unsafe(method(unorderedListIntentWithIdentity:nestedInsideIntent:))]
1082 #[unsafe(method_family = none)]
1083 pub fn unorderedListIntentWithIdentity_nestedInsideIntent(
1084 identity: NSInteger,
1085 parent: Option<&NSPresentationIntent>,
1086 ) -> Retained<NSPresentationIntent>;
1087
1088 #[unsafe(method(listItemIntentWithIdentity:ordinal:nestedInsideIntent:))]
1089 #[unsafe(method_family = none)]
1090 pub fn listItemIntentWithIdentity_ordinal_nestedInsideIntent(
1091 identity: NSInteger,
1092 ordinal: NSInteger,
1093 parent: Option<&NSPresentationIntent>,
1094 ) -> Retained<NSPresentationIntent>;
1095
1096 #[unsafe(method(blockQuoteIntentWithIdentity:nestedInsideIntent:))]
1097 #[unsafe(method_family = none)]
1098 pub fn blockQuoteIntentWithIdentity_nestedInsideIntent(
1099 identity: NSInteger,
1100 parent: Option<&NSPresentationIntent>,
1101 ) -> Retained<NSPresentationIntent>;
1102
1103 #[cfg(all(feature = "NSArray", feature = "NSValue"))]
1104 #[unsafe(method(tableIntentWithIdentity:columnCount:alignments:nestedInsideIntent:))]
1105 #[unsafe(method_family = none)]
1106 pub fn tableIntentWithIdentity_columnCount_alignments_nestedInsideIntent(
1107 identity: NSInteger,
1108 column_count: NSInteger,
1109 alignments: &NSArray<NSNumber>,
1110 parent: Option<&NSPresentationIntent>,
1111 ) -> Retained<NSPresentationIntent>;
1112
1113 #[unsafe(method(tableHeaderRowIntentWithIdentity:nestedInsideIntent:))]
1114 #[unsafe(method_family = none)]
1115 pub fn tableHeaderRowIntentWithIdentity_nestedInsideIntent(
1116 identity: NSInteger,
1117 parent: Option<&NSPresentationIntent>,
1118 ) -> Retained<NSPresentationIntent>;
1119
1120 #[unsafe(method(tableRowIntentWithIdentity:row:nestedInsideIntent:))]
1121 #[unsafe(method_family = none)]
1122 pub fn tableRowIntentWithIdentity_row_nestedInsideIntent(
1123 identity: NSInteger,
1124 row: NSInteger,
1125 parent: Option<&NSPresentationIntent>,
1126 ) -> Retained<NSPresentationIntent>;
1127
1128 #[unsafe(method(tableCellIntentWithIdentity:column:nestedInsideIntent:))]
1129 #[unsafe(method_family = none)]
1130 pub fn tableCellIntentWithIdentity_column_nestedInsideIntent(
1131 identity: NSInteger,
1132 column: NSInteger,
1133 parent: Option<&NSPresentationIntent>,
1134 ) -> Retained<NSPresentationIntent>;
1135
1136 #[unsafe(method(identity))]
1138 #[unsafe(method_family = none)]
1139 pub fn identity(&self) -> NSInteger;
1140
1141 #[unsafe(method(ordinal))]
1143 #[unsafe(method_family = none)]
1144 pub fn ordinal(&self) -> NSInteger;
1145
1146 #[cfg(all(feature = "NSArray", feature = "NSValue"))]
1147 #[unsafe(method(columnAlignments))]
1149 #[unsafe(method_family = none)]
1150 pub fn columnAlignments(&self) -> Option<Retained<NSArray<NSNumber>>>;
1151
1152 #[unsafe(method(columnCount))]
1154 #[unsafe(method_family = none)]
1155 pub fn columnCount(&self) -> NSInteger;
1156
1157 #[unsafe(method(headerLevel))]
1159 #[unsafe(method_family = none)]
1160 pub fn headerLevel(&self) -> NSInteger;
1161
1162 #[cfg(feature = "NSString")]
1163 #[unsafe(method(languageHint))]
1165 #[unsafe(method_family = none)]
1166 pub fn languageHint(&self) -> Option<Retained<NSString>>;
1167
1168 #[unsafe(method(column))]
1170 #[unsafe(method_family = none)]
1171 pub fn column(&self) -> NSInteger;
1172
1173 #[unsafe(method(row))]
1175 #[unsafe(method_family = none)]
1176 pub fn row(&self) -> NSInteger;
1177
1178 #[unsafe(method(indentationLevel))]
1181 #[unsafe(method_family = none)]
1182 pub fn indentationLevel(&self) -> NSInteger;
1183
1184 #[unsafe(method(isEquivalentToPresentationIntent:))]
1186 #[unsafe(method_family = none)]
1187 pub fn isEquivalentToPresentationIntent(&self, other: &NSPresentationIntent) -> bool;
1188 );
1189}
1190
1191impl NSPresentationIntent {
1193 extern_methods!(
1194 #[unsafe(method(new))]
1195 #[unsafe(method_family = new)]
1196 pub unsafe fn new() -> Retained<Self>;
1197 );
1198}