Fix drawing getting stuck in empty terminal
Fix drawing getting stuck in loops when terminal is too small by checking for it.async
parent
4301fa3b04
commit
f131e01bfc
|
@ -71,10 +71,16 @@ pub trait TextProcessing: UnicodeSegmentation + CodePointsIter {
|
|||
|
||||
impl TextProcessing for str {
|
||||
fn split_lines(&self, width: usize) -> Vec<String> {
|
||||
if width == 0 {
|
||||
return vec![];
|
||||
}
|
||||
super::line_break::linear(self, width)
|
||||
}
|
||||
|
||||
fn split_lines_reflow(&self, reflow: Reflow, width: Option<usize>) -> Vec<String> {
|
||||
if width == Some(0) {
|
||||
return vec![];
|
||||
}
|
||||
super::line_break::split_lines_reflow(self, reflow, width)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1023,6 +1023,9 @@ pub fn split_lines_reflow(text: &str, reflow: Reflow, width: Option<usize>) -> V
|
|||
ret.push(format!("⤷{}", &line[prev_line_offset..end_offset]));
|
||||
}
|
||||
}
|
||||
if prev_line_offset == end_offset && prev == new_off {
|
||||
break;
|
||||
}
|
||||
prev_line_offset = end_offset;
|
||||
prev = new_off;
|
||||
}
|
||||
|
|
|
@ -294,6 +294,9 @@ impl ListingTrait for CompactListing {
|
|||
return;
|
||||
}
|
||||
let rows = get_y(bottom_right) - get_y(upper_left) + 1;
|
||||
if rows == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(mvm) = self.movement.take() {
|
||||
match mvm {
|
||||
|
|
|
@ -295,6 +295,9 @@ impl ListingTrait for ConversationsListing {
|
|||
return;
|
||||
}
|
||||
let rows = (get_y(bottom_right) - get_y(upper_left) + 1) / 3;
|
||||
if rows == 0 {
|
||||
return;
|
||||
}
|
||||
let pad = (get_y(bottom_right) - get_y(upper_left) + 1) % 3;
|
||||
|
||||
if let Some(mvm) = self.movement.take() {
|
||||
|
|
|
@ -300,6 +300,9 @@ impl ListingTrait for PlainListing {
|
|||
return;
|
||||
}
|
||||
let rows = get_y(bottom_right) - get_y(upper_left) + 1;
|
||||
if rows == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(mvm) = self.movement.take() {
|
||||
match mvm {
|
||||
|
|
|
@ -225,6 +225,9 @@ impl ListingTrait for ThreadListing {
|
|||
return;
|
||||
}
|
||||
let rows = get_y(bottom_right) - get_y(upper_left) + 1;
|
||||
if rows == 0 {
|
||||
return;
|
||||
}
|
||||
if let Some(mvm) = self.movement.take() {
|
||||
match mvm {
|
||||
PageMovement::Up(amount) => {
|
||||
|
|
|
@ -57,12 +57,8 @@ pub fn pos_dec(p: Pos, dec: (usize, usize)) -> Pos {
|
|||
/// An `Area` consists of two points: the upper left and bottom right corners.
|
||||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// # #[macro_use] extern crate ui; fn main() {
|
||||
/// use ui::*;
|
||||
///
|
||||
/// ```no_run
|
||||
/// let new_area = ((0, 0), (1, 1));
|
||||
/// # }
|
||||
/// ```
|
||||
pub type Area = (Pos, Pos);
|
||||
|
||||
|
@ -70,12 +66,8 @@ pub type Area = (Pos, Pos);
|
|||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// # #[macro_use] extern crate ui; fn main() {
|
||||
/// use ui::*;
|
||||
///
|
||||
/// let new_area = ((0, 0), (1, 1));
|
||||
/// assert_eq!(height!(new_area), 1);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! height {
|
||||
|
@ -88,12 +80,8 @@ macro_rules! height {
|
|||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// # #[macro_use] extern crate ui; fn main() {
|
||||
/// use ui::*;
|
||||
///
|
||||
/// let new_area = ((0, 0), (1, 1));
|
||||
/// assert_eq!(width!(new_area), 1);
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! width {
|
||||
|
@ -106,12 +94,8 @@ macro_rules! width {
|
|||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// # #[macro_use] extern crate ui; fn main() {
|
||||
/// use ui::*;
|
||||
///
|
||||
/// let new_area = ((0, 0), (1, 1));
|
||||
/// assert_eq!(upper_left!(new_area), (0, 0));
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! upper_left {
|
||||
|
@ -124,12 +108,8 @@ macro_rules! upper_left {
|
|||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// # #[macro_use] extern crate ui; fn main() {
|
||||
/// use ui::*;
|
||||
///
|
||||
/// let new_area = ((0, 0), (1, 1));
|
||||
/// assert_eq!(bottom_right!(new_area), (1, 1));
|
||||
/// # }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! bottom_right {
|
||||
|
@ -142,15 +122,12 @@ macro_rules! bottom_right {
|
|||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// # #[macro_use] extern crate ui; fn main() {
|
||||
/// use ui::*;
|
||||
///
|
||||
/// let valid_area = ((0, 0), (1, 1));
|
||||
/// assert!(is_valid_area!(valid_area));
|
||||
///
|
||||
/// let invalid_area = ((2, 2), (1, 1));
|
||||
/// assert!(!is_valid_area!(invalid_area));
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
#[macro_export]
|
||||
macro_rules! is_valid_area {
|
||||
|
|
Loading…
Reference in New Issue