aboutsummaryrefslogtreecommitdiffstats
path: root/teleterm/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-22 15:16:14 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-22 15:20:00 -0500
commitcc0ac6c8337e3dfea740feb0385d4a14e737d77c (patch)
tree760a62e92f97705dfe922ae026cb6f6d0cf82e95 /teleterm/src
parentb6bfebb57804bc72fe1f85bcc050b548cb79a11d (diff)
downloadteleterm-cc0ac6c8337e3dfea740feb0385d4a14e737d77c.tar.gz
teleterm-cc0ac6c8337e3dfea740feb0385d4a14e737d77c.zip
resize the browser terminal if the streamer terminal is resized
Diffstat (limited to 'teleterm/src')
-rw-r--r--teleterm/src/cmd/watch.rs3
-rw-r--r--teleterm/src/server.rs23
-rw-r--r--teleterm/src/web.rs9
3 files changed, 22 insertions, 13 deletions
diff --git a/teleterm/src/cmd/watch.rs b/teleterm/src/cmd/watch.rs
index f156112..f205002 100644
--- a/teleterm/src/cmd/watch.rs
+++ b/teleterm/src/cmd/watch.rs
@@ -360,6 +360,9 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
crate::protocol::Message::Error { msg } => {
return Err(Error::Server { message: msg });
}
+ crate::protocol::Message::Resize { .. } => {
+ // do nothing
+ }
msg => {
return Err(crate::error::Error::UnexpectedMessage {
message: msg,
diff --git a/teleterm/src/server.rs b/teleterm/src/server.rs
index 1f8f442..1f565a2 100644
--- a/teleterm/src/server.rs
+++ b/teleterm/src/server.rs
@@ -489,16 +489,17 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
let username = conn.state.username().unwrap();
if let Some(stream_conn) = self.connections.get(&id) {
- let data = stream_conn
- .state
- .term()
- .map(|parser| parser.screen().contents_formatted())
- .ok_or_else(|| Error::InvalidWatchId {
- id: id.to_string(),
- })?;
+ let term = stream_conn.state.term().ok_or_else(|| {
+ Error::InvalidWatchId { id: id.to_string() }
+ })?;
+ let (rows, cols) = term.screen().size();
+ let data = term.screen().contents_formatted();
log::info!("{}: watch({}, {})", conn.id, username, id);
conn.state.watch(&id);
+ conn.send_message(crate::protocol::Message::resize(
+ crate::term::Size { rows, cols },
+ ));
conn.send_message(crate::protocol::Message::terminal_output(
&data,
));
@@ -585,6 +586,14 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
parser.set_size(size.rows, size.cols);
}
+ for watch_conn in self.watchers_mut() {
+ let watch_id = watch_conn.state.watch_id().unwrap();
+ if conn.id == watch_id {
+ watch_conn
+ .send_message(crate::protocol::Message::resize(size));
+ }
+ }
+
Ok(())
}
diff --git a/teleterm/src/web.rs b/teleterm/src/web.rs
index 6cc9568..89291c5 100644
--- a/teleterm/src/web.rs
+++ b/teleterm/src/web.rs
@@ -377,12 +377,9 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
msg: &crate::protocol::Message,
) -> Result<Option<tungstenite::Message>> {
match msg {
- crate::protocol::Message::TerminalOutput { .. } => {
- let json = serde_json::to_string(msg)
- .context(crate::error::SerializeMessage)?;
- Ok(Some(tungstenite::Message::Text(json)))
- }
- crate::protocol::Message::Disconnected => {
+ crate::protocol::Message::TerminalOutput { .. }
+ | crate::protocol::Message::Disconnected
+ | crate::protocol::Message::Resize { .. } => {
let json = serde_json::to_string(msg)
.context(crate::error::SerializeMessage)?;
Ok(Some(tungstenite::Message::Text(json)))