fixed to maintain backwards compatibility with a warning

This commit is contained in:
Tyarel8 2024-09-16 14:54:41 +02:00 committed by sxyazi
parent 680da00d97
commit 41bf51fa9e
No known key found for this signature in database
3 changed files with 23 additions and 2 deletions

View file

@ -83,5 +83,15 @@ Please replace e.g. `shell` with `shell --interactive`, `shell "my-template"` wi
}
}
// TODO: Remove when deprecated
if matches!(INPUT.create_title, popup::CreateTitle::One(_)) {
println!(
r#"WARNING: `create_title` config now takes two different values to account for the `--dir` flag.
Example:
[input]
create_title = ["Create:", "Create (dir):"]"#
);
}
Ok(())
}

View file

@ -4,6 +4,13 @@ use serde::Deserialize;
use super::{Offset, Origin};
#[derive(Deserialize)]
#[serde(untagged)]
pub enum CreateTitle {
One(String),
Two([String; 2]),
}
#[derive(Deserialize)]
pub struct Input {
pub cursor_blink: bool,
@ -14,7 +21,7 @@ pub struct Input {
pub cd_offset: Offset,
// create
pub create_title: [String; 2],
pub create_title: CreateTitle,
pub create_origin: Origin,
pub create_offset: Offset,

View file

@ -41,8 +41,12 @@ impl InputCfg {
}
pub fn create(dir: bool) -> Self {
let title = match &INPUT.create_title {
super::CreateTitle::One(single_title) => single_title.to_owned(),
super::CreateTitle::Two(titles) => titles[dir as usize].to_owned(),
};
Self {
title: INPUT.create_title[dir as usize].to_owned(),
title,
position: Position::new(INPUT.create_origin, INPUT.create_offset),
..Default::default()
}