39 lines
1 KiB
Rust
39 lines
1 KiB
Rust
use crate::{
|
|
commands::{wrap_command, wrap_origin_accessors},
|
|
macros::{wrap_fields, wrap_functions},
|
|
};
|
|
use servicepoint::{CharGrid, CharGridCommand, Origin};
|
|
use std::ptr::NonNull;
|
|
|
|
wrap_command!(CharGrid);
|
|
|
|
wrap_fields!(CharGridCommand;
|
|
prop grid: CharGrid { get mut; set move; };
|
|
);
|
|
|
|
wrap_origin_accessors!(CharGridCommand);
|
|
|
|
wrap_functions!(associate CharGridCommand;
|
|
/// Show UTF-8 encoded text on the screen.
|
|
///
|
|
/// The passed [CharGrid] gets consumed.
|
|
///
|
|
/// Returns: a new [CharGridCommand] instance.
|
|
fn new(
|
|
grid: move NonNull<CharGrid>,
|
|
origin_x: val usize,
|
|
origin_y: val usize,
|
|
) -> move NonNull<CharGridCommand> {
|
|
CharGridCommand {
|
|
grid,
|
|
origin: Origin::new(origin_x, origin_y),
|
|
}
|
|
};
|
|
|
|
/// Moves the provided [CharGrid] into a new [CharGridCommand],
|
|
/// leaving other fields as their default values.
|
|
fn from_grid(grid: move NonNull<CharGrid>) -> move NonNull<CharGridCommand> {
|
|
grid.into()
|
|
};
|
|
);
|