servicepoint-binding-c/src/commands/cp437_grid_command.rs
Vinzenz Schroeter 5beea6151a wip generic wrap
2025-06-26 20:42:31 +02:00

39 lines
1.1 KiB
Rust

use crate::{
commands::{wrap_command, wrap_origin_accessors},
macros::{wrap, wrap_functions},
};
use servicepoint::{Cp437Grid, Cp437GridCommand, Origin};
use std::ptr::NonNull;
wrap_command!(Cp437Grid);
wrap!(Cp437GridCommand;
prop grid: Cp437Grid { get mut; set move; };
);
wrap_origin_accessors!(Cp437GridCommand);
wrap_functions!(associate Cp437GridCommand;
/// Show text on the screen.
///
/// The text is sent in the form of a 2D grid of [CP-437] encoded characters.
///
/// The origin is relative to the top-left of the display.
fn new(
grid: move NonNull<Cp437Grid>,
origin_x: val usize,
origin_y: val usize,
) -> move NonNull<Cp437GridCommand> {
Cp437GridCommand {
grid,
origin: Origin::new(origin_x, origin_y),
}
};
/// Moves the provided [Cp437Grid] into a new [Cp437GridCommand],
/// leaving other fields as their default values.
fn from_grid(grid: move NonNull<Cp437Grid>) -> move NonNull<Cp437GridCommand> {
grid.into()
};
);