From 4ffaae067e18e0b4373aa5e62ef30f44b1159767 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 16 Feb 2023 09:18:08 +0100 Subject: [PATCH] Export all types at top level --- examples/hello_world.rs | 3 +-- examples/overlapping_graphemes.rs | 3 +-- examples/text_wrapping.rs | 4 +--- src/buffer.rs | 3 +-- src/frame.rs | 4 +--- src/lib.rs | 14 ++++++++++---- src/styled.rs | 2 +- src/terminal.rs | 9 ++++----- src/wrap.rs | 2 +- 9 files changed, 21 insertions(+), 23 deletions(-) diff --git a/examples/hello_world.rs b/examples/hello_world.rs index b7b670d..874740e 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -1,7 +1,6 @@ use crossterm::event::Event; use crossterm::style::{ContentStyle, Stylize}; -use toss::frame::{Frame, Pos}; -use toss::terminal::Terminal; +use toss::{Frame, Pos, Terminal}; fn draw(f: &mut Frame) { f.write( diff --git a/examples/overlapping_graphemes.rs b/examples/overlapping_graphemes.rs index e87dff7..b3b07e1 100644 --- a/examples/overlapping_graphemes.rs +++ b/examples/overlapping_graphemes.rs @@ -1,7 +1,6 @@ use crossterm::event::Event; use crossterm::style::{ContentStyle, Stylize}; -use toss::frame::{Frame, Pos}; -use toss::terminal::Terminal; +use toss::{Frame, Pos, Terminal}; fn draw(f: &mut Frame) { f.write( diff --git a/examples/text_wrapping.rs b/examples/text_wrapping.rs index 1f711fa..1943fae 100644 --- a/examples/text_wrapping.rs +++ b/examples/text_wrapping.rs @@ -1,7 +1,5 @@ use crossterm::event::Event; -use toss::frame::{Frame, Pos}; -use toss::styled::Styled; -use toss::terminal::Terminal; +use toss::{Frame, Pos, Styled, Terminal}; fn draw(f: &mut Frame) { let text = concat!( diff --git a/src/buffer.rs b/src/buffer.rs index 721ffa7..b8b9882 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -2,8 +2,7 @@ use std::ops::{Add, AddAssign, Neg, Range, Sub, SubAssign}; use crossterm::style::ContentStyle; -use crate::styled::Styled; -use crate::widthdb::WidthDb; +use crate::{Styled, WidthDb}; #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] pub struct Size { diff --git a/src/frame.rs b/src/frame.rs index 3eef23b..2e9bad1 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -1,9 +1,7 @@ //! Rendering the next frame. use crate::buffer::Buffer; -pub use crate::buffer::{Pos, Size}; -use crate::styled::Styled; -use crate::widthdb::WidthDb; +use crate::{Pos, Size, Styled, WidthDb}; #[derive(Debug, Default)] pub struct Frame { diff --git a/src/lib.rs b/src/lib.rs index 9a03207..4daa5ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,8 +10,14 @@ #![warn(clippy::use_self)] mod buffer; -pub mod frame; -pub mod styled; -pub mod terminal; -pub mod widthdb; +mod frame; +mod styled; +mod terminal; +mod widthdb; mod wrap; + +pub use buffer::{Pos, Size}; +pub use frame::*; +pub use styled::*; +pub use terminal::*; +pub use widthdb::*; diff --git a/src/styled.rs b/src/styled.rs index 872e4c5..425a717 100644 --- a/src/styled.rs +++ b/src/styled.rs @@ -1,5 +1,5 @@ use std::iter::Peekable; -use std::{slice, vec}; +use std::slice; use crossterm::style::{ContentStyle, StyledContent}; use unicode_segmentation::{GraphemeIndices, Graphemes, UnicodeSegmentation}; diff --git a/src/terminal.rs b/src/terminal.rs index 878a49a..2f1bf5b 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -1,7 +1,7 @@ //! Displaying frames on a terminal. -use std::io::Write; -use std::{io, mem}; +use std::io::{self, Write}; +use std::mem; use crossterm::cursor::{Hide, MoveTo, Show}; use crossterm::event::{ @@ -12,9 +12,8 @@ use crossterm::style::{PrintStyledContent, StyledContent}; use crossterm::terminal::{Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen}; use crossterm::{ExecutableCommand, QueueableCommand}; -use crate::buffer::{Buffer, Size}; -use crate::frame::Frame; -use crate::widthdb::WidthDb; +use crate::buffer::Buffer; +use crate::{Frame, Size, WidthDb}; pub struct Terminal { /// Render target. diff --git a/src/wrap.rs b/src/wrap.rs index a0f4e0d..a1ef1d4 100644 --- a/src/wrap.rs +++ b/src/wrap.rs @@ -3,7 +3,7 @@ use unicode_linebreak::BreakOpportunity; use unicode_segmentation::UnicodeSegmentation; -use crate::widthdb::WidthDb; +use crate::WidthDb; pub fn wrap(widthdb: &mut WidthDb, text: &str, width: usize) -> Vec { let mut breaks = vec![];