-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00b4075
commit fcba251
Showing
4 changed files
with
95 additions
and
81 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/main/java/com/luoboduner/moo/tool/ui/component/RegexRTextScrollPane.java
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,34 @@ | ||
package com.luoboduner.moo.tool.ui.component; | ||
|
||
import com.formdev.flatlaf.FlatLaf; | ||
import com.luoboduner.moo.tool.App; | ||
import org.fife.ui.rtextarea.Gutter; | ||
import org.fife.ui.rtextarea.RTextScrollPane; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class RegexRTextScrollPane extends RTextScrollPane { | ||
// constructor | ||
public RegexRTextScrollPane(RegexSyntaxTextViewer textArea) { | ||
super(textArea); | ||
|
||
setMaximumSize(new Dimension(-1, -1)); | ||
setMinimumSize(new Dimension(-1, -1)); | ||
|
||
Color defaultBackground = App.mainFrame.getBackground(); | ||
|
||
Gutter gutter = getGutter(); | ||
if (FlatLaf.isLafDark()) { | ||
gutter.setBorderColor(gutter.getLineNumberColor().darker()); | ||
} else { | ||
gutter.setBorderColor(gutter.getLineNumberColor().brighter()); | ||
} | ||
gutter.setBackground(defaultBackground); | ||
Font font2 = new Font(App.config.getFont(), Font.PLAIN, App.config.getFontSize()); | ||
gutter.setLineNumberFont(font2); | ||
gutter.setBackground(UIManager.getColor("Editor.gutter.background")); | ||
gutter.setBorderColor(UIManager.getColor("Editor.gutter.borderColor")); | ||
gutter.setLineNumberColor(UIManager.getColor("Editor.gutter.lineNumberColor")); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/luoboduner/moo/tool/ui/component/RegexSyntaxTextViewer.java
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 |
---|---|---|
@@ -1,10 +1,68 @@ | ||
package com.luoboduner.moo.tool.ui.component; | ||
|
||
import com.formdev.flatlaf.FlatLaf; | ||
import com.luoboduner.moo.tool.App; | ||
import com.luoboduner.moo.tool.ui.form.func.TimeConvertForm; | ||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; | ||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants; | ||
import org.fife.ui.rsyntaxtextarea.Theme; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.io.IOException; | ||
|
||
public class RegexSyntaxTextViewer extends RSyntaxTextArea { | ||
public RegexSyntaxTextViewer() { | ||
|
||
setDoubleBuffered(true); | ||
|
||
try { | ||
Theme theme; | ||
if (FlatLaf.isLafDark()) { | ||
theme = Theme.load(RegexSyntaxTextViewer.class.getResourceAsStream( | ||
"/org/fife/ui/rsyntaxtextarea/themes/monokai.xml")); | ||
} else { | ||
theme = Theme.load(RegexSyntaxTextViewer.class.getResourceAsStream( | ||
"/org/fife/ui/rsyntaxtextarea/themes/idea.xml")); | ||
} | ||
theme.apply(this); | ||
} catch (IOException ioe) { // Never happens | ||
ioe.printStackTrace(); | ||
} | ||
|
||
setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE); | ||
setCodeFoldingEnabled(true); | ||
// setCurrentLineHighlightColor(new Color(52, 52, 52)); | ||
// setUseSelectedTextColor(true); | ||
// setSelectedTextColor(new Color(50, 50, 50)); | ||
|
||
// 初始化背景色 | ||
// Style.blackTextArea(this); | ||
setBackground(TimeConvertForm.getInstance().getTimeHisTextArea().getBackground()); | ||
// 初始化边距 | ||
setMargin(new Insets(10, 10, 10, 10)); | ||
|
||
// 初始化字体 | ||
String fontName = App.config.getJsonBeautyFontName(); | ||
int fontSize = App.config.getJsonBeautyFontSize(); | ||
if (fontSize == 0) { | ||
fontSize = getFont().getSize() + 2; | ||
} | ||
Font font = new Font(fontName, Font.PLAIN, fontSize); | ||
setFont(font); | ||
|
||
setHyperlinksEnabled(false); | ||
|
||
|
||
setBackground(UIManager.getColor("Editor.background")); | ||
setCaretColor(UIManager.getColor("Editor.caretColor")); | ||
setSelectionColor(UIManager.getColor("Editor.selectionBackground")); | ||
setCurrentLineHighlightColor(UIManager.getColor("Editor.currentLineHighlight")); | ||
setMarkAllHighlightColor(UIManager.getColor("Editor.markAllHighlightColor")); | ||
setMarkOccurrencesColor(UIManager.getColor("Editor.markOccurrencesColor")); | ||
setMatchedBracketBGColor(UIManager.getColor("Editor.matchedBracketBackground")); | ||
setMatchedBracketBorderColor(UIManager.getColor("Editor.matchedBracketBorderColor")); | ||
setPaintMatchedBracketPair(true); | ||
setAnimateBracketMatching(false); | ||
} | ||
} |
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