aboutsummaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authoracheronfail <acheronfail@gmail.com>2019-04-24 05:05:47 +1000
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-04-23 19:05:47 +0000
commite9813031f6e308984cb5547aa1049839cb75745f (patch)
treec8e6286c98f4f42b6e170e477baa6b1f949b83ef /src/config
parentb0efa9d105b53211d8df094238c7eb8324e93566 (diff)
downloadr-alacritty-e9813031f6e308984cb5547aa1049839cb75745f.tar.gz
r-alacritty-e9813031f6e308984cb5547aa1049839cb75745f.tar.bz2
r-alacritty-e9813031f6e308984cb5547aa1049839cb75745f.zip
Add fullscreen support
Fixes #34. Fixes #2012.
Diffstat (limited to 'src/config')
-rw-r--r--src/config/bindings.rs18
-rw-r--r--src/config/mod.rs45
2 files changed, 57 insertions, 6 deletions
diff --git a/src/config/bindings.rs b/src/config/bindings.rs
index 0e00f6fe..7e69182b 100644
--- a/src/config/bindings.rs
+++ b/src/config/bindings.rs
@@ -178,7 +178,7 @@ pub fn default_key_bindings() -> Vec<KeyBinding> {
}
#[cfg(not(any(target_os = "macos", test)))]
-pub fn platform_key_bindings() -> Vec<KeyBinding> {
+fn common_keybindings() -> Vec<KeyBinding> {
bindings!(
KeyBinding;
Key::V, [ctrl: true, shift: true]; Action::Paste;
@@ -192,6 +192,21 @@ pub fn platform_key_bindings() -> Vec<KeyBinding> {
)
}
+#[cfg(not(any(target_os = "macos", target_os = "windows", test)))]
+pub fn platform_key_bindings() -> Vec<KeyBinding> {
+ common_keybindings()
+}
+
+#[cfg(all(target_os = "windows", not(test)))]
+pub fn platform_key_bindings() -> Vec<KeyBinding> {
+ let mut bindings = bindings!(
+ KeyBinding;
+ Key::Return, [alt: true]; Action::ToggleFullscreen;
+ );
+ bindings.extend(common_keybindings());
+ bindings
+}
+
#[cfg(all(target_os = "macos", not(test)))]
pub fn platform_key_bindings() -> Vec<KeyBinding> {
bindings!(
@@ -200,6 +215,7 @@ pub fn platform_key_bindings() -> Vec<KeyBinding> {
Key::Equals, [logo: true]; Action::IncreaseFontSize;
Key::Add, [logo: true]; Action::IncreaseFontSize;
Key::Minus, [logo: true]; Action::DecreaseFontSize;
+ Key::F, [ctrl: true, logo: true]; Action::ToggleFullscreen;
Key::K, [logo: true]; Action::ClearHistory;
Key::K, [logo: true]; Action::Esc("\x0c".into());
Key::V, [logo: true]; Action::Paste;
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 67431e68..4d6026ca 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -318,6 +318,21 @@ impl Default for Alpha {
}
}
+#[derive(Debug, Deserialize, Copy, Clone, PartialEq, Eq)]
+pub enum StartupMode {
+ Windowed,
+ Maximized,
+ Fullscreen,
+ #[cfg(target_os = "macos")]
+ SimpleFullscreen,
+}
+
+impl Default for StartupMode {
+ fn default() -> StartupMode {
+ StartupMode::Windowed
+ }
+}
+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Decorations {
Full,
@@ -438,9 +453,13 @@ pub struct WindowConfig {
#[serde(deserialize_with = "failure_default")]
dynamic_padding: bool,
- /// Start maximized
+ /// Startup mode
+ #[serde(deserialize_with = "failure_default")]
+ startup_mode: StartupMode,
+
+ /// TODO: DEPRECATED
#[serde(deserialize_with = "failure_default")]
- start_maximized: bool,
+ start_maximized: Option<bool>,
}
impl Default for WindowConfig {
@@ -452,6 +471,7 @@ impl Default for WindowConfig {
decorations: Default::default(),
dynamic_padding: Default::default(),
start_maximized: Default::default(),
+ startup_mode: Default::default(),
}
}
}
@@ -482,8 +502,8 @@ impl WindowConfig {
self.dynamic_padding
}
- pub fn start_maximized(&self) -> bool {
- self.start_maximized
+ pub fn startup_mode(&self) -> StartupMode {
+ self.startup_mode
}
pub fn position(&self) -> Option<Delta<i32>> {
@@ -874,7 +894,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
"Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \
ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollLineUp, ScrollLineDown, \
ScrollToTop, ScrollToBottom, ClearHistory, Hide, ClearLogNotice, \
- SpawnNewInstance, None or Quit",
+ SpawnNewInstance, ToggleFullscreen, ToggleSimpleFullscreen, None or Quit",
)
}
@@ -900,6 +920,9 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
"Quit" => Action::Quit,
"ClearLogNotice" => Action::ClearLogNotice,
"SpawnNewInstance" => Action::SpawnNewInstance,
+ "ToggleFullscreen" => Action::ToggleFullscreen,
+ #[cfg(target_os = "macos")]
+ "ToggleSimpleFullscreen" => Action::ToggleSimpleFullscreen,
"None" => Action::None,
_ => return Err(E::invalid_value(Unexpected::Str(value), &self)),
}))
@@ -1992,6 +2015,18 @@ impl Config {
instead"
);
}
+
+ if let Some(start_maximized) = self.window.start_maximized {
+ warn!(
+ "Config window.start_maximized is deprecated; please use window.startup_mode \
+ instead"
+ );
+
+ // While `start_maximized` is deprecated its setting takes precedence.
+ if start_maximized {
+ self.window.startup_mode = StartupMode::Maximized;
+ }
+ }
}
}