use core::ffi::*;
use core::ptr::NonNull;
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!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSSpellChecker;
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSSpellChecker {}
);
impl NSSpellChecker {
extern_methods!(
#[unsafe(method(sharedSpellChecker))]
#[unsafe(method_family = none)]
pub fn sharedSpellChecker() -> Retained<NSSpellChecker>;
#[unsafe(method(sharedSpellCheckerExists))]
#[unsafe(method_family = none)]
pub fn sharedSpellCheckerExists() -> bool;
#[unsafe(method(uniqueSpellDocumentTag))]
#[unsafe(method_family = none)]
pub fn uniqueSpellDocumentTag() -> NSInteger;
#[unsafe(method(checkSpellingOfString:startingAt:language:wrap:inSpellDocumentWithTag:wordCount:))]
#[unsafe(method_family = none)]
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;
#[unsafe(method(checkSpellingOfString:startingAt:))]
#[unsafe(method_family = none)]
pub fn checkSpellingOfString_startingAt(
&self,
string_to_check: &NSString,
starting_offset: NSInteger,
) -> NSRange;
#[unsafe(method(countWordsInString:language:))]
#[unsafe(method_family = none)]
pub fn countWordsInString_language(
&self,
string_to_count: &NSString,
language: Option<&NSString>,
) -> NSInteger;
#[unsafe(method(checkGrammarOfString:startingAt:language:wrap:inSpellDocumentWithTag:details:))]
#[unsafe(method_family = none)]
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<Retained<NSArray<NSDictionary<NSString, AnyObject>>>>>,
) -> NSRange;
#[unsafe(method(checkString:range:types:options:inSpellDocumentWithTag:orthography:wordCount:))]
#[unsafe(method_family = none)]
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<Retained<NSOrthography>>>,
word_count: *mut NSInteger,
) -> Retained<NSArray<NSTextCheckingResult>>;
#[cfg(feature = "block2")]
#[unsafe(method(requestCheckingOfString:range:types:options:inSpellDocumentWithTag:completionHandler:))]
#[unsafe(method_family = none)]
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<
&block2::DynBlock<
dyn Fn(
NSInteger,
NonNull<NSArray<NSTextCheckingResult>>,
NonNull<NSOrthography>,
NSInteger,
),
>,
>,
) -> NSInteger;
#[cfg(feature = "block2")]
#[unsafe(method(requestCandidatesForSelectedRange:inString:types:options:inSpellDocumentWithTag:completionHandler:))]
#[unsafe(method_family = none)]
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<
&block2::DynBlock<dyn Fn(NSInteger, NonNull<NSArray<NSTextCheckingResult>>)>,
>,
) -> NSInteger;
#[cfg(all(feature = "NSMenu", feature = "NSResponder", feature = "NSView"))]
#[unsafe(method(menuForResult:string:options:atLocation:inView:))]
#[unsafe(method_family = none)]
pub unsafe fn menuForResult_string_options_atLocation_inView(
&self,
result: &NSTextCheckingResult,
checked_string: &NSString,
options: Option<&NSDictionary<NSTextCheckingOptionKey, AnyObject>>,
location: NSPoint,
view: &NSView,
) -> Option<Retained<NSMenu>>;
#[unsafe(method(userQuotesArrayForLanguage:))]
#[unsafe(method_family = none)]
pub fn userQuotesArrayForLanguage(
&self,
language: &NSString,
) -> Retained<NSArray<NSString>>;
#[unsafe(method(userReplacementsDictionary))]
#[unsafe(method_family = none)]
pub fn userReplacementsDictionary(&self) -> Retained<NSDictionary<NSString, NSString>>;
#[unsafe(method(updateSpellingPanelWithMisspelledWord:))]
#[unsafe(method_family = none)]
pub fn updateSpellingPanelWithMisspelledWord(&self, word: &NSString);
#[unsafe(method(updateSpellingPanelWithGrammarString:detail:))]
#[unsafe(method_family = none)]
pub unsafe fn updateSpellingPanelWithGrammarString_detail(
&self,
string: &NSString,
detail: &NSDictionary<NSString, AnyObject>,
);
#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
#[unsafe(method(spellingPanel))]
#[unsafe(method_family = none)]
pub fn spellingPanel(&self, mtm: MainThreadMarker) -> Retained<NSPanel>;
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[unsafe(method(accessoryView))]
#[unsafe(method_family = none)]
pub fn accessoryView(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[unsafe(method(setAccessoryView:))]
#[unsafe(method_family = none)]
pub fn setAccessoryView(&self, accessory_view: Option<&NSView>);
#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
#[unsafe(method(substitutionsPanel))]
#[unsafe(method_family = none)]
pub fn substitutionsPanel(&self, mtm: MainThreadMarker) -> Retained<NSPanel>;
#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
#[unsafe(method(substitutionsPanelAccessoryViewController))]
#[unsafe(method_family = none)]
pub fn substitutionsPanelAccessoryViewController(
&self,
mtm: MainThreadMarker,
) -> Option<Retained<NSViewController>>;
#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
#[unsafe(method(setSubstitutionsPanelAccessoryViewController:))]
#[unsafe(method_family = none)]
pub fn setSubstitutionsPanelAccessoryViewController(
&self,
substitutions_panel_accessory_view_controller: Option<&NSViewController>,
);
#[unsafe(method(updatePanels))]
#[unsafe(method_family = none)]
pub fn updatePanels(&self);
#[unsafe(method(ignoreWord:inSpellDocumentWithTag:))]
#[unsafe(method_family = none)]
pub fn ignoreWord_inSpellDocumentWithTag(&self, word_to_ignore: &NSString, tag: NSInteger);
#[unsafe(method(ignoredWordsInSpellDocumentWithTag:))]
#[unsafe(method_family = none)]
pub fn ignoredWordsInSpellDocumentWithTag(
&self,
tag: NSInteger,
) -> Option<Retained<NSArray<NSString>>>;
#[unsafe(method(setIgnoredWords:inSpellDocumentWithTag:))]
#[unsafe(method_family = none)]
pub fn setIgnoredWords_inSpellDocumentWithTag(
&self,
words: &NSArray<NSString>,
tag: NSInteger,
);
#[unsafe(method(guessesForWordRange:inString:language:inSpellDocumentWithTag:))]
#[unsafe(method_family = none)]
pub fn guessesForWordRange_inString_language_inSpellDocumentWithTag(
&self,
range: NSRange,
string: &NSString,
language: Option<&NSString>,
tag: NSInteger,
) -> Option<Retained<NSArray<NSString>>>;
#[unsafe(method(correctionForWordRange:inString:language:inSpellDocumentWithTag:))]
#[unsafe(method_family = none)]
pub fn correctionForWordRange_inString_language_inSpellDocumentWithTag(
&self,
range: NSRange,
string: &NSString,
language: &NSString,
tag: NSInteger,
) -> Option<Retained<NSString>>;
#[unsafe(method(completionsForPartialWordRange:inString:language:inSpellDocumentWithTag:))]
#[unsafe(method_family = none)]
pub fn completionsForPartialWordRange_inString_language_inSpellDocumentWithTag(
&self,
range: NSRange,
string: &NSString,
language: Option<&NSString>,
tag: NSInteger,
) -> Option<Retained<NSArray<NSString>>>;
#[unsafe(method(languageForWordRange:inString:orthography:))]
#[unsafe(method_family = none)]
pub fn languageForWordRange_inString_orthography(
&self,
range: NSRange,
string: &NSString,
orthography: Option<&NSOrthography>,
) -> Option<Retained<NSString>>;
#[unsafe(method(closeSpellDocumentWithTag:))]
#[unsafe(method_family = none)]
pub fn closeSpellDocumentWithTag(&self, tag: NSInteger);
#[unsafe(method(recordResponse:toCorrection:forWord:language:inSpellDocumentWithTag:))]
#[unsafe(method_family = none)]
pub 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"))]
#[unsafe(method(showCorrectionIndicatorOfType:primaryString:alternativeStrings:forStringInRect:view:completionHandler:))]
#[unsafe(method_family = none)]
pub 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<&block2::DynBlock<dyn Fn(*mut NSString)>>,
);
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[unsafe(method(dismissCorrectionIndicatorForView:))]
#[unsafe(method_family = none)]
pub fn dismissCorrectionIndicatorForView(&self, view: &NSView);
#[cfg(feature = "NSTextInputClient")]
#[unsafe(method(showInlinePredictionForCandidates:client:))]
#[unsafe(method_family = none)]
pub fn showInlinePredictionForCandidates_client(
&self,
candidates: &NSArray<NSTextCheckingResult>,
client: &ProtocolObject<dyn NSTextInputClient>,
);
#[unsafe(method(preventsAutocorrectionBeforeString:language:))]
#[unsafe(method_family = none)]
pub fn preventsAutocorrectionBeforeString_language(
&self,
string: &NSString,
language: Option<&NSString>,
) -> bool;
#[unsafe(method(deletesAutospaceBetweenString:andString:language:))]
#[unsafe(method_family = none)]
pub fn deletesAutospaceBetweenString_andString_language(
&self,
preceding_string: &NSString,
following_string: &NSString,
language: Option<&NSString>,
) -> bool;
#[unsafe(method(availableLanguages))]
#[unsafe(method_family = none)]
pub fn availableLanguages(&self) -> Retained<NSArray<NSString>>;
#[unsafe(method(userPreferredLanguages))]
#[unsafe(method_family = none)]
pub fn userPreferredLanguages(&self) -> Retained<NSArray<NSString>>;
#[unsafe(method(automaticallyIdentifiesLanguages))]
#[unsafe(method_family = none)]
pub fn automaticallyIdentifiesLanguages(&self) -> bool;
#[unsafe(method(setAutomaticallyIdentifiesLanguages:))]
#[unsafe(method_family = none)]
pub fn setAutomaticallyIdentifiesLanguages(&self, automatically_identifies_languages: bool);
#[unsafe(method(setWordFieldStringValue:))]
#[unsafe(method_family = none)]
pub fn setWordFieldStringValue(&self, string: &NSString);
#[unsafe(method(learnWord:))]
#[unsafe(method_family = none)]
pub fn learnWord(&self, word: &NSString);
#[unsafe(method(hasLearnedWord:))]
#[unsafe(method_family = none)]
pub fn hasLearnedWord(&self, word: &NSString) -> bool;
#[unsafe(method(unlearnWord:))]
#[unsafe(method_family = none)]
pub fn unlearnWord(&self, word: &NSString);
#[unsafe(method(isAutomaticTextReplacementEnabled))]
#[unsafe(method_family = none)]
pub fn isAutomaticTextReplacementEnabled() -> bool;
#[unsafe(method(isAutomaticSpellingCorrectionEnabled))]
#[unsafe(method_family = none)]
pub fn isAutomaticSpellingCorrectionEnabled() -> bool;
#[unsafe(method(isAutomaticQuoteSubstitutionEnabled))]
#[unsafe(method_family = none)]
pub fn isAutomaticQuoteSubstitutionEnabled() -> bool;
#[unsafe(method(isAutomaticDashSubstitutionEnabled))]
#[unsafe(method_family = none)]
pub fn isAutomaticDashSubstitutionEnabled() -> bool;
#[unsafe(method(isAutomaticCapitalizationEnabled))]
#[unsafe(method_family = none)]
pub fn isAutomaticCapitalizationEnabled() -> bool;
#[unsafe(method(isAutomaticPeriodSubstitutionEnabled))]
#[unsafe(method_family = none)]
pub fn isAutomaticPeriodSubstitutionEnabled() -> bool;
#[unsafe(method(isAutomaticTextCompletionEnabled))]
#[unsafe(method_family = none)]
pub fn isAutomaticTextCompletionEnabled() -> bool;
#[unsafe(method(isAutomaticInlinePredictionEnabled))]
#[unsafe(method_family = none)]
pub fn isAutomaticInlinePredictionEnabled() -> bool;
#[unsafe(method(language))]
#[unsafe(method_family = none)]
pub fn language(&self) -> Retained<NSString>;
#[unsafe(method(setLanguage:))]
#[unsafe(method_family = none)]
pub fn setLanguage(&self, language: &NSString) -> bool;
);
}
impl NSSpellChecker {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for NSSpellChecker {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
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;
}
impl NSSpellChecker {
extern_methods!(
#[deprecated = "Use -guessesForWordRange:inString:language:inSpellDocumentWithTag instead"]
#[unsafe(method(guessesForWord:))]
#[unsafe(method_family = none)]
pub unsafe fn guessesForWord(&self, word: Option<&NSString>) -> Option<Retained<NSArray>>;
#[deprecated]
#[unsafe(method(forgetWord:))]
#[unsafe(method_family = none)]
pub unsafe fn forgetWord(&self, word: Option<&NSString>);
);
}