Merge branch 'main' into window_context_2
This commit is contained in:
commit
c76b9794e4
45 changed files with 1760 additions and 882 deletions
|
@ -252,6 +252,7 @@ pub struct TerminalSettings {
|
|||
pub working_directory: Option<WorkingDirectory>,
|
||||
pub font_size: Option<f32>,
|
||||
pub font_family: Option<String>,
|
||||
pub line_height: Option<TerminalLineHeight>,
|
||||
pub font_features: Option<fonts::Features>,
|
||||
pub env: Option<HashMap<String, String>>,
|
||||
pub blinking: Option<TerminalBlink>,
|
||||
|
@ -260,6 +261,25 @@ pub struct TerminalSettings {
|
|||
pub copy_on_select: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, Default)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum TerminalLineHeight {
|
||||
#[default]
|
||||
Comfortable,
|
||||
Standard,
|
||||
Custom(f32),
|
||||
}
|
||||
|
||||
impl TerminalLineHeight {
|
||||
fn value(&self) -> f32 {
|
||||
match self {
|
||||
TerminalLineHeight::Comfortable => 1.618,
|
||||
TerminalLineHeight::Standard => 1.3,
|
||||
TerminalLineHeight::Custom(line_height) => *line_height,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum TerminalBlink {
|
||||
|
@ -316,6 +336,14 @@ impl Default for WorkingDirectory {
|
|||
}
|
||||
}
|
||||
|
||||
impl TerminalSettings {
|
||||
fn line_height(&self) -> Option<f32> {
|
||||
self.line_height
|
||||
.to_owned()
|
||||
.map(|line_height| line_height.value())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone, Hash, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum DockAnchor {
|
||||
|
@ -640,16 +668,6 @@ impl Settings {
|
|||
})
|
||||
}
|
||||
|
||||
fn terminal_setting<F, R: Default + Clone>(&self, f: F) -> R
|
||||
where
|
||||
F: Fn(&TerminalSettings) -> Option<&R>,
|
||||
{
|
||||
f(&self.terminal_overrides)
|
||||
.or_else(|| f(&self.terminal_defaults))
|
||||
.cloned()
|
||||
.unwrap_or_else(|| R::default())
|
||||
}
|
||||
|
||||
pub fn telemetry(&self) -> TelemetrySettings {
|
||||
TelemetrySettings {
|
||||
diagnostics: Some(self.telemetry_diagnostics()),
|
||||
|
@ -671,20 +689,33 @@ impl Settings {
|
|||
.expect("missing default")
|
||||
}
|
||||
|
||||
fn terminal_setting<F, R>(&self, f: F) -> R
|
||||
where
|
||||
F: Fn(&TerminalSettings) -> Option<R>,
|
||||
{
|
||||
None.or_else(|| f(&self.terminal_overrides))
|
||||
.or_else(|| f(&self.terminal_defaults))
|
||||
.expect("missing default")
|
||||
}
|
||||
|
||||
pub fn terminal_line_height(&self) -> f32 {
|
||||
self.terminal_setting(|terminal_setting| terminal_setting.line_height())
|
||||
}
|
||||
|
||||
pub fn terminal_scroll(&self) -> AlternateScroll {
|
||||
self.terminal_setting(|terminal_setting| terminal_setting.alternate_scroll.as_ref())
|
||||
self.terminal_setting(|terminal_setting| terminal_setting.alternate_scroll.to_owned())
|
||||
}
|
||||
|
||||
pub fn terminal_shell(&self) -> Shell {
|
||||
self.terminal_setting(|terminal_setting| terminal_setting.shell.as_ref())
|
||||
self.terminal_setting(|terminal_setting| terminal_setting.shell.to_owned())
|
||||
}
|
||||
|
||||
pub fn terminal_env(&self) -> HashMap<String, String> {
|
||||
self.terminal_setting(|terminal_setting| terminal_setting.env.as_ref())
|
||||
self.terminal_setting(|terminal_setting| terminal_setting.env.to_owned())
|
||||
}
|
||||
|
||||
pub fn terminal_strategy(&self) -> WorkingDirectory {
|
||||
self.terminal_setting(|terminal_setting| terminal_setting.working_directory.as_ref())
|
||||
self.terminal_setting(|terminal_setting| terminal_setting.working_directory.to_owned())
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue