This repository has been archived by the owner on May 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from ShyykoSerhiy/dev
Dev
- Loading branch information
Showing
7 changed files
with
116 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.github.shyykoserhiy.gfm.ui; | ||
|
||
import com.intellij.ide.highlighter.HighlighterFactory; | ||
import com.intellij.openapi.editor.Document; | ||
import com.intellij.openapi.editor.Editor; | ||
import com.intellij.openapi.editor.EditorFactory; | ||
import com.intellij.openapi.editor.EditorSettings; | ||
import com.intellij.openapi.editor.colors.EditorColorsManager; | ||
import com.intellij.openapi.editor.ex.EditorEx; | ||
import com.intellij.openapi.editor.highlighter.EditorHighlighter; | ||
import com.intellij.openapi.fileTypes.FileType; | ||
import com.intellij.openapi.fileTypes.FileTypeManager; | ||
import com.intellij.openapi.fileTypes.UnknownFileType; | ||
|
||
public class Utils { | ||
public static Editor createEditor(String fileExtension) { | ||
EditorFactory editorFactory = EditorFactory.getInstance(); | ||
Document editorDocument = editorFactory.createDocument(""); | ||
EditorEx editor = (EditorEx) editorFactory.createEditor(editorDocument); | ||
fillEditorSettings(editor.getSettings()); | ||
setHighlighting(editor, fileExtension); | ||
return editor; | ||
} | ||
|
||
private static void setHighlighting(EditorEx editor, String fileExtension) { | ||
FileType cssFileType = FileTypeManager.getInstance().getFileTypeByExtension(fileExtension); | ||
if (cssFileType != UnknownFileType.INSTANCE) { | ||
EditorHighlighter editorHighlighter = HighlighterFactory.createHighlighter(cssFileType, EditorColorsManager.getInstance().getGlobalScheme(), null); | ||
editor.setHighlighter(editorHighlighter); | ||
} | ||
} | ||
|
||
private static void fillEditorSettings(EditorSettings editorSettings) { | ||
editorSettings.setWhitespacesShown(false); | ||
editorSettings.setLineMarkerAreaShown(false); | ||
editorSettings.setIndentGuidesShown(false); | ||
editorSettings.setLineNumbersShown(true); | ||
editorSettings.setFoldingOutlineShown(false); | ||
editorSettings.setAdditionalColumnsCount(1); | ||
editorSettings.setAdditionalLinesCount(1); | ||
editorSettings.setUseSoftWraps(false); | ||
} | ||
} |