tui: reserve 1 cell right margin for composer and user history (#5026)
keep a 1 cell margin at the right edge of the screen in the composer (and in the user message in history). this lets us print clear-to-EOL 1 char before the end of the line in history, so that resizing the terminal will keep the background color (at least in iterm/terminal.app). it also stops the cursor in the textarea from floating off the right edge. --------- Co-authored-by: joshka-oai <joshka@openai.com>
This commit is contained in:
@@ -114,7 +114,11 @@ impl HistoryCell for UserHistoryCell {
|
||||
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
|
||||
let mut lines: Vec<Line<'static>> = Vec::new();
|
||||
|
||||
let wrap_width = width.saturating_sub(LIVE_PREFIX_COLS);
|
||||
let wrap_width = width
|
||||
.saturating_sub(
|
||||
LIVE_PREFIX_COLS + 1, /* keep a one-column right margin for wrapping */
|
||||
)
|
||||
.max(1);
|
||||
|
||||
let style = user_message_style();
|
||||
|
||||
@@ -125,7 +129,8 @@ impl HistoryCell for UserHistoryCell {
|
||||
.map(|l| Line::from(l).style(style))
|
||||
.collect::<Vec<_>>(),
|
||||
// Wrap algorithm matches textarea.rs.
|
||||
RtOptions::new(wrap_width as usize).wrap_algorithm(textwrap::WrapAlgorithm::FirstFit),
|
||||
RtOptions::new(usize::from(wrap_width))
|
||||
.wrap_algorithm(textwrap::WrapAlgorithm::FirstFit),
|
||||
);
|
||||
|
||||
lines.push(Line::from("").style(style));
|
||||
|
||||
Reference in New Issue
Block a user