-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 NEW Text Filtering Panel, just click the
expand icon
on the `All …
…Texts` Panel.
- Loading branch information
Showing
21 changed files
with
817 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
enum TextType { code, url, word, sentence, paragraph } | ||
|
||
TextType determineTextType(String text) { | ||
// Check if the text is code | ||
if (isCode(text)) { | ||
return TextType.code; | ||
} | ||
|
||
// Check if the text is a URL | ||
if (Uri.tryParse(text)?.isAbsolute ?? false) { | ||
return TextType.url; | ||
} | ||
|
||
// Check if the text is a single word | ||
if (!text.trim().contains(' ')) { | ||
return TextType.word; | ||
} | ||
|
||
// Check if the text is a single sentence | ||
if (text.endsWith('.') || text.endsWith('!') || text.endsWith('?')) { | ||
return TextType.sentence; | ||
} | ||
|
||
// If none of the above conditions are met, consider it a paragraph | ||
return TextType.paragraph; | ||
} | ||
|
||
bool isCode(String text) { | ||
// Check for keywords and punctuation common in code. | ||
final keywords = RegExp( | ||
r"\b(if|else|for|while|try|except|def|class|return|import|from|print)\b"); | ||
final punctuation = RegExp(r"[{}()\[\];,.<>?:]+"); | ||
final operators = RegExp(r"[+\-*/%|=!<>&]"); | ||
|
||
// Check for presence of keywords, punctuation, and operators. | ||
if (keywords.hasMatch(text) || | ||
punctuation.hasMatch(text) || | ||
operators.hasMatch(text)) { | ||
return true; | ||
} | ||
|
||
// Check for specific patterns like comments or imports. | ||
if (RegExp(r"#.*").hasMatch(text) || RegExp(r"import\s+.*").hasMatch(text)) { | ||
return true; | ||
} | ||
|
||
// If none of the above patterns are found, the text is likely not code. | ||
return false; | ||
} |
2 changes: 1 addition & 1 deletion
2
lib/app/powermode/presentation/dialogs/daemon_manager_dialog.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
lib/app/powermode/presentation/dialogs/entity_info_dialog.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/app/powermode/presentation/dialogs/power_mode_settings.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.