Expand description
newt-rs
Rust bindings for the Newt console UI library.
This crate provides bindings to Red Hat, Inc.’s Newt console UI library. Newt is a small and simple to use UI library providing widgets and basic stacked window management for console applications.
The majority, if not all of Newt’s functionality has been implemented. Although some features currently require the nightly build of the Rust compiler.
Example
extern crate newt;
use newt::prelude::*;
pub fn main() {
newt::init().unwrap();
newt::cls();
newt::centered_window(20, 5, Some("Greetings")).unwrap();
let text = Textbox::new(4, 1, 12, 1, 0);
let ok = CompactButton::new(7, 3, "Ok");
text.set_text("Hello World!");
let mut form = Form::new(None, 0);
form.add_components(&[&text, &ok]).unwrap();
let reason = form.run().unwrap();
newt::finished();
match reason {
ExitReason::HotKey(key) => // F12 is the default HotKey
println!("Execution stopped due to HotKey: {}", key),
ExitReason::Component(co) =>
println!("Execution stopped due to Component: {:?}", co),
_ =>
println!("Execution stopped due to other reason...")
}
}
Features
-
asm
- Allows building of the Grid module and the windows::win_entries and windows::win_menu functions. These require the inline assembly feature of Rust which is only available in nightly builds. This feature is also only available on x86/x86_64 architectures. -
static
- Builds and linksnewt-sys
statically against its included libraries rather than linking dynamically against available system libraries. This is done automatically if the required system libraries are unavailable.
License
Copyright (C) 2018,2019 Robert Gill <rtgill82@gmail.com>
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Re-exports
pub use self::component::Component;
pub use self::callbacks::Callback;
pub use self::windows::win_message;
pub use self::windows::win_choice;
pub use self::windows::win_ternary;
pub use self::windows::win_menu;
pub use self::windows::win_entries;
Modules
Callbacks and filters.
Trait implemented by Widget
and Grid
types.
Constants used by the newt library.
Methods for easily arranging component placement.
Convenient imports.
newt UI widgets.
Convenient windowing functions.
Structs
A struct containing the color sets for all components.
Functions
Issue a terminal beep.
Open a window in the center of the screen.
Clear the key buffer.
Clear the screen.
Turn the cursor visibility off.
Turn the cursor visibility on.
Wait for a specified amount of time.
Draw text directly to the root window.
Close down the newt library and reset the terminal.
Get the terminal screen size.
Initialize the newt library.
Open a window at the specified location.
Remove the help line.
Close the most recently opened window.
Close the most recently opened window without redrawing the screen.
Display a help string on the bottom of the screen.
Redraw the help line.
Reflow text according to the provided specifications.
Redraw the screen.
Notify newt of a screen resize.
Resume running the newt library.
Set a specific color set.
Set the colors used by the newt library.
Temporarily suspend the newt library and reset the terminal.
Wait until a key is pressed.