From aae283aebe7343be9106b49b445be3b85d26df42 Mon Sep 17 00:00:00 2001 From: myypo Date: Sat, 17 Aug 2024 23:22:46 +0300 Subject: [PATCH] feat(marks): update the default sign to indicate mark time type --- README.md | 9 +++++---- compass/src/config/common/sign.rs | 12 ++++++------ compass/src/config/marks/signs.rs | 29 ++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index cab483f..13f5670 100644 --- a/README.md +++ b/README.md @@ -112,11 +112,12 @@ Default configuration: }, -- Which signs to use for different mark types relatively to the current position + -- You can find more Unicode options online, and, if using a patched nerdfont, here: https://www.nerdfonts.com/cheat-sheet signs = { - past = "●", - close_past = "●", - future = "●", - close_future = "●", + past = "◀", + close_past = "◀", + future = "▶", + close_future = "▶", }, }, diff --git a/compass/src/config/common/sign.rs b/compass/src/config/common/sign.rs index c74031b..c391446 100644 --- a/compass/src/config/common/sign.rs +++ b/compass/src/config/common/sign.rs @@ -5,18 +5,18 @@ use serde::Deserialize; #[derive(Debug, Deserialize)] pub struct SignText(String); -impl Default for SignText { - fn default() -> Self { - Self("●".to_owned()) - } -} - impl From for String { fn from(value: SignText) -> String { value.0 } } +impl From for SignText { + fn from(value: String) -> SignText { + SignText(value) + } +} + impl Deref for SignText { type Target = str; diff --git a/compass/src/config/marks/signs.rs b/compass/src/config/marks/signs.rs index e07e131..3077a86 100644 --- a/compass/src/config/marks/signs.rs +++ b/compass/src/config/marks/signs.rs @@ -2,15 +2,34 @@ use crate::config::SignText; use serde::Deserialize; -#[derive(Debug, Default, Deserialize)] +#[derive(Debug, Deserialize)] pub struct Signs { - #[serde(default)] + #[serde(default = "default_past")] pub past: SignText, - #[serde(default)] + #[serde(default = "default_past")] pub close_past: SignText, - #[serde(default)] + #[serde(default = "default_future")] pub future: SignText, - #[serde(default)] + #[serde(default = "default_future")] pub close_future: SignText, } + +fn default_past() -> SignText { + "◀".to_owned().into() +} + +fn default_future() -> SignText { + "▶".to_owned().into() +} + +impl Default for Signs { + fn default() -> Self { + Self { + past: default_past(), + close_past: default_past(), + future: default_future(), + close_future: default_future(), + } + } +}