summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-12-31 05:52:45 +0000
committerGitHub <noreply@github.com>2020-12-31 05:52:45 +0000
commit1723e30d25f0c6068f9532448b016a89aa491a95 (patch)
tree543790b11a4fdc3c82f7f0b0ebc1cbc79d1c2009
parent0aa1df327bf5c3e7892ad13d949be7e598aafda9 (diff)
downloadalacritty-1723e30d25f0c6068f9532448b016a89aa491a95.tar.gz
alacritty-1723e30d25f0c6068f9532448b016a89aa491a95.zip
Use ConfigDeserialize for all config enums
This fixes up all of the remaining enums which are used in the configuration file to make sure they all support fully case insensitive deserialization. Fixes #4611.
-rw-r--r--alacritty/src/config/bindings.rs2
-rw-r--r--alacritty_terminal/src/ansi.rs14
-rw-r--r--alacritty_terminal/src/config/colors.rs17
-rw-r--r--alacritty_terminal/src/grid/mod.rs2
-rw-r--r--alacritty_terminal/src/grid/row.rs2
-rw-r--r--alacritty_terminal/src/grid/storage.rs2
-rw-r--r--alacritty_terminal/src/index.rs6
-rw-r--r--alacritty_terminal/src/vi_mode.rs4
8 files changed, 33 insertions, 16 deletions
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs
index 50923a37..383a057e 100644
--- a/alacritty/src/config/bindings.rs
+++ b/alacritty/src/config/bindings.rs
@@ -252,7 +252,7 @@ pub enum ViAction {
}
/// Search mode specific actions.
-#[derive(Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
+#[derive(ConfigDeserialize, Debug, Copy, Clone, PartialEq, Eq)]
pub enum SearchAction {
/// Move the focus to the next search match.
SearchFocusNext,
diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs
index 21f0ec45..2bd445ea 100644
--- a/alacritty_terminal/src/ansi.rs
+++ b/alacritty_terminal/src/ansi.rs
@@ -7,6 +7,8 @@ use log::{debug, trace};
use serde::{Deserialize, Serialize};
use vte::{Params, ParamsIter};
+use alacritty_config_derive::ConfigDeserialize;
+
use crate::index::{Column, Line};
use crate::term::color::Rgb;
@@ -332,14 +334,14 @@ pub trait Handler {
}
/// Terminal cursor configuration.
-#[derive(Deserialize, Default, Debug, Eq, PartialEq, Copy, Clone, Hash)]
+#[derive(ConfigDeserialize, Default, Debug, Eq, PartialEq, Copy, Clone, Hash)]
pub struct CursorStyle {
pub shape: CursorShape,
pub blinking: bool,
}
/// Terminal cursor shape.
-#[derive(Deserialize, Debug, Eq, PartialEq, Copy, Clone, Hash)]
+#[derive(ConfigDeserialize, Debug, Eq, PartialEq, Copy, Clone, Hash)]
pub enum CursorShape {
/// Cursor is a block like `▒`.
Block,
@@ -351,11 +353,11 @@ pub enum CursorShape {
Beam,
/// Cursor is a box like `☐`.
- #[serde(skip)]
+ #[config(skip)]
HollowBlock,
/// Invisible cursor.
- #[serde(skip)]
+ #[config(skip)]
Hidden,
}
@@ -509,7 +511,7 @@ pub enum TabulationClearMode {
///
/// The order here matters since the enum should be castable to a `usize` for
/// indexing a color list.
-#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord)]
pub enum NamedColor {
/// Black.
Black = 0,
@@ -621,7 +623,7 @@ impl NamedColor {
}
}
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
pub enum Color {
Named(NamedColor),
Spec(Rgb),
diff --git a/alacritty_terminal/src/config/colors.rs b/alacritty_terminal/src/config/colors.rs
index df52f19f..f295da1c 100644
--- a/alacritty_terminal/src/config/colors.rs
+++ b/alacritty_terminal/src/config/colors.rs
@@ -178,7 +178,7 @@ impl Default for BrightColors {
}
}
-#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
+#[derive(ConfigDeserialize, Clone, Debug, PartialEq, Eq)]
pub struct DimColors {
pub black: Rgb,
pub red: Rgb,
@@ -189,3 +189,18 @@ pub struct DimColors {
pub cyan: Rgb,
pub white: Rgb,
}
+
+impl Default for DimColors {
+ fn default() -> Self {
+ DimColors {
+ black: Rgb { r: 0x13, g: 0x14, b: 0x15 },
+ red: Rgb { r: 0x86, g: 0x43, b: 0x43 },
+ green: Rgb { r: 0x77, g: 0x7c, b: 0x44 },
+ yellow: Rgb { r: 0x9e, g: 0x82, b: 0x4c },
+ blue: Rgb { r: 0x55, g: 0x6a, b: 0x7d },
+ magenta: Rgb { r: 0x75, g: 0x61, b: 0x7b },
+ cyan: Rgb { r: 0x5b, g: 0x7d, b: 0x78 },
+ white: Rgb { r: 0x82, g: 0x84, b: 0x82 },
+ }
+ }
+}
diff --git a/alacritty_terminal/src/grid/mod.rs b/alacritty_terminal/src/grid/mod.rs
index 1c23bfc8..4b3c86dc 100644
--- a/alacritty_terminal/src/grid/mod.rs
+++ b/alacritty_terminal/src/grid/mod.rs
@@ -126,7 +126,7 @@ impl IndexMut<CharsetIndex> for Charsets {
/// ^
/// cols
/// ```
-#[derive(Clone, Debug, Deserialize, Serialize)]
+#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Grid<T> {
/// Current cursor for writing data.
#[serde(skip)]
diff --git a/alacritty_terminal/src/grid/row.rs b/alacritty_terminal/src/grid/row.rs
index 5b1be31c..e48103a6 100644
--- a/alacritty_terminal/src/grid/row.rs
+++ b/alacritty_terminal/src/grid/row.rs
@@ -13,7 +13,7 @@ use crate::index::Column;
use crate::term::cell::ResetDiscriminant;
/// A row in the grid.
-#[derive(Default, Clone, Debug, Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Default, Clone, Debug)]
pub struct Row<T> {
inner: Vec<T>,
diff --git a/alacritty_terminal/src/grid/storage.rs b/alacritty_terminal/src/grid/storage.rs
index 96c578b3..a7d4adcf 100644
--- a/alacritty_terminal/src/grid/storage.rs
+++ b/alacritty_terminal/src/grid/storage.rs
@@ -26,7 +26,7 @@ const MAX_CACHE_SIZE: usize = 1_000;
/// [`slice::rotate_left`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rotate_left
/// [`Deref`]: std::ops::Deref
/// [`zero`]: #structfield.zero
-#[derive(Deserialize, Serialize, Clone, Debug)]
+#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Storage<T> {
inner: Vec<Row<T>>,
diff --git a/alacritty_terminal/src/index.rs b/alacritty_terminal/src/index.rs
index 8b84b7f5..4b0d6943 100644
--- a/alacritty_terminal/src/index.rs
+++ b/alacritty_terminal/src/index.rs
@@ -45,7 +45,7 @@ pub enum Boundary {
}
/// Index in the grid using row, column notation.
-#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default, Eq, PartialEq)]
pub struct Point<L = Line> {
pub line: L,
pub col: Column,
@@ -199,7 +199,7 @@ impl From<&RenderableCell> for Point<Line> {
/// A line.
///
/// Newtype to avoid passing values incorrectly.
-#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd)]
pub struct Line(pub usize);
impl fmt::Display for Line {
@@ -211,7 +211,7 @@ impl fmt::Display for Line {
/// A column.
///
/// Newtype to avoid passing values incorrectly.
-#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd)]
pub struct Column(pub usize);
impl fmt::Display for Column {
diff --git a/alacritty_terminal/src/vi_mode.rs b/alacritty_terminal/src/vi_mode.rs
index f6e93fd9..46439a75 100644
--- a/alacritty_terminal/src/vi_mode.rs
+++ b/alacritty_terminal/src/vi_mode.rs
@@ -1,6 +1,6 @@
use std::cmp::{max, min};
-use serde::Deserialize;
+use alacritty_config_derive::ConfigDeserialize;
use crate::event::EventListener;
use crate::grid::{Dimensions, GridCell};
@@ -9,7 +9,7 @@ use crate::term::cell::Flags;
use crate::term::Term;
/// Possible vi mode motion movements.
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
+#[derive(ConfigDeserialize, Debug, Copy, Clone, PartialEq, Eq)]
pub enum ViMotion {
/// Move up.
Up,