Trait tcod::console::Console [] [src]

pub trait Console: AsNative<TCOD_console_t> {
    fn get_alignment(&self) -> TextAlignment { ... }
    fn set_alignment(&mut self, alignment: TextAlignment) { ... }
    fn set_key_color(&mut self, color: Color) { ... }
    fn width(&self) -> i32 { ... }
    fn height(&self) -> i32 { ... }
    fn get_default_background(&mut self) -> Color { ... }
    fn set_default_background(&mut self, color: Color) { ... }
    fn set_default_foreground(&mut self, color: Color) { ... }
    fn get_char_background(&self, x: i32, y: i32) -> Color { ... }
    fn get_char_foreground(&self, x: i32, y: i32) -> Color { ... }
    fn get_background_flag(&self) -> BackgroundFlag { ... }
    fn set_background_flag(&mut self, background_flag: BackgroundFlag) { ... }
    fn get_char(&self, x: i32, y: i32) -> char { ... }
    fn set_char(&mut self, x: i32, y: i32, c: char) { ... }
    fn set_char_background(&mut self,
                           x: i32,
                           y: i32,
                           color: Color,
                           background_flag: BackgroundFlag) { ... } fn set_char_foreground(&mut self, x: i32, y: i32, color: Color) { ... } fn put_char(&mut self,
                x: i32,
                y: i32,
                glyph: char,
                background_flag: BackgroundFlag) { ... } fn put_char_ex(&mut self,
                   x: i32,
                   y: i32,
                   glyph: char,
                   foreground: Color,
                   background: Color) { ... } fn clear(&mut self) { ... } fn print<T>(&mut self, x: i32, y: i32, text: T) where Self: Sized, T: AsRef<[u8]> + TcodString { ... } fn print_rect<T>(&mut self,
                     x: i32,
                     y: i32,
                     width: i32,
                     height: i32,
                     text: T) where Self: Sized, T: AsRef<[u8]> + TcodString { ... } fn print_ex<T>(&mut self,
                   x: i32,
                   y: i32,
                   background_flag: BackgroundFlag,
                   alignment: TextAlignment,
                   text: T) where Self: Sized, T: AsRef<[u8]> + TcodString { ... } fn print_rect_ex<T>(&mut self,
                        x: i32,
                        y: i32,
                        width: i32,
                        height: i32,
                        background_flag: BackgroundFlag,
                        alignment: TextAlignment,
                        text: T) where Self: Sized, T: AsRef<[u8]> + TcodString { ... } fn get_height_rect<T>(&self,
                          x: i32,
                          y: i32,
                          width: i32,
                          height: i32,
                          text: T)
                          -> i32 where Self: Sized, T: AsRef<[u8]> + TcodString { ... } fn rect(&mut self,
            x: i32,
            y: i32,
            width: i32,
            height: i32,
            clear: bool,
            background_flag: BackgroundFlag) { ... } fn horizontal_line(&mut self,
                       x: i32,
                       y: i32,
                       length: i32,
                       background_flag: BackgroundFlag) { ... } fn vertical_line(&mut self,
                     x: i32,
                     y: i32,
                     length: i32,
                     background_flag: BackgroundFlag) { ... } fn print_frame<T>(&mut self,
                      x: i32,
                      y: i32,
                      width: i32,
                      height: i32,
                      clear: bool,
                      background_flag: BackgroundFlag,
                      title: Option<T>) where Self: Sized, T: AsRef<str> { ... } }

Defines the common functionality between Root and Offscreen consoles

Examples

Printing text with explicit alignment:

use tcod::console::{Console, Root, BackgroundFlag, TextAlignment};

let mut root = Root::initializer().size(80, 50).init();

root.print_ex(1, 1, BackgroundFlag::None, TextAlignment::Left,
              "Text aligned to left.");

root.print_ex(78, 1, BackgroundFlag::None, TextAlignment::Right,
              "Text aligned to right.");

root.print_ex(40, 15, BackgroundFlag::None, TextAlignment::Center,
              "And this bit of text is centered.");

root.print_ex(40, 19, BackgroundFlag::None, TextAlignment::Center,
              "Press any key to quit.");

Provided Methods

Returns the default text alignment for the Console instance. For all the possible text alignment options, see the documentation for TextAlignment.

Sets the default text alignment for the console. For all the possible text alignment options, see the documentation for TextAlignment.

Sets a key color that will be ignored when blitting the contents of this console onto an other (essentially a transparent background color).

Returns the width of the console in characters.

Returns the height of the console in characters.

Return the console's default background color. This is used in several other methods, like: clear, put_char, etc.

Sets the console's default background color. This is used in several other methods, like: clear, put_char, etc.

Sets the console's default foreground color. This is used in several printing functions.

Returns the background color of the cell at the specified coordinates.

Returns the foreground color of the cell at the specified coordinates.

Returns the console's current background flag. For a detailed explanation of the possible values, see BackgroundFlag.

Sets the console's current background flag. For a detailed explanation of the possible values, see BackgroundFlag.

Returns the ASCII value of the cell located at x, y

Modifies the ASCII value of the cell located at x, y.

Changes the background color of the specified cell

Changes the foreground color of the specified cell

This function modifies every property of the given cell:

  1. Updates its background color according to the console's default and background_flag, see BackgroundFlag.
  2. Updates its foreground color based on the default color set in the console
  3. Sets its ASCII value to glyph

Updates every propert of the given cell using explicit colors for the background and foreground.

Clears the console with its default background color

Prints the text at the specified location. The position of the x and y coordinates depend on the TextAlignment set in the console:

  • TextAlignment::Left: leftmost character of the string
  • TextAlignment::Center: center character of the sting
  • TextAlignment::Right: rightmost character of the string

Prints the text at the specified location in a rectangular area with the dimensions: (width; height). If the text is longer than the width the newlines will be inserted.

Prints the text at the specified location with an explicit BackgroundFlag and TextAlignment.

Combines the functions of print_ex and print_rect

Compute the height of a wrapped text printed using print_rect or print_rect_ex.

Fill a rectangle with the default background colour.

If clear is true, set each cell's character to space (ASCII 32).

Draw a horizontal line.

Uses tcod::chars::HLINE (ASCII 196) as the line character and console's default background and foreground colours.

Draw a vertical line.

Uses tcod::chars::VLINE (ASCII 179) as the line character and console's default background and foreground colours.

Draw a window frame with an optional title.

Draws a rectangle (using the rect method) using the suplied background flag, then draws a rectangle with the console's default foreground colour.

If the title is specified, it will be printed on top of the rectangle using inverted colours.

Implementors