Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: reformat imports #219

Merged
merged 2 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions examples/barchart.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::{
error::Error,
io,
time::{Duration, Instant},
};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
Expand All @@ -10,11 +16,6 @@ use ratatui::{
widgets::{BarChart, Block, Borders},
Frame, Terminal,
};
use std::{
error::Error,
io,
time::{Duration, Instant},
};

struct App<'a> {
data: Vec<(&'a str, u64)>,
Expand Down
3 changes: 2 additions & 1 deletion examples/block.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{error::Error, io};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
Expand All @@ -11,7 +13,6 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Padding, Paragraph},
Frame, Terminal,
};
use std::{error::Error, io};

fn main() -> Result<(), Box<dyn Error>> {
// setup terminal
Expand Down
5 changes: 1 addition & 4 deletions examples/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ use crossterm::{
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};

use ratatui::{
backend::{Backend, CrosstermBackend},
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style},
widgets::calendar::{CalendarEventStore, DateStyler, Monthly},
Frame, Terminal,
};

use time::{Date, Month, OffsetDateTime};

use ratatui::widgets::calendar::{CalendarEventStore, DateStyler, Monthly};

fn main() -> Result<(), Box<dyn Error>> {
enable_raw_mode()?;
let mut stdout = io::stdout();
Expand Down
11 changes: 6 additions & 5 deletions examples/canvas.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::{
error::Error,
io,
time::{Duration, Instant},
};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
Expand All @@ -15,11 +21,6 @@ use ratatui::{
},
Frame, Terminal,
};
use std::{
error::Error,
io,
time::{Duration, Instant},
};

struct App {
x: f64,
Expand Down
11 changes: 6 additions & 5 deletions examples/chart.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::{
error::Error,
io,
time::{Duration, Instant},
};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
Expand All @@ -12,11 +18,6 @@ use ratatui::{
widgets::{Axis, Block, Borders, Chart, Dataset, GraphType},
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 DATA2: [(f64, f64); 7] = [
Expand Down
3 changes: 2 additions & 1 deletion examples/custom_widget.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{error::Error, io};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
Expand All @@ -11,7 +13,6 @@ use ratatui::{
widgets::Widget,
Frame, Terminal,
};
use std::{error::Error, io};

#[derive(Default)]
struct Label<'a> {
Expand Down
14 changes: 8 additions & 6 deletions examples/demo/crossterm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use crate::{app::App, ui};
use std::{
error::Error,
io,
time::{Duration, Instant},
};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
execute,
Expand All @@ -8,11 +13,8 @@ use ratatui::{
backend::{Backend, CrosstermBackend},
Terminal,
};
use std::{
error::Error,
io,
time::{Duration, Instant},
};

use crate::{app::App, ui};

pub fn run(tick_rate: Duration, enhanced_graphics: bool) -> Result<(), Box<dyn Error>> {
// setup terminal
Expand Down
7 changes: 4 additions & 3 deletions examples/demo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ mod termwiz;

mod ui;

use std::{error::Error, time::Duration};

use argh::FromArgs;

#[cfg(feature = "crossterm")]
use crate::crossterm::run;
#[cfg(feature = "termion")]
use crate::termion::run;
#[cfg(feature = "termwiz")]
use crate::termwiz::run;

use argh::FromArgs;
use std::{error::Error, time::Duration};

/// Demo
#[derive(Debug, FromArgs)]
struct Cli {
Expand Down
6 changes: 4 additions & 2 deletions examples/demo/termion.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use crate::{app::App, ui};
use std::{error::Error, io, sync::mpsc, thread, time::Duration};

use ratatui::{
backend::{Backend, TermionBackend},
Terminal,
};
use std::{error::Error, io, sync::mpsc, thread, time::Duration};
use termion::{
event::Key,
input::{MouseTerminal, TermRead},
raw::IntoRawMode,
screen::IntoAlternateScreen,
};

use crate::{app::App, ui};

pub fn run(tick_rate: Duration, enhanced_graphics: bool) -> Result<(), Box<dyn Error>> {
// setup terminal
let stdout = io::stdout()
Expand Down
3 changes: 2 additions & 1 deletion examples/demo/termwiz.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use ratatui::{backend::TermwizBackend, Terminal};
use std::{
error::Error,
io,
time::{Duration, Instant},
};

use ratatui::{backend::TermwizBackend, Terminal};
use termwiz::{input::*, terminal::Terminal as TermwizTerminal};

use crate::{app::App, ui};
Expand Down
5 changes: 3 additions & 2 deletions examples/demo/ui.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use crate::app::App;
use ratatui::{
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style},
symbols,
text::{Line, Span},
widgets::canvas::{Canvas, Circle, Line as CanvasLine, Map, MapResolution, Rectangle},
widgets::{
canvas::{Canvas, Circle, Line as CanvasLine, Map, MapResolution, Rectangle},
Axis, BarChart, Block, Borders, Cell, Chart, Dataset, Gauge, LineGauge, List, ListItem,
Paragraph, Row, Sparkline, Table, Tabs, Wrap,
},
Frame,
};

use crate::app::App;

pub fn draw<B: Backend>(f: &mut Frame<B>, app: &mut App) {
let chunks = Layout::default()
.constraints([Constraint::Length(3), Constraint::Min(0)].as_ref())
Expand Down
11 changes: 6 additions & 5 deletions examples/gauge.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::{
error::Error,
io,
time::{Duration, Instant},
};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
Expand All @@ -11,11 +17,6 @@ use ratatui::{
widgets::{Block, Borders, Gauge},
Frame, Terminal,
};
use std::{
error::Error,
io,
time::{Duration, Instant},
};

struct App {
progress1: u16,
Expand Down
9 changes: 5 additions & 4 deletions examples/hello_world.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use std::{
io::{self, Stdout},
time::Duration,
};

use anyhow::{Context, Result};
use crossterm::{
event::{self, Event, KeyCode},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
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 not meant to be prescriptive. It is only meant to demonstrate the basic setup and
Expand Down
17 changes: 9 additions & 8 deletions examples/inline.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
use std::{
collections::{BTreeMap, VecDeque},
error::Error,
io,
sync::mpsc,
thread,
time::{Duration, Instant},
};

use rand::distributions::{Distribution, Uniform};
use ratatui::{
backend::{Backend, CrosstermBackend},
Expand All @@ -8,14 +17,6 @@ use ratatui::{
widgets::{Block, Gauge, LineGauge, List, ListItem, Paragraph, Widget},
Frame, Terminal, TerminalOptions, Viewport,
};
use std::{
collections::{BTreeMap, VecDeque},
error::Error,
io,
sync::mpsc,
thread,
time::{Duration, Instant},
};

const NUM_DOWNLOADS: usize = 10;

Expand Down
3 changes: 2 additions & 1 deletion examples/layout.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{error::Error, io};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
Expand All @@ -9,7 +11,6 @@ use ratatui::{
widgets::{Block, Borders},
Frame, Terminal,
};
use std::{error::Error, io};

fn main() -> Result<(), Box<dyn Error>> {
// setup terminal
Expand Down
11 changes: 6 additions & 5 deletions examples/list.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::{
error::Error,
io,
time::{Duration, Instant},
};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind},
execute,
Expand All @@ -11,11 +17,6 @@ use ratatui::{
widgets::{Block, Borders, List, ListItem, ListState},
Frame, Terminal,
};
use std::{
error::Error,
io,
time::{Duration, Instant},
};

struct StatefulList<T> {
state: ListState,
Expand Down
25 changes: 13 additions & 12 deletions examples/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
#![deny(clippy::all)]
#![warn(clippy::pedantic, clippy::nursery)]

use std::error::Error;
use std::io;

use crossterm::event::{self, Event, KeyCode};
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
use crossterm::terminal::{EnterAlternateScreen, LeaveAlternateScreen};

use ratatui::backend::{Backend, CrosstermBackend};
use ratatui::layout::Alignment;
use ratatui::text::Line;
use ratatui::widgets::{Block, Borders, Paragraph};
use ratatui::{Frame, Terminal};
use std::{error::Error, io};

use crossterm::{
event::{self, Event, KeyCode},
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use ratatui::{
backend::{Backend, CrosstermBackend},
layout::Alignment,
text::Line,
widgets::{Block, Borders, Paragraph},
Frame, Terminal,
};

type Result<T> = std::result::Result<T, Box<dyn Error>>;

Expand Down
11 changes: 6 additions & 5 deletions examples/paragraph.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::{
error::Error,
io,
time::{Duration, Instant},
};

use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
execute,
Expand All @@ -11,11 +17,6 @@ use ratatui::{
widgets::{Block, Borders, Paragraph, Wrap},
Frame, Terminal,
};
use std::{
error::Error,
io,
time::{Duration, Instant},
};

struct App {
scroll: u16,
Expand Down
14 changes: 7 additions & 7 deletions examples/popup.rs
Original file line number Diff line number Diff line change
@@ -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::{
backend::{Backend, CrosstermBackend},
layout::{Alignment, Constraint, Direction, Layout, Rect},
Expand All @@ -6,13 +13,6 @@ use ratatui::{
widgets::{Block, Borders, Clear, Paragraph, Wrap},
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 {
show_popup: bool,
Expand Down
Loading