|
|
|
@ -23,11 +23,12 @@ use std::fs::OpenOptions; |
|
|
|
|
use std::io::{Read, Write}; |
|
|
|
|
use std::path::Path; |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)] |
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)] |
|
|
|
|
pub struct Config { |
|
|
|
|
menu: Option<Menu>, |
|
|
|
|
format: Option<Format>, |
|
|
|
|
layout: Option<Layout>, |
|
|
|
|
sequence: Option<Sequence>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn tilde_expand_file_names(file_names: Vec<String>) -> Vec<String> { |
|
|
|
@ -159,15 +160,23 @@ impl Config { |
|
|
|
|
.or_else(|| Layout::default().auto_tile_min_window_width_per_output_width_as_map()) |
|
|
|
|
.expect("No layout.auto_tile_min_window_width_per_output_width defined.") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn get_sequence_timeout(&self) -> u64 { |
|
|
|
|
self.sequence |
|
|
|
|
.as_ref() |
|
|
|
|
.and_then(|s| s.timeout) |
|
|
|
|
.or_else(|| Sequence::default().timeout) |
|
|
|
|
.expect("No sequence.timeout defined") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)] |
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)] |
|
|
|
|
pub struct Menu { |
|
|
|
|
executable: Option<String>, |
|
|
|
|
args: Option<Vec<String>>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)] |
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)] |
|
|
|
|
pub struct Format { |
|
|
|
|
output_format: Option<String>, |
|
|
|
|
workspace_format: Option<String>, |
|
|
|
@ -181,12 +190,17 @@ pub struct Format { |
|
|
|
|
fallback_icon: Option<String>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)] |
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)] |
|
|
|
|
pub struct Layout { |
|
|
|
|
auto_tile: Option<bool>, |
|
|
|
|
auto_tile_min_window_width_per_output_width: Option<Vec<[i32; 2]>>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)] |
|
|
|
|
pub struct Sequence { |
|
|
|
|
timeout: Option<u64>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl Layout { |
|
|
|
|
pub fn auto_tile_min_window_width_per_output_width_as_map( |
|
|
|
|
&self, |
|
|
|
@ -294,12 +308,19 @@ impl Default for Layout { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl Default for Sequence { |
|
|
|
|
fn default() -> Self { |
|
|
|
|
Sequence { timeout: Some(0) } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl Default for Config { |
|
|
|
|
fn default() -> Self { |
|
|
|
|
Config { |
|
|
|
|
menu: Some(Menu::default()), |
|
|
|
|
format: Some(Format::default()), |
|
|
|
|
layout: Some(Layout::default()), |
|
|
|
|
sequence: Some(Sequence::default()), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|