Struct RenderConfig

Source
pub struct RenderConfig {
Show 18 fields pub prompt_prefix: Styled<&'static str>, pub answered_prompt_prefix: Styled<&'static str>, pub prompt: StyleSheet, pub default_value: StyleSheet, pub placeholder: StyleSheet, pub help_message: StyleSheet, pub password_mask: char, pub text_input: StyleSheet, pub answer: StyleSheet, pub canceled_prompt_indicator: Styled<&'static str>, pub error_message: ErrorMessageRenderConfig, pub highlighted_option_prefix: Styled<&'static str>, pub scroll_up_prefix: Styled<&'static str>, pub scroll_down_prefix: Styled<&'static str>, pub selected_checkbox: Styled<&'static str>, pub unselected_checkbox: Styled<&'static str>, pub option_index_prefix: IndexPrefix, pub option: StyleSheet,
}
Expand description

Rendering configuration that can be applied to a prompt.

Render configurations can set mostly style sheets for particular parts of the prompt layout. Additionally, it allows you to set the content of a few tokens, such as prompt or error message prefixes.

§Example

use inquire::ui::{Color, RenderConfig, Styled};

let empty: RenderConfig = RenderConfig::empty();
let default: RenderConfig = RenderConfig::default();

let prompt_prefix = Styled::new("$").with_fg(Color::DarkRed);
let mine = default.with_prompt_prefix(prompt_prefix);

Fields§

§prompt_prefix: Styled<&'static str>

Prefix added before prompts.

Note: a space character will be added to separate the prefix and the prompt message.

§answered_prompt_prefix: Styled<&'static str>

Prefix added before answered prompts.

Note: a space character will be added to separate the prefix and the prompt message.

§prompt: StyleSheet

Style of the prompt message, applicable to all prompt types.

§default_value: StyleSheet

Render configuration of default values.

Note: default values are displayed wrapped in parenthesis, e.g. (yes). Non-styled space characters is added before the default value display and after the default value, as separators.

§placeholder: StyleSheet

Render configuration of placeholders.

Note: placeholders are displayed wrapped in parenthesis, e.g. (yes). Non-styled space characters is added before the default value display and after the default value, as separators.

§help_message: StyleSheet

Render configuration of help messages.

Note: help messages are displayed wrapped in brackets, e.g. [Be careful!].

§password_mask: char

Character used to mask password text inputs when in mode Masked.

Note: Styles for masked text inputs are set in the text_input configuration.

§text_input: StyleSheet

Style sheet for text inputs.

Note: a non-styled space character is added before the text input as a separator from the prompt message (or default value display).

§answer: StyleSheet

Render configuration of final prompt answers (submissions).

Note: a non-styled space character is added before the answer as a separator from the prompt message (or default value display).

§canceled_prompt_indicator: Styled<&'static str>

Render configuration of the message printed in the place of an answer when the prompt is canceled by the user - by pressing ESC.

Note: a non-styled space character is added before the indicator as a separator from the prompt message.

§error_message: ErrorMessageRenderConfig

Render configuration for error messages.

§highlighted_option_prefix: Styled<&'static str>

Prefix for the current highlighted option.

Note: a space character will be added to separate the prefix and the option value or the checkbox.

§scroll_up_prefix: Styled<&'static str>

Prefix for the option listed at the top of the page, when it is possible to scroll up.

Note: a space character will be added to separate the prefix and the option value or the checkbox.

§scroll_down_prefix: Styled<&'static str>

Prefix for the option listed at the bottom of the page, when it is possible to scroll down.

Note: a space character will be added to separate the prefix and the option value or the checkbox.

§selected_checkbox: Styled<&'static str>

Selected checkbox in multi-select options.

Note: a space character will be added to separate the checkbox from a possible prefix, and to separate the checkbox from the option value to the right.

§unselected_checkbox: Styled<&'static str>

Unselected checkbox in multi-select options.

Note: a space character will be added to separate the checkbox from a possible prefix, and to separate the checkbox from the option value to the right.

§option_index_prefix: IndexPrefix

Definition of index prefixes in option lists.

§option: StyleSheet

Style sheet for options.

Note: a non-styled space character is added before the option value as a separator from the prefix.

Implementations§

Source§

impl RenderConfig

Source

pub fn empty() -> RenderConfig

RenderConfig in which no colors or attributes are applied.

Source

pub fn default_colored() -> RenderConfig

RenderConfig where default colors and attributes are applied.

Source

pub fn with_prompt_prefix( self, prompt_prefix: Styled<&'static str>, ) -> RenderConfig

Sets the prompt prefix and its style sheet.

Source

pub fn with_text_input(self, text_input: StyleSheet) -> RenderConfig

Sets style for text inputs.

Source

pub fn with_default_value(self, default_value: StyleSheet) -> RenderConfig

Sets the style sheet for default values.

Source

pub fn with_help_message(self, help_message: StyleSheet) -> RenderConfig

Sets the style sheet for help messages.

Source

pub fn with_answer(self, answer: StyleSheet) -> RenderConfig

Sets the style sheet for answers.

Source

pub fn with_error_message( self, error_message: ErrorMessageRenderConfig, ) -> RenderConfig

Sets the render configuration for error messages.

Source

pub fn with_highlighted_option_prefix( self, highlighted_option_prefix: Styled<&'static str>, ) -> RenderConfig

Sets the styled component for prefixes in highlighted options.

Source

pub fn with_scroll_up_prefix( self, scroll_up_prefix: Styled<&'static str>, ) -> RenderConfig

Sets the styled component for prefixes in scroll-up indicators.

Source

pub fn with_scroll_down_prefix( self, scroll_down_prefix: Styled<&'static str>, ) -> RenderConfig

Sets the styled component for prefixes in scroll-down indicators.

Source

pub fn with_selected_checkbox( self, selected_checkbox: Styled<&'static str>, ) -> RenderConfig

Sets the styled component for selected checkboxes.

Source

pub fn with_unselected_checkbox( self, unselected_checkbox: Styled<&'static str>, ) -> RenderConfig

Sets the styled component for unselected checkboxes.

Source

pub fn with_option_index_prefix(self, index_prefix: IndexPrefix) -> RenderConfig

Sets the index prefix for option lists.

Source

pub fn with_option(self, option: StyleSheet) -> RenderConfig

Sets the style sheet for option values.

Source

pub fn with_canceled_prompt_indicator( self, canceled_prompt_indicator: Styled<&'static str>, ) -> RenderConfig

Sets the indicator for canceled prompts.

Trait Implementations§

Source§

impl Clone for RenderConfig

Source§

fn clone(&self) -> RenderConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for RenderConfig

Source§

fn default() -> RenderConfig

Returns the “default value” for a type. Read more
Source§

impl Copy for RenderConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more