rust: NcCell width-aware constructors #1203 #1205

pull/1232/head
joseLuís 4 years ago
parent 2190b33421
commit 7f175cf37c

@ -9,11 +9,11 @@ use crate::{
impl NcCell {
/// New NcCell, expects a [char], [NcStyleMask] and [NcChannelPair].
#[inline]
pub const fn with_all(ch: char, stylemask: NcStyleMask, channels: NcChannelPair) -> Self {
pub const fn with_all(ch: char, width: u8, stylemask: NcStyleMask, channels: NcChannelPair) -> Self {
NcCell {
gcluster: ch as u32,
gcluster_backstop: 0 as NcEgcBackstop,
width: 0,
width,
stylemask,
channels,
}
@ -22,7 +22,7 @@ impl NcCell {
/// New NcCell, expects a 7-bit [char].
#[inline]
pub const fn with_7bitchar(ch: char) -> Self {
Self::with_all(ch, 0 as NcStyleMask, 0 as NcChannelPair)
Self::with_all(ch, 0_u8, 0 as NcStyleMask, 0 as NcChannelPair)
}
/// New NcCell, expects an [NcPlane] and a [char].

@ -117,11 +117,10 @@ pub fn ncplane_putchar(plane: &mut NcPlane, c: char) -> NcResult {
/// Advance the cursor by 1. On success, returns 1. On failure, returns -1.
/// This works whether the underlying char is signed or unsigned.
#[inline]
// TODO: test char is < 8bit (currently 32bit)
pub fn ncplane_putchar_yx(plane: &mut NcPlane, y: i32, x: i32, c: char) -> NcResult {
pub fn ncplane_putchar_yx(plane: &mut NcPlane, y: i32, x: i32, ch: char) -> NcResult {
unsafe {
let ce = NcCell::with_all(c, ncplane_styles(plane), ncplane_channels(plane));
ncplane_putc_yx(plane, y, x, &ce)
let cell = NcCell::with_all(ch, 0, ncplane_styles(plane), ncplane_channels(plane));
ncplane_putc_yx(plane, y, x, &cell)
}
}

Loading…
Cancel
Save