mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
rust: type changes
- rename types in order to make them more similar to the original ones, and so that they play better alongside the higher types defined by notcurses-rs. - Plane -> NcPlane - DirectMode -> NcDirect - DirectModeFlags -> NcDirectFlags - FullMode -> Notcurses - Align -> NcAlign - Blitter -> NcBlitter - Scale -> NcScale - make `types` module re-exportable. - rename nc module to notcurses. - improve comments.
This commit is contained in:
parent
d59d05990b
commit
4beec0845f
@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
use crate as nc;
|
use crate as nc;
|
||||||
use nc::types::{
|
use nc::types::{
|
||||||
AlphaBits, Cell, CellGcluster, Channel, ChannelPair, Color, IntResult, PaletteIndex, Plane,
|
AlphaBits, Cell, CellGcluster, Channel, ChannelPair, Color, IntResult, NcPlane, PaletteIndex,
|
||||||
StyleMask, EGC,
|
StyleMask, EGC,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ pub unsafe fn cell_prime(
|
|||||||
///
|
///
|
||||||
#[allow(unused_unsafe)]
|
#[allow(unused_unsafe)]
|
||||||
pub unsafe fn cells_load_box(
|
pub unsafe fn cells_load_box(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
style: StyleMask,
|
style: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: ChannelPair,
|
||||||
ul: &mut Cell,
|
ul: &mut Cell,
|
||||||
@ -242,7 +242,7 @@ pub fn cell_wide_left_p(cell: &Cell) -> bool {
|
|||||||
/// copy the UTF8-encoded EGC out of the cell, whether simple or complex. the
|
/// copy the UTF8-encoded EGC out of the cell, whether simple or complex. the
|
||||||
/// result is not tied to the ncplane, and persists across erases / destruction.
|
/// result is not tied to the ncplane, and persists across erases / destruction.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_strdup(plane: &Plane, cell: &Cell) -> EGC {
|
pub fn cell_strdup(plane: &NcPlane, cell: &Cell) -> EGC {
|
||||||
core::char::from_u32(
|
core::char::from_u32(
|
||||||
unsafe { libc::strdup(nc::cell_extended_gcluster(plane, cell)) } as i32 as u32,
|
unsafe { libc::strdup(nc::cell_extended_gcluster(plane, cell)) } as i32 as u32,
|
||||||
)
|
)
|
||||||
@ -257,7 +257,7 @@ pub fn cell_strdup(plane: &Plane, cell: &Cell) -> EGC {
|
|||||||
/// Extract the three elements of a cell.
|
/// Extract the three elements of a cell.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cell_extract(
|
pub fn cell_extract(
|
||||||
plane: &Plane,
|
plane: &NcPlane,
|
||||||
cell: &Cell,
|
cell: &Cell,
|
||||||
stylemask: &mut StyleMask,
|
stylemask: &mut StyleMask,
|
||||||
channels: &mut ChannelPair,
|
channels: &mut ChannelPair,
|
||||||
@ -276,7 +276,7 @@ pub fn cell_extract(
|
|||||||
/// be the same. Only the expanded EGC must be equal. The EGC must be bit-equal;
|
/// be the same. Only the expanded EGC must be equal. The EGC must be bit-equal;
|
||||||
/// it would probably be better to test whether they're Unicode-equal FIXME.
|
/// it would probably be better to test whether they're Unicode-equal FIXME.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cellcmp(plane1: &Plane, cell1: &Cell, plane2: &Plane, cell2: &Cell) -> bool {
|
pub fn cellcmp(plane1: &NcPlane, cell1: &Cell, plane2: &NcPlane, cell2: &Cell) -> bool {
|
||||||
if cell1.stylemask != cell2.stylemask {
|
if cell1.stylemask != cell2.stylemask {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ pub fn cellcmp(plane1: &Plane, cell1: &Cell, plane2: &Plane, cell2: &Cell) -> bo
|
|||||||
///
|
///
|
||||||
// NOTE: remove casting for CELL_WIEDASIAN_MASK 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]
|
#[inline]
|
||||||
pub fn cell_load_simple(plane: &mut Plane, cell: &mut Cell, ch: EGC) -> i32 {
|
pub fn cell_load_simple(plane: &mut NcPlane, cell: &mut Cell, ch: EGC) -> i32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::cell_release(plane, cell);
|
nc::cell_release(plane, cell);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
// ncdirect_flush
|
// ncdirect_flush
|
||||||
// ncdirect_getc
|
// ncdirect_getc
|
||||||
// ncdirect_hline_interp
|
// ncdirect_hline_interp
|
||||||
// ncdirect_init // wrapped at start()
|
// ncdirect_init // wrapped at _new() & _with_flags()
|
||||||
// ncdirect_inputready_fd
|
// ncdirect_inputready_fd
|
||||||
// ncdirect_palette_size
|
// ncdirect_palette_size
|
||||||
// ncdirect_printf_aligned
|
// ncdirect_printf_aligned
|
||||||
@ -40,7 +40,7 @@
|
|||||||
// ncdirect_vline_interp
|
// ncdirect_vline_interp
|
||||||
|
|
||||||
use crate as nc;
|
use crate as nc;
|
||||||
use nc::types::{DirectMode, DirectModeFlags};
|
use nc::types::{NcDirect, NcDirectFlags};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn libc_stdout() -> *mut nc::_IO_FILE;
|
fn libc_stdout() -> *mut nc::_IO_FILE;
|
||||||
@ -55,7 +55,7 @@ extern "C" {
|
|||||||
/// used to add color and styling to text in the standard output paradigm.
|
/// used to add color and styling to text in the standard output paradigm.
|
||||||
///
|
///
|
||||||
/// Returns NULL on error, including any failure initializing terminfo.
|
/// Returns NULL on error, including any failure initializing terminfo.
|
||||||
pub unsafe fn ncdirect_new() -> *mut DirectMode {
|
pub unsafe fn ncdirect_new() -> *mut NcDirect {
|
||||||
ncdirect_with_flags(0)
|
ncdirect_with_flags(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +65,6 @@ pub unsafe fn ncdirect_new() -> *mut DirectMode {
|
|||||||
/// - NCDIRECT_OPTION_INHIBIT_CBREAK
|
/// - NCDIRECT_OPTION_INHIBIT_CBREAK
|
||||||
/// - NCDIRECT_OPTION_INHIBIT_SETLOCALE
|
/// - NCDIRECT_OPTION_INHIBIT_SETLOCALE
|
||||||
///
|
///
|
||||||
pub unsafe fn ncdirect_with_flags(flags: DirectModeFlags) -> *mut DirectMode {
|
pub unsafe fn ncdirect_with_flags(flags: NcDirectFlags) -> *mut NcDirect {
|
||||||
nc::ncdirect_init(core::ptr::null(), libc_stdout(), flags)
|
nc::ncdirect_init(core::ptr::null(), libc_stdout(), flags)
|
||||||
}
|
}
|
||||||
|
@ -21,19 +21,20 @@ mod direct;
|
|||||||
mod input;
|
mod input;
|
||||||
mod key;
|
mod key;
|
||||||
mod keycodes;
|
mod keycodes;
|
||||||
mod nc;
|
mod notcurses;
|
||||||
mod palette;
|
mod palette;
|
||||||
mod pixel;
|
mod pixel;
|
||||||
mod plane;
|
mod plane;
|
||||||
mod types;
|
pub mod types; // re-exportable
|
||||||
mod visual;
|
mod visual;
|
||||||
|
|
||||||
pub use cells::*;
|
pub use cells::*;
|
||||||
pub use channel::*;
|
pub use channel::*;
|
||||||
pub use direct::*;
|
pub use direct::*;
|
||||||
pub use input::*;
|
pub use input::*;
|
||||||
pub use key::*;
|
pub use key::*;
|
||||||
pub use keycodes::*;
|
pub use keycodes::*;
|
||||||
pub use nc::*;
|
pub use notcurses::*;
|
||||||
pub use palette::*;
|
pub use palette::*;
|
||||||
pub use pixel::*;
|
pub use pixel::*;
|
||||||
pub use plane::*;
|
pub use plane::*;
|
||||||
|
@ -55,27 +55,27 @@
|
|||||||
use core::ptr::null;
|
use core::ptr::null;
|
||||||
|
|
||||||
use crate as nc;
|
use crate as nc;
|
||||||
use nc::types::{Align, FullMode, Input, Plane, ALIGN_CENTER, ALIGN_LEFT};
|
use nc::types::{Input, NcAlign, NcPlane, Notcurses, NCALIGN_CENTER, NCALIGN_LEFT};
|
||||||
|
|
||||||
/// return the offset into 'availcols' at which 'cols' ought be output given the requirements of 'align'
|
/// return the offset into 'availcols' at which 'cols' ought be output given the requirements of 'align'
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn notcurses_align(availcols: i32, align: Align, cols: i32) -> i32 {
|
pub fn notcurses_align(availcols: i32, align: NcAlign, cols: i32) -> i32 {
|
||||||
if align == ALIGN_LEFT {
|
if align == NCALIGN_LEFT {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if cols > availcols {
|
if cols > availcols {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if align == ALIGN_CENTER {
|
if align == NCALIGN_CENTER {
|
||||||
return (availcols - cols) / 2;
|
return (availcols - cols) / 2;
|
||||||
}
|
}
|
||||||
availcols - cols // ALIGN_RIGHT
|
availcols - cols // NCALIGN_RIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 'input' may be NULL if the caller is uninterested in event details.
|
/// 'input' may be NULL if the caller is uninterested in event details.
|
||||||
/// If no event is ready, returns 0.
|
/// If no event is ready, returns 0.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn notcurses_getc_nblock(nc: &mut FullMode, input: &mut Input) -> nc::char32_t {
|
pub fn notcurses_getc_nblock(nc: &mut Notcurses, input: &mut Input) -> nc::char32_t {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut sigmask = nc::sigset_t { __val: [0; 16] };
|
let mut sigmask = nc::sigset_t { __val: [0; 16] };
|
||||||
nc::sigfillset(&mut sigmask);
|
nc::sigfillset(&mut sigmask);
|
||||||
@ -90,7 +90,7 @@ pub fn notcurses_getc_nblock(nc: &mut FullMode, input: &mut Input) -> nc::char32
|
|||||||
/// 'input' may be NULL if the caller is uninterested in event details.
|
/// 'input' may be NULL if the caller is uninterested in event details.
|
||||||
/// Blocks until an event is processed or a signal is received.
|
/// Blocks until an event is processed or a signal is received.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn notcurses_getc_nblocking(nc: &mut FullMode, input: &mut Input) -> nc::char32_t {
|
pub fn notcurses_getc_nblocking(nc: &mut Notcurses, input: &mut Input) -> nc::char32_t {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut sigmask = nc::sigset_t { __val: [0; 16] };
|
let mut sigmask = nc::sigset_t { __val: [0; 16] };
|
||||||
nc::sigemptyset(&mut sigmask);
|
nc::sigemptyset(&mut sigmask);
|
||||||
@ -100,7 +100,7 @@ pub fn notcurses_getc_nblocking(nc: &mut FullMode, input: &mut Input) -> nc::cha
|
|||||||
|
|
||||||
/// notcurses_stdplane(), plus free bonus dimensions written to non-NULL y/x!
|
/// notcurses_stdplane(), plus free bonus dimensions written to non-NULL y/x!
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn notcurses_stddim_yx(nc: &mut FullMode, y: &mut i32, x: &mut i32) -> Plane {
|
pub fn notcurses_stddim_yx(nc: &mut Notcurses, y: &mut i32, x: &mut i32) -> NcPlane {
|
||||||
unsafe {
|
unsafe {
|
||||||
let s = nc::notcurses_stdplane(nc);
|
let s = nc::notcurses_stdplane(nc);
|
||||||
nc::ncplane_dim_yx(s, y, x);
|
nc::ncplane_dim_yx(s, y, x);
|
||||||
@ -110,14 +110,14 @@ pub fn notcurses_stddim_yx(nc: &mut FullMode, y: &mut i32, x: &mut i32) -> Plane
|
|||||||
|
|
||||||
/// Return our current idea of the terminal dimensions in rows and cols.
|
/// Return our current idea of the terminal dimensions in rows and cols.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn notcurses_term_dim_yx(nc: &FullMode, rows: &mut i32, cols: &mut i32) {
|
pub fn notcurses_term_dim_yx(nc: &Notcurses, rows: &mut i32, cols: &mut i32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_dim_yx(nc::notcurses_stdplane_const(nc), rows, cols);
|
nc::ncplane_dim_yx(nc::notcurses_stdplane_const(nc), rows, cols);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// pub unsafe fn notcurses_start() -> *mut FullMode {
|
// pub unsafe fn notcurses_start() -> *mut Notcurses {
|
||||||
// nc::notcurses_init(core::ptr::null(), libc_stdout())
|
// nc::notcurses_init(core::ptr::null(), libc_stdout())
|
||||||
// }
|
// }
|
||||||
|
|
@ -156,7 +156,8 @@ use cstr_core::CString;
|
|||||||
|
|
||||||
use crate as nc;
|
use crate as nc;
|
||||||
use nc::types::{
|
use nc::types::{
|
||||||
Align, AlphaBits, Cell, Channel, ChannelPair, Color, EGCBackstop, IntResult, Plane, StyleMask,
|
AlphaBits, Cell, Channel, ChannelPair, Color, EGCBackstop, IntResult, NcAlign, NcPlane,
|
||||||
|
StyleMask,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Return the column at which 'cols' columns ought start in order to be aligned
|
/// Return the column at which 'cols' columns ought start in order to be aligned
|
||||||
@ -165,14 +166,14 @@ use nc::types::{
|
|||||||
//
|
//
|
||||||
// NOTE: [leave cols as i32](https://github.com/dankamongmen/notcurses/issues/904)
|
// NOTE: [leave cols as i32](https://github.com/dankamongmen/notcurses/issues/904)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_align(plane: &Plane, align: Align, cols: i32) -> i32 {
|
pub fn ncplane_align(plane: &NcPlane, align: NcAlign, cols: i32) -> i32 {
|
||||||
nc::notcurses_align(nc::ncplane_dim_x(plane), align, cols)
|
nc::notcurses_align(nc::ncplane_dim_x(plane), align, cols)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve the current contents of the cell under the cursor into 'cell'.
|
/// Retrieve the current contents of the cell under the cursor into 'cell'.
|
||||||
/// This cell is invalidated if the associated plane is destroyed.
|
/// This cell is invalidated if the associated plane is destroyed.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn nplane_at_cursor_cell(plane: &mut Plane, cell: &mut Cell) -> IntResult {
|
pub fn nplane_at_cursor_cell(plane: &mut NcPlane, cell: &mut Cell) -> IntResult {
|
||||||
let mut egc = unsafe { nc::ncplane_at_cursor(plane, &mut cell.stylemask, &mut cell.channels) };
|
let mut egc = unsafe { nc::ncplane_at_cursor(plane, &mut cell.stylemask, &mut cell.channels) };
|
||||||
if egc.is_null() {
|
if egc.is_null() {
|
||||||
return -1;
|
return -1;
|
||||||
@ -189,7 +190,7 @@ pub fn nplane_at_cursor_cell(plane: &mut Plane, cell: &mut Cell) -> IntResult {
|
|||||||
/// Retrieve the current contents of the specified cell into 'cell'.
|
/// Retrieve the current contents of the specified cell into 'cell'.
|
||||||
/// This cell is invalidated if the associated plane is destroyed.
|
/// This cell is invalidated if the associated plane is destroyed.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_at_yx_cell(plane: &mut Plane, y: i32, x: i32, cell: &mut Cell) -> IntResult {
|
pub fn ncplane_at_yx_cell(plane: &mut NcPlane, y: i32, x: i32, cell: &mut Cell) -> IntResult {
|
||||||
let mut egc =
|
let mut egc =
|
||||||
unsafe { nc::ncplane_at_yx(plane, y, x, &mut cell.stylemask, &mut cell.channels) };
|
unsafe { nc::ncplane_at_yx(plane, y, x, &mut cell.stylemask, &mut cell.channels) };
|
||||||
if egc.is_null() {
|
if egc.is_null() {
|
||||||
@ -209,7 +210,7 @@ pub fn ncplane_at_yx_cell(plane: &mut Plane, y: i32, x: i32, cell: &mut Cell) ->
|
|||||||
/// minimum box size is 2x2, and it cannot be drawn off-screen.
|
/// minimum box size is 2x2, and it cannot be drawn off-screen.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_box_sized(
|
pub fn ncplane_box_sized(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
ul: &Cell,
|
ul: &Cell,
|
||||||
ur: &Cell,
|
ur: &Cell,
|
||||||
ll: &Cell,
|
ll: &Cell,
|
||||||
@ -240,7 +241,7 @@ pub fn ncplane_box_sized(
|
|||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_dim_x(plane: &Plane) -> i32 {
|
pub fn ncplane_dim_x(plane: &NcPlane) -> i32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut x = 0;
|
let mut x = 0;
|
||||||
nc::ncplane_dim_yx(plane, null_mut(), &mut x);
|
nc::ncplane_dim_yx(plane, null_mut(), &mut x);
|
||||||
@ -250,7 +251,7 @@ pub fn ncplane_dim_x(plane: &Plane) -> i32 {
|
|||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_dim_y(plane: &Plane) -> i32 {
|
pub fn ncplane_dim_y(plane: &NcPlane) -> i32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
nc::ncplane_dim_yx(plane, &mut y, null_mut());
|
nc::ncplane_dim_yx(plane, &mut y, null_mut());
|
||||||
@ -261,7 +262,7 @@ pub fn ncplane_dim_y(plane: &Plane) -> i32 {
|
|||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_double_box(
|
pub fn ncplane_double_box(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: ChannelPair,
|
||||||
ystop: i32,
|
ystop: i32,
|
||||||
@ -307,7 +308,7 @@ pub fn ncplane_double_box(
|
|||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_double_box_sized(
|
pub fn ncplane_double_box_sized(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: ChannelPair,
|
||||||
ylen: i32,
|
ylen: i32,
|
||||||
@ -330,14 +331,14 @@ pub fn ncplane_double_box_sized(
|
|||||||
|
|
||||||
/// On error, return the negative number of cells drawn.
|
/// On error, return the negative number of cells drawn.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_hline(plane: &mut Plane, cell: &Cell, len: i32) -> i32 {
|
pub fn ncplane_hline(plane: &mut NcPlane, cell: &Cell, len: i32) -> i32 {
|
||||||
unsafe { nc::ncplane_hline_interp(plane, cell, len, cell.channels, cell.channels) }
|
unsafe { nc::ncplane_hline_interp(plane, cell, len, cell.channels, cell.channels) }
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_perimeter(
|
pub fn ncplane_perimeter(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
ul: &Cell,
|
ul: &Cell,
|
||||||
ur: &Cell,
|
ur: &Cell,
|
||||||
ll: &Cell,
|
ll: &Cell,
|
||||||
@ -357,7 +358,7 @@ pub fn ncplane_perimeter(
|
|||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_perimeter_double(
|
pub fn ncplane_perimeter_double(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: ChannelPair,
|
||||||
ctlword: u32,
|
ctlword: u32,
|
||||||
@ -406,7 +407,7 @@ pub fn ncplane_perimeter_double(
|
|||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_perimeter_rounded(
|
pub fn ncplane_perimeter_rounded(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: ChannelPair,
|
||||||
ctlword: u32,
|
ctlword: u32,
|
||||||
@ -454,19 +455,19 @@ pub fn ncplane_perimeter_rounded(
|
|||||||
|
|
||||||
/// Call ncplane_putc_yx() for the current cursor location.
|
/// Call ncplane_putc_yx() for the current cursor location.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_putc(plane: &mut Plane, cell: &Cell) -> IntResult {
|
pub fn ncplane_putc(plane: &mut NcPlane, cell: &Cell) -> IntResult {
|
||||||
unsafe { nc::ncplane_putc_yx(plane, -1, -1, cell) }
|
unsafe { nc::ncplane_putc_yx(plane, -1, -1, cell) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Call ncplane_putegc() at the current cursor location.
|
/// Call ncplane_putegc() at the current cursor location.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_putegc(plane: &mut Plane, gcluster: i8, sbytes: &mut i32) -> IntResult {
|
pub fn ncplane_putegc(plane: &mut NcPlane, gcluster: i8, sbytes: &mut i32) -> IntResult {
|
||||||
unsafe { nc::ncplane_putegc_yx(plane, -1, -1, &gcluster, sbytes) }
|
unsafe { nc::ncplane_putegc_yx(plane, -1, -1, &gcluster, sbytes) }
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_putstr(plane: &mut Plane, gclustarr: &[u8]) -> IntResult {
|
pub fn ncplane_putstr(plane: &mut NcPlane, gclustarr: &[u8]) -> IntResult {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_putstr_yx(
|
nc::ncplane_putstr_yx(
|
||||||
plane,
|
plane,
|
||||||
@ -479,7 +480,7 @@ pub fn ncplane_putstr(plane: &mut Plane, gclustarr: &[u8]) -> IntResult {
|
|||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_putnstr(plane: &mut Plane, size: nc::size_t, gclustarr: &[u8]) -> IntResult {
|
pub fn ncplane_putnstr(plane: &mut NcPlane, size: nc::size_t, gclustarr: &[u8]) -> IntResult {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_putnstr_yx(
|
nc::ncplane_putnstr_yx(
|
||||||
plane,
|
plane,
|
||||||
@ -494,7 +495,7 @@ pub fn ncplane_putnstr(plane: &mut Plane, size: nc::size_t, gclustarr: &[u8]) ->
|
|||||||
/// Resize the plane, retaining what data we can (everything, unless we're
|
/// Resize the plane, retaining what data we can (everything, unless we're
|
||||||
/// shrinking in some dimension). Keep the origin where it is.
|
/// shrinking in some dimension). Keep the origin where it is.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_resize_simple(plane: &mut Plane, ylen: i32, xlen: i32) -> IntResult {
|
pub fn ncplane_resize_simple(plane: &mut NcPlane, ylen: i32, xlen: i32) -> IntResult {
|
||||||
let (mut oldy, mut oldx) = (0, 0);
|
let (mut oldy, mut oldx) = (0, 0);
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_dim_yx(plane, &mut oldy, &mut oldx);
|
nc::ncplane_dim_yx(plane, &mut oldy, &mut oldx);
|
||||||
@ -519,13 +520,13 @@ pub fn ncplane_resize_simple(plane: &mut Plane, ylen: i32, xlen: i32) -> IntResu
|
|||||||
///
|
///
|
||||||
/// On error, return the negative number of cells drawn.
|
/// On error, return the negative number of cells drawn.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_vline(plane: &mut Plane, cell: &Cell, len: i32) -> i32 {
|
pub fn ncplane_vline(plane: &mut NcPlane, cell: &Cell, len: i32) -> i32 {
|
||||||
unsafe { nc::ncplane_vline_interp(plane, cell, len, cell.channels, cell.channels) }
|
unsafe { nc::ncplane_vline_interp(plane, cell, len, cell.channels, cell.channels) }
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_vprintf(plane: &mut Plane, format: &str, ap: &mut nc::__va_list_tag) -> IntResult {
|
pub fn ncplane_vprintf(plane: &mut NcPlane, format: &str, ap: &mut nc::__va_list_tag) -> IntResult {
|
||||||
unsafe {
|
unsafe {
|
||||||
nc::ncplane_vprintf_yx(
|
nc::ncplane_vprintf_yx(
|
||||||
plane,
|
plane,
|
||||||
@ -543,7 +544,7 @@ pub fn ncplane_vprintf(plane: &mut Plane, format: &str, ap: &mut nc::__va_list_t
|
|||||||
// XXX receive cells as u32? https://github.com/dankamongmen/notcurses/issues/920
|
// XXX receive cells as u32? https://github.com/dankamongmen/notcurses/issues/920
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_gradient_sized(
|
pub fn ncplane_gradient_sized(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
egc: &[u8],
|
egc: &[u8],
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
ul: u64,
|
ul: u64,
|
||||||
@ -575,56 +576,56 @@ pub fn ncplane_gradient_sized(
|
|||||||
|
|
||||||
/// Extract the 32-bit working foreground channel from an ncplane.
|
/// Extract the 32-bit working foreground channel from an ncplane.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_fchannel(plane: &Plane) -> Channel {
|
pub fn ncplane_fchannel(plane: &NcPlane) -> Channel {
|
||||||
nc::channels_fchannel(unsafe { nc::ncplane_channels(plane) })
|
nc::channels_fchannel(unsafe { nc::ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract the 32-bit working background channel from an ncplane.
|
/// Extract the 32-bit working background channel from an ncplane.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_bchannel(plane: &Plane) -> Channel {
|
pub fn ncplane_bchannel(plane: &NcPlane) -> Channel {
|
||||||
nc::channels_bchannel(unsafe { nc::ncplane_channels(plane) })
|
nc::channels_bchannel(unsafe { nc::ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of working foreground RGB from an ncplane, shifted to LSBs.
|
/// Extract 24 bits of working foreground RGB from an ncplane, shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_fg_rgb(plane: &Plane) -> Channel {
|
pub fn ncplane_fg_rgb(plane: &NcPlane) -> Channel {
|
||||||
nc::channels_fg_rgb(unsafe { nc::ncplane_channels(plane) })
|
nc::channels_fg_rgb(unsafe { nc::ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of working background RGB from an ncplane, shifted to LSBs.
|
/// Extract 24 bits of working background RGB from an ncplane, shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_bg_rgb(plane: &Plane) -> Channel {
|
pub fn ncplane_bg_rgb(plane: &NcPlane) -> Channel {
|
||||||
nc::channels_bg_rgb(unsafe { nc::ncplane_channels(plane) })
|
nc::channels_bg_rgb(unsafe { nc::ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 2 bits of foreground alpha from 'struct ncplane', shifted to LSBs.
|
/// Extract 2 bits of foreground alpha from 'struct ncplane', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_fg_alpha(plane: &Plane) -> AlphaBits {
|
pub fn ncplane_fg_alpha(plane: &NcPlane) -> AlphaBits {
|
||||||
nc::channels_fg_alpha(unsafe { nc::ncplane_channels(plane) })
|
nc::channels_fg_alpha(unsafe { nc::ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 2 bits of background alpha from 'struct ncplane', shifted to LSBs.
|
/// Extract 2 bits of background alpha from 'struct ncplane', shifted to LSBs.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_bg_alpha(plane: &Plane) -> AlphaBits {
|
pub fn ncplane_bg_alpha(plane: &NcPlane) -> AlphaBits {
|
||||||
nc::channels_bg_alpha(unsafe { nc::ncplane_channels(plane) })
|
nc::channels_bg_alpha(unsafe { nc::ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the plane's foreground using the "default foreground color"?
|
/// Is the plane's foreground using the "default foreground color"?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_fg_default_p(plane: &Plane) -> bool {
|
pub fn ncplane_fg_default_p(plane: &NcPlane) -> bool {
|
||||||
nc::channels_fg_default_p(unsafe { nc::ncplane_channels(plane) })
|
nc::channels_fg_default_p(unsafe { nc::ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the plane's background using the "default background color"?
|
/// Is the plane's background using the "default background color"?
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_bg_default_p(plane: &Plane) -> bool {
|
pub fn ncplane_bg_default_p(plane: &NcPlane) -> bool {
|
||||||
nc::channels_bg_default_p(unsafe { nc::ncplane_channels(plane) })
|
nc::channels_bg_default_p(unsafe { nc::ncplane_channels(plane) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract 24 bits of foreground RGB from a plane, split into components.
|
/// Extract 24 bits of foreground RGB from a plane, split into components.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_fg_rgb8(
|
pub fn ncplane_fg_rgb8(
|
||||||
plane: &Plane,
|
plane: &NcPlane,
|
||||||
red: &mut Color,
|
red: &mut Color,
|
||||||
green: &mut Color,
|
green: &mut Color,
|
||||||
blue: &mut Color,
|
blue: &mut Color,
|
||||||
@ -635,7 +636,7 @@ pub fn ncplane_fg_rgb8(
|
|||||||
/// Extract 24 bits of background RGB from a plane, split into components.
|
/// Extract 24 bits of background RGB from a plane, split into components.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_bg_rgb8(
|
pub fn ncplane_bg_rgb8(
|
||||||
plane: &Plane,
|
plane: &NcPlane,
|
||||||
red: &mut Color,
|
red: &mut Color,
|
||||||
green: &mut Color,
|
green: &mut Color,
|
||||||
blue: &mut Color,
|
blue: &mut Color,
|
||||||
@ -646,7 +647,7 @@ pub fn ncplane_bg_rgb8(
|
|||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_rounded_box(
|
pub fn ncplane_rounded_box(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: ChannelPair,
|
||||||
ystop: i32,
|
ystop: i32,
|
||||||
@ -692,7 +693,7 @@ pub fn ncplane_rounded_box(
|
|||||||
///
|
///
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn ncplane_rounded_box_sized(
|
pub fn ncplane_rounded_box_sized(
|
||||||
plane: &mut Plane,
|
plane: &mut NcPlane,
|
||||||
stylemask: StyleMask,
|
stylemask: StyleMask,
|
||||||
channels: ChannelPair,
|
channels: ChannelPair,
|
||||||
ylen: i32,
|
ylen: i32,
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
//! The notcurses types are defined and/or explained here
|
//! The notcurses types are defined and/or explained here
|
||||||
//!
|
//!
|
||||||
|
//! Existing types are wrapped to make them follow the Rust API Guidelines
|
||||||
|
//! and to enforce type check whenever possible
|
||||||
|
//!
|
||||||
|
//! See: [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/naming.html)
|
||||||
|
|
||||||
use crate as nc;
|
use crate as nc;
|
||||||
|
|
||||||
/// RGB: 24 bits broken into 3x 8bpp channels.
|
/// RGB: 24 bits broken into 3x 8bpp channels.
|
||||||
@ -202,7 +207,7 @@ pub type StyleMask = u16;
|
|||||||
// - EGCPool
|
// - EGCPool
|
||||||
//
|
//
|
||||||
// type in C: ncplane (struct)
|
// type in C: ncplane (struct)
|
||||||
pub type Plane = nc::ncplane;
|
pub type NcPlane = nc::ncplane;
|
||||||
|
|
||||||
// EGCPool: contiguous region chopped up into NUL-terminated UTF8 EGCs, one per plane
|
// EGCPool: contiguous region chopped up into NUL-terminated UTF8 EGCs, one per plane
|
||||||
//
|
//
|
||||||
@ -211,82 +216,80 @@ pub type Plane = nc::ncplane;
|
|||||||
// CellMatrix: rectilinear array of Cells
|
// CellMatrix: rectilinear array of Cells
|
||||||
// one -- fb per plane, and transients show up ?
|
// one -- fb per plane, and transients show up ?
|
||||||
|
|
||||||
|
/// Typle alias of palette256
|
||||||
|
pub type Palette = nc::palette256;
|
||||||
|
|
||||||
/// 8-bit value used for indexing into a palette
|
/// 8-bit value used for indexing into a palette
|
||||||
///
|
///
|
||||||
pub type PaletteIndex = u8;
|
pub type PaletteIndex = u8;
|
||||||
pub type Palette = nc::palette256;
|
|
||||||
|
|
||||||
/// 32-bit signed value used to return errors, when value < 0, (usually -1)
|
/// 32-bit signed value used to return errors, when value < 0, (usually -1)
|
||||||
///
|
///
|
||||||
pub type IntResult = i32;
|
pub type IntResult = i32;
|
||||||
|
|
||||||
|
|
||||||
/// Type alias of ncalign_e
|
/// Type alias of ncalign_e
|
||||||
pub type Align = nc::ncalign_e;
|
pub type NcAlign = nc::ncalign_e;
|
||||||
pub const ALIGN_LEFT: Align = nc::ncalign_e_NCALIGN_LEFT;
|
pub const NCALIGN_LEFT: NcAlign = nc::ncalign_e_NCALIGN_LEFT;
|
||||||
pub const ALIGN_RIGHT: Align = nc::ncalign_e_NCALIGN_RIGHT;
|
pub const NCALIGN_RIGHT: NcAlign = nc::ncalign_e_NCALIGN_RIGHT;
|
||||||
pub const ALIGN_CENTER: Align = nc::ncalign_e_NCALIGN_CENTER;
|
pub const NCALIGN_CENTER: NcAlign = nc::ncalign_e_NCALIGN_CENTER;
|
||||||
|
|
||||||
|
|
||||||
/// Type alias of ncblitter_e
|
/// Type alias of ncblitter_e
|
||||||
pub type Blitter = nc::ncblitter_e;
|
pub type NcBlitter = nc::ncblitter_e;
|
||||||
|
|
||||||
/// space, compatible with ASCII
|
/// space, compatible with ASCII
|
||||||
pub const BLIT_1x1: Blitter = nc::ncblitter_e_NCBLIT_1x1;
|
pub const NCBLIT_1x1: NcBlitter = nc::ncblitter_e_NCBLIT_1x1;
|
||||||
|
|
||||||
/// halves + 1x1 (space)
|
/// halves + 1x1 (space)
|
||||||
/// ▄▀
|
/// ▄▀
|
||||||
pub const BLIT_2x1: Blitter = nc::ncblitter_e_NCBLIT_2x1;
|
pub const NCBLIT_2x1: NcBlitter = nc::ncblitter_e_NCBLIT_2x1;
|
||||||
|
|
||||||
/// quadrants + 2x1
|
/// quadrants + 2x1
|
||||||
/// ▗▐ ▖▀▟▌▙
|
/// ▗▐ ▖▀▟▌▙
|
||||||
pub const BLIT_2x2: Blitter = nc::ncblitter_e_NCBLIT_2x2;
|
pub const NCBLIT_2x2: NcBlitter = nc::ncblitter_e_NCBLIT_2x2;
|
||||||
|
|
||||||
/// sextants (NOT 2x2)
|
/// sextants (NOT 2x2)
|
||||||
/// 🬀🬁🬂🬃🬄🬅🬆🬇🬈🬉🬊🬋🬌🬍🬎🬏🬐🬑🬒🬓🬔🬕🬖🬗🬘🬙🬚🬛🬜🬝🬞🬟🬠🬡🬢🬣🬤🬥🬦🬧🬨🬩🬪🬫🬬🬭🬮🬯🬰🬱🬲🬳🬴🬵🬶🬷🬸🬹🬺🬻
|
/// 🬀🬁🬂🬃🬄🬅🬆🬇🬈🬉🬊🬋🬌🬍🬎🬏🬐🬑🬒🬓🬔🬕🬖🬗🬘🬙🬚🬛🬜🬝🬞🬟🬠🬡🬢🬣🬤🬥🬦🬧🬨🬩🬪🬫🬬🬭🬮🬯🬰🬱🬲🬳🬴🬵🬶🬷🬸🬹🬺🬻
|
||||||
pub const BLIT_3x2: Blitter = nc::ncblitter_e_NCBLIT_3x2;
|
pub const NCBLIT_3x2: NcBlitter = nc::ncblitter_e_NCBLIT_3x2;
|
||||||
|
|
||||||
/// four vertical levels
|
/// four vertical levels
|
||||||
/// █▆▄▂
|
/// █▆▄▂
|
||||||
pub const BLIT_4x1: Blitter = nc::ncblitter_e_NCBLIT_4x1;
|
pub const NCBLIT_4x1: NcBlitter = nc::ncblitter_e_NCBLIT_4x1;
|
||||||
|
|
||||||
/// eight vertical levels
|
/// eight vertical levels
|
||||||
/// █▇▆▅▄▃▂▁
|
/// █▇▆▅▄▃▂▁
|
||||||
pub const BLIT_8x1: Blitter = nc::ncblitter_e_NCBLIT_8x1;
|
pub const NCBLIT_8x1: NcBlitter = nc::ncblitter_e_NCBLIT_8x1;
|
||||||
|
|
||||||
/// 4 rows, 2 cols (braille)
|
/// 4 rows, 2 cols (braille)
|
||||||
/// ⡀⡄⡆⡇⢀⣀⣄⣆⣇⢠⣠⣤⣦⣧⢰⣰⣴⣶⣷⢸⣸⣼⣾⣿
|
/// ⡀⡄⡆⡇⢀⣀⣄⣆⣇⢠⣠⣤⣦⣧⢰⣰⣴⣶⣷⢸⣸⣼⣾⣿
|
||||||
pub const BLIT_BRAILLE: Blitter = nc::ncblitter_e_NCBLIT_BRAILLE;
|
pub const NCBLIT_BRAILLE: NcBlitter = nc::ncblitter_e_NCBLIT_BRAILLE;
|
||||||
|
|
||||||
/// the blitter is automatically chosen
|
/// the blitter is automatically chosen
|
||||||
pub const BLIT_DEFAULT: Blitter = nc::ncblitter_e_NCBLIT_DEFAULT;
|
pub const NCBLIT_DEFAULT: NcBlitter = nc::ncblitter_e_NCBLIT_DEFAULT;
|
||||||
|
|
||||||
/// 6 rows, 1 col (RGB), spotty support among terminals
|
/// 6 rows, 1 col (RGB), spotty support among terminals
|
||||||
pub const BLIT_SIXEL: Blitter = nc::ncblitter_e_NCBLIT_SIXEL;
|
pub const NCBLIT_SIXEL: NcBlitter = nc::ncblitter_e_NCBLIT_SIXEL;
|
||||||
|
|
||||||
|
|
||||||
/// Type alias of ncscale_e
|
/// Type alias of ncscale_e
|
||||||
pub type Scale = nc::ncscale_e;
|
pub type Scale = nc::ncscale_e;
|
||||||
|
|
||||||
/// Maintain original size
|
/// Maintain original size
|
||||||
pub const SCALE_NONE: Scale = nc::ncscale_e_NCSCALE_NONE;
|
pub const NCSCALE_NONE: Scale = nc::ncscale_e_NCSCALE_NONE;
|
||||||
|
|
||||||
/// Maintain aspect ratio
|
/// Maintain aspect ratio
|
||||||
pub const SCALE_SCALE: Scale = nc::ncscale_e_NCSCALE_SCALE;
|
pub const NCSCALE_SCALE: Scale = nc::ncscale_e_NCSCALE_SCALE;
|
||||||
|
|
||||||
/// Throw away aspect ratio
|
/// Throw away aspect ratio
|
||||||
pub const SCALE_STRETCH: Scale = nc::ncscale_e_NCSCALE_STRETCH;
|
pub const NCSCALE_STRETCH: Scale = nc::ncscale_e_NCSCALE_STRETCH;
|
||||||
|
|
||||||
|
|
||||||
/// Type alias of ncdirect (direct mode)
|
/// Type alias of ncdirect (direct mode)
|
||||||
pub type DirectMode = nc::ncdirect;
|
pub type NcDirect = nc::ncdirect;
|
||||||
|
|
||||||
|
|
||||||
/// Type alias of
|
/// Type alias of
|
||||||
pub type DirectModeFlags = u64;
|
pub type NcDirectFlags = u64;
|
||||||
|
|
||||||
/// Avoids placing the terminal into cbreak mode (disabling echo and line buffering)
|
/// Avoids placing the terminal into cbreak mode (disabling echo and line buffering)
|
||||||
pub const DIRECTMODE_INHIBIT_CBREAK: DirectModeFlags = nc::NCDIRECT_OPTION_INHIBIT_CBREAK as DirectModeFlags;
|
pub const NCDIRECT_INHIBIT_CBREAK: NcDirectFlags =
|
||||||
|
nc::NCDIRECT_OPTION_INHIBIT_CBREAK as NcDirectFlags;
|
||||||
|
|
||||||
/// Avoids calling setlocale(LC_ALL, NULL).
|
/// Avoids calling setlocale(LC_ALL, NULL).
|
||||||
///
|
///
|
||||||
@ -294,12 +297,11 @@ pub const DIRECTMODE_INHIBIT_CBREAK: DirectModeFlags = nc::NCDIRECT_OPTION_INHIB
|
|||||||
/// and then call setlocale(LC_ALL, ""). This will attempt to set the locale based
|
/// and then call setlocale(LC_ALL, ""). This will attempt to set the locale based
|
||||||
/// off the LANG environment variable. Your program should call setlocale(3) itself,
|
/// off the LANG environment variable. Your program should call setlocale(3) itself,
|
||||||
/// usually as one of the first lines.
|
/// usually as one of the first lines.
|
||||||
pub const DIRECTMODE_INHIBIT_SETLOCALE: DirectModeFlags = nc::NCDIRECT_OPTION_INHIBIT_SETLOCALE as DirectModeFlags;
|
pub const NCDIRECT_INHIBIT_SETLOCALE: NcDirectFlags =
|
||||||
|
nc::NCDIRECT_OPTION_INHIBIT_SETLOCALE as NcDirectFlags;
|
||||||
|
|
||||||
/// Type alias of notcurses (full mode)
|
/// Type alias of notcurses (full mode)
|
||||||
pub type FullMode = nc::notcurses;
|
pub type Notcurses = nc::bindings::notcurses;
|
||||||
|
|
||||||
|
|
||||||
/// Type alias of ncinput
|
/// Type alias of ncinput
|
||||||
pub type Input = nc::ncinput;
|
pub type Input = nc::ncinput;
|
||||||
|
@ -26,21 +26,21 @@
|
|||||||
// ncvisual_default_blitter
|
// ncvisual_default_blitter
|
||||||
|
|
||||||
use crate as nc;
|
use crate as nc;
|
||||||
use nc::types::{BLIT_1x1, BLIT_2x1, BLIT_2x2, Blitter, Scale, SCALE_STRETCH};
|
use nc::types::{NCBLIT_1x1, NCBLIT_2x1, NCBLIT_2x2, NcBlitter, Scale, NCSCALE_STRETCH};
|
||||||
|
|
||||||
/// Returns the best default blitter available
|
/// Returns the best default blitter available
|
||||||
///
|
///
|
||||||
/// NCBLIT_3x2 is better image quality, especially for large images, but
|
/// NCBLIT_3x2 is better image quality, especially for large images, but
|
||||||
/// it's not the general default because it doesn't preserve aspect ratio.
|
/// it's not the general default because it doesn't preserve aspect ratio.
|
||||||
/// NCSCALE_STRETCH throws away aspect ratio, and can safely use NCBLIT_3x2.
|
/// NCSCALE_STRETCH throws away aspect ratio, and can safely use NCBLIT_3x2.
|
||||||
pub fn ncvisual_default_blitter(utf8: bool, scale: Scale) -> Blitter {
|
pub fn ncvisual_default_blitter(utf8: bool, scale: Scale) -> NcBlitter {
|
||||||
if utf8 {
|
if utf8 {
|
||||||
if scale == SCALE_STRETCH {
|
if scale == NCSCALE_STRETCH {
|
||||||
return BLIT_2x2;
|
return NCBLIT_2x2;
|
||||||
}
|
}
|
||||||
return BLIT_2x1;
|
return NCBLIT_2x1;
|
||||||
}
|
}
|
||||||
BLIT_1x1
|
NCBLIT_1x1
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user