<commit_before>﻿class Config {
		__New(file_address) {
			this.file_address := file_address
			
			this.cfg := {}
			this.cfg["NORMAL"]   := {"font_color" : "FF0000", "bg_color" : "000000", "_title": "avl_normal"  }
			this.cfg["INSERT"]   := {"font_color" : "3F51B5", "bg_color" : "FFFFFF", "_title": "avl_insert"  }
			this.cfg["CAPSLOCK"] := {"font_color" : "FF4081", "bg_color" : "FFFFFF", "_title": "avl_capslock"}

			for sect, obj in this.cfg {
				for key, def in obj {
					ini_value := this.get_ini_value(sect, key, def)
					if(this.is_invalid_value(key, ini_value)){
						ini_value := this.fix_ini_value( sect, key, this.cfg[sect][key] )
					}				
					this.cfg[sect][key] := ini_value
				}
			}
			;this.cfg["FENCE"]       := this.func_get_tray_location()
			this.cfg["STAT_LOC"]    := this.func_get_stat_location()
			this.cfg["MONITOR_CNT"] := this.get_monitor_cnt()
			
			cnt := this.cfg["MONITOR_CNT"]
			loop %cnt% {
				SysGet, mon, Monitor, %A_Index%
				name := "FENCE" . A_Index
				this.cfg[name] := {"loc" : "down", "size" : 0, "width" : monRight - monLeft, "height" : monBottom - monTop, "x" : monLeft, "y" : monTop }
			}
		} ; // end of __New
		
		get_monitor_cnt(){
			SysGet, cnt, MonitorCount
			return cnt
		}
		
		has_sect(str){
			return this.cfg.HasKey(str)
		}
		
		get_sect(str){
			return this.cfg[str]
		}

		get_value(sect, key){
			return this.cfg[sect][key]
		}
		
		get_ini_value(sect, key, default_value){
			file := this.file_address
			IniRead, value, %file%, %sect%, %key%, %default_value%
			return value
		}
		
		is_invalid_value( key, value ) {
			if(RegExMatch( key , "^_"))
				return false
			
			if( RegExMatch( key, "^[^_]+_color$" ) )
				 return not RegExMatch( value, "^[0-9a-fA-F]{6}$" )
		}
	
		fix_ini_value( sect, key, value ){
			file := this.file_address
			IniWrite, %value%, %file%, %sect%, %key%
			return value
		}
		func_get_stat_location(){
			tray_info := this.cfg["FENCE"]
			loc := tray_info["loc"]
			size := tray_info["size"]

			height := this.get_stat_height()
			if( loc = "down" )
				return {"x" : Floor(A_ScreenWidth/2), "y" : A_ScreenHeight - size - height }
			else
				return {"x" : Floor(A_ScreenWidth/2), "y" : A_ScreenHeight - height }
		}
		func_get_tray_location(){
			WinGetPos,xx,yy,ww,hh,ahk_class Shell_TrayWnd,,,
			if( ww > hh and yy > 0 )
				return {"loc" : "down", "size" : hh, "width" : A_ScreenWidth, "height" : A_ScreenHeight - hh, "x" : 0, "y" : 0 }
			else if( ww < hh and yy = 0 and xx = 0)
				return {"loc" : "left", "size" : hh, "width" : A_ScreenWidth - ww, "height" : A_ScreenHeight, "x" : ww, "y" : 0 }
			else if( ww < hh and xx > 0 )
				return {"loc" : "right", "size" : hh, "width" : A_ScreenWidth - ww, "height" : A_ScreenHeight, "x" : 0, "y" : 0  }
			else
				return {"loc" : "up", "size" : hh, "width" : A_ScreenWidth, "height" : A_ScreenHeight - hh, "x" : 0, "y" : hh  }
		}
		get_stat_height(){
			create_gui("PANEL", "size_test", "NORMAL", -100, -100, "000000", "FFFFFF")
			WinGetPos,xx,yy,ww, hh, size_test
			return hh
		}
}<commit_msg>comment added<commit_after>﻿class Config {
		
		/*
			Contructor
		*/
		__New(file_address) {
			this.file_address := file_address
			
			this.cfg := {}
			this.cfg["NORMAL"]   := {"font_color" : "FF0000", "bg_color" : "000000", "_title": "avl_normal"  }
			this.cfg["INSERT"]   := {"font_color" : "3F51B5", "bg_color" : "FFFFFF", "_title": "avl_insert"  }
			this.cfg["CAPSLOCK"] := {"font_color" : "FF4081", "bg_color" : "FFFFFF", "_title": "avl_capslock"}

			for sect, obj in this.cfg {
				for key, def in obj {
					ini_value := this.get_ini_value(sect, key, def)
					if(this.is_invalid_value(key, ini_value)){
						ini_value := this.fix_ini_value( sect, key, this.cfg[sect][key] )
					}				
					this.cfg[sect][key] := ini_value
				}
			}

			this.cfg["MONITOR_CNT"] := this.get_monitor_cnt()
			cnt := this.cfg["MONITOR_CNT"]
			loop %cnt% {
				SysGet, mon, Monitor, %A_Index%
				name := "FENCE" . A_Index
				this.cfg[name] := {"loc" : "down", "size" : 0, "width" : monRight - monLeft, "height" : monBottom - monTop, "x" : monLeft, "y" : monTop }
			}
			this.cfg["FENCE"]       := this.func_get_tray_location()
			this.cfg["STAT_LOC"]    := this.func_get_stat_location()
			


		} ; // end of __New
		
		/*
			get monitor count
		*/
		get_monitor_cnt(){
			SysGet, cnt, MonitorCount
			return cnt
		}
		
		/*
			check config section
		*/
		has_sect(str){
			return this.cfg.HasKey(str)
		}
		
		/*
			get section config
		*/
		get_sect(str){
			return this.cfg[str]
		}

		/*
			get section-key value
		*/
		get_value(sect, key){
			return this.cfg[sect][key]
		}
		
		/*
			get value from ini file
		*/
		get_ini_value(sect, key, default_value){
			file := this.file_address
			IniRead, value, %file%, %sect%, %key%, %default_value%
			return value
		}
		
		/*
			ini value validate check 
		*/
		is_invalid_value( key, value ) {
			if(RegExMatch( key , "^_"))
				return false
			
			if( RegExMatch( key, "^[^_]+_color$" ) )
				 return not RegExMatch( value, "^[0-9a-fA-F]{6}$" )
		}
	
		/*
			fix unvalid value in ini file
		*/
		fix_ini_value( sect, key, value ){
			file := this.file_address
			IniWrite, %value%, %file%, %sect%, %key%
			return value
		}
		
		/*
			
		*/
		func_get_stat_location(){
			tray_info := this.cfg["FENCE"]
			loc := tray_info["loc"]
			size := tray_info["size"]

			height := this.get_stat_height()
			if( loc = "down" )
				return {"x" : Floor(A_ScreenWidth/2), "y" : A_ScreenHeight - size - height }
			else
				return {"x" : Floor(A_ScreenWidth/2), "y" : A_ScreenHeight - height }
		}
		func_get_tray_location(){
			WinGetPos,xx,yy,ww,hh,ahk_class Shell_TrayWnd,,,
			if( ww > hh and yy > 0 )
				return {"loc" : "down", "size" : hh, "width" : A_ScreenWidth, "height" : A_ScreenHeight - hh, "x" : 0, "y" : 0 }
			else if( ww < hh and yy = 0 and xx = 0)
				return {"loc" : "left", "size" : hh, "width" : A_ScreenWidth - ww, "height" : A_ScreenHeight, "x" : ww, "y" : 0 }
			else if( ww < hh and xx > 0 )
				return {"loc" : "right", "size" : hh, "width" : A_ScreenWidth - ww, "height" : A_ScreenHeight, "x" : 0, "y" : 0  }
			else
				return {"loc" : "up", "size" : hh, "width" : A_ScreenWidth, "height" : A_ScreenHeight - hh, "x" : 0, "y" : hh  }
		}
		get_stat_height(){
			create_gui("PANEL", "size_test", "NORMAL", -100, -100, "000000", "FFFFFF")
			WinGetPos,xx,yy,ww, hh, size_test
			return hh
		}
}
{'fraction_non_alphanumeric': 0.18184648917951113, 'fraction_numerical': 0.014323524832632726, 'mean_word_length': 3.017510944340213, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5166416', 'n_tokens_mistral': 3067, 'n_tokens_neox': 2558, 'n_words': 559}