This commit is contained in:
Alexandre Bury 2016-07-25 13:39:10 -07:00
parent 5e6222bf23
commit 7283e7f3af
5 changed files with 8 additions and 11 deletions

View File

@ -229,7 +229,8 @@ impl Cursive {
/// Loads a theme from the given file. /// Loads a theme from the given file.
/// ///
/// `filename` must point to a valid toml file. /// `filename` must point to a valid toml file.
pub fn load_theme_file<P: AsRef<Path>>(&mut self, filename: P) -> Result<(), theme::Error> { pub fn load_theme_file<P: AsRef<Path>>(&mut self, filename: P)
-> Result<(), theme::Error> {
self.theme = try!(theme::load_theme_file(filename)); self.theme = try!(theme::load_theme_file(filename));
Ok(()) Ok(())
} }

View File

@ -36,7 +36,7 @@
//! Color styles are defined to easily refer to a pair of colors from the //! Color styles are defined to easily refer to a pair of colors from the
//! palette. //! palette.
//! //!
//! * **`Background`**: style used to print the application background. //! * **`Background`**: style used to print the application background.
//! * Its *background* color is `background`. //! * Its *background* color is `background`.
//! * Its *foreground* color is unimportant as no characters are ever //! * Its *foreground* color is unimportant as no characters are ever
//! printed in the background. //! printed in the background.

View File

@ -31,11 +31,10 @@ impl<T: View + Any> ViewWrapper for IdView<T> {
/// Makes a view wrappable in an `IdView`. /// Makes a view wrappable in an `IdView`.
pub trait Identifiable: View + Sized { pub trait Identifiable: View + Sized {
/// Wraps this view into an IdView with the given id. /// Wraps this view into an IdView with the given id.
fn with_id(self, id: &str) -> IdView<Self> { fn with_id(self, id: &str) -> IdView<Self> {
IdView::new(id, self) IdView::new(id, self)
} }
} }
impl <T: View> Identifiable for T {} impl<T: View> Identifiable for T {}

View File

@ -10,9 +10,7 @@ pub struct Panel<V: View> {
impl<V: View> Panel<V> { impl<V: View> Panel<V> {
/// Creates a new panel around the given view. /// Creates a new panel around the given view.
pub fn new(view: V) -> Self { pub fn new(view: V) -> Self {
Panel { Panel { view: view }
view: view,
}
} }
} }

View File

@ -46,9 +46,7 @@ impl ProgressBar {
/// Sets the callback to follow. /// Sets the callback to follow.
/// ///
/// Whenever `callback` is set, it will be called on the next event loop. /// Whenever `callback` is set, it will be called on the next event loop.
pub fn with_callback(mut self, pub fn with_callback(mut self, callback: Arc<Mutex<CbPromise>>) -> Self {
callback: Arc<Mutex<CbPromise>>)
-> Self {
self.callback = Some(callback); self.callback = Some(callback);
self self
} }
@ -88,7 +86,8 @@ impl View for ProgressBar {
let available = printer.size.x; let available = printer.size.x;
let value = self.value.load(Ordering::Relaxed); let value = self.value.load(Ordering::Relaxed);
let length = ((1 + available) * (value - self.min)) / (1 + self.max - self.min); let length = ((1 + available) * (value - self.min)) /
(1 + self.max - self.min);
printer.with_color(ColorStyle::Highlight, |printer| { printer.with_color(ColorStyle::Highlight, |printer| {
printer.print_hline((0, 0), length, " "); printer.print_hline((0, 0), length, " ");
}); });