Trait bracket_terminal::prelude::Console
source · [−]pub trait Console {
Show 39 methods
fn get_char_size(&self) -> (u32, u32);
fn resize_pixels(&mut self, width: u32, height: u32);
fn at(&self, x: i32, y: i32) -> usize;
fn cls(&mut self);
fn cls_bg(&mut self, background: RGBA);
fn print(&mut self, x: i32, y: i32, output: &str);
fn print_color(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, output: &str);
fn printer(
&mut self,
x: i32,
y: i32,
output: &str,
align: TextAlign,
background: Option<RGBA>
);
fn set(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, glyph: FontCharType);
fn set_bg(&mut self, x: i32, y: i32, bg: RGBA);
fn draw_box(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
);
fn draw_hollow_box(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
);
fn draw_box_double(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
);
fn draw_hollow_box_double(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
);
fn fill_region(&mut self, target: Rect, glyph: FontCharType, fg: RGBA, bg: RGBA);
fn draw_bar_horizontal(
&mut self,
x: i32,
y: i32,
width: i32,
n: i32,
max: i32,
fg: RGBA,
bg: RGBA
);
fn draw_bar_vertical(
&mut self,
x: i32,
y: i32,
height: i32,
n: i32,
max: i32,
fg: RGBA,
bg: RGBA
);
fn print_centered(&mut self, y: i32, text: &str);
fn print_color_centered(&mut self, y: i32, fg: RGBA, bg: RGBA, text: &str);
fn print_centered_at(&mut self, x: i32, y: i32, text: &str);
fn print_color_centered_at(
&mut self,
x: i32,
y: i32,
fg: RGBA,
bg: RGBA,
text: &str
);
fn print_right(&mut self, x: i32, y: i32, text: &str);
fn print_color_right(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, text: &str);
fn to_xp_layer(&self) -> XpLayer;
fn set_offset(&mut self, x: f32, y: f32);
fn set_scale(&mut self, scale: f32, center_x: i32, center_y: i32);
fn get_scale(&self) -> (f32, i32, i32);
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
fn set_clipping(&mut self, clipping: Option<Rect>);
fn get_clipping(&self) -> Option<Rect>;
fn set_all_fg_alpha(&mut self, alpha: f32);
fn set_all_bg_alpha(&mut self, alpha: f32);
fn set_all_alpha(&mut self, fg: f32, bg: f32);
fn set_translation_mode(&mut self, mode: CharacterTranslationMode);
fn set_char_size(&mut self, width: u32, height: u32);
fn clear_dirty(&mut self);
fn in_bounds(&self, x: i32, y: i32) -> bool { ... }
fn try_at(&self, x: i32, y: i32) -> Option<usize> { ... }
}
Expand description
Trait that must be implemented by console types.
Required Methods
sourcefn get_char_size(&self) -> (u32, u32)
fn get_char_size(&self) -> (u32, u32)
Gets the dimensions of the console in characters
fn resize_pixels(&mut self, width: u32, height: u32)
sourcefn cls_bg(&mut self, background: RGBA)
fn cls_bg(&mut self, background: RGBA)
Clear the console to a set background color, if supported.
sourcefn print(&mut self, x: i32, y: i32, output: &str)
fn print(&mut self, x: i32, y: i32, output: &str)
Print a string at the specified x/y coordinate.
sourcefn print_color(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, output: &str)
fn print_color(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, output: &str)
Print a string in color at the specified x/y coordinate, with specified foreground and background.
sourcefn printer(
&mut self,
x: i32,
y: i32,
output: &str,
align: TextAlign,
background: Option<RGBA>
)
fn printer(
&mut self,
x: i32,
y: i32,
output: &str,
align: TextAlign,
background: Option<RGBA>
)
Print a colorized string with the color encoding defined inline. For example: printer(1, 1, “#[blue]This blue text contains a #[pink]pink#[] word”) You can get the same effect with a TextBlock, but this can be easier. Thanks to doryen_rs for the idea.
sourcefn set(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, glyph: FontCharType)
fn set(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, glyph: FontCharType)
Sets a single cell to a color/glyph combination.
sourcefn draw_box(&mut self, x: i32, y: i32, width: i32, height: i32, fg: RGBA, bg: RGBA)
fn draw_box(&mut self, x: i32, y: i32, width: i32, height: i32, fg: RGBA, bg: RGBA)
Draws a box, starting at x/y with the extents width/height using CP437 line characters
sourcefn draw_hollow_box(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
)
fn draw_hollow_box(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
)
Draws a box, starting at x/y with the extents width/height using CP437 line characters, without filling in the middle
sourcefn draw_box_double(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
)
fn draw_box_double(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
)
Draws a box, starting at x/y with the extents width/height using CP437 double line characters
sourcefn draw_hollow_box_double(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
)
fn draw_hollow_box_double(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
fg: RGBA,
bg: RGBA
)
Draws a box, starting at x/y with the extents width/height using CP437 double line characters, without filling in the middle
sourcefn fill_region(&mut self, target: Rect, glyph: FontCharType, fg: RGBA, bg: RGBA)
fn fill_region(&mut self, target: Rect, glyph: FontCharType, fg: RGBA, bg: RGBA)
Fills a rectangle-defined region with a given glyph
sourcefn draw_bar_horizontal(
&mut self,
x: i32,
y: i32,
width: i32,
n: i32,
max: i32,
fg: RGBA,
bg: RGBA
)
fn draw_bar_horizontal(
&mut self,
x: i32,
y: i32,
width: i32,
n: i32,
max: i32,
fg: RGBA,
bg: RGBA
)
Draws a horizontal progress bar.
sourcefn draw_bar_vertical(
&mut self,
x: i32,
y: i32,
height: i32,
n: i32,
max: i32,
fg: RGBA,
bg: RGBA
)
fn draw_bar_vertical(
&mut self,
x: i32,
y: i32,
height: i32,
n: i32,
max: i32,
fg: RGBA,
bg: RGBA
)
Draws a vertical progress bar.
sourcefn print_centered(&mut self, y: i32, text: &str)
fn print_centered(&mut self, y: i32, text: &str)
Prints text, centered to the whole console width, at vertical location y.
sourcefn print_color_centered(&mut self, y: i32, fg: RGBA, bg: RGBA, text: &str)
fn print_color_centered(&mut self, y: i32, fg: RGBA, bg: RGBA, text: &str)
Prints text in color, centered to the whole console width, at vertical location y.
sourcefn print_centered_at(&mut self, x: i32, y: i32, text: &str)
fn print_centered_at(&mut self, x: i32, y: i32, text: &str)
Prints text, centered on an arbitrary point
sourcefn print_color_centered_at(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, text: &str)
fn print_color_centered_at(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, text: &str)
Prints colored text, centered on an arbitrary point
sourcefn print_right(&mut self, x: i32, y: i32, text: &str)
fn print_right(&mut self, x: i32, y: i32, text: &str)
Prints text right-aligned
sourcefn print_color_right(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, text: &str)
fn print_color_right(&mut self, x: i32, y: i32, fg: RGBA, bg: RGBA, text: &str)
Prints colored text right-aligned
sourcefn to_xp_layer(&self) -> XpLayer
fn to_xp_layer(&self) -> XpLayer
Serializes the console layer to an XpFile
sourcefn set_offset(&mut self, x: f32, y: f32)
fn set_offset(&mut self, x: f32, y: f32)
Specify a global offset (by character count, so 0.5 is half a character). Useful for drawing walls between tiles.
sourcefn set_scale(&mut self, scale: f32, center_x: i32, center_y: i32)
fn set_scale(&mut self, scale: f32, center_x: i32, center_y: i32)
Specify a scale and center of the console. A scale above 1.0 will make the text larger. The center of the scale is at character position (center_x, center_y).
sourcefn get_scale(&self) -> (f32, i32, i32)
fn get_scale(&self) -> (f32, i32, i32)
Get the scale & center of the console. Returns (scale, center_x, center_y).
sourcefn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Produces the implementor as an Any that can be matched to determine type and access natively.
sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Produces the implementor as an Any that can be matched to determine type and access natively.
sourcefn set_clipping(&mut self, clipping: Option<Rect>)
fn set_clipping(&mut self, clipping: Option<Rect>)
Permits the creation of an arbitrary clipping rectangle. It’s a really good idea to make sure that this rectangle is entirely valid.
sourcefn get_clipping(&self) -> Option<Rect>
fn get_clipping(&self) -> Option<Rect>
Returns the current arbitrary clipping rectangle, None if there isn’t one.
sourcefn set_all_fg_alpha(&mut self, alpha: f32)
fn set_all_fg_alpha(&mut self, alpha: f32)
Sets ALL tiles foreground alpha (only tiles that exist, in sparse consoles).
sourcefn set_all_bg_alpha(&mut self, alpha: f32)
fn set_all_bg_alpha(&mut self, alpha: f32)
Sets ALL tiles background alpha (only tiles that exist, in sparse consoles).
sourcefn set_all_alpha(&mut self, fg: f32, bg: f32)
fn set_all_alpha(&mut self, fg: f32, bg: f32)
Sets ALL tiles foreground alpha (only tiles that exist, in sparse consoles).
sourcefn set_translation_mode(&mut self, mode: CharacterTranslationMode)
fn set_translation_mode(&mut self, mode: CharacterTranslationMode)
Sets the character translation mode
sourcefn set_char_size(&mut self, width: u32, height: u32)
fn set_char_size(&mut self, width: u32, height: u32)
Sets the character size of the layer. Be really careful with this.