diff options
| author | Vladislav Stepanov <8uk.8ak@gmail.com> | 2023-04-14 23:18:58 +0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-14 20:18:58 +0100 |
| commit | c05d2850420a2c163b8f62c33a6cef7c0ae1ad8d (patch) | |
| tree | 2c44a44eda7e76fa74e78ac1fd02f55c1ed4d804 /src/ratatui/mod.rs | |
| parent | Switch to uuidv7 (#864) (diff) | |
| download | atuin-c05d2850420a2c163b8f62c33a6cef7c0ae1ad8d.zip | |
Workspace reorder (#868)
* Try different workspace structure
Move main crate (atuin) to be on the same level with other crates in
this workspace
* extract common dependencies to the workspace definition
* fix base64 v0.21 deprecation warning
* questionable: update deps & fix chrono deprecations
possible panic sites are unchanged, they're just more visible now
* Revert "questionable: update deps & fix chrono deprecations"
This reverts commit 993e60f8dea81a1625a04285a617959ad09a0866.
Diffstat (limited to 'src/ratatui/mod.rs')
| -rw-r--r-- | src/ratatui/mod.rs | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/src/ratatui/mod.rs b/src/ratatui/mod.rs deleted file mode 100644 index d7926b96..00000000 --- a/src/ratatui/mod.rs +++ /dev/null @@ -1,177 +0,0 @@ -#![allow(clippy::all)] -#![allow(warnings)] - -//! [ratatui](https://github.com/tui-rs-revival/ratatui) is a library used to build rich -//! terminal users interfaces and dashboards. -//! -//!  -//! -//! # Get started -//! -//! ## Adding `ratatui` as a dependency -//! -//! Add the following to your `Cargo.toml`: -//! ```toml -//! [dependencies] -//! crossterm = "0.26" -//! ratatui = "0.20" -//! ``` -//! -//! The crate is using the `crossterm` backend by default that works on most platforms. But if for -//! example you want to use the `termion` backend instead. This can be done by changing your -//! dependencies specification to the following: -//! -//! ```toml -//! [dependencies] -//! termion = "1.5" -//! ratatui = { version = "0.20", default-features = false, features = ['termion'] } -//! -//! ``` -//! -//! The same logic applies for all other available backends. -//! -//! ## Creating a `Terminal` -//! -//! Every application using `ratatui` should start by instantiating a `Terminal`. It is a light -//! abstraction over available backends that provides basic functionalities such as clearing the -//! screen, hiding the cursor, etc. -//! -//! ```rust,no_run -//! use std::io; -//! use ratatui::{backend::CrosstermBackend, Terminal}; -//! -//! fn main() -> Result<(), io::Error> { -//! let stdout = io::stdout(); -//! let backend = CrosstermBackend::new(stdout); -//! let mut terminal = Terminal::new(backend)?; -//! Ok(()) -//! } -//! ``` -//! -//! If you had previously chosen `termion` as a backend, the terminal can be created in a similar -//! way: -//! -//! ```rust,ignore -//! use std::io; -//! use ratatui::{backend::TermionBackend, Terminal}; -//! use termion::raw::IntoRawMode; -//! -//! fn main() -> Result<(), io::Error> { -//! let stdout = io::stdout().into_raw_mode()?; -//! let backend = TermionBackend::new(stdout); -//! let mut terminal = Terminal::new(backend)?; -//! Ok(()) -//! } -//! ``` -//! -//! You may also refer to the examples to find out how to create a `Terminal` for each available -//! backend. -//! -//! ## Building a User Interface (UI) -//! -//! Every component of your interface will be implementing the `Widget` trait. The library comes -//! with a predefined set of widgets that should meet most of your use cases. You are also free to -//! implement your own. -//! -//! Each widget follows a builder pattern API providing a default configuration along with methods -//! to customize them. The widget is then rendered using [`Frame::render_widget`] which takes -//! your widget instance and an area to draw to. -//! -//! The following example renders a block of the size of the terminal: -//! -//! ```rust,no_run -//! use std::{io, thread, time::Duration}; -//! use ratatui::{ -//! backend::CrosstermBackend, -//! widgets::{Widget, Block, Borders}, -//! layout::{Layout, Constraint, Direction}, -//! Terminal -//! }; -//! use crossterm::{ -//! event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode}, -//! execute, -//! terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, -//! }; -//! -//! fn main() -> Result<(), io::Error> { -//! // setup terminal -//! enable_raw_mode()?; -//! let mut stdout = io::stdout(); -//! execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?; -//! let backend = CrosstermBackend::new(stdout); -//! let mut terminal = Terminal::new(backend)?; -//! -//! terminal.draw(|f| { -//! let size = f.size(); -//! let block = Block::default() -//! .title("Block") -//! .borders(Borders::ALL); -//! f.render_widget(block, size); -//! })?; -//! -//! thread::sleep(Duration::from_millis(5000)); -//! -//! // restore terminal -//! disable_raw_mode()?; -//! execute!( -//! terminal.backend_mut(), -//! LeaveAlternateScreen, -//! DisableMouseCapture -//! )?; -//! terminal.show_cursor()?; -//! -//! Ok(()) -//! } -//! ``` -//! -//! ## Layout -//! -//! The library comes with a basic yet useful layout management object called `Layout`. As you may -//! see below and in the examples, the library makes heavy use of the builder pattern to provide -//! full customization. And `Layout` is no exception: -//! -//! ```rust,no_run -//! use ratatui::{ -//! backend::Backend, -//! layout::{Constraint, Direction, Layout}, -//! widgets::{Block, Borders}, -//! Frame, -//! }; -//! fn ui<B: Backend>(f: &mut Frame<B>) { -//! let chunks = Layout::default() -//! .direction(Direction::Vertical) -//! .margin(1) -//! .constraints( -//! [ -//! Constraint::Percentage(10), -//! Constraint::Percentage(80), -//! Constraint::Percentage(10) -//! ].as_ref() -//! ) -//! .split(f.size()); -//! let block = Block::default() -//! .title("Block") -//! .borders(Borders::ALL); -//! f.render_widget(block, chunks[0]); -//! let block = Block::default() -//! .title("Block 2") -//! .borders(Borders::ALL); -//! f.render_widget(block, chunks[1]); -//! } -//! ``` -//! -//! This let you describe responsive terminal UI by nesting layouts. You should note that by -//! default the computed layout tries to fill the available space completely. So if for any reason -//! you might need a blank space somewhere, try to pass an additional constraint and don't use the -//! corresponding area. - -pub mod backend; -pub mod buffer; -pub mod layout; -pub mod style; -pub mod symbols; -pub mod terminal; -pub mod text; -pub mod widgets; - -pub use self::terminal::{Frame, Terminal, TerminalOptions, Viewport}; |
