diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-01 18:03:20 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-01 18:03:20 +0200 |
| commit | c2b6daeaaf1da5c6f81300e954f2b3592c0668c0 (patch) | |
| tree | 62411383ea6a2d69ecf2b0fdf3e18155e660796d /rsnix/src | |
| parent | rsnix: preemptive kernel tasks (ADR 0003) — sched, IST fault stacks, 176-by... (diff) | |
| download | rs-dos-c2b6daeaaf1da5c6f81300e954f2b3592c0668c0.tar.gz rs-dos-c2b6daeaaf1da5c6f81300e954f2b3592c0668c0.zip | |
klog/tty/pager: no more truncated lines — full lines flow, terminal wraps
- klog: MAX_LINE 128 -> 512 (lens widened u8 -> u16) — long serial_println
lines (panics, boot messages) are no longer cut at 128 bytes; they
print in full and the terminal wraps them at the screen edge
- tty: LINE_BUF_SIZE 256 -> 1024 — typed command lines longer than 256
chars were silently dropped at the buffer limit; now they echo and
submit in full (the terminal already wraps the echo mid-typing)
- pager (-p): screenfuls now count wrapped rows, not lines — a line
wider than the terminal occupies ceil(len/cols) rows, so the pause
lands at a real screen boundary instead of overflowing it
Diffstat (limited to '')
| -rw-r--r-- | rsnix/src/klog.rs | 10 | ||||
| -rw-r--r-- | rsnix/src/tty.rs | 5 |
2 files changed, 11 insertions, 4 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; | |||
| 21 | use alloc::string::String; | 21 | use alloc::string::String; |
| 22 | 22 | ||
| 23 | pub const MAX_LINES: usize = 128; | 23 | pub const MAX_LINES: usize = 128; |
| 24 | pub 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. | ||
| 28 | pub const MAX_LINE: usize = 512; | ||
| 25 | 29 | ||
| 26 | struct Ring { | 30 | struct 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}; | |||
| 17 | use crate::strbuf; | 17 | use crate::strbuf; |
| 18 | use crate::{gop, serial}; | 18 | use crate::{gop, serial}; |
| 19 | 19 | ||
| 20 | pub 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. | ||
| 23 | pub 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) |
