pomera-ai-commander 0.1.0

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 (192) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +680 -0
  3. package/bin/pomera-ai-commander.js +62 -0
  4. package/core/__init__.py +66 -0
  5. package/core/__pycache__/__init__.cpython-313.pyc +0 -0
  6. package/core/__pycache__/app_context.cpython-313.pyc +0 -0
  7. package/core/__pycache__/async_text_processor.cpython-313.pyc +0 -0
  8. package/core/__pycache__/backup_manager.cpython-313.pyc +0 -0
  9. package/core/__pycache__/backup_recovery_manager.cpython-313.pyc +0 -0
  10. package/core/__pycache__/content_hash_cache.cpython-313.pyc +0 -0
  11. package/core/__pycache__/context_menu.cpython-313.pyc +0 -0
  12. package/core/__pycache__/data_validator.cpython-313.pyc +0 -0
  13. package/core/__pycache__/database_connection_manager.cpython-313.pyc +0 -0
  14. package/core/__pycache__/database_curl_settings_manager.cpython-313.pyc +0 -0
  15. package/core/__pycache__/database_promera_ai_settings_manager.cpython-313.pyc +0 -0
  16. package/core/__pycache__/database_schema.cpython-313.pyc +0 -0
  17. package/core/__pycache__/database_schema_manager.cpython-313.pyc +0 -0
  18. package/core/__pycache__/database_settings_manager.cpython-313.pyc +0 -0
  19. package/core/__pycache__/database_settings_manager_interface.cpython-313.pyc +0 -0
  20. package/core/__pycache__/dialog_manager.cpython-313.pyc +0 -0
  21. package/core/__pycache__/efficient_line_numbers.cpython-313.pyc +0 -0
  22. package/core/__pycache__/error_handler.cpython-313.pyc +0 -0
  23. package/core/__pycache__/error_service.cpython-313.pyc +0 -0
  24. package/core/__pycache__/event_consolidator.cpython-313.pyc +0 -0
  25. package/core/__pycache__/memory_efficient_text_widget.cpython-313.pyc +0 -0
  26. package/core/__pycache__/migration_manager.cpython-313.pyc +0 -0
  27. package/core/__pycache__/migration_test_suite.cpython-313.pyc +0 -0
  28. package/core/__pycache__/migration_validator.cpython-313.pyc +0 -0
  29. package/core/__pycache__/optimized_find_replace.cpython-313.pyc +0 -0
  30. package/core/__pycache__/optimized_pattern_engine.cpython-313.pyc +0 -0
  31. package/core/__pycache__/optimized_search_highlighter.cpython-313.pyc +0 -0
  32. package/core/__pycache__/performance_monitor.cpython-313.pyc +0 -0
  33. package/core/__pycache__/persistence_manager.cpython-313.pyc +0 -0
  34. package/core/__pycache__/progressive_stats_calculator.cpython-313.pyc +0 -0
  35. package/core/__pycache__/regex_pattern_cache.cpython-313.pyc +0 -0
  36. package/core/__pycache__/regex_pattern_library.cpython-313.pyc +0 -0
  37. package/core/__pycache__/search_operation_manager.cpython-313.pyc +0 -0
  38. package/core/__pycache__/settings_defaults_registry.cpython-313.pyc +0 -0
  39. package/core/__pycache__/settings_integrity_validator.cpython-313.pyc +0 -0
  40. package/core/__pycache__/settings_serializer.cpython-313.pyc +0 -0
  41. package/core/__pycache__/settings_validator.cpython-313.pyc +0 -0
  42. package/core/__pycache__/smart_stats_calculator.cpython-313.pyc +0 -0
  43. package/core/__pycache__/statistics_update_manager.cpython-313.pyc +0 -0
  44. package/core/__pycache__/stats_config_manager.cpython-313.pyc +0 -0
  45. package/core/__pycache__/streaming_text_handler.cpython-313.pyc +0 -0
  46. package/core/__pycache__/task_scheduler.cpython-313.pyc +0 -0
  47. package/core/__pycache__/visibility_monitor.cpython-313.pyc +0 -0
  48. package/core/__pycache__/widget_cache.cpython-313.pyc +0 -0
  49. package/core/app_context.py +482 -0
  50. package/core/async_text_processor.py +422 -0
  51. package/core/backup_manager.py +656 -0
  52. package/core/backup_recovery_manager.py +1034 -0
  53. package/core/content_hash_cache.py +509 -0
  54. package/core/context_menu.py +313 -0
  55. package/core/data_validator.py +1067 -0
  56. package/core/database_connection_manager.py +745 -0
  57. package/core/database_curl_settings_manager.py +609 -0
  58. package/core/database_promera_ai_settings_manager.py +447 -0
  59. package/core/database_schema.py +412 -0
  60. package/core/database_schema_manager.py +396 -0
  61. package/core/database_settings_manager.py +1508 -0
  62. package/core/database_settings_manager_interface.py +457 -0
  63. package/core/dialog_manager.py +735 -0
  64. package/core/efficient_line_numbers.py +511 -0
  65. package/core/error_handler.py +747 -0
  66. package/core/error_service.py +431 -0
  67. package/core/event_consolidator.py +512 -0
  68. package/core/mcp/__init__.py +43 -0
  69. package/core/mcp/__pycache__/__init__.cpython-313.pyc +0 -0
  70. package/core/mcp/__pycache__/protocol.cpython-313.pyc +0 -0
  71. package/core/mcp/__pycache__/schema.cpython-313.pyc +0 -0
  72. package/core/mcp/__pycache__/server_stdio.cpython-313.pyc +0 -0
  73. package/core/mcp/__pycache__/tool_registry.cpython-313.pyc +0 -0
  74. package/core/mcp/protocol.py +288 -0
  75. package/core/mcp/schema.py +251 -0
  76. package/core/mcp/server_stdio.py +299 -0
  77. package/core/mcp/tool_registry.py +2345 -0
  78. package/core/memory_efficient_text_widget.py +712 -0
  79. package/core/migration_manager.py +915 -0
  80. package/core/migration_test_suite.py +1086 -0
  81. package/core/migration_validator.py +1144 -0
  82. package/core/optimized_find_replace.py +715 -0
  83. package/core/optimized_pattern_engine.py +424 -0
  84. package/core/optimized_search_highlighter.py +553 -0
  85. package/core/performance_monitor.py +675 -0
  86. package/core/persistence_manager.py +713 -0
  87. package/core/progressive_stats_calculator.py +632 -0
  88. package/core/regex_pattern_cache.py +530 -0
  89. package/core/regex_pattern_library.py +351 -0
  90. package/core/search_operation_manager.py +435 -0
  91. package/core/settings_defaults_registry.py +1087 -0
  92. package/core/settings_integrity_validator.py +1112 -0
  93. package/core/settings_serializer.py +558 -0
  94. package/core/settings_validator.py +1824 -0
  95. package/core/smart_stats_calculator.py +710 -0
  96. package/core/statistics_update_manager.py +619 -0
  97. package/core/stats_config_manager.py +858 -0
  98. package/core/streaming_text_handler.py +723 -0
  99. package/core/task_scheduler.py +596 -0
  100. package/core/update_pattern_library.py +169 -0
  101. package/core/visibility_monitor.py +596 -0
  102. package/core/widget_cache.py +498 -0
  103. package/mcp.json +61 -0
  104. package/package.json +57 -0
  105. package/pomera.py +7483 -0
  106. package/pomera_mcp_server.py +144 -0
  107. package/tools/__init__.py +5 -0
  108. package/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  109. package/tools/__pycache__/ai_tools.cpython-313.pyc +0 -0
  110. package/tools/__pycache__/ascii_art_generator.cpython-313.pyc +0 -0
  111. package/tools/__pycache__/base64_tools.cpython-313.pyc +0 -0
  112. package/tools/__pycache__/base_tool.cpython-313.pyc +0 -0
  113. package/tools/__pycache__/case_tool.cpython-313.pyc +0 -0
  114. package/tools/__pycache__/column_tools.cpython-313.pyc +0 -0
  115. package/tools/__pycache__/cron_tool.cpython-313.pyc +0 -0
  116. package/tools/__pycache__/curl_history.cpython-313.pyc +0 -0
  117. package/tools/__pycache__/curl_processor.cpython-313.pyc +0 -0
  118. package/tools/__pycache__/curl_settings.cpython-313.pyc +0 -0
  119. package/tools/__pycache__/curl_tool.cpython-313.pyc +0 -0
  120. package/tools/__pycache__/diff_viewer.cpython-313.pyc +0 -0
  121. package/tools/__pycache__/email_extraction_tool.cpython-313.pyc +0 -0
  122. package/tools/__pycache__/email_header_analyzer.cpython-313.pyc +0 -0
  123. package/tools/__pycache__/extraction_tools.cpython-313.pyc +0 -0
  124. package/tools/__pycache__/find_replace.cpython-313.pyc +0 -0
  125. package/tools/__pycache__/folder_file_reporter.cpython-313.pyc +0 -0
  126. package/tools/__pycache__/folder_file_reporter_adapter.cpython-313.pyc +0 -0
  127. package/tools/__pycache__/generator_tools.cpython-313.pyc +0 -0
  128. package/tools/__pycache__/hash_generator.cpython-313.pyc +0 -0
  129. package/tools/__pycache__/html_tool.cpython-313.pyc +0 -0
  130. package/tools/__pycache__/huggingface_helper.cpython-313.pyc +0 -0
  131. package/tools/__pycache__/jsonxml_tool.cpython-313.pyc +0 -0
  132. package/tools/__pycache__/line_tools.cpython-313.pyc +0 -0
  133. package/tools/__pycache__/list_comparator.cpython-313.pyc +0 -0
  134. package/tools/__pycache__/markdown_tools.cpython-313.pyc +0 -0
  135. package/tools/__pycache__/mcp_widget.cpython-313.pyc +0 -0
  136. package/tools/__pycache__/notes_widget.cpython-313.pyc +0 -0
  137. package/tools/__pycache__/number_base_converter.cpython-313.pyc +0 -0
  138. package/tools/__pycache__/regex_extractor.cpython-313.pyc +0 -0
  139. package/tools/__pycache__/slug_generator.cpython-313.pyc +0 -0
  140. package/tools/__pycache__/sorter_tools.cpython-313.pyc +0 -0
  141. package/tools/__pycache__/string_escape_tool.cpython-313.pyc +0 -0
  142. package/tools/__pycache__/text_statistics_tool.cpython-313.pyc +0 -0
  143. package/tools/__pycache__/text_wrapper.cpython-313.pyc +0 -0
  144. package/tools/__pycache__/timestamp_converter.cpython-313.pyc +0 -0
  145. package/tools/__pycache__/tool_loader.cpython-313.pyc +0 -0
  146. package/tools/__pycache__/translator_tools.cpython-313.pyc +0 -0
  147. package/tools/__pycache__/url_link_extractor.cpython-313.pyc +0 -0
  148. package/tools/__pycache__/url_parser.cpython-313.pyc +0 -0
  149. package/tools/__pycache__/whitespace_tools.cpython-313.pyc +0 -0
  150. package/tools/__pycache__/word_frequency_counter.cpython-313.pyc +0 -0
  151. package/tools/ai_tools.py +2892 -0
  152. package/tools/ascii_art_generator.py +353 -0
  153. package/tools/base64_tools.py +184 -0
  154. package/tools/base_tool.py +511 -0
  155. package/tools/case_tool.py +309 -0
  156. package/tools/column_tools.py +396 -0
  157. package/tools/cron_tool.py +885 -0
  158. package/tools/curl_history.py +601 -0
  159. package/tools/curl_processor.py +1208 -0
  160. package/tools/curl_settings.py +503 -0
  161. package/tools/curl_tool.py +5467 -0
  162. package/tools/diff_viewer.py +1072 -0
  163. package/tools/email_extraction_tool.py +249 -0
  164. package/tools/email_header_analyzer.py +426 -0
  165. package/tools/extraction_tools.py +250 -0
  166. package/tools/find_replace.py +1751 -0
  167. package/tools/folder_file_reporter.py +1463 -0
  168. package/tools/folder_file_reporter_adapter.py +480 -0
  169. package/tools/generator_tools.py +1217 -0
  170. package/tools/hash_generator.py +256 -0
  171. package/tools/html_tool.py +657 -0
  172. package/tools/huggingface_helper.py +449 -0
  173. package/tools/jsonxml_tool.py +730 -0
  174. package/tools/line_tools.py +419 -0
  175. package/tools/list_comparator.py +720 -0
  176. package/tools/markdown_tools.py +562 -0
  177. package/tools/mcp_widget.py +1417 -0
  178. package/tools/notes_widget.py +973 -0
  179. package/tools/number_base_converter.py +373 -0
  180. package/tools/regex_extractor.py +572 -0
  181. package/tools/slug_generator.py +311 -0
  182. package/tools/sorter_tools.py +459 -0
  183. package/tools/string_escape_tool.py +393 -0
  184. package/tools/text_statistics_tool.py +366 -0
  185. package/tools/text_wrapper.py +431 -0
  186. package/tools/timestamp_converter.py +422 -0
  187. package/tools/tool_loader.py +710 -0
  188. package/tools/translator_tools.py +523 -0
  189. package/tools/url_link_extractor.py +262 -0
  190. package/tools/url_parser.py +205 -0
  191. package/tools/whitespace_tools.py +356 -0
  192. package/tools/word_frequency_counter.py +147 -0
@@ -0,0 +1,431 @@
1
+ """
2
+ Text Wrapper/Formatter Module - Text formatting utilities
3
+
4
+ This module provides text wrapping and formatting functionality
5
+ for the Pomera AI Commander application.
6
+
7
+ Features:
8
+ - Word Wrap: Wrap text at specified column width
9
+ - Justify Text: Left, right, center, full justify
10
+ - Add Prefix/Suffix: Add text to start/end of each line
11
+ - Indent/Dedent: Add or remove indentation
12
+ """
13
+
14
+ import tkinter as tk
15
+ from tkinter import ttk
16
+ import textwrap
17
+
18
+
19
+ class TextWrapperProcessor:
20
+ """Text wrapper processor with various formatting capabilities."""
21
+
22
+ @staticmethod
23
+ def word_wrap(text, width=80, break_long_words=True, break_on_hyphens=True):
24
+ """Wrap text at specified column width."""
25
+ lines = text.split('\n')
26
+ wrapped_lines = []
27
+
28
+ for line in lines:
29
+ if line.strip():
30
+ wrapped = textwrap.fill(
31
+ line,
32
+ width=width,
33
+ break_long_words=break_long_words,
34
+ break_on_hyphens=break_on_hyphens
35
+ )
36
+ wrapped_lines.append(wrapped)
37
+ else:
38
+ wrapped_lines.append('')
39
+
40
+ return '\n'.join(wrapped_lines)
41
+
42
+ @staticmethod
43
+ def justify_text(text, width=80, mode="left"):
44
+ """Justify text to specified width."""
45
+ lines = text.split('\n')
46
+ result = []
47
+
48
+ for line in lines:
49
+ line = line.strip()
50
+ if not line:
51
+ result.append('')
52
+ continue
53
+
54
+ if mode == "left":
55
+ result.append(line.ljust(width))
56
+ elif mode == "right":
57
+ result.append(line.rjust(width))
58
+ elif mode == "center":
59
+ result.append(line.center(width))
60
+ elif mode == "full":
61
+ # Full justify - distribute spaces evenly
62
+ words = line.split()
63
+ if len(words) == 1:
64
+ result.append(line.ljust(width))
65
+ else:
66
+ total_spaces = width - sum(len(w) for w in words)
67
+ gaps = len(words) - 1
68
+ if gaps > 0:
69
+ space_per_gap = total_spaces // gaps
70
+ extra_spaces = total_spaces % gaps
71
+ justified = words[0]
72
+ for i, word in enumerate(words[1:]):
73
+ spaces = space_per_gap + (1 if i < extra_spaces else 0)
74
+ justified += ' ' * spaces + word
75
+ result.append(justified)
76
+ else:
77
+ result.append(line)
78
+ else:
79
+ result.append(line)
80
+
81
+ return '\n'.join(result)
82
+
83
+ @staticmethod
84
+ def add_prefix_suffix(text, prefix="", suffix="", skip_empty=True):
85
+ """Add prefix and/or suffix to each line."""
86
+ lines = text.split('\n')
87
+ result = []
88
+
89
+ for line in lines:
90
+ if skip_empty and not line.strip():
91
+ result.append(line)
92
+ else:
93
+ result.append(f"{prefix}{line}{suffix}")
94
+
95
+ return '\n'.join(result)
96
+
97
+ @staticmethod
98
+ def indent(text, size=4, char="space"):
99
+ """Add indentation to each line."""
100
+ indent_char = '\t' if char == "tab" else ' '
101
+ indent_str = indent_char * size if char == "space" else indent_char * size
102
+
103
+ lines = text.split('\n')
104
+ result = [indent_str + line if line.strip() else line for line in lines]
105
+
106
+ return '\n'.join(result)
107
+
108
+ @staticmethod
109
+ def dedent(text, size=4):
110
+ """Remove indentation from each line."""
111
+ lines = text.split('\n')
112
+ result = []
113
+
114
+ for line in lines:
115
+ # Count leading whitespace
116
+ stripped = line.lstrip()
117
+ leading = len(line) - len(stripped)
118
+
119
+ # Remove up to 'size' characters of indentation
120
+ remove = min(leading, size)
121
+ result.append(line[remove:])
122
+
123
+ return '\n'.join(result)
124
+
125
+ @staticmethod
126
+ def quote_text(text, style="double"):
127
+ """Wrap text in quotes or code blocks."""
128
+ if style == "double":
129
+ return f'"{text}"'
130
+ elif style == "single":
131
+ return f"'{text}'"
132
+ elif style == "backtick":
133
+ return f"`{text}`"
134
+ elif style == "code_block":
135
+ return f"```\n{text}\n```"
136
+ elif style == "blockquote":
137
+ lines = text.split('\n')
138
+ return '\n'.join(f"> {line}" for line in lines)
139
+ else:
140
+ return text
141
+
142
+
143
+ class TextWrapperWidget(ttk.Frame):
144
+ """Tabbed interface widget for text wrapper tools."""
145
+
146
+ def __init__(self, parent, app):
147
+ super().__init__(parent)
148
+ self.app = app
149
+ self.processor = TextWrapperProcessor()
150
+
151
+ self.wrap_width = tk.IntVar(value=80)
152
+ self.justify_mode = tk.StringVar(value="left")
153
+ self.justify_width = tk.IntVar(value=80)
154
+ self.prefix = tk.StringVar(value="")
155
+ self.suffix = tk.StringVar(value="")
156
+ self.skip_empty = tk.BooleanVar(value=True)
157
+ self.indent_size = tk.IntVar(value=4)
158
+ self.indent_char = tk.StringVar(value="space")
159
+ self.quote_style = tk.StringVar(value="double")
160
+
161
+ self.create_widgets()
162
+ self.load_settings()
163
+
164
+ def create_widgets(self):
165
+ """Creates the tabbed interface for text wrapper tools."""
166
+ self.notebook = ttk.Notebook(self)
167
+ self.notebook.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
168
+
169
+ self.create_wrap_tab()
170
+ self.create_justify_tab()
171
+ self.create_prefix_suffix_tab()
172
+ self.create_indent_tab()
173
+ self.create_quote_tab()
174
+
175
+ def create_wrap_tab(self):
176
+ """Creates the Word Wrap tab."""
177
+ frame = ttk.Frame(self.notebook)
178
+ self.notebook.add(frame, text="Word Wrap")
179
+
180
+ width_frame = ttk.Frame(frame)
181
+ width_frame.pack(fill=tk.X, padx=5, pady=10)
182
+
183
+ ttk.Label(width_frame, text="Line Width:").pack(side=tk.LEFT)
184
+ ttk.Spinbox(width_frame, from_=20, to=200, width=5,
185
+ textvariable=self.wrap_width,
186
+ command=self.on_setting_change).pack(side=tk.LEFT, padx=5)
187
+ ttk.Label(width_frame, text="characters").pack(side=tk.LEFT)
188
+
189
+ ttk.Button(frame, text="Wrap Text",
190
+ command=lambda: self.process("wrap")).pack(pady=10)
191
+
192
+ def create_justify_tab(self):
193
+ """Creates the Justify Text tab."""
194
+ frame = ttk.Frame(self.notebook)
195
+ self.notebook.add(frame, text="Justify")
196
+
197
+ mode_frame = ttk.LabelFrame(frame, text="Alignment", padding=10)
198
+ mode_frame.pack(fill=tk.X, padx=5, pady=5)
199
+
200
+ modes = [("Left", "left"), ("Right", "right"),
201
+ ("Center", "center"), ("Full", "full")]
202
+ for text, value in modes:
203
+ ttk.Radiobutton(mode_frame, text=text,
204
+ variable=self.justify_mode, value=value,
205
+ command=self.on_setting_change).pack(side=tk.LEFT, padx=5)
206
+
207
+ width_frame = ttk.Frame(frame)
208
+ width_frame.pack(fill=tk.X, padx=5, pady=5)
209
+
210
+ ttk.Label(width_frame, text="Width:").pack(side=tk.LEFT)
211
+ ttk.Spinbox(width_frame, from_=20, to=200, width=5,
212
+ textvariable=self.justify_width,
213
+ command=self.on_setting_change).pack(side=tk.LEFT, padx=5)
214
+
215
+ ttk.Button(frame, text="Justify Text",
216
+ command=lambda: self.process("justify")).pack(pady=10)
217
+
218
+ def create_prefix_suffix_tab(self):
219
+ """Creates the Prefix/Suffix tab."""
220
+ frame = ttk.Frame(self.notebook)
221
+ self.notebook.add(frame, text="Prefix/Suffix")
222
+
223
+ prefix_frame = ttk.Frame(frame)
224
+ prefix_frame.pack(fill=tk.X, padx=5, pady=5)
225
+ ttk.Label(prefix_frame, text="Prefix:").pack(side=tk.LEFT)
226
+ ttk.Entry(prefix_frame, textvariable=self.prefix, width=20).pack(side=tk.LEFT, padx=5)
227
+
228
+ suffix_frame = ttk.Frame(frame)
229
+ suffix_frame.pack(fill=tk.X, padx=5, pady=5)
230
+ ttk.Label(suffix_frame, text="Suffix:").pack(side=tk.LEFT)
231
+ ttk.Entry(suffix_frame, textvariable=self.suffix, width=20).pack(side=tk.LEFT, padx=5)
232
+
233
+ ttk.Checkbutton(frame, text="Skip Empty Lines",
234
+ variable=self.skip_empty,
235
+ command=self.on_setting_change).pack(anchor=tk.W, padx=5, pady=5)
236
+
237
+ ttk.Button(frame, text="Add Prefix/Suffix",
238
+ command=lambda: self.process("prefix_suffix")).pack(pady=10)
239
+
240
+ def create_indent_tab(self):
241
+ """Creates the Indent/Dedent tab."""
242
+ frame = ttk.Frame(self.notebook)
243
+ self.notebook.add(frame, text="Indent")
244
+
245
+ size_frame = ttk.Frame(frame)
246
+ size_frame.pack(fill=tk.X, padx=5, pady=5)
247
+ ttk.Label(size_frame, text="Indent Size:").pack(side=tk.LEFT)
248
+ ttk.Spinbox(size_frame, from_=1, to=16, width=4,
249
+ textvariable=self.indent_size,
250
+ command=self.on_setting_change).pack(side=tk.LEFT, padx=5)
251
+
252
+ char_frame = ttk.LabelFrame(frame, text="Indent Character", padding=10)
253
+ char_frame.pack(fill=tk.X, padx=5, pady=5)
254
+
255
+ ttk.Radiobutton(char_frame, text="Spaces",
256
+ variable=self.indent_char, value="space",
257
+ command=self.on_setting_change).pack(side=tk.LEFT, padx=10)
258
+ ttk.Radiobutton(char_frame, text="Tabs",
259
+ variable=self.indent_char, value="tab",
260
+ command=self.on_setting_change).pack(side=tk.LEFT, padx=10)
261
+
262
+ buttons_frame = ttk.Frame(frame)
263
+ buttons_frame.pack(pady=10)
264
+
265
+ ttk.Button(buttons_frame, text="Indent",
266
+ command=lambda: self.process("indent")).pack(side=tk.LEFT, padx=5)
267
+ ttk.Button(buttons_frame, text="Dedent",
268
+ command=lambda: self.process("dedent")).pack(side=tk.LEFT, padx=5)
269
+
270
+ def create_quote_tab(self):
271
+ """Creates the Quote Text tab."""
272
+ frame = ttk.Frame(self.notebook)
273
+ self.notebook.add(frame, text="Quote")
274
+
275
+ style_frame = ttk.LabelFrame(frame, text="Quote Style", padding=10)
276
+ style_frame.pack(fill=tk.X, padx=5, pady=5)
277
+
278
+ styles = [
279
+ ('Double Quotes ("...")', "double"),
280
+ ("Single Quotes ('...')", "single"),
281
+ ("Backticks (`...`)", "backtick"),
282
+ ("Code Block (```...```)", "code_block"),
283
+ ("Blockquote (> ...)", "blockquote"),
284
+ ]
285
+
286
+ for text, value in styles:
287
+ ttk.Radiobutton(style_frame, text=text,
288
+ variable=self.quote_style, value=value,
289
+ command=self.on_setting_change).pack(anchor=tk.W)
290
+
291
+ ttk.Button(frame, text="Quote Text",
292
+ command=lambda: self.process("quote")).pack(pady=10)
293
+
294
+ def load_settings(self):
295
+ """Load settings from the application."""
296
+ settings = self.app.settings.get("tool_settings", {}).get("Text Wrapper", {})
297
+
298
+ self.wrap_width.set(settings.get("wrap_width", 80))
299
+ self.justify_mode.set(settings.get("justify_mode", "left"))
300
+ self.justify_width.set(settings.get("justify_width", 80))
301
+ self.prefix.set(settings.get("prefix", ""))
302
+ self.suffix.set(settings.get("suffix", ""))
303
+ self.skip_empty.set(settings.get("skip_empty", True))
304
+ self.indent_size.set(settings.get("indent_size", 4))
305
+ self.indent_char.set(settings.get("indent_char", "space"))
306
+ self.quote_style.set(settings.get("quote_style", "double"))
307
+
308
+ def save_settings(self):
309
+ """Save current settings to the application."""
310
+ if "Text Wrapper" not in self.app.settings["tool_settings"]:
311
+ self.app.settings["tool_settings"]["Text Wrapper"] = {}
312
+
313
+ self.app.settings["tool_settings"]["Text Wrapper"].update({
314
+ "wrap_width": self.wrap_width.get(),
315
+ "justify_mode": self.justify_mode.get(),
316
+ "justify_width": self.justify_width.get(),
317
+ "prefix": self.prefix.get(),
318
+ "suffix": self.suffix.get(),
319
+ "skip_empty": self.skip_empty.get(),
320
+ "indent_size": self.indent_size.get(),
321
+ "indent_char": self.indent_char.get(),
322
+ "quote_style": self.quote_style.get()
323
+ })
324
+
325
+ self.app.save_settings()
326
+
327
+ def on_setting_change(self, *args):
328
+ """Handle setting changes."""
329
+ self.save_settings()
330
+
331
+ def process(self, operation):
332
+ """Process the input text."""
333
+ active_input_tab = self.app.input_tabs[self.app.input_notebook.index(self.app.input_notebook.select())]
334
+ input_text = active_input_tab.text.get("1.0", tk.END).rstrip('\n')
335
+
336
+ if not input_text:
337
+ return
338
+
339
+ if operation == "wrap":
340
+ result = TextWrapperProcessor.word_wrap(input_text, self.wrap_width.get())
341
+ elif operation == "justify":
342
+ result = TextWrapperProcessor.justify_text(
343
+ input_text, self.justify_width.get(), self.justify_mode.get())
344
+ elif operation == "prefix_suffix":
345
+ result = TextWrapperProcessor.add_prefix_suffix(
346
+ input_text, self.prefix.get(), self.suffix.get(), self.skip_empty.get())
347
+ elif operation == "indent":
348
+ result = TextWrapperProcessor.indent(
349
+ input_text, self.indent_size.get(), self.indent_char.get())
350
+ elif operation == "dedent":
351
+ result = TextWrapperProcessor.dedent(input_text, self.indent_size.get())
352
+ elif operation == "quote":
353
+ result = TextWrapperProcessor.quote_text(input_text, self.quote_style.get())
354
+ else:
355
+ result = input_text
356
+
357
+ active_output_tab = self.app.output_tabs[self.app.output_notebook.index(self.app.output_notebook.select())]
358
+ active_output_tab.text.config(state="normal")
359
+ active_output_tab.text.delete("1.0", tk.END)
360
+ active_output_tab.text.insert("1.0", result)
361
+ active_output_tab.text.config(state="disabled")
362
+
363
+ self.app.update_all_stats()
364
+
365
+
366
+ class TextWrapper:
367
+ """Main class for Text Wrapper integration."""
368
+
369
+ def __init__(self):
370
+ self.processor = TextWrapperProcessor()
371
+
372
+ def create_widget(self, parent, app):
373
+ """Create and return the Text Wrapper widget."""
374
+ return TextWrapperWidget(parent, app)
375
+
376
+ def get_default_settings(self):
377
+ """Return default settings for Text Wrapper."""
378
+ return {
379
+ "wrap_width": 80,
380
+ "justify_mode": "left",
381
+ "justify_width": 80,
382
+ "prefix": "",
383
+ "suffix": "",
384
+ "skip_empty": True,
385
+ "indent_size": 4,
386
+ "indent_char": "space",
387
+ "quote_style": "double"
388
+ }
389
+
390
+
391
+ # BaseTool-compatible wrapper
392
+ try:
393
+ from tools.base_tool import BaseTool
394
+ from typing import Dict, Any, Optional, Callable
395
+
396
+ class TextWrapperV2(BaseTool):
397
+ """
398
+ BaseTool-compatible version of TextWrapper.
399
+ """
400
+
401
+ TOOL_NAME = "Text Wrapper"
402
+ TOOL_DESCRIPTION = "Wrap text to specified width"
403
+ TOOL_VERSION = "2.0.0"
404
+
405
+ def __init__(self):
406
+ super().__init__()
407
+ self._processor = TextWrapperProcessor()
408
+
409
+ def process_text(self, input_text: str, settings: Dict[str, Any]) -> str:
410
+ """Wrap text to specified width."""
411
+ width = settings.get("width", 80)
412
+ return TextWrapperProcessor.word_wrap(input_text, width)
413
+
414
+ def create_ui(self,
415
+ parent,
416
+ settings: Dict[str, Any],
417
+ on_setting_change_callback: Optional[Callable] = None,
418
+ apply_tool_callback: Optional[Callable] = None):
419
+ """Create minimal UI - full widget used separately."""
420
+ self._settings = settings.copy()
421
+ self._on_setting_change = on_setting_change_callback
422
+ self._apply_callback = apply_tool_callback
423
+ return None
424
+
425
+ @classmethod
426
+ def get_default_settings(cls) -> Dict[str, Any]:
427
+ """Return default settings."""
428
+ return {"width": 80}
429
+
430
+ except ImportError:
431
+ pass