@@ -26,25 +26,25 @@ def _ensure_config_dir(self) -> None:
2626 def _load_config (self ) -> None :
2727 """Load configuration from file."""
2828 default_colors = {
29- 'reset' : '\\ 033[0m ' ,
30- 'bold' : '\\ 033[1m ' ,
31- 'dim' : '\\ 033[2m ' ,
32- 'red' : '\\ 033[91m ' ,
33- 'green' : '\\ 033[92m ' ,
34- 'yellow' : '\\ 033[93m ' ,
35- 'blue' : '\\ 033[94m ' ,
36- 'magenta' : '\\ 033[95m ' ,
37- 'cyan' : '\\ 033[96m ' ,
38- 'white' : '\\ 033[97m ' ,
39- 'orange' : '\\ 033[38;2;255;165;0m ' ,
40- 'accent' : '\\ 033[1m ' ,
41- 'header' : '\\ 033[38;2;118;215;161m ' ,
42- 'muted' : '\\ 033[2m ' ,
43- '0' : '\\ 033[48;5;238m ' ,
44- '1' : '\\ 033[48;5;28m ' ,
45- '2' : '\\ 033[48;5;34m ' ,
46- '3' : '\\ 033[48;5;40m ' ,
47- '4' : '\\ 033[48;5;82m '
29+ 'reset' : '#000000 ' ,
30+ 'bold' : '#FFFFFF ' ,
31+ 'dim' : '#888888 ' ,
32+ 'red' : '#FF5555 ' ,
33+ 'green' : '#50FA7B ' ,
34+ 'yellow' : '#F1FA8C ' ,
35+ 'blue' : '#BD93F9 ' ,
36+ 'magenta' : '#FF79C6 ' ,
37+ 'cyan' : '#8BE9FD ' ,
38+ 'white' : '#F8F8F2 ' ,
39+ 'orange' : '#FFB86C ' ,
40+ 'accent' : '#FFFFFF ' ,
41+ 'header' : '#76D7A1 ' ,
42+ 'muted' : '#44475A ' ,
43+ '0' : '#282A36 ' ,
44+ '1' : '#44475A ' ,
45+ '2' : '#6272A4 ' ,
46+ '3' : '#50FA7B ' ,
47+ '4' : '#F1FA8C '
4848 }
4949 if self .CONFIG_FILE .exists ():
5050 self .config .read (self .CONFIG_FILE )
@@ -80,9 +80,7 @@ def _load_config(self) -> None:
8080 self .config .add_section ('COLORS' )
8181 for key , value in default_colors .items ():
8282 self .config .set ('COLORS' , key , value )
83- for k , v in self .config ._sections ['COLORS' ].items ():
84- self .config ._sections ['COLORS' ][k ] = v .encode (
85- 'utf-8' ).decode ('unicode_escape' )
83+ # No longer decode ANSI escapes; store as hex
8684
8785 def get_default_username (self ) -> Optional [str ]:
8886 """
@@ -96,46 +94,43 @@ def get_default_username(self) -> Optional[str]:
9694
9795 def get_colors (self ) -> dict :
9896 """
99- Get colors
97+ Get colors as hex codes from config.
10098
10199 Returns:
102- User defined colors or default colors if not set
100+ dict: color name to hex code
103101 """
104- # Color name to ANSI code mapping
105- color_names = {
106- 'black' : '\\ 033[30m' ,
107- 'red' : '\\ 033[91m' ,
108- 'green' : '\\ 033[92m' ,
109- 'yellow' : '\\ 033[93m' ,
110- 'blue' : '\\ 033[94m' ,
111- 'magenta' : '\\ 033[95m' ,
112- 'cyan' : '\\ 033[96m' ,
113- 'white' : '\\ 033[97m' ,
114- 'gray' : '\\ 033[90m' ,
115- 'bright_red' : '\\ 033[91m' ,
116- 'bright_green' : '\\ 033[92m' ,
117- 'bright_yellow' : '\\ 033[93m' ,
118- 'bright_blue' : '\\ 033[94m' ,
119- 'bright_magenta' : '\\ 033[95m' ,
120- 'bright_cyan' : '\\ 033[96m' ,
121- 'bright_white' : '\\ 033[97m' ,
122- 'orange' : '\\ 033[38;2;255;165;0m' ,
123- 'purple' : '\\ 033[95m' , # alias for magenta
124- 'pink' : '\\ 033[95m' , # alias for magenta
125- }
102+ return dict (self .config ._sections ["COLORS" ])
126103
127- colors = self .config ._sections ["COLORS" ]
128- resolved_colors = {}
104+ def get_ansi_colors (self ) -> dict :
105+ """
106+ Get colors as ANSI escape codes for terminal output.
129107
108+ Returns:
109+ dict: color name to ANSI code
110+ """
111+ # Map hex codes to ANSI codes (basic mapping for demonstration)
112+ hex_to_ansi = {
113+ '#000000' : '\033 [0m' ,
114+ '#FFFFFF' : '\033 [1m' ,
115+ '#888888' : '\033 [2m' ,
116+ '#FF5555' : '\033 [91m' ,
117+ '#50FA7B' : '\033 [92m' ,
118+ '#F1FA8C' : '\033 [93m' ,
119+ '#BD93F9' : '\033 [94m' ,
120+ '#FF79C6' : '\033 [95m' ,
121+ '#8BE9FD' : '\033 [96m' ,
122+ '#F8F8F2' : '\033 [97m' ,
123+ '#FFB86C' : '\033 [38;2;255;184;108m' ,
124+ '#76D7A1' : '\033 [38;2;118;215;161m' ,
125+ '#44475A' : '\033 [38;2;68;71;90m' ,
126+ '#282A36' : '\033 [48;5;238m' ,
127+ '#6272A4' : '\033 [38;2;98;114;164m' ,
128+ }
129+ colors = self .get_colors ()
130+ ansi_colors = {}
130131 for key , value in colors .items ():
131- # If the value is a known color name, map it to ANSI code
132- if value .lower () in color_names :
133- resolved_colors [key ] = color_names [value .lower ()]
134- else :
135- # Assume it's already an ANSI code or keep as-is
136- resolved_colors [key ] = value
137-
138- return resolved_colors
132+ ansi_colors [key ] = hex_to_ansi .get (value , value )
133+ return ansi_colors
139134
140135 def set_default_username (self , username : str ) -> None :
141136 """
0 commit comments