From b96895a2f28e1e9fead9228617cdc02fdd1f3c31 Mon Sep 17 00:00:00 2001 From: rabite Date: Tue, 29 Jan 2019 18:54:13 +0100 Subject: previews for directories --- src/widget.rs | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'src/widget.rs') diff --git a/src/widget.rs b/src/widget.rs index 7fc319c..db2a4f1 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -68,16 +68,41 @@ pub trait Widget { ) } - //fn get_window(&self) -> Window; - //fn get_window_mut(&mut self) -> &mut Window; + fn get_clearlist(&self) -> String { + let (xpos, ypos) = self.get_position().position(); + let (xsize, ysize) = self.get_size().size(); + + let mut clearcmd = String::from(""); + for line in ypos..ysize { + clearcmd += &format!("{}{:xsize$}", + crate::term::goto_xy(xpos, line), + " ", + xsize=xsize as usize); + } + + clearcmd + } - //fn run(&mut self) { - // self.draw(); - // self.handle_input(); - //} + fn get_redraw_empty_list(&self, lines: usize) -> String { + let (xpos, ypos) = self.get_position().position(); + let (xsize, ysize) = self.get_size().size(); + + let mut output = String::new(); + + if ysize as usize > lines { + let start_y = lines + 1 + ypos as usize; + for i in start_y..(ysize+2) as usize { + output += &format!("{}{:xsize$}", + crate::term::goto_xy(xpos,i as u16), + " ", + xsize = xsize as usize); + } + } + + output + } - //fn get_buffer(&self) -> &Vec; fn refresh(&mut self); fn get_drawlist(&self) -> String; } -- cgit v1.2.3