add margin in pad calculations

This commit is contained in:
Giacomo Pasini 2024-01-03 11:23:38 +01:00
parent b7971d5a3f
commit 875261d728
No known key found for this signature in database
GPG Key ID: FC08489D2D895D4B
1 changed files with 6 additions and 1 deletions

View File

@ -125,8 +125,13 @@ fn render_messages(f: &mut Frame, app: &App, rect: Rect) {
.iter()
.map(|ChatMessage { author, message }| {
let content = if author == app.username.as_ref().unwrap() {
static MARGIN: usize = 2;
// pad to make it appear aligned on the right
let pad = " ".repeat((rect.width as usize).saturating_sub(message.len()));
let pad = " ".repeat(
(rect.width as usize)
.saturating_sub(message.len())
.saturating_sub(MARGIN),
);
Line::from(vec![Span::raw(pad), Span::raw(message)])
} else {
Line::from(vec![