From c2b6daeaaf1da5c6f81300e954f2b3592c0668c0 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 18:03:20 +0200 Subject: klog/tty/pager: no more truncated lines — full lines flow, terminal wraps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- rsnix/src/klog.rs | 10 +++++++--- rsnix/src/tty.rs | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'rsnix') 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; use alloc::string::String; pub const MAX_LINES: usize = 128; -pub const MAX_LINE: usize = 128; +/// Max bytes stored per line. Wide enough that no real line truncates +/// at any plausible terminal width (a 240-col 4K framebuffer row is +/// still under this) — long lines flow in full and the terminal wraps +/// them at the screen edge instead of cutting them off. +pub const MAX_LINE: usize = 512; struct Ring { /// Sequence counter for the next line to be appended (total ever). @@ -36,7 +40,7 @@ struct Ring { /// the timer is running (early-boot PIT reads are uninitialised). last_ms: u64, ms: [u64; MAX_LINES], - lens: [u8; MAX_LINES], + lens: [u16; MAX_LINES], bytes: [[u8; MAX_LINE]; MAX_LINES], } @@ -74,7 +78,7 @@ pub fn append(line: &str, mut ms: u64) { } r.ms[r.next] = ms; r.bytes[r.next][..n].copy_from_slice(&b[..n]); - r.lens[r.next] = n as u8; + r.lens[r.next] = n as u16; r.next = (r.next + 1) % MAX_LINES; r.seq += 1; } 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}; use crate::strbuf; use crate::{gop, serial}; -pub const LINE_BUF_SIZE: usize = 256; +/// Max characters a single typed line can hold. Long enough that no +/// realistic command line gets silently cut — the terminal wraps the +/// echo at the screen edge, and the full line is what's submitted. +pub const LINE_BUF_SIZE: usize = 1024; /// Result of one canonical line-input session. #[allow(clippy::large_enum_variant)] // stack buffer by design (no heap churn) -- cgit v1.2.3