[−]Struct xterm_js_sys::xterm::LinkMatcherOptions
An object containing options for a link matcher.
Note: we had to make some significant compromises to mirroring this
interface on the Rust side. Because the interface contains optional
functions we choose to model this as a struct rather than as an extern-ed
type: we can have fields that have a Closure
or a function trait object
in an Option
but we have no way to have an optional function in a Rust
trait.
Unfortunately Option<Closure<_>>
and Option<dyn Fn{,Mut}(...)>
don't
implement OptionIntoWasmAbi
, so we had to make the fields required.
Additionally, the validation callback actually takes another callback which
we couldn't model as the appropriate Rust type (dyn FnMut(bool)
) because
dyn FnMut
and the Closure
type don't implement FromWasmAbi
(i.e. you
can't produce something of those types on the JS side). So, we had to fall
back to using js_sys::Function
.
Fortunately since this interface is only ever produced by the user of the
API, the first point (not having optional functions) isn't too big a deal.
The second point makes actually making a LinkMatcherOptions
instance in
Rust kind of a pain, but it's still workable.
Since we can't actually do the Option<Closure<_>>
thing, it might actually
have been better to model this as an extern-ed type + a Rust trait, but
let's leave that for another time. If there's interest in actually using
this part of the API in Rust we can make the change (but I doubt there will
be).
Fields
match_index: Option<u32>
The index of the link from the regex.match(text)
call.
This defaults to 0 (for regular expressions without capture groups).
validation_callback: &'static Closure<dyn FnMut(Str, Function)>
A function that validates whether to create an individual link.
The callback that this function is given is passed a bool
indicating
whether the link given (uri
) is valid.
Since the signature, post-translation, is rather cryptic, here's the original TypeScript binding:
validationCallback?: (
uri: string,
callback: (isValid: boolean) => void,
) => void;
tooltip_callback: &'static Closure<dyn FnMut(MouseEvent, Str, ViewportRange) -> Option<bool>>
A function that is called when the mouse hovers over a link for a period
of time (defined by TerminalOptions::link_tooltip_hover_duration
).
Since the signature, post-translation, is rather cryptic, here's the original TypeScript binding:
tooltipCallback?: (
event: MouseEvent,
uri: string,
location: IViewportRange,
) => boolean | void;
leave_callback: &'static Closure<dyn FnMut()>
A function that is called when the mouse leaves a link.
Note that this can happen even when tooltip_callback
hasn't fired
for the link yet.
Just to be thorough, here's the original TypeScript binding:
leaveCallback?: () => void;
priority: Option<i16>
The priority of the link matcher.
This defined the order in which the link matcher is evaluated relative to others, from highest to lowest. The default value is 0.
will_link_activate: &'static Closure<dyn FnMut(MouseEvent, Str) -> bool>
A function that is called when the mousedown and click events occur.
This function is responsible for determining whether a link will be
activated upon click. This enables only activating a link when a certain
modifier is held down. If this function determines that an event does
not activate the link (i.e. by returning false
) then the event will
continue propagation (e.g. double click to select word).
Since the signature, post-translation, is rather cryptic, here's the original TypeScript binding:
willLinkActivate?: (event: MouseEvent, uri: string) => boolean;
Trait Implementations
impl Clone for LinkMatcherOptions
fn clone(&self) -> LinkMatcherOptions
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for LinkMatcherOptions
impl From<LinkMatcherOptions> for JsValue
[src]
fn from(value: LinkMatcherOptions) -> Self
[src]
impl FromWasmAbi for LinkMatcherOptions
[src]
type Abi = u32
The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more
unsafe fn from_abi(js: u32) -> Self
[src]
impl IntoWasmAbi for LinkMatcherOptions
[src]
type Abi = u32
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
fn into_abi(self) -> u32
[src]
impl OptionFromWasmAbi for LinkMatcherOptions
[src]
impl OptionIntoWasmAbi for LinkMatcherOptions
[src]
impl RefFromWasmAbi for LinkMatcherOptions
[src]
type Abi = u32
The wasm ABI type references to Self
are recovered from.
type Anchor = Ref<'static, LinkMatcherOptions>
The type that holds the reference to Self
for the duration of the invocation of the function that has an &Self
parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
[src]
impl RefMutFromWasmAbi for LinkMatcherOptions
[src]
type Abi = u32
Same as RefFromWasmAbi::Abi
type Anchor = RefMut<'static, LinkMatcherOptions>
Same as RefFromWasmAbi::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
[src]
impl WasmDescribe for LinkMatcherOptions
[src]
Auto Trait Implementations
impl !RefUnwindSafe for LinkMatcherOptions
impl !Send for LinkMatcherOptions
impl !Sync for LinkMatcherOptions
impl Unpin for LinkMatcherOptions
impl !UnwindSafe for LinkMatcherOptions
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
[src]
T: IntoWasmAbi,
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,