rust: rename NcInput's new() to new_empty(); add new()

pull/1270/head
joseLuís 4 years ago
parent a29e9f0014
commit 1d4653e7c8

@ -18,7 +18,7 @@ fn main() -> NcResult<()> {
println!("Exit with F1\n");
let mut input = NcInput::new();
let mut input = NcInput::new_empty();
loop {
let key = notcurses_getc_nblock(nc, &mut input);

@ -79,7 +79,7 @@ fn run_menu(nc: &mut Notcurses, menu: &mut NcMenu) -> NcResult<()> {
channels.set_bg_rgb(0x88aa00);
selplane.set_base(' ', 0, channels)?;
let mut ni = NcInput::new();
let mut ni = NcInput::new_empty();
let mut keypress: char;
// FIXME: screen updates one keypress later.
@ -102,11 +102,15 @@ fn run_menu(nc: &mut Notcurses, menu: &mut NcMenu) -> NcResult<()> {
}
}
}
selplane.erase();
// let mut selni = NcInput::new();
// BUG FIXME:
// let selitem = menu.selected(Some(&mut selni))?;
// selplane.putstr_aligned(1, NCALIGN_CENTER, &selitem)?;
let mut selni = NcInput::new_empty();
// if let Some(selitem) = menu.selected(Some(&mut selni)) {
// selplane.putstr_aligned(1, NCALIGN_CENTER, &selitem)?;
// } else {
// // DEBUG
// selplane.putstr_aligned(1, NCALIGN_CENTER, "nothing opened")?;
// }
nc.render()?;
}
}

@ -53,7 +53,7 @@ pub const fn ncinput_equal_p(n1: NcInput, n2: NcInput) -> bool {
/// New NcInput.
impl NcInput {
/// New empty NcInput.
pub const fn new() -> NcInput {
pub const fn new_empty() -> NcInput {
NcInput {
id: 0,
y: 0,
@ -65,6 +65,26 @@ impl NcInput {
}
}
/// New NcInput.
pub const fn new(id: char) -> NcInput {
Self::with_all_args(id, None, None, false, false, false, 0)
}
/// New NcInput with alt key.
pub const fn with_alt(id: char) -> NcInput {
Self::with_all_args(id, None, None, true, false, false, 0)
}
/// New NcInput with shift key.
pub const fn with_shift(id: char) -> NcInput {
Self::with_all_args(id, None, None, false, true, false, 0)
}
/// New NcInput with ctrl key.
pub const fn with_ctrl(id: char) -> NcInput {
Self::with_all_args(id, None, None, false, false, true, 0)
}
/// New NcInput, expecting all the arguments.
pub const fn with_all_args(
id: char,
@ -97,21 +117,6 @@ impl NcInput {
seqnum,
}
}
/// New NcInput with alt key.
pub const fn with_alt(id: char) -> NcInput {
Self::with_all_args(id, None, None, true, false, false, 0)
}
/// New NcInput with shift key.
pub const fn with_shift(id: char) -> NcInput {
Self::with_all_args(id, None, None, false, true, false, 0)
}
/// New NcInput with ctrl key.
pub const fn with_ctrl(id: char) -> NcInput {
Self::with_all_args(id, None, None, false, false, true, 0)
}
}
/// Is this [char] a Supplementary Private Use Area-B codepoint?

@ -27,7 +27,7 @@ impl NcMenuItem {
pub fn new_empty() -> Self {
Self {
desc: null_mut(),
shortcut: NcInput::new(),
shortcut: NcInput::new_empty(),
}
}
}
@ -60,7 +60,7 @@ impl NcMenuSection {
name: null_mut(),
items: null_mut(),
itemcount: 0,
shortcut: NcInput::new(),
shortcut: NcInput::new_empty(),
}
}
}

Loading…
Cancel
Save