Make width measuring optional and disabled by default

This commit is contained in:
Joscha 2022-06-08 17:38:38 +02:00
parent 33264b4aec
commit 333cf74fba
5 changed files with 47 additions and 27 deletions

View file

@ -1,7 +1,7 @@
use crossterm::event::Event;
use crossterm::style::ContentStyle;
use toss::frame::{Frame, Pos};
use toss::terminal::{Redraw, Terminal};
use toss::terminal::Terminal;
fn draw(f: &mut Frame) {
let text = concat!(
@ -36,7 +36,9 @@ fn render_frame(term: &mut Terminal) {
draw(term.frame());
if term.present().unwrap() == Redraw::NotRequired {
if term.measuring_required() {
term.measure_widths().unwrap();
} else {
break;
}
}
@ -45,6 +47,7 @@ fn render_frame(term: &mut Terminal) {
fn main() {
// Automatically enters alternate screen and enables raw mode
let mut term = Terminal::new().unwrap();
term.set_measuring(true);
loop {
// Render and display a frame. A full frame is displayed on the terminal