From 0d8e05039d691dde1c471d75186884476dd72712 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 1 Apr 2013 04:02:18 -0500 Subject: buffer writes --- test/rl.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'test/rl.rs') diff --git a/test/rl.rs b/test/rl.rs index 96c0df3..1915c43 100644 --- a/test/rl.rs +++ b/test/rl.rs @@ -1,31 +1,31 @@ extern mod term; use term::{KeyCharacter,KeyEscape,KeyUp,KeyDown,KeyLeft,KeyRight}; -fn term_app (body: &fn (r: &mut term::Reader, w: &term::Writer)) { - let writer = term::Writer(true); +fn term_app (body: &fn (r: &mut term::Reader, w: &mut term::Writer)) { + let mut writer = term::Writer(true); let mut reader = term::Reader(true); do term::ios::preserve { writer.alternate_screen(true); - body(&mut reader, &writer); + body(&mut reader, &mut writer); } } -fn draw_map (w: &term::Writer, rows: uint, cols: uint) { +fn draw_map (w: &mut term::Writer, rows: uint, cols: uint) { for uint::range(0, rows) |i| { w.move(0, i); - io::print(str::repeat(".", cols)); + w.write(str::repeat(".", cols)); } } -fn draw_character (w: &term::Writer, x: uint, y: uint) { +fn draw_character (w: &mut term::Writer, x: uint, y: uint) { w.move(x, y); - io::print("@"); + w.write("@"); w.move(x, y); } -fn draw_ground (w: &term::Writer, x: uint, y: uint) { +fn draw_ground (w: &mut term::Writer, x: uint, y: uint) { w.move(x, y); - io::print("."); + w.write("."); } fn main () { @@ -42,6 +42,7 @@ fn main () { let mut cursor = true; loop { draw_character(w, x, y); + w.flush(); let k = match r.read() { Some(key) => key, None => break, -- cgit v1.2.3-54-g00ecf