1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTextCursorAccessoryPlacement(pub NSInteger);
impl NSTextCursorAccessoryPlacement {
    #[doc(alias = "NSTextCursorAccessoryPlacementUnspecified")]
    pub const Unspecified: Self = Self(0);
    #[doc(alias = "NSTextCursorAccessoryPlacementBackward")]
    pub const Backward: Self = Self(1);
    #[doc(alias = "NSTextCursorAccessoryPlacementForward")]
    pub const Forward: Self = Self(2);
    #[doc(alias = "NSTextCursorAccessoryPlacementInvisible")]
    pub const Invisible: Self = Self(3);
    #[doc(alias = "NSTextCursorAccessoryPlacementCenter")]
    pub const Center: Self = Self(4);
    #[doc(alias = "NSTextCursorAccessoryPlacementOffscreenLeft")]
    pub const OffscreenLeft: Self = Self(5);
    #[doc(alias = "NSTextCursorAccessoryPlacementOffscreenTop")]
    pub const OffscreenTop: Self = Self(6);
    #[doc(alias = "NSTextCursorAccessoryPlacementOffscreenRight")]
    pub const OffscreenRight: Self = Self(7);
    #[doc(alias = "NSTextCursorAccessoryPlacementOffscreenBottom")]
    pub const OffscreenBottom: Self = Self(8);
}

unsafe impl Encode for NSTextCursorAccessoryPlacement {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSTextCursorAccessoryPlacement {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    pub unsafe trait NSTextInputClient {
        #[method(insertText:replacementRange:)]
        unsafe fn insertText_replacementRange(
            &self,
            string: &AnyObject,
            replacement_range: NSRange,
        );

        #[method(doCommandBySelector:)]
        unsafe fn doCommandBySelector(&self, selector: Sel);

        #[method(setMarkedText:selectedRange:replacementRange:)]
        unsafe fn setMarkedText_selectedRange_replacementRange(
            &self,
            string: &AnyObject,
            selected_range: NSRange,
            replacement_range: NSRange,
        );

        #[method(unmarkText)]
        unsafe fn unmarkText(&self);

        #[method(selectedRange)]
        unsafe fn selectedRange(&self) -> NSRange;

        #[method(markedRange)]
        unsafe fn markedRange(&self) -> NSRange;

        #[method(hasMarkedText)]
        unsafe fn hasMarkedText(&self) -> bool;

        #[method_id(@__retain_semantics Other attributedSubstringForProposedRange:actualRange:)]
        unsafe fn attributedSubstringForProposedRange_actualRange(
            &self,
            range: NSRange,
            actual_range: NSRangePointer,
        ) -> Option<Retained<NSAttributedString>>;

        #[method_id(@__retain_semantics Other validAttributesForMarkedText)]
        unsafe fn validAttributesForMarkedText(&self) -> Retained<NSArray<NSAttributedStringKey>>;

        #[method(firstRectForCharacterRange:actualRange:)]
        unsafe fn firstRectForCharacterRange_actualRange(
            &self,
            range: NSRange,
            actual_range: NSRangePointer,
        ) -> NSRect;

        #[method(characterIndexForPoint:)]
        unsafe fn characterIndexForPoint(&self, point: NSPoint) -> NSUInteger;

        #[optional]
        #[method_id(@__retain_semantics Other attributedString)]
        unsafe fn attributedString(&self) -> Retained<NSAttributedString>;

        #[optional]
        #[method(fractionOfDistanceThroughGlyphForPoint:)]
        unsafe fn fractionOfDistanceThroughGlyphForPoint(&self, point: NSPoint) -> CGFloat;

        #[optional]
        #[method(baselineDeltaForCharacterAtIndex:)]
        unsafe fn baselineDeltaForCharacterAtIndex(&self, an_index: NSUInteger) -> CGFloat;

        #[optional]
        #[method(windowLevel)]
        unsafe fn windowLevel(&self) -> NSInteger;

        #[optional]
        #[method(drawsVerticallyForCharacterAtIndex:)]
        unsafe fn drawsVerticallyForCharacterAtIndex(&self, char_index: NSUInteger) -> bool;

        #[optional]
        #[method(preferredTextAccessoryPlacement)]
        unsafe fn preferredTextAccessoryPlacement(&self) -> NSTextCursorAccessoryPlacement;

        #[optional]
        #[method(unionRectInVisibleSelectedRange)]
        unsafe fn unionRectInVisibleSelectedRange(&self) -> NSRect;

        #[optional]
        #[method(documentVisibleRect)]
        unsafe fn documentVisibleRect(&self) -> NSRect;
    }

    unsafe impl ProtocolType for dyn NSTextInputClient {}
);