1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-30 06:03:39 +03:00

move some config defaults into the config module

This commit is contained in:
Wez Furlong 2019-11-24 06:56:41 -08:00
parent e904e11e58
commit 385b3bedbd
3 changed files with 22 additions and 15 deletions

View File

@ -100,8 +100,9 @@ pub struct Config {
/// This acts as a brake in the case of a command spewing a
/// ton of output and allows for the UI to remain responsive
/// so that you can hit CTRL-C to interrupt it if desired.
/// The default value is 2MB/s.
pub ratelimit_output_bytes_per_second: Option<u32>,
/// The default value is 200K/s.
#[serde(default = "default_ratelimit_output_bytes_per_second")]
pub ratelimit_output_bytes_per_second: u32,
/// Constrains the rate at which the multiplexer server will
/// unilaterally push data to the client.
@ -113,12 +114,14 @@ pub struct Config {
/// the result to the client.
/// That decision is throttled by this configuration value
/// which has a default value of 10/s
pub ratelimit_mux_output_pushes_per_second: Option<u32>,
#[serde(default = "default_ratelimit_mux_output_pushes_per_second")]
pub ratelimit_mux_output_pushes_per_second: u32,
/// Constrain how often the mux server scans the terminal
/// model to compute a diff to send to the mux client.
/// The default value is 100/s
pub ratelimit_mux_output_scans_per_second: Option<u32>,
#[serde(default = "default_ratelimit_mux_output_scans_per_second")]
pub ratelimit_mux_output_scans_per_second: u32,
#[serde(default)]
pub keys: Vec<Key>,
@ -147,6 +150,18 @@ pub struct Config {
pub enable_tab_bar: bool,
}
fn default_ratelimit_mux_output_scans_per_second() -> u32 {
100
}
fn default_ratelimit_mux_output_pushes_per_second() -> u32 {
10
}
fn default_ratelimit_output_bytes_per_second() -> u32 {
200_000
}
fn default_true() -> bool {
true
}

View File

@ -49,7 +49,7 @@ fn read_from_tab_pty(config: Arc<Config>, tab_id: TabId, mut reader: Box<dyn std
const BUFSIZE: usize = 32 * 1024;
let mut buf = [0; BUFSIZE];
let mut lim = RateLimiter::new(config.ratelimit_output_bytes_per_second.unwrap_or(200_000));
let mut lim = RateLimiter::new(config.ratelimit_output_bytes_per_second);
loop {
match reader.read(&mut buf) {

View File

@ -429,16 +429,8 @@ struct ClientSurfaceState {
impl ClientSurfaceState {
fn new(cols: usize, rows: usize) -> Self {
let mux = Mux::get().expect("to be running on gui thread");
let push_limiter = RateLimiter::new(
mux.config()
.ratelimit_mux_output_pushes_per_second
.unwrap_or(10),
);
let update_limiter = RateLimiter::new(
mux.config()
.ratelimit_mux_output_scans_per_second
.unwrap_or(100),
);
let push_limiter = RateLimiter::new(mux.config().ratelimit_mux_output_pushes_per_second);
let update_limiter = RateLimiter::new(mux.config().ratelimit_mux_output_scans_per_second);
let surface = Surface::new(cols, rows);
Self {
surface,