aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrooks J Rady <b.j.rady@gmail.com>2021-01-06 13:34:21 +0000
committerBrooks J Rady <b.j.rady@gmail.com>2021-01-06 13:34:21 +0000
commitd509b0c339fc7857dc6ef17d678961b0060de646 (patch)
tree274466a42800200a52eee5b7fc21a953b6a4becf /src
parentAlso borken (diff)
downloadsl0ppij-d509b0c339fc7857dc6ef17d678961b0060de646.tar.gz
sl0ppij-d509b0c339fc7857dc6ef17d678961b0060de646.tar.xz
sl0ppij-d509b0c339fc7857dc6ef17d678961b0060de646.zip
Very nearly working
Diffstat (limited to 'src')
-rw-r--r--src/tab.rs3
-rw-r--r--src/terminal_pane/terminal_pane.rs2
-rw-r--r--src/utils/shared.rs6
3 files changed, 5 insertions, 6 deletions
diff --git a/src/tab.rs b/src/tab.rs
index 2677e373..81ac309b 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -555,8 +555,7 @@ impl Tab {
terminal.y() + 1,
terminal.x() + 1,
pad_to_size(&vte_output, terminal.rows(), terminal.columns())
- )
- .expect("cannot write to stdout");
+ ).expect("cannot write to stdout");
}
}
}
diff --git a/src/terminal_pane/terminal_pane.rs b/src/terminal_pane/terminal_pane.rs
index fda74c2a..096e9836 100644
--- a/src/terminal_pane/terminal_pane.rs
+++ b/src/terminal_pane/terminal_pane.rs
@@ -1,6 +1,6 @@
#![allow(clippy::clippy::if_same_then_else)]
-use crate::tab::Pane;
+use crate::{tab::Pane, utils::shared::ansi_len};
use ::nix::pty::Winsize;
use ::std::os::unix::io::RawFd;
use ::vte::Perform;
diff --git a/src/utils/shared.rs b/src/utils/shared.rs
index 3b8b5fbd..f5d4c303 100644
--- a/src/utils/shared.rs
+++ b/src/utils/shared.rs
@@ -1,15 +1,15 @@
-use std::iter;
+use std::{iter, str::from_utf8};
use strip_ansi_escapes::strip;
// FIXME: Should this be an extension trait? Or here at all?
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 {
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)))
.take(rows)
.collect::<Vec<_>>()