fce-enhanced 0.1.0__tar.gz

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.
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.3
2
+ Name: fce-enhanced
3
+ Version: 0.1.0
4
+ Summary: Enhanced Flet CodeEditor with file open/save/save-as/close/search and replace capabilities
5
+ Keywords: flet,code-editor,syntax-highlighting,text-editor,gui,flutter
6
+ Author: Tim Lang
7
+ Author-email: Tim Lang <ttim.lang@gmail.com>
8
+ License: MIT
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Text Editors
17
+ Classifier: Operating System :: OS Independent
18
+ Requires-Dist: flet>=0.81.0
19
+ Requires-Dist: flet-code-editor>=0.81.0
20
+ Requires-Dist: loguru>=0.7
21
+ Requires-Python: >=3.12
22
+ Project-URL: Homepage, https://github.com/oktl/flet-fce-enhanced
23
+ Project-URL: Repository, https://github.com/oktl/flet-fce-enhanced
24
+ Project-URL: Bug Tracker, https://github.com/oktl/flet-fce-enhanced/issues
25
+ Description-Content-Type: text/markdown
26
+
27
+ # fce-enhanced
28
+
29
+ An enhanced [Flet](https://flet.dev) CodeEditor control with file I/O, search/replace, syntax highlighting, and theme selection.
30
+
31
+ Built on top of [`flet-code-editor`](https://pypi.org/project/flet-code-editor/), adding a full-featured editing experience you can drop into any Flet app or run standalone. This project was created to explore and showcase what's possible with Flet — building a desktop-quality code editor entirely in Python.
32
+
33
+ ![fce-enhanced screenshot](https://raw.githubusercontent.com/oktl/flet-fce-enhanced/main/docs/images/Screenshot.png)
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ pip install fce-enhanced
39
+ ```
40
+
41
+ Or with uv:
42
+
43
+ ```bash
44
+ uv add fce-enhanced
45
+ ```
46
+
47
+ ### Development setup
48
+
49
+ ```bash
50
+ git clone https://github.com/oktl/flet-fce-enhanced.git
51
+ cd flet-fce-enhanced
52
+ uv sync
53
+ source .venv/bin/activate
54
+ pre-commit install # optional, for development
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ ### Run as a standalone app
60
+
61
+ ```bash
62
+ fce-enhanced
63
+ ```
64
+
65
+ Or during development:
66
+
67
+ ```bash
68
+ flet run src/fce_enhanced/editor.py
69
+ ```
70
+
71
+ ### Embed in your own Flet app
72
+
73
+ `EnhancedCodeEditor` is a standard `ft.Column` subclass — add it to any Flet page or layout just like any other control.
74
+
75
+ #### Minimal example
76
+
77
+ ```python
78
+ import flet as ft
79
+ from fce_enhanced import EnhancedCodeEditor
80
+
81
+
82
+ def main(page: ft.Page):
83
+ page.title = "My Editor"
84
+ editor = EnhancedCodeEditor(expand=True)
85
+ page.add(editor)
86
+
87
+
88
+ ft.run(main)
89
+ ```
90
+
91
+ #### With configuration
92
+
93
+ ```python
94
+ import flet as ft
95
+ import flet_code_editor as fce
96
+ from fce_enhanced import EnhancedCodeEditor
97
+
98
+
99
+ def main(page: ft.Page):
100
+ page.title = "My Editor"
101
+
102
+ def on_title_change(display_path, name, is_dirty):
103
+ page.title = f"{name}{'*' if is_dirty else ''} — My Editor"
104
+ page.update()
105
+
106
+ editor = EnhancedCodeEditor(
107
+ language=fce.CodeLanguage.JAVASCRIPT,
108
+ value="console.log('hello');",
109
+ code_theme=fce.CodeTheme.MONOKAI,
110
+ on_title_change=on_title_change,
111
+ ruff_on_save=False, # disable ruff (only applies to Python files)
112
+ expand=True,
113
+ )
114
+ page.add(editor)
115
+
116
+
117
+ ft.run(main)
118
+ ```
119
+
120
+ #### Constructor parameters
121
+
122
+ | Parameter | Type | Default | Description |
123
+ | ----------------------------- | -------------- | ---------------- | ------------------------------------------ |
124
+ | `language` | `CodeLanguage` | `PYTHON` | Initial syntax highlighting language |
125
+ | `value` | `str` | `"# New file\n"` | Initial editor content |
126
+ | `show_toolbar` | `bool` | `True` | Show the file I/O toolbar |
127
+ | `show_status_bar` | `bool` | `True` | Show the line/column status bar |
128
+ | `register_keyboard_shortcuts` | `bool` | `True` | Register global keyboard shortcuts |
129
+ | `autocomplete` | `bool` | `True` | Enable autocomplete |
130
+ | `autocomplete_words` | `list[str]` | `None` | Custom autocomplete suggestions |
131
+ | `code_theme` | `CodeTheme` | `ATOM_ONE_DARK` | Syntax highlighting theme |
132
+ | `text_style` | `TextStyle` | `None` | Text style for editor content |
133
+ | `gutter_style` | `GutterStyle` | `None` | Style for the line number gutter |
134
+ | `on_title_change` | `callable` | `None` | Callback `(display_path, name, is_dirty)` |
135
+ | `ruff_on_save` | `bool` | `True` | Auto-format Python files with ruff on save |
136
+
137
+ Any additional keyword arguments are passed through to `ft.Column`.
138
+
139
+ #### Useful properties
140
+
141
+ ```python
142
+ editor.value # current editor content (str)
143
+ editor.current_path # path of open file, or None
144
+ editor.dirty # True if there are unsaved changes
145
+ editor.language # current CodeLanguage
146
+ editor.code_editor # the underlying fce.CodeEditor control
147
+ editor.search_bar # the SearchReplaceBar control
148
+ ```
149
+
150
+ ## Features
151
+
152
+ - **File operations** — Open, Save, Save As, Close with unsaved-changes confirmation
153
+ - **Native file dialogs** — AppleScript dialogs on macOS, Flet FilePicker fallback elsewhere
154
+ - **Search & Replace** — Find toolbar with match counting, case sensitivity toggle, prev/next navigation
155
+ - **Command Palette** — Searchable list of all actions (Cmd+Shift+P / Ctrl+Shift+P)
156
+ - **Theme Selector** — 89 built-in syntax highlighting themes via a searchable dialog
157
+ - **Go to Line** — Jump to a specific line number (Cmd+G / Ctrl+G)
158
+ - **Read-Only Mode** — Toggle editing lock (Cmd+L / Ctrl+L)
159
+ - **Font Size Controls** — Increase/decrease font size (Cmd+= / Cmd+-)
160
+ - **Language Selector** — Choose syntax highlighting language from a searchable dialog; auto-detected on file open, and Save As defaults to the matching file extension
161
+ - **Language Detection** — Automatic syntax highlighting for 40+ file extensions
162
+ - **Dirty-File Tracking** — Visual indicator for unsaved changes
163
+ - **Diff Pane** — Toggleable unified diff view showing changes since last save, with green/red syntax coloring (Cmd+D / Ctrl+D)
164
+ - **Ruff on Save** — Auto-runs `ruff check --fix` and `ruff format` on Python files (requires ruff on PATH); toggleable from the toolbar
165
+ - **Status Bar** — Line, column, language, and selection info
166
+
167
+ ### Keyboard shortcuts
168
+
169
+ | Action | macOS | Windows / Linux |
170
+ | ------------------ | ----- | --------------- |
171
+ | Open File | ⌘O | Ctrl+O |
172
+ | Save | ⌘S | Ctrl+S |
173
+ | Save As | ⇧⌘S | Ctrl+Shift+S |
174
+ | Close File | ⌘W | Ctrl+W |
175
+ | Find | ⌘F | Ctrl+F |
176
+ | Find and Replace | ⌥⌘F | Ctrl+H |
177
+ | Toggle Diff | ⌘D | Ctrl+D |
178
+ | Go to Line | ⌘G | Ctrl+G |
179
+ | Toggle Read-Only | ⌘L | Ctrl+L |
180
+ | Increase Font Size | ⌘+ | Ctrl++ |
181
+ | Decrease Font Size | ⌘- | Ctrl+- |
182
+ | Command Palette | ⇧⌘P | Ctrl+Shift+P |
183
+ | Help | F1 | F1 |
184
+ | Close Search Bar | Esc | Esc |
185
+
186
+ ## License
187
+
188
+ MIT
189
+
190
+ ## Development
191
+
192
+ Code style is enforced with [ruff](https://docs.astral.sh/ruff/) via pre-commit hooks:
193
+
194
+ ```bash
195
+ pre-commit run --all-files
196
+ ```
197
+
198
+ Run tests:
199
+
200
+ ```bash
201
+ pytest
202
+ ```
203
+
204
+ ## Built With
205
+
206
+ - [Flet](https://flet.dev) — Build multi-platform apps in Python powered by Flutter
207
+ - [flet-code-editor](https://pypi.org/project/flet-code-editor/) — Code editor control for Flet with syntax highlighting
208
+ - [ruff](https://docs.astral.sh/ruff/) — Fast Python linter and formatter
@@ -0,0 +1,182 @@
1
+ # fce-enhanced
2
+
3
+ An enhanced [Flet](https://flet.dev) CodeEditor control with file I/O, search/replace, syntax highlighting, and theme selection.
4
+
5
+ Built on top of [`flet-code-editor`](https://pypi.org/project/flet-code-editor/), adding a full-featured editing experience you can drop into any Flet app or run standalone. This project was created to explore and showcase what's possible with Flet — building a desktop-quality code editor entirely in Python.
6
+
7
+ ![fce-enhanced screenshot](https://raw.githubusercontent.com/oktl/flet-fce-enhanced/main/docs/images/Screenshot.png)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install fce-enhanced
13
+ ```
14
+
15
+ Or with uv:
16
+
17
+ ```bash
18
+ uv add fce-enhanced
19
+ ```
20
+
21
+ ### Development setup
22
+
23
+ ```bash
24
+ git clone https://github.com/oktl/flet-fce-enhanced.git
25
+ cd flet-fce-enhanced
26
+ uv sync
27
+ source .venv/bin/activate
28
+ pre-commit install # optional, for development
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ### Run as a standalone app
34
+
35
+ ```bash
36
+ fce-enhanced
37
+ ```
38
+
39
+ Or during development:
40
+
41
+ ```bash
42
+ flet run src/fce_enhanced/editor.py
43
+ ```
44
+
45
+ ### Embed in your own Flet app
46
+
47
+ `EnhancedCodeEditor` is a standard `ft.Column` subclass — add it to any Flet page or layout just like any other control.
48
+
49
+ #### Minimal example
50
+
51
+ ```python
52
+ import flet as ft
53
+ from fce_enhanced import EnhancedCodeEditor
54
+
55
+
56
+ def main(page: ft.Page):
57
+ page.title = "My Editor"
58
+ editor = EnhancedCodeEditor(expand=True)
59
+ page.add(editor)
60
+
61
+
62
+ ft.run(main)
63
+ ```
64
+
65
+ #### With configuration
66
+
67
+ ```python
68
+ import flet as ft
69
+ import flet_code_editor as fce
70
+ from fce_enhanced import EnhancedCodeEditor
71
+
72
+
73
+ def main(page: ft.Page):
74
+ page.title = "My Editor"
75
+
76
+ def on_title_change(display_path, name, is_dirty):
77
+ page.title = f"{name}{'*' if is_dirty else ''} — My Editor"
78
+ page.update()
79
+
80
+ editor = EnhancedCodeEditor(
81
+ language=fce.CodeLanguage.JAVASCRIPT,
82
+ value="console.log('hello');",
83
+ code_theme=fce.CodeTheme.MONOKAI,
84
+ on_title_change=on_title_change,
85
+ ruff_on_save=False, # disable ruff (only applies to Python files)
86
+ expand=True,
87
+ )
88
+ page.add(editor)
89
+
90
+
91
+ ft.run(main)
92
+ ```
93
+
94
+ #### Constructor parameters
95
+
96
+ | Parameter | Type | Default | Description |
97
+ | ----------------------------- | -------------- | ---------------- | ------------------------------------------ |
98
+ | `language` | `CodeLanguage` | `PYTHON` | Initial syntax highlighting language |
99
+ | `value` | `str` | `"# New file\n"` | Initial editor content |
100
+ | `show_toolbar` | `bool` | `True` | Show the file I/O toolbar |
101
+ | `show_status_bar` | `bool` | `True` | Show the line/column status bar |
102
+ | `register_keyboard_shortcuts` | `bool` | `True` | Register global keyboard shortcuts |
103
+ | `autocomplete` | `bool` | `True` | Enable autocomplete |
104
+ | `autocomplete_words` | `list[str]` | `None` | Custom autocomplete suggestions |
105
+ | `code_theme` | `CodeTheme` | `ATOM_ONE_DARK` | Syntax highlighting theme |
106
+ | `text_style` | `TextStyle` | `None` | Text style for editor content |
107
+ | `gutter_style` | `GutterStyle` | `None` | Style for the line number gutter |
108
+ | `on_title_change` | `callable` | `None` | Callback `(display_path, name, is_dirty)` |
109
+ | `ruff_on_save` | `bool` | `True` | Auto-format Python files with ruff on save |
110
+
111
+ Any additional keyword arguments are passed through to `ft.Column`.
112
+
113
+ #### Useful properties
114
+
115
+ ```python
116
+ editor.value # current editor content (str)
117
+ editor.current_path # path of open file, or None
118
+ editor.dirty # True if there are unsaved changes
119
+ editor.language # current CodeLanguage
120
+ editor.code_editor # the underlying fce.CodeEditor control
121
+ editor.search_bar # the SearchReplaceBar control
122
+ ```
123
+
124
+ ## Features
125
+
126
+ - **File operations** — Open, Save, Save As, Close with unsaved-changes confirmation
127
+ - **Native file dialogs** — AppleScript dialogs on macOS, Flet FilePicker fallback elsewhere
128
+ - **Search & Replace** — Find toolbar with match counting, case sensitivity toggle, prev/next navigation
129
+ - **Command Palette** — Searchable list of all actions (Cmd+Shift+P / Ctrl+Shift+P)
130
+ - **Theme Selector** — 89 built-in syntax highlighting themes via a searchable dialog
131
+ - **Go to Line** — Jump to a specific line number (Cmd+G / Ctrl+G)
132
+ - **Read-Only Mode** — Toggle editing lock (Cmd+L / Ctrl+L)
133
+ - **Font Size Controls** — Increase/decrease font size (Cmd+= / Cmd+-)
134
+ - **Language Selector** — Choose syntax highlighting language from a searchable dialog; auto-detected on file open, and Save As defaults to the matching file extension
135
+ - **Language Detection** — Automatic syntax highlighting for 40+ file extensions
136
+ - **Dirty-File Tracking** — Visual indicator for unsaved changes
137
+ - **Diff Pane** — Toggleable unified diff view showing changes since last save, with green/red syntax coloring (Cmd+D / Ctrl+D)
138
+ - **Ruff on Save** — Auto-runs `ruff check --fix` and `ruff format` on Python files (requires ruff on PATH); toggleable from the toolbar
139
+ - **Status Bar** — Line, column, language, and selection info
140
+
141
+ ### Keyboard shortcuts
142
+
143
+ | Action | macOS | Windows / Linux |
144
+ | ------------------ | ----- | --------------- |
145
+ | Open File | ⌘O | Ctrl+O |
146
+ | Save | ⌘S | Ctrl+S |
147
+ | Save As | ⇧⌘S | Ctrl+Shift+S |
148
+ | Close File | ⌘W | Ctrl+W |
149
+ | Find | ⌘F | Ctrl+F |
150
+ | Find and Replace | ⌥⌘F | Ctrl+H |
151
+ | Toggle Diff | ⌘D | Ctrl+D |
152
+ | Go to Line | ⌘G | Ctrl+G |
153
+ | Toggle Read-Only | ⌘L | Ctrl+L |
154
+ | Increase Font Size | ⌘+ | Ctrl++ |
155
+ | Decrease Font Size | ⌘- | Ctrl+- |
156
+ | Command Palette | ⇧⌘P | Ctrl+Shift+P |
157
+ | Help | F1 | F1 |
158
+ | Close Search Bar | Esc | Esc |
159
+
160
+ ## License
161
+
162
+ MIT
163
+
164
+ ## Development
165
+
166
+ Code style is enforced with [ruff](https://docs.astral.sh/ruff/) via pre-commit hooks:
167
+
168
+ ```bash
169
+ pre-commit run --all-files
170
+ ```
171
+
172
+ Run tests:
173
+
174
+ ```bash
175
+ pytest
176
+ ```
177
+
178
+ ## Built With
179
+
180
+ - [Flet](https://flet.dev) — Build multi-platform apps in Python powered by Flutter
181
+ - [flet-code-editor](https://pypi.org/project/flet-code-editor/) — Code editor control for Flet with syntax highlighting
182
+ - [ruff](https://docs.astral.sh/ruff/) — Fast Python linter and formatter
@@ -0,0 +1,89 @@
1
+ [project]
2
+ name = "fce-enhanced"
3
+ version = "0.1.0"
4
+ description = "Enhanced Flet CodeEditor with file open/save/save-as/close/search and replace capabilities"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Tim Lang", email = "ttim.lang@gmail.com" }
8
+ ]
9
+ license = { text = "MIT" }
10
+ keywords = [
11
+ "flet",
12
+ "code-editor",
13
+ "syntax-highlighting",
14
+ "text-editor",
15
+ "gui",
16
+ "flutter",
17
+ ]
18
+ requires-python = ">=3.12"
19
+ classifiers = [
20
+ "Development Status :: 4 - Beta",
21
+ "Intended Audience :: Developers",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Software Development :: Libraries :: Python Modules",
27
+ "Topic :: Text Editors",
28
+ "Operating System :: OS Independent",
29
+ ]
30
+ dependencies = [
31
+ "flet>=0.81.0",
32
+ "flet-code-editor>=0.81.0",
33
+ "loguru>=0.7",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/oktl/flet-fce-enhanced"
38
+ Repository = "https://github.com/oktl/flet-fce-enhanced"
39
+ "Bug Tracker" = "https://github.com/oktl/flet-fce-enhanced/issues"
40
+
41
+ [project.scripts]
42
+ fce-enhanced = "fce_enhanced.editor:run"
43
+
44
+ [build-system]
45
+ requires = ["uv_build>=0.10.4,<0.11.0"]
46
+ build-backend = "uv_build"
47
+
48
+ [dependency-groups]
49
+ dev = [
50
+ "pre-commit>=4.5.1",
51
+ "pytest>=9.0.2",
52
+ "pytest-asyncio>=1.3.0",
53
+ "pytest-cov>=7.0.0",
54
+ "ruff>=0.15.4",
55
+ ]
56
+
57
+ [tool.pytest.ini_options]
58
+ python_files = "test_*.py"
59
+ python_classes = "Test*"
60
+ python_functions = "test_*"
61
+ addopts = "-v --tb=short --strict-markers -ra --cov=fce_enhanced --cov-report=term-missing --cov-report=html"
62
+ testpaths = ["tests"]
63
+ markers = [
64
+ "asyncio: marks tests as async (requires pytest-asyncio)",
65
+ "slow: marks tests as slow running",
66
+ "integration: marks tests as integration tests",
67
+ ]
68
+ asyncio_mode = "auto"
69
+
70
+ [tool.ruff.lint]
71
+ select = ["E", "F", "I", "W", "UP", "B", "SIM"]
72
+ ignore = [
73
+ "E501", # line too long (handled by formatter)
74
+ "SIM108", # ternary operator (readability preference)
75
+ ]
76
+
77
+ [tool.ruff.lint.isort]
78
+ known-first-party = ["fce_enhanced"]
79
+ known-third-party = ["flet", "rich"]
80
+ section-order = [
81
+ "future",
82
+ "standard-library",
83
+ "third-party",
84
+ "first-party",
85
+ "local-folder",
86
+ ]
87
+ combine-as-imports = true
88
+ force-sort-within-sections = true
89
+
@@ -0,0 +1,25 @@
1
+ """Enhanced Flet CodeEditor with file open/save/save-as/close capabilities."""
2
+
3
+ from importlib.metadata import version
4
+
5
+ from fce_enhanced.editor import EnhancedCodeEditor, main, run
6
+ from fce_enhanced.file_dialog import open_file, save_file
7
+ from fce_enhanced.languages import EXTENSION_TO_LANGUAGE, language_for_path
8
+ from fce_enhanced.search import SearchReplaceBar
9
+ from fce_enhanced.themes import DEFAULT_THEME, THEMES, theme_display_name
10
+
11
+ __version__ = version("fce-enhanced")
12
+
13
+ __all__ = [
14
+ "DEFAULT_THEME",
15
+ "EnhancedCodeEditor",
16
+ "EXTENSION_TO_LANGUAGE",
17
+ "SearchReplaceBar",
18
+ "THEMES",
19
+ "language_for_path",
20
+ "main",
21
+ "open_file",
22
+ "run",
23
+ "save_file",
24
+ "theme_display_name",
25
+ ]