use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextFinderAction(pub NSInteger);
impl NSTextFinderAction {
#[doc(alias = "NSTextFinderActionShowFindInterface")]
pub const ShowFindInterface: Self = Self(1);
#[doc(alias = "NSTextFinderActionNextMatch")]
pub const NextMatch: Self = Self(2);
#[doc(alias = "NSTextFinderActionPreviousMatch")]
pub const PreviousMatch: Self = Self(3);
#[doc(alias = "NSTextFinderActionReplaceAll")]
pub const ReplaceAll: Self = Self(4);
#[doc(alias = "NSTextFinderActionReplace")]
pub const Replace: Self = Self(5);
#[doc(alias = "NSTextFinderActionReplaceAndFind")]
pub const ReplaceAndFind: Self = Self(6);
#[doc(alias = "NSTextFinderActionSetSearchString")]
pub const SetSearchString: Self = Self(7);
#[doc(alias = "NSTextFinderActionReplaceAllInSelection")]
pub const ReplaceAllInSelection: Self = Self(8);
#[doc(alias = "NSTextFinderActionSelectAll")]
pub const SelectAll: Self = Self(9);
#[doc(alias = "NSTextFinderActionSelectAllInSelection")]
pub const SelectAllInSelection: Self = Self(10);
#[doc(alias = "NSTextFinderActionHideFindInterface")]
pub const HideFindInterface: Self = Self(11);
#[doc(alias = "NSTextFinderActionShowReplaceInterface")]
pub const ShowReplaceInterface: Self = Self(12);
#[doc(alias = "NSTextFinderActionHideReplaceInterface")]
pub const HideReplaceInterface: Self = Self(13);
}
unsafe impl Encode for NSTextFinderAction {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSTextFinderAction {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
pub type NSPasteboardTypeTextFinderOptionKey = NSString;
extern "C" {
pub static NSTextFinderCaseInsensitiveKey: &'static NSPasteboardTypeTextFinderOptionKey;
}
extern "C" {
pub static NSTextFinderMatchingTypeKey: &'static NSPasteboardTypeTextFinderOptionKey;
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextFinderMatchingType(pub NSInteger);
impl NSTextFinderMatchingType {
#[doc(alias = "NSTextFinderMatchingTypeContains")]
pub const Contains: Self = Self(0);
#[doc(alias = "NSTextFinderMatchingTypeStartsWith")]
pub const StartsWith: Self = Self(1);
#[doc(alias = "NSTextFinderMatchingTypeFullWord")]
pub const FullWord: Self = Self(2);
#[doc(alias = "NSTextFinderMatchingTypeEndsWith")]
pub const EndsWith: Self = Self(3);
}
unsafe impl Encode for NSTextFinderMatchingType {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSTextFinderMatchingType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSTextFinder;
);
extern_conformance!(
unsafe impl NSCoding for NSTextFinder {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSTextFinder {}
);
impl NSTextFinder {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
#[unsafe(method(client))]
#[unsafe(method_family = none)]
pub unsafe fn client(&self) -> Option<Retained<ProtocolObject<dyn NSTextFinderClient>>>;
#[unsafe(method(setClient:))]
#[unsafe(method_family = none)]
pub unsafe fn setClient(&self, client: Option<&ProtocolObject<dyn NSTextFinderClient>>);
#[unsafe(method(performAction:))]
#[unsafe(method_family = none)]
pub fn performAction(&self, op: NSTextFinderAction);
#[unsafe(method(validateAction:))]
#[unsafe(method_family = none)]
pub fn validateAction(&self, op: NSTextFinderAction) -> bool;
#[unsafe(method(findBarContainer))]
#[unsafe(method_family = none)]
pub unsafe fn findBarContainer(
&self,
) -> Option<Retained<ProtocolObject<dyn NSTextFinderBarContainer>>>;
#[unsafe(method(setFindBarContainer:))]
#[unsafe(method_family = none)]
pub unsafe fn setFindBarContainer(
&self,
find_bar_container: Option<&ProtocolObject<dyn NSTextFinderBarContainer>>,
);
#[unsafe(method(cancelFindIndicator))]
#[unsafe(method_family = none)]
pub fn cancelFindIndicator(&self);
#[unsafe(method(findIndicatorNeedsUpdate))]
#[unsafe(method_family = none)]
pub fn findIndicatorNeedsUpdate(&self) -> bool;
#[unsafe(method(setFindIndicatorNeedsUpdate:))]
#[unsafe(method_family = none)]
pub fn setFindIndicatorNeedsUpdate(&self, find_indicator_needs_update: bool);
#[unsafe(method(isIncrementalSearchingEnabled))]
#[unsafe(method_family = none)]
pub fn isIncrementalSearchingEnabled(&self) -> bool;
#[unsafe(method(setIncrementalSearchingEnabled:))]
#[unsafe(method_family = none)]
pub fn setIncrementalSearchingEnabled(&self, incremental_searching_enabled: bool);
#[unsafe(method(incrementalSearchingShouldDimContentView))]
#[unsafe(method_family = none)]
pub fn incrementalSearchingShouldDimContentView(&self) -> bool;
#[unsafe(method(setIncrementalSearchingShouldDimContentView:))]
#[unsafe(method_family = none)]
pub fn setIncrementalSearchingShouldDimContentView(
&self,
incremental_searching_should_dim_content_view: bool,
);
#[unsafe(method(incrementalMatchRanges))]
#[unsafe(method_family = none)]
pub fn incrementalMatchRanges(&self) -> Retained<NSArray<NSValue>>;
#[unsafe(method(drawIncrementalMatchHighlightInRect:))]
#[unsafe(method_family = none)]
pub fn drawIncrementalMatchHighlightInRect(rect: NSRect);
#[unsafe(method(noteClientStringWillChange))]
#[unsafe(method_family = none)]
pub fn noteClientStringWillChange(&self);
);
}
impl NSTextFinder {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for NSTextFinder {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
extern_protocol!(
pub unsafe trait NSTextFinderClient: NSObjectProtocol {
#[optional]
#[unsafe(method(isSelectable))]
#[unsafe(method_family = none)]
fn isSelectable(&self) -> bool;
#[optional]
#[unsafe(method(allowsMultipleSelection))]
#[unsafe(method_family = none)]
fn allowsMultipleSelection(&self) -> bool;
#[optional]
#[unsafe(method(isEditable))]
#[unsafe(method_family = none)]
fn isEditable(&self) -> bool;
#[optional]
#[unsafe(method(string))]
#[unsafe(method_family = none)]
fn string(&self) -> Retained<NSString>;
#[optional]
#[unsafe(method(stringAtIndex:effectiveRange:endsWithSearchBoundary:))]
#[unsafe(method_family = none)]
unsafe fn stringAtIndex_effectiveRange_endsWithSearchBoundary(
&self,
character_index: NSUInteger,
out_range: NSRangePointer,
out_flag: NonNull<Bool>,
) -> Retained<NSString>;
#[optional]
#[unsafe(method(stringLength))]
#[unsafe(method_family = none)]
fn stringLength(&self) -> NSUInteger;
#[optional]
#[unsafe(method(firstSelectedRange))]
#[unsafe(method_family = none)]
fn firstSelectedRange(&self) -> NSRange;
#[optional]
#[unsafe(method(selectedRanges))]
#[unsafe(method_family = none)]
fn selectedRanges(&self) -> Retained<NSArray<NSValue>>;
#[optional]
#[unsafe(method(setSelectedRanges:))]
#[unsafe(method_family = none)]
fn setSelectedRanges(&self, selected_ranges: &NSArray<NSValue>);
#[optional]
#[unsafe(method(scrollRangeToVisible:))]
#[unsafe(method_family = none)]
fn scrollRangeToVisible(&self, range: NSRange);
#[optional]
#[unsafe(method(shouldReplaceCharactersInRanges:withStrings:))]
#[unsafe(method_family = none)]
fn shouldReplaceCharactersInRanges_withStrings(
&self,
ranges: &NSArray<NSValue>,
strings: &NSArray<NSString>,
) -> bool;
#[optional]
#[unsafe(method(replaceCharactersInRange:withString:))]
#[unsafe(method_family = none)]
fn replaceCharactersInRange_withString(&self, range: NSRange, string: &NSString);
#[optional]
#[unsafe(method(didReplaceCharacters))]
#[unsafe(method_family = none)]
fn didReplaceCharacters(&self);
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[optional]
#[unsafe(method(contentViewAtIndex:effectiveCharacterRange:))]
#[unsafe(method_family = none)]
unsafe fn contentViewAtIndex_effectiveCharacterRange(
&self,
index: NSUInteger,
out_range: NSRangePointer,
mtm: MainThreadMarker,
) -> Retained<NSView>;
#[optional]
#[unsafe(method(rectsForCharacterRange:))]
#[unsafe(method_family = none)]
fn rectsForCharacterRange(&self, range: NSRange) -> Option<Retained<NSArray<NSValue>>>;
#[optional]
#[unsafe(method(visibleCharacterRanges))]
#[unsafe(method_family = none)]
fn visibleCharacterRanges(&self) -> Retained<NSArray<NSValue>>;
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[optional]
#[unsafe(method(drawCharactersInRange:forContentView:))]
#[unsafe(method_family = none)]
fn drawCharactersInRange_forContentView(&self, range: NSRange, view: &NSView);
}
);
extern_protocol!(
pub unsafe trait NSTextFinderBarContainer: NSObjectProtocol {
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[unsafe(method(findBarView))]
#[unsafe(method_family = none)]
fn findBarView(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[unsafe(method(setFindBarView:))]
#[unsafe(method_family = none)]
fn setFindBarView(&self, find_bar_view: Option<&NSView>);
#[unsafe(method(isFindBarVisible))]
#[unsafe(method_family = none)]
fn isFindBarVisible(&self) -> bool;
#[unsafe(method(setFindBarVisible:))]
#[unsafe(method_family = none)]
fn setFindBarVisible(&self, find_bar_visible: bool);
#[unsafe(method(findBarViewDidChangeHeight))]
#[unsafe(method_family = none)]
fn findBarViewDidChangeHeight(&self);
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[optional]
#[unsafe(method(contentView))]
#[unsafe(method_family = none)]
fn contentView(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
}
);