Struct arkham::prelude::Rune

source ·
pub struct Rune {
    pub content: Option<char>,
    pub fg: Option<Color>,
    pub bg: Option<Color>,
    pub bold: bool,
}
Expand description

Rune repesents the state of the screen at a specific position. It stores the character content and styling information that will be rendered.

Fields§

§content: Option<char>§fg: Option<Color>§bg: Option<Color>§bold: bool

Implementations§

source§

impl Rune

source

pub fn new() -> Self

Create a new empty Rune. This can be used with the settings functions as a builder pattern

Example:

use arkham::prelude::*;
let rune:Rune = Rune::new().bg(Color::Blue).fg(Color::White).bold();
Examples found in repository?
examples/component_functions.rs (line 9)
7
8
9
10
11
12
fn root(ctx: &mut ViewContext) {
    let size = ctx.size();
    ctx.fill(size, Rune::new().bg(Color::DarkGrey));
    ctx.component(Rect::new((10, 10), (20, 1)), hello_world);
    ctx.component(Rect::new(0, (size.width, 1)), quit_nag);
}
More examples
Hide additional examples
examples/component_params.rs (line 9)
7
8
9
10
11
12
fn root(ctx: &mut ViewContext) {
    let size = ctx.size();
    ctx.fill(size, Rune::new().bg(Color::DarkGrey));
    ctx.component(Rect::new((10, 10), (20, 1)), say_hello("Alice"));
    ctx.component(Rect::new(0, (size.width, 1)), quit_nag);
}
examples/simple.rs (line 9)
7
8
9
10
11
12
13
14
15
fn root(ctx: &mut ViewContext) {
    let size = ctx.size();
    ctx.fill(size, Rune::new().bg(Color::DarkGrey));
    ctx.insert((10, 10), "Hello World");
    ctx.insert(
        ((size.width / 2) - 7, 0),
        "Press Q to Quit".to_runes().fg(Color::Red),
    );
}
examples/keyboard.rs (line 9)
7
8
9
10
11
12
13
fn root(ctx: &mut ViewContext) {
    let size = ctx.size();
    ctx.fill(size, Rune::new().bg(Color::DarkGrey));
    ctx.component(((10, 10), (30, 1)), hello_world);
    ctx.component(((10, 11), (20, 1)), show_key_press);
    ctx.component((0, (size.width, 1)), quit_nag);
}
source

pub fn content(self, content: char) -> Self

Set the content of the rune. The rune’s content is a single character.

Example:

use arkham::prelude::*;
let rune = Rune::new().content('A');
assert_eq!(rune.content, Some('A'));
source

pub fn bg(self, bg: Color) -> Self

Set the background color of the rune.

Example:

use arkham::prelude::*;
let rune = Rune::new().bg(Color::Green);
assert_eq!(rune.bg, Some(Color::Green));
Examples found in repository?
examples/component_functions.rs (line 9)
7
8
9
10
11
12
fn root(ctx: &mut ViewContext) {
    let size = ctx.size();
    ctx.fill(size, Rune::new().bg(Color::DarkGrey));
    ctx.component(Rect::new((10, 10), (20, 1)), hello_world);
    ctx.component(Rect::new(0, (size.width, 1)), quit_nag);
}
More examples
Hide additional examples
examples/component_params.rs (line 9)
7
8
9
10
11
12
fn root(ctx: &mut ViewContext) {
    let size = ctx.size();
    ctx.fill(size, Rune::new().bg(Color::DarkGrey));
    ctx.component(Rect::new((10, 10), (20, 1)), say_hello("Alice"));
    ctx.component(Rect::new(0, (size.width, 1)), quit_nag);
}
examples/simple.rs (line 9)
7
8
9
10
11
12
13
14
15
fn root(ctx: &mut ViewContext) {
    let size = ctx.size();
    ctx.fill(size, Rune::new().bg(Color::DarkGrey));
    ctx.insert((10, 10), "Hello World");
    ctx.insert(
        ((size.width / 2) - 7, 0),
        "Press Q to Quit".to_runes().fg(Color::Red),
    );
}
examples/keyboard.rs (line 9)
7
8
9
10
11
12
13
fn root(ctx: &mut ViewContext) {
    let size = ctx.size();
    ctx.fill(size, Rune::new().bg(Color::DarkGrey));
    ctx.component(((10, 10), (30, 1)), hello_world);
    ctx.component(((10, 11), (20, 1)), show_key_press);
    ctx.component((0, (size.width, 1)), quit_nag);
}
source

pub fn fg(self, fg: Color) -> Self

Set the text color of the rune.

Example:

use arkham::prelude::*;
let rune = Rune::new().fg(Color::Green);
assert_eq!(rune.fg, Some(Color::Green));
source

pub fn bold(self) -> Self

Set the text color of the rune.

Example:

use arkham::prelude::*;
let rune = Rune::new().fg(Color::Green);
assert_eq!(rune.fg, Some(Color::Green));

Trait Implementations§

source§

impl Add for Rune

§

type Output = Rune

The resulting type after applying the + operator.
source§

fn add(self, rhs: Rune) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for Rune

source§

fn clone(&self) -> Rune

Returns a copy 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 Rune

source§

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

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

impl Default for Rune

source§

fn default() -> Rune

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

impl From<Color> for Rune

source§

fn from(value: Color) -> Self

Converts to this type from the input type.
source§

impl From<Rune> for Runes

source§

fn from(value: Rune) -> Self

Converts to this type from the input type.
source§

impl From<char> for Rune

source§

fn from(value: char) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Rune

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Rune

source§

impl Eq for Rune

source§

impl StructuralPartialEq for Rune

Auto Trait Implementations§

§

impl Freeze for Rune

§

impl RefUnwindSafe for Rune

§

impl Send for Rune

§

impl Sync for Rune

§

impl Unpin for Rune

§

impl UnwindSafe for Rune

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> 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,

§

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>,

§

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>,

§

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.