Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a toolkit window #39

Merged
merged 3 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "afrim-wish"
version = "0.3.2"
edition = "2021"
description = "Wish interface for the afrim."
description = "Afrim Wish is an GUI interface for the afrim ime."
repository = "https://github.com/pythonbrad/afrim-wish"
license = "MIT"
readme = "README.md"
Expand Down
5 changes: 5 additions & 0 deletions data/sample.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[info]
name = "Sample config"
maintainors = ["test"]
input_method = "test"

[core]
buffer_size = 20
page_size = 10
Expand Down
26 changes: 21 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,41 @@ use serde::Deserialize;
use std::{error, fs, path::Path};
use toml::{self};

#[derive(Deserialize, Debug)]
#[derive(Clone, Deserialize, Debug)]
pub struct Config {
pub theme: Option<Theme>,
pub core: Core,
pub info: Info,
}

#[derive(Deserialize, Debug)]
#[derive(Clone, Deserialize, Debug)]
pub struct Core {
pub buffer_size: i8,
pub auto_commit: bool,
}

#[derive(Clone, Deserialize, Debug)]
pub struct Info {
pub name: String,
pub maintainors: Vec<String>,
pub input_method: String,
pub homepage: Option<String>,
}

#[derive(Clone, Deserialize, Debug)]
pub struct Theme {
pub header: SectionTheme,
pub body: SectionTheme,
}

#[derive(Deserialize, Debug)]
#[derive(Clone, Deserialize, Debug)]
pub struct SectionTheme {
pub background: String,
pub foreground: String,
pub font: ThemeFont,
}

#[derive(Deserialize, Debug)]
#[derive(Clone, Deserialize, Debug)]
pub struct ThemeFont {
pub family: String,
pub size: u64,
Expand All @@ -47,6 +63,6 @@ mod tests {
assert!(config.is_ok());

let config = Config::from_file(Path::new("./data/blank_sample.toml"));
assert!(config.is_ok());
assert!(config.is_err());
}
}
Loading