Add/fix some doc

This commit is contained in:
Alexandre Bury 2015-05-26 16:48:27 -07:00
parent 3460f8123d
commit 44899bdcd6
6 changed files with 19 additions and 6 deletions

View File

@ -96,11 +96,11 @@ impl View for BufferView {
let (discard,offset) = if self.buffer.len() > printer.size.y as usize { let (discard,offset) = if self.buffer.len() > printer.size.y as usize {
(self.buffer.len() - printer.size.y as usize, 0) (self.buffer.len() - printer.size.y as usize, 0)
} else { } else {
(0, printer.size.y - self.buffer.len() as u32) (0, printer.size.y - self.buffer.len())
}; };
for (i, line) in self.ring().skip(discard).enumerate() { for (i, line) in self.ring().skip(discard).enumerate() {
printer.print((0,offset + i as u32), line); printer.print((0,offset + i), line);
} }
} }
} }

View File

@ -156,6 +156,7 @@ impl Cursive {
self.screen_mut().add_layer(view); self.screen_mut().add_layer(view);
} }
/// Convenient method to remove a layer from the current screen.
pub fn pop_layer(&mut self) { pub fn pop_layer(&mut self) {
self.screen_mut().pop_layer(); self.screen_mut().pop_layer();
} }

View File

@ -61,6 +61,14 @@ impl Printer {
/// Returns a wrapper around this printer, /// Returns a wrapper around this printer,
/// that will apply the given style on prints. /// that will apply the given style on prints.
///
/// # Examples
///
/// ```
/// printer.with_style(color::HIGHLIGHT, |printer| {
/// printer.print((0,0), "This text is highlighted!");
/// });
/// ```
pub fn with_style<'a, F>(&'a self, style: color::ThemeColor, f: F) pub fn with_style<'a, F>(&'a self, style: color::ThemeColor, f: F)
where F: Fn(&Printer) where F: Fn(&Printer)
{ {
@ -75,7 +83,7 @@ impl Printer {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// printer.print_box((0,0), (6,4), '+', '-', '|'); /// printer.print_box((0,0), (6,4));
/// ``` /// ```
pub fn print_box<T: ToVec2>(&self, start: T, size: T) { pub fn print_box<T: ToVec2>(&self, start: T, size: T) {
let start_v = start.to_vec2(); let start_v = start.to_vec2();

View File

@ -72,6 +72,7 @@ impl Dialog {
self self
} }
/// Sets the padding in the dialog (around content and buttons).
pub fn padding<T: ToVec4>(mut self, padding: T) -> Self { pub fn padding<T: ToVec4>(mut self, padding: T) -> Self {
self.padding = padding.to_vec4(); self.padding = padding.to_vec4();

View File

@ -3,8 +3,7 @@ use vec::Vec2;
/// Simple wrapper view that asks for all the space it can get. /// Simple wrapper view that asks for all the space it can get.
pub struct FullView<T: View> { pub struct FullView<T: View> {
/// Wrapped view. view: T,
pub view: T,
} }
impl <T: View> FullView<T> { impl <T: View> FullView<T> {

View File

@ -3,11 +3,15 @@ use printer::Printer;
use vec::Vec2; use vec::Vec2;
use color; use color;
/// Wrapper view that adds a shadow.
///
/// It reserves a 1 pixel border on each side.
pub struct ShadowView<T: View> { pub struct ShadowView<T: View> {
pub view: T, view: T,
} }
impl <T: View> ShadowView<T> { impl <T: View> ShadowView<T> {
/// Wraps the given view.
pub fn new(view: T) -> Self { pub fn new(view: T) -> Self {
ShadowView { ShadowView {
view: view, view: view,