1010from datetime import datetime
1111from .config import ConfigManager
1212
13+
1314class DisplayFormatter :
1415 """Formats and displays GitHub stats in a neofetch-style layout."""
1516
16- def __init__ (self ,config_manager : ConfigManager ):
17+ def __init__ (self , config_manager : ConfigManager ):
1718 """Initialize the display formatter."""
1819 self .terminal_width = shutil .get_terminal_size ().columns
1920 self .enable_color = sys .stdout .isatty ()
2021 self .colors = config_manager .get_colors ()
2122
2223 def display (self , username : str , user_data : Dict [str , Any ],
23- stats : Dict [str , Any ],spaced = True ) -> None :
24+ stats : Dict [str , Any ], spaced = True ) -> None :
2425 """
2526 Display GitHub statistics in neofetch style.
2627
@@ -35,13 +36,13 @@ def display(self, username: str, user_data: Dict[str, Any],
3536
3637 if layout == 'minimal' :
3738 # Only show contribution graph
38- self ._display_minimal (username , stats ,spaced )
39+ self ._display_minimal (username , stats , spaced )
3940 elif layout == 'compact' :
4041 # Show graph and key info
41- self ._display_compact (username , user_data , stats ,spaced )
42+ self ._display_compact (username , user_data , stats , spaced )
4243 else :
4344 # Full layout with all sections
44- self ._display_full (username , user_data , stats ,spaced )
45+ self ._display_full (username , user_data , stats , spaced )
4546
4647 print () # Empty line at the end
4748
@@ -68,11 +69,11 @@ def _display_minimal(self, username: str, stats: Dict[str, Any], spaced=True) ->
6869 print (line )
6970
7071 def _display_compact (self , username : str , user_data : Dict [str , Any ],
71- stats : Dict [str , Any ], spaced = True ) -> None :
72- """Display graph and minimal info side-by-side."""
72+ stats : Dict [str , Any ], spaced = True ) -> None :
73+ """Display graph and minimal info side-by-side (no languages) ."""
7374 contrib_graph = stats .get ('contribution_graph' , [])
7475 recent_weeks = self ._get_recent_weeks (contrib_graph )
75- graph_width = max (40 , (self .terminal_width - 10 ) // 2 )
76+ graph_width = max (40 , (self .terminal_width - 40 ) // 2 )
7677 graph_lines = self ._get_contribution_graph_lines (
7778 contrib_graph ,
7879 username ,
@@ -84,7 +85,6 @@ def _display_compact(self, username: str, user_data: Dict[str, Any],
8485 info_lines = self ._format_user_info_compact (user_data , stats )
8586 achievements = self ._build_achievements (recent_weeks )
8687
87- # Combine sections
8888 right_side = list (info_lines )
8989 if achievements :
9090 right_side .append ("" )
@@ -96,7 +96,6 @@ def _display_compact(self, username: str, user_data: Dict[str, Any],
9696 graph_part = (graph_lines [i ] if i < len (graph_lines ) else "" )
9797 graph_len = self ._display_width (graph_part )
9898 padding = " " * max (0 , graph_width - graph_len )
99-
10099 info_part = (right_side [i ] if i < len (right_side ) else "" )
101100 print (f"{ graph_part } { padding } { info_part } " )
102101
@@ -116,11 +115,17 @@ def _display_full(self, username: str, user_data: Dict[str, Any],
116115 pull_request_lines = self ._format_pull_requests (stats )
117116 issue_lines = self ._format_issues (stats )
118117
119- section_columns = [
120- pull_request_lines ,
121- issue_lines ,
122- ]
123-
118+ # Only show PR/Issue columns if they fit side by side, otherwise show neither
119+ section_columns = []
120+ if pull_request_lines and issue_lines :
121+ pr_width = max ((self ._display_width (line )
122+ for line in pull_request_lines ), default = 0 )
123+ issue_width = max ((self ._display_width (line )
124+ for line in issue_lines ), default = 0 )
125+ total_width = pr_width + issue_width + len (" " ) # gap
126+ if total_width <= graph_width :
127+ section_columns = [pull_request_lines , issue_lines ]
128+ # Do not show only one column; only show both if they fit
124129 combined_sections = self ._combine_section_grid (
125130 section_columns , width_limit = graph_width
126131 )
@@ -132,7 +137,7 @@ def _display_full(self, username: str, user_data: Dict[str, Any],
132137 language_lines = self ._format_languages (stats )
133138
134139 right_side = list (info_lines )
135- if language_lines :
140+ if language_lines and self . terminal_width >= 120 :
136141 right_side .append ("" )
137142 right_side .extend (language_lines )
138143
0 commit comments