objc2-browser-engine-kit 0.3.2

Bindings to the BrowserEngineKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/betextdocumentcontext?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct BETextDocumentContext;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for BETextDocumentContext {}
);

impl BETextDocumentContext {
    extern_methods!(
        /// Initializes a new document context with plain text.
        ///
        /// Parameter `selectedText`: The currently selected text, or nil in the case of a caret selection.
        /// This string may be empty but non-nil if non-textual content is selected, in which case a single call to -deleteBackward will not delete from contextBeforeSelection.
        /// May be empty if its outside of the context's area, even if it exists elsewhere in the document.
        ///
        /// Parameter `contextBefore`: A suffix of the text preceding the selection, or nil if the selection is at the beginning of the document.
        /// This text must correspond to a range that does not include any non-text content.
        /// In particular, if a context comprises k backward-deletion clusters, then k calls to -deleteBackward must delete the corresponding text from the document.
        /// The beginning of this string must lie on a word boundary (or not be inside a word at all).
        ///
        /// Parameter `contextAfter`: A prefix of the text following the selection, or nil if the selection is at the end of the document.
        /// This text must correspond to a range that does not include any non-text content.
        /// The end of this string must lie on a word boundary (or not be inside a word at all).
        ///
        /// Parameter `markedText`: May be empty if it's outside of the context's area, even if it exists elsewhere in the document.
        ///
        /// Parameter `selectedRangeInMarkedText`: The range of the current text selection, relative to the marked text range. Specify (NSNotFound, 0) if there is no marked text.
        #[unsafe(method(initWithSelectedText:contextBefore:contextAfter:markedText:selectedRangeInMarkedText:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSelectedText_contextBefore_contextAfter_markedText_selectedRangeInMarkedText(
            this: Allocated<Self>,
            selected_text: Option<&NSString>,
            context_before: Option<&NSString>,
            context_after: Option<&NSString>,
            marked_text: Option<&NSString>,
            selected_range_in_marked_text: NSRange,
        ) -> Retained<Self>;

        /// Initializes a new document context with attributed strings. The `selectedText`, `contextBefore`, and `contextAfter`
        /// represent the same ranges as they do in the `-initWithSelectedText:contextBefore:contextAfter:` initializer.
        #[unsafe(method(initWithAttributedSelectedText:contextBefore:contextAfter:markedText:selectedRangeInMarkedText:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAttributedSelectedText_contextBefore_contextAfter_markedText_selectedRangeInMarkedText(
            this: Allocated<Self>,
            selected_text: Option<&NSAttributedString>,
            context_before: Option<&NSAttributedString>,
            context_after: Option<&NSAttributedString>,
            marked_text: Option<&NSAttributedString>,
            selected_range_in_marked_text: NSRange,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        /// Adds a text `rect` for the given character `range`
        /// The CGRects representing each character range are specified in -textInputView coordinates.
        #[unsafe(method(addTextRect:forCharacterRange:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addTextRect_forCharacterRange(&self, rect: CGRect, range: NSRange);

        /// Array of `NSRange` values, relative to the full context string made by combining the
        /// `contextBefore`, `markedText` (or `selectedText` if the marked text is empty), and the
        /// `contextAfter`.
        #[unsafe(method(autocorrectedRanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn autocorrectedRanges(&self) -> Retained<NSArray<NSValue>>;

        /// Setter for [`autocorrectedRanges`][Self::autocorrectedRanges].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAutocorrectedRanges:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAutocorrectedRanges(&self, autocorrected_ranges: &NSArray<NSValue>);

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(&self) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl BETextDocumentContext {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new_class() -> Retained<Self>;
    );
}