libnotcurses_sys/widgets/reader/
mod.rs

1//! `NcReader` widget.
2
3// functions already exported by bindgen : 11
4// ------------------------------------------
5//  ncreader_clear
6//  ncreader_contents
7//  ncreader_create
8//  ncreader_destroy
9//  ncreader_move_down
10//  ncreader_move_left
11//  ncreader_move_right
12//  ncreader_move_up
13//  ncreader_offer_input
14//  ncreader_plane
15//  ncreader_write_egc
16
17use crate::c_api::ffi;
18
19mod methods;
20
21/// Provides a freeform input in a (possibly multiline) region
22///
23/// Supports optional readline keybindings (opt out using
24/// `NCREADER_OPTION_NOCMDKEYS` flag)
25///
26/// Takes ownership of its [`NcPlane`][crate::NcPlane], destroying it on any
27/// error (otherwise [`destroy`][NcReader#method.destroy] destroys the plane).
28///
29/// `type in C: ncreader (struct)`
30pub type NcReader = ffi::ncreader;
31
32/// Options struct for [`NcReader`]
33///
34/// `type in C: ncreader_options (struct)`
35pub type NcReaderOptions = ffi::ncreader_options;
36
37impl NcReaderOptions {
38    /// Makes the terminal cursor visible across the lifetime of the ncreader, and
39    /// have the ncreader manage the cursor's placement.
40    pub const CURSOR: u32 = c_api::NCREADER_OPTION_CURSOR;
41
42    /// Enables horizontal scrolling. Virtual lines can then grow arbitrarily long.
43    pub const HORSCROLL: u32 = c_api::NCREADER_OPTION_HORSCROLL;
44
45    /// Disables all editing shortcuts. By default, emacs-style keys are available.
46    pub const NOCMDKEYS: u32 = c_api::NCREADER_OPTION_NOCMDKEYS;
47
48    /// Enables vertical scrolling. You can then use arbitrarily many virtual lines.
49    pub const VERSCROLL: u32 = c_api::NCREADER_OPTION_VERSCROLL;
50}
51
52pub(crate) mod c_api {
53    use super::ffi;
54
55    /// Makes the terminal cursor visible across the lifetime of the ncreader, and
56    /// have the ncreader manage the cursor's placement.
57    pub const NCREADER_OPTION_CURSOR: u32 = ffi::NCREADER_OPTION_CURSOR;
58
59    /// Enables horizontal scrolling. Virtual lines can then grow arbitrarily long.
60    pub const NCREADER_OPTION_HORSCROLL: u32 = ffi::NCREADER_OPTION_HORSCROLL;
61
62    /// Disables all editing shortcuts. By default, emacs-style keys are available.
63    pub const NCREADER_OPTION_NOCMDKEYS: u32 = ffi::NCREADER_OPTION_NOCMDKEYS;
64
65    /// Enables vertical scrolling. You can then use arbitrarily many virtual lines.
66    pub const NCREADER_OPTION_VERSCROLL: u32 = ffi::NCREADER_OPTION_VERSCROLL;
67}