rust: egc char related fixes

pull/922/head
joseLuís 4 years ago
parent 6b36ee8ac3
commit cac8202e03

@ -59,7 +59,7 @@
use crate as ffi;
use ffi::types::{
AlphaBits, Channel, ChannelPair, Color, EGC, IntResult, PaletteIndex, StyleMask,
AlphaBits, Channel, ChannelPair, Color, IntResult, PaletteIndex, StyleMask,
};
use ffi::{cell, ncplane};
@ -305,14 +305,14 @@ pub fn cellcmp(plane1: &ncplane, cell1: &cell, plane2: &ncplane, cell2: &cell) -
}
// TODO: TEST
// NOTE: remove casting when fixed: https://github.com/rust-lang/rust-bindgen/issues/1875
// NOTE: remove casting for CELL_WIEDASIAN_MASK when fixed: https://github.com/rust-lang/rust-bindgen/issues/1875
#[inline]
pub fn cell_load_simple(plane: &mut ncplane, cell: &mut cell, ch: char) -> i32 {
unsafe {
ffi::cell_release(plane, cell);
}
cell.channels &= !(ffi::CELL_WIDEASIAN_MASK as u64 | ffi::CELL_NOBACKGROUND_MASK);
cell.gcluster = ch as EGC;
cell.gcluster = ch as u32;
1
}

@ -4,7 +4,7 @@
macro_rules! cell_initializer {
( $c:expr, $s:expr, $chan:expr ) => {
cell {
gcluster: $c as EGC,
gcluster: $c as u32,
gcluster_backstop: 0 as EGCBackstop,
reserved: 0,
stylemask: $s,

@ -143,7 +143,7 @@ use core::ptr::null_mut;
use cstr_core::CString;
use crate as ffi;
use ffi::types::{AlphaBits, Channel, ChannelPair, Color, EGCBackstop, IntResult, StyleMask, EGC};
use ffi::types::{AlphaBits, Channel, ChannelPair, Color, EGCBackstop, IntResult, StyleMask};
use ffi::{cell, ncalign_e, ncplane};
/// Return the column at which 'cols' columns ought start in order to be aligned
@ -471,8 +471,8 @@ pub fn ncplane_putc(plane: &mut ncplane, cell: &cell) -> IntResult {
/// Call ncplane_putsimple_yx() at the current cursor location.
// TODO: TEST
#[inline]
pub fn ncplane_putsimple(plane: &mut ncplane, char: i8) -> IntResult {
ffi::ncplane_putsimple_yx(plane, -1, -1, char)
pub fn ncplane_putsimple(plane: &mut ncplane, ch: char) -> IntResult {
ffi::ncplane_putsimple_yx(plane, -1, -1, ch)
}
/// Call ncplane_putegc() at the current cursor location.
@ -486,12 +486,12 @@ pub fn ncplane_putegc(plane: &mut ncplane, gcluster: i8, sbytes: &mut i32) -> In
/// of the plane will not be changed.
///
/// Replace the cell at the specified coordinates with the provided 7-bit char
/// 'c'. Advance the cursor by 1. On success, returns 1. On failure, returns -1.
/// 'ch'. Advance the cursor by 1. On success, returns 1. On failure, returns -1.
/// This works whether the underlying char is signed or unsigned.
// TODO: TEST
#[inline]
pub fn ncplane_putsimple_yx(plane: &mut ncplane, y: i32, x: i32, char: i8) -> IntResult {
let newcell = cell_initializer![char, unsafe { ffi::ncplane_attr(plane) }, unsafe {
pub fn ncplane_putsimple_yx(plane: &mut ncplane, y: i32, x: i32, ch: char) -> IntResult {
let newcell = cell_initializer![ch, unsafe { ffi::ncplane_attr(plane) }, unsafe {
ffi::ncplane_channels(plane)
}];
unsafe { ffi::ncplane_putc_yx(plane, y, x, &newcell) }

@ -173,8 +173,10 @@ pub type Pixel = u32;
///
/// type in C: gcluster (uint32_t)
///
pub type EGC = u32;
// pub type EGC<'a> = &'a[u8]; // XXX WIP in a safer abstraction
// WIP towards a safe abstraction for Cell & functions receiving
// pub type EGC = u32;
// pub type EGC = char;
// pub type EGC<'a> = &'a[u8];
/// EGC BackStop
///

Loading…
Cancel
Save