summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--rsnix/src/klog.rs10
-rw-r--r--rsnix/src/tty.rs5
-rw-r--r--shell/src/lib.rs12
3 files changed, 21 insertions, 6 deletions
diff --git a/rsnix/src/klog.rs b/rsnix/src/klog.rs
index 5da5094..2e1fc82 100644
--- a/rsnix/src/klog.rs
+++ b/rsnix/src/klog.rs
@@ -21,7 +21,11 @@ extern crate alloc;
21use alloc::string::String; 21use alloc::string::String;
22 22
23pub const MAX_LINES: usize = 128; 23pub const MAX_LINES: usize = 128;
24pub const MAX_LINE: usize = 128; 24/// Max bytes stored per line. Wide enough that no real line truncates
25/// at any plausible terminal width (a 240-col 4K framebuffer row is
26/// still under this) — long lines flow in full and the terminal wraps
27/// them at the screen edge instead of cutting them off.
28pub const MAX_LINE: usize = 512;
25 29
26struct Ring { 30struct Ring {
27 /// Sequence counter for the next line to be appended (total ever). 31 /// Sequence counter for the next line to be appended (total ever).
@@ -36,7 +40,7 @@ struct Ring {
36 /// the timer is running (early-boot PIT reads are uninitialised). 40 /// the timer is running (early-boot PIT reads are uninitialised).
37 last_ms: u64, 41 last_ms: u64,
38 ms: [u64; MAX_LINES], 42 ms: [u64; MAX_LINES],
39 lens: [u8; MAX_LINES], 43 lens: [u16; MAX_LINES],
40 bytes: [[u8; MAX_LINE]; MAX_LINES], 44 bytes: [[u8; MAX_LINE]; MAX_LINES],
41} 45}
42 46
@@ -74,7 +78,7 @@ pub fn append(line: &str, mut ms: u64) {
74 } 78 }
75 r.ms[r.next] = ms; 79 r.ms[r.next] = ms;
76 r.bytes[r.next][..n].copy_from_slice(&b[..n]); 80 r.bytes[r.next][..n].copy_from_slice(&b[..n]);
77 r.lens[r.next] = n as u8; 81 r.lens[r.next] = n as u16;
78 r.next = (r.next + 1) % MAX_LINES; 82 r.next = (r.next + 1) % MAX_LINES;
79 r.seq += 1; 83 r.seq += 1;
80} 84}
diff --git a/rsnix/src/tty.rs b/rsnix/src/tty.rs
index 81a7a24..7304925 100644
--- a/rsnix/src/tty.rs
+++ b/rsnix/src/tty.rs
@@ -17,7 +17,10 @@ use crate::ps2::{self, KeyEvent};
17use crate::strbuf; 17use crate::strbuf;
18use crate::{gop, serial}; 18use crate::{gop, serial};
19 19
20pub const LINE_BUF_SIZE: usize = 256; 20/// Max characters a single typed line can hold. Long enough that no
21/// realistic command line gets silently cut — the terminal wraps the
22/// echo at the screen edge, and the full line is what's submitted.
23pub const LINE_BUF_SIZE: usize = 1024;
21 24
22/// Result of one canonical line-input session. 25/// Result of one canonical line-input session.
23#[allow(clippy::large_enum_variant)] // stack buffer by design (no heap churn) 26#[allow(clippy::large_enum_variant)] // stack buffer by design (no heap churn)
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 }