From 7f175cf37c74a56e7919d391b222375102e7f3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Thu, 17 Dec 2020 12:10:36 +0100 Subject: [PATCH] rust: NcCell width-aware constructors #1203 #1205 --- rust/src/cells/methods.rs | 6 +++--- rust/src/plane/reimplemented.rs | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/rust/src/cells/methods.rs b/rust/src/cells/methods.rs index 67f95c905..71b3d2b9b 100644 --- a/rust/src/cells/methods.rs +++ b/rust/src/cells/methods.rs @@ -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]. diff --git a/rust/src/plane/reimplemented.rs b/rust/src/plane/reimplemented.rs index b70918df1..7fcec2f5e 100644 --- a/rust/src/plane/reimplemented.rs +++ b/rust/src/plane/reimplemented.rs @@ -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) } }