1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-20 03:09:06 +03:00

tmux: when resizing locally, inform tmux of new size

This isn't really correct: if there are splits, this is most
likely going to do the wrong thing.

refs: #336
This commit is contained in:
Wez Furlong 2022-01-17 16:36:24 -07:00
parent 11a9d9065e
commit ebef7dc659
2 changed files with 26 additions and 2 deletions

View File

@ -266,6 +266,28 @@ impl TmuxCommand for ListAllPanes {
}
}
#[derive(Debug)]
pub(crate) struct Resize {
pub size: portable_pty::PtySize,
}
impl TmuxCommand for Resize {
fn get_command(&self) -> String {
format!("refresh-client -C {}x{}\n", self.size.cols, self.size.rows)
}
fn process_result(&self, domain_id: DomainId, result: &Guarded) -> anyhow::Result<()> {
if result.error {
log::error!(
"Error resizing: domain_id={} result={:?}",
domain_id,
result
);
}
Ok(())
}
}
#[derive(Debug)]
pub(crate) struct CapturePane(TmuxPaneId);
impl TmuxCommand for CapturePane {

View File

@ -1,5 +1,5 @@
use crate::tmux::{RefTmuxRemotePane, TmuxCmdQueue, TmuxDomainState};
use crate::tmux_commands::SendKeys;
use crate::tmux_commands::{Resize, SendKeys};
use crate::DomainId;
use filedescriptor::FileDescriptor;
use portable_pty::{Child, ChildKiller, ExitStatus, MasterPty};
@ -123,7 +123,9 @@ impl ChildKiller for TmuxChild {
impl MasterPty for TmuxPty {
fn resize(&self, size: portable_pty::PtySize) -> Result<(), anyhow::Error> {
log::warn!("TODO: perform pane resize");
let mut cmd_queue = self.cmd_queue.lock().unwrap();
cmd_queue.push_back(Box::new(Resize { size }));
TmuxDomainState::schedule_send_next_command(self.domain_id);
Ok(())
}