Commit 3b46859e authored by Joe Moon's avatar Joe Moon Committed by Joe Wilm

Improve window.decorations options: (#1241)

The decorations config was changed from a bool to an enum.
`full` has taken the place of `true`, and `none`, has replaced `false`.

On macOS, there are now options for `transparent` and `buttonless`.
These options are explained in both the CHANGELOG and in the
configuration files.
parent 641f3291
......@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Implement the `hidden` escape sequence (`echo -e "\e[8mTEST"`)
- Add support for macOS systemwide dark mode
- Set the environment variable `COLORTERM="truecolor"` to advertise 24-bit color support
- On macOS, there are two new values for the config option `window.decorations`:
- `transparent` - This makes the title bar transparent and allows the
viewport to extend to the top of the window.
- `buttonless` - Similar to transparent but also removed the buttons.
### Changed
......@@ -23,6 +27,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Windows started as unfocused now show the hollow cursor if the setting is enabled
- Bracketed paste mode now filters escape sequences beginning with \x1b
### Deprecated
- The config option `window.decorations` should now use `full` or `none` instead
of `true` or `false`, respectively.
## Version 0.2.0
### Added
......
......@@ -30,8 +30,10 @@ window:
y: 2
# Window decorations
# Setting this to false will result in window without borders and title bar.
decorations: true
# Available values:
# - `full`: Window with borders and title bar.
# - `none`: Window without borders or title bar.
decorations: full
scrolling:
# How many lines of scrollback to keep,
......
......@@ -28,8 +28,14 @@ window:
y: 2
# Window decorations
# Setting this to false will result in window without borders and title bar.
decorations: true
# Available values:
# - `full`: Window with title bar and title bar buttons
# - `none`: Window without title bar, rounded corners, or drop shadow
# - `transparent`: Window with title bar with transparent background and title
# bar buttons
# - `buttonless`: Window with title bar with transparent background and no
# title bar buttons
decorations: full
scrolling:
# How many lines of scrollback to keep,
......
......@@ -248,6 +248,89 @@ impl Default for Alpha {
}
}
#[derive(Debug, Copy, Clone)]
pub enum Decorations {
Full,
Transparent,
Buttonless,
None,
}
impl Default for Decorations {
fn default() -> Decorations {
Decorations::Full
}
}
impl<'de> Deserialize<'de> for Decorations {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Decorations, D::Error>
where D: de::Deserializer<'de>
{
struct DecorationsVisitor;
impl<'de> Visitor<'de> for DecorationsVisitor {
type Value = Decorations;
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Some subset of full|transparent|buttonless|none")
}
fn visit_bool<E>(self, value: bool) -> ::std::result::Result<Decorations, E>
where E: de::Error
{
if value {
eprintln!("deprecated decorations boolean value, use one of default|transparent|buttonless|none instead; Falling back to \"full\"");
Ok(Decorations::Full)
} else {
eprintln!("deprecated decorations boolean value, use one of default|transparent|buttonless|none instead; Falling back to \"none\"");
Ok(Decorations::None)
}
}
#[cfg(target_os = "macos")]
fn visit_str<E>(self, value: &str) -> ::std::result::Result<Decorations, E>
where E: de::Error
{
match value {
"transparent" => Ok(Decorations::Transparent),
"buttonless" => Ok(Decorations::Buttonless),
"none" => Ok(Decorations::None),
"full" => Ok(Decorations::Full),
_ => {
eprintln!("invalid decorations value: {}; Using default value", value);
Ok(Decorations::Full)
}
}
}
#[cfg(not(target_os = "macos"))]
fn visit_str<E>(self, value: &str) -> ::std::result::Result<Decorations, E>
where E: de::Error
{
match value {
"none" => Ok(Decorations::None),
"full" => Ok(Decorations::Full),
"transparent" => {
eprintln!("macos-only decorations value: {}; Using default value", value);
Ok(Decorations::Full)
},
"buttonless" => {
eprintln!("macos-only decorations value: {}; Using default value", value);
Ok(Decorations::Full)
}
_ => {
eprintln!("invalid decorations value: {}; Using default value", value);
Ok(Decorations::Full)
}
}
}
}
deserializer.deserialize_str(DecorationsVisitor)
}
}
#[derive(Debug, Copy, Clone, Deserialize)]
pub struct WindowConfig {
/// Initial dimensions
......@@ -259,8 +342,7 @@ pub struct WindowConfig {
padding: Delta<u8>,
/// Draw the window with title bar / borders
#[serde(default, deserialize_with = "failure_default")]
decorations: bool,
decorations: Decorations,
}
fn default_padding() -> Delta<u8> {
......@@ -280,7 +362,7 @@ fn deserialize_padding<'a, D>(deserializer: D) -> ::std::result::Result<Delta<u8
}
impl WindowConfig {
pub fn decorations(&self) -> bool {
pub fn decorations(&self) -> Decorations {
self.decorations
}
}
......@@ -290,7 +372,7 @@ impl Default for WindowConfig {
WindowConfig{
dimensions: Default::default(),
padding: default_padding(),
decorations: true,
decorations: Default::default(),
}
}
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment