Skip to content

Commit

Permalink
feat: add a toolkit window (#39)
Browse files Browse the repository at this point in the history
This window will show information about the configuration file and the
afrim project.
  • Loading branch information
pythonbrad authored Dec 3, 2023
1 parent 60290e2 commit 63fa1f6
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 40 deletions.
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

0 comments on commit 63fa1f6

Please sign in to comment.