Very nearly working
This commit is contained in:
parent
a6ba792e89
commit
d509b0c339
3 changed files with 5 additions and 6 deletions
|
|
@ -555,8 +555,7 @@ impl Tab {
|
||||||
terminal.y() + 1,
|
terminal.y() + 1,
|
||||||
terminal.x() + 1,
|
terminal.x() + 1,
|
||||||
pad_to_size(&vte_output, terminal.rows(), terminal.columns())
|
pad_to_size(&vte_output, terminal.rows(), terminal.columns())
|
||||||
)
|
).expect("cannot write to stdout");
|
||||||
.expect("cannot write to stdout");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(clippy::clippy::if_same_then_else)]
|
#![allow(clippy::clippy::if_same_then_else)]
|
||||||
|
|
||||||
use crate::tab::Pane;
|
use crate::{tab::Pane, utils::shared::ansi_len};
|
||||||
use ::nix::pty::Winsize;
|
use ::nix::pty::Winsize;
|
||||||
use ::std::os::unix::io::RawFd;
|
use ::std::os::unix::io::RawFd;
|
||||||
use ::vte::Perform;
|
use ::vte::Perform;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
use std::iter;
|
use std::{iter, str::from_utf8};
|
||||||
|
|
||||||
use strip_ansi_escapes::strip;
|
use strip_ansi_escapes::strip;
|
||||||
|
|
||||||
// FIXME: Should this be an extension trait? Or here at all?
|
// FIXME: Should this be an extension trait? Or here at all?
|
||||||
pub fn ansi_len(s: &str) -> usize {
|
pub fn ansi_len(s: &str) -> usize {
|
||||||
strip(s.as_bytes()).unwrap().len()
|
from_utf8(&strip(s.as_bytes()).unwrap()).unwrap().chars().count()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pad_to_size(s: &str, rows: usize, columns: usize) -> String {
|
pub fn pad_to_size(s: &str, rows: usize, columns: usize) -> String {
|
||||||
s.lines()
|
s.lines()
|
||||||
.map(|l| [l, &str::repeat(" ", dbg!(columns) - dbg!(ansi_len(l)))].concat())
|
.map(|l| [l, &str::repeat(" ", columns - ansi_len(l))].concat())
|
||||||
.chain(iter::repeat(str::repeat(" ", columns)))
|
.chain(iter::repeat(str::repeat(" ", columns)))
|
||||||
.take(rows)
|
.take(rows)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue