-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add monarch support for sora-editor #580
Open
dingyi222666
wants to merge
28
commits into
Rosemoe:main
Choose a base branch
from
dingyi222666:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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 commit adds support for the Monarch language system, including the implementation of MonarchGrammarDefinitionDSL for grammar definition, and updates to the language-monarch module to handle language loading and configuration. Theme support for Monarch is also introduced, allowing for dark and light mode theming consistency with TextMate.
Themes now load colors asynchronously, which prevents blocking the main thread when parsing and applying theme settings. This optimization enhances the overall performance andresponsiveness of the application when switching or initializing themes. The TokenTheme adapter was updated to handle the asynchronous loading of theme colors. MonarchColorScheme was modified to apply themes more efficiently, especially when dealing with legacy TextMate themes. Additionally, the theme registration and management logic was refactored to ensure themes are loaded only when necessary.
…kens Adjust the theme loading function to collect colors into a map when provided with a nullthemeColorsMap. This change simplifies theme loading logic and avoids unnecessary skipping of values. Additionally, modify the token color reading function to add a default empty token, ensuring that at least one token is always present. This prevents potential runtime issues due to empty token lists.
consistency and adhere to coding standards.
…x implementation Update the regex libraries to the latest versions and modify the implementation in the MonarchLanguage class to support the additional regex features. Additionally, refactor the JSON parsing logic in the AutoClosingPairConditional loading process for better clarity.
- Remove unnecessary logging statements in AsyncIncrementalAnalyzeManager to clean up the code. - Adjust if-statement formatting for consistency and better readability. - Eliminate unused code segments in JsonParseTests and adjust import statements. - Ensure consistent code formatting across the specified files for enhanced maintainability.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the monarch to sora-editor.
Introduction
Monarch is a lightweight, declarative lexical specification-based syntax highlighter designed by the VSCode development team. The main purpose of introducing this library is to leverage Monarch's concise syntax definition and loading speed. Compared to the TextMate module, it offers a 10% - 40% speed advantage when rendering large text code, making it suitable for scenarios that don't require complex highlighting effects but desire dynamically loaded syntax highlighting with a certain level of speed.
Usage
Refer to MainActivity.kt for usage, similar to
lang-textmate
.Screenshots and Comparison
Monarch effect and rendering time for View.java
output1.mp4
TextMate effect and rendering time for View.java
output.mp4
Other
This PR also implements VSCode theme loading and grammar repository abstraction, which may be useful in the future when rewriting the
lang-textmate
module to Kotlin implementation.