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.
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/component_functions.rs (
line 9)
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)
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);
}
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),
);
}
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);
}
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'));
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/component_functions.rs (
line 9)
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)
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);
}
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),
);
}
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);
}
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));
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));
The resulting type after applying the +
operator.
Performs copy-assignment from
source
.
Read more
Formats the value using the given formatter.
Read more
Returns the “default value” for a type.
Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
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.
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.