#[cfg(feature = "block2")]
use block2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
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;
}
#[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);
}
#[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!(
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!(
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>);
}
);