pub struct NSTextStorage { /* private fields */ }
NSTextStorage
only.Expand description
Implementations§
Source§impl NSTextStorage
impl NSTextStorage
Sourcepub fn layoutManagers(&self) -> Retained<NSArray<NSLayoutManager>>
Available on crate feature NSLayoutManager
only.
pub fn layoutManagers(&self) -> Retained<NSArray<NSLayoutManager>>
NSLayoutManager
only.************************** Layout manager ***************************
pub fn addLayoutManager(&self, a_layout_manager: &NSLayoutManager)
NSLayoutManager
only.pub fn removeLayoutManager(&self, a_layout_manager: &NSLayoutManager)
NSLayoutManager
only.Sourcepub fn editedMask(&self) -> NSTextStorageEditActions
pub fn editedMask(&self) -> NSTextStorageEditActions
************************** Pending edit info ***************************
pub fn editedRange(&self) -> NSRange
pub fn changeInLength(&self) -> NSInteger
Sourcepub fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn NSTextStorageDelegate>>>
pub fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn NSTextStorageDelegate>>>
************************** Delegate ***************************
Sourcepub fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn NSTextStorageDelegate>>,
)
pub fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn NSTextStorageDelegate>>, )
Setter for delegate
.
This is a weak property.
Sourcepub fn edited_range_changeInLength(
&self,
edited_mask: NSTextStorageEditActions,
edited_range: NSRange,
delta: NSInteger,
)
pub fn edited_range_changeInLength( &self, edited_mask: NSTextStorageEditActions, edited_range: NSRange, delta: NSInteger, )
************************** Edit management ***************************
pub fn processEditing(&self)
Sourcepub fn fixesAttributesLazily(&self) -> bool
pub fn fixesAttributesLazily(&self) -> bool
************************** Attribute fixing ***************************
pub fn invalidateAttributesInRange(&self, range: NSRange)
pub fn ensureAttributesAreFixedInRange(&self, range: NSRange)
Sourcepub fn textStorageObserver(
&self,
) -> Option<Retained<ProtocolObject<dyn NSTextStorageObserving>>>
pub fn textStorageObserver( &self, ) -> Option<Retained<ProtocolObject<dyn NSTextStorageObserving>>>
************************** NSTextStorageObserving ***************************
Sourcepub fn setTextStorageObserver(
&self,
text_storage_observer: Option<&ProtocolObject<dyn NSTextStorageObserving>>,
)
pub fn setTextStorageObserver( &self, text_storage_observer: Option<&ProtocolObject<dyn NSTextStorageObserving>>, )
Setter for textStorageObserver
.
This is a weak property.
Source§impl NSTextStorage
Methods declared on superclass NSObject
.
impl NSTextStorage
Methods declared on superclass NSObject
.
Source§impl NSTextStorage
Scripting.
impl NSTextStorage
Scripting.
pub fn attributeRuns(&self) -> Retained<NSArray<NSTextStorage>>
NSTextStorageScripting
only.Sourcepub fn setAttributeRuns(&self, attribute_runs: &NSArray<NSTextStorage>)
Available on crate feature NSTextStorageScripting
only.
pub fn setAttributeRuns(&self, attribute_runs: &NSArray<NSTextStorage>)
NSTextStorageScripting
only.Setter for attributeRuns
.
This is copied when set.
pub fn paragraphs(&self) -> Retained<NSArray<NSTextStorage>>
NSTextStorageScripting
only.Sourcepub fn setParagraphs(&self, paragraphs: &NSArray<NSTextStorage>)
Available on crate feature NSTextStorageScripting
only.
pub fn setParagraphs(&self, paragraphs: &NSArray<NSTextStorage>)
NSTextStorageScripting
only.Setter for paragraphs
.
This is copied when set.
pub fn words(&self) -> Retained<NSArray<NSTextStorage>>
NSTextStorageScripting
only.Sourcepub fn setWords(&self, words: &NSArray<NSTextStorage>)
Available on crate feature NSTextStorageScripting
only.
pub fn setWords(&self, words: &NSArray<NSTextStorage>)
NSTextStorageScripting
only.pub fn characters(&self) -> Retained<NSArray<NSTextStorage>>
NSTextStorageScripting
only.Sourcepub fn setCharacters(&self, characters: &NSArray<NSTextStorage>)
Available on crate feature NSTextStorageScripting
only.
pub fn setCharacters(&self, characters: &NSArray<NSTextStorage>)
NSTextStorageScripting
only.Setter for characters
.
This is copied when set.
pub fn font(&self) -> Option<Retained<NSFont>>
NSTextStorageScripting
and NSFont
only.Sourcepub fn setFont(&self, font: Option<&NSFont>)
Available on crate features NSTextStorageScripting
and NSFont
only.
pub fn setFont(&self, font: Option<&NSFont>)
NSTextStorageScripting
and NSFont
only.Setter for font
.
pub fn foregroundColor(&self) -> Option<Retained<NSColor>>
NSTextStorageScripting
and NSColor
only.Sourcepub fn setForegroundColor(&self, foreground_color: Option<&NSColor>)
Available on crate features NSTextStorageScripting
and NSColor
only.
pub fn setForegroundColor(&self, foreground_color: Option<&NSColor>)
NSTextStorageScripting
and NSColor
only.Setter for foregroundColor
.
Methods from Deref<Target = NSMutableAttributedString>§
pub fn replaceCharactersInRange_withString( &self, range: NSRange, str: &NSString, )
Sourcepub unsafe fn setAttributes_range(
&self,
attrs: Option<&NSDictionary<NSString>>,
range: NSRange,
)
pub unsafe fn setAttributes_range( &self, attrs: Option<&NSDictionary<NSString>>, range: NSRange, )
§Safety
attrs
generic should be of the correct type.
pub fn mutableString(&self) -> Retained<NSMutableString>
Sourcepub unsafe fn addAttribute_value_range(
&self,
name: &NSString,
value: &AnyObject,
range: NSRange,
)
pub unsafe fn addAttribute_value_range( &self, name: &NSString, value: &AnyObject, range: NSRange, )
§Safety
value
should be of the correct type.
Sourcepub unsafe fn addAttributes_range(
&self,
attrs: &NSDictionary<NSString>,
range: NSRange,
)
pub unsafe fn addAttributes_range( &self, attrs: &NSDictionary<NSString>, range: NSRange, )
§Safety
attrs
generic should be of the correct type.
pub fn removeAttribute_range(&self, name: &NSString, range: NSRange)
pub fn replaceCharactersInRange_withAttributedString( &self, range: NSRange, attr_string: &NSAttributedString, )
pub fn insertAttributedString_atIndex( &self, attr_string: &NSAttributedString, loc: usize, )
pub fn appendAttributedString(&self, attr_string: &NSAttributedString)
pub fn deleteCharactersInRange(&self, range: NSRange)
pub fn setAttributedString(&self, attr_string: &NSAttributedString)
pub fn beginEditing(&self)
pub fn endEditing(&self)
Methods from Deref<Target = NSAttributedString>§
pub fn string(&self) -> Retained<NSString>
Sourcepub unsafe fn attributesAtIndex_effectiveRange(
&self,
location: usize,
range: *mut NSRange,
) -> Retained<NSDictionary<NSString>>
pub unsafe fn attributesAtIndex_effectiveRange( &self, location: usize, range: *mut NSRange, ) -> Retained<NSDictionary<NSString>>
§Safety
range
must be a valid pointer or null.
pub fn length(&self) -> usize
Sourcepub unsafe fn attribute_atIndex_effectiveRange(
&self,
attr_name: &NSString,
location: usize,
range: *mut NSRange,
) -> Option<Retained<AnyObject>>
pub unsafe fn attribute_atIndex_effectiveRange( &self, attr_name: &NSString, location: usize, range: *mut NSRange, ) -> Option<Retained<AnyObject>>
§Safety
range
must be a valid pointer or null.
pub fn attributedSubstringFromRange( &self, range: NSRange, ) -> Retained<NSAttributedString>
Sourcepub unsafe fn attributesAtIndex_longestEffectiveRange_inRange(
&self,
location: usize,
range: *mut NSRange,
range_limit: NSRange,
) -> Retained<NSDictionary<NSString>>
pub unsafe fn attributesAtIndex_longestEffectiveRange_inRange( &self, location: usize, range: *mut NSRange, range_limit: NSRange, ) -> Retained<NSDictionary<NSString>>
§Safety
range
must be a valid pointer or null.
Sourcepub unsafe fn attribute_atIndex_longestEffectiveRange_inRange(
&self,
attr_name: &NSString,
location: usize,
range: *mut NSRange,
range_limit: NSRange,
) -> Option<Retained<AnyObject>>
pub unsafe fn attribute_atIndex_longestEffectiveRange_inRange( &self, attr_name: &NSString, location: usize, range: *mut NSRange, range_limit: NSRange, ) -> Option<Retained<AnyObject>>
§Safety
range
must be a valid pointer or null.
pub fn isEqualToAttributedString(&self, other: &NSAttributedString) -> bool
Sourcepub fn attributedStringByInflectingString(&self) -> Retained<NSAttributedString>
pub 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 DefaultRetained for NSTextStorage
impl DefaultRetained 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