Add some doc

This commit is contained in:
Alexandre Bury 2015-05-22 16:57:29 -07:00
parent 602ec49332
commit 94e723d3f0
4 changed files with 9 additions and 1 deletions

View File

@ -22,6 +22,8 @@ fn main() {
thread::spawn(|| { generate_logs(tx); }); thread::spawn(|| { generate_logs(tx); });
// And sets the view to read from the other end of the channel. // 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.add_layer(FullView::new(BufferView::new(200, rx)));
siv.run(); siv.run();
@ -68,8 +70,8 @@ impl BufferView {
while let Ok(line) = self.rx.try_recv() { while let Ok(line) = self.rx.try_recv() {
i = (i+1) % self.buffer.len(); i = (i+1) % self.buffer.len();
self.buffer[i] = line; self.buffer[i] = line;
self.pos = i;
} }
self.pos = i;
} }
// Chain together the two parts of the buffer to appear as a circular one. // Chain together the two parts of the buffer to appear as a circular one.

View File

@ -8,6 +8,7 @@ use std::path::Path;
use ncurses; use ncurses;
use toml; use toml;
/// Represents a colorpair from a Theme.
pub type ThemeColor = i16; pub type ThemeColor = i16;
/// Application background, where no view is present. /// Application background, where no view is present.

View File

@ -1,7 +1,9 @@
/// Integer division that rounds up.
pub fn div_up_usize(p: usize, q: usize) -> usize { pub fn div_up_usize(p: usize, q: usize) -> usize {
div_up(p as u32, q as u32) as 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 { pub fn div_up(p: u32, q: u32) -> u32 {
if p % q == 0 { p/q } if p % q == 0 { p/q }
else { 1 + p/q } else { 1 + p/q }

View File

@ -1,11 +1,14 @@
use view::{View,ViewWrapper,SizeRequest,DimensionRequest}; use view::{View,ViewWrapper,SizeRequest,DimensionRequest};
use vec::Vec2; use vec::Vec2;
/// Simple wrapper view that asks for all the space it can get.
pub struct FullView<T: View> { pub struct FullView<T: View> {
/// Wrapped view.
pub view: T, pub view: T,
} }
impl <T: View> FullView<T> { impl <T: View> FullView<T> {
/// Wraps the given view into a new FullView.
pub fn new(view: T) -> Self { pub fn new(view: T) -> Self {
FullView { FullView {
view: view, view: view,