pub struct Rule {
    pub regex: Regex,
    pub format: String,
}
Expand description

In addition to handling explicit escape sequences to enable hyperlinks, we also support defining rules that match text from screen lines and generate implicit hyperlinks. This can be used both for making http URLs clickable and also to make other text clickable. For example, you might define a rule that makes bug or issue numbers expand to the corresponding URL to view the details for that issue. The Rule struct is configuration that is passed to the terminal and is evaluated when processing mouse hover events.

Fields

regex: Regex

The compiled regex for the rule. This is used to match against a line of text from the screen (typically the line over which the mouse is hovering).

format: String

The format string that defines how to transform the matched text into a URL. For example, a format string of $0 expands to the entire matched text, whereas mailto:$0 expands to the matched text with a mailto: prefix. More formally, each instance of $N (where N is a number) in the format string is replaced by the capture number N from the regex. The replacements are carried out in reverse order, starting with the highest numbered capture first. This avoids issues with ambiguous replacement of $11 vs $1 in the case of more complex regexes.

Implementations

Construct a new rule. It may fail if the regex is invalid.

Given a line of text from the terminal screen, and a set of rules, return the set of RuleMatches.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Convert from Self to Value, by storing directly into the target Object. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.