Skip to content

Commit 1723e30

Browse files
authored
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 alacritty#4611.
1 parent 0aa1df3 commit 1723e30

File tree

8 files changed

+33
-16
lines changed

8 files changed

+33
-16
lines changed

Diff for: alacritty/src/config/bindings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ pub enum ViAction {
252252
}
253253

254254
/// Search mode specific actions.
255-
#[derive(Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
255+
#[derive(ConfigDeserialize, Debug, Copy, Clone, PartialEq, Eq)]
256256
pub enum SearchAction {
257257
/// Move the focus to the next search match.
258258
SearchFocusNext,

Diff for: alacritty_terminal/src/ansi.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use log::{debug, trace};
77
use serde::{Deserialize, Serialize};
88
use vte::{Params, ParamsIter};
99

10+
use alacritty_config_derive::ConfigDeserialize;
11+
1012
use crate::index::{Column, Line};
1113
use crate::term::color::Rgb;
1214

@@ -332,14 +334,14 @@ pub trait Handler {
332334
}
333335

334336
/// Terminal cursor configuration.
335-
#[derive(Deserialize, Default, Debug, Eq, PartialEq, Copy, Clone, Hash)]
337+
#[derive(ConfigDeserialize, Default, Debug, Eq, PartialEq, Copy, Clone, Hash)]
336338
pub struct CursorStyle {
337339
pub shape: CursorShape,
338340
pub blinking: bool,
339341
}
340342

341343
/// Terminal cursor shape.
342-
#[derive(Deserialize, Debug, Eq, PartialEq, Copy, Clone, Hash)]
344+
#[derive(ConfigDeserialize, Debug, Eq, PartialEq, Copy, Clone, Hash)]
343345
pub enum CursorShape {
344346
/// Cursor is a block like `▒`.
345347
Block,
@@ -351,11 +353,11 @@ pub enum CursorShape {
351353
Beam,
352354

353355
/// Cursor is a box like `☐`.
354-
#[serde(skip)]
356+
#[config(skip)]
355357
HollowBlock,
356358

357359
/// Invisible cursor.
358-
#[serde(skip)]
360+
#[config(skip)]
359361
Hidden,
360362
}
361363

@@ -509,7 +511,7 @@ pub enum TabulationClearMode {
509511
///
510512
/// The order here matters since the enum should be castable to a `usize` for
511513
/// indexing a color list.
512-
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
514+
#[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord)]
513515
pub enum NamedColor {
514516
/// Black.
515517
Black = 0,
@@ -621,7 +623,7 @@ impl NamedColor {
621623
}
622624
}
623625

624-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
626+
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
625627
pub enum Color {
626628
Named(NamedColor),
627629
Spec(Rgb),

Diff for: alacritty_terminal/src/config/colors.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl Default for BrightColors {
178178
}
179179
}
180180

181-
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
181+
#[derive(ConfigDeserialize, Clone, Debug, PartialEq, Eq)]
182182
pub struct DimColors {
183183
pub black: Rgb,
184184
pub red: Rgb,
@@ -189,3 +189,18 @@ pub struct DimColors {
189189
pub cyan: Rgb,
190190
pub white: Rgb,
191191
}
192+
193+
impl Default for DimColors {
194+
fn default() -> Self {
195+
DimColors {
196+
black: Rgb { r: 0x13, g: 0x14, b: 0x15 },
197+
red: Rgb { r: 0x86, g: 0x43, b: 0x43 },
198+
green: Rgb { r: 0x77, g: 0x7c, b: 0x44 },
199+
yellow: Rgb { r: 0x9e, g: 0x82, b: 0x4c },
200+
blue: Rgb { r: 0x55, g: 0x6a, b: 0x7d },
201+
magenta: Rgb { r: 0x75, g: 0x61, b: 0x7b },
202+
cyan: Rgb { r: 0x5b, g: 0x7d, b: 0x78 },
203+
white: Rgb { r: 0x82, g: 0x84, b: 0x82 },
204+
}
205+
}
206+
}

Diff for: alacritty_terminal/src/grid/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl IndexMut<CharsetIndex> for Charsets {
126126
/// ^
127127
/// cols
128128
/// ```
129-
#[derive(Clone, Debug, Deserialize, Serialize)]
129+
#[derive(Serialize, Deserialize, Clone, Debug)]
130130
pub struct Grid<T> {
131131
/// Current cursor for writing data.
132132
#[serde(skip)]

Diff for: alacritty_terminal/src/grid/row.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::index::Column;
1313
use crate::term::cell::ResetDiscriminant;
1414

1515
/// A row in the grid.
16-
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
16+
#[derive(Serialize, Deserialize, Default, Clone, Debug)]
1717
pub struct Row<T> {
1818
inner: Vec<T>,
1919

Diff for: alacritty_terminal/src/grid/storage.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const MAX_CACHE_SIZE: usize = 1_000;
2626
/// [`slice::rotate_left`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rotate_left
2727
/// [`Deref`]: std::ops::Deref
2828
/// [`zero`]: #structfield.zero
29-
#[derive(Deserialize, Serialize, Clone, Debug)]
29+
#[derive(Serialize, Deserialize, Clone, Debug)]
3030
pub struct Storage<T> {
3131
inner: Vec<Row<T>>,
3232

Diff for: alacritty_terminal/src/index.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum Boundary {
4545
}
4646

4747
/// Index in the grid using row, column notation.
48-
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize)]
48+
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default, Eq, PartialEq)]
4949
pub struct Point<L = Line> {
5050
pub line: L,
5151
pub col: Column,
@@ -199,7 +199,7 @@ impl From<&RenderableCell> for Point<Line> {
199199
/// A line.
200200
///
201201
/// Newtype to avoid passing values incorrectly.
202-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Serialize, Deserialize)]
202+
#[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd)]
203203
pub struct Line(pub usize);
204204

205205
impl fmt::Display for Line {
@@ -211,7 +211,7 @@ impl fmt::Display for Line {
211211
/// A column.
212212
///
213213
/// Newtype to avoid passing values incorrectly.
214-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd, Serialize, Deserialize)]
214+
#[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, Default, Ord, PartialOrd)]
215215
pub struct Column(pub usize);
216216

217217
impl fmt::Display for Column {

Diff for: alacritty_terminal/src/vi_mode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::cmp::{max, min};
22

3-
use serde::Deserialize;
3+
use alacritty_config_derive::ConfigDeserialize;
44

55
use crate::event::EventListener;
66
use crate::grid::{Dimensions, GridCell};
@@ -9,7 +9,7 @@ use crate::term::cell::Flags;
99
use crate::term::Term;
1010

1111
/// Possible vi mode motion movements.
12-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
12+
#[derive(ConfigDeserialize, Debug, Copy, Clone, PartialEq, Eq)]
1313
pub enum ViMotion {
1414
/// Move up.
1515
Up,

0 commit comments

Comments
 (0)