objc2_core_services/generated/DictionaryServices.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::marker::{PhantomData, PhantomPinned};
5use core::ptr::NonNull;
6#[cfg(feature = "objc2")]
7use objc2::__framework_prelude::*;
8use objc2_core_foundation::*;
9
10use crate::*;
11
12/// Opaque CF object that represents a dictionary file
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/coreservices/dcsdictionary?language=objc)
15#[doc(alias = "DCSDictionaryRef")]
16#[repr(C)]
17pub struct DCSDictionary {
18 inner: [u8; 0],
19 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23 unsafe impl DCSDictionary {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27 unsafe impl RefEncode<"__DCSDictionary"> for DCSDictionary {}
28);
29
30extern "C-unwind" {
31 /// Look for a word or a phrase that contains the specified offset in dictionaries
32 /// activated in Dictionary.app preference
33 ///
34 /// Parameter `dictionary`: This parameter is not supported for Leopard. You should always pass NULL.
35 ///
36 /// Parameter `textString`: Text that contains the word or phrase to look up
37 ///
38 /// Parameter `offset`: Specifies a character offset in textString
39 ///
40 /// Returns: Returns a detected range of word or phrase around the specified offset,
41 /// or (kCFNotFound, 0) is returned if any term is not found in active dictionaries.
42 /// The result range can be used as an input parameter of DCSCopyTextDefinition()
43 /// and HIDictionaryWindowShow() in Carbon framework.
44 pub fn DCSGetTermRangeInString(
45 dictionary: Option<&DCSDictionary>,
46 text_string: &CFString,
47 offset: CFIndex,
48 ) -> CFRange;
49}
50
51/// Copies definition for a specified range of text
52///
53/// Parameter `dictionary`: This parameter is not supported for Leopard. You should always pass NULL.
54///
55/// Parameter `textString`: Text that contains the word or phrase to look up
56///
57/// Parameter `range`: Range of the target word or phrase in textString
58///
59/// Returns: Returns a definition of the specified term in range in plain text
60#[inline]
61pub unsafe extern "C-unwind" fn DCSCopyTextDefinition(
62 dictionary: Option<&DCSDictionary>,
63 text_string: &CFString,
64 range: CFRange,
65) -> Option<CFRetained<CFString>> {
66 extern "C-unwind" {
67 fn DCSCopyTextDefinition(
68 dictionary: Option<&DCSDictionary>,
69 text_string: &CFString,
70 range: CFRange,
71 ) -> Option<NonNull<CFString>>;
72 }
73 let ret = unsafe { DCSCopyTextDefinition(dictionary, text_string, range) };
74 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
75}