├── .github ├── jetbrains-variant-3.png └── workflows │ └── gradle.yml ├── .gitignore ├── .idea ├── .gitignore ├── .name ├── copyright │ ├── LGPL.xml │ ├── profiles_settings.xml │ └── tm4e_EPL.xml └── scopes │ └── tm4e_epl_licensed.xml ├── LICENSE ├── README.es.md ├── README.jp.md ├── README.md ├── README.zh-cn.md ├── app ├── .gitignore ├── build.gradle.kts ├── libs │ └── EmmyLua-LS-all.jar ├── proguard-rules.pro ├── release │ └── output-metadata.json └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── JetBrainsMono-Regular.ttf │ ├── Roboto-Regular.ttf │ ├── Ubuntu-Regular.ttf │ ├── samples │ │ ├── big_sample.txt │ │ └── sample.txt │ ├── testProject │ │ ├── sample.lua │ │ └── std │ │ │ └── Lua53 │ │ │ ├── builtin.lua │ │ │ ├── coroutine.lua │ │ │ ├── debug.lua │ │ │ ├── global.lua │ │ │ ├── io.lua │ │ │ ├── math.lua │ │ │ ├── os.lua │ │ │ ├── package.lua │ │ │ ├── string.lua │ │ │ ├── table.lua │ │ │ └── utf8.lua │ ├── textmate │ │ ├── abyss.json │ │ ├── darcula.json │ │ ├── html │ │ │ ├── language-configuration.json │ │ │ └── syntaxes │ │ │ │ └── html.tmLanguage.json │ │ ├── java │ │ │ ├── language-configuration.json │ │ │ └── syntaxes │ │ │ │ └── java.tmLanguage.json │ │ ├── javascript │ │ │ ├── language-configuration.json │ │ │ └── syntaxes │ │ │ │ └── JavaScript.tmLanguage.json │ │ ├── kotlin │ │ │ ├── language-configuration.json │ │ │ └── syntaxes │ │ │ │ └── Kotlin.tmLanguage │ │ ├── languages.json │ │ ├── lua │ │ │ ├── language-configuration.json │ │ │ └── syntaxes │ │ │ │ └── lua.tmLanguage.json │ │ ├── markdown │ │ │ ├── language-configuration.json │ │ │ └── syntaxes │ │ │ │ └── markdown.tmLanguage.json │ │ ├── python │ │ │ ├── language-configuration.json │ │ │ └── syntaxes │ │ │ │ └── python.tmLanguage.json │ │ ├── quietlight.json │ │ ├── solarized_dark.json │ │ └── xml │ │ │ ├── language-configuration.json │ │ │ └── syntaxes │ │ │ └── xml.tmLanguage.json │ └── tree-sitter-queries │ │ └── java │ │ ├── blocks.scm │ │ ├── brackets.scm │ │ ├── highlights.scm │ │ └── locals.scm │ ├── java │ └── io │ │ └── github │ │ └── rosemoe │ │ └── sora │ │ ├── app │ │ ├── LspLanguageServerService.kt │ │ ├── LspTestActivity.kt │ │ ├── LspTestJavaActivity.java │ │ ├── MainActivity.kt │ │ ├── Utils.kt │ │ └── tests │ │ │ └── TestActivity.kt │ │ ├── lang │ │ └── langJava.kt │ │ └── utils │ │ ├── CrashHandler.java │ │ ├── stringUtils.kt │ │ └── toastUtils.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ ├── ic_launcher_background.xml │ ├── redo.xml │ ├── scrollbar_thumb.xml │ ├── scrollbar_track.xml │ └── undo.xml │ ├── layout │ └── activity_main.xml │ ├── menu │ ├── menu_lsp.xml │ ├── menu_main.xml │ └── menu_search_options.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── box_red.png │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── values-night │ └── styles.xml │ ├── values-zh │ └── strings.xml │ ├── values │ ├── strings.xml │ └── styles.xml │ └── xml │ └── network_security_config.xml ├── bom └── build.gradle.kts ├── build-logic ├── convention │ ├── .gitignore │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ ├── CI.kt │ │ ├── Versions.kt │ │ └── build-logic.root-project.gradle.kts ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties └── settings.gradle.kts ├── build.gradle.kts ├── debug.jks ├── editor-lsp ├── .gitignore ├── README.md ├── build.gradle.kts ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── io │ │ └── github │ │ └── rosemoe │ │ └── sora │ │ └── lsp │ │ ├── client │ │ ├── ClientContext.kt │ │ ├── DefaultLanguageClient.kt │ │ ├── ServerWrapperBaseClientContext.kt │ │ ├── connection │ │ │ ├── CustomConnectProvider.kt │ │ │ ├── SocketStreamConnectionProvider.kt │ │ │ └── StreamConnectionProvider.kt │ │ └── languageserver │ │ │ ├── ServerInitializeListener.kt │ │ │ ├── ServerStatus.kt │ │ │ ├── requestmanager │ │ │ ├── DefaultRequestManager.kt │ │ │ └── RequestManager.kt │ │ │ ├── serverdefinition │ │ │ ├── CustomLanguageServerDefinition.kt │ │ │ └── LanguageServerDefinition.kt │ │ │ └── wrapper │ │ │ ├── EventHandler.kt │ │ │ └── LanguageServerWrapper.kt │ │ ├── editor │ │ ├── LspEditor.kt │ │ ├── LspEventManager.kt │ │ ├── LspLanguage.kt │ │ ├── LspProject.kt │ │ ├── completion │ │ │ ├── CompletionItemProvider.kt │ │ │ └── LspCompletionItem.kt │ │ ├── diagnostics │ │ │ └── DiagnosticsContainer.kt │ │ ├── event │ │ │ └── LspEditorContentChangeEventReceiver.kt │ │ ├── format │ │ │ └── LspFormatter.kt │ │ └── signature │ │ │ └── SignatureHelpWindow.kt │ │ ├── events │ │ ├── EventEmitter.kt │ │ ├── completion │ │ │ └── CompletionEvent.kt │ │ ├── diagnostics │ │ │ ├── PublishDiagnosticsEvent.kt │ │ │ └── QueryDocumentDiagnosticsEvent.kt │ │ ├── document │ │ │ ├── ApplyEditsEvent.kt │ │ │ ├── DocumentChangeEvent.kt │ │ │ ├── DocumentCloseEvent.kt │ │ │ ├── DocumentOpenEvent.kt │ │ │ └── DocumentSaveEvent.kt │ │ ├── format │ │ │ ├── FullFormattingEvent.kt │ │ │ └── RangeFormattingEvent.kt │ │ └── signature │ │ │ └── SignatureHelpEvent.kt │ │ ├── requests │ │ └── Timeout.kt │ │ └── utils │ │ ├── LSPException.kt │ │ ├── LspUtils.kt │ │ └── URIUtils.kt │ └── res │ ├── drawable │ └── signature_tooltip_background.xml │ └── layout │ └── signature_help_tooltip_window.xml ├── editor ├── .gitignore ├── build.gradle.kts ├── consumer-rules.pro ├── gradle.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── io │ │ └── github │ │ └── rosemoe │ │ └── sora │ │ └── text │ │ └── ContentTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── io │ │ │ └── github │ │ │ └── rosemoe │ │ │ └── sora │ │ │ ├── I18nConfig.java │ │ │ ├── annotations │ │ │ ├── Experimental.java │ │ │ ├── InvalidateRequired.java │ │ │ └── UnsupportedUserUsage.java │ │ │ ├── data │ │ │ └── ObjectAllocator.java │ │ │ ├── event │ │ │ ├── ClickEvent.java │ │ │ ├── ColorSchemeUpdateEvent.kt │ │ │ ├── ContentChangeEvent.java │ │ │ ├── DoubleClickEvent.java │ │ │ ├── EditorKeyEvent.java │ │ │ ├── EditorMotionEvent.java │ │ │ ├── Event.java │ │ │ ├── EventManager.java │ │ │ ├── EventReceiver.java │ │ │ ├── HandleStateChangeEvent.java │ │ │ ├── InterceptTarget.java │ │ │ ├── KeyBindingEvent.java │ │ │ ├── LongPressEvent.java │ │ │ ├── ResultedEvent.java │ │ │ ├── ScrollEvent.java │ │ │ ├── SelectionChangeEvent.java │ │ │ ├── SideIconClickEvent.kt │ │ │ ├── SnippetEvent.java │ │ │ ├── SubscriptionReceipt.java │ │ │ ├── Unsubscribe.java │ │ │ ├── Utils.kt │ │ │ └── editorMinorEvents.kt │ │ │ ├── graphics │ │ │ ├── BubbleHelper.java │ │ │ ├── BufferedDrawPoints.java │ │ │ ├── CharPosDesc.java │ │ │ ├── GraphicCharacter.java │ │ │ ├── GraphicTextRow.java │ │ │ ├── Paint.java │ │ │ ├── RectUtils.java │ │ │ ├── SingleCharacterWidths.java │ │ │ └── TextRegionIterator.java │ │ │ ├── lang │ │ │ ├── EmptyLanguage.java │ │ │ ├── Language.java │ │ │ ├── QuickQuoteHandler.java │ │ │ ├── analysis │ │ │ │ ├── AnalyzeManager.java │ │ │ │ ├── AsyncIncrementalAnalyzeManager.java │ │ │ │ ├── IncrementalAnalyzeManager.java │ │ │ │ ├── SequenceUpdateRange.kt │ │ │ │ ├── SimpleAnalyzeManager.java │ │ │ │ ├── StyleReceiver.java │ │ │ │ └── StyleUpdateRange.kt │ │ │ ├── brackets │ │ │ │ ├── BracketsProvider.java │ │ │ │ ├── OnlineBracketsMatcher.java │ │ │ │ ├── PairedBracket.java │ │ │ │ └── SimpleBracketsCollector.java │ │ │ ├── completion │ │ │ │ ├── CompletionCancelledException.java │ │ │ │ ├── CompletionHelper.java │ │ │ │ ├── CompletionItem.java │ │ │ │ ├── CompletionItemKind.kt │ │ │ │ ├── CompletionPublisher.java │ │ │ │ ├── IdentifierAutoComplete.java │ │ │ │ ├── MatchHelper.java │ │ │ │ ├── SimpleCompletionIconDrawer.kt │ │ │ │ ├── SimpleCompletionItem.java │ │ │ │ ├── SimpleSnippetCompletionItem.java │ │ │ │ ├── SnippetDescription.kt │ │ │ │ ├── comparators.kt │ │ │ │ ├── filters.kt │ │ │ │ └── snippet │ │ │ │ │ ├── CodeSnippet.java │ │ │ │ │ ├── ConditionalFormat.java │ │ │ │ │ ├── FormatString.java │ │ │ │ │ ├── InterpolatedShellItem.java │ │ │ │ │ ├── NextUpperCaseFormat.java │ │ │ │ │ ├── NoFormat.java │ │ │ │ │ ├── PlaceHolderElement.kt │ │ │ │ │ ├── PlaceholderDefinition.kt │ │ │ │ │ ├── PlaceholderItem.java │ │ │ │ │ ├── PlainPlaceholderElement.kt │ │ │ │ │ ├── PlainTextItem.java │ │ │ │ │ ├── SnippetItem.java │ │ │ │ │ ├── Transform.java │ │ │ │ │ ├── VariableItem.java │ │ │ │ │ └── parser │ │ │ │ │ ├── CodeSnippetParser.java │ │ │ │ │ ├── CodeSnippetTokenizer.java │ │ │ │ │ ├── Token.java │ │ │ │ │ └── TokenType.java │ │ │ ├── diagnostic │ │ │ │ ├── DiagnosticDetail.kt │ │ │ │ ├── DiagnosticRegion.java │ │ │ │ ├── DiagnosticsContainer.java │ │ │ │ └── Quickfix.kt │ │ │ ├── folding │ │ │ │ └── FoldingRegion.java │ │ │ ├── format │ │ │ │ ├── AsyncFormatter.java │ │ │ │ └── Formatter.java │ │ │ ├── smartEnter │ │ │ │ ├── NewlineHandleResult.java │ │ │ │ └── NewlineHandler.java │ │ │ ├── styling │ │ │ │ ├── BlocksUpdater.java │ │ │ │ ├── CodeBlock.java │ │ │ │ ├── EmptyReader.java │ │ │ │ ├── MappedSpanUpdater.java │ │ │ │ ├── MappedSpans.java │ │ │ │ ├── Span.java │ │ │ │ ├── SpanFactory.java │ │ │ │ ├── SpanPool.kt │ │ │ │ ├── Spans.java │ │ │ │ ├── Styles.java │ │ │ │ ├── StylesUtils.java │ │ │ │ ├── TextStyle.java │ │ │ │ ├── TextStyle.kt │ │ │ │ ├── color │ │ │ │ │ ├── ConstColor.kt │ │ │ │ │ ├── EditorColor.kt │ │ │ │ │ └── ResolvableColor.kt │ │ │ │ ├── inlayHint │ │ │ │ │ ├── InlayHint.kt │ │ │ │ │ ├── InlayHintLayoutType.kt │ │ │ │ │ ├── SparseUpdateRange.kt │ │ │ │ │ └── TextInlayHint.kt │ │ │ │ ├── line │ │ │ │ │ ├── LineAnchorStyle.kt │ │ │ │ │ ├── LineBackground.kt │ │ │ │ │ ├── LineGutterBackground.kt │ │ │ │ │ ├── LineSideIcon.kt │ │ │ │ │ └── LineStyles.kt │ │ │ │ └── span │ │ │ │ │ ├── SpanClickableUrl.kt │ │ │ │ │ ├── SpanColorResolver.kt │ │ │ │ │ ├── SpanConstColorResolver.kt │ │ │ │ │ ├── SpanExt.kt │ │ │ │ │ ├── SpanExtAttrs.java │ │ │ │ │ ├── SpanExternalRenderer.kt │ │ │ │ │ ├── SpanInteractionInfo.kt │ │ │ │ │ └── internal │ │ │ │ │ └── SpanImpl.java │ │ │ └── util │ │ │ │ ├── BaseAnalyzeManager.java │ │ │ │ ├── PlainTextAnalyzeManager.java │ │ │ │ └── PlainTextSpans.java │ │ │ ├── text │ │ │ ├── AndroidEmoji.java │ │ │ ├── CachedIndexer.java │ │ │ ├── CharArrayWrapper.java │ │ │ ├── CharPosition.java │ │ │ ├── CharSequenceIterator.java │ │ │ ├── ComposingText.java │ │ │ ├── Content.java │ │ │ ├── Content.kt │ │ │ ├── ContentIO.java │ │ │ ├── ContentLine.java │ │ │ ├── ContentListener.java │ │ │ ├── ContentReference.java │ │ │ ├── Cursor.java │ │ │ ├── FunctionCharacters.java │ │ │ ├── ICUUtils.java │ │ │ ├── Indexer.java │ │ │ ├── InsertTextHelper.java │ │ │ ├── LineNumberCalculator.java │ │ │ ├── LineSeparator.java │ │ │ ├── SpanRecycler.java │ │ │ ├── TextLayoutHelper.java │ │ │ ├── TextRange.java │ │ │ ├── TextReference.java │ │ │ ├── TextUtils.java │ │ │ ├── TextUtilsP.java │ │ │ ├── UndoManager.java │ │ │ ├── UnicodeIterator.java │ │ │ ├── bidi │ │ │ │ ├── BidiRequirementChecker.java │ │ │ │ ├── ContentBidi.java │ │ │ │ ├── Directions.java │ │ │ │ └── TextBidi.java │ │ │ └── method │ │ │ │ └── KeyMetaStates.java │ │ │ ├── util │ │ │ ├── ArrayList.java │ │ │ ├── BinaryHeap.java │ │ │ ├── BlockIntList.java │ │ │ ├── CharCode.kt │ │ │ ├── Chars.kt │ │ │ ├── ClipDataUtils.java │ │ │ ├── EditorHandler.kt │ │ │ ├── Floats.java │ │ │ ├── IntPair.java │ │ │ ├── KeyboardUtils.kt │ │ │ ├── Logger.java │ │ │ ├── LongArrayList.java │ │ │ ├── MutableInt.java │ │ │ ├── MyCharacter.java │ │ │ ├── Numbers.java │ │ │ ├── ObjectPool.java │ │ │ ├── RegionIterator.java │ │ │ ├── RendererUtils.kt │ │ │ ├── SegmentList.java │ │ │ ├── ShareableData.kt │ │ │ ├── TemporaryCharBuffer.java │ │ │ ├── TemporaryFloatBuffer.java │ │ │ ├── ThemeUtils.java │ │ │ ├── TrieTree.java │ │ │ ├── ViewUtils.java │ │ │ └── regex │ │ │ │ ├── RegexBackrefGrammar.java │ │ │ │ ├── RegexBackrefHelper.java │ │ │ │ ├── RegexBackrefParser.java │ │ │ │ └── RegexBackrefToken.java │ │ │ └── widget │ │ │ ├── CodeEditor.java │ │ │ ├── CursorBlink.java │ │ │ ├── DirectAccessProps.java │ │ │ ├── Editor.kt │ │ │ ├── EditorInputConnection.java │ │ │ ├── EditorKeyEventHandler.java │ │ │ ├── EditorRenderer.java │ │ │ ├── EditorScroller.java │ │ │ ├── EditorSearcher.java │ │ │ ├── EditorStyleDelegate.java │ │ │ ├── EditorTouchEventHandler.java │ │ │ ├── LanguageHelper.java │ │ │ ├── RegionResolver.kt │ │ │ ├── SelectionMovement.kt │ │ │ ├── SymbolInputView.java │ │ │ ├── SymbolPairMatch.java │ │ │ ├── base │ │ │ └── EditorPopupWindow.java │ │ │ ├── component │ │ │ ├── CompletionLayout.java │ │ │ ├── DefaultCompletionItemAdapter.java │ │ │ ├── DefaultCompletionLayout.java │ │ │ ├── EditorAutoCompletion.java │ │ │ ├── EditorBuiltinComponent.java │ │ │ ├── EditorCompletionAdapter.java │ │ │ ├── EditorContextMenuCreator.kt │ │ │ ├── EditorDiagnosticTooltipWindow.kt │ │ │ ├── EditorTextActionWindow.java │ │ │ └── Magnifier.java │ │ │ ├── ext │ │ │ └── EditorSpanInteractionHandler.kt │ │ │ ├── layout │ │ │ ├── AbstractLayout.java │ │ │ ├── BidiLayoutHelper.kt │ │ │ ├── Layout.java │ │ │ ├── LineBreakLayout.java │ │ │ ├── Row.java │ │ │ ├── RowIterator.java │ │ │ ├── ViewMeasureHelper.java │ │ │ └── WordwrapLayout.java │ │ │ ├── rendering │ │ │ ├── MeasureCacheItem.kt │ │ │ ├── RenderCache.kt │ │ │ ├── RenderContext.kt │ │ │ ├── RenderNodeHolder.kt │ │ │ ├── RenderingConstants.java │ │ │ └── package-info.java │ │ │ ├── schemes │ │ │ ├── EditorColorScheme.java │ │ │ ├── SchemeDarcula.java │ │ │ ├── SchemeEclipse.java │ │ │ ├── SchemeGitHub.java │ │ │ ├── SchemeNotepadXX.java │ │ │ └── SchemeVS2019.java │ │ │ ├── snippet │ │ │ ├── SnippetController.kt │ │ │ ├── TransformApplier.java │ │ │ └── variable │ │ │ │ ├── ClipboardBasedSnippetVariableResolver.java │ │ │ │ ├── CommentBasedSnippetVariableResolver.java │ │ │ │ ├── CompositeSnippetVariableResolver.java │ │ │ │ ├── EditorBasedSnippetVariableResolver.java │ │ │ │ ├── FileBasedSnippetVariableResolver.java │ │ │ │ ├── ISnippetVariableResolver.java │ │ │ │ ├── RandomBasedSnippetVariableResolver.java │ │ │ │ ├── TimeBasedSnippetVariableResolver.java │ │ │ │ └── WorkspaceBasedSnippetVariableResolver.java │ │ │ └── style │ │ │ ├── CursorAnimator.java │ │ │ ├── DiagnosticIndicatorStyle.java │ │ │ ├── LineInfoPanelPosition.java │ │ │ ├── LineInfoPanelPositionMode.java │ │ │ ├── LineNumberTipTextProvider.kt │ │ │ ├── SelectionHandleStyle.java │ │ │ └── builtin │ │ │ ├── DefaultLineNumberTip.kt │ │ │ ├── FadeCursorAnimator.java │ │ │ ├── HandleStyleDrop.java │ │ │ ├── HandleStyleSideDrop.java │ │ │ ├── MoveCursorAnimator.java │ │ │ └── ScaleCursorAnimator.java │ └── res │ │ ├── anim │ │ ├── anim_diagnostic_tooltip_window_enter.xml │ │ ├── anim_diagnostic_tooltip_window_exit.xml │ │ ├── anim_text_action_popup_enter.xml │ │ └── anim_text_action_popup_exit.xml │ │ ├── drawable │ │ ├── baseline_more_vert_24.xml │ │ ├── editor_text_select_start.xml │ │ ├── ic_more_vert_black_20dp.xml │ │ ├── ic_sora_handle_drop.xml │ │ ├── magnifier_background.xml │ │ ├── round_content_copy_20.xml │ │ ├── round_content_cut_20.xml │ │ ├── round_content_paste_20.xml │ │ ├── round_save_20.xml │ │ └── round_select_all_20.xml │ │ ├── layout │ │ ├── default_completion_result_item.xml │ │ ├── diagnostic_tooltip_window.xml │ │ ├── magnifier_popup.xml │ │ └── text_compose_panel.xml │ │ ├── values-night │ │ └── colors.xml │ │ ├── values-zh │ │ └── strings.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── style.xml │ └── test │ └── java │ └── io │ └── github │ └── rosemoe │ └── sora │ ├── lang │ └── completion │ │ └── snippet │ │ └── parser │ │ └── CodeSnippetParserTest.kt │ ├── text │ ├── ContentIOTest.kt │ └── ContentShallowCopyTest.kt │ └── util │ └── SegmentListTest.kt ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images ├── editor_banner.jpg ├── general.jpg └── problem_indicators.jpg ├── language-java ├── .gitignore ├── build.gradle.kts ├── consumer-rules.pro ├── gradle.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── io │ │ └── github │ │ └── rosemoe │ │ └── langs │ │ └── java │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── io │ │ └── github │ │ └── rosemoe │ │ └── sora │ │ └── langs │ │ └── java │ │ ├── JavaIncrementalAnalyzeManager.java │ │ ├── JavaLanguage.java │ │ ├── JavaQuoteHandler.java │ │ ├── JavaTextTokenizer.java │ │ ├── State.java │ │ └── Tokens.java │ └── test │ └── java │ └── io │ └── github │ └── rosemoe │ └── langs │ └── java │ └── ExampleUnitTest.java ├── language-monarch ├── .gitignore ├── README.md ├── build.gradle.kts ├── consumer-rules.pro ├── gradle.properties ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── io │ │ └── github │ │ └── rosemoe │ │ └── sora │ │ └── langs │ │ └── monarch │ │ ├── MonarchAnalyzer.kt │ │ ├── MonarchColorScheme.kt │ │ ├── MonarchLanguage.kt │ │ ├── MonarchNewlineHandler.kt │ │ ├── MonarchState.kt │ │ ├── MonarchSymbolPairMatch.kt │ │ ├── folding │ │ ├── FoldingHelper.kt │ │ ├── FoldingRegion.kt │ │ ├── FoldingRegions.kt │ │ ├── IndentRange.kt │ │ ├── PreviousRegion.kt │ │ └── RangesCollector.kt │ │ ├── languageconfiguration │ │ ├── loader.kt │ │ ├── model │ │ │ ├── AutoClosingPair.kt │ │ │ ├── CommentRule.kt │ │ │ ├── CompleteEnterAction.kt │ │ │ ├── EnterAction.kt │ │ │ ├── FoldingMarkers.kt │ │ │ ├── FoldingRules.kt │ │ │ ├── IndentAction.kt │ │ │ ├── IndentationRule.kt │ │ │ ├── LanguageConfiguration.kt │ │ │ └── OnEnterRule.kt │ │ └── support │ │ │ ├── IndentRulesSupport.kt │ │ │ └── OnEnterSupport.kt │ │ ├── registry │ │ ├── FileProviderRegistry.kt │ │ ├── GrammarRegistry.kt │ │ ├── MonarchGrammarRegistry.kt │ │ ├── ThemeRegistry.kt │ │ ├── dsl │ │ │ ├── GrammarDefinitionDSL.kt │ │ │ └── MonarchGrammarDefinitionDSL.kt │ │ ├── grammardefinition │ │ │ ├── GrammarDefinitionReader.kt │ │ │ └── MonarchGrammarDefinitionReader.kt │ │ ├── model │ │ │ ├── GrammarDefinition.kt │ │ │ └── ThemeModel.kt │ │ └── provider │ │ │ ├── AssetsFileResolver.kt │ │ │ └── FileResolver.kt │ │ ├── theme │ │ ├── ColorMap.kt │ │ ├── ExternalThemeTrieElement.kt │ │ ├── ThemeDefaultColors.kt │ │ ├── ThemeTrieElement.kt │ │ ├── ThemeTrieElementRule.kt │ │ ├── TokenTheme.kt │ │ ├── loader.kt │ │ ├── parse.kt │ │ └── types.kt │ │ └── utils │ │ └── string.kt │ └── test │ ├── kotlin │ └── JsonParseTests.kt │ └── resources │ ├── javascript-language-configuration.json │ └── sakura-color-theme.json ├── language-textmate ├── .gitignore ├── README.md ├── build.gradle.kts ├── consumer-rules.pro ├── gradle.properties ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ ├── io │ └── github │ │ └── rosemoe │ │ └── sora │ │ └── langs │ │ └── textmate │ │ ├── MyState.java │ │ ├── TextMateAnalyzer.java │ │ ├── TextMateColorScheme.java │ │ ├── TextMateLanguage.java │ │ ├── TextMateNewlineHandler.java │ │ ├── TextMateSymbolPairMatch.java │ │ ├── folding │ │ ├── FoldingHelper.java │ │ ├── FoldingRegion.java │ │ ├── FoldingRegions.java │ │ ├── IndentRange.java │ │ ├── PreviousRegion.java │ │ └── RangesCollector.java │ │ ├── registry │ │ ├── FileProviderRegistry.java │ │ ├── GrammarRegistry.java │ │ ├── ThemeRegistry.java │ │ ├── dsl │ │ │ └── GrammarDefinitionDSL.kt │ │ ├── model │ │ │ ├── DefaultGrammarDefinition.java │ │ │ ├── GrammarDefinition.java │ │ │ └── ThemeModel.java │ │ ├── provider │ │ │ ├── AssetsFileResolver.java │ │ │ └── FileResolver.java │ │ └── reader │ │ │ └── LanguageDefinitionReader.java │ │ └── utils │ │ ├── MatcherUtils.java │ │ └── StringUtils.java │ └── org │ └── eclipse │ └── tm4e │ ├── core │ ├── TMException.java │ ├── grammar │ │ ├── IGrammar.java │ │ ├── IStateStack.java │ │ ├── IToken.java │ │ └── ITokenizeLineResult.java │ ├── internal │ │ ├── grammar │ │ │ ├── AttributedScopeStack.java │ │ │ ├── BalancedBracketSelectors.java │ │ │ ├── BasicScopeAttributes.java │ │ │ ├── BasicScopeAttributesProvider.java │ │ │ ├── Grammar.java │ │ │ ├── Injection.java │ │ │ ├── LineTokenizer.java │ │ │ ├── LineTokens.java │ │ │ ├── ScopeStack.java │ │ │ ├── StateStack.java │ │ │ ├── TokenTypeMatcher.java │ │ │ ├── TokenizeLineResult.java │ │ │ ├── dependencies │ │ │ │ ├── AbsoluteRuleReference.java │ │ │ │ ├── IncludeReference.java │ │ │ │ └── ScopeDependencyProcessor.java │ │ │ ├── raw │ │ │ │ ├── IRawCaptures.java │ │ │ │ ├── IRawGrammar.java │ │ │ │ ├── IRawRepository.java │ │ │ │ ├── IRawRule.java │ │ │ │ ├── RawCaptures.java │ │ │ │ ├── RawGrammar.java │ │ │ │ ├── RawGrammarReader.java │ │ │ │ ├── RawRepository.java │ │ │ │ └── RawRule.java │ │ │ └── tokenattrs │ │ │ │ ├── EncodedTokenAttributes.java │ │ │ │ ├── EncodedTokenDataConsts.java │ │ │ │ ├── OptionalStandardTokenType.java │ │ │ │ └── StandardTokenType.java │ │ ├── matcher │ │ │ ├── Matcher.java │ │ │ ├── MatcherBuilder.java │ │ │ ├── MatcherWithPriority.java │ │ │ └── NameMatcher.java │ │ ├── oniguruma │ │ │ ├── OnigCaptureIndex.java │ │ │ ├── OnigRegExp.java │ │ │ ├── OnigResult.java │ │ │ ├── OnigScanner.java │ │ │ ├── OnigScannerMatch.java │ │ │ ├── OnigSearcher.java │ │ │ └── OnigString.java │ │ ├── parser │ │ │ ├── PropertySettable.java │ │ │ ├── TMParser.java │ │ │ ├── TMParserJSON.java │ │ │ ├── TMParserPList.java │ │ │ ├── TMParserPropertyPath.java │ │ │ └── TMParserYAML.java │ │ ├── registry │ │ │ ├── IGrammarRepository.java │ │ │ ├── IThemeProvider.java │ │ │ └── SyncRegistry.java │ │ ├── rule │ │ │ ├── BeginEndRule.java │ │ │ ├── BeginWhileRule.java │ │ │ ├── CaptureRule.java │ │ │ ├── CompilePatternsResult.java │ │ │ ├── CompiledRule.java │ │ │ ├── IGrammarRegistry.java │ │ │ ├── IRuleFactoryHelper.java │ │ │ ├── IRuleRegistry.java │ │ │ ├── IncludeOnlyRule.java │ │ │ ├── MatchRule.java │ │ │ ├── RegExpSource.java │ │ │ ├── RegExpSourceList.java │ │ │ ├── Rule.java │ │ │ ├── RuleFactory.java │ │ │ └── RuleId.java │ │ ├── theme │ │ │ ├── ColorMap.java │ │ │ ├── FontStyle.java │ │ │ ├── IThemeSetting.java │ │ │ ├── ParsedThemeRule.java │ │ │ ├── StyleAttributes.java │ │ │ ├── Theme.java │ │ │ ├── ThemeTrieElement.java │ │ │ ├── ThemeTrieElementRule.java │ │ │ └── raw │ │ │ │ ├── IRawTheme.java │ │ │ │ ├── IRawThemeSetting.java │ │ │ │ ├── RawTheme.java │ │ │ │ └── RawThemeReader.java │ │ └── utils │ │ │ ├── AbstractListeners.java │ │ │ ├── MoreCollections.java │ │ │ ├── NullSafetyHelper.java │ │ │ ├── ObjectCloner.java │ │ │ ├── RegexSource.java │ │ │ ├── ScopeNames.java │ │ │ └── StringUtils.java │ └── registry │ │ ├── IGrammarConfiguration.java │ │ ├── IGrammarSource.java │ │ ├── IRegistryOptions.java │ │ ├── IThemeSource.java │ │ └── Registry.java │ └── languageconfiguration │ └── internal │ ├── model │ ├── AutoClosingPair.java │ ├── AutoClosingPairConditional.java │ ├── CharacterPair.java │ ├── CommentRule.java │ ├── CompleteEnterAction.java │ ├── EnterAction.java │ ├── FoldingRules.java │ ├── IndentForEnter.java │ ├── IndentationRules.java │ ├── LanguageConfiguration.java │ ├── OnEnterRule.java │ └── RegExPattern.java │ ├── supports │ ├── CharacterPairSupport.java │ ├── CommentSupport.java │ ├── IndentRulesSupport.java │ └── OnEnterSupport.java │ └── utils │ ├── RegExpUtils.java │ └── TextUtils.java ├── language-treesitter ├── .gitignore ├── build.gradle.kts ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── io │ │ └── github │ │ └── rosemoe │ │ └── sora │ │ └── editor │ │ └── ts │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── io │ │ └── github │ │ └── rosemoe │ │ └── sora │ │ └── editor │ │ └── ts │ │ ├── LineSpansGenerator.kt │ │ ├── LocalsCaptureSpec.kt │ │ ├── SafeTsTree.kt │ │ ├── TsAnalyzeManager.kt │ │ ├── TsBracketPairs.kt │ │ ├── TsLanguage.kt │ │ ├── TsLanguageSpec.kt │ │ ├── TsScopedVariables.kt │ │ ├── TsTheme.kt │ │ ├── Utils.kt │ │ ├── multilang │ │ ├── LanguagePriorityCheck.kt │ │ ├── TsIndentHelper.kt │ │ └── TsInjectableLanguageSpec.kt │ │ ├── predicate │ │ ├── PredicateResult.kt │ │ ├── Predicator.kt │ │ ├── TsClientPredicateStep.kt │ │ ├── TsPredicate.kt │ │ ├── TsSyntheticCapture.kt │ │ ├── TsSyntheticCaptureContainer.kt │ │ └── builtin │ │ │ ├── MatchPredicate.kt │ │ │ ├── SetCapturePredicate.kt │ │ │ └── Utils.kt │ │ └── spans │ │ ├── DefaultSpanFactory.kt │ │ └── TsSpanFactory.kt │ └── test │ └── java │ └── io │ └── github │ └── rosemoe │ └── sora │ └── editor │ └── ts │ └── ExampleUnitTest.kt ├── renovate.json └── settings.gradle.kts /.github/jetbrains-variant-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/.github/jetbrains-variant-3.png -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | sora-editor -------------------------------------------------------------------------------- /.idea/copyright/LGPL.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/copyright/tm4e_EPL.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/libs/EmmyLua-LS-all.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/libs/EmmyLua-LS-all.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/release/output-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "artifactType": { 4 | "type": "APK", 5 | "kind": "Directory" 6 | }, 7 | "applicationId": "com.rose.editor.android", 8 | "variantName": "release", 9 | "elements": [ 10 | { 11 | "type": "SINGLE", 12 | "filters": [], 13 | "properties": [], 14 | "versionCode": 1, 15 | "versionName": "1.0", 16 | "enabled": true, 17 | "outputFile": "app-release.apk" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /app/src/main/assets/JetBrainsMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/assets/JetBrainsMono-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/assets/Roboto-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/Ubuntu-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/assets/Ubuntu-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/testProject/sample.lua: -------------------------------------------------------------------------------- 1 | function test() 2 | return { 3 | b = 12 4 | } 5 | end 6 | 7 | for a in pairs(test()) do 8 | print(a) 9 | end 10 | 11 | local f,e = pcall(load) 12 | 13 | print(f,e) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/assets/textmate/java/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "//", 4 | "blockComment": ["/*", "*/"] 5 | }, 6 | "brackets": [ 7 | ["{", "}"], 8 | ["[", "]"], 9 | ["(", ")"] 10 | ], 11 | "autoClosingPairs": [ 12 | ["{", "}"], 13 | ["[", "]"], 14 | ["(", ")"], { 15 | "open": "\"", 16 | "close": "\"", 17 | "notIn": ["string"] 18 | }, { 19 | "open": "'", 20 | "close": "'", 21 | "notIn": ["string"] 22 | }, { 23 | "open": "/**", 24 | "close": " */", 25 | "notIn": ["string"] 26 | } 27 | ], 28 | "surroundingPairs": [ 29 | ["{", "}"], 30 | ["[", "]"], 31 | ["(", ")"], 32 | ["\"", "\""], 33 | ["'", "'"] 34 | ], 35 | "folding": { 36 | "offSide": false, 37 | "markers": { 38 | "start": "^\\s*//\\s*#region", 39 | "end": "^\\s*//\\s*#endregion" 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /app/src/main/assets/textmate/kotlin/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "//", 4 | "blockComment": [ "/*", "*/" ] 5 | }, 6 | "brackets": [ 7 | ["{", "}"], 8 | ["[", "]"], 9 | ["(", ")"], 10 | ["<", ">"] 11 | ], 12 | "autoClosingPairs": [ 13 | { "open": "{", "close": "}" }, 14 | { "open": "[", "close": "]" }, 15 | { "open": "(", "close": ")" }, 16 | { "open": "'", "close": "'", "notIn": ["string", "comment"] }, 17 | { "open": "\"", "close": "\"", "notIn": ["string"] }, 18 | { "open": "/*", "close": " */", "notIn": ["string"] } 19 | ], 20 | "surroundingPairs": [ 21 | ["{", "}"], 22 | ["[", "]"], 23 | ["(", ")"], 24 | ["<", ">"], 25 | ["'", "'"], 26 | ["\"", "\""] 27 | ], 28 | "folding": { 29 | "offSide": false, 30 | "markers": { 31 | "start": "^\\s*//\\s*#region", 32 | "end": "^\\s*//\\s*#endregion" 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /app/src/main/assets/textmate/lua/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "--", 4 | "blockComment": [ 5 | "--[[", 6 | "]]" 7 | ] 8 | }, 9 | "brackets": [ 10 | [ 11 | "{", 12 | "}" 13 | ], 14 | [ 15 | "[", 16 | "]" 17 | ], 18 | [ 19 | "(", 20 | ")" 21 | ] 22 | ], 23 | "autoClosingPairs": [ 24 | [ 25 | "{", 26 | "}" 27 | ], 28 | [ 29 | "[", 30 | "]" 31 | ], 32 | [ 33 | "(", 34 | ")" 35 | ], 36 | { 37 | "open": "\"", 38 | "close": "\"", 39 | "notIn": [ 40 | "string" 41 | ] 42 | }, 43 | { 44 | "open": "'", 45 | "close": "'", 46 | "notIn": [ 47 | "string" 48 | ] 49 | } 50 | ], 51 | "surroundingPairs": [ 52 | [ 53 | "{", 54 | "}" 55 | ], 56 | [ 57 | "[", 58 | "]" 59 | ], 60 | [ 61 | "(", 62 | ")" 63 | ], 64 | [ 65 | "\"", 66 | "\"" 67 | ], 68 | [ 69 | "'", 70 | "'" 71 | ] 72 | ], 73 | "indentationRules": { 74 | "increaseIndentPattern": "^((?!(\\-\\-)).)*((\\b(else|function|then|do|repeat)\\b((?!\\b(end|until)\\b).)*)|(\\{\\s*))$", 75 | "decreaseIndentPattern": "^\\s*((\\b(elseif|else|end|until)\\b)|(\\})|(\\)))" 76 | } 77 | } -------------------------------------------------------------------------------- /app/src/main/assets/textmate/markdown/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "blockComment": [ 4 | "" 6 | ] 7 | }, 8 | "brackets": [ 9 | [ 10 | "{", 11 | "}" 12 | ], 13 | [ 14 | "[", 15 | "]" 16 | ], 17 | [ 18 | "(", 19 | ")" 20 | ] 21 | ], 22 | "colorizedBracketPairs": [ 23 | ], 24 | "autoClosingPairs": [ 25 | { 26 | "open": "{", 27 | "close": "}" 28 | }, 29 | { 30 | "open": "[", 31 | "close": "]" 32 | }, 33 | { 34 | "open": "(", 35 | "close": ")" 36 | }, 37 | { 38 | "open": "<", 39 | "close": ">", 40 | "notIn": [ 41 | "string" 42 | ] 43 | } 44 | ], 45 | "surroundingPairs": [ 46 | [ 47 | "(", 48 | ")" 49 | ], 50 | [ 51 | "[", 52 | "]" 53 | ], 54 | [ 55 | "`", 56 | "`" 57 | ], 58 | [ 59 | "_", 60 | "_" 61 | ], 62 | [ 63 | "*", 64 | "*" 65 | ], 66 | [ 67 | "{", 68 | "}" 69 | ], 70 | [ 71 | "'", 72 | "'" 73 | ], 74 | [ 75 | "\"", 76 | "\"" 77 | ] 78 | ], 79 | "folding": { 80 | "offSide": true, 81 | "markers": { 82 | "start": "^\\s*", 83 | "end": "^\\s*" 84 | } 85 | }, 86 | "wordPattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*" 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/assets/tree-sitter-queries/java/blocks.scm: -------------------------------------------------------------------------------- 1 | ; Code block patterns for editor 2 | ; Capture names for scopes does not matter much in sora-editor implementation, you may use 'abc', 'test.xyz', etc. 3 | ; General, editor considers the captured node's region as code block region. 4 | ; However, capture name with '.marked' suffix is special. The last terminal node's start position in the capture will be the end position of the block 5 | ; 'terminal node' refers to a node without children 6 | 7 | (class_declaration 8 | body: (_) @scope.marked) 9 | 10 | (record_declaration 11 | body: (_) @scope.marked) 12 | 13 | (enum_declaration 14 | body: (_) @scope.marked) 15 | 16 | (block) @scope.marked 17 | 18 | (array_initializer) @scope.marked -------------------------------------------------------------------------------- /app/src/main/assets/tree-sitter-queries/java/brackets.scm: -------------------------------------------------------------------------------- 1 | ; Brackets pattern for editor 2 | ; Note that you should match both open node and close node in one pattern 3 | ; In sora-editor, capture named 'editor.brackets.open' is regarded as open symbol node, capture named 'editor.brackets.close' is regarded as close symbol node. 4 | (block 5 | "{" @editor.brackets.open 6 | "}" @editor.brackets.close) 7 | 8 | (expression 9 | "(" @editor.brackets.open 10 | ")" @editor.brackets.close) 11 | 12 | (array_initializer 13 | "{" @editor.brackets.open 14 | "}" @editor.brackets.close) -------------------------------------------------------------------------------- /app/src/main/java/io/github/rosemoe/sora/utils/stringUtils.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.utils 26 | 27 | fun CharSequence.codePointStringAt(index: Int): String { 28 | val cp = Character.codePointAt(this, index) 29 | return String(Character.toChars(cp)) 30 | } 31 | 32 | fun String.escapeCodePointIfNecessary() = 33 | when (this) { 34 | "\n" -> "\\n" 35 | "\t" -> "\\t" 36 | "\r" -> "\\r" 37 | " " -> "" 38 | else -> this 39 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/scrollbar_thumb.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/scrollbar_track.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_lsp.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/box_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-xxhdpi/box_red.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /build-logic/convention/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /build-logic/convention/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | plugins { 26 | `kotlin-dsl` 27 | } 28 | 29 | repositories { 30 | google() 31 | gradlePluginPortal() 32 | mavenCentral() 33 | } 34 | 35 | java { 36 | targetCompatibility = JavaVersion.VERSION_17 37 | sourceCompatibility = JavaVersion.VERSION_17 38 | } 39 | 40 | kotlin { 41 | jvmToolchain(17) 42 | } 43 | -------------------------------------------------------------------------------- /build-logic/convention/src/main/kotlin/build-logic.root-project.gradle.kts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | 26 | require(project == rootProject) { 27 | "This script must be apply to the root project." 28 | } 29 | -------------------------------------------------------------------------------- /build-logic/gradle.properties: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # sora-editor - the awesome code editor for Android 3 | # https://github.com/Rosemoe/sora-editor 4 | # Copyright (C) 2020-2024 Rosemoe 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | # USA 20 | # 21 | # Please contact Rosemoe by email 2073412493@qq.com if you need 22 | # additional information or have any questions 23 | ################################################################################ 24 | 25 | # Gradle properties are not passed to included builds https://github.com/gradle/gradle/issues/2534 26 | org.gradle.parallel=true 27 | org.gradle.caching=true 28 | org.gradle.configureondemand=true 29 | -------------------------------------------------------------------------------- /build-logic/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/build-logic/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /build-logic/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # sora-editor - the awesome code editor for Android 3 | # https://github.com/Rosemoe/sora-editor 4 | # Copyright (C) 2020-2024 Rosemoe 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | # USA 20 | # 21 | # Please contact Rosemoe by email 2073412493@qq.com if you need 22 | # additional information or have any questions 23 | ################################################################################ 24 | 25 | distributionBase=GRADLE_USER_HOME 26 | distributionPath=wrapper/dists 27 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip 28 | zipStoreBase=GRADLE_USER_HOME 29 | zipStorePath=wrapper/dists 30 | -------------------------------------------------------------------------------- /build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 26 | 27 | dependencyResolutionManagement { 28 | repositories { 29 | google() 30 | mavenCentral() 31 | } 32 | versionCatalogs { 33 | create("libs") { 34 | from(files("../gradle/libs.versions.toml")) 35 | } 36 | } 37 | } 38 | 39 | include(":convention") 40 | rootProject.name = "build-logic" 41 | -------------------------------------------------------------------------------- /debug.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/debug.jks -------------------------------------------------------------------------------- /editor-lsp/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /editor-lsp/README.md: -------------------------------------------------------------------------------- 1 | ## About 2 | 3 | **Experimental, work in progress** 4 | 5 | `editor-lsp` module is a language service protocol client based on lsp4j, providing language service 6 | protocol support for sora-editor. 7 | 8 | Based on the module, you can access different language servers to provide features for different 9 | languages, such as auto-completion, formatting, etc. 10 | 11 | ## Features(already available) 12 | 13 | 1.`textDocument/formatting` 14 | 15 | 2.`textDocument/rangeFormatting` 16 | 17 | 3.`textDocument/diagnostic` 18 | 19 | ## How to connect to the language server 20 | 21 | We recommend to use socket to connect to the language server, you can let the language server run on 22 | another process without worrying that a crash of the language server will cause the main process to 23 | crash. 24 | 25 | See [this](https://github.com/Rosemoe/sora-editor/blob/main/app/src/main/java/io/github/rosemoe/sora/app/LspTestActivity.kt#L135) 26 | to see example of connecting to a language server 27 | 28 | -------------------------------------------------------------------------------- /editor-lsp/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/editor-lsp/consumer-rules.pro -------------------------------------------------------------------------------- /editor-lsp/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /editor-lsp/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /editor-lsp/src/main/java/io/github/rosemoe/sora/lsp/client/languageserver/ServerStatus.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.lsp.client.languageserver 26 | 27 | /** 28 | * An enum representing a server status 29 | */ 30 | enum class ServerStatus { 31 | STOPPED, 32 | STARTING, 33 | STARTED, 34 | INITIALIZED, 35 | STOPPING 36 | } -------------------------------------------------------------------------------- /editor-lsp/src/main/java/io/github/rosemoe/sora/lsp/editor/completion/CompletionItemProvider.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.lsp.editor.completion 25 | 26 | import io.github.rosemoe.sora.lang.completion.CompletionItem 27 | import io.github.rosemoe.sora.lsp.editor.LspEventManager 28 | 29 | fun interface CompletionItemProvider { 30 | fun createCompletionItem( 31 | completionItem: org.eclipse.lsp4j.CompletionItem, 32 | eventManager: LspEventManager, 33 | prefixLength: Int 34 | ): T 35 | } 36 | -------------------------------------------------------------------------------- /editor-lsp/src/main/java/io/github/rosemoe/sora/lsp/utils/LSPException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.lsp.utils 25 | 26 | class LSPException : RuntimeException { 27 | constructor(msg: String) : super(msg) 28 | constructor(msg: String, cause: Throwable?) : super(msg, cause) 29 | constructor(cause: Throwable?) : super(cause) 30 | } 31 | -------------------------------------------------------------------------------- /editor-lsp/src/main/res/drawable/signature_tooltip_background.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /editor/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /editor/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/editor/consumer-rules.pro -------------------------------------------------------------------------------- /editor/gradle.properties: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # sora-editor - the awesome code editor for Android 3 | # https://github.com/Rosemoe/sora-editor 4 | # Copyright (C) 2020-2024 Rosemoe 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | # USA 20 | # 21 | # Please contact Rosemoe by email 2073412493@qq.com if you need 22 | # additional information or have any questions 23 | ################################################################################ 24 | 25 | POM_ARTIFACT_ID=editor 26 | POM_NAME=editor 27 | POM_DESCRIPTION=An awesome code editor library on Android 28 | POM_PACKAGING=aar 29 | -------------------------------------------------------------------------------- /editor/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /editor/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/annotations/InvalidateRequired.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.annotations; 25 | 26 | import android.view.View; 27 | 28 | import java.lang.annotation.ElementType; 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.RetentionPolicy; 31 | import java.lang.annotation.Target; 32 | 33 | /** 34 | * Marks you must call {@link View#invalidate()} after changing this property 35 | */ 36 | @Retention(RetentionPolicy.CLASS) 37 | @Target({ElementType.FIELD}) 38 | public @interface InvalidateRequired { 39 | } 40 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/annotations/UnsupportedUserUsage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.annotations; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | /** 32 | * Marks that this member is internally used and that it is not recommended using this 33 | * member at your side. 34 | */ 35 | @Retention(RetentionPolicy.CLASS) 36 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.TYPE}) 37 | public @interface UnsupportedUserUsage { 38 | } 39 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/event/EventReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.event; 25 | 26 | import androidx.annotation.NonNull; 27 | 28 | public interface EventReceiver { 29 | 30 | void onReceive(@NonNull T event, @NonNull Unsubscribe unsubscribe); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/event/InterceptTarget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.event; 25 | 26 | /** 27 | * Define available intercept targets. You may intercept one or more targets of the given event. 28 | * 29 | * @author Rosemoe 30 | */ 31 | public interface InterceptTarget { 32 | 33 | /** 34 | * Registered receivers in the event dispatching graph 35 | */ 36 | int TARGET_RECEIVERS = 1; 37 | 38 | /** 39 | * Editor built-in behavior 40 | */ 41 | int TARGET_EDITOR = 1 << 1; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/completion/snippet/FormatString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.lang.completion.snippet; 25 | 26 | public interface FormatString { 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/completion/snippet/NextUpperCaseFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.lang.completion.snippet; 25 | 26 | public class NextUpperCaseFormat implements FormatString { 27 | } 28 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/completion/snippet/NoFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.lang.completion.snippet; 25 | 26 | public class NoFormat implements FormatString { 27 | 28 | private String text; 29 | 30 | public NoFormat(String text) { 31 | setText(text); 32 | } 33 | 34 | public void setText(String text) { 35 | this.text = text; 36 | } 37 | 38 | public String getText() { 39 | return text; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/completion/snippet/PlaceHolderElement.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.lang.completion.snippet 26 | 27 | /** 28 | * Marker interface for elements that can be present in a [PlaceholderItem]. 29 | * 30 | * @author Akash Yadav 31 | */ 32 | interface PlaceHolderElement -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/completion/snippet/PlaceholderDefinition.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.lang.completion.snippet 26 | 27 | data class PlaceholderDefinition @JvmOverloads constructor( 28 | var id: Int, 29 | var choices: List? = null, 30 | var elements: List = mutableListOf(), // do not use emptyList() 31 | var transform: Transform? = null 32 | ) { 33 | internal var text: String? = null 34 | } 35 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/completion/snippet/PlainPlaceholderElement.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.lang.completion.snippet 26 | 27 | /** 28 | * Plain placeholder text. 29 | * 30 | * @author Akash Yadav 31 | */ 32 | data class PlainPlaceholderElement(var text: String) : PlaceHolderElement -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/diagnostic/DiagnosticDetail.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.lang.diagnostic 26 | 27 | /** 28 | * Detail messages of diagnostic item. 29 | * 30 | * @author Rosemoe 31 | */ 32 | data class DiagnosticDetail( 33 | val briefMessage: CharSequence, 34 | val detailedMessage: CharSequence? = null, 35 | val quickfixes: List? = null, 36 | val extraData: Any? = null 37 | ) -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/styling/inlayHint/InlayHintLayoutType.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.lang.styling.inlayHint 26 | 27 | enum class InlayHintLayoutType { 28 | IN_LINE, 29 | ABOVE_LINE, 30 | BELOW_LINE 31 | } -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/styling/line/LineSideIcon.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.lang.styling.line 26 | 27 | import android.graphics.drawable.Drawable 28 | 29 | /** 30 | * A small icon shown at the left of line. 31 | * Note that the bounds of the drawable is specified every time the drawable is drawn on screen. 32 | * 33 | * @author Rosemoe 34 | */ 35 | data class LineSideIcon(override var line: Int, val drawable: Drawable) : LineAnchorStyle(line) -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/styling/span/SpanExt.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.lang.styling.span 26 | 27 | import io.github.rosemoe.sora.lang.styling.Span 28 | 29 | /** 30 | * Extended attribute for [Span]. These attributes are uncommonly-used, and will be stored in 31 | * a lazily initialized map to save memory. 32 | */ 33 | interface SpanExt 34 | 35 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/lang/styling/span/SpanInteractionInfo.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.lang.styling.span 26 | 27 | /** 28 | * Interaction attributes for a [Span]. 29 | */ 30 | interface SpanInteractionInfo : SpanExt { 31 | 32 | fun isClickable(): Boolean 33 | 34 | fun isLongClickable(): Boolean 35 | 36 | fun isDoubleClickable(): Boolean 37 | 38 | fun getData(): Any? 39 | 40 | } -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/text/Content.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.text 26 | 27 | /** 28 | * A delegate method. 29 | * Notify the UndoManager to batch edit. 30 | * @see Content.beginBatchEdit 31 | * @see Content.endBatchEdit 32 | */ 33 | fun Content.batchEdit(block: (Content) -> Unit): Content { 34 | this.beginBatchEdit() 35 | block(this) 36 | this.endBatchEdit() 37 | return this 38 | } -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/text/bidi/BidiRequirementChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.text.bidi; 25 | 26 | public interface BidiRequirementChecker { 27 | 28 | boolean mayNeedBidi(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/util/ArrayList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.util; 25 | 26 | /** 27 | * Expose {@link java.util.ArrayList#removeRange(int, int)} to public. 28 | *

29 | * {@inheritDoc} 30 | */ 31 | public class ArrayList extends java.util.ArrayList { 32 | 33 | public ArrayList() { 34 | super(); 35 | } 36 | 37 | public ArrayList(int initialCapacity) { 38 | super(initialCapacity); 39 | } 40 | 41 | @Override 42 | public void removeRange(int fromIndex, int toIndex) { 43 | super.removeRange(fromIndex, toIndex); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/util/EditorHandler.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.util 26 | 27 | import android.os.Handler 28 | import android.os.Looper 29 | 30 | object EditorHandler : Handler(Looper.getMainLooper()) -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/util/Floats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.util; 25 | 26 | public class Floats { 27 | 28 | public static boolean withinDelta(float a, float b, float delta) { 29 | return Math.abs(a - b) < Math.abs(delta); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/util/MutableInt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.util; 25 | 26 | public class MutableInt { 27 | 28 | public int value; 29 | 30 | public MutableInt(int v) { 31 | value = v; 32 | } 33 | 34 | public int decreaseAndGet() { 35 | return --value; 36 | } 37 | 38 | public void increase() { 39 | value++; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/util/ThemeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.util; 25 | 26 | import android.util.TypedValue; 27 | import android.view.ContextThemeWrapper; 28 | 29 | public class ThemeUtils { 30 | 31 | public static int getColorPrimary(ContextThemeWrapper context) { 32 | TypedValue typedValue = new TypedValue(); 33 | context.getTheme().resolveAttribute(android.R.attr.colorPrimary, typedValue, true); 34 | return typedValue.data; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/util/regex/RegexBackrefGrammar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2025 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.util.regex; 25 | 26 | public class RegexBackrefGrammar { 27 | 28 | public final static RegexBackrefGrammar DEFAULT = new RegexBackrefGrammar('$', '\\'); 29 | 30 | public final char backrefStartChar; 31 | 32 | public final char escapeChar; 33 | 34 | public RegexBackrefGrammar(char backrefStartChar, char escapeChar) { 35 | this.backrefStartChar = backrefStartChar; 36 | this.escapeChar = escapeChar; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/widget/rendering/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | 25 | 26 | /** 27 | * This package contains classes related to editor rendering. 28 | */ 29 | package io.github.rosemoe.sora.widget.rendering; 30 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/widget/snippet/variable/FileBasedSnippetVariableResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.widget.snippet.variable; 25 | 26 | import androidx.annotation.NonNull; 27 | 28 | public abstract class FileBasedSnippetVariableResolver implements ISnippetVariableResolver { 29 | 30 | @NonNull 31 | @Override 32 | public String[] getResolvableNames() { 33 | return new String[]{ 34 | "TM_FILENAME", "TM_FILENAME_BASE", "TM_DIRECTORY", "TM_FILEPATH", "RELATIVE_PATH" 35 | }; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/widget/snippet/variable/WorkspaceBasedSnippetVariableResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.widget.snippet.variable; 25 | 26 | import androidx.annotation.NonNull; 27 | 28 | public abstract class WorkspaceBasedSnippetVariableResolver implements ISnippetVariableResolver { 29 | 30 | @NonNull 31 | @Override 32 | public String[] getResolvableNames() { 33 | return new String[]{ 34 | "WORKSPACE_NAME", "WORKSPACE_FOLDER" 35 | }; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/widget/style/DiagnosticIndicatorStyle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.widget.style; 25 | 26 | /** 27 | * Style for diagnostic displaying 28 | * 29 | * @author Rosemoe 30 | */ 31 | public enum DiagnosticIndicatorStyle { 32 | NONE, 33 | LINE, 34 | DOUBLE_LINE, 35 | WAVY_LINE 36 | } 37 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/widget/style/LineInfoPanelPosition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.widget.style; 25 | 26 | public class LineInfoPanelPosition { 27 | public static final int LEFT = 1; 28 | public static final int TOP = 2; 29 | public static final int RIGHT = 4; 30 | public static final int BOTTOM = 8; 31 | public static final int CENTER = 15; 32 | } 33 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/widget/style/LineInfoPanelPositionMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.widget.style; 25 | 26 | public class LineInfoPanelPositionMode { 27 | public static final int FIXED = 0; 28 | public static final int FOLLOW = 1; 29 | } 30 | -------------------------------------------------------------------------------- /editor/src/main/java/io/github/rosemoe/sora/widget/style/builtin/DefaultLineNumberTip.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.widget.style.builtin 26 | 27 | import io.github.rosemoe.sora.widget.CodeEditor 28 | import io.github.rosemoe.sora.widget.style.LineNumberTipTextProvider 29 | 30 | object DefaultLineNumberTip : LineNumberTipTextProvider { 31 | 32 | override fun getCurrentText(editor: CodeEditor) = "L${editor.firstVisibleLine + 1}" 33 | 34 | } -------------------------------------------------------------------------------- /editor/src/main/res/anim/anim_text_action_popup_enter.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 32 | 33 | -------------------------------------------------------------------------------- /editor/src/main/res/anim/anim_text_action_popup_exit.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 32 | 33 | -------------------------------------------------------------------------------- /editor/src/main/res/drawable/magnifier_background.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /editor/src/main/res/layout/magnifier_popup.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | -------------------------------------------------------------------------------- /editor/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | @android:color/background_dark 27 | @android:color/white 28 | -------------------------------------------------------------------------------- /editor/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | @android:color/tertiary_text_light 27 | @android:color/background_light 28 | @android:color/black 29 | -------------------------------------------------------------------------------- /editor/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Aug 03 16:05:07 CST 2024 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip 5 | networkTimeout=10000 6 | validateDistributionUrl=true 7 | zipStoreBase=GRADLE_USER_HOME 8 | zipStorePath=wrapper/dists 9 | -------------------------------------------------------------------------------- /images/editor_banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/images/editor_banner.jpg -------------------------------------------------------------------------------- /images/general.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/images/general.jpg -------------------------------------------------------------------------------- /images/problem_indicators.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/images/problem_indicators.jpg -------------------------------------------------------------------------------- /language-java/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /language-java/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/language-java/consumer-rules.pro -------------------------------------------------------------------------------- /language-java/gradle.properties: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # sora-editor - the awesome code editor for Android 3 | # https://github.com/Rosemoe/sora-editor 4 | # Copyright (C) 2020-2024 Rosemoe 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | # USA 20 | # 21 | # Please contact Rosemoe by email 2073412493@qq.com if you need 22 | # additional information or have any questions 23 | ################################################################################ 24 | 25 | POM_ARTIFACT_ID=language-java 26 | POM_NAME=language-java 27 | POM_DESCRIPTION=An awesome code editor library on Android 28 | POM_PACKAGING=aar 29 | -------------------------------------------------------------------------------- /language-java/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /language-java/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /language-java/src/test/java/io/github/rosemoe/langs/java/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.langs.java; 25 | 26 | import static org.junit.Assert.assertEquals; 27 | 28 | import org.junit.Test; 29 | 30 | /** 31 | * Example local unit test, which will execute on the development machine (host). 32 | * 33 | * @see Testing documentation 34 | */ 35 | public class ExampleUnitTest { 36 | @Test 37 | public void addition_isCorrect() { 38 | assertEquals(4, 2 + 2); 39 | } 40 | } -------------------------------------------------------------------------------- /language-monarch/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /language-monarch/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/language-monarch/consumer-rules.pro -------------------------------------------------------------------------------- /language-monarch/gradle.properties: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # sora-editor - the awesome code editor for Android 3 | # https://github.com/Rosemoe/sora-editor 4 | # Copyright (C) 2020-2024 Rosemoe 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | # USA 20 | # 21 | # Please contact Rosemoe by email 2073412493@qq.com if you need 22 | # additional information or have any questions 23 | ################################################################################ 24 | 25 | POM_ARTIFACT_ID=language-monarch 26 | POM_NAME=language-monarch 27 | POM_DESCRIPTION=An awesome code editor library on Android 28 | POM_PACKAGING=aar 29 | -------------------------------------------------------------------------------- /language-monarch/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /language-monarch/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/MonarchState.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.langs.monarch 26 | 27 | import io.github.dingyi222666.monarch.types.TokenizeState 28 | import io.github.dingyi222666.regex.MatchResult 29 | 30 | data class MonarchState( 31 | val tokenizeState: TokenizeState, 32 | val foldingCache: MatchResult?, 33 | val indent: Int, 34 | val identifiers: List? 35 | ) 36 | -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/folding/FoldingHelper.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.langs.monarch.folding 26 | 27 | import io.github.dingyi222666.regex.MatchResult 28 | 29 | interface FoldingHelper { 30 | fun getResultFor(line: Int): MatchResult? 31 | 32 | fun getIndentFor(line: Int): Int 33 | } -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/folding/FoldingRegion.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.langs.monarch.folding 25 | 26 | class FoldingRegion(private val ranges: FoldingRegions, private val regionIndex: Int) { 27 | val startLineNumber: Int 28 | get() = ranges.getStartLineNumber(this.regionIndex) 29 | 30 | val endLineNumber: Int 31 | get() = ranges.getEndLineNumber(this.regionIndex) 32 | 33 | @get:Throws(Exception::class) 34 | val parentIndex: Int 35 | get() = ranges.getParentIndex(this.regionIndex) 36 | } 37 | -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/folding/PreviousRegion.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.langs.monarch.folding 25 | 26 | data class PreviousRegion(// indent or -2 if a marker 27 | var indent: Int, // end line number for the region above 28 | var endAbove: Int, // start line of the region. Only used for marker regions. 29 | var line: Int 30 | ) 31 | -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/AutoClosingPair.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model 16 | 17 | interface BaseAutoClosingPair { 18 | val open: String 19 | val close: String 20 | val isSurroundingPair: Boolean 21 | } 22 | 23 | data class AutoClosingPair( 24 | override val open: String, 25 | override val close: String, 26 | override val isSurroundingPair: Boolean = false 27 | ): BaseAutoClosingPair 28 | 29 | data class AutoClosingPairConditional( 30 | override val open: String, 31 | override val close: String, 32 | val notIn: List, 33 | override val isSurroundingPair: Boolean = false 34 | ): BaseAutoClosingPair -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/CommentRule.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model 16 | 17 | data class CommentRule ( 18 | val lineComment: String? = null, 19 | val blockComment: CharacterPair? = null 20 | ) -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/CompleteEnterAction.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model 16 | 17 | data class CompleteEnterAction( 18 | /** 19 | * Describe what to do with the indentation. 20 | */ 21 | val indentAction: Int, 22 | /** 23 | * Describes text to be appended after the new line and after the indentation. 24 | */ 25 | val appendText: String, 26 | /** 27 | * Describes the number of characters to remove from the new line's indentation. 28 | */ 29 | val removeText: Int?, 30 | /** 31 | * The line's indentation minus removeText 32 | */ 33 | val indentation: String 34 | ) -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/EnterAction.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model 16 | 17 | data class EnterAction( 18 | val indentAction: Int, 19 | val appendText: String? = null, 20 | val removeText: Int? = null 21 | ) -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/FoldingMarkers.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model 16 | 17 | import io.github.dingyi222666.regex.Regex 18 | 19 | data class FoldingMarkers( 20 | val start: Regex, 21 | val end: Regex 22 | ) -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/FoldingRules.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model 16 | 17 | data class FoldingRules( 18 | val offSide: Boolean? = null, 19 | val markers: FoldingMarkers? = null 20 | ) -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/IndentAction.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model 16 | 17 | object IndentAction { 18 | const val None = 0 19 | const val Indent = 1 20 | const val IndentOutdent = 2 21 | const val Outdent = 3 22 | } -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/IndentationRule.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model 16 | 17 | import io.github.dingyi222666.regex.Regex 18 | 19 | data class IndentationRule( 20 | val decreaseIndentPattern: Regex, 21 | val increaseIndentPattern: Regex, 22 | val indentNextLinePattern: Regex? = null, 23 | val unIndentedLinePattern: Regex? = null 24 | ) -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/OnEnterRule.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model 16 | 17 | import io.github.dingyi222666.regex.Regex 18 | 19 | data class OnEnterRule( 20 | val beforeText: Regex, 21 | val afterText: Regex? = null, 22 | val previousLineText: Regex? = null, 23 | val action: EnterAction 24 | ) -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/registry/model/GrammarDefinition.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.langs.monarch.registry.model; 25 | 26 | import io.github.rosemoe.sora.langs.monarch.languageconfiguration.model.LanguageConfiguration 27 | 28 | 29 | data class GrammarDefinition( 30 | val name: String, 31 | val grammar: T, 32 | val embeddedLanguages: Map, 33 | val languageConfiguration: LanguageConfiguration? = null, 34 | var scopeName: String, 35 | ) 36 | -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/registry/provider/AssetsFileResolver.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.langs.monarch.registry.provider 25 | 26 | import android.content.res.AssetManager 27 | import java.io.InputStream 28 | 29 | class AssetsFileResolver(private var assetManager: AssetManager?) : FileResolver { 30 | override fun resolve(path: String): InputStream? { 31 | return assetManager?.open(path) 32 | } 33 | 34 | override fun dispose() { 35 | // assetManager?.close() 36 | assetManager = null 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/theme/ColorMap.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.theme 16 | 17 | class ColorMap { 18 | 19 | private var lastColorId: Int = -1 20 | private val id2color = mutableListOf() 21 | private val color2id = mutableMapOf() 22 | 23 | fun getId(color: String?): Int { 24 | if (color == null) { 25 | return 0 26 | } 27 | return color2id.getOrPut(color) { 28 | lastColorId++ 29 | id2color.add(lastColorId, color) 30 | lastColorId 31 | } 32 | } 33 | 34 | fun getColor(id: Int): String? { 35 | return id2color.getOrNull(id) 36 | } 37 | 38 | val colorMap: List 39 | get() = id2color.toList() 40 | 41 | override fun toString(): String { 42 | return "ColorMap(lastColorId=$lastColorId, id2color=$id2color, color2id=$color2id)" 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/theme/ExternalThemeTrieElement.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.theme 16 | 17 | class ExternalThemeTrieElement( 18 | val mainRule: ThemeTrieElementRule, 19 | children: Map = mapOf() 20 | ) { 21 | val children = children.toMutableMap() 22 | } -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/theme/ThemeDefaultColors.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.theme 16 | 17 | class ThemeDefaultColors( 18 | defaultColors: Map, 19 | val oldTextMateStyle: Boolean = false 20 | ) { 21 | private val colors = mutableMapOf() 22 | 23 | init { 24 | colors.putAll(defaultColors) 25 | } 26 | 27 | constructor() : this(emptyMap()) 28 | 29 | operator fun get(key: String): String? { 30 | return colors[key] 31 | } 32 | 33 | fun putColors(map: Map) { 34 | colors.putAll(map) 35 | } 36 | 37 | fun getColor(key: String): String? { 38 | return colors[key] 39 | } 40 | 41 | fun getColors(): Map { 42 | return colors 43 | } 44 | 45 | override fun toString(): String { 46 | return "ThemeDefaultColors(colors=$colors)" 47 | } 48 | 49 | companion object { 50 | val EMPTY = ThemeDefaultColors() 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/theme/types.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support 12 | * 13 | ******************************************************************************/ 14 | 15 | package io.github.rosemoe.sora.langs.monarch.theme 16 | 17 | 18 | interface ITokenThemeRule { 19 | var token: String 20 | var foreground: String? 21 | var background: String? 22 | var fontStyle: String? 23 | } 24 | 25 | class ParsedTokenThemeRule( 26 | val token: String, 27 | val index: Int, 28 | val fontStyle: Int, 29 | val foreground: String?, 30 | val background: String? 31 | ) -------------------------------------------------------------------------------- /language-textmate/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /language-textmate/README.md: -------------------------------------------------------------------------------- 1 | ## About 2 | 3 | **Work In Progress** `language-textmate` module is a module that performs syntax highlighting and other functions dynamically. To use it, you need to introduce several other `textmate-*` modules.Our goal is to achieve the effect of VSCode. However, for many reasons, this may be difficult to achieve in the short term. 4 | 5 | ## Features(already available) 6 | 7 | 1. Highlighting of files based on syntax rules 8 | 2. Load color theme from file 9 | 3. Code block line based on indent and rule 10 | 11 | ## How to get syntax and theme files 12 | If many people use this module, they may collect the available configuration files into a repository later. 13 | - You can obtain relevant documents from [Textmate](https://github.com/textmate). 14 | - Eclipse also uses Textmate, and you can also get files from its related repository。 15 | - Textmate is also used in [vscode](https://github.com/microsoft/vscode/tree/main/extensions), but its version is ahead of the version used in this module. You can get the configuration file from its source code, but not all of them can be used normally -------------------------------------------------------------------------------- /language-textmate/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/language-textmate/consumer-rules.pro -------------------------------------------------------------------------------- /language-textmate/gradle.properties: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # sora-editor - the awesome code editor for Android 3 | # https://github.com/Rosemoe/sora-editor 4 | # Copyright (C) 2020-2024 Rosemoe 5 | # 6 | # This library is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU Lesser General Public 8 | # License as published by the Free Software Foundation; either 9 | # version 2.1 of the License, or (at your option) any later version. 10 | # 11 | # This library is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this library; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | # USA 20 | # 21 | # Please contact Rosemoe by email 2073412493@qq.com if you need 22 | # additional information or have any questions 23 | ################################################################################ 24 | 25 | POM_ARTIFACT_ID=language-textmate 26 | POM_NAME=language-textmate 27 | POM_DESCRIPTION=An awesome code editor library on Android 28 | POM_PACKAGING=aar 29 | -------------------------------------------------------------------------------- /language-textmate/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /language-textmate/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/io/github/rosemoe/sora/langs/textmate/folding/FoldingHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.langs.textmate.folding; 25 | 26 | import org.eclipse.tm4e.core.internal.oniguruma.OnigResult; 27 | 28 | public interface FoldingHelper { 29 | 30 | OnigResult getResultFor(int line); 31 | 32 | int getIndentFor(int line); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/io/github/rosemoe/sora/langs/textmate/folding/PreviousRegion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | */ 24 | package io.github.rosemoe.sora.langs.textmate.folding; 25 | 26 | public class PreviousRegion { 27 | // indent or -2 if a marker 28 | public int indent; 29 | // end line number for the region above 30 | public int endAbove; 31 | // start line of the region. Only used for marker regions. 32 | public int line; 33 | 34 | public PreviousRegion(int indent, int endAbove, int line) { 35 | this.indent = indent; 36 | this.endAbove = endAbove; 37 | this.line = line; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/TMException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | */ 12 | package org.eclipse.tm4e.core; 13 | 14 | /** 15 | * TextMate exception. 16 | * 17 | */ 18 | public class TMException extends RuntimeException { 19 | 20 | private static final long serialVersionUID = 1L; 21 | 22 | public TMException(final String message) { 23 | super(message); 24 | } 25 | 26 | public TMException(final String message, final Throwable cause) { 27 | super(message, cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/grammar/IStateStack.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.grammar; 18 | 19 | /** 20 | * Represents a "pushed" state on the stack (as a linked list element). 21 | * 22 | * @see 23 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts 24 | */ 25 | public interface IStateStack { 26 | int getDepth(); 27 | } 28 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/grammar/IToken.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.grammar; 18 | 19 | import java.util.List; 20 | 21 | /** 22 | * @see 23 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts 24 | */ 25 | public interface IToken { 26 | 27 | /** 28 | * 0-based start-index, inclusive 29 | */ 30 | int getStartIndex(); 31 | 32 | void setStartIndex(int startIndex); 33 | 34 | /** 35 | * 0-based end-index, exclusive 36 | */ 37 | int getEndIndex(); 38 | 39 | List getScopes(); 40 | } 41 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/grammar/ITokenizeLineResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.grammar; 18 | 19 | /** 20 | * Result of the line tokenization API. 21 | * 22 | * @see 23 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts 24 | */ 25 | public interface ITokenizeLineResult { 26 | 27 | T getTokens(); 28 | 29 | /** 30 | * Returns the `prevState` to be passed on to the next line tokenization. 31 | * 32 | * @return the `prevState` to be passed on to the next line tokenization. 33 | */ 34 | IStateStack getRuleStack(); 35 | 36 | /** 37 | * Did tokenization stop early due to reaching the time limit. 38 | */ 39 | boolean isStoppedEarly(); 40 | } 41 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/BasicScopeAttributes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * Angelo Zerr - initial API and implementation 15 | */ 16 | package org.eclipse.tm4e.core.internal.grammar; 17 | 18 | /** 19 | * @see 21 | * github.com/microsoft/vscode-textmate/blob/main/src/basicScopesAttributeProvider.ts 22 | */ 23 | final class BasicScopeAttributes { 24 | 25 | final int languageId; 26 | final int /*OptionalStandardTokenType*/ tokenType; 27 | 28 | BasicScopeAttributes(final int languageId, final int /*OptionalStandardTokenType*/ tokenType) { 29 | this.languageId = languageId; 30 | this.tokenType = tokenType; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/TokenTypeMatcher.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022 Sebastian Thomschke and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Initial code from https://github.com/microsoft/vscode-textmate/ 11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 12 | * Initial license: MIT 13 | * 14 | * Contributors: 15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 16 | * - Sebastian Thomschke - translation and adaptation to Java 17 | */ 18 | package org.eclipse.tm4e.core.internal.grammar; 19 | 20 | import java.util.List; 21 | 22 | import org.eclipse.tm4e.core.internal.matcher.Matcher; 23 | 24 | /** 25 | * @see 27 | * github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammar.ts 28 | */ 29 | final class TokenTypeMatcher { 30 | 31 | final Matcher> matcher; 32 | final int /*StandardTokenType*/ type; 33 | 34 | TokenTypeMatcher(final Matcher> matcher, final int type) { 35 | this.matcher = matcher; 36 | this.type = type; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/TokenizeLineResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.grammar; 18 | 19 | import org.eclipse.tm4e.core.grammar.ITokenizeLineResult; 20 | 21 | /** 22 | * Result of the line tokenization implementation. 23 | */ 24 | final class TokenizeLineResult implements ITokenizeLineResult { 25 | 26 | private final T tokens; 27 | private final StateStack ruleStack; 28 | private final boolean stoppedEarly; 29 | 30 | TokenizeLineResult(final T tokens, final StateStack ruleStack, final boolean stoppedEarly) { 31 | this.tokens = tokens; 32 | this.ruleStack = ruleStack; 33 | this.stoppedEarly = stoppedEarly; 34 | } 35 | 36 | @Override 37 | public T getTokens() { 38 | return tokens; 39 | } 40 | 41 | @Override 42 | public StateStack getRuleStack() { 43 | return ruleStack; 44 | } 45 | 46 | @Override 47 | public boolean isStoppedEarly() { 48 | return stoppedEarly; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/IRawCaptures.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.grammar.raw; 18 | 19 | /** 20 | * @see 22 | * github.com/microsoft/vscode-textmate/blob/main/src/rawGrammar.ts 23 | */ 24 | public interface IRawCaptures { 25 | 26 | IRawRule getCapture(String captureId); 27 | 28 | Iterable getCaptureIds(); 29 | } 30 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/IRawGrammar.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.grammar.raw; 18 | 19 | import java.util.Collection; 20 | import java.util.Map; 21 | 22 | import org.eclipse.jdt.annotation.Nullable; 23 | 24 | /** 25 | * @see 27 | * github.com/microsoft/vscode-textmate/blob/main/src/rawGrammar.ts 28 | */ 29 | public interface IRawGrammar { 30 | 31 | IRawRepository getRepository(); 32 | 33 | String getScopeName(); 34 | 35 | @Nullable // TODO non-null in upstream project 36 | Collection getPatterns(); 37 | 38 | @Nullable 39 | Map getInjections(); 40 | 41 | @Nullable 42 | String getInjectionSelector(); 43 | 44 | Collection getFileTypes(); 45 | 46 | @Nullable 47 | String getName(); 48 | 49 | @Nullable 50 | String getFirstLineMatch(); 51 | 52 | void setRepository(IRawRepository repository); 53 | 54 | IRawRule toRawRule(); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawCaptures.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022 Sebastian Thomschke and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | */ 10 | package org.eclipse.tm4e.core.internal.grammar.raw; 11 | 12 | import org.eclipse.tm4e.core.internal.parser.PropertySettable; 13 | 14 | public final class RawCaptures extends PropertySettable.HashMap implements IRawCaptures { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | @Override 19 | public IRawRule getCapture(final String captureId) { 20 | return get(captureId); 21 | } 22 | 23 | @Override 24 | public Iterable getCaptureIds() { 25 | return keySet(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/tokenattrs/OptionalStandardTokenType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022 Sebastian Thomschke and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Initial code from https://github.com/microsoft/vscode-textmate/ 11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 12 | * Initial license: MIT 13 | * 14 | * Contributors: 15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 16 | * - Sebastian Thomschke - translation and adaptation to Java 17 | */ 18 | package org.eclipse.tm4e.core.internal.grammar.tokenattrs; 19 | 20 | /** 21 | * @see 23 | * github.com/microsoft/vscode-textmate/blob/main/src/encodedTokenAttributes.ts 24 | */ 25 | public final class OptionalStandardTokenType { 26 | 27 | // Must have the same values as `StandardTokenType`! 28 | public static final int Other = StandardTokenType.Other; 29 | public static final int Comment = StandardTokenType.Comment; 30 | public static final int String = StandardTokenType.String; 31 | public static final int RegEx = StandardTokenType.RegEx; 32 | 33 | /** 34 | * Indicates that no token type is set. 35 | */ 36 | public static final int NotSet = 8; 37 | 38 | /** 39 | * Content should be accessed statically 40 | */ 41 | private OptionalStandardTokenType() { 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/tokenattrs/StandardTokenType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | */ 12 | package org.eclipse.tm4e.core.internal.grammar.tokenattrs; 13 | 14 | /** 15 | * Standard TextMate token type. 16 | * 17 | * @see 19 | * github.com/microsoft/vscode-textmate/blob/main/src/encodedTokenAttributes.ts 20 | */ 21 | public final class StandardTokenType { 22 | 23 | public static final int Other = 0; 24 | public static final int Comment = 1; 25 | public static final int String = 2; 26 | public static final int RegEx = 3; 27 | 28 | /** 29 | * Content should be accessed statically 30 | */ 31 | private StandardTokenType() { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/matcher/Matcher.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.matcher; 18 | 19 | import java.util.List; 20 | 21 | @FunctionalInterface 22 | public interface Matcher { 23 | 24 | static List>> createMatchers(final String selector) { 25 | return createMatchers(selector, NameMatcher.DEFAULT); 26 | } 27 | 28 | static List>> createMatchers(final String selector, 29 | final NameMatcher> matchesName) { 30 | return new MatcherBuilder<>(selector, matchesName).results; 31 | } 32 | 33 | boolean matches(T t); 34 | } 35 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/matcher/MatcherWithPriority.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.matcher; 18 | 19 | public final class MatcherWithPriority { 20 | 21 | public final Matcher matcher; 22 | public final int priority; 23 | 24 | MatcherWithPriority(final Matcher matcher, final int priority) { 25 | this.matcher = matcher; 26 | this.priority = priority; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigScanner.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/atom/node-oniguruma 10 | * Initial copyright Copyright (c) 2013 GitHub Inc. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - GitHub Inc.: Initial code, written in JavaScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.oniguruma; 18 | 19 | import java.util.List; 20 | 21 | import org.eclipse.jdt.annotation.Nullable; 22 | 23 | /** 24 | * @see 25 | * github.com/atom/node-oniguruma/blob/master/src/onig-scanner.cc 26 | */ 27 | public final class OnigScanner { 28 | 29 | private final OnigSearcher searcher; 30 | 31 | public OnigScanner(final List regexps) { 32 | searcher = new OnigSearcher(regexps); 33 | } 34 | 35 | @Nullable 36 | public OnigScannerMatch findNextMatch(final OnigString source, final int startPosition) { 37 | final OnigResult bestResult = searcher.search(source, startPosition); 38 | if (bestResult != null) { 39 | return new OnigScannerMatch(bestResult, source); 40 | } 41 | return null; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/parser/PropertySettable.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022 Sebastian Thomschke and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Sebastian Thomschke - initial implementation 12 | */ 13 | package org.eclipse.tm4e.core.internal.parser; 14 | 15 | public interface PropertySettable { 16 | 17 | public class ArrayList extends java.util.ArrayList implements PropertySettable { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | @Override 22 | public void setProperty(final String name, final T value) { 23 | final var idx = Integer.parseInt(name); 24 | if (idx == size()) 25 | add(value); 26 | else 27 | set(idx, value); 28 | } 29 | } 30 | 31 | public class HashMap extends java.util.HashMap implements PropertySettable { 32 | 33 | private static final long serialVersionUID = 1L; 34 | 35 | @Override 36 | public void setProperty(final String name, final T value) { 37 | put(name, value); 38 | } 39 | } 40 | 41 | void setProperty(String name, V value); 42 | } 43 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/parser/TMParserYAML.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023 Vegard IT GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * Sebastian Thomschke (Vegard IT) - initial implementation 12 | */ 13 | package org.eclipse.tm4e.core.internal.parser; 14 | 15 | import java.io.Reader; 16 | import java.util.ArrayList; 17 | import java.util.HashMap; 18 | import java.util.HashSet; 19 | import java.util.Map; 20 | 21 | import org.snakeyaml.engine.v2.api.Load; 22 | import org.snakeyaml.engine.v2.api.LoadSettings; 23 | 24 | public final class TMParserYAML extends TMParserJSON { 25 | 26 | public static final TMParserYAML INSTANCE = new TMParserYAML(); 27 | 28 | private static final LoadSettings LOAD_SETTINGS = LoadSettings.builder() 29 | .setDefaultList(ArrayList::new) 30 | .setDefaultMap(HashMap::new) 31 | .setDefaultSet(HashSet::new) 32 | .build(); 33 | 34 | @Override 35 | @SuppressWarnings({ "null", "unchecked" }) 36 | protected Map loadRaw(final Reader source) { 37 | return (Map) new Load(LOAD_SETTINGS).loadFromReader(source); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/registry/IGrammarRepository.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.registry; 18 | 19 | import java.util.Collection; 20 | 21 | import org.eclipse.jdt.annotation.Nullable; 22 | import org.eclipse.tm4e.core.internal.grammar.raw.IRawGrammar; 23 | 24 | /** 25 | * TextMate grammar repository API. 26 | * 27 | * @see 29 | * github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammar.ts 30 | */ 31 | public interface IGrammarRepository { 32 | 33 | /** 34 | * Lookup a raw grammar. 35 | */ 36 | @Nullable 37 | IRawGrammar lookup(String scopeName); 38 | 39 | /** 40 | * Returns the injections for the given grammar 41 | */ 42 | @Nullable 43 | Collection injections(String targetScope); 44 | } 45 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/registry/IThemeProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | */ 12 | package org.eclipse.tm4e.core.internal.registry; 13 | 14 | import org.eclipse.jdt.annotation.Nullable; 15 | import org.eclipse.tm4e.core.internal.grammar.ScopeStack; 16 | import org.eclipse.tm4e.core.internal.theme.StyleAttributes; 17 | 18 | /** 19 | * @see 21 | * github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammar.ts 22 | */ 23 | public interface IThemeProvider { 24 | 25 | @Nullable 26 | StyleAttributes themeMatch(ScopeStack scopePath); 27 | 28 | StyleAttributes getDefaults(); 29 | } 30 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/CompilePatternsResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.rule; 18 | 19 | /** 20 | * @see 22 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts 23 | */ 24 | final class CompilePatternsResult { 25 | 26 | final RuleId[] patterns; 27 | final boolean hasMissingPatterns; 28 | 29 | CompilePatternsResult(final RuleId[] patterns, final boolean hasMissingPatterns) { 30 | this.hasMissingPatterns = hasMissingPatterns; 31 | this.patterns = patterns; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/CompiledRule.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.rule; 18 | 19 | import java.util.List; 20 | 21 | import org.eclipse.tm4e.core.internal.oniguruma.OnigScanner; 22 | 23 | /** 24 | * @see 26 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts 27 | */ 28 | public final class CompiledRule { 29 | 30 | public final List debugRegExps; 31 | public final OnigScanner scanner; 32 | public final RuleId[] rules; 33 | 34 | CompiledRule(final List regExps, final RuleId[] rules) { 35 | this.debugRegExps = regExps; 36 | this.rules = rules; 37 | this.scanner = new OnigScanner(regExps); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/IGrammarRegistry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.rule; 18 | 19 | import org.eclipse.jdt.annotation.Nullable; 20 | import org.eclipse.tm4e.core.internal.grammar.raw.IRawGrammar; 21 | import org.eclipse.tm4e.core.internal.grammar.raw.IRawRepository; 22 | 23 | /** 24 | * @see 26 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts 27 | */ 28 | interface IGrammarRegistry { 29 | 30 | @Nullable 31 | IRawGrammar getExternalGrammar(String scopeName, IRawRepository repository); 32 | } 33 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/IRuleFactoryHelper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.rule; 18 | 19 | /** 20 | * @see 22 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts 23 | */ 24 | public interface IRuleFactoryHelper extends IRuleRegistry, IGrammarRegistry { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/IRuleRegistry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.internal.rule; 18 | 19 | import java.util.function.Function; 20 | 21 | /** 22 | * @see 24 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts 25 | */ 26 | public interface IRuleRegistry { 27 | 28 | /** 29 | * @throws IndexOutOfBoundsException if no rule with the given id was found. 30 | */ 31 | Rule getRule(RuleId ruleId); 32 | 33 | T registerRule(Function factory); 34 | } 35 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/theme/IThemeSetting.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | */ 12 | package org.eclipse.tm4e.core.internal.theme; 13 | 14 | import org.eclipse.jdt.annotation.Nullable; 15 | 16 | public interface IThemeSetting { 17 | 18 | @Nullable 19 | Object getFontStyle(); 20 | 21 | @Nullable 22 | String getBackground(); 23 | 24 | @Nullable 25 | String getForeground(); 26 | } 27 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/theme/raw/IRawTheme.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | */ 12 | package org.eclipse.tm4e.core.internal.theme.raw; 13 | 14 | import java.util.Collection; 15 | 16 | import org.eclipse.jdt.annotation.Nullable; 17 | 18 | public interface IRawTheme { 19 | 20 | @Nullable 21 | String getName(); 22 | 23 | @Nullable 24 | Collection getSettings(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/theme/raw/IRawThemeSetting.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | */ 12 | package org.eclipse.tm4e.core.internal.theme.raw; 13 | 14 | import org.eclipse.jdt.annotation.Nullable; 15 | import org.eclipse.tm4e.core.internal.theme.IThemeSetting; 16 | 17 | /** 18 | * A single theme setting. 19 | * 20 | * @see 21 | * github.com/microsoft/vscode-textmate/blob/main/src/theme.ts 22 | */ 23 | public interface IRawThemeSetting { 24 | 25 | @Nullable 26 | String getName(); 27 | 28 | @Nullable 29 | Object getScope(); 30 | 31 | @Nullable 32 | IThemeSetting getSetting(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/internal/utils/ScopeNames.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Sebastian Thomschke and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Contributors: 11 | * - Sebastian Thomschke - initial API and implementation 12 | */ 13 | package org.eclipse.tm4e.core.internal.utils; 14 | 15 | import org.eclipse.jdt.annotation.Nullable; 16 | 17 | /** 18 | * Utility class to deal with plugin scoped TextMate Scope Names, e.g. "source.batchfile@com.example.myplugin" 19 | */ 20 | public final class ScopeNames { 21 | 22 | public static final char CONTRIBUTOR_SEPARATOR = '@'; 23 | 24 | public static @Nullable String getContributor(final String scopeName) { 25 | final int separatorAt = scopeName.indexOf(CONTRIBUTOR_SEPARATOR); 26 | if (separatorAt == -1) { 27 | return ""; 28 | } 29 | return scopeName.substring(separatorAt + 1); 30 | } 31 | 32 | /** 33 | * @return true if a scope name is suffixed by the contributing plugin id, e.g. "source.batchfile@com.example.myplugin" 34 | */ 35 | public static boolean hasContributor(final String scopeName) { 36 | return scopeName.indexOf(CONTRIBUTOR_SEPARATOR) > -1; 37 | } 38 | 39 | public static String withoutContributor(final String scopeName) { 40 | final int separatorAt = scopeName.indexOf(CONTRIBUTOR_SEPARATOR); 41 | if (separatorAt == -1) { 42 | return scopeName; 43 | } 44 | return scopeName.substring(0, separatorAt); 45 | } 46 | 47 | private ScopeNames() { 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/registry/IGrammarConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022 Sebastian Thomschke and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Initial code from https://github.com/microsoft/vscode-textmate/ 11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 12 | * Initial license: MIT 13 | * 14 | * Contributors: 15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 16 | * - Sebastian Thomschke - translation and adaptation to Java 17 | */ 18 | package org.eclipse.tm4e.core.registry; 19 | 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | import org.eclipse.jdt.annotation.Nullable; 24 | 25 | /** 26 | * @see 28 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts 29 | */ 30 | public interface IGrammarConfiguration { 31 | 32 | @Nullable 33 | default Map getEmbeddedLanguages() { 34 | return null; 35 | } 36 | 37 | @Nullable 38 | default Map getTokenTypes() { 39 | return null; 40 | } 41 | 42 | @Nullable 43 | default List getBalancedBracketSelectors() { 44 | return null; 45 | } 46 | 47 | @Nullable 48 | default List getUnbalancedBracketSelectors() { 49 | return null; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/core/registry/IRegistryOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Initial code from https://github.com/microsoft/vscode-textmate/ 10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 11 | * Initial license: MIT 12 | * 13 | * Contributors: 14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 15 | * - Angelo Zerr - translation and adaptation to Java 16 | */ 17 | package org.eclipse.tm4e.core.registry; 18 | 19 | import java.util.Collection; 20 | import java.util.List; 21 | 22 | import org.eclipse.jdt.annotation.Nullable; 23 | import org.eclipse.tm4e.core.internal.theme.raw.IRawTheme; 24 | 25 | /** 26 | * @see 28 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts 29 | */ 30 | public interface IRegistryOptions { 31 | 32 | @Nullable 33 | default IRawTheme getTheme() { 34 | return null; 35 | } 36 | 37 | @Nullable 38 | default List getColorMap() { 39 | return null; 40 | } 41 | 42 | @Nullable 43 | default IGrammarSource getGrammarSource(@SuppressWarnings("unused") final String scopeName) { 44 | return null; 45 | } 46 | 47 | @Nullable 48 | default Collection getInjections(@SuppressWarnings("unused") final String scopeName) { 49 | return null; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/model/AutoClosingPair.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022 Sebastian Thomschke and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Initial code from https://github.com/microsoft/vscode-textmate/ 11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 12 | * Initial license: MIT 13 | * 14 | * Contributors: 15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 16 | * - Sebastian Thomschke - translation and adaptation to Java 17 | */ 18 | package org.eclipse.tm4e.languageconfiguration.internal.model; 19 | 20 | /** 21 | * @see 23 | * github.com/microsoft/vscode/blob/main/src/vs/editor/common/languages/languageConfiguration.ts#L196 24 | */ 25 | public class AutoClosingPair extends CharacterPair { 26 | 27 | public AutoClosingPair(final String open, final String close) { 28 | super(open, close); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/model/AutoClosingPairConditional.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | * 7 | * SPDX-License-Identifier: EPL-2.0 8 | * 9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | */ 12 | package org.eclipse.tm4e.languageconfiguration.internal.model; 13 | 14 | import androidx.annotation.NonNull; 15 | 16 | import java.util.List; 17 | 18 | import org.eclipse.tm4e.core.internal.utils.StringUtils; 19 | 20 | /** 21 | * @see 23 | * github.com/microsoft/vscode/blob/main/src/vs/editor/common/languages/languageConfiguration.ts#L201 24 | */ 25 | public final class AutoClosingPairConditional extends AutoClosingPair { 26 | 27 | public final List notIn; 28 | 29 | public AutoClosingPairConditional(final String open, final String close, final List notIn) { 30 | super(open, close); 31 | this.notIn = notIn; 32 | } 33 | 34 | @NonNull 35 | @Override 36 | public String toString() { 37 | return StringUtils.toString(this, sb -> sb 38 | .append("open=").append(open).append(", ") 39 | .append("close=").append(close).append(", ") 40 | .append("notIn=").append(notIn)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/model/IndentForEnter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Vegard IT GmbH and others. 3 | * 4 | * This program and the accompanying materials are made 5 | * available under the terms of the Eclipse Public License 2.0 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 7 | * 8 | * SPDX-License-Identifier: EPL-2.0 9 | * 10 | * Initial code from https://github.com/microsoft/vscode/ 11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved. 12 | * Initial license: MIT 13 | * 14 | * Contributors: 15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license 16 | * - Sebastian Thomschke - translation and adaptation to Java 17 | */ 18 | package org.eclipse.tm4e.languageconfiguration.internal.model; 19 | 20 | import org.eclipse.tm4e.core.internal.utils.StringUtils; 21 | 22 | /** 23 | * Describes indentation rules for a language. 24 | * 25 | * @see 27 | * github.com/microsoft/vscode/blob/main/src/vs/editor/common/languages/autoIndent.ts#L278 28 | */ 29 | public class IndentForEnter { 30 | 31 | public final String beforeEnter; 32 | public final String afterEnter; 33 | 34 | public IndentForEnter(final String beforeEnter, final String afterEnter) { 35 | this.beforeEnter = beforeEnter; 36 | this.afterEnter = afterEnter; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return StringUtils.toString(this, sb -> sb 42 | .append("beforeEnter=").append(beforeEnter).append(", ") 43 | .append("afterEnter=").append(afterEnter)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /language-textmate/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/utils/RegExpUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-2017 Angelo ZERR. 3 | * This program and the accompanying materials are made 4 | * available under the terms of the Eclipse Public License 2.0 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ 6 | *

7 | * SPDX-License-Identifier: EPL-2.0 8 | *

9 | * Contributors: 10 | * Angelo Zerr - initial API and implementation 11 | */ 12 | package org.eclipse.tm4e.languageconfiguration.internal.utils; 13 | 14 | 15 | import java.util.regex.Pattern; 16 | 17 | import org.eclipse.jdt.annotation.Nullable; 18 | 19 | import io.github.rosemoe.sora.util.Logger; 20 | 21 | /** 22 | * Regex utilities. 23 | */ 24 | public final class RegExpUtils { 25 | 26 | private static final Logger log = Logger.instance(RegExpUtils.class.getName()); 27 | 28 | /** 29 | * Escapes regular expression characters in a given string 30 | */ 31 | public static String escapeRegExpCharacters(final String value) { 32 | return value.replaceAll("[\\-\\\\\\{\\}\\*\\+\\?\\|\\^\\$\\.\\[\\]\\(\\)\\#]", "\\\\$0"); //$NON-NLS-1$ //$NON-NLS-2$ 33 | } 34 | 35 | /** 36 | * Create Java Regexp and null otherwise. 37 | * 38 | * @return Java Regexp and null otherwise. 39 | */ 40 | @Nullable 41 | public static Pattern create(final String regex) { 42 | try { 43 | return Pattern.compile(regex); 44 | } catch (final Exception ex) { 45 | log.e("Failed to parse pattern: " + regex, ex); 46 | return null; 47 | } 48 | } 49 | 50 | private RegExpUtils() { 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /language-treesitter/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /language-treesitter/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/language-treesitter/consumer-rules.pro -------------------------------------------------------------------------------- /language-treesitter/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /language-treesitter/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /language-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/multilang/LanguagePriorityCheck.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.editor.ts.multilang 26 | 27 | interface LanguagePriorityCheck { 28 | 29 | companion object { 30 | val PRIORITY_NEVER = 0 31 | val PRIORITY_AS_FALLBACK = 1 32 | val PRIORITY_ALWAYS = 1000 33 | } 34 | 35 | fun getPriorityByName(name: String) : Int 36 | 37 | } -------------------------------------------------------------------------------- /language-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/multilang/TsIndentHelper.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.editor.ts.multilang 26 | 27 | interface TsIndentHelper { 28 | } -------------------------------------------------------------------------------- /language-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/predicate/TsClientPredicateStep.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.editor.ts.predicate 26 | 27 | import com.itsaky.androidide.treesitter.TSQueryPredicateStep 28 | 29 | data class TsClientPredicateStep( 30 | val predicateType: TSQueryPredicateStep.Type, 31 | val content: String 32 | ) 33 | -------------------------------------------------------------------------------- /language-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/predicate/TsSyntheticCapture.kt: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * sora-editor - the awesome code editor for Android 3 | * https://github.com/Rosemoe/sora-editor 4 | * Copyright (C) 2020-2024 Rosemoe 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 19 | * USA 20 | * 21 | * Please contact Rosemoe by email 2073412493@qq.com if you need 22 | * additional information or have any questions 23 | ******************************************************************************/ 24 | 25 | package io.github.rosemoe.sora.editor.ts.predicate 26 | 27 | import com.itsaky.androidide.treesitter.TSNode 28 | 29 | data class TsSyntheticCapture( 30 | val captureName: String, 31 | val captureText: String? = null, 32 | val captureNode: TSNode? = null 33 | ) -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base", ":disableDependencyDashboard" 5 | ] 6 | } 7 | --------------------------------------------------------------------------------