#[repr(C)]pub struct NSTextStorage { /* private fields */ }
NSTextStorage
only.Expand description
Implementations§
Source§impl NSTextStorage
impl NSTextStorage
Sourcepub unsafe fn layoutManagers(&self) -> Retained<NSArray<NSLayoutManager>>
Available on crate feature NSLayoutManager
only.
pub unsafe fn layoutManagers(&self) -> Retained<NSArray<NSLayoutManager>>
NSLayoutManager
only.************************** Layout manager ***************************
pub unsafe fn addLayoutManager(&self, a_layout_manager: &NSLayoutManager)
NSLayoutManager
only.pub unsafe fn removeLayoutManager(&self, a_layout_manager: &NSLayoutManager)
NSLayoutManager
only.Sourcepub unsafe fn editedMask(&self) -> NSTextStorageEditActions
pub unsafe fn editedMask(&self) -> NSTextStorageEditActions
************************** Pending edit info ***************************
pub unsafe fn editedRange(&self) -> NSRange
pub unsafe fn changeInLength(&self) -> NSInteger
Sourcepub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn NSTextStorageDelegate>>>
pub unsafe fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn NSTextStorageDelegate>>>
************************** Delegate ***************************
Sourcepub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn NSTextStorageDelegate>>,
)
pub unsafe fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn NSTextStorageDelegate>>, )
This is a weak property.
Setter for delegate
.
Sourcepub unsafe fn edited_range_changeInLength(
&self,
edited_mask: NSTextStorageEditActions,
edited_range: NSRange,
delta: NSInteger,
)
pub unsafe fn edited_range_changeInLength( &self, edited_mask: NSTextStorageEditActions, edited_range: NSRange, delta: NSInteger, )
************************** Edit management ***************************
pub unsafe fn processEditing(&self)
Sourcepub unsafe fn fixesAttributesLazily(&self) -> bool
pub unsafe fn fixesAttributesLazily(&self) -> bool
************************** Attribute fixing ***************************
pub unsafe fn invalidateAttributesInRange(&self, range: NSRange)
pub unsafe fn ensureAttributesAreFixedInRange(&self, range: NSRange)
Sourcepub unsafe fn textStorageObserver(
&self,
) -> Option<Retained<ProtocolObject<dyn NSTextStorageObserving>>>
pub unsafe fn textStorageObserver( &self, ) -> Option<Retained<ProtocolObject<dyn NSTextStorageObserving>>>
************************** NSTextStorageObserving ***************************
Sourcepub unsafe fn setTextStorageObserver(
&self,
text_storage_observer: Option<&ProtocolObject<dyn NSTextStorageObserving>>,
)
pub unsafe fn setTextStorageObserver( &self, text_storage_observer: Option<&ProtocolObject<dyn NSTextStorageObserving>>, )
This is a weak property.
Setter for textStorageObserver
.
Source§impl NSTextStorage
Methods declared on superclass NSObject
.
impl NSTextStorage
Methods declared on superclass NSObject
.
Source§impl NSTextStorage
Scripting.
impl NSTextStorage
Scripting.
pub unsafe fn attributeRuns(&self) -> Retained<NSArray<NSTextStorage>>
NSTextStorageScripting
only.Sourcepub unsafe fn setAttributeRuns(&self, attribute_runs: &NSArray<NSTextStorage>)
Available on crate feature NSTextStorageScripting
only.
pub unsafe fn setAttributeRuns(&self, attribute_runs: &NSArray<NSTextStorage>)
NSTextStorageScripting
only.Setter for attributeRuns
.
pub unsafe fn paragraphs(&self) -> Retained<NSArray<NSTextStorage>>
NSTextStorageScripting
only.Sourcepub unsafe fn setParagraphs(&self, paragraphs: &NSArray<NSTextStorage>)
Available on crate feature NSTextStorageScripting
only.
pub unsafe fn setParagraphs(&self, paragraphs: &NSArray<NSTextStorage>)
NSTextStorageScripting
only.Setter for paragraphs
.
pub unsafe fn words(&self) -> Retained<NSArray<NSTextStorage>>
NSTextStorageScripting
only.Sourcepub unsafe fn setWords(&self, words: &NSArray<NSTextStorage>)
Available on crate feature NSTextStorageScripting
only.
pub unsafe fn setWords(&self, words: &NSArray<NSTextStorage>)
NSTextStorageScripting
only.Setter for words
.
pub unsafe fn characters(&self) -> Retained<NSArray<NSTextStorage>>
NSTextStorageScripting
only.Sourcepub unsafe fn setCharacters(&self, characters: &NSArray<NSTextStorage>)
Available on crate feature NSTextStorageScripting
only.
pub unsafe fn setCharacters(&self, characters: &NSArray<NSTextStorage>)
NSTextStorageScripting
only.Setter for characters
.
pub unsafe fn font(&self) -> Option<Retained<NSFont>>
NSTextStorageScripting
and NSFont
only.Sourcepub unsafe fn setFont(&self, font: Option<&NSFont>)
Available on crate features NSTextStorageScripting
and NSFont
only.
pub unsafe fn setFont(&self, font: Option<&NSFont>)
NSTextStorageScripting
and NSFont
only.Setter for font
.
pub unsafe fn foregroundColor(&self) -> Option<Retained<NSColor>>
NSTextStorageScripting
and NSColor
only.Sourcepub unsafe fn setForegroundColor(&self, foreground_color: Option<&NSColor>)
Available on crate features NSTextStorageScripting
and NSColor
only.
pub unsafe fn setForegroundColor(&self, foreground_color: Option<&NSColor>)
NSTextStorageScripting
and NSColor
only.Setter for foregroundColor
.
Methods from Deref<Target = NSMutableAttributedString>§
pub unsafe fn replaceCharactersInRange_withString( &self, range: NSRange, str: &NSString, )
pub unsafe fn setAttributes_range( &self, attrs: Option<&NSDictionary<NSString>>, range: NSRange, )
pub unsafe fn mutableString(&self) -> Retained<NSMutableString>
pub unsafe fn addAttribute_value_range( &self, name: &NSString, value: &AnyObject, range: NSRange, )
pub unsafe fn addAttributes_range( &self, attrs: &NSDictionary<NSString>, range: NSRange, )
pub unsafe fn removeAttribute_range(&self, name: &NSString, range: NSRange)
pub unsafe fn replaceCharactersInRange_withAttributedString( &self, range: NSRange, attr_string: &NSAttributedString, )
pub unsafe fn insertAttributedString_atIndex( &self, attr_string: &NSAttributedString, loc: usize, )
pub unsafe fn appendAttributedString(&self, attr_string: &NSAttributedString)
pub unsafe fn deleteCharactersInRange(&self, range: NSRange)
pub fn setAttributedString(&self, attr_string: &NSAttributedString)
pub unsafe fn beginEditing(&self)
pub unsafe fn endEditing(&self)
Methods from Deref<Target = NSAttributedString>§
pub fn string(&self) -> Retained<NSString>
pub unsafe fn attributesAtIndex_effectiveRange( &self, location: usize, range: *mut NSRange, ) -> Retained<NSDictionary<NSString>>
pub fn length(&self) -> usize
pub unsafe fn attribute_atIndex_effectiveRange( &self, attr_name: &NSString, location: usize, range: *mut NSRange, ) -> Option<Retained<AnyObject>>
pub unsafe fn attributedSubstringFromRange( &self, range: NSRange, ) -> Retained<NSAttributedString>
pub unsafe fn attributesAtIndex_longestEffectiveRange_inRange( &self, location: usize, range: *mut NSRange, range_limit: NSRange, ) -> Retained<NSDictionary<NSString>>
pub unsafe fn attribute_atIndex_longestEffectiveRange_inRange( &self, attr_name: &NSString, location: usize, range: *mut NSRange, range_limit: NSRange, ) -> Option<Retained<AnyObject>>
pub unsafe fn isEqualToAttributedString( &self, other: &NSAttributedString, ) -> bool
Sourcepub unsafe fn attributedStringByInflectingString(
&self,
) -> Retained<NSAttributedString>
pub unsafe fn attributedStringByInflectingString( &self, ) -> Retained<NSAttributedString>
If the string has portions tagged with NSInflectionRuleAttributeName that have no format specifiers, create a new string with those portions inflected by following the rule in the attribute.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
Available on crate feature NSAccessibilityConstants
only.
pub fn class(&self) -> &'static AnyClass
NSAccessibilityConstants
only.Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.Available on crate feature NSAccessibilityConstants
only.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.NSAccessibilityConstants
only.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Available on crate feature NSAccessibilityConstants
only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
NSAccessibilityConstants
only.Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for NSTextStorage
impl AsRef<AnyObject> for NSTextStorage
Source§impl AsRef<NSAttributedString> for NSTextStorage
impl AsRef<NSAttributedString> for NSTextStorage
Source§fn as_ref(&self) -> &NSAttributedString
fn as_ref(&self) -> &NSAttributedString
Source§impl AsRef<NSMutableAttributedString> for NSTextStorage
impl AsRef<NSMutableAttributedString> for NSTextStorage
Source§fn as_ref(&self) -> &NSMutableAttributedString
fn as_ref(&self) -> &NSMutableAttributedString
Source§impl AsRef<NSObject> for NSTextStorage
impl AsRef<NSObject> for NSTextStorage
Source§impl AsRef<NSTextStorage> for NSTextStorage
impl AsRef<NSTextStorage> for NSTextStorage
Source§impl Borrow<AnyObject> for NSTextStorage
impl Borrow<AnyObject> for NSTextStorage
Source§impl Borrow<NSAttributedString> for NSTextStorage
impl Borrow<NSAttributedString> for NSTextStorage
Source§fn borrow(&self) -> &NSAttributedString
fn borrow(&self) -> &NSAttributedString
Source§impl Borrow<NSMutableAttributedString> for NSTextStorage
impl Borrow<NSMutableAttributedString> for NSTextStorage
Source§fn borrow(&self) -> &NSMutableAttributedString
fn borrow(&self) -> &NSMutableAttributedString
Source§impl Borrow<NSObject> for NSTextStorage
impl Borrow<NSObject> for NSTextStorage
Source§impl ClassType for NSTextStorage
impl ClassType for NSTextStorage
Source§const NAME: &'static str = "NSTextStorage"
const NAME: &'static str = "NSTextStorage"
Source§type Super = NSMutableAttributedString
type Super = NSMutableAttributedString
Source§type ThreadKind = <<NSTextStorage as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<NSTextStorage as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for NSTextStorage
impl Debug for NSTextStorage
Source§impl Deref for NSTextStorage
impl Deref for NSTextStorage
Source§impl Hash for NSTextStorage
impl Hash for NSTextStorage
Source§impl Message for NSTextStorage
impl Message for NSTextStorage
Source§impl NSCoding for NSTextStorage
impl NSCoding for NSTextStorage
Source§impl NSObjectProtocol for NSTextStorage
impl NSObjectProtocol for NSTextStorage
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref