diff --git a/docs/changelog.markdown b/docs/changelog.markdown index 5e89f65d3..e540da48d 100644 --- a/docs/changelog.markdown +++ b/docs/changelog.markdown @@ -10,7 +10,8 @@ daily) from the master branch. It may not be usable and the feature set may change. As features stabilize some brief notes about them may accumulate here. -* No notable changes yet! +* Added `initial_rows` and `initial_cols` config options to set the starting + size of new terminal windows ### 20200202-181957-765184e5 diff --git a/src/config/mod.rs b/src/config/mod.rs index e5f3a5af9..db8d2dbf6 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -8,7 +8,7 @@ use crate::frontend::FrontEndSelection; use crate::keyassignment::KeyAssignment; use anyhow::{anyhow, bail, Context, Error}; use lazy_static::lazy_static; -use portable_pty::CommandBuilder; +use portable_pty::{CommandBuilder, PtySize}; use serde::Deserialize; use std; use std::collections::HashMap; @@ -300,6 +300,14 @@ pub struct Config { /// as the positional arguments to that command. pub default_prog: Option>, + /// Specifies the height of a new window, expressed in character cells. + #[serde(default = "default_initial_rows")] + pub initial_rows: u16, + + /// Specifies the width of a new window, expressed in character cells + #[serde(default = "default_initial_cols")] + pub initial_cols: u16, + #[serde(default = "default_hyperlink_rules")] pub hyperlink_rules: Vec, @@ -756,6 +764,15 @@ impl Config { Ok(()) } + pub fn initial_size(&self) -> PtySize { + PtySize { + rows: self.initial_rows, + cols: self.initial_cols, + pixel_width: 0, + pixel_height: 0, + } + } + pub fn build_prog(&self, prog: Option>) -> Result { let mut cmd = match prog { Some(args) => { @@ -808,6 +825,14 @@ fn default_scrollback_lines() -> usize { 3500 } +fn default_initial_rows() -> u16 { + 24 +} + +fn default_initial_cols() -> u16 { + 80 +} + fn default_hyperlink_rules() -> Vec { vec![ // URL with a protocol diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index 57126f5dc..e6e2d143f 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -1224,11 +1224,12 @@ impl TermWindow { pub fn spawn_new_window(&mut self) { async fn new_window() -> anyhow::Result<()> { let mux = Mux::get().unwrap(); + let config = crate::config::configuration(); let fonts = Rc::new(FontConfiguration::new()); let window_id = mux.new_empty_window(); let tab = mux .default_domain() - .spawn(PtySize::default(), None, None, window_id) + .spawn(config.initial_size(), None, None, window_id) .await?; let front_end = front_end().expect("to be called on gui thread"); front_end.spawn_new_window(&fonts, &tab, window_id)?; diff --git a/src/main.rs b/src/main.rs index 2e0d6beff..581c60a3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,6 @@ use crate::mux::Mux; use crate::server::client::{unix_connect_with_retry, Client}; use crate::server::domain::{ClientDomain, ClientDomainConfig}; use portable_pty::cmdbuilder::CommandBuilder; -use portable_pty::PtySize; mod font; use crate::font::locator::FontLocatorSelection; @@ -366,7 +365,7 @@ async fn async_run_ssh(opts: SshCommand, params: SshParameters) -> anyhow::Resul let window_id = mux.new_empty_window(); let tab = domain - .spawn(PtySize::default(), cmd, None, window_id) + .spawn(config.initial_size(), cmd, None, window_id) .await?; let fontconfig = Rc::new(FontConfiguration::new()); gui.spawn_new_window(&fontconfig, &tab, window_id)?; @@ -424,7 +423,7 @@ fn run_serial(config: config::ConfigHandle, opts: &SerialCommand) -> anyhow::Res block_on(domain.attach())?; // FIXME: blocking let window_id = mux.new_empty_window(); - let tab = block_on(domain.spawn(PtySize::default(), None, None, window_id))?; // FIXME: blocking + let tab = block_on(domain.spawn(config.initial_size(), None, None, window_id))?; // FIXME: blocking gui.spawn_new_window(&fontconfig, &tab, window_id)?; maybe_show_configuration_error_window(); @@ -499,10 +498,11 @@ async fn spawn_tab_in_default_domain_if_mux_is_empty( return Ok(()); } + let config = config::configuration(); let window_id = mux.new_empty_window(); let tab = mux .default_domain() - .spawn(PtySize::default(), cmd, None, window_id) + .spawn(config.initial_size(), cmd, None, window_id) .await?; let fontconfig = Rc::new(FontConfiguration::new()); front_end()