@@ -47,22 +47,31 @@ pub struct ThemeConfig {
4747 pub cursor : ( u8 , u8 , u8 ) ,
4848}
4949
50+ /// Configuration for the TuiType application
5051#[ derive( Clone , Debug , PartialEq , Serialize , Deserialize ) ]
5152pub struct Config {
53+ /// The current test mode (timed, words, quote, or custom)
5254 pub test_mode : TestMode ,
5355
56+ /// The difficulty level for text generation
5457 pub difficulty : Difficulty ,
5558
59+ /// Custom text to use for typing tests
5660 pub custom_text : Option < String > ,
5761
62+ /// The visual theme to use
5863 pub theme_type : ThemeType ,
5964
65+ /// The font style to use for display
6066 pub font_style : FontStyle ,
6167
68+ /// Whether to repeat the same test after completion
6269 pub repeat_test : bool ,
6370
71+ /// The text from the last completed test
6472 pub last_test_text : Option < String > ,
6573
74+ /// Whether to end the test on the first error
6675 pub end_on_first_error : bool ,
6776}
6877
@@ -82,6 +91,7 @@ impl Default for Config {
8291}
8392
8493impl Config {
94+ /// Get the configuration directory path, creating it if it doesn't exist
8595 fn get_config_dir ( ) -> Result < PathBuf > {
8696 let mut dir = dirs:: config_dir ( ) . unwrap_or_else ( || PathBuf :: from ( "." ) ) ;
8797 dir. push ( "tuitype" ) ;
@@ -91,19 +101,22 @@ impl Config {
91101 Ok ( dir)
92102 }
93103
104+ /// Get the full path to the configuration file
94105 fn get_config_path ( ) -> Result < PathBuf > {
95106 let mut path = Self :: get_config_dir ( ) ?;
96107 path. push ( "config.json" ) ;
97108 Ok ( path)
98109 }
99110
111+ /// Save the current configuration to disk
100112 pub fn save ( & self ) -> Result < ( ) > {
101113 let path = Self :: get_config_path ( ) ?;
102114 let serialized = serde_json:: to_string_pretty ( self ) ?;
103115 fs:: write ( path, serialized) ?;
104116 Ok ( ( ) )
105117 }
106118
119+ /// Load configuration from disk, creating a default config if none exists
107120 pub fn load ( ) -> Result < Self > {
108121 let path = Self :: get_config_path ( ) ?;
109122 if path. exists ( ) {
0 commit comments