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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
//! 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_TYPED_ENUM
pub type NSTextCheckingOptionKey = NSString;

extern "C" {
    pub static NSTextCheckingOrthographyKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingQuotesKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingReplacementsKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingReferenceDateKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingReferenceTimeZoneKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingDocumentURLKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingDocumentTitleKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingDocumentAuthorKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingRegularExpressionsKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingSelectedRangeKey: &'static NSTextCheckingOptionKey;
}

extern "C" {
    pub static NSTextCheckingGenerateInlinePredictionsKey: &'static NSTextCheckingOptionKey;
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSCorrectionResponse(pub NSInteger);
impl NSCorrectionResponse {
    #[doc(alias = "NSCorrectionResponseNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "NSCorrectionResponseAccepted")]
    pub const Accepted: Self = Self(1);
    #[doc(alias = "NSCorrectionResponseRejected")]
    pub const Rejected: Self = Self(2);
    #[doc(alias = "NSCorrectionResponseIgnored")]
    pub const Ignored: Self = Self(3);
    #[doc(alias = "NSCorrectionResponseEdited")]
    pub const Edited: Self = Self(4);
    #[doc(alias = "NSCorrectionResponseReverted")]
    pub const Reverted: Self = Self(5);
}

unsafe impl Encode for NSCorrectionResponse {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSCorrectionIndicatorType(pub NSInteger);
impl NSCorrectionIndicatorType {
    #[doc(alias = "NSCorrectionIndicatorTypeDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "NSCorrectionIndicatorTypeReversion")]
    pub const Reversion: Self = Self(1);
    #[doc(alias = "NSCorrectionIndicatorTypeGuesses")]
    pub const Guesses: Self = Self(2);
}

unsafe impl Encode for NSCorrectionIndicatorType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

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

    unsafe impl ClassType for NSSpellChecker {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for NSSpellChecker {}

extern_methods!(
    unsafe impl NSSpellChecker {
        #[method_id(@__retain_semantics Other sharedSpellChecker)]
        pub unsafe fn sharedSpellChecker() -> Id<NSSpellChecker>;

        #[method(sharedSpellCheckerExists)]
        pub unsafe fn sharedSpellCheckerExists() -> bool;

        #[method(uniqueSpellDocumentTag)]
        pub unsafe fn uniqueSpellDocumentTag() -> NSInteger;

        #[method(checkSpellingOfString:startingAt:language:wrap:inSpellDocumentWithTag:wordCount:)]
        pub unsafe fn checkSpellingOfString_startingAt_language_wrap_inSpellDocumentWithTag_wordCount(
            &self,
            string_to_check: &NSString,
            starting_offset: NSInteger,
            language: Option<&NSString>,
            wrap_flag: bool,
            tag: NSInteger,
            word_count: *mut NSInteger,
        ) -> NSRange;

        #[method(checkSpellingOfString:startingAt:)]
        pub unsafe fn checkSpellingOfString_startingAt(
            &self,
            string_to_check: &NSString,
            starting_offset: NSInteger,
        ) -> NSRange;

        #[method(countWordsInString:language:)]
        pub unsafe fn countWordsInString_language(
            &self,
            string_to_count: &NSString,
            language: Option<&NSString>,
        ) -> NSInteger;

        #[method(checkGrammarOfString:startingAt:language:wrap:inSpellDocumentWithTag:details:)]
        pub unsafe fn checkGrammarOfString_startingAt_language_wrap_inSpellDocumentWithTag_details(
            &self,
            string_to_check: &NSString,
            starting_offset: NSInteger,
            language: Option<&NSString>,
            wrap_flag: bool,
            tag: NSInteger,
            details: Option<&mut Option<Id<NSArray<NSDictionary<NSString, AnyObject>>>>>,
        ) -> NSRange;

        #[method_id(@__retain_semantics Other checkString:range:types:options:inSpellDocumentWithTag:orthography:wordCount:)]
        pub unsafe fn checkString_range_types_options_inSpellDocumentWithTag_orthography_wordCount(
            &self,
            string_to_check: &NSString,
            range: NSRange,
            checking_types: NSTextCheckingTypes,
            options: Option<&NSDictionary<NSTextCheckingOptionKey, AnyObject>>,
            tag: NSInteger,
            orthography: Option<&mut Option<Id<NSOrthography>>>,
            word_count: *mut NSInteger,
        ) -> Id<NSArray<NSTextCheckingResult>>;

        #[cfg(feature = "block2")]
        #[method(requestCheckingOfString:range:types:options:inSpellDocumentWithTag:completionHandler:)]
        pub unsafe fn requestCheckingOfString_range_types_options_inSpellDocumentWithTag_completionHandler(
            &self,
            string_to_check: &NSString,
            range: NSRange,
            checking_types: NSTextCheckingTypes,
            options: Option<&NSDictionary<NSTextCheckingOptionKey, AnyObject>>,
            tag: NSInteger,
            completion_handler: Option<
                &Block<
                    dyn Fn(
                        NSInteger,
                        NonNull<NSArray<NSTextCheckingResult>>,
                        NonNull<NSOrthography>,
                        NSInteger,
                    ),
                >,
            >,
        ) -> NSInteger;

        #[cfg(feature = "block2")]
        #[method(requestCandidatesForSelectedRange:inString:types:options:inSpellDocumentWithTag:completionHandler:)]
        pub unsafe fn requestCandidatesForSelectedRange_inString_types_options_inSpellDocumentWithTag_completionHandler(
            &self,
            selected_range: NSRange,
            string_to_check: &NSString,
            checking_types: NSTextCheckingTypes,
            options: Option<&NSDictionary<NSTextCheckingOptionKey, AnyObject>>,
            tag: NSInteger,
            completion_handler: Option<
                &Block<dyn Fn(NSInteger, NonNull<NSArray<NSTextCheckingResult>>)>,
            >,
        ) -> NSInteger;

        #[cfg(all(feature = "NSMenu", feature = "NSResponder", feature = "NSView"))]
        #[method_id(@__retain_semantics Other menuForResult:string:options:atLocation:inView:)]
        pub unsafe fn menuForResult_string_options_atLocation_inView(
            &self,
            result: &NSTextCheckingResult,
            checked_string: &NSString,
            options: Option<&NSDictionary<NSTextCheckingOptionKey, AnyObject>>,
            location: NSPoint,
            view: &NSView,
        ) -> Option<Id<NSMenu>>;

        #[method_id(@__retain_semantics Other userQuotesArrayForLanguage:)]
        pub unsafe fn userQuotesArrayForLanguage(
            &self,
            language: &NSString,
        ) -> Id<NSArray<NSString>>;

        #[method_id(@__retain_semantics Other userReplacementsDictionary)]
        pub unsafe fn userReplacementsDictionary(&self) -> Id<NSDictionary<NSString, NSString>>;

        #[method(updateSpellingPanelWithMisspelledWord:)]
        pub unsafe fn updateSpellingPanelWithMisspelledWord(&self, word: &NSString);

        #[method(updateSpellingPanelWithGrammarString:detail:)]
        pub unsafe fn updateSpellingPanelWithGrammarString_detail(
            &self,
            string: &NSString,
            detail: &NSDictionary<NSString, AnyObject>,
        );

        #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
        #[method_id(@__retain_semantics Other spellingPanel)]
        pub unsafe fn spellingPanel(&self, mtm: MainThreadMarker) -> Id<NSPanel>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[method_id(@__retain_semantics Other accessoryView)]
        pub unsafe fn accessoryView(&self, mtm: MainThreadMarker) -> Option<Id<NSView>>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[method(setAccessoryView:)]
        pub unsafe fn setAccessoryView(&self, accessory_view: Option<&NSView>);

        #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
        #[method_id(@__retain_semantics Other substitutionsPanel)]
        pub unsafe fn substitutionsPanel(&self, mtm: MainThreadMarker) -> Id<NSPanel>;

        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
        #[method_id(@__retain_semantics Other substitutionsPanelAccessoryViewController)]
        pub unsafe fn substitutionsPanelAccessoryViewController(
            &self,
            mtm: MainThreadMarker,
        ) -> Option<Id<NSViewController>>;

        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
        #[method(setSubstitutionsPanelAccessoryViewController:)]
        pub unsafe fn setSubstitutionsPanelAccessoryViewController(
            &self,
            substitutions_panel_accessory_view_controller: Option<&NSViewController>,
        );

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

        #[method(ignoreWord:inSpellDocumentWithTag:)]
        pub unsafe fn ignoreWord_inSpellDocumentWithTag(
            &self,
            word_to_ignore: &NSString,
            tag: NSInteger,
        );

        #[method_id(@__retain_semantics Other ignoredWordsInSpellDocumentWithTag:)]
        pub unsafe fn ignoredWordsInSpellDocumentWithTag(
            &self,
            tag: NSInteger,
        ) -> Option<Id<NSArray<NSString>>>;

        #[method(setIgnoredWords:inSpellDocumentWithTag:)]
        pub unsafe fn setIgnoredWords_inSpellDocumentWithTag(
            &self,
            words: &NSArray<NSString>,
            tag: NSInteger,
        );

        #[method_id(@__retain_semantics Other guessesForWordRange:inString:language:inSpellDocumentWithTag:)]
        pub unsafe fn guessesForWordRange_inString_language_inSpellDocumentWithTag(
            &self,
            range: NSRange,
            string: &NSString,
            language: Option<&NSString>,
            tag: NSInteger,
        ) -> Option<Id<NSArray<NSString>>>;

        #[method_id(@__retain_semantics Other correctionForWordRange:inString:language:inSpellDocumentWithTag:)]
        pub unsafe fn correctionForWordRange_inString_language_inSpellDocumentWithTag(
            &self,
            range: NSRange,
            string: &NSString,
            language: &NSString,
            tag: NSInteger,
        ) -> Option<Id<NSString>>;

        #[method_id(@__retain_semantics Other completionsForPartialWordRange:inString:language:inSpellDocumentWithTag:)]
        pub unsafe fn completionsForPartialWordRange_inString_language_inSpellDocumentWithTag(
            &self,
            range: NSRange,
            string: &NSString,
            language: Option<&NSString>,
            tag: NSInteger,
        ) -> Option<Id<NSArray<NSString>>>;

        #[method_id(@__retain_semantics Other languageForWordRange:inString:orthography:)]
        pub unsafe fn languageForWordRange_inString_orthography(
            &self,
            range: NSRange,
            string: &NSString,
            orthography: Option<&NSOrthography>,
        ) -> Option<Id<NSString>>;

        #[method(closeSpellDocumentWithTag:)]
        pub unsafe fn closeSpellDocumentWithTag(&self, tag: NSInteger);

        #[method(recordResponse:toCorrection:forWord:language:inSpellDocumentWithTag:)]
        pub unsafe fn recordResponse_toCorrection_forWord_language_inSpellDocumentWithTag(
            &self,
            response: NSCorrectionResponse,
            correction: &NSString,
            word: &NSString,
            language: Option<&NSString>,
            tag: NSInteger,
        );

        #[cfg(all(feature = "NSResponder", feature = "NSView", feature = "block2"))]
        #[method(showCorrectionIndicatorOfType:primaryString:alternativeStrings:forStringInRect:view:completionHandler:)]
        pub unsafe fn showCorrectionIndicatorOfType_primaryString_alternativeStrings_forStringInRect_view_completionHandler(
            &self,
            r#type: NSCorrectionIndicatorType,
            primary_string: &NSString,
            alternative_strings: &NSArray<NSString>,
            rect_of_typed_string: NSRect,
            view: &NSView,
            completion_block: Option<&Block<dyn Fn(*mut NSString)>>,
        );

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[method(dismissCorrectionIndicatorForView:)]
        pub unsafe fn dismissCorrectionIndicatorForView(&self, view: &NSView);

        #[cfg(feature = "NSTextInputClient")]
        #[method(showInlinePredictionForCandidates:client:)]
        pub unsafe fn showInlinePredictionForCandidates_client(
            &self,
            candidates: &NSArray<NSTextCheckingResult>,
            client: &ProtocolObject<dyn NSTextInputClient>,
        );

        #[method(preventsAutocorrectionBeforeString:language:)]
        pub unsafe fn preventsAutocorrectionBeforeString_language(
            &self,
            string: &NSString,
            language: Option<&NSString>,
        ) -> bool;

        #[method(deletesAutospaceBetweenString:andString:language:)]
        pub unsafe fn deletesAutospaceBetweenString_andString_language(
            &self,
            preceding_string: &NSString,
            following_string: &NSString,
            language: Option<&NSString>,
        ) -> bool;

        #[method_id(@__retain_semantics Other availableLanguages)]
        pub unsafe fn availableLanguages(&self) -> Id<NSArray<NSString>>;

        #[method_id(@__retain_semantics Other userPreferredLanguages)]
        pub unsafe fn userPreferredLanguages(&self) -> Id<NSArray<NSString>>;

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

        #[method(setAutomaticallyIdentifiesLanguages:)]
        pub unsafe fn setAutomaticallyIdentifiesLanguages(
            &self,
            automatically_identifies_languages: bool,
        );

        #[method(setWordFieldStringValue:)]
        pub unsafe fn setWordFieldStringValue(&self, string: &NSString);

        #[method(learnWord:)]
        pub unsafe fn learnWord(&self, word: &NSString);

        #[method(hasLearnedWord:)]
        pub unsafe fn hasLearnedWord(&self, word: &NSString) -> bool;

        #[method(unlearnWord:)]
        pub unsafe fn unlearnWord(&self, word: &NSString);

        #[method(isAutomaticTextReplacementEnabled)]
        pub unsafe fn isAutomaticTextReplacementEnabled() -> bool;

        #[method(isAutomaticSpellingCorrectionEnabled)]
        pub unsafe fn isAutomaticSpellingCorrectionEnabled() -> bool;

        #[method(isAutomaticQuoteSubstitutionEnabled)]
        pub unsafe fn isAutomaticQuoteSubstitutionEnabled() -> bool;

        #[method(isAutomaticDashSubstitutionEnabled)]
        pub unsafe fn isAutomaticDashSubstitutionEnabled() -> bool;

        #[method(isAutomaticCapitalizationEnabled)]
        pub unsafe fn isAutomaticCapitalizationEnabled() -> bool;

        #[method(isAutomaticPeriodSubstitutionEnabled)]
        pub unsafe fn isAutomaticPeriodSubstitutionEnabled() -> bool;

        #[method(isAutomaticTextCompletionEnabled)]
        pub unsafe fn isAutomaticTextCompletionEnabled() -> bool;

        #[method(isAutomaticInlinePredictionEnabled)]
        pub unsafe fn isAutomaticInlinePredictionEnabled() -> bool;

        #[method_id(@__retain_semantics Other language)]
        pub unsafe fn language(&self) -> Id<NSString>;

        #[method(setLanguage:)]
        pub unsafe fn setLanguage(&self, language: &NSString) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSSpellChecker {
        #[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 "C" {
    pub static NSSpellCheckerDidChangeAutomaticSpellingCorrectionNotification:
        &'static NSNotificationName;
}

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

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

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

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

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

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

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

extern_methods!(
    /// NSDeprecated
    unsafe impl NSSpellChecker {
        #[deprecated = "Use -guessesForWordRange:inString:language:inSpellDocumentWithTag instead"]
        #[method_id(@__retain_semantics Other guessesForWord:)]
        pub unsafe fn guessesForWord(&self, word: Option<&NSString>) -> Option<Id<NSArray>>;

        #[deprecated]
        #[method(forgetWord:)]
        pub unsafe fn forgetWord(&self, word: Option<&NSString>);
    }
);