Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Commit 8296e81

Browse files
Haeribobbylight
authored andcommitted
Gutter Background
- Added gutterBackgroundColor with the according functions to read and write to xml - Adjusted theme.dtd to support the new gutter background color - Removed a stacktrace before a throw - Made GutterBorder public so that the margin can be changed
1 parent a30c809 commit 8296e81

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/main/java/org/fife/ui/rsyntaxtextarea/Theme.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public class Theme {
9595

9696
public SyntaxScheme scheme;
9797

98+
public Color gutterBackgroundColor;
9899
public Color gutterBorderColor;
99100
public Color activeLineRangeColor;
100101
public boolean iconRowHeaderInheritsGutterBG;
@@ -158,7 +159,7 @@ public Theme(RSyntaxTextArea textArea) {
158159

159160
Gutter gutter = RSyntaxUtilities.getGutter(textArea);
160161
if (gutter!=null) {
161-
bgColor = gutter.getBackground();
162+
gutterBackgroundColor = gutter.getBackground();
162163
gutterBorderColor = gutter.getBorderColor();
163164
activeLineRangeColor = gutter.getActiveLineRangeColor();
164165
iconRowHeaderInheritsGutterBG = gutter.getIconRowHeaderInheritsGutterBackground();
@@ -208,7 +209,7 @@ public void apply(RSyntaxTextArea textArea) {
208209

209210
Gutter gutter = RSyntaxUtilities.getGutter(textArea);
210211
if (gutter!=null) {
211-
gutter.setBackground(bgColor);
212+
gutter.setBackground(gutterBackgroundColor);
212213
gutter.setBorderColor(gutterBorderColor);
213214
gutter.setActiveLineRangeColor(activeLineRangeColor);
214215
gutter.setIconRowHeaderInheritsGutterBackground(iconRowHeaderInheritsGutterBG);
@@ -444,6 +445,10 @@ public void save(OutputStream out) throws IOException {
444445
}
445446
root.appendChild(elem);
446447

448+
elem = doc.createElement("gutterBackground");
449+
elem.setAttribute("color", colorToString(gutterBackgroundColor));
450+
root.appendChild(elem);
451+
447452
elem = doc.createElement("gutterBorder");
448453
elem.setAttribute("color", colorToString(gutterBorderColor));
449454
root.appendChild(elem);
@@ -620,7 +625,7 @@ public static void load(Theme theme, InputStream in) throws IOException {
620625
is.setEncoding("UTF-8");
621626
reader.parse(is);
622627
} catch (/*SAX|ParserConfiguration*/Exception se) {
623-
se.printStackTrace();
628+
// se.printStackTrace();
624629
throw new IOException(se.toString());
625630
}
626631
}
@@ -655,6 +660,7 @@ public void startElement(String uri, String localName, String qName,
655660
String color = attrs.getValue("color");
656661
if (color!=null) {
657662
theme.bgColor = stringToColor(color, getDefaultBG());
663+
theme.gutterBackgroundColor = theme.bgColor;
658664
}
659665
else {
660666
String img = attrs.getValue("image");
@@ -703,6 +709,13 @@ else if ("foldIndicator".equals(qName)) {
703709
theme.armedFoldBG = stringToColor(color);
704710
}
705711

712+
else if ("gutterBackground".equals(qName)) {
713+
String color = attrs.getValue("color");
714+
if (color!=null) {
715+
theme.gutterBackgroundColor = stringToColor(color);
716+
}
717+
}
718+
706719
else if ("gutterBorder".equals(qName)) {
707720
String color = attrs.getValue("color");
708721
theme.gutterBorderColor = stringToColor(color);

src/main/java/org/fife/ui/rtextarea/Gutter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,12 @@ public void setBorder(Border border) {
874874
/**
875875
* The border used by the gutter.
876876
*/
877-
private static class GutterBorder extends EmptyBorder {
877+
public static class GutterBorder extends EmptyBorder {
878878

879879
private Color color;
880880
private Rectangle visibleRect;
881881

882-
GutterBorder(int top, int left, int bottom, int right) {
882+
public GutterBorder(int top, int left, int bottom, int right) {
883883
super(top, left, bottom, right);
884884
color = new Color(221, 221, 221);
885885
visibleRect = new Rectangle();

src/main/resources/org/fife/ui/rsyntaxtextarea/themes/theme.dtd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- DTD for RSyntaxTextArea Theme XML. See /themes folder for examples. -->
22
<!ELEMENT RSyntaxTheme (baseFont?, background, caret, selection,
33
currentLineHighlight, marginLine, markAllHighlight, markOccurrencesHighlight,
4-
matchedBracket, hyperlinks, secondaryLanguages, gutterBorder, lineNumbers,
4+
matchedBracket, hyperlinks, secondaryLanguages, gutterBackground?, gutterBorder, lineNumbers,
55
foldIndicator, iconRowHeader?, tokenStyles)>
66
<!ELEMENT background EMPTY>
77
<!ELEMENT baseFont EMPTY>
@@ -15,6 +15,7 @@
1515
<!ELEMENT hyperlinks EMPTY>
1616
<!ELEMENT secondaryLanguages (language+)>
1717
<!ELEMENT language EMPTY>
18+
<!ELEMENT gutterBackground EMPTY>
1819
<!ELEMENT gutterBorder EMPTY>
1920
<!ELEMENT lineNumbers EMPTY>
2021
<!ELEMENT foldIndicator EMPTY>
@@ -56,6 +57,8 @@
5657
<!ATTLIST language
5758
index (1|2|3) #REQUIRED
5859
bg CDATA #REQUIRED>
60+
<!ATTLIST gutterBackground
61+
color CDATA #REQUIRED>
5962
<!ATTLIST gutterBorder
6063
color CDATA #REQUIRED>
6164
<!ATTLIST lineNumbers

0 commit comments

Comments
 (0)