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
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ import curses
6
+ import os
7
+ from typing import Optional
8
+
9
+ from .base_dialog import BaseDialog
10
+
11
+
12
+ class ExportDialog(BaseDialog):
13
+ def __init__(self, stdscr, default_path: str = ""):
14
+ super().__init__(stdscr, "Export .gitignore Content")
15
+ if not default_path:
16
+ self.file_path = os.path.join(
17
+ os.path.expanduser("~"), "gitignore_export.txt"
18
+ )
19
+ else:
20
+ self.file_path = default_path
21
+ self.cursor_pos = len(self.file_path)
22
+
23
+ def show(self) -> Optional[str]:
24
+ width = 70
25
+ height = 10
26
+ y, x = self.calculate_position(width, height)
27
+
28
+ while True:
29
+ self.draw_background(y, x, height, width)
30
+ self.draw_border(y, x, height, width, self.title)
31
+
32
+ try:
33
+ desc_lines = [
34
+ "Export the generated .gitignore content to a file.",
35
+ "This will create a new file with the complete content.",
36
+ ]
37
+
38
+ for i, line in enumerate(desc_lines):
39
+ self.stdscr.addstr(y + 2 + i, x + 2, line, curses.color_pair(8))
40
+
41
+ label = "Export file path:"
42
+ self.stdscr.addstr(y + 5, x + 2, label, curses.color_pair(8))
43
+
44
+ input_y = y + 6
45
+ input_x = x + 2
46
+ input_width = width - 4
47
+
48
+ self.stdscr.addstr(
49
+ input_y, input_x, " " * input_width, curses.color_pair(3)
50
+ )
51
+
52
+ display_path = self.file_path
53
+ if len(display_path) > input_width - 1:
54
+ display_start = len(display_path) - (input_width - 4)
55
+ display_path = "..." + display_path[display_start:]
56
+
57
+ self.stdscr.addstr(
58
+ input_y,
59
+ input_x,
60
+ display_path[: input_width - 1],
61
+ curses.color_pair(3),
62
+ )
63
+
64
+ cursor_display_pos = min(self.cursor_pos, input_width - 1)
65
+ if len(self.file_path) > input_width - 1:
66
+ visible_start = max(0, len(self.file_path) - (input_width - 4))
67
+ cursor_display_pos = self.cursor_pos - visible_start + 3
68
+ cursor_display_pos = max(
69
+ 3, min(cursor_display_pos, input_width - 1)
70
+ )
71
+
72
+ if cursor_display_pos < len(display_path):
73
+ cursor_char = display_path[cursor_display_pos]
74
+ else:
75
+ cursor_char = " "
76
+
77
+ try:
78
+ self.stdscr.addch(
79
+ input_y,
80
+ input_x + cursor_display_pos,
81
+ cursor_char,
82
+ curses.color_pair(3) | curses.A_REVERSE,
83
+ )
84
+ except curses.error:
85
+ pass
86
+
87
+ button_y = y + 8
88
+ export_btn = " Export "
89
+ cancel_btn = " Cancel "
90
+
91
+ export_x = x + width // 2 - len(export_btn) - 2
92
+ cancel_x = x + width // 2 + 2
93
+
94
+ self.stdscr.addstr(
95
+ button_y, export_x, export_btn, curses.color_pair(4) | curses.A_BOLD
96
+ )
97
+ self.stdscr.addstr(button_y, cancel_x, cancel_btn, curses.color_pair(7))
98
+
99
+ except curses.error:
100
+ pass
101
+
102
+ self.stdscr.refresh()
103
+
104
+ key = self.stdscr.getch()
105
+
106
+ if key == 27:
107
+ return None
108
+ elif key in [curses.KEY_ENTER, ord("\n"), ord("\r")]:
109
+ if self.file_path.strip():
110
+ return self.file_path.strip()
111
+ elif key == curses.KEY_BACKSPACE or key == 127:
112
+ if self.cursor_pos > 0:
113
+ self.file_path = (
114
+ self.file_path[: self.cursor_pos - 1]
115
+ + self.file_path[self.cursor_pos :]
116
+ )
117
+ self.cursor_pos -= 1
118
+ elif key == curses.KEY_DC:
119
+ if self.cursor_pos < len(self.file_path):
120
+ self.file_path = (
121
+ self.file_path[: self.cursor_pos]
122
+ + self.file_path[self.cursor_pos + 1 :]
123
+ )
124
+ elif key == curses.KEY_LEFT:
125
+ self.cursor_pos = max(0, self.cursor_pos - 1)
126
+ elif key == curses.KEY_RIGHT:
127
+ self.cursor_pos = min(len(self.file_path), self.cursor_pos + 1)
128
+ elif key == curses.KEY_HOME:
129
+ self.cursor_pos = 0
130
+ elif key == curses.KEY_END:
131
+ self.cursor_pos = len(self.file_path)
132
+ elif 32 <= key <= 126:
133
+ char = chr(key)
134
+ self.file_path = (
135
+ self.file_path[: self.cursor_pos]
136
+ + char
137
+ + self.file_path[self.cursor_pos :]
138
+ )
139
+ self.cursor_pos += 1
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ import curses
6
+
7
+ from .base_dialog import BaseDialog
8
+
9
+
10
+ class HelpDialog(BaseDialog):
11
+ def __init__(self, stdscr):
12
+ super().__init__(stdscr, "Help - Keyboard Shortcuts")
13
+ self.scroll_position = 0
14
+ self.help_content = [
15
+ "NAVIGATION:",
16
+ " Tab / Shift+Tab - Switch between panels",
17
+ " Arrow Keys - Navigate within panels",
18
+ " Page Up/Down - Scroll content",
19
+ " Home/End - Go to top/bottom",
20
+ "",
21
+ "SEARCH PANEL:",
22
+ " F1 - Fuzzy search mode",
23
+ " F2 - Exact search mode",
24
+ " F3 - Regex search mode",
25
+ " Ctrl+U - Clear search",
26
+ " Enter - Apply search",
27
+ "",
28
+ "TEMPLATES PANEL:",
29
+ " Space - Select/deselect template",
30
+ " a - Select all filtered templates",
31
+ " x - Clear all selections",
32
+ " F5 - Refresh templates list",
33
+ "",
34
+ "SELECTED PANEL:",
35
+ " Space - Remove selected template",
36
+ " c - Clear all selections",
37
+ "",
38
+ "CONTENT PANEL:",
39
+ " Up/Down Arrows - Scroll content",
40
+ " Page Up/Down - Fast scroll",
41
+ "",
42
+ "GLOBAL ACTIONS:",
43
+ " s - Save to .gitignore",
44
+ " e - Export to file",
45
+ " g - Generate content",
46
+ " h - Show this help",
47
+ " q / Ctrl+C - Quit application",
48
+ "",
49
+ "TIPS:",
50
+ " • Fuzzy search matches partial words",
51
+ " • Exact search requires complete matches",
52
+ " • Regex search supports patterns like 'python|node'",
53
+ " • Selected templates are automatically generated",
54
+ " • Use Ctrl+U to quickly clear search and see all templates",
55
+ ]
56
+
57
+ def show(self):
58
+ width = 70
59
+ height = 20
60
+ y, x = self.calculate_position(width, height)
61
+
62
+ while True:
63
+ self.draw_background(y, x, height, width)
64
+ self.draw_border(y, x, height, width, self.title)
65
+
66
+ content_height = height - 4
67
+ content_width = width - 4
68
+ visible_lines = self.help_content[
69
+ self.scroll_position : self.scroll_position + content_height
70
+ ]
71
+
72
+ for i, line in enumerate(visible_lines):
73
+ content_y = y + 2 + i
74
+ content_x = x + 2
75
+
76
+ try:
77
+ if line.startswith(" "):
78
+ self.stdscr.addstr(
79
+ content_y,
80
+ content_x,
81
+ line[:content_width],
82
+ curses.color_pair(8),
83
+ )
84
+ elif line.endswith(":"):
85
+ self.stdscr.addstr(
86
+ content_y,
87
+ content_x,
88
+ line[:content_width],
89
+ curses.color_pair(2) | curses.A_BOLD,
90
+ )
91
+ elif line.startswith(" •"):
92
+ self.stdscr.addstr(
93
+ content_y,
94
+ content_x,
95
+ line[:content_width],
96
+ curses.color_pair(4),
97
+ )
98
+ else:
99
+ self.stdscr.addstr(
100
+ content_y,
101
+ content_x,
102
+ line[:content_width],
103
+ curses.color_pair(8),
104
+ )
105
+ except curses.error:
106
+ pass
107
+
108
+ if len(self.help_content) > content_height:
109
+ scrollbar_x = x + width - 2
110
+ for i in range(content_height):
111
+ try:
112
+ if i == 0 and self.scroll_position > 0:
113
+ self.stdscr.addch(
114
+ y + 2 + i, scrollbar_x, "▲", curses.color_pair(1)
115
+ )
116
+ elif (
117
+ i == content_height - 1
118
+ and self.scroll_position + content_height
119
+ < len(self.help_content)
120
+ ):
121
+ self.stdscr.addch(
122
+ y + 2 + i, scrollbar_x, "▼", curses.color_pair(1)
123
+ )
124
+ else:
125
+ self.stdscr.addch(
126
+ y + 2 + i, scrollbar_x, "│", curses.color_pair(1)
127
+ )
128
+ except curses.error:
129
+ pass
130
+
131
+ try:
132
+ footer = "Use Up/Down to scroll, ESC or q to close"
133
+ footer_y = y + height - 2
134
+ footer_x = x + (width - len(footer)) // 2
135
+ self.stdscr.addstr(footer_y, footer_x, footer, curses.color_pair(1))
136
+ except curses.error:
137
+ pass
138
+
139
+ self.stdscr.refresh()
140
+
141
+ key = self.stdscr.getch()
142
+
143
+ if key in [ord("q"), ord("Q"), 27, curses.KEY_F10]:
144
+ break
145
+ elif key == curses.KEY_UP:
146
+ self.scroll_position = max(0, self.scroll_position - 1)
147
+ elif key == curses.KEY_DOWN:
148
+ max_scroll = max(0, len(self.help_content) - content_height)
149
+ self.scroll_position = min(max_scroll, self.scroll_position + 1)
150
+ elif key == curses.KEY_PPAGE:
151
+ self.scroll_position = max(0, self.scroll_position - content_height)
152
+ elif key == curses.KEY_NPAGE:
153
+ max_scroll = max(0, len(self.help_content) - content_height)
154
+ self.scroll_position = min(
155
+ max_scroll, self.scroll_position + content_height
156
+ )
157
+ elif key == curses.KEY_HOME:
158
+ self.scroll_position = 0
159
+ elif key == curses.KEY_END:
160
+ max_scroll = max(0, len(self.help_content) - content_height)
161
+ self.scroll_position = max_scroll
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ import curses
6
+ from typing import Optional
7
+
8
+ from .base_dialog import BaseDialog
9
+
10
+
11
+ class SaveDialog(BaseDialog):
12
+ def __init__(self, stdscr, default_path: str = ".gitignore"):
13
+ super().__init__(stdscr, "Save .gitignore File")
14
+ self.file_path = default_path
15
+ self.cursor_pos = len(self.file_path)
16
+
17
+ def show(self) -> Optional[str]:
18
+ width = 60
19
+ height = 8
20
+ y, x = self.calculate_position(width, height)
21
+
22
+ while True:
23
+ self.draw_background(y, x, height, width)
24
+ self.draw_border(y, x, height, width, self.title)
25
+
26
+ try:
27
+ prompt = "Enter file path:"
28
+ self.stdscr.addstr(y + 2, x + 2, prompt, curses.color_pair(8))
29
+
30
+ input_y = y + 3
31
+ input_x = x + 2
32
+ input_width = width - 4
33
+
34
+ self.stdscr.addstr(
35
+ input_y, input_x, " " * input_width, curses.color_pair(3)
36
+ )
37
+
38
+ display_path = self.file_path[: input_width - 1]
39
+ self.stdscr.addstr(input_y, input_x, display_path, curses.color_pair(3))
40
+
41
+ cursor_display_pos = min(self.cursor_pos, input_width - 1)
42
+ if cursor_display_pos < len(display_path):
43
+ cursor_char = display_path[cursor_display_pos]
44
+ else:
45
+ cursor_char = " "
46
+ self.stdscr.addch(
47
+ input_y,
48
+ input_x + cursor_display_pos,
49
+ cursor_char,
50
+ curses.color_pair(3) | curses.A_REVERSE,
51
+ )
52
+
53
+ button_y = y + 5
54
+ save_btn = " Save "
55
+ cancel_btn = " Cancel "
56
+
57
+ save_x = x + width // 2 - len(save_btn) - 2
58
+ cancel_x = x + width // 2 + 2
59
+
60
+ self.stdscr.addstr(
61
+ button_y, save_x, save_btn, curses.color_pair(4) | curses.A_BOLD
62
+ )
63
+ self.stdscr.addstr(button_y, cancel_x, cancel_btn, curses.color_pair(7))
64
+
65
+ help_text = "Enter: Save | ESC: Cancel"
66
+ help_x = x + (width - len(help_text)) // 2
67
+ self.stdscr.addstr(y + 6, help_x, help_text, curses.color_pair(1))
68
+
69
+ except curses.error:
70
+ pass
71
+
72
+ self.stdscr.refresh()
73
+
74
+ key = self.stdscr.getch()
75
+
76
+ if key == 27:
77
+ return None
78
+ elif key in [curses.KEY_ENTER, ord("\n"), ord("\r")]:
79
+ if self.file_path.strip():
80
+ return self.file_path.strip()
81
+ elif key == curses.KEY_BACKSPACE or key == 127:
82
+ if self.cursor_pos > 0:
83
+ self.file_path = (
84
+ self.file_path[: self.cursor_pos - 1]
85
+ + self.file_path[self.cursor_pos :]
86
+ )
87
+ self.cursor_pos -= 1
88
+ elif key == curses.KEY_DC:
89
+ if self.cursor_pos < len(self.file_path):
90
+ self.file_path = (
91
+ self.file_path[: self.cursor_pos]
92
+ + self.file_path[self.cursor_pos + 1 :]
93
+ )
94
+ elif key == curses.KEY_LEFT:
95
+ self.cursor_pos = max(0, self.cursor_pos - 1)
96
+ elif key == curses.KEY_RIGHT:
97
+ self.cursor_pos = min(len(self.file_path), self.cursor_pos + 1)
98
+ elif key == curses.KEY_HOME:
99
+ self.cursor_pos = 0
100
+ elif key == curses.KEY_END:
101
+ self.cursor_pos = len(self.file_path)
102
+ elif 32 <= key <= 126:
103
+ char = chr(key)
104
+ self.file_path = (
105
+ self.file_path[: self.cursor_pos]
106
+ + char
107
+ + self.file_path[self.cursor_pos :]
108
+ )
109
+ self.cursor_pos += 1
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ import curses
6
+
7
+ from .base_panel import BasePanel
8
+
9
+
10
+ class SearchPanel(BasePanel):
11
+ def __init__(self, stdscr, y: int, x: int, height: int, width: int):
12
+ super().__init__(stdscr, y, x, height, width, "Search")
13
+ self.filter_text = ""
14
+ self.current_search_mode = "fuzzy"
15
+
16
+ def draw(self):
17
+ mode_indicator = f"Search ({self.current_search_mode.upper()})"
18
+ self.draw_border(mode_indicator, self.is_active)
19
+
20
+ inner_y, inner_x = self.y + 1, self.x + 1
21
+ inner_width = self.width - 2
22
+
23
+ search_text = self.filter_text
24
+ prompt = "> "
25
+ display_text = prompt + search_text
26
+
27
+ if self.is_active:
28
+ display_text += "_"
29
+
30
+ try:
31
+ if self.is_active:
32
+ attr = curses.color_pair(3) | curses.A_BOLD
33
+ else:
34
+ attr = curses.color_pair(8)
35
+
36
+ self.stdscr.addstr(inner_y, inner_x, " " * (inner_width - 1), attr)
37
+ self.stdscr.addstr(inner_y, inner_x, display_text[: inner_width - 1], attr)
38
+
39
+ if self.height > 3:
40
+ mode_help = "F1:Fuzzy F2:Exact F3:Regex"
41
+ if len(mode_help) < inner_width - 1:
42
+ try:
43
+ mode_attr = (
44
+ curses.color_pair(1)
45
+ if self.is_active
46
+ else curses.color_pair(5)
47
+ )
48
+ self.stdscr.addstr(inner_y + 1, inner_x, mode_help, mode_attr)
49
+ except curses.error:
50
+ pass
51
+ except curses.error:
52
+ pass
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ import curses
6
+ from typing import Set
7
+
8
+ from .base_panel import BasePanel
9
+
10
+
11
+ class SelectedPanel(BasePanel):
12
+ def __init__(self, stdscr, y: int, x: int, height: int, width: int):
13
+ super().__init__(stdscr, y, x, height, width, "Selected Templates")
14
+ self.selected_templates: Set[str] = set()
15
+ self.selected_index = 0
16
+ self.selected_scroll = 0
17
+
18
+ def draw(self):
19
+ title = "Selected Templates"
20
+
21
+ selected_list = sorted(list(self.selected_templates))
22
+ scroll_info = ""
23
+ if selected_list:
24
+ visible_count = self.height - 2
25
+ if len(selected_list) > visible_count:
26
+ first_visible = self.selected_scroll + 1
27
+ last_visible = min(
28
+ self.selected_scroll + visible_count, len(selected_list)
29
+ )
30
+ scroll_info = f" ({first_visible}-{last_visible}/{len(selected_list)})"
31
+ if len(title) + len(scroll_info) > self.width - 6:
32
+ scroll_info = f" ({first_visible}-{last_visible})"
33
+ if len(title) + len(scroll_info) > self.width - 6:
34
+ scroll_info = ""
35
+
36
+ full_title = title + scroll_info
37
+ self.draw_border(full_title, self.is_active)
38
+
39
+ inner_y, inner_x = self.y + 1, self.x + 1
40
+ inner_height, inner_width = self.height - 2, self.width - 2
41
+
42
+ if not selected_list:
43
+ try:
44
+ self.stdscr.addstr(
45
+ inner_y + 1,
46
+ inner_x + 2,
47
+ "No templates selected",
48
+ curses.color_pair(8),
49
+ )
50
+ self.stdscr.addstr(
51
+ inner_y + 2,
52
+ inner_x + 2,
53
+ "Select templates from the left panel",
54
+ curses.color_pair(8),
55
+ )
56
+ except curses.error:
57
+ pass
58
+ return
59
+
60
+ visible_count = inner_height
61
+ show_scrollbar = len(selected_list) > visible_count
62
+ content_width = inner_width - 2
63
+ if show_scrollbar:
64
+ content_width -= 2
65
+
66
+ if self.selected_index < self.selected_scroll:
67
+ self.selected_scroll = self.selected_index
68
+ elif self.selected_index >= self.selected_scroll + visible_count:
69
+ self.selected_scroll = self.selected_index - visible_count + 1
70
+
71
+ if self.selected_index >= len(selected_list):
72
+ self.selected_index = max(0, len(selected_list) - 1)
73
+
74
+ for i in range(visible_count):
75
+ item_idx = self.selected_scroll + i
76
+ if item_idx >= len(selected_list):
77
+ break
78
+
79
+ template = selected_list[item_idx]
80
+ display_y = inner_y + i
81
+
82
+ is_highlighted = item_idx == self.selected_index and self.is_active
83
+
84
+ if is_highlighted:
85
+ attr = curses.color_pair(3)
86
+ prefix = "► "
87
+ else:
88
+ attr = curses.color_pair(4)
89
+ prefix = "• "
90
+
91
+ try:
92
+ display_text = prefix + template
93
+ display_line = display_text[:content_width].ljust(content_width)
94
+ self.stdscr.addstr(display_y, inner_x + 1, display_line, attr)
95
+ except curses.error:
96
+ pass
97
+
98
+ if show_scrollbar:
99
+ scrollbar_x = inner_x + inner_width - 1
100
+ self.draw_scrollbar(
101
+ inner_y,
102
+ scrollbar_x,
103
+ inner_height,
104
+ len(selected_list),
105
+ visible_count,
106
+ self.selected_scroll,
107
+ )