flet-code-editor 0.85.0.dev0__tar.gz → 0.85.0.dev1__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.
- {flet_code_editor-0.85.0.dev0/src/flet_code_editor.egg-info → flet_code_editor-0.85.0.dev1}/PKG-INFO +3 -3
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/README.md +1 -1
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/pyproject.toml +2 -2
- flet_code_editor-0.85.0.dev1/src/flet_code_editor/__init__.py +19 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flet_code_editor/code_editor.py +11 -1
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flet_code_editor/types.py +41 -1
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1/src/flet_code_editor.egg-info}/PKG-INFO +3 -3
- flet_code_editor-0.85.0.dev1/src/flet_code_editor.egg-info/requires.txt +1 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flutter/flet_code_editor/lib/src/code_editor.dart +56 -12
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flutter/flet_code_editor/lib/src/utils/flet_code_controller.dart +10 -0
- flet_code_editor-0.85.0.dev0/src/flet_code_editor/__init__.py +0 -10
- flet_code_editor-0.85.0.dev0/src/flet_code_editor.egg-info/requires.txt +0 -1
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/LICENSE +0 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/setup.cfg +0 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flet_code_editor.egg-info/SOURCES.txt +0 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flet_code_editor.egg-info/dependency_links.txt +0 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flet_code_editor.egg-info/top_level.txt +0 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flutter/flet_code_editor/lib/flet_code_editor.dart +0 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flutter/flet_code_editor/lib/src/extension.dart +0 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flutter/flet_code_editor/lib/src/utils/code_editor.dart +0 -0
- {flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flutter/flet_code_editor/pubspec.yaml +0 -0
{flet_code_editor-0.85.0.dev0/src/flet_code_editor.egg-info → flet_code_editor-0.85.0.dev1}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flet-code-editor
|
|
3
|
-
Version: 0.85.0.
|
|
3
|
+
Version: 0.85.0.dev1
|
|
4
4
|
Summary: Edit and highlight source code inside Flet apps.
|
|
5
5
|
Author-email: Flet contributors <hello@flet.dev>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -11,7 +11,7 @@ Project-URL: Issues, https://github.com/flet-dev/flet/issues
|
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: flet==0.85.0.
|
|
14
|
+
Requires-Dist: flet==0.85.0.dev1
|
|
15
15
|
Dynamic: license-file
|
|
16
16
|
|
|
17
17
|
# flet-code-editor
|
|
@@ -47,4 +47,4 @@ To install the `flet-code-editor` package and add it to your project dependencie
|
|
|
47
47
|
|
|
48
48
|
### Examples
|
|
49
49
|
|
|
50
|
-
For examples, see [these](https://github.com/flet-dev/flet/tree/main/examples/
|
|
50
|
+
For examples, see [these](https://github.com/flet-dev/flet/tree/main/sdk/python/examples/extensions/code_editor).
|
|
@@ -31,4 +31,4 @@ To install the `flet-code-editor` package and add it to your project dependencie
|
|
|
31
31
|
|
|
32
32
|
### Examples
|
|
33
33
|
|
|
34
|
-
For examples, see [these](https://github.com/flet-dev/flet/tree/main/examples/
|
|
34
|
+
For examples, see [these](https://github.com/flet-dev/flet/tree/main/sdk/python/examples/extensions/code_editor).
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "flet-code-editor"
|
|
3
|
-
version = "0.85.0.
|
|
3
|
+
version = "0.85.0.dev1"
|
|
4
4
|
description = "Edit and highlight source code inside Flet apps."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Flet contributors", email = "hello@flet.dev" }]
|
|
7
7
|
license = "Apache-2.0"
|
|
8
8
|
requires-python = ">=3.10"
|
|
9
9
|
dependencies = [
|
|
10
|
-
"flet==0.85.0.
|
|
10
|
+
"flet==0.85.0.dev1",
|
|
11
11
|
]
|
|
12
12
|
|
|
13
13
|
[project.urls]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from flet_code_editor.code_editor import CodeEditor
|
|
2
|
+
from flet_code_editor.types import (
|
|
3
|
+
CodeLanguage,
|
|
4
|
+
CodeTheme,
|
|
5
|
+
CustomCodeTheme,
|
|
6
|
+
GutterStyle,
|
|
7
|
+
Issue,
|
|
8
|
+
IssueType,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"CodeEditor",
|
|
13
|
+
"CodeLanguage",
|
|
14
|
+
"CodeTheme",
|
|
15
|
+
"CustomCodeTheme",
|
|
16
|
+
"GutterStyle",
|
|
17
|
+
"Issue",
|
|
18
|
+
"IssueType",
|
|
19
|
+
]
|
{flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1}/src/flet_code_editor/code_editor.py
RENAMED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
from dataclasses import field
|
|
1
2
|
from typing import Optional, Union
|
|
2
3
|
|
|
3
4
|
import flet as ft
|
|
4
|
-
from flet_code_editor.types import
|
|
5
|
+
from flet_code_editor.types import (
|
|
6
|
+
CodeLanguage,
|
|
7
|
+
CodeTheme,
|
|
8
|
+
CustomCodeTheme,
|
|
9
|
+
GutterStyle,
|
|
10
|
+
Issue,
|
|
11
|
+
)
|
|
5
12
|
|
|
6
13
|
__all__ = ["CodeEditor"]
|
|
7
14
|
|
|
@@ -46,6 +53,9 @@ class CodeEditor(ft.LayoutControl):
|
|
|
46
53
|
autocomplete_words: Optional[list[str]] = None
|
|
47
54
|
"""Words offered by autocomplete."""
|
|
48
55
|
|
|
56
|
+
issues: list[Issue] = field(default_factory=list)
|
|
57
|
+
"""List of code analysis issues to display in the editor gutter."""
|
|
58
|
+
|
|
49
59
|
read_only: Optional[bool] = False
|
|
50
60
|
"""Whether the editor is read-only."""
|
|
51
61
|
|
|
@@ -4,7 +4,14 @@ from typing import Optional
|
|
|
4
4
|
import flet as ft
|
|
5
5
|
from flet.controls.core.markdown import MarkdownCodeTheme, MarkdownCustomCodeTheme
|
|
6
6
|
|
|
7
|
-
__all__ = [
|
|
7
|
+
__all__ = [
|
|
8
|
+
"CodeLanguage",
|
|
9
|
+
"CodeTheme",
|
|
10
|
+
"CustomCodeTheme",
|
|
11
|
+
"GutterStyle",
|
|
12
|
+
"Issue",
|
|
13
|
+
"IssueType",
|
|
14
|
+
]
|
|
8
15
|
|
|
9
16
|
|
|
10
17
|
class CodeLanguage(Enum):
|
|
@@ -846,3 +853,36 @@ class GutterStyle:
|
|
|
846
853
|
|
|
847
854
|
show_line_numbers: bool = True
|
|
848
855
|
"""Whether to show line numbers in the gutter."""
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
class IssueType(Enum):
|
|
859
|
+
"""Severity level of a code analysis issue."""
|
|
860
|
+
|
|
861
|
+
ERROR = "error"
|
|
862
|
+
"""Error severity."""
|
|
863
|
+
|
|
864
|
+
WARNING = "warning"
|
|
865
|
+
"""Warning severity."""
|
|
866
|
+
|
|
867
|
+
INFO = "info"
|
|
868
|
+
"""Informational severity."""
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
@ft.value
|
|
872
|
+
class Issue:
|
|
873
|
+
"""A code analysis issue displayed in the editor gutter."""
|
|
874
|
+
|
|
875
|
+
line: int = 0
|
|
876
|
+
"""0-indexed line number where the issue occurs."""
|
|
877
|
+
|
|
878
|
+
message: str = ""
|
|
879
|
+
"""Description of the issue."""
|
|
880
|
+
|
|
881
|
+
type: Optional[IssueType] = None
|
|
882
|
+
"""Severity level: error, warning, or info."""
|
|
883
|
+
|
|
884
|
+
suggestion: Optional[str] = None
|
|
885
|
+
"""Optional suggested fix."""
|
|
886
|
+
|
|
887
|
+
url: Optional[str] = None
|
|
888
|
+
"""Optional URL for more information."""
|
{flet_code_editor-0.85.0.dev0 → flet_code_editor-0.85.0.dev1/src/flet_code_editor.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flet-code-editor
|
|
3
|
-
Version: 0.85.0.
|
|
3
|
+
Version: 0.85.0.dev1
|
|
4
4
|
Summary: Edit and highlight source code inside Flet apps.
|
|
5
5
|
Author-email: Flet contributors <hello@flet.dev>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -11,7 +11,7 @@ Project-URL: Issues, https://github.com/flet-dev/flet/issues
|
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: flet==0.85.0.
|
|
14
|
+
Requires-Dist: flet==0.85.0.dev1
|
|
15
15
|
Dynamic: license-file
|
|
16
16
|
|
|
17
17
|
# flet-code-editor
|
|
@@ -47,4 +47,4 @@ To install the `flet-code-editor` package and add it to your project dependencie
|
|
|
47
47
|
|
|
48
48
|
### Examples
|
|
49
49
|
|
|
50
|
-
For examples, see [these](https://github.com/flet-dev/flet/tree/main/examples/
|
|
50
|
+
For examples, see [these](https://github.com/flet-dev/flet/tree/main/sdk/python/examples/extensions/code_editor).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flet==0.85.0.dev1
|
|
@@ -198,21 +198,65 @@ class _CodeEditorControlState extends State<CodeEditorControl> {
|
|
|
198
198
|
_controller.popupController.hide();
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
// Apply issues from Python side
|
|
202
|
+
final issuesList = widget.control.get("issues");
|
|
203
|
+
final List<fce.Issue> parsedIssues;
|
|
204
|
+
if (issuesList is List) {
|
|
205
|
+
parsedIssues = issuesList
|
|
206
|
+
.whereType<Map>()
|
|
207
|
+
.map((item) => fce.Issue(
|
|
208
|
+
line: parseInt(item["line"]) ?? 0,
|
|
209
|
+
message: item["message"]?.toString() ?? "",
|
|
210
|
+
type: parseEnum(fce.IssueType.values, item["type"]?.toString(), fce.IssueType.error)!,
|
|
211
|
+
suggestion: item["suggestion"]?.toString(),
|
|
212
|
+
url: item["url"]?.toString(),
|
|
213
|
+
))
|
|
214
|
+
.toList();
|
|
215
|
+
} else {
|
|
216
|
+
parsedIssues = const [];
|
|
217
|
+
}
|
|
218
|
+
final prevIssueCount = _controller.analysisResult.issues.length;
|
|
219
|
+
if (parsedIssues.length != prevIssueCount || parsedIssues.isNotEmpty) {
|
|
220
|
+
_controller.removeListener(_handleControllerChange);
|
|
221
|
+
_controller.setIssues(fce.AnalysisResult(issues: parsedIssues));
|
|
222
|
+
_controller.addListener(_handleControllerChange);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
Widget buildEditor({double? minHeight}) {
|
|
226
|
+
Widget editor = SingleChildScrollView(
|
|
227
|
+
child: ConstrainedBox(
|
|
228
|
+
constraints: BoxConstraints(minHeight: minHeight ?? 0),
|
|
202
229
|
child: fce.CodeField(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
230
|
+
controller: _controller,
|
|
231
|
+
focusNode: _focusNode,
|
|
232
|
+
readOnly: widget.control.getBool("read_only", false)!,
|
|
233
|
+
textStyle:
|
|
234
|
+
widget.control.getTextStyle("text_style", Theme.of(context)),
|
|
235
|
+
gutterStyle: gutterStyle,
|
|
236
|
+
padding: widget.control.getEdgeInsets("padding", EdgeInsets.zero)!,
|
|
237
|
+
enabled: !widget.control.disabled,
|
|
238
|
+
),
|
|
239
|
+
));
|
|
240
|
+
|
|
241
|
+
if (themeData != null) {
|
|
242
|
+
editor = fce.CodeTheme(data: themeData, child: editor);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return editor;
|
|
246
|
+
}
|
|
211
247
|
|
|
212
|
-
|
|
213
|
-
|
|
248
|
+
final isExpanded = widget.control.getExpand("expand") != null;
|
|
249
|
+
|
|
250
|
+
Widget child;
|
|
251
|
+
if (isExpanded) {
|
|
252
|
+
child = LayoutBuilder(
|
|
253
|
+
builder: (context, constraints) =>
|
|
254
|
+
buildEditor(minHeight: constraints.maxHeight),
|
|
255
|
+
);
|
|
256
|
+
} else {
|
|
257
|
+
child = buildEditor();
|
|
214
258
|
}
|
|
215
259
|
|
|
216
|
-
return LayoutControl(control: widget.control, child:
|
|
260
|
+
return LayoutControl(control: widget.control, child: child);
|
|
217
261
|
}
|
|
218
262
|
}
|
|
@@ -9,6 +9,16 @@ class FletCodeController extends fce.CodeController {
|
|
|
9
9
|
|
|
10
10
|
bool autocompletionEnabled = false;
|
|
11
11
|
|
|
12
|
+
@override
|
|
13
|
+
Future<void> analyzeCode() async {
|
|
14
|
+
// Analysis is handled by the Python side via the issues property.
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void setIssues(fce.AnalysisResult result) {
|
|
18
|
+
analysisResult = result;
|
|
19
|
+
notifyListeners();
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
@override
|
|
13
23
|
Future<void> generateSuggestions() async {
|
|
14
24
|
if (!autocompletionEnabled) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
flet==0.85.0.dev0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|