mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-10 07:04:17 +00:00
style: reformat imports (#219)
Order imports by std, external, crate and group them by crate
This commit is contained in:
parent
492af7a92d
commit
f7af8a3863
52 changed files with 247 additions and 191 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||||
execute,
|
execute,
|
||||||
|
@ -10,11 +16,6 @@ use ratatui::{
|
||||||
widgets::{BarChart, Block, Borders},
|
widgets::{BarChart, Block, Borders},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
error::Error,
|
|
||||||
io,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
struct App<'a> {
|
struct App<'a> {
|
||||||
data: Vec<(&'a str, u64)>,
|
data: Vec<(&'a str, u64)>,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::{error::Error, io};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||||
execute,
|
execute,
|
||||||
|
@ -11,7 +13,6 @@ use ratatui::{
|
||||||
widgets::{Block, BorderType, Borders, Padding, Paragraph},
|
widgets::{Block, BorderType, Borders, Padding, Paragraph},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{error::Error, io};
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
// setup terminal
|
// setup terminal
|
||||||
|
|
|
@ -5,18 +5,15 @@ use crossterm::{
|
||||||
execute,
|
execute,
|
||||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||||
};
|
};
|
||||||
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::{Backend, CrosstermBackend},
|
backend::{Backend, CrosstermBackend},
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
style::{Color, Modifier, Style},
|
style::{Color, Modifier, Style},
|
||||||
|
widgets::calendar::{CalendarEventStore, DateStyler, Monthly},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
|
|
||||||
use time::{Date, Month, OffsetDateTime};
|
use time::{Date, Month, OffsetDateTime};
|
||||||
|
|
||||||
use ratatui::widgets::calendar::{CalendarEventStore, DateStyler, Monthly};
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
let mut stdout = io::stdout();
|
let mut stdout = io::stdout();
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||||
execute,
|
execute,
|
||||||
|
@ -15,11 +21,6 @@ use ratatui::{
|
||||||
},
|
},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
error::Error,
|
|
||||||
io,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
struct App {
|
struct App {
|
||||||
x: f64,
|
x: f64,
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||||
execute,
|
execute,
|
||||||
|
@ -12,11 +18,6 @@ use ratatui::{
|
||||||
widgets::{Axis, Block, Borders, Chart, Dataset, GraphType},
|
widgets::{Axis, Block, Borders, Chart, Dataset, GraphType},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
error::Error,
|
|
||||||
io,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
const DATA: [(f64, f64); 5] = [(0.0, 0.0), (1.0, 1.0), (2.0, 2.0), (3.0, 3.0), (4.0, 4.0)];
|
const DATA: [(f64, f64); 5] = [(0.0, 0.0), (1.0, 1.0), (2.0, 2.0), (3.0, 3.0), (4.0, 4.0)];
|
||||||
const DATA2: [(f64, f64); 7] = [
|
const DATA2: [(f64, f64); 7] = [
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::{error::Error, io};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||||
execute,
|
execute,
|
||||||
|
@ -11,7 +13,6 @@ use ratatui::{
|
||||||
widgets::Widget,
|
widgets::Widget,
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{error::Error, io};
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Label<'a> {
|
struct Label<'a> {
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
use crate::{app::App, ui};
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
||||||
execute,
|
execute,
|
||||||
|
@ -8,11 +13,8 @@ use ratatui::{
|
||||||
backend::{Backend, CrosstermBackend},
|
backend::{Backend, CrosstermBackend},
|
||||||
Terminal,
|
Terminal,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
error::Error,
|
use crate::{app::App, ui};
|
||||||
io,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn run(tick_rate: Duration, enhanced_graphics: bool) -> Result<(), Box<dyn Error>> {
|
pub fn run(tick_rate: Duration, enhanced_graphics: bool) -> Result<(), Box<dyn Error>> {
|
||||||
// setup terminal
|
// setup terminal
|
||||||
|
|
|
@ -8,6 +8,10 @@ mod termwiz;
|
||||||
|
|
||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
|
use std::{error::Error, time::Duration};
|
||||||
|
|
||||||
|
use argh::FromArgs;
|
||||||
|
|
||||||
#[cfg(feature = "crossterm")]
|
#[cfg(feature = "crossterm")]
|
||||||
use crate::crossterm::run;
|
use crate::crossterm::run;
|
||||||
#[cfg(feature = "termion")]
|
#[cfg(feature = "termion")]
|
||||||
|
@ -15,9 +19,6 @@ use crate::termion::run;
|
||||||
#[cfg(feature = "termwiz")]
|
#[cfg(feature = "termwiz")]
|
||||||
use crate::termwiz::run;
|
use crate::termwiz::run;
|
||||||
|
|
||||||
use argh::FromArgs;
|
|
||||||
use std::{error::Error, time::Duration};
|
|
||||||
|
|
||||||
/// Demo
|
/// Demo
|
||||||
#[derive(Debug, FromArgs)]
|
#[derive(Debug, FromArgs)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::{app::App, ui};
|
use std::{error::Error, io, sync::mpsc, thread, time::Duration};
|
||||||
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::{Backend, TermionBackend},
|
backend::{Backend, TermionBackend},
|
||||||
Terminal,
|
Terminal,
|
||||||
};
|
};
|
||||||
use std::{error::Error, io, sync::mpsc, thread, time::Duration};
|
|
||||||
use termion::{
|
use termion::{
|
||||||
event::Key,
|
event::Key,
|
||||||
input::{MouseTerminal, TermRead},
|
input::{MouseTerminal, TermRead},
|
||||||
|
@ -11,6 +11,8 @@ use termion::{
|
||||||
screen::IntoAlternateScreen,
|
screen::IntoAlternateScreen,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{app::App, ui};
|
||||||
|
|
||||||
pub fn run(tick_rate: Duration, enhanced_graphics: bool) -> Result<(), Box<dyn Error>> {
|
pub fn run(tick_rate: Duration, enhanced_graphics: bool) -> Result<(), Box<dyn Error>> {
|
||||||
// setup terminal
|
// setup terminal
|
||||||
let stdout = io::stdout()
|
let stdout = io::stdout()
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use ratatui::{backend::TermwizBackend, Terminal};
|
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
io,
|
io,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use ratatui::{backend::TermwizBackend, Terminal};
|
||||||
use termwiz::{input::*, terminal::Terminal as TermwizTerminal};
|
use termwiz::{input::*, terminal::Terminal as TermwizTerminal};
|
||||||
|
|
||||||
use crate::{app::App, ui};
|
use crate::{app::App, ui};
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
use crate::app::App;
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
style::{Color, Modifier, Style},
|
style::{Color, Modifier, Style},
|
||||||
symbols,
|
symbols,
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::canvas::{Canvas, Circle, Line as CanvasLine, Map, MapResolution, Rectangle},
|
|
||||||
widgets::{
|
widgets::{
|
||||||
|
canvas::{Canvas, Circle, Line as CanvasLine, Map, MapResolution, Rectangle},
|
||||||
Axis, BarChart, Block, Borders, Cell, Chart, Dataset, Gauge, LineGauge, List, ListItem,
|
Axis, BarChart, Block, Borders, Cell, Chart, Dataset, Gauge, LineGauge, List, ListItem,
|
||||||
Paragraph, Row, Sparkline, Table, Tabs, Wrap,
|
Paragraph, Row, Sparkline, Table, Tabs, Wrap,
|
||||||
},
|
},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::app::App;
|
||||||
|
|
||||||
pub fn draw<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
pub fn draw<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
||||||
let chunks = Layout::default()
|
let chunks = Layout::default()
|
||||||
.constraints([Constraint::Length(3), Constraint::Min(0)].as_ref())
|
.constraints([Constraint::Length(3), Constraint::Min(0)].as_ref())
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||||
execute,
|
execute,
|
||||||
|
@ -11,11 +17,6 @@ use ratatui::{
|
||||||
widgets::{Block, Borders, Gauge},
|
widgets::{Block, Borders, Gauge},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
error::Error,
|
|
||||||
io,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
struct App {
|
struct App {
|
||||||
progress1: u16,
|
progress1: u16,
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
use std::{
|
||||||
|
io::{self, Stdout},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, Event, KeyCode},
|
event::{self, Event, KeyCode},
|
||||||
|
@ -5,10 +10,6 @@ use crossterm::{
|
||||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||||
};
|
};
|
||||||
use ratatui::{backend::CrosstermBackend, widgets::Paragraph, Terminal};
|
use ratatui::{backend::CrosstermBackend, widgets::Paragraph, Terminal};
|
||||||
use std::{
|
|
||||||
io::{self, Stdout},
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// This is a bare minimum example. There are many approaches to running an application loop, so
|
/// This is a bare minimum example. There are many approaches to running an application loop, so
|
||||||
/// this is not meant to be prescriptive. It is only meant to demonstrate the basic setup and
|
/// this is not meant to be prescriptive. It is only meant to demonstrate the basic setup and
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
use std::{
|
||||||
|
collections::{BTreeMap, VecDeque},
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
sync::mpsc,
|
||||||
|
thread,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use rand::distributions::{Distribution, Uniform};
|
use rand::distributions::{Distribution, Uniform};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::{Backend, CrosstermBackend},
|
backend::{Backend, CrosstermBackend},
|
||||||
|
@ -8,14 +17,6 @@ use ratatui::{
|
||||||
widgets::{Block, Gauge, LineGauge, List, ListItem, Paragraph, Widget},
|
widgets::{Block, Gauge, LineGauge, List, ListItem, Paragraph, Widget},
|
||||||
Frame, Terminal, TerminalOptions, Viewport,
|
Frame, Terminal, TerminalOptions, Viewport,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
collections::{BTreeMap, VecDeque},
|
|
||||||
error::Error,
|
|
||||||
io,
|
|
||||||
sync::mpsc,
|
|
||||||
thread,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
const NUM_DOWNLOADS: usize = 10;
|
const NUM_DOWNLOADS: usize = 10;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::{error::Error, io};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||||
execute,
|
execute,
|
||||||
|
@ -9,7 +11,6 @@ use ratatui::{
|
||||||
widgets::{Block, Borders},
|
widgets::{Block, Borders},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{error::Error, io};
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
// setup terminal
|
// setup terminal
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
||||||
execute,
|
execute,
|
||||||
|
@ -11,11 +17,6 @@ use ratatui::{
|
||||||
widgets::{Block, Borders, List, ListItem, ListState},
|
widgets::{Block, Borders, List, ListItem, ListState},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
error::Error,
|
|
||||||
io,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
struct StatefulList<T> {
|
struct StatefulList<T> {
|
||||||
state: ListState,
|
state: ListState,
|
||||||
|
|
|
@ -17,18 +17,19 @@
|
||||||
#![deny(clippy::all)]
|
#![deny(clippy::all)]
|
||||||
#![warn(clippy::pedantic, clippy::nursery)]
|
#![warn(clippy::pedantic, clippy::nursery)]
|
||||||
|
|
||||||
use std::error::Error;
|
use std::{error::Error, io};
|
||||||
use std::io;
|
|
||||||
|
|
||||||
use crossterm::event::{self, Event, KeyCode};
|
use crossterm::{
|
||||||
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
|
event::{self, Event, KeyCode},
|
||||||
use crossterm::terminal::{EnterAlternateScreen, LeaveAlternateScreen};
|
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||||
|
};
|
||||||
use ratatui::backend::{Backend, CrosstermBackend};
|
use ratatui::{
|
||||||
use ratatui::layout::Alignment;
|
backend::{Backend, CrosstermBackend},
|
||||||
use ratatui::text::Line;
|
layout::Alignment,
|
||||||
use ratatui::widgets::{Block, Borders, Paragraph};
|
text::Line,
|
||||||
use ratatui::{Frame, Terminal};
|
widgets::{Block, Borders, Paragraph},
|
||||||
|
Frame, Terminal,
|
||||||
|
};
|
||||||
|
|
||||||
type Result<T> = std::result::Result<T, Box<dyn Error>>;
|
type Result<T> = std::result::Result<T, Box<dyn Error>>;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||||
execute,
|
execute,
|
||||||
|
@ -11,11 +17,6 @@ use ratatui::{
|
||||||
widgets::{Block, Borders, Paragraph, Wrap},
|
widgets::{Block, Borders, Paragraph, Wrap},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
error::Error,
|
|
||||||
io,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
struct App {
|
struct App {
|
||||||
scroll: u16,
|
scroll: u16,
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
use std::{error::Error, io};
|
||||||
|
|
||||||
|
use crossterm::{
|
||||||
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
||||||
|
execute,
|
||||||
|
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||||
|
};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::{Backend, CrosstermBackend},
|
backend::{Backend, CrosstermBackend},
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
|
@ -6,13 +13,6 @@ use ratatui::{
|
||||||
widgets::{Block, Borders, Clear, Paragraph, Wrap},
|
widgets::{Block, Borders, Clear, Paragraph, Wrap},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{error::Error, io};
|
|
||||||
|
|
||||||
use crossterm::{
|
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
|
||||||
execute,
|
|
||||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
|
||||||
};
|
|
||||||
|
|
||||||
struct App {
|
struct App {
|
||||||
show_popup: bool,
|
show_popup: bool,
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
|
||||||
execute,
|
execute,
|
||||||
|
@ -14,11 +20,6 @@ use ratatui::{
|
||||||
widgets::{Block, Borders, Sparkline},
|
widgets::{Block, Borders, Sparkline},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
error::Error,
|
|
||||||
io,
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct RandomSignal {
|
pub struct RandomSignal {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::{error::Error, io};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
||||||
execute,
|
execute,
|
||||||
|
@ -10,7 +12,6 @@ use ratatui::{
|
||||||
widgets::{Block, Borders, Cell, Row, Table, TableState},
|
widgets::{Block, Borders, Cell, Row, Table, TableState},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{error::Error, io};
|
|
||||||
|
|
||||||
struct App<'a> {
|
struct App<'a> {
|
||||||
state: TableState,
|
state: TableState,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::{error::Error, io};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
|
||||||
execute,
|
execute,
|
||||||
|
@ -11,7 +13,6 @@ use ratatui::{
|
||||||
widgets::{Block, Borders, Tabs},
|
widgets::{Block, Borders, Tabs},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{error::Error, io};
|
|
||||||
|
|
||||||
struct App<'a> {
|
struct App<'a> {
|
||||||
pub titles: Vec<&'a str>,
|
pub titles: Vec<&'a str>,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::{error::Error, io};
|
||||||
|
|
||||||
/// A simple example demonstrating how to handle user input. This is
|
/// A simple example demonstrating how to handle user input. This is
|
||||||
/// a bit out of the scope of the library as it does not provide any
|
/// a bit out of the scope of the library as it does not provide any
|
||||||
/// input handling out of the box. However, it may helps some to get
|
/// input handling out of the box. However, it may helps some to get
|
||||||
|
@ -22,7 +24,6 @@ use ratatui::{
|
||||||
widgets::{Block, Borders, List, ListItem, Paragraph},
|
widgets::{Block, Borders, List, ListItem, Paragraph},
|
||||||
Frame, Terminal,
|
Frame, Terminal,
|
||||||
};
|
};
|
||||||
use std::{error::Error, io};
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
enum InputMode {
|
enum InputMode {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# configuration for https://rust-lang.github.io/rustfmt/
|
# configuration for https://rust-lang.github.io/rustfmt/
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
imports_granularity = "Crate"
|
||||||
wrap_comments = true
|
wrap_comments = true
|
||||||
comment_width = 100
|
comment_width = 100
|
||||||
|
|
|
@ -5,12 +5,8 @@
|
||||||
//! [`Backend`]: trait.Backend.html
|
//! [`Backend`]: trait.Backend.html
|
||||||
//! [`CrosstermBackend`]: struct.CrosstermBackend.html
|
//! [`CrosstermBackend`]: struct.CrosstermBackend.html
|
||||||
|
|
||||||
use crate::{
|
use std::io::{self, Write};
|
||||||
backend::{Backend, ClearType},
|
|
||||||
buffer::Cell,
|
|
||||||
layout::Rect,
|
|
||||||
style::{Color, Modifier},
|
|
||||||
};
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
cursor::{Hide, MoveTo, Show},
|
cursor::{Hide, MoveTo, Show},
|
||||||
execute, queue,
|
execute, queue,
|
||||||
|
@ -20,7 +16,13 @@ use crossterm::{
|
||||||
},
|
},
|
||||||
terminal::{self, Clear},
|
terminal::{self, Clear},
|
||||||
};
|
};
|
||||||
use std::io::{self, Write};
|
|
||||||
|
use crate::{
|
||||||
|
backend::{Backend, ClearType},
|
||||||
|
buffer::Cell,
|
||||||
|
layout::Rect,
|
||||||
|
style::{Color, Modifier},
|
||||||
|
};
|
||||||
|
|
||||||
/// A backend implementation using the `crossterm` crate.
|
/// A backend implementation using the `crossterm` crate.
|
||||||
///
|
///
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use crate::buffer::Cell;
|
use crate::{buffer::Cell, layout::Rect};
|
||||||
use crate::layout::Rect;
|
|
||||||
|
|
||||||
#[cfg(feature = "termion")]
|
#[cfg(feature = "termion")]
|
||||||
mod termion;
|
mod termion;
|
||||||
|
|
|
@ -4,16 +4,17 @@
|
||||||
//! [`Backend`]: crate::backend::Backend
|
//! [`Backend`]: crate::backend::Backend
|
||||||
//! [`TermionBackend`]: crate::backend::TermionBackend
|
//! [`TermionBackend`]: crate::backend::TermionBackend
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
fmt,
|
||||||
|
io::{self, Write},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::{Backend, ClearType},
|
backend::{Backend, ClearType},
|
||||||
buffer::Cell,
|
buffer::Cell,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
style::{Color, Modifier},
|
style::{Color, Modifier},
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
fmt,
|
|
||||||
io::{self, Write},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A backend that uses the Termion library to draw content, manipulate the cursor,
|
/// A backend that uses the Termion library to draw content, manipulate the cursor,
|
||||||
/// and clear the terminal screen.
|
/// and clear the terminal screen.
|
||||||
|
|
|
@ -4,13 +4,8 @@
|
||||||
//! [`Backend`]: trait.Backend.html
|
//! [`Backend`]: trait.Backend.html
|
||||||
//! [`TermwizBackend`]: crate::backend::TermionBackend
|
//! [`TermwizBackend`]: crate::backend::TermionBackend
|
||||||
|
|
||||||
use crate::{
|
|
||||||
backend::Backend,
|
|
||||||
buffer::Cell,
|
|
||||||
layout::Rect,
|
|
||||||
style::{Color, Modifier},
|
|
||||||
};
|
|
||||||
use std::{error::Error, io};
|
use std::{error::Error, io};
|
||||||
|
|
||||||
use termwiz::{
|
use termwiz::{
|
||||||
caps::Capabilities,
|
caps::Capabilities,
|
||||||
cell::{AttributeChange, Blink, Intensity, Underline},
|
cell::{AttributeChange, Blink, Intensity, Underline},
|
||||||
|
@ -19,6 +14,13 @@ use termwiz::{
|
||||||
terminal::{buffered::BufferedTerminal, SystemTerminal, Terminal},
|
terminal::{buffered::BufferedTerminal, SystemTerminal, Terminal},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
backend::Backend,
|
||||||
|
buffer::Cell,
|
||||||
|
layout::Rect,
|
||||||
|
style::{Color, Modifier},
|
||||||
|
};
|
||||||
|
|
||||||
/// Termwiz backend implementation for the [`Backend`] trait.
|
/// Termwiz backend implementation for the [`Backend`] trait.
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
//! This module provides the `TestBackend` implementation for the [`Backend`] trait.
|
//! This module provides the `TestBackend` implementation for the [`Backend`] trait.
|
||||||
//! It is used in the integration tests to verify the correctness of the library.
|
//! It is used in the integration tests to verify the correctness of the library.
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
fmt::{Display, Write},
|
||||||
|
io,
|
||||||
|
};
|
||||||
|
|
||||||
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
buffer::{Buffer, Cell},
|
buffer::{Buffer, Cell},
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
fmt::{Display, Write},
|
|
||||||
io,
|
|
||||||
};
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
|
||||||
|
|
||||||
/// A backend used for the integration tests.
|
/// A backend used for the integration tests.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
|
use std::{
|
||||||
|
cmp::min,
|
||||||
|
fmt::{Debug, Formatter, Result},
|
||||||
|
};
|
||||||
|
|
||||||
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
use crate::{
|
use crate::{
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
style::{Color, Modifier, Style},
|
style::{Color, Modifier, Style},
|
||||||
text::{Line, Span, Spans},
|
text::{Line, Span, Spans},
|
||||||
};
|
};
|
||||||
use std::{
|
|
||||||
cmp::min,
|
|
||||||
fmt::{Debug, Formatter, Result},
|
|
||||||
};
|
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
|
||||||
|
|
||||||
/// A buffer cell
|
/// A buffer cell
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
use std::cell::RefCell;
|
use std::{
|
||||||
use std::cmp::{max, min};
|
cell::RefCell,
|
||||||
use std::collections::HashMap;
|
cmp::{max, min},
|
||||||
use std::rc::Rc;
|
collections::HashMap,
|
||||||
|
rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
use cassowary::strength::{MEDIUM, REQUIRED, WEAK};
|
use cassowary::{
|
||||||
use cassowary::WeightedRelation::{EQ, GE, LE};
|
strength::{MEDIUM, REQUIRED, WEAK},
|
||||||
use cassowary::{Constraint as CassowaryConstraint, Expression, Solver, Variable};
|
Constraint as CassowaryConstraint, Expression, Solver, Variable,
|
||||||
|
WeightedRelation::{EQ, GE, LE},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Corner {
|
pub enum Corner {
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
//! `style` contains the primitives used to control how your user interface will look.
|
//! `style` contains the primitives used to control how your user interface will look.
|
||||||
|
|
||||||
use bitflags::bitflags;
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt::{self, Debug},
|
fmt::{self, Debug},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use bitflags::bitflags;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
use std::io;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::{Backend, ClearType},
|
backend::{Backend, ClearType},
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
widgets::{StatefulWidget, Widget},
|
widgets::{StatefulWidget, Widget},
|
||||||
};
|
};
|
||||||
use std::io;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum Viewport {
|
pub enum Viewport {
|
||||||
|
|
|
@ -46,11 +46,13 @@
|
||||||
//! Span::raw(" title"),
|
//! Span::raw(" title"),
|
||||||
//! ]);
|
//! ]);
|
||||||
//! ```
|
//! ```
|
||||||
use crate::style::Style;
|
|
||||||
use std::{borrow::Cow, fmt::Debug};
|
use std::{borrow::Cow, fmt::Debug};
|
||||||
|
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
use crate::style::Style;
|
||||||
|
|
||||||
mod line;
|
mod line;
|
||||||
mod masked;
|
mod masked;
|
||||||
mod spans;
|
mod spans;
|
||||||
|
|
|
@ -143,9 +143,11 @@ impl<'a> From<Spans<'a>> for Line<'a> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::layout::Alignment;
|
use crate::{
|
||||||
use crate::style::{Color, Modifier, Style};
|
layout::Alignment,
|
||||||
use crate::text::{Line, Span, Spans};
|
style::{Color, Modifier, Style},
|
||||||
|
text::{Line, Span, Spans},
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_width() {
|
fn test_width() {
|
||||||
|
|
|
@ -86,9 +86,10 @@ impl<'a> From<Masked<'a>> for Text<'a> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::borrow::Borrow;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::text::Line;
|
use crate::text::Line;
|
||||||
use std::borrow::Borrow;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_masked_value() {
|
fn test_masked_value() {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#![allow(deprecated)]
|
#![allow(deprecated)]
|
||||||
|
|
||||||
use super::{Span, Style};
|
use super::{Span, Style};
|
||||||
use crate::layout::Alignment;
|
use crate::{layout::Alignment, text::Line};
|
||||||
use crate::text::Line;
|
|
||||||
|
|
||||||
/// A string composed of clusters of graphemes, each with their own style.
|
/// A string composed of clusters of graphemes, each with their own style.
|
||||||
///
|
///
|
||||||
|
@ -137,8 +136,10 @@ impl<'a> From<Spans<'a>> for String {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::style::{Color, Modifier, Style};
|
use crate::{
|
||||||
use crate::text::{Span, Spans};
|
style::{Color, Modifier, Style},
|
||||||
|
text::{Span, Spans},
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_width() {
|
fn test_width() {
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
use std::cmp::min;
|
||||||
|
|
||||||
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
|
@ -5,8 +9,6 @@ use crate::{
|
||||||
symbols,
|
symbols,
|
||||||
widgets::{Block, Widget},
|
widgets::{Block, Widget},
|
||||||
};
|
};
|
||||||
use std::cmp::min;
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
|
||||||
|
|
||||||
/// Display multiple bars in a single widgets
|
/// Display multiple bars in a single widgets
|
||||||
///
|
///
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
//! [`Monthly`] has several controls for what should be displayed
|
//! [`Monthly`] has several controls for what should be displayed
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use time::{Date, Duration, OffsetDateTime};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
|
@ -18,8 +20,6 @@ use crate::{
|
||||||
widgets::{Block, Widget},
|
widgets::{Block, Widget},
|
||||||
};
|
};
|
||||||
|
|
||||||
use time::{Date, Duration, OffsetDateTime};
|
|
||||||
|
|
||||||
/// Display a month calendar for the month containing `display_date`
|
/// Display a month calendar for the month containing `display_date`
|
||||||
pub struct Monthly<'a, S: DateStyler> {
|
pub struct Monthly<'a, S: DateStyler> {
|
||||||
display_date: Date,
|
display_date: Date,
|
||||||
|
@ -214,9 +214,10 @@ impl Default for CalendarEventStore {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use time::Month;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::style::Color;
|
use crate::style::Color;
|
||||||
use time::Month;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn event_store() {
|
fn event_store() {
|
||||||
|
|
|
@ -27,12 +27,16 @@ impl Shape for Circle {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::buffer::Buffer;
|
use crate::{
|
||||||
use crate::layout::Rect;
|
buffer::Buffer,
|
||||||
use crate::style::Color;
|
layout::Rect,
|
||||||
use crate::symbols::Marker;
|
style::Color,
|
||||||
use crate::widgets::canvas::{Canvas, Circle};
|
symbols::Marker,
|
||||||
use crate::widgets::Widget;
|
widgets::{
|
||||||
|
canvas::{Canvas, Circle},
|
||||||
|
Widget,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_it_draws_a_circle() {
|
fn test_it_draws_a_circle() {
|
||||||
|
|
|
@ -5,12 +5,15 @@ mod points;
|
||||||
mod rectangle;
|
mod rectangle;
|
||||||
mod world;
|
mod world;
|
||||||
|
|
||||||
pub use self::circle::Circle;
|
use std::fmt::Debug;
|
||||||
pub use self::line::Line;
|
|
||||||
pub use self::map::{Map, MapResolution};
|
|
||||||
pub use self::points::Points;
|
|
||||||
pub use self::rectangle::Rectangle;
|
|
||||||
|
|
||||||
|
pub use self::{
|
||||||
|
circle::Circle,
|
||||||
|
line::Line,
|
||||||
|
map::{Map, MapResolution},
|
||||||
|
points::Points,
|
||||||
|
rectangle::Rectangle,
|
||||||
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
|
@ -19,7 +22,6 @@ use crate::{
|
||||||
text::Line as TextLine,
|
text::Line as TextLine,
|
||||||
widgets::{Block, Widget},
|
widgets::{Block, Widget},
|
||||||
};
|
};
|
||||||
use std::fmt::Debug;
|
|
||||||
|
|
||||||
/// Interface for all shapes that may be drawn on a Canvas widget.
|
/// Interface for all shapes that may be drawn on a Canvas widget.
|
||||||
pub trait Shape {
|
pub trait Shape {
|
||||||
|
@ -514,9 +516,10 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use indoc::indoc;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{buffer::Cell, symbols::Marker};
|
use crate::{buffer::Cell, symbols::Marker};
|
||||||
use indoc::indoc;
|
|
||||||
|
|
||||||
// helper to test the canvas checks that drawing a vertical and horizontal line
|
// helper to test the canvas checks that drawing a vertical and horizontal line
|
||||||
// results in the expected output
|
// results in the expected output
|
||||||
|
|
|
@ -2,10 +2,9 @@ use std::{borrow::Cow, cmp::max};
|
||||||
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use crate::layout::Alignment;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Constraint, Rect},
|
layout::{Alignment, Constraint, Rect},
|
||||||
style::{Color, Style},
|
style::{Color, Style},
|
||||||
symbols,
|
symbols,
|
||||||
text::{Line as TextLine, Span},
|
text::{Line as TextLine, Span},
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Corner, Rect},
|
layout::{Corner, Rect},
|
||||||
|
@ -5,7 +7,6 @@ use crate::{
|
||||||
text::Text,
|
text::Text,
|
||||||
widgets::{Block, StatefulWidget, Widget},
|
widgets::{Block, StatefulWidget, Widget},
|
||||||
};
|
};
|
||||||
use unicode_width::UnicodeWidthStr;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct ListState {
|
pub struct ListState {
|
||||||
|
@ -294,6 +295,7 @@ impl<'a> Widget for List<'a> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
assert_buffer_eq,
|
assert_buffer_eq,
|
||||||
style::Color,
|
style::Color,
|
||||||
|
@ -301,8 +303,6 @@ mod tests {
|
||||||
widgets::{Borders, StatefulWidget, Widget},
|
widgets::{Borders, StatefulWidget, Widget},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_list_state_selected() {
|
fn test_list_state_selected() {
|
||||||
let mut state = ListState::default();
|
let mut state = ListState::default();
|
||||||
|
|
|
@ -33,20 +33,22 @@ mod tabs;
|
||||||
|
|
||||||
use std::fmt::{self, Debug};
|
use std::fmt::{self, Debug};
|
||||||
|
|
||||||
pub use self::barchart::BarChart;
|
|
||||||
pub use self::block::{Block, BorderType, Padding};
|
|
||||||
pub use self::chart::{Axis, Chart, Dataset, GraphType};
|
|
||||||
pub use self::clear::Clear;
|
|
||||||
pub use self::gauge::{Gauge, LineGauge};
|
|
||||||
pub use self::list::{List, ListItem, ListState};
|
|
||||||
pub use self::paragraph::{Paragraph, Wrap};
|
|
||||||
pub use self::sparkline::{RenderDirection, Sparkline};
|
|
||||||
pub use self::table::{Cell, Row, Table, TableState};
|
|
||||||
pub use self::tabs::Tabs;
|
|
||||||
|
|
||||||
use crate::{buffer::Buffer, layout::Rect};
|
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
|
|
||||||
|
pub use self::{
|
||||||
|
barchart::BarChart,
|
||||||
|
block::{Block, BorderType, Padding},
|
||||||
|
chart::{Axis, Chart, Dataset, GraphType},
|
||||||
|
clear::Clear,
|
||||||
|
gauge::{Gauge, LineGauge},
|
||||||
|
list::{List, ListItem, ListState},
|
||||||
|
paragraph::{Paragraph, Wrap},
|
||||||
|
sparkline::{RenderDirection, Sparkline},
|
||||||
|
table::{Cell, Row, Table, TableState},
|
||||||
|
tabs::Tabs,
|
||||||
|
};
|
||||||
|
use crate::{buffer::Buffer, layout::Rect};
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
/// Bitflags that can be composed to set the visible borders essentially on the block widget.
|
/// Bitflags that can be composed to set the visible borders essentially on the block widget.
|
||||||
#[derive(Clone, Copy, Default, PartialEq, Eq)]
|
#[derive(Clone, Copy, Default, PartialEq, Eq)]
|
||||||
|
|
|
@ -200,8 +200,8 @@ impl<'a> Widget for Paragraph<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::backend::TestBackend;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
backend::TestBackend,
|
||||||
style::Color,
|
style::Color,
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::Borders,
|
widgets::Borders,
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
use std::collections::VecDeque;
|
use std::{collections::VecDeque, vec::IntoIter};
|
||||||
use std::vec::IntoIter;
|
|
||||||
|
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use crate::layout::Alignment;
|
use crate::{layout::Alignment, text::StyledGrapheme};
|
||||||
use crate::text::StyledGrapheme;
|
|
||||||
|
|
||||||
const NBSP: &str = "\u{00a0}";
|
const NBSP: &str = "\u{00a0}";
|
||||||
|
|
||||||
|
@ -323,11 +321,14 @@ fn trim_offset(src: &str, mut offset: usize) -> &str {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
|
||||||
use crate::style::Style;
|
|
||||||
use crate::text::{Line, Text};
|
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
use crate::{
|
||||||
|
style::Style,
|
||||||
|
text::{Line, Text},
|
||||||
|
};
|
||||||
|
|
||||||
enum Composer {
|
enum Composer {
|
||||||
WordWrapper { trim: bool },
|
WordWrapper { trim: bool },
|
||||||
LineTruncator,
|
LineTruncator,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::cmp::min;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
|
@ -5,7 +7,6 @@ use crate::{
|
||||||
symbols,
|
symbols,
|
||||||
widgets::{Block, Widget},
|
widgets::{Block, Widget},
|
||||||
};
|
};
|
||||||
use std::cmp::min;
|
|
||||||
|
|
||||||
/// Widget to render a sparkline over one or more lines.
|
/// Widget to render a sparkline over one or more lines.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
|
@ -5,7 +7,6 @@ use crate::{
|
||||||
text::Text,
|
text::Text,
|
||||||
widgets::{Block, StatefulWidget, Widget},
|
widgets::{Block, StatefulWidget, Widget},
|
||||||
};
|
};
|
||||||
use unicode_width::UnicodeWidthStr;
|
|
||||||
|
|
||||||
/// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`].
|
/// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`].
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::{Backend, TestBackend},
|
backend::{Backend, TestBackend},
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
widgets::Paragraph,
|
widgets::Paragraph,
|
||||||
Terminal,
|
Terminal,
|
||||||
};
|
};
|
||||||
use std::error::Error;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn terminal_buffer_size_should_be_limited() {
|
fn terminal_buffer_size_should_be_limited() {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use ratatui::backend::TestBackend;
|
use ratatui::{
|
||||||
use ratatui::buffer::Buffer;
|
backend::TestBackend,
|
||||||
use ratatui::widgets::{BarChart, Block, Borders};
|
buffer::Buffer,
|
||||||
use ratatui::Terminal;
|
widgets::{BarChart, Block, Borders},
|
||||||
|
Terminal,
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn widgets_barchart_not_full_below_max_value() {
|
fn widgets_barchart_not_full_below_max_value() {
|
||||||
|
|
|
@ -9,7 +9,6 @@ use ratatui::{
|
||||||
},
|
},
|
||||||
Terminal,
|
Terminal,
|
||||||
};
|
};
|
||||||
|
|
||||||
use time::{Date, Month};
|
use time::{Date, Month};
|
||||||
|
|
||||||
fn test_render<W: Widget>(widget: W, expected: Buffer, size: (u16, u16)) {
|
fn test_render<W: Widget>(widget: W, expected: Buffer, size: (u16, u16)) {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use ratatui::layout::Alignment;
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
backend::TestBackend,
|
backend::TestBackend,
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::{Alignment, Rect},
|
||||||
style::{Color, Style},
|
style::{Color, Style},
|
||||||
symbols,
|
symbols,
|
||||||
text::Span,
|
text::Span,
|
||||||
|
|
Loading…
Reference in a new issue