1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
#[cfg(feature = "block2")]
use block2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextStorageEditActions(pub NSUInteger);
impl NSTextStorageEditActions {
    pub const NSTextStorageEditedAttributes: Self = Self(1 << 0);
    pub const NSTextStorageEditedCharacters: Self = Self(1 << 1);
}

unsafe impl Encode for NSTextStorageEditActions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSTextStorageEditActions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSTextStorage;

    unsafe impl ClassType for NSTextStorage {
        #[inherits(NSAttributedString, NSObject)]
        type Super = NSMutableAttributedString;
        type Mutability = Mutable;
    }
);

unsafe impl NSCoding for NSTextStorage {}

unsafe impl NSObjectProtocol for NSTextStorage {}

unsafe impl NSSecureCoding for NSTextStorage {}

extern_methods!(
    unsafe impl NSTextStorage {
        #[cfg(feature = "NSLayoutManager")]
        #[method_id(@__retain_semantics Other layoutManagers)]
        pub unsafe fn layoutManagers(&self) -> Id<NSArray<NSLayoutManager>>;

        #[cfg(feature = "NSLayoutManager")]
        #[method(addLayoutManager:)]
        pub unsafe fn addLayoutManager(&mut self, a_layout_manager: &NSLayoutManager);

        #[cfg(feature = "NSLayoutManager")]
        #[method(removeLayoutManager:)]
        pub unsafe fn removeLayoutManager(&mut self, a_layout_manager: &NSLayoutManager);

        #[method(editedMask)]
        pub unsafe fn editedMask(&self) -> NSTextStorageEditActions;

        #[method(editedRange)]
        pub unsafe fn editedRange(&self) -> NSRange;

        #[method(changeInLength)]
        pub unsafe fn changeInLength(&self) -> NSInteger;

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(&self) -> Option<Id<ProtocolObject<dyn NSTextStorageDelegate>>>;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(
            &mut self,
            delegate: Option<&ProtocolObject<dyn NSTextStorageDelegate>>,
        );

        #[method(edited:range:changeInLength:)]
        pub unsafe fn edited_range_changeInLength(
            &mut self,
            edited_mask: NSTextStorageEditActions,
            edited_range: NSRange,
            delta: NSInteger,
        );

        #[method(processEditing)]
        pub unsafe fn processEditing(&mut self);

        #[method(fixesAttributesLazily)]
        pub unsafe fn fixesAttributesLazily(&self) -> bool;

        #[method(invalidateAttributesInRange:)]
        pub unsafe fn invalidateAttributesInRange(&mut self, range: NSRange);

        #[method(ensureAttributesAreFixedInRange:)]
        pub unsafe fn ensureAttributesAreFixedInRange(&mut self, range: NSRange);

        #[method_id(@__retain_semantics Other textStorageObserver)]
        pub unsafe fn textStorageObserver(
            &self,
        ) -> Option<Id<ProtocolObject<dyn NSTextStorageObserving>>>;

        #[method(setTextStorageObserver:)]
        pub unsafe fn setTextStorageObserver(
            &mut self,
            text_storage_observer: Option<&ProtocolObject<dyn NSTextStorageObserving>>,
        );
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSTextStorage {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);

extern_protocol!(
    pub unsafe trait NSTextStorageDelegate: NSObjectProtocol {
        #[optional]
        #[method(textStorage:willProcessEditing:range:changeInLength:)]
        unsafe fn textStorage_willProcessEditing_range_changeInLength(
            &self,
            text_storage: &NSTextStorage,
            edited_mask: NSTextStorageEditActions,
            edited_range: NSRange,
            delta: NSInteger,
        );

        #[optional]
        #[method(textStorage:didProcessEditing:range:changeInLength:)]
        unsafe fn textStorage_didProcessEditing_range_changeInLength(
            &self,
            text_storage: &NSTextStorage,
            edited_mask: NSTextStorageEditActions,
            edited_range: NSRange,
            delta: NSInteger,
        );
    }

    unsafe impl ProtocolType for dyn NSTextStorageDelegate {}
);

extern "C" {
    pub static NSTextStorageWillProcessEditingNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSTextStorageDidProcessEditingNotification: &'static NSNotificationName;
}

extern_protocol!(
    pub unsafe trait NSTextStorageObserving: NSObjectProtocol {
        #[method_id(@__retain_semantics Other textStorage)]
        unsafe fn textStorage(&self) -> Option<Id<NSTextStorage>>;

        #[method(setTextStorage:)]
        unsafe fn setTextStorage(&self, text_storage: Option<&NSTextStorage>);

        #[method(processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:)]
        unsafe fn processEditingForTextStorage_edited_range_changeInLength_invalidatedRange(
            &self,
            text_storage: &NSTextStorage,
            edit_mask: NSTextStorageEditActions,
            new_char_range: NSRange,
            delta: NSInteger,
            invalidated_char_range: NSRange,
        );

        #[cfg(feature = "block2")]
        #[method(performEditingTransactionForTextStorage:usingBlock:)]
        unsafe fn performEditingTransactionForTextStorage_usingBlock(
            &self,
            text_storage: &NSTextStorage,
            transaction: &Block<dyn Fn() + '_>,
        );
    }

    unsafe impl ProtocolType for dyn NSTextStorageObserving {}
);

pub type NSTextStorageEditedOptions = NSUInteger;