diff options
Diffstat (limited to 'shell/src/lib.rs')
| -rw-r--r-- | shell/src/lib.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/shell/src/lib.rs b/shell/src/lib.rs index 97fa6c2..617e5a4 100644 --- a/shell/src/lib.rs +++ b/shell/src/lib.rs | |||
| @@ -365,6 +365,7 @@ enum StageState { | |||
| 365 | Pause { | 365 | Pause { |
| 366 | shown: usize, | 366 | shown: usize, |
| 367 | screen: usize, | 367 | screen: usize, |
| 368 | cols: usize, | ||
| 368 | }, | 369 | }, |
| 369 | } | 370 | } |
| 370 | 371 | ||
| @@ -433,6 +434,10 @@ impl Pipeline { | |||
| 433 | Filter::Pause => StageState::Pause { | 434 | Filter::Pause => StageState::Pause { |
| 434 | shown: 0, | 435 | shown: 0, |
| 435 | screen: rsnix::vt::size().0.saturating_sub(1).max(1), | 436 | screen: rsnix::vt::size().0.saturating_sub(1).max(1), |
| 437 | // Rows a screenful of *wrapped* output occupies: a | ||
| 438 | // line wider than the terminal takes more than one | ||
| 439 | // row, so the pager counts rows, not lines. | ||
| 440 | cols: rsnix::vt::size().1.max(1), | ||
| 436 | }, | 441 | }, |
| 437 | }; | 442 | }; |
| 438 | stages.push((f.clone(), st)); | 443 | stages.push((f.clone(), st)); |
| @@ -510,14 +515,17 @@ impl Pipeline { | |||
| 510 | } | 515 | } |
| 511 | } | 516 | } |
| 512 | Filter::Pause => { | 517 | Filter::Pause => { |
| 513 | let StageState::Pause { shown, screen } = st else { | 518 | let StageState::Pause { shown, screen, cols } = st else { |
| 514 | unreachable!("stage state does not match filter") | 519 | unreachable!("stage state does not match filter") |
| 515 | }; | 520 | }; |
| 516 | for l in cur.drain(..) { | 521 | for l in cur.drain(..) { |
| 522 | // Rows this line occupies after terminal wrapping | ||
| 523 | // (at least 1; an empty line is one row). | ||
| 524 | let rows = l.len().div_ceil(*cols); | ||
| 517 | if *shown > 0 && *shown % *screen == 0 && !pager_wait() { | 525 | if *shown > 0 && *shown % *screen == 0 && !pager_wait() { |
| 518 | return false; | 526 | return false; |
| 519 | } | 527 | } |
| 520 | *shown += 1; | 528 | *shown += rows; |
| 521 | out.push(l); | 529 | out.push(l); |
| 522 | } | 530 | } |
| 523 | } | 531 | } |
