core_foundation_sys/
attributed_string.rs

1// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution.
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, CFTypeRef};
11use crate::dictionary::CFDictionaryRef;
12use crate::string::CFMutableStringRef;
13use crate::string::CFStringRef;
14use std::os::raw::c_void;
15
16#[repr(C)]
17pub struct __CFAttributedString(c_void);
18
19pub type CFAttributedStringRef = *const __CFAttributedString;
20pub type CFMutableAttributedStringRef = *mut __CFAttributedString;
21
22extern "C" {
23    /*
24     * CFAttributedString.h
25     */
26
27    /* CFAttributedString */
28    /* Creating a CFAttributedString */
29    pub fn CFAttributedStringCreate(
30        allocator: CFAllocatorRef,
31        str: CFStringRef,
32        attributes: CFDictionaryRef,
33    ) -> CFAttributedStringRef;
34    pub fn CFAttributedStringCreateCopy(
35        alloc: CFAllocatorRef,
36        aStr: CFAttributedStringRef,
37    ) -> CFAttributedStringRef;
38    pub fn CFAttributedStringCreateWithSubstring(
39        alloc: CFAllocatorRef,
40        aStr: CFAttributedStringRef,
41        range: CFRange,
42    ) -> CFAttributedStringRef;
43    pub fn CFAttributedStringGetLength(astr: CFAttributedStringRef) -> CFIndex;
44    pub fn CFAttributedStringGetString(aStr: CFAttributedStringRef) -> CFStringRef;
45
46    /* Accessing Attributes */
47    pub fn CFAttributedStringGetAttribute(
48        aStr: CFAttributedStringRef,
49        loc: CFIndex,
50        attrName: CFStringRef,
51        effectiveRange: *mut CFRange,
52    ) -> CFTypeRef;
53    pub fn CFAttributedStringGetAttributes(
54        aStr: CFAttributedStringRef,
55        loc: CFIndex,
56        effectiveRange: *mut CFRange,
57    ) -> CFDictionaryRef;
58    pub fn CFAttributedStringGetAttributeAndLongestEffectiveRange(
59        aStr: CFAttributedStringRef,
60        loc: CFIndex,
61        attrName: CFStringRef,
62        inRange: CFRange,
63        longestEffectiveRange: *mut CFRange,
64    ) -> CFTypeRef;
65    pub fn CFAttributedStringGetAttributesAndLongestEffectiveRange(
66        aStr: CFAttributedStringRef,
67        loc: CFIndex,
68        inRange: CFRange,
69        longestEffectiveRange: *mut CFRange,
70    ) -> CFDictionaryRef;
71
72    /* Getting Attributed String Properties */
73    pub fn CFAttributedStringGetTypeID() -> CFTypeID;
74
75    /* CFMutableAttributedString */
76    /* Creating a CFMutableAttributedString */
77    pub fn CFAttributedStringCreateMutable(
78        allocator: CFAllocatorRef,
79        max_length: CFIndex,
80    ) -> CFMutableAttributedStringRef;
81    pub fn CFAttributedStringCreateMutableCopy(
82        allocator: CFAllocatorRef,
83        max_length: CFIndex,
84        astr: CFAttributedStringRef,
85    ) -> CFMutableAttributedStringRef;
86
87    /* Modifying a CFMutableAttributedString */
88    pub fn CFAttributedStringBeginEditing(aStr: CFMutableAttributedStringRef);
89    pub fn CFAttributedStringEndEditing(aStr: CFMutableAttributedStringRef);
90    pub fn CFAttributedStringGetMutableString(
91        aStr: CFMutableAttributedStringRef,
92    ) -> CFMutableStringRef;
93    pub fn CFAttributedStringRemoveAttribute(
94        aStr: CFMutableAttributedStringRef,
95        range: CFRange,
96        attrName: CFStringRef,
97    );
98    pub fn CFAttributedStringReplaceString(
99        aStr: CFMutableAttributedStringRef,
100        range: CFRange,
101        replacement: CFStringRef,
102    );
103    pub fn CFAttributedStringReplaceAttributedString(
104        aStr: CFMutableAttributedStringRef,
105        range: CFRange,
106        replacement: CFAttributedStringRef,
107    );
108    pub fn CFAttributedStringSetAttribute(
109        aStr: CFMutableAttributedStringRef,
110        range: CFRange,
111        attrName: CFStringRef,
112        value: CFTypeRef,
113    );
114    pub fn CFAttributedStringSetAttributes(
115        aStr: CFMutableAttributedStringRef,
116        range: CFRange,
117        replacement: CFDictionaryRef,
118        clearOtherAttributes: Boolean,
119    );
120}