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

Added initial_rows, initial_cols configuration

Allows specifying the size of new windows.

Refs: https://github.com/wez/wezterm/issues/142
This commit is contained in:
Wez Furlong 2020-02-07 21:42:26 -08:00
parent 8f3a233773
commit 7d94aaa475
4 changed files with 34 additions and 7 deletions

View File

@ -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

View File

@ -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<Vec<String>>,
/// 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<hyperlink::Rule>,
@ -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<Vec<&OsStr>>) -> Result<CommandBuilder, Error> {
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<hyperlink::Rule> {
vec![
// URL with a protocol

View File

@ -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)?;

View File

@ -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()