Fix examples

This commit is contained in:
Alexandre Bury 2016-07-16 11:20:40 -07:00
parent 99993ab1ec
commit d633684e41
2 changed files with 6 additions and 2 deletions

View File

@ -29,7 +29,7 @@ impl KeyCodeView {
}
impl View for KeyCodeView {
fn draw(&mut self, printer: &Printer) {
fn draw(&self, printer: &Printer) {
for (y, line) in self.history.iter().enumerate() {
printer.print((0, y), &line);
}

View File

@ -5,6 +5,7 @@ use std::thread;
use std::time::Duration;
use cursive::Cursive;
use cursive::vec::Vec2;
use cursive::Printer;
use cursive::view::{View, FullView};
@ -91,9 +92,12 @@ impl BufferView {
}
impl View for BufferView {
fn draw(&mut self, printer: &Printer) {
fn layout(&mut self, _: Vec2) {
// Before drawing, we'll want to update the buffer
self.update();
}
fn draw(&self, printer: &Printer) {
// If the buffer is large enough, we'll discard the beginning and keep the end.
// If the buffer is too small, only print a part of it with an offset.