Skip to main content

BufferOpts

Struct BufferOpts 

Source
pub struct BufferOpts {
Show 17 fields pub highlight_current_line: bool, pub wrap_lines: bool, pub wrap_on_word: bool, pub wrapping_cap: Option<u32>, pub indent_wraps: bool, pub tabstop: u8, pub scrolloff: ScrollOff, pub force_scrolloff: bool, pub extra_word_chars: &'static [char], pub indent_str: Option<&'static str>, pub indent_str_on_empty: bool, pub indent_tab_str: Option<&'static str>, pub space_char: Option<char>, pub space_char_trailing: Option<char>, pub new_line_char: char, pub new_line_on_empty: Option<char>, pub new_line_trailing: Option<char>,
}
Expand description

The default suite of options available to Buffers

Unlike most other widget options, these ones are dynamic, that is, if they are changed while duat is still open, the Buffer will be updated accordingly.

§Note

While these options are defined as a core part of the Buffer, they are not implemented natively. The implementation is done in the duat-base crate, which means you may replace the implementation with your own version if that suits you.

Fields§

§highlight_current_line: bool

Highlights the current line

The default is true

This makes use of the current_line Form

§wrap_lines: bool

Enables wrapping of lines

The default is true

§wrap_on_word: bool

Wrap on word boundaries, rather than on any character

The default is false.

§wrapping_cap: Option<u32>

Where to start wrapping

The default is None

If this value is None and opts.wrap_lines == true, then wrapping will take place at the right edge of the screen.

Otherwise, if it is Some({cap}), then wrapping will take place {cap} cells from the left edge. This value may or may not be greater than the width of the area. If it is greater than it, then wrapping will take place slightly outside the screen as a concequence.

§indent_wraps: bool

Whether to indent wrapped lines or not

The default is true.

This turns this:

    This is a very long line of text, so long that it
wraps around

Into this:

    This is a very long line of text, so long that it
    wraps around
§tabstop: u8

How much space a tab should occupy

The default is 4

This also affect other things, like if your tabs are converted into spaces, this will also set how many spaces should be added.

§scrolloff: ScrollOff

How much space to keep between the cursor and edges

The default is ScrollOff { x: 3, y: 3 }

§force_scrolloff: bool

Whether to limit scrolloff at the end of lines

The default is false

This makes it so, as you reach the end of a long line of text, the cursor line will continue scrolling to the left, maintaining the scrolloff.x’s gap.

§extra_word_chars: &'static [char]

Extra characters to be considered part of a word

The default is &[].

Normally, word characters include all of those in the \w character set, which most importantly includes [0-9A-Za-z_].

You can use this setting to add more characters to that list, usually something like -, $ or @, which are useful to consider as word characters in some circumstances.

§indent_str: Option<&'static str>

Indent string

The default is Some("│").

The indent lines will be printed with the replace.indent Form.

A string to replace the indentation at the start of the line. This string will repeat on every opts.tabstop initial spaces or on every \t character, replacing that many characters of the tab stop with those of the string.

For example, if tabstop == 2 && indent_str == Some("│ "), this:

int (int var1, int var2) {
  if (var1 > 2)
    return 42;
  else
    if (var1 <= 50)
      return 20;
    else
      return 10;
}

Would be displayed like this:

int (int var1, int var2) {
│ if (var1 > 2)
│ │ return 42;
│ else
│ │ if (var1 <= 50)
│ │ │ return 20;
│ │ else
│ │ │ return 10;
}

That is, it will take tabstop characters and print them. Where the tabstop == 4, it would use all 4 characters.

§indent_str_on_empty: bool

Wether to copy the indentation string of opts.indent_str on empty lines.

The default is true

If this is set to true, this str will be printed with the replace.indent.empty form.

This will always copy whichever line has the smallest ammount of indentation.

§indent_tab_str: Option<&'static str>

An indent string, just like opts.indent_str, but only for \ts

The default is None

This is useful for languages like python, where the mixup of tabs and spaces on indentation can cause problems.

If it is Some, the str will be shown with the replace.indent.tab form. If this is None, then opts.indent_str will be used instead.

§space_char: Option<char>

A character to be printed in place of the space

The default is None

The char will be printed with the replace.space Form.

This character will replace only the space characters that are not part of the indentation.

§space_char_trailing: Option<char>

A character to be printed on trailing whitespace

The default is None

This character will be printed with the replace.space.trailing Form

If it is None, it will be the same as opts.space_char.

§new_line_char: char

Which char should be printed in new lines

The default is ' ' (space character)

This character will be printed with the replace.new_line Form.

§new_line_on_empty: Option<char>

A character to be printed on the new line on empty strings

The default is None

This character will be printed with the replace.new_line.empty Form.

If it is None, it will be the same as opts.new_line_char.

§new_line_trailing: Option<char>

A character to be printed on trailing new lines

The default is None

This character will be printed with the replace.new_line.trailing Form.

Implementations§

Trait Implementations§

Source§

impl Clone for BufferOpts

Source§

fn clone(&self) -> BufferOpts

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 BufferOpts

Source§

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

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

impl Default for BufferOpts

Source§

fn default() -> Self

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

impl Hash for BufferOpts

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BufferOpts

Source§

fn eq(&self, other: &BufferOpts) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for BufferOpts

Source§

impl Eq for BufferOpts

Source§

impl StructuralPartialEq for BufferOpts

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.