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 NSWritingDirection(pub NSInteger);
impl NSWritingDirection {
#[doc(alias = "NSWritingDirectionNatural")]
pub const Natural: Self = Self(-1);
#[doc(alias = "NSWritingDirectionLeftToRight")]
pub const LeftToRight: Self = Self(0);
#[doc(alias = "NSWritingDirectionRightToLeft")]
pub const RightToLeft: Self = Self(1);
}
unsafe impl Encode for NSWritingDirection {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSWritingDirection {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextAlignment(pub NSInteger);
impl NSTextAlignment {
#[doc(alias = "NSTextAlignmentLeft")]
pub const Left: Self = Self(0);
#[doc(alias = "NSTextAlignmentJustified")]
pub const Justified: Self = Self(3);
#[doc(alias = "NSTextAlignmentNatural")]
pub const Natural: Self = Self(4);
}
unsafe impl Encode for NSTextAlignment {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSTextAlignment {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSView, NSResponder, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
pub struct NSText;
);
#[cfg(all(
feature = "NSAccessibilityProtocols",
feature = "NSResponder",
feature = "NSView"
))]
extern_conformance!(
unsafe impl NSAccessibility for NSText {}
);
#[cfg(all(
feature = "NSAccessibilityProtocols",
feature = "NSResponder",
feature = "NSView"
))]
extern_conformance!(
unsafe impl NSAccessibilityElementProtocol for NSText {}
);
#[cfg(all(feature = "NSAnimation", feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
unsafe impl NSAnimatablePropertyContainer for NSText {}
);
#[cfg(all(feature = "NSAppearance", feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
unsafe impl NSAppearanceCustomization for NSText {}
);
#[cfg(all(
feature = "NSResponder",
feature = "NSSpellProtocol",
feature = "NSView"
))]
extern_conformance!(
unsafe impl NSChangeSpelling for NSText {}
);
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
unsafe impl NSCoding for NSText {}
);
#[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
unsafe impl NSDraggingDestination for NSText {}
);
#[cfg(all(
feature = "NSResponder",
feature = "NSSpellProtocol",
feature = "NSView"
))]
extern_conformance!(
unsafe impl NSIgnoreMisspelledWords for NSText {}
);
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
extern_conformance!(
unsafe impl NSObjectProtocol for NSText {}
);
#[cfg(all(
feature = "NSResponder",
feature = "NSUserInterfaceItemIdentification",
feature = "NSView"
))]
extern_conformance!(
unsafe impl NSUserInterfaceItemIdentification for NSText {}
);
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSText {
extern_methods!(
#[unsafe(method(initWithFrame:))]
#[unsafe(method_family = init)]
pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
#[unsafe(method(string))]
#[unsafe(method_family = none)]
pub fn string(&self) -> Retained<NSString>;
#[unsafe(method(setString:))]
#[unsafe(method_family = none)]
pub fn setString(&self, string: &NSString);
#[unsafe(method(replaceCharactersInRange:withString:))]
#[unsafe(method_family = none)]
pub fn replaceCharactersInRange_withString(&self, range: NSRange, string: &NSString);
#[unsafe(method(replaceCharactersInRange:withRTF:))]
#[unsafe(method_family = none)]
pub fn replaceCharactersInRange_withRTF(&self, range: NSRange, rtf_data: &NSData);
#[unsafe(method(replaceCharactersInRange:withRTFD:))]
#[unsafe(method_family = none)]
pub fn replaceCharactersInRange_withRTFD(&self, range: NSRange, rtfd_data: &NSData);
#[unsafe(method(RTFFromRange:))]
#[unsafe(method_family = none)]
pub fn RTFFromRange(&self, range: NSRange) -> Option<Retained<NSData>>;
#[unsafe(method(RTFDFromRange:))]
#[unsafe(method_family = none)]
pub fn RTFDFromRange(&self, range: NSRange) -> Option<Retained<NSData>>;
#[unsafe(method(writeRTFDToFile:atomically:))]
#[unsafe(method_family = none)]
pub fn writeRTFDToFile_atomically(&self, path: &NSString, flag: bool) -> bool;
#[unsafe(method(readRTFDFromFile:))]
#[unsafe(method_family = none)]
pub fn readRTFDFromFile(&self, path: &NSString) -> bool;
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSTextDelegate>>>;
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSTextDelegate>>);
#[unsafe(method(isEditable))]
#[unsafe(method_family = none)]
pub fn isEditable(&self) -> bool;
#[unsafe(method(setEditable:))]
#[unsafe(method_family = none)]
pub fn setEditable(&self, editable: bool);
#[unsafe(method(isSelectable))]
#[unsafe(method_family = none)]
pub fn isSelectable(&self) -> bool;
#[unsafe(method(setSelectable:))]
#[unsafe(method_family = none)]
pub fn setSelectable(&self, selectable: bool);
#[unsafe(method(isRichText))]
#[unsafe(method_family = none)]
pub fn isRichText(&self) -> bool;
#[unsafe(method(setRichText:))]
#[unsafe(method_family = none)]
pub fn setRichText(&self, rich_text: bool);
#[unsafe(method(importsGraphics))]
#[unsafe(method_family = none)]
pub fn importsGraphics(&self) -> bool;
#[unsafe(method(setImportsGraphics:))]
#[unsafe(method_family = none)]
pub fn setImportsGraphics(&self, imports_graphics: bool);
#[unsafe(method(isFieldEditor))]
#[unsafe(method_family = none)]
pub fn isFieldEditor(&self) -> bool;
#[unsafe(method(setFieldEditor:))]
#[unsafe(method_family = none)]
pub fn setFieldEditor(&self, field_editor: bool);
#[unsafe(method(usesFontPanel))]
#[unsafe(method_family = none)]
pub fn usesFontPanel(&self) -> bool;
#[unsafe(method(setUsesFontPanel:))]
#[unsafe(method_family = none)]
pub fn setUsesFontPanel(&self, uses_font_panel: bool);
#[unsafe(method(drawsBackground))]
#[unsafe(method_family = none)]
pub fn drawsBackground(&self) -> bool;
#[unsafe(method(setDrawsBackground:))]
#[unsafe(method_family = none)]
pub fn setDrawsBackground(&self, draws_background: bool);
#[cfg(feature = "NSColor")]
#[unsafe(method(backgroundColor))]
#[unsafe(method_family = none)]
pub fn backgroundColor(&self) -> Option<Retained<NSColor>>;
#[cfg(feature = "NSColor")]
#[unsafe(method(setBackgroundColor:))]
#[unsafe(method_family = none)]
pub fn setBackgroundColor(&self, background_color: Option<&NSColor>);
#[unsafe(method(isRulerVisible))]
#[unsafe(method_family = none)]
pub fn isRulerVisible(&self) -> bool;
#[unsafe(method(selectedRange))]
#[unsafe(method_family = none)]
pub fn selectedRange(&self) -> NSRange;
#[unsafe(method(setSelectedRange:))]
#[unsafe(method_family = none)]
pub fn setSelectedRange(&self, selected_range: NSRange);
#[unsafe(method(scrollRangeToVisible:))]
#[unsafe(method_family = none)]
pub fn scrollRangeToVisible(&self, range: NSRange);
#[cfg(feature = "NSFont")]
#[unsafe(method(font))]
#[unsafe(method_family = none)]
pub fn font(&self) -> Option<Retained<NSFont>>;
#[cfg(feature = "NSFont")]
#[unsafe(method(setFont:))]
#[unsafe(method_family = none)]
pub fn setFont(&self, font: Option<&NSFont>);
#[cfg(feature = "NSColor")]
#[unsafe(method(textColor))]
#[unsafe(method_family = none)]
pub fn textColor(&self) -> Option<Retained<NSColor>>;
#[cfg(feature = "NSColor")]
#[unsafe(method(setTextColor:))]
#[unsafe(method_family = none)]
pub fn setTextColor(&self, text_color: Option<&NSColor>);
#[unsafe(method(alignment))]
#[unsafe(method_family = none)]
pub fn alignment(&self) -> NSTextAlignment;
#[unsafe(method(setAlignment:))]
#[unsafe(method_family = none)]
pub fn setAlignment(&self, alignment: NSTextAlignment);
#[unsafe(method(baseWritingDirection))]
#[unsafe(method_family = none)]
pub fn baseWritingDirection(&self) -> NSWritingDirection;
#[unsafe(method(setBaseWritingDirection:))]
#[unsafe(method_family = none)]
pub fn setBaseWritingDirection(&self, base_writing_direction: NSWritingDirection);
#[cfg(feature = "NSColor")]
#[unsafe(method(setTextColor:range:))]
#[unsafe(method_family = none)]
pub fn setTextColor_range(&self, color: Option<&NSColor>, range: NSRange);
#[cfg(feature = "NSFont")]
#[unsafe(method(setFont:range:))]
#[unsafe(method_family = none)]
pub fn setFont_range(&self, font: &NSFont, range: NSRange);
#[unsafe(method(maxSize))]
#[unsafe(method_family = none)]
pub fn maxSize(&self) -> NSSize;
#[unsafe(method(setMaxSize:))]
#[unsafe(method_family = none)]
pub fn setMaxSize(&self, max_size: NSSize);
#[unsafe(method(minSize))]
#[unsafe(method_family = none)]
pub fn minSize(&self) -> NSSize;
#[unsafe(method(setMinSize:))]
#[unsafe(method_family = none)]
pub fn setMinSize(&self, min_size: NSSize);
#[unsafe(method(isHorizontallyResizable))]
#[unsafe(method_family = none)]
pub fn isHorizontallyResizable(&self) -> bool;
#[unsafe(method(setHorizontallyResizable:))]
#[unsafe(method_family = none)]
pub fn setHorizontallyResizable(&self, horizontally_resizable: bool);
#[unsafe(method(isVerticallyResizable))]
#[unsafe(method_family = none)]
pub fn isVerticallyResizable(&self) -> bool;
#[unsafe(method(setVerticallyResizable:))]
#[unsafe(method_family = none)]
pub fn setVerticallyResizable(&self, vertically_resizable: bool);
#[unsafe(method(sizeToFit))]
#[unsafe(method_family = none)]
pub fn sizeToFit(&self);
#[unsafe(method(copy:))]
#[unsafe(method_family = none)]
pub unsafe fn copy(&self, sender: Option<&AnyObject>);
#[unsafe(method(copyFont:))]
#[unsafe(method_family = none)]
pub unsafe fn copyFont(&self, sender: Option<&AnyObject>);
#[unsafe(method(copyRuler:))]
#[unsafe(method_family = none)]
pub unsafe fn copyRuler(&self, sender: Option<&AnyObject>);
#[unsafe(method(cut:))]
#[unsafe(method_family = none)]
pub unsafe fn cut(&self, sender: Option<&AnyObject>);
#[unsafe(method(delete:))]
#[unsafe(method_family = none)]
pub unsafe fn delete(&self, sender: Option<&AnyObject>);
#[unsafe(method(paste:))]
#[unsafe(method_family = none)]
pub unsafe fn paste(&self, sender: Option<&AnyObject>);
#[unsafe(method(pasteFont:))]
#[unsafe(method_family = none)]
pub unsafe fn pasteFont(&self, sender: Option<&AnyObject>);
#[unsafe(method(pasteRuler:))]
#[unsafe(method_family = none)]
pub unsafe fn pasteRuler(&self, sender: Option<&AnyObject>);
#[unsafe(method(selectAll:))]
#[unsafe(method_family = none)]
pub unsafe fn selectAll(&self, sender: Option<&AnyObject>);
#[unsafe(method(changeFont:))]
#[unsafe(method_family = none)]
pub unsafe fn changeFont(&self, sender: Option<&AnyObject>);
#[unsafe(method(alignLeft:))]
#[unsafe(method_family = none)]
pub unsafe fn alignLeft(&self, sender: Option<&AnyObject>);
#[unsafe(method(alignRight:))]
#[unsafe(method_family = none)]
pub unsafe fn alignRight(&self, sender: Option<&AnyObject>);
#[unsafe(method(alignCenter:))]
#[unsafe(method_family = none)]
pub unsafe fn alignCenter(&self, sender: Option<&AnyObject>);
#[unsafe(method(subscript:))]
#[unsafe(method_family = none)]
pub unsafe fn subscript(&self, sender: Option<&AnyObject>);
#[unsafe(method(superscript:))]
#[unsafe(method_family = none)]
pub unsafe fn superscript(&self, sender: Option<&AnyObject>);
#[unsafe(method(underline:))]
#[unsafe(method_family = none)]
pub unsafe fn underline(&self, sender: Option<&AnyObject>);
#[unsafe(method(unscript:))]
#[unsafe(method_family = none)]
pub unsafe fn unscript(&self, sender: Option<&AnyObject>);
#[unsafe(method(showGuessPanel:))]
#[unsafe(method_family = none)]
pub unsafe fn showGuessPanel(&self, sender: Option<&AnyObject>);
#[unsafe(method(checkSpelling:))]
#[unsafe(method_family = none)]
pub unsafe fn checkSpelling(&self, sender: Option<&AnyObject>);
#[unsafe(method(toggleRuler:))]
#[unsafe(method_family = none)]
pub unsafe fn toggleRuler(&self, sender: Option<&AnyObject>);
);
}
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSText {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
impl NSText {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
pub const NSEnterCharacter: c_uint = 0x0003;
pub const NSBackspaceCharacter: c_uint = 0x0008;
pub const NSTabCharacter: c_uint = 0x0009;
pub const NSNewlineCharacter: c_uint = 0x000a;
pub const NSFormFeedCharacter: c_uint = 0x000c;
pub const NSCarriageReturnCharacter: c_uint = 0x000d;
pub const NSBackTabCharacter: c_uint = 0x0019;
pub const NSDeleteCharacter: c_uint = 0x007f;
pub const NSLineSeparatorCharacter: c_uint = 0x2028;
pub const NSParagraphSeparatorCharacter: c_uint = 0x2029;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextMovement(pub NSInteger);
impl NSTextMovement {
#[doc(alias = "NSTextMovementReturn")]
pub const Return: Self = Self(0x10);
#[doc(alias = "NSTextMovementTab")]
pub const Tab: Self = Self(0x11);
#[doc(alias = "NSTextMovementBacktab")]
pub const Backtab: Self = Self(0x12);
#[doc(alias = "NSTextMovementLeft")]
pub const Left: Self = Self(0x13);
#[doc(alias = "NSTextMovementRight")]
pub const Right: Self = Self(0x14);
#[doc(alias = "NSTextMovementUp")]
pub const Up: Self = Self(0x15);
#[doc(alias = "NSTextMovementDown")]
pub const Down: Self = Self(0x16);
#[doc(alias = "NSTextMovementCancel")]
pub const Cancel: Self = Self(0x17);
#[doc(alias = "NSTextMovementOther")]
pub const Other: Self = Self(0);
}
unsafe impl Encode for NSTextMovement {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSTextMovement {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
pub static NSTextDidBeginEditingNotification: &'static NSNotificationName;
}
extern "C" {
pub static NSTextDidEndEditingNotification: &'static NSNotificationName;
}
extern "C" {
pub static NSTextDidChangeNotification: &'static NSNotificationName;
}
extern "C" {
pub static NSTextMovementUserInfoKey: &'static NSString;
}
pub const NSIllegalTextMovement: c_uint = 0;
pub const NSReturnTextMovement: c_uint = 0x10;
pub const NSTabTextMovement: c_uint = 0x11;
pub const NSBacktabTextMovement: c_uint = 0x12;
pub const NSLeftTextMovement: c_uint = 0x13;
pub const NSRightTextMovement: c_uint = 0x14;
pub const NSUpTextMovement: c_uint = 0x15;
pub const NSDownTextMovement: c_uint = 0x16;
pub const NSCancelTextMovement: c_uint = 0x17;
pub const NSOtherTextMovement: c_uint = 0;
extern_protocol!(
pub unsafe trait NSTextDelegate: NSObjectProtocol + MainThreadOnly {
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[optional]
#[unsafe(method(textShouldBeginEditing:))]
#[unsafe(method_family = none)]
fn textShouldBeginEditing(&self, text_object: &NSText) -> bool;
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[optional]
#[unsafe(method(textShouldEndEditing:))]
#[unsafe(method_family = none)]
fn textShouldEndEditing(&self, text_object: &NSText) -> bool;
#[optional]
#[unsafe(method(textDidBeginEditing:))]
#[unsafe(method_family = none)]
fn textDidBeginEditing(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(textDidEndEditing:))]
#[unsafe(method_family = none)]
fn textDidEndEditing(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(textDidChange:))]
#[unsafe(method_family = none)]
fn textDidChange(&self, notification: &NSNotification);
}
);
#[deprecated = "Use NSWritingDirectionEmbedding instead"]
pub const NSTextWritingDirectionEmbedding: c_uint = 0 << 1;
#[deprecated = "Use NSWritingDirectionOverride instead"]
pub const NSTextWritingDirectionOverride: c_uint = 1 << 1;
#[deprecated]
pub static NSLeftTextAlignment: NSTextAlignment = NSTextAlignment(NSTextAlignment::Left.0);
#[deprecated]
pub static NSRightTextAlignment: NSTextAlignment = NSTextAlignment(NSTextAlignment::Right.0);
#[deprecated]
pub static NSCenterTextAlignment: NSTextAlignment = NSTextAlignment(NSTextAlignment::Center.0);
#[deprecated]
pub static NSJustifiedTextAlignment: NSTextAlignment =
NSTextAlignment(NSTextAlignment::Justified.0);
#[deprecated]
pub static NSNaturalTextAlignment: NSTextAlignment = NSTextAlignment(NSTextAlignment::Natural.0);