igntui 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. igntui/__init__.py +57 -0
  2. igntui/__main__.py +10 -0
  3. igntui/app.py +37 -0
  4. igntui/cli/__init__.py +31 -0
  5. igntui/cli/base.py +104 -0
  6. igntui/cli/commands/__init__.py +17 -0
  7. igntui/cli/commands/cache_cmd.py +95 -0
  8. igntui/cli/commands/generate_cmd.py +85 -0
  9. igntui/cli/commands/list_cmd.py +66 -0
  10. igntui/cli/commands/test_cmd.py +64 -0
  11. igntui/cli/commands/tui_cmd.py +34 -0
  12. igntui/cli/parser.py +162 -0
  13. igntui/cli/setup.py +71 -0
  14. igntui/core/__init__.py +8 -0
  15. igntui/core/api/__init__.py +16 -0
  16. igntui/core/api/client.py +222 -0
  17. igntui/core/api/errors.py +29 -0
  18. igntui/core/api/rate_limiter.py +30 -0
  19. igntui/core/api/request_handler.py +124 -0
  20. igntui/core/api/response.py +16 -0
  21. igntui/core/cache.py +284 -0
  22. igntui/core/config.py +174 -0
  23. igntui/core/search.py +354 -0
  24. igntui/main.py +74 -0
  25. igntui/tui/__init__.py +22 -0
  26. igntui/tui/actions.py +254 -0
  27. igntui/tui/app.py +246 -0
  28. igntui/tui/curses_setup.py +88 -0
  29. igntui/tui/event_handler.py +310 -0
  30. igntui/tui/lifecycle.py +102 -0
  31. igntui/tui/renderer.py +108 -0
  32. igntui/tui/state.py +77 -0
  33. igntui/ui/__init__.py +33 -0
  34. igntui/ui/components/__init__.py +31 -0
  35. igntui/ui/components/base_dialog.py +75 -0
  36. igntui/ui/components/base_panel.py +85 -0
  37. igntui/ui/components/confirm_dialog.py +100 -0
  38. igntui/ui/components/content_panel.py +77 -0
  39. igntui/ui/components/export_dialog.py +139 -0
  40. igntui/ui/components/help_dialog.py +161 -0
  41. igntui/ui/components/save_dialog.py +109 -0
  42. igntui/ui/components/search_panel.py +52 -0
  43. igntui/ui/components/selected_panel.py +107 -0
  44. igntui/ui/components/splash.py +236 -0
  45. igntui/ui/components/status_bar.py +78 -0
  46. igntui/ui/components/templates_panel.py +153 -0
  47. igntui/utils/__init__.py +19 -0
  48. igntui/utils/logging.py +288 -0
  49. igntui-0.0.0.dist-info/METADATA +425 -0
  50. igntui-0.0.0.dist-info/RECORD +52 -0
  51. igntui-0.0.0.dist-info/WHEEL +4 -0
  52. igntui-0.0.0.dist-info/entry_points.txt +4 -0
igntui/core/search.py ADDED
@@ -0,0 +1,354 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ import logging
6
+ import re
7
+ import time
8
+ from abc import ABC, abstractmethod
9
+ from dataclasses import dataclass
10
+ from enum import Enum
11
+ from typing import Any, Dict, List, Optional, Tuple
12
+
13
+ logger = logging.getLogger(__name__)
14
+
15
+
16
+ class SearchMode(Enum):
17
+ FUZZY = "fuzzy"
18
+ EXACT = "exact"
19
+ REGEX = "regex"
20
+
21
+
22
+ @dataclass
23
+ class SearchResult:
24
+ item: str
25
+ score: float
26
+ match_positions: List[Tuple[int, int]]
27
+ search_mode: SearchMode
28
+
29
+
30
+ @dataclass
31
+ class SearchResults:
32
+ results: List[SearchResult]
33
+ query: str
34
+ search_mode: SearchMode
35
+ search_time: float
36
+ total_items: int
37
+
38
+ def get_items(self) -> List[str]:
39
+ return [result.item for result in self.results]
40
+
41
+
42
+ class SearchEngine(ABC):
43
+ def __init__(self):
44
+ self.stats = {
45
+ "searches_performed": 0,
46
+ "total_search_time": 0.0,
47
+ "items_processed": 0,
48
+ }
49
+
50
+ @abstractmethod
51
+ def search(
52
+ self, items: List[str], query: str, max_results: int = 100
53
+ ) -> SearchResults:
54
+ pass
55
+
56
+ def get_stats(self) -> Dict[str, Any]:
57
+ avg_search_time = self.stats["total_search_time"] / max(
58
+ 1, self.stats["searches_performed"]
59
+ )
60
+
61
+ return {
62
+ "searches_performed": self.stats["searches_performed"],
63
+ "avg_search_time": avg_search_time,
64
+ "total_items_processed": self.stats["items_processed"],
65
+ }
66
+
67
+
68
+ class FuzzySearchEngine(SearchEngine):
69
+ def __init__(self, case_sensitive: bool = False):
70
+ super().__init__()
71
+ self.case_sensitive = case_sensitive
72
+
73
+ def search(
74
+ self, items: List[str], query: str, max_results: int = 100
75
+ ) -> SearchResults:
76
+ start_time = time.time()
77
+
78
+ if not query.strip():
79
+ results = [
80
+ SearchResult(item, 1.0, [], SearchMode.FUZZY)
81
+ for item in items[:max_results]
82
+ ]
83
+ else:
84
+ scored_results = []
85
+ search_query = query if self.case_sensitive else query.lower()
86
+
87
+ for item in items:
88
+ search_item = item if self.case_sensitive else item.lower()
89
+ score, positions = self._fuzzy_match(search_query, search_item)
90
+
91
+ if score > 0:
92
+ scored_results.append(
93
+ SearchResult(item, score, positions, SearchMode.FUZZY)
94
+ )
95
+
96
+ scored_results.sort(key=lambda x: (-x.score, x.item.lower()))
97
+ results = scored_results[:max_results]
98
+
99
+ search_time = time.time() - start_time
100
+
101
+ self.stats["searches_performed"] += 1
102
+ self.stats["total_search_time"] += search_time
103
+ self.stats["items_processed"] += len(items)
104
+
105
+ logger.debug(
106
+ f"Fuzzy search for '{query}' found {len(results)} matches in {search_time:.3f}s"
107
+ )
108
+
109
+ return SearchResults(
110
+ results=results,
111
+ query=query,
112
+ search_mode=SearchMode.FUZZY,
113
+ search_time=search_time,
114
+ total_items=len(items),
115
+ )
116
+
117
+ def _fuzzy_match(
118
+ self, query: str, text: str
119
+ ) -> Tuple[float, List[Tuple[int, int]]]:
120
+ if not query:
121
+ return 1.0, []
122
+
123
+ if not text:
124
+ return 0.0, []
125
+
126
+ if query == text:
127
+ return 1.0, [(0, len(text))]
128
+
129
+ if query in text:
130
+ start_pos = text.find(query)
131
+ return 0.9, [(start_pos, start_pos + len(query))]
132
+
133
+ query_chars = list(query)
134
+ text_chars = list(text)
135
+
136
+ matches = 0
137
+ query_idx = 0
138
+ positions = []
139
+
140
+ for text_idx, text_char in enumerate(text_chars):
141
+ if query_idx < len(query_chars) and text_char == query_chars[query_idx]:
142
+ matches += 1
143
+ positions.append((text_idx, text_idx + 1))
144
+ query_idx += 1
145
+
146
+ if matches == 0:
147
+ return 0.0, []
148
+
149
+ match_ratio = matches / len(query)
150
+ length_penalty = 1.0 - (
151
+ abs(len(text) - len(query)) / max(len(text), len(query))
152
+ )
153
+
154
+ start_bonus = 1.0
155
+ if positions and positions[0][0] == 0:
156
+ start_bonus = 1.2
157
+
158
+ score = match_ratio * length_penalty * start_bonus * 0.8
159
+
160
+ return min(score, 1.0), positions
161
+
162
+
163
+ class ExactSearchEngine(SearchEngine):
164
+ def __init__(self, case_sensitive: bool = False):
165
+ super().__init__()
166
+ self.case_sensitive = case_sensitive
167
+
168
+ def search(
169
+ self, items: List[str], query: str, max_results: int = 100
170
+ ) -> SearchResults:
171
+ start_time = time.time()
172
+
173
+ if not query.strip():
174
+ results = [
175
+ SearchResult(item, 1.0, [], SearchMode.EXACT)
176
+ for item in items[:max_results]
177
+ ]
178
+ else:
179
+ results = []
180
+ search_query = query if self.case_sensitive else query.lower()
181
+
182
+ for item in items:
183
+ search_item = item if self.case_sensitive else item.lower()
184
+
185
+ if search_query in search_item:
186
+ positions = []
187
+ start = 0
188
+ while True:
189
+ pos = search_item.find(search_query, start)
190
+ if pos == -1:
191
+ break
192
+ positions.append((pos, pos + len(search_query)))
193
+ start = pos + 1
194
+
195
+ score = len(search_query) / len(search_item)
196
+
197
+ if search_query == search_item:
198
+ score = 1.0
199
+
200
+ results.append(
201
+ SearchResult(item, score, positions, SearchMode.EXACT)
202
+ )
203
+
204
+ if len(results) >= max_results:
205
+ break
206
+
207
+ results.sort(key=lambda x: (-x.score, x.item.lower()))
208
+
209
+ search_time = time.time() - start_time
210
+
211
+ self.stats["searches_performed"] += 1
212
+ self.stats["total_search_time"] += search_time
213
+ self.stats["items_processed"] += len(items)
214
+
215
+ logger.debug(
216
+ f"Exact search for '{query}' found {len(results)} matches in {search_time:.3f}s"
217
+ )
218
+
219
+ return SearchResults(
220
+ results=results,
221
+ query=query,
222
+ search_mode=SearchMode.EXACT,
223
+ search_time=search_time,
224
+ total_items=len(items),
225
+ )
226
+
227
+
228
+ class RegexSearchEngine(SearchEngine):
229
+ def __init__(self, case_sensitive: bool = False):
230
+ super().__init__()
231
+ self.case_sensitive = case_sensitive
232
+ self._compiled_patterns = {}
233
+
234
+ def search(
235
+ self, items: List[str], query: str, max_results: int = 100
236
+ ) -> SearchResults:
237
+ start_time = time.time()
238
+
239
+ if not query.strip():
240
+ results = [
241
+ SearchResult(item, 1.0, [], SearchMode.REGEX)
242
+ for item in items[:max_results]
243
+ ]
244
+ else:
245
+ results = []
246
+
247
+ try:
248
+ pattern = self._get_compiled_pattern(query)
249
+
250
+ for item in items:
251
+ matches = list(pattern.finditer(item))
252
+
253
+ if matches:
254
+ positions = [(match.start(), match.end()) for match in matches]
255
+ total_match_length = sum(
256
+ end - start for start, end in positions
257
+ )
258
+ score = total_match_length / len(item)
259
+
260
+ results.append(
261
+ SearchResult(item, score, positions, SearchMode.REGEX)
262
+ )
263
+
264
+ if len(results) >= max_results:
265
+ break
266
+
267
+ results.sort(key=lambda x: (-x.score, x.item.lower()))
268
+
269
+ except re.error as e:
270
+ logger.warning(f"Invalid regex pattern '{query}': {e}")
271
+ results = []
272
+
273
+ search_time = time.time() - start_time
274
+
275
+ self.stats["searches_performed"] += 1
276
+ self.stats["total_search_time"] += search_time
277
+ self.stats["items_processed"] += len(items)
278
+
279
+ logger.debug(
280
+ f"Regex search for '{query}' found {len(results)} matches in {search_time:.3f}s"
281
+ )
282
+
283
+ return SearchResults(
284
+ results=results,
285
+ query=query,
286
+ search_mode=SearchMode.REGEX,
287
+ search_time=search_time,
288
+ total_items=len(items),
289
+ )
290
+
291
+ def _get_compiled_pattern(self, pattern_str: str) -> re.Pattern:
292
+ cache_key = (pattern_str, self.case_sensitive)
293
+
294
+ if cache_key not in self._compiled_patterns:
295
+ flags = 0 if self.case_sensitive else re.IGNORECASE
296
+ self._compiled_patterns[cache_key] = re.compile(pattern_str, flags)
297
+
298
+ return self._compiled_patterns[cache_key]
299
+
300
+
301
+ class SearchManager:
302
+ def __init__(self, case_sensitive: bool = False):
303
+ self.case_sensitive = case_sensitive
304
+
305
+ self.engines = {
306
+ SearchMode.FUZZY: FuzzySearchEngine(case_sensitive),
307
+ SearchMode.EXACT: ExactSearchEngine(case_sensitive),
308
+ SearchMode.REGEX: RegexSearchEngine(case_sensitive),
309
+ }
310
+
311
+ self.current_mode = SearchMode.FUZZY
312
+
313
+ logger.debug(f"Initialized search manager with {len(self.engines)} engines")
314
+
315
+ def search(
316
+ self,
317
+ items: List[str],
318
+ query: str,
319
+ mode: Optional[SearchMode] = None,
320
+ max_results: int = 100,
321
+ ) -> SearchResults:
322
+ search_mode = mode or self.current_mode
323
+ engine = self.engines[search_mode]
324
+
325
+ return engine.search(items, query, max_results)
326
+
327
+ def set_mode(self, mode: SearchMode) -> None:
328
+ if mode in self.engines:
329
+ self.current_mode = mode
330
+ logger.debug(f"Switched to {mode.value} search mode")
331
+ else:
332
+ logger.warning(f"Unknown search mode: {mode}")
333
+
334
+ def get_mode(self) -> SearchMode:
335
+ return self.current_mode
336
+
337
+ def get_stats(self) -> Dict[str, Any]:
338
+ stats = {
339
+ "current_mode": self.current_mode.value,
340
+ "case_sensitive": self.case_sensitive,
341
+ "engines": {},
342
+ }
343
+
344
+ for mode, engine in self.engines.items():
345
+ stats["engines"][mode.value] = engine.get_stats()
346
+
347
+ return stats
348
+
349
+ def clear_caches(self) -> None:
350
+ for engine in self.engines.values():
351
+ if hasattr(engine, "_compiled_patterns"):
352
+ engine._compiled_patterns.clear()
353
+
354
+ logger.debug("Cleared search engine caches")
igntui/main.py ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ import argparse
6
+ import sys
7
+ from typing import Optional
8
+
9
+ from .cli import (
10
+ BaseCLI,
11
+ create_base_parser,
12
+ create_command_parser,
13
+ get_command_instance,
14
+ safe_exit,
15
+ )
16
+
17
+
18
+ def main() -> int:
19
+ cli = BaseCLI()
20
+ parser = create_base_parser()
21
+ parser = create_command_parser(parser)
22
+ args = parser.parse_args()
23
+
24
+ if args.verbose:
25
+ cli.setup_logging(verbose=True)
26
+
27
+ command = args.command
28
+
29
+ if command is None:
30
+ command = "tui"
31
+ args.no_splash = False
32
+
33
+ command_instance = get_command_instance(command, cli)
34
+ if command_instance is None:
35
+ print(f"Error: Unknown command '{command}'")
36
+ parser.print_help()
37
+ return 1
38
+
39
+ try:
40
+ return command_instance.execute(args)
41
+ except KeyboardInterrupt:
42
+ print("\nOperation cancelled by user")
43
+ return 1
44
+ except Exception as e:
45
+ print(f"Unexpected error: {e}")
46
+ if args.verbose:
47
+ import traceback
48
+
49
+ traceback.print_exc()
50
+ return 1
51
+
52
+
53
+ def cli_main() -> None:
54
+ try:
55
+ exit_code = main()
56
+ safe_exit(exit_code)
57
+ except Exception as e:
58
+ print(f"Fatal error: {e}")
59
+ safe_exit(1)
60
+
61
+
62
+ def tui_main() -> None:
63
+ try:
64
+ from .app import run_tui
65
+
66
+ exit_code = run_tui(show_splash=True)
67
+ safe_exit(exit_code)
68
+ except Exception as e:
69
+ print(f"Fatal error: {e}")
70
+ safe_exit(1)
71
+
72
+
73
+ if __name__ == "__main__":
74
+ cli_main()
igntui/tui/__init__.py ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ from .app import GitIgnoreTUI, main
6
+ from .state import TUIState
7
+ from .curses_setup import CursesSetup
8
+ from .lifecycle import TemplateLifecycle
9
+ from .event_handler import EventHandler
10
+ from .actions import TUIActions
11
+ from .renderer import TUIRenderer
12
+
13
+ __all__ = [
14
+ "GitIgnoreTUI",
15
+ "main",
16
+ "TUIState",
17
+ "CursesSetup",
18
+ "TemplateLifecycle",
19
+ "EventHandler",
20
+ "TUIActions",
21
+ "TUIRenderer",
22
+ ]
igntui/tui/actions.py ADDED
@@ -0,0 +1,254 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ import curses
6
+ import json
7
+ import logging
8
+ import time
9
+ from pathlib import Path
10
+ from typing import Optional
11
+
12
+ from .. import __version__, get_version_string
13
+ from ..ui import ConfirmDialog, ExportDialog, HelpDialog, SaveDialog
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+
18
+ class TUIActions:
19
+ def __init__(self, stdscr, state):
20
+ self.stdscr = stdscr
21
+ self.state = state
22
+
23
+ def save_gitignore(self) -> None:
24
+ if not self.state.generated_content or self.state.generated_content.startswith(
25
+ "# No templates selected"
26
+ ):
27
+ self.state.set_status_message(
28
+ "No content to save - select templates first", is_error=True
29
+ )
30
+ return
31
+
32
+ try:
33
+ dialog = SaveDialog(self.stdscr)
34
+ save_path_str = dialog.show()
35
+
36
+ if not save_path_str:
37
+ self.state.set_status_message("Save cancelled")
38
+ return
39
+
40
+ gitignore_path = Path(save_path_str)
41
+
42
+ if gitignore_path.exists():
43
+ confirm_dialog = ConfirmDialog(
44
+ self.stdscr,
45
+ "Overwrite File?",
46
+ f"File '{gitignore_path.name}' already exists. Overwrite?",
47
+ )
48
+ if not confirm_dialog.show():
49
+ self.state.set_status_message("Save cancelled")
50
+ return
51
+
52
+ timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
53
+ selected_list = self.state.get_selected_templates_list()
54
+ templates_str = ", ".join(selected_list)
55
+
56
+ header = f"""# .gitignore file generated by igntui (MKAbuMattar.com)
57
+ # Generated on: {timestamp}
58
+ # Templates used: {templates_str}
59
+ #
60
+ # This file was created using the igntui tool
61
+ # Visit: https://github.com/MKAbuMattar/igntui
62
+ #
63
+ # ================================================================
64
+
65
+ """
66
+
67
+ content_with_header = header + self.state.generated_content
68
+
69
+ with open(gitignore_path, "w", encoding="utf-8") as f:
70
+ f.write(content_with_header)
71
+
72
+ content_size = len(self.state.generated_content)
73
+ self.state.set_status_message(
74
+ f"✓ Saved to {gitignore_path.name} ({content_size} chars)"
75
+ )
76
+ logger.info(f"Saved {content_size} chars to {gitignore_path}")
77
+
78
+ except Exception as e:
79
+ self.state.set_status_message(f"Failed to save: {e}", is_error=True)
80
+ logger.error(f"Error saving .gitignore: {e}")
81
+
82
+ def export_templates(self) -> None:
83
+ if not self.state.selected_templates:
84
+ self.state.set_status_message(
85
+ "No templates selected for export", is_error=True
86
+ )
87
+ return
88
+
89
+ try:
90
+ dialog = ExportDialog(self.stdscr)
91
+ export_path_str = dialog.show()
92
+
93
+ if not export_path_str:
94
+ self.state.set_status_message("Export cancelled")
95
+ return
96
+
97
+ export_path = Path(export_path_str)
98
+
99
+ export_data = {
100
+ "export_info": {
101
+ "tool": "igntui",
102
+ "version": f"{__version__}",
103
+ "timestamp": time.strftime("%Y-%m-%d %H:%M:%S"),
104
+ "templates_count": len(self.state.selected_templates),
105
+ },
106
+ "templates": self.state.get_selected_templates_list(),
107
+ "search_info": {
108
+ "last_search": self.state.filter_text,
109
+ "search_mode": self.state.current_search_mode,
110
+ "total_available": len(self.state.templates),
111
+ "filtered_count": len(self.state.filtered_templates),
112
+ },
113
+ }
114
+
115
+ with open(export_path, "w", encoding="utf-8") as f:
116
+ json.dump(export_data, f, indent=2, ensure_ascii=False)
117
+
118
+ self.state.set_status_message(
119
+ f"✓ Exported {len(self.state.selected_templates)} templates to {export_path.name}"
120
+ )
121
+ logger.info(
122
+ f"Exported {len(self.state.selected_templates)} templates to {export_path}"
123
+ )
124
+
125
+ except Exception as e:
126
+ self.state.set_status_message(f"Export failed: {e}", is_error=True)
127
+ logger.error(f"Error exporting templates: {e}")
128
+
129
+ def show_help_dialog(self) -> None:
130
+ try:
131
+ dialog = HelpDialog(self.stdscr)
132
+ dialog.show()
133
+
134
+ self.stdscr.clear()
135
+ self.stdscr.refresh()
136
+
137
+ except Exception as e:
138
+ self.state.set_status_message(f"Error showing help: {e}", is_error=True)
139
+ logger.error(f"Error showing help dialog: {e}")
140
+
141
+ def show_info_dialog(self) -> None:
142
+ max_y, max_x = self.stdscr.getmaxyx()
143
+
144
+ dialog_width = min(70, max_x - 4)
145
+ dialog_height = min(18, max_y - 4)
146
+ dialog_y = (max_y - dialog_height) // 2
147
+ dialog_x = (max_x - dialog_width) // 2
148
+
149
+ try:
150
+ version_string = get_version_string()
151
+
152
+ for y in range(max_y):
153
+ for x in range(max_x):
154
+ try:
155
+ self.stdscr.addch(
156
+ y, x, " ", curses.color_pair(1) | curses.A_DIM
157
+ )
158
+ except curses.error:
159
+ pass
160
+
161
+ for y in range(dialog_y, dialog_y + dialog_height):
162
+ for x in range(dialog_x, dialog_x + dialog_width):
163
+ try:
164
+ self.stdscr.addch(y, x, " ", curses.color_pair(8))
165
+ except curses.error:
166
+ pass
167
+
168
+ self._draw_border(
169
+ dialog_y, dialog_x, dialog_height, dialog_width, "About igntui"
170
+ )
171
+
172
+ info_lines = [
173
+ "",
174
+ "igntui - GitIgnore Template Generator",
175
+ "",
176
+ version_string,
177
+ "",
178
+ "A powerful TUI for generating .gitignore files",
179
+ "from gitignore.io templates with smart search,",
180
+ "caching, and multi-template support.",
181
+ "",
182
+ "Author: Mohammad Abu Mattar",
183
+ "GitHub: github.com/MKAbuMattar/igntui",
184
+ "Website: MKAbuMattar.com",
185
+ "",
186
+ "Press any key to close...",
187
+ ]
188
+
189
+ for idx, line in enumerate(info_lines):
190
+ y = dialog_y + 2 + idx
191
+ if y < dialog_y + dialog_height - 1:
192
+ try:
193
+ x = dialog_x + (dialog_width - len(line)) // 2
194
+ if "igntui" in line and idx == 1:
195
+ attr = curses.color_pair(4) | curses.A_BOLD
196
+ elif line.startswith("igntui/"):
197
+ attr = curses.color_pair(2) | curses.A_BOLD
198
+ elif line.startswith("Author:") or line.startswith("GitHub:"):
199
+ attr = curses.color_pair(6)
200
+ else:
201
+ attr = curses.color_pair(8)
202
+ self.stdscr.addstr(y, x, line, attr)
203
+ except curses.error:
204
+ pass
205
+
206
+ self.stdscr.refresh()
207
+
208
+ self.stdscr.timeout(-1)
209
+ self.stdscr.getch()
210
+ self.stdscr.timeout(100)
211
+
212
+ self.stdscr.clear()
213
+ self.stdscr.refresh()
214
+
215
+ except Exception as e:
216
+ self.state.set_status_message(f"Error showing info: {e}", is_error=True)
217
+ logger.error(f"Error showing info dialog: {e}")
218
+
219
+ def _draw_border(
220
+ self, y: int, x: int, height: int, width: int, title: str = ""
221
+ ) -> None:
222
+ try:
223
+ self.stdscr.addch(y, x, curses.ACS_ULCORNER, curses.color_pair(1))
224
+ self.stdscr.addch(
225
+ y, x + width - 1, curses.ACS_URCORNER, curses.color_pair(1)
226
+ )
227
+ self.stdscr.addch(
228
+ y + height - 1, x, curses.ACS_LLCORNER, curses.color_pair(1)
229
+ )
230
+ self.stdscr.addch(
231
+ y + height - 1, x + width - 1, curses.ACS_LRCORNER, curses.color_pair(1)
232
+ )
233
+
234
+ for i in range(1, width - 1):
235
+ self.stdscr.addch(y, x + i, curses.ACS_HLINE, curses.color_pair(1))
236
+ self.stdscr.addch(
237
+ y + height - 1, x + i, curses.ACS_HLINE, curses.color_pair(1)
238
+ )
239
+
240
+ for i in range(1, height - 1):
241
+ self.stdscr.addch(y + i, x, curses.ACS_VLINE, curses.color_pair(1))
242
+ self.stdscr.addch(
243
+ y + i, x + width - 1, curses.ACS_VLINE, curses.color_pair(1)
244
+ )
245
+
246
+ if title:
247
+ title_text = f" {title} "
248
+ title_x = x + (width - len(title_text)) // 2
249
+ self.stdscr.addstr(
250
+ y, title_x, title_text, curses.color_pair(6) | curses.A_BOLD
251
+ )
252
+
253
+ except curses.error:
254
+ pass