From 94e723d3f03433732efc498c443a45cf381ac2ce Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Fri, 22 May 2015 16:57:29 -0700 Subject: [PATCH] Add some doc --- examples/logs.rs | 4 +++- src/color.rs | 1 + src/div.rs | 2 ++ src/view/full_view.rs | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/logs.rs b/examples/logs.rs index e52c9f9..6d4efd1 100644 --- a/examples/logs.rs +++ b/examples/logs.rs @@ -22,6 +22,8 @@ fn main() { thread::spawn(|| { generate_logs(tx); }); // And sets the view to read from the other end of the channel. + // (We use FullView to force fullscreen because + // we have no min_size for the BufferView). siv.add_layer(FullView::new(BufferView::new(200, rx))); siv.run(); @@ -68,8 +70,8 @@ impl BufferView { while let Ok(line) = self.rx.try_recv() { i = (i+1) % self.buffer.len(); self.buffer[i] = line; - self.pos = i; } + self.pos = i; } // Chain together the two parts of the buffer to appear as a circular one. diff --git a/src/color.rs b/src/color.rs index 915bc0f..436d692 100644 --- a/src/color.rs +++ b/src/color.rs @@ -8,6 +8,7 @@ use std::path::Path; use ncurses; use toml; +/// Represents a colorpair from a Theme. pub type ThemeColor = i16; /// Application background, where no view is present. diff --git a/src/div.rs b/src/div.rs index b8fc1d2..48cad6b 100644 --- a/src/div.rs +++ b/src/div.rs @@ -1,7 +1,9 @@ +/// Integer division that rounds up. pub fn div_up_usize(p: usize, q: usize) -> usize { div_up(p as u32, q as u32) as usize } +/// Integer division that rounds up. pub fn div_up(p: u32, q: u32) -> u32 { if p % q == 0 { p/q } else { 1 + p/q } diff --git a/src/view/full_view.rs b/src/view/full_view.rs index 45c9db5..f558c7d 100644 --- a/src/view/full_view.rs +++ b/src/view/full_view.rs @@ -1,11 +1,14 @@ use view::{View,ViewWrapper,SizeRequest,DimensionRequest}; use vec::Vec2; +/// Simple wrapper view that asks for all the space it can get. pub struct FullView { + /// Wrapped view. pub view: T, } impl FullView { + /// Wraps the given view into a new FullView. pub fn new(view: T) -> Self { FullView { view: view,