rust: finish adding Notcurses methods.

This commit is contained in:
joseLuís 2020-12-22 15:17:50 +01:00
parent fa693a89c1
commit 4c048ef625
2 changed files with 35 additions and 5 deletions

View File

@ -263,6 +263,19 @@ impl Notcurses {
crate::notcurses_getc_nblocking(self, input)
}
/// Gets a file descriptor suitable for input event poll()ing.
///
/// When this descriptor becomes available, you can call
/// [getc_nblock][Notcurses#method.getc_nblock](), and input ought be ready.
///
/// This file descriptor is not necessarily the file descriptor associated
/// with stdin (but it might be!).
///
/// C style function: [notcurses_inputready_fd][crate::notcurses_inputready_fd]
pub fn inputready_fd(&mut self) -> NcResult {
unsafe { crate::notcurses_inputready_fd(self) }
}
/// Returns an [NcBlitter] from a string representation.
///
/// C style function: [notcurses_lex_blitter][crate::notcurses_lex_blitter]
@ -366,6 +379,24 @@ impl Notcurses {
unsafe { crate::notcurses_render(self) }
}
/// Performs the rendering and rasterization portion of
/// [render][Notcurses#method.render] but do not write the resulting buffer
/// out to the terminal.
///
/// Using this function, the user can control the writeout process,
/// and render a second frame while writing another.
///
/// The returned buffer must be freed by the caller.
///
/// C style function: [notcurses_render_to_buffer][crate::notcurses_render_to_buffer]
//
// CHECK that this works.
pub fn render_to_buffer(&mut self, buffer: &mut Vec<u8>) -> NcResult {
let mut len = buffer.len() as u64;
let mut buf = buffer.as_mut_ptr() as *mut i8;
unsafe { crate::notcurses_render_to_buffer(self, &mut buf, &mut len) }
}
/// Writes the last rendered frame, in its entirety, to 'fp'.
///
/// If [render][Notcurses#method.render]() has not yet been called,
@ -470,7 +501,6 @@ impl Notcurses {
unsafe { &mut *crate::notcurses_top(self) }
}
/// Returns a human-readable string describing the running Notcurses version.
///
/// C style function: [notcurses_version][crate::notcurses_version]

View File

@ -3,7 +3,7 @@
// functions already exported by bindgen : 41
// ------------------------------------------
// (#) test: 10
// (W) wrap: 38
// (W) wrap: 40 / 1
// ------------------------------------------
//W notcurses_at_yx
//W notcurses_bottom
@ -20,7 +20,7 @@
//W# notcurses_drop_planes
//W notcurses_getc
//W# notcurses_init
// notcurses_inputready_fd
//W notcurses_inputready_fd
//W notcurses_lex_blitter
//W notcurses_lex_margins
//W notcurses_lex_scalemode
@ -31,7 +31,7 @@
//W notcurses_palette_size
//W notcurses_refresh
//W notcurses_render
// notcurses_render_to_buffer
//W notcurses_render_to_buffer
//W notcurses_render_to_file
//W notcurses_stats
//W notcurses_stats_alloc
@ -43,7 +43,7 @@
//W notcurses_str_scalemode
//W notcurses_supported_styles
//W notcurses_top
// notcurses_ucs32_to_utf8
//~ notcurses_ucs32_to_utf8 (not needed in rust)
//W notcurses_version
//W notcurses_version_components
//