diff options
-rw-r--r-- | src/cell.rs | 28 | ||||
-rw-r--r-- | src/ffi.c | 16 | ||||
-rw-r--r-- | src/ffi.rs | 8 |
3 files changed, 36 insertions, 16 deletions
diff --git a/src/cell.rs b/src/cell.rs index e78f16c..abec58f 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -58,21 +58,41 @@ impl Cell { pub fn bold(&self) -> bool { let Cell(cell_impl) = *self; - unsafe { ffi::vt100_wrapper_cell_bold(cell_impl) != 0 } + let prefix: *mut CellPrefix = unsafe { + std::mem::transmute(cell_impl) + }; + unsafe { + ffi::vt100_wrapper_cell_attrs_bold(&mut (*prefix).attrs) != 0 + } } pub fn italic(&self) -> bool { let Cell(cell_impl) = *self; - unsafe { ffi::vt100_wrapper_cell_italic(cell_impl) != 0 } + let prefix: *mut CellPrefix = unsafe { + std::mem::transmute(cell_impl) + }; + unsafe { + ffi::vt100_wrapper_cell_attrs_italic(&mut (*prefix).attrs) != 0 + } } pub fn underline(&self) -> bool { let Cell(cell_impl) = *self; - unsafe { ffi::vt100_wrapper_cell_underline(cell_impl) != 0 } + let prefix: *mut CellPrefix = unsafe { + std::mem::transmute(cell_impl) + }; + unsafe { + ffi::vt100_wrapper_cell_attrs_underline(&mut (*prefix).attrs) != 0 + } } pub fn inverse(&self) -> bool { let Cell(cell_impl) = *self; - unsafe { ffi::vt100_wrapper_cell_inverse(cell_impl) != 0 } + let prefix: *mut CellPrefix = unsafe { + std::mem::transmute(cell_impl) + }; + unsafe { + ffi::vt100_wrapper_cell_attrs_inverse(&mut (*prefix).attrs) != 0 + } } } @@ -6,22 +6,22 @@ int vt100_wrapper_cell_is_wide(struct vt100_cell *cell) return cell->is_wide; } -int vt100_wrapper_cell_bold(struct vt100_cell *cell) +int vt100_wrapper_cell_attrs_bold(struct vt100_cell_attrs *attrs) { - return cell->attrs.bold; + return attrs->bold; } -int vt100_wrapper_cell_italic(struct vt100_cell *cell) +int vt100_wrapper_cell_attrs_italic(struct vt100_cell_attrs *attrs) { - return cell->attrs.italic; + return attrs->italic; } -int vt100_wrapper_cell_underline(struct vt100_cell *cell) +int vt100_wrapper_cell_attrs_underline(struct vt100_cell_attrs *attrs) { - return cell->attrs.underline; + return attrs->underline; } -int vt100_wrapper_cell_inverse(struct vt100_cell *cell) +int vt100_wrapper_cell_attrs_inverse(struct vt100_cell_attrs *attrs) { - return cell->attrs.inverse; + return attrs->inverse; } @@ -39,10 +39,10 @@ extern "C" { ) -> *mut types::CellImpl; pub fn vt100_wrapper_cell_is_wide(cell: *mut types::CellImpl) -> libc::c_int; - pub fn vt100_wrapper_cell_bold(cell: *mut types::CellImpl) -> libc::c_int; - pub fn vt100_wrapper_cell_italic(cell: *mut types::CellImpl) -> libc::c_int; - pub fn vt100_wrapper_cell_underline(cell: *mut types::CellImpl) -> libc::c_int; - pub fn vt100_wrapper_cell_inverse(cell: *mut types::CellImpl) -> libc::c_int; + pub fn vt100_wrapper_cell_attrs_bold(cell: *mut types::CellAttrs) -> libc::c_int; + pub fn vt100_wrapper_cell_attrs_italic(cell: *mut types::CellAttrs) -> libc::c_int; + pub fn vt100_wrapper_cell_attrs_underline(cell: *mut types::CellAttrs) -> libc::c_int; + pub fn vt100_wrapper_cell_attrs_inverse(cell: *mut types::CellAttrs) -> libc::c_int; } #[cfg(test)] |