~hime/protochat

08d3df183dd6d7622441e7fa8e93bb61c6a4c67d — drbawb 11 months ago 9596ed2
make sure we clear rest of the buffer panel
1 files changed, 11 insertions(+), 33 deletions(-)

M linetest/src/shell/ui/buffer.rs
M linetest/src/shell/ui/buffer.rs => linetest/src/shell/ui/buffer.rs +11 -33
@@ 108,46 108,24 @@ impl Buffer {
            .flat_map(|span| span.line_iter())
            .take(self.rows as usize);

        let mut rows_drawn = 0;
        for line in viewport_lines {
            rows_drawn += 1;
            stdout
                .queue(Clear(ClearType::CurrentLine))?
                .queue(Print(line))?
                .queue(cursor::MoveUp(1))?
                .queue(cursor::MoveToColumn(0))?;
        }



        // while rows_left > 0 {
        //     // grab the next buffer line
        //     let buffer_line = match buffer_lines.next() {
        //         Some(line) => line,
        //         None => {
        //             stdout
        //                 .queue(Clear(ClearType::CurrentLine))?
        //                 .queue(cursor::MoveUp(1))?
        //                 .queue(cursor::MoveToColumn(0))?;
                    
        //             rows_left -= 1; continue
        //         },
        //     };

        //     // create a span & paint it from the bottom up
        //     let span = Span::new(buffer_line, self.cols);
        //     let span_lines = span.lines.iter().rev();

        //     for span_line in span_lines {
        //         if rows_left == 0 { break; } // can't fit any more spans
                
        //         stdout
        //             .queue(Clear(ClearType::CurrentLine))?
        //             .queue(Print(span_line))?
        //             .queue(cursor::MoveUp(1))?
        //             .queue(cursor::MoveToColumn(0))?;

        //         rows_left -= 1;        
        //     }
        // }
        
        // clear remaining lines
        while rows_drawn < self.rows {
            rows_drawn += 1;
            stdout
                .queue(Clear(ClearType::CurrentLine))?
                .queue(cursor::MoveUp(1))?
                .queue(cursor::MoveToColumn(0))?;
        }

        Ok(())
    }