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 NSTextStorageEditActions(pub NSUInteger);
bitflags::bitflags! {
impl NSTextStorageEditActions: NSUInteger {
#[doc(alias = "NSTextStorageEditedAttributes")]
const EditedAttributes = 1<<0;
#[doc(alias = "NSTextStorageEditedCharacters")]
const EditedCharacters = 1<<1;
}
}
unsafe impl Encode for NSTextStorageEditActions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSTextStorageEditActions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSMutableAttributedString, NSAttributedString, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSTextStorage;
);
extern_conformance!(
unsafe impl NSCoding for NSTextStorage {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSTextStorage {}
);
extern_conformance!(
unsafe impl NSSecureCoding for NSTextStorage {}
);
impl NSTextStorage {
extern_methods!(
#[cfg(feature = "NSLayoutManager")]
#[unsafe(method(layoutManagers))]
#[unsafe(method_family = none)]
pub fn layoutManagers(&self) -> Retained<NSArray<NSLayoutManager>>;
#[cfg(feature = "NSLayoutManager")]
#[unsafe(method(addLayoutManager:))]
#[unsafe(method_family = none)]
pub fn addLayoutManager(&self, a_layout_manager: &NSLayoutManager);
#[cfg(feature = "NSLayoutManager")]
#[unsafe(method(removeLayoutManager:))]
#[unsafe(method_family = none)]
pub fn removeLayoutManager(&self, a_layout_manager: &NSLayoutManager);
#[unsafe(method(editedMask))]
#[unsafe(method_family = none)]
pub fn editedMask(&self) -> NSTextStorageEditActions;
#[unsafe(method(editedRange))]
#[unsafe(method_family = none)]
pub fn editedRange(&self) -> NSRange;
#[unsafe(method(changeInLength))]
#[unsafe(method_family = none)]
pub fn changeInLength(&self) -> NSInteger;
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSTextStorageDelegate>>>;
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSTextStorageDelegate>>);
#[unsafe(method(edited:range:changeInLength:))]
#[unsafe(method_family = none)]
pub fn edited_range_changeInLength(
&self,
edited_mask: NSTextStorageEditActions,
edited_range: NSRange,
delta: NSInteger,
);
#[unsafe(method(processEditing))]
#[unsafe(method_family = none)]
pub fn processEditing(&self);
#[unsafe(method(fixesAttributesLazily))]
#[unsafe(method_family = none)]
pub fn fixesAttributesLazily(&self) -> bool;
#[unsafe(method(invalidateAttributesInRange:))]
#[unsafe(method_family = none)]
pub fn invalidateAttributesInRange(&self, range: NSRange);
#[unsafe(method(ensureAttributesAreFixedInRange:))]
#[unsafe(method_family = none)]
pub fn ensureAttributesAreFixedInRange(&self, range: NSRange);
#[unsafe(method(textStorageObserver))]
#[unsafe(method_family = none)]
pub fn textStorageObserver(
&self,
) -> Option<Retained<ProtocolObject<dyn NSTextStorageObserving>>>;
#[unsafe(method(setTextStorageObserver:))]
#[unsafe(method_family = none)]
pub fn setTextStorageObserver(
&self,
text_storage_observer: Option<&ProtocolObject<dyn NSTextStorageObserving>>,
);
);
}
impl NSTextStorage {
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 NSTextStorage {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
extern_protocol!(
pub unsafe trait NSTextStorageDelegate: NSObjectProtocol {
#[optional]
#[unsafe(method(textStorage:willProcessEditing:range:changeInLength:))]
#[unsafe(method_family = none)]
fn textStorage_willProcessEditing_range_changeInLength(
&self,
text_storage: &NSTextStorage,
edited_mask: NSTextStorageEditActions,
edited_range: NSRange,
delta: NSInteger,
);
#[optional]
#[unsafe(method(textStorage:didProcessEditing:range:changeInLength:))]
#[unsafe(method_family = none)]
fn textStorage_didProcessEditing_range_changeInLength(
&self,
text_storage: &NSTextStorage,
edited_mask: NSTextStorageEditActions,
edited_range: NSRange,
delta: NSInteger,
);
}
);
extern "C" {
pub static NSTextStorageWillProcessEditingNotification: &'static NSNotificationName;
}
extern "C" {
pub static NSTextStorageDidProcessEditingNotification: &'static NSNotificationName;
}
extern_protocol!(
pub unsafe trait NSTextStorageObserving: NSObjectProtocol {
#[unsafe(method(textStorage))]
#[unsafe(method_family = none)]
fn textStorage(&self) -> Option<Retained<NSTextStorage>>;
#[unsafe(method(setTextStorage:))]
#[unsafe(method_family = none)]
fn setTextStorage(&self, text_storage: Option<&NSTextStorage>);
#[unsafe(method(processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:))]
#[unsafe(method_family = none)]
fn processEditingForTextStorage_edited_range_changeInLength_invalidatedRange(
&self,
text_storage: &NSTextStorage,
edit_mask: NSTextStorageEditActions,
new_char_range: NSRange,
delta: NSInteger,
invalidated_char_range: NSRange,
);
#[cfg(feature = "block2")]
#[unsafe(method(performEditingTransactionForTextStorage:usingBlock:))]
#[unsafe(method_family = none)]
fn performEditingTransactionForTextStorage_usingBlock(
&self,
text_storage: &NSTextStorage,
transaction: &block2::DynBlock<dyn Fn() + '_>,
);
}
);
pub type NSTextStorageEditedOptions = NSUInteger;