From ebef7dc659ccac6a99c592b0f21401992cfb5bd8 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 17 Jan 2022 16:36:24 -0700 Subject: [PATCH] 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 --- mux/src/tmux_commands.rs | 22 ++++++++++++++++++++++ mux/src/tmux_pty.rs | 6 ++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mux/src/tmux_commands.rs b/mux/src/tmux_commands.rs index c77d92e96..b28142931 100644 --- a/mux/src/tmux_commands.rs +++ b/mux/src/tmux_commands.rs @@ -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 { diff --git a/mux/src/tmux_pty.rs b/mux/src/tmux_pty.rs index e51c7a911..4405b5af2 100644 --- a/mux/src/tmux_pty.rs +++ b/mux/src/tmux_pty.rs @@ -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(()) }