| 2910 | } |
| 2911 | |
| 2912 | void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) { |
| 2913 | const CodeEditorConfig& config = mConfig.editor; |
| 2914 | const DocumentConfig& docc = !mCurrentProject.empty() && !mProjectDocConfig.useGlobalSettings |
| 2915 | ? mProjectDocConfig.doc |
| 2916 | : mConfig.doc; |
| 2917 | editor->setFontSize( config.fontSize.asPixels( 0, Sizef(), mUISceneNode->getDPI() ) ); |
| 2918 | editor->setEnableColorPickerOnSelection( true ); |
| 2919 | editor->setDisplayLockedIcon( true ); |
| 2920 | editor->setColorScheme( mSplitter->getCurrentColorScheme() ); |
| 2921 | editor->setShowLineNumber( config.showLineNumbers ); |
| 2922 | editor->setShowWhitespaces( config.showWhiteSpaces ); |
| 2923 | editor->setShowLineEndings( config.showLineEndings ); |
| 2924 | editor->setShowIndentationGuides( config.showIndentationGuides ); |
| 2925 | editor->setHighlightMatchingBracket( config.highlightMatchingBracket ); |
| 2926 | editor->setVerticalScrollBarEnabled( config.verticalScrollbar ); |
| 2927 | editor->setHorizontalScrollBarEnabled( config.horizontalScrollbar ); |
| 2928 | editor->setHighlightCurrentLine( config.highlightCurrentLine ); |
| 2929 | editor->setTabWidth( docc.tabWidth ); |
| 2930 | editor->setLineBreakingColumn( docc.lineBreakingColumn ); |
| 2931 | editor->setHighlightSelectionMatch( config.highlightSelectionMatch ); |
| 2932 | editor->setEnableColorPickerOnSelection( config.colorPickerSelection ); |
| 2933 | editor->setColorPreview( config.colorPreview ); |
| 2934 | editor->setFont( mFontMono ); |
| 2935 | editor->setMenuIconSize( mMenuIconSize ); |
| 2936 | editor->setAutoCloseXMLTags( config.autoCloseXMLTags ); |
| 2937 | editor->setLineSpacing( config.lineSpacing ); |
| 2938 | editor->setCursorBlinkTime( config.cursorBlinkingTime ); |
| 2939 | editor->setLineWrapKeepIndentation( config.wrapKeepIndentation ); |
| 2940 | editor->setLineWrapMode( config.wrapMode ); |
| 2941 | editor->setLineWrapType( config.wrapType ); |
| 2942 | editor->setFoldDrawable( findIcon( "chevron-down", PixelDensity::dpToPxI( 12 ) ) ); |
| 2943 | editor->setFoldedDrawable( findIcon( "chevron-right", PixelDensity::dpToPxI( 12 ) ) ); |
| 2944 | editor->setTabStops( mConfig.doc.tabStops ); |
| 2945 | editor->setEnableInlineColorBoxes( config.inlineColorBoxes ); |
| 2946 | |
| 2947 | doc.setAutoCloseBrackets( !mConfig.editor.autoCloseBrackets.empty() ); |
| 2948 | doc.setAutoCloseBracketsPairs( makeAutoClosePairs( mConfig.editor.autoCloseBrackets ) ); |
| 2949 | doc.setLineEnding( docc.lineEndings ); |
| 2950 | doc.setTrimTrailingWhitespaces( docc.trimTrailingWhitespaces ); |
| 2951 | doc.setForceNewLineAtEndOfFile( docc.forceNewLineAtEndOfFile ); |
| 2952 | doc.setIndentType( docc.indentSpaces ? TextDocument::IndentType::IndentSpaces |
| 2953 | : TextDocument::IndentType::IndentTabs ); |
| 2954 | doc.setIndentWidth( docc.indentWidth ); |
| 2955 | doc.setAutoDetectIndentType( docc.autoDetectIndentType ); |
| 2956 | doc.setAutoIndent( docc.autoIndent ); |
| 2957 | doc.setBOM( docc.writeUnicodeBOM ); |
| 2958 | |
| 2959 | doc.getFoldRangeService().setEnabled( config.codeFoldingEnabled ); |
| 2960 | editor->setFoldsAlwaysVisible( config.codeFoldingAlwaysVisible ); |
| 2961 | editor->setFoldsRefreshTime( config.codeFoldingRefreshFreq ); |
| 2962 | |
| 2963 | if ( !config.tabIndentCharacter.empty() ) { |
| 2964 | String indentChar( config.tabIndentCharacter ); |
| 2965 | if ( indentChar.size() == 1 ) |
| 2966 | editor->setTabIndentCharacter( indentChar[0] ); |
| 2967 | } |
| 2968 | editor->setTabIndentAlignment( config.tabIndentAlignment ); |
| 2969 |
no test coverage detected