diff --git a/rustfmt.toml b/rustfmt.toml index 0dc5737..7355152 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,4 @@ +unstable_features = true max_width = 79 reorder_imports = true fn_args_density = "Compressed" diff --git a/src/backend/blt.rs b/src/backend/blt.rs index f3a47cc..05b49fa 100644 --- a/src/backend/blt.rs +++ b/src/backend/blt.rs @@ -22,7 +22,10 @@ pub struct Concrete { impl Concrete { fn blt_keycode_to_ev( - &mut self, kc: KeyCode, shift: bool, ctrl: bool + &mut self, + kc: KeyCode, + shift: bool, + ctrl: bool, ) -> Event { match kc { KeyCode::F1 diff --git a/src/backend/curses/n.rs b/src/backend/curses/n.rs index 66ba074..c6189bc 100644 --- a/src/backend/curses/n.rs +++ b/src/backend/curses/n.rs @@ -24,7 +24,9 @@ pub struct Concrete { impl Concrete { /// Save a new color pair. fn insert_color( - &self, pairs: &mut HashMap, pair: ColorPair + &self, + pairs: &mut HashMap, + pair: ColorPair, ) -> i16 { let n = 1 + pairs.len() as i16; let target = if ncurses::COLOR_PAIRS() > i32::from(n) { @@ -89,10 +91,12 @@ impl Concrete { | ncurses::BUTTON_CTRL) as mmask_t; - let make_event = |event| Event::Mouse { - offset: Vec2::zero(), - position: Vec2::new(mevent.x as usize, mevent.y as usize), - event: event, + let make_event = |event| { + Event::Mouse { + offset: Vec2::zero(), + position: Vec2::new(mevent.x as usize, mevent.y as usize), + event: event, + } }; if mevent.bstate == ncurses::REPORT_MOUSE_POSITION as mmask_t { diff --git a/src/backend/curses/pan.rs b/src/backend/curses/pan.rs index 91802f4..817e294 100644 --- a/src/backend/curses/pan.rs +++ b/src/backend/curses/pan.rs @@ -22,7 +22,9 @@ pub struct Concrete { impl Concrete { /// Save a new color pair. fn insert_color( - &self, pairs: &mut HashMap, pair: ColorPair + &self, + pairs: &mut HashMap, + pair: ColorPair, ) -> i32 { let n = 1 + pairs.len() as i32; @@ -80,10 +82,12 @@ impl Concrete { mevent.bstate &= !(pancurses::BUTTON_SHIFT | pancurses::BUTTON_ALT | pancurses::BUTTON_CTRL) as mmask_t; - let make_event = |event| Event::Mouse { - offset: Vec2::zero(), - position: Vec2::new(mevent.x as usize, mevent.y as usize), - event: event, + let make_event = |event| { + Event::Mouse { + offset: Vec2::zero(), + position: Vec2::new(mevent.x as usize, mevent.y as usize), + event: event, + } }; if mevent.bstate == pancurses::REPORT_MOUSE_POSITION as mmask_t { @@ -414,13 +418,15 @@ impl backend::Backend for Concrete { pancurses::Input::KeySuspend => Event::Refresh, pancurses::Input::KeyUndo => Event::Refresh, pancurses::Input::KeyResize => { - // Let pancurses adjust their structures when the window is resized. - // Do it for Windows only, as 'resize_term' is not implemented for Unix + // Let pancurses adjust their structures when the + // window is resized. + // Do it for Windows only, as 'resize_term' is not + // implemented for Unix if cfg!(target_os = "windows") { pancurses::resize_term(0, 0); } Event::WindowResize - }, + } pancurses::Input::KeyEvent => Event::Refresh, // TODO: mouse support pancurses::Input::KeyMouse => self.parse_mouse_event(), diff --git a/src/lib.rs b/src/lib.rs index c81c01c..ac6acc3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,14 +59,14 @@ //! Or you can use gdb as usual. #![deny(missing_docs)] +#[macro_use] +extern crate enum_map; #[macro_use] extern crate enumset; #[macro_use] extern crate log; #[macro_use] extern crate maplit; -#[macro_use] -extern crate enum_map; extern crate num; extern crate owning_ref; diff --git a/src/printer.rs b/src/printer.rs index 5f24c5f..18d3f84 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -5,7 +5,7 @@ use enumset::EnumSet; use std::cell::Cell; use std::cmp::min; use std::rc::Rc; -use theme::{BorderStyle, ColorStyle, Effect, Style, Theme, PaletteColor}; +use theme::{BorderStyle, ColorStyle, Effect, PaletteColor, Style, Theme}; use unicode_segmentation::UnicodeSegmentation; use utils::lines::simple::prefix; use vec::Vec2; @@ -33,7 +33,9 @@ impl<'a> Printer<'a> { /// But nobody needs to know that. #[doc(hidden)] pub fn new>( - size: T, theme: &'a Theme, backend: &'a backend::Concrete + size: T, + theme: &'a Theme, + backend: &'a backend::Concrete, ) -> Self { Printer { offset: Vec2::zero(), @@ -51,7 +53,8 @@ impl<'a> Printer<'a> { /// /// Users rarely need to call this directly. pub fn clear(&self) { - self.backend.clear(self.theme.palette[PaletteColor::Background]); + self.backend + .clear(self.theme.palette[PaletteColor::Background]); } /// Returns `true` if nothing has been printed yet. @@ -131,7 +134,8 @@ impl<'a> Printer<'a> { where F: FnOnce(&Printer), { - self.backend.with_color(c.resolve(&self.theme.palette), || f(self)); + self.backend + .with_color(c.resolve(&self.theme.palette), || f(self)); } /// Call the given closure with a styled printer, @@ -200,7 +204,10 @@ impl<'a> Printer<'a> { /// printer.print_box((0,0), (6,4), false); /// ``` pub fn print_box, S: Into>( - &self, start: T, size: S, invert: bool + &self, + start: T, + size: S, + invert: bool, ) { self.new.set(false); @@ -297,7 +304,10 @@ impl<'a> Printer<'a> { /// Returns a printer on a subset of this one's area. pub fn sub_printer, T: Into>( - &'a self, offset: S, size: T, focused: bool + &'a self, + offset: S, + size: T, + focused: bool, ) -> Printer<'a> { let size = size.into(); let offset = offset.into().or_min(self.size); diff --git a/src/theme/mod.rs b/src/theme/mod.rs index 86b7c07..b915e3c 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -67,7 +67,8 @@ //! Since some pairs are frequently used, `ColorStyle` defines some methods to //! create these usual values: //! -//! * **`ColorStyle::background()`**: style used to print the application background. +//! * **`ColorStyle::background()`**: style used to print the application +//! background. //! * Its *background* color is `Background`. //! * Its *foreground* color is unimportant as no characters are ever //! printed in the background. @@ -86,7 +87,8 @@ //! * **`ColorStyle::title_primary()`**: style used to print titles. //! * Its *background* color is `View`. //! * Its *foreground* color is `TitlePrimary`. -//! * **`ColorStyle::title_secondary()`**: style used to print secondary titles. +//! * **`ColorStyle::title_secondary()`**: style used to print secondary +//! titles. //! * Its *background* color is `View`. //! * Its *foreground* color is `TitleSecondary`. //! * **`ColorStyle::highlight()`**: style used to print selected items. @@ -167,7 +169,7 @@ pub use self::color::{BaseColor, Color}; pub use self::color_pair::ColorPair; pub use self::color_style::{ColorStyle, ColorType}; pub use self::effect::Effect; -pub use self::palette::{Palette, PaletteColor, default_palette}; +pub use self::palette::{default_palette, Palette, PaletteColor}; pub use self::style::Style; use std::fs::File; use std::io; diff --git a/src/theme/style.rs b/src/theme/style.rs index 644b1ce..877d266 100644 --- a/src/theme/style.rs +++ b/src/theme/style.rs @@ -1,4 +1,4 @@ -use super::{ColorStyle, Effect, Color, PaletteColor, ColorType}; +use super::{Color, ColorStyle, ColorType, Effect, PaletteColor}; use enumset::EnumSet; /// Combine a color and an effect. @@ -51,7 +51,10 @@ impl Style { } /// Returns a combination of `self` and `other`. - pub fn add(self, other: S) -> Self where S: Into