Skip to content

Commit 51dbeea

Browse files
authored
Issue 172: Delete CodeController.theme, bump version to 0.3.0 (akvelon#247)
* removed _styleRegExp and theme (akvelon#172) * Bump version to v0.3.0 * deleted new lines * RC
1 parent 158bc18 commit 51dbeea

File tree

3 files changed

+6
-51
lines changed

3 files changed

+6
-51
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.3.0
2+
3+
* **BREAKING:** Deleted `CodeController.stringMap`.
4+
* **BREAKING:** Deleted `theme` from `CodeController`, (Issue [172](https://github.com/akvelon/flutter-code-editor/issues/172)).
5+
16
## 0.2.24
27

38
* Hide the suggestion box when `CodeField` is disposed (Issue [241](https://github.com/akvelon/flutter-code-editor/issues/241)).

lib/src/code_field/code_controller.dart

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ class CodeController extends TextEditingController {
6969
/// A map of specific regexes to style
7070
final Map<String, TextStyle>? patternMap;
7171

72-
/// A map of specific keywords to style
73-
final Map<String, TextStyle>? stringMap;
74-
7572
/// Common editor params such as the size of a tab in spaces
7673
///
7774
/// Will be exposed to all [modifiers]
@@ -101,7 +98,6 @@ class CodeController extends TextEditingController {
10198

10299
final _styleList = <TextStyle>[];
103100
final _modifierMap = <String, CodeModifier>{};
104-
RegExp? _styleRegExp;
105101
late PopupController popupController;
106102
final autocompleter = Autocompleter();
107103
late final historyController = CodeHistoryController(codeController: this);
@@ -143,12 +139,9 @@ class CodeController extends TextEditingController {
143139
this.namedSectionParser,
144140
Set<String> readOnlySectionNames = const {},
145141
Set<String> visibleSectionNames = const {},
146-
@Deprecated('Use CodeTheme widget to provide theme to CodeField.')
147-
Map<String, TextStyle>? theme,
148142
this.analysisResult = const AnalysisResult(issues: []),
149143
this.patternMap,
150144
this.readOnly = false,
151-
this.stringMap,
152145
this.params = const EditorParams(),
153146
this.modifiers = const [
154147
IndentModifier(),
@@ -178,15 +171,10 @@ class CodeController extends TextEditingController {
178171

179172
// Build styleRegExp
180173
final patternList = <String>[];
181-
if (stringMap != null) {
182-
patternList.addAll(stringMap!.keys.map((e) => r'(\b' + e + r'\b)'));
183-
_styleList.addAll(stringMap!.values);
184-
}
185174
if (patternMap != null) {
186175
patternList.addAll(patternMap!.keys.map((e) => '($e)'));
187176
_styleList.addAll(patternMap!.values);
188177
}
189-
_styleRegExp = RegExp(patternList.join('|'), multiLine: true);
190178

191179
popupController = PopupController(onCompletionSelected: insertSelectedWord);
192180

@@ -911,47 +899,9 @@ class CodeController extends TextEditingController {
911899
).build();
912900
}
913901

914-
if (_styleRegExp != null) {
915-
return _processPatterns(text, style);
916-
}
917-
918902
return TextSpan(text: text, style: style);
919903
}
920904

921-
TextSpan _processPatterns(String text, TextStyle? style) {
922-
final children = <TextSpan>[];
923-
924-
text.splitMapJoin(
925-
_styleRegExp!,
926-
onMatch: (Match m) {
927-
if (_styleList.isEmpty) {
928-
return '';
929-
}
930-
931-
int idx;
932-
for (idx = 1;
933-
idx < m.groupCount &&
934-
idx <= _styleList.length &&
935-
m.group(idx) == null;
936-
idx++) {}
937-
938-
children.add(
939-
TextSpan(
940-
text: m[0],
941-
style: _styleList[idx - 1],
942-
),
943-
);
944-
return '';
945-
},
946-
onNonMatch: (String span) {
947-
children.add(TextSpan(text: span, style: style));
948-
return '';
949-
},
950-
);
951-
952-
return TextSpan(style: style, children: children);
953-
}
954-
955905
CodeThemeData _getTheme(BuildContext context) {
956906
return CodeTheme.of(context) ?? CodeThemeData();
957907
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_code_editor
22
description: A customizable code field supporting syntax highlighting and code folding.
3-
version: 0.2.24
3+
version: 0.3.0
44
repository: https://github.com/akvelon/flutter-code-editor
55

66
environment:

0 commit comments

Comments
 (0)