Skip to content

Commit 87c0d9a

Browse files
committed
Merge commit 'aead840509c92072a3dbaaa253fa7521f57e9d7b'
2 parents cc583e6 + aead840 commit 87c0d9a

File tree

120 files changed

+15103
-6319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+15103
-6319
lines changed

third_party/RSyntaxTextArea/README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Coverage Status](https://coveralls.io/repos/bobbylight/RSyntaxTextArea/badge.svg)](https://coveralls.io/r/bobbylight/RSyntaxTextArea)
44

55
RSyntaxTextArea is a customizable, syntax highlighting text component for Java Swing applications. Out of
6-
the box, it supports syntax highlighting for 40+ programming languages, code folding, search and replace,
6+
the box, it supports syntax highlighting for 50+ programming languages, code folding, search and replace,
77
and has add-on libraries for code completion and spell checking. Syntax highlighting for additional languages
88
[can be added](https://github.com/bobbylight/RSyntaxTextArea/wiki) via tools such as [JFlex](http://jflex.de).
99

@@ -30,35 +30,34 @@ RSyntaxTextArea is simply a subclass of JTextComponent, so it can be dropped int
3030
```java
3131
import javax.swing.*;
3232
import java.awt.BorderLayout;
33+
3334
import org.fife.ui.rtextarea.*;
3435
import org.fife.ui.rsyntaxtextarea.*;
3536

3637
public class TextEditorDemo extends JFrame {
3738

38-
public TextEditorDemo() {
39+
public TextEditorDemo() {
3940

40-
JPanel cp = new JPanel(new BorderLayout());
41+
JPanel cp = new JPanel(new BorderLayout());
4142

42-
RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
43-
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
44-
textArea.setCodeFoldingEnabled(true);
45-
RTextScrollPane sp = new RTextScrollPane(textArea);
46-
cp.add(sp);
43+
RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
44+
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
45+
textArea.setCodeFoldingEnabled(true);
46+
RTextScrollPane sp = new RTextScrollPane(textArea);
47+
cp.add(sp);
4748

48-
setContentPane(cp);
49-
setTitle("Text Editor Demo");
50-
setDefaultCloseOperation(EXIT_ON_CLOSE);
51-
pack();
52-
setLocationRelativeTo(null);
49+
setContentPane(cp);
50+
setTitle("Text Editor Demo");
51+
setDefaultCloseOperation(EXIT_ON_CLOSE);
52+
pack();
53+
setLocationRelativeTo(null);
5354

54-
}
55+
}
5556

56-
public static void main(String[] args) {
57-
// Start all Swing applications on the EDT.
58-
SwingUtilities.invokeLater(() -> {
59-
new TextEditorDemo().setVisible(true);
60-
});
61-
}
57+
public static void main(String[] args) {
58+
// Start all Swing applications on the EDT.
59+
SwingUtilities.invokeLater(() -> new TextEditorDemo().setVisible(true));
60+
}
6261

6362
}
6463
```

third_party/RSyntaxTextArea/RSyntaxTextArea/src/main/java/org/fife/io/UnicodeWriter.java

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,24 +218,28 @@ private void init(OutputStream out, String encoding) throws IOException {
218218

219219
// Write the proper BOM if they specified a Unicode encoding.
220220
// NOTE: Creating an OutputStreamWriter with encoding "UTF-16" DOES
221-
// DOES write out the BOM; "UTF-16LE", "UTF-16BE", "UTF-32", "UTF-32LE"
221+
// write out the BOM; "UTF-16LE", "UTF-16BE", "UTF-32", "UTF-32LE"
222222
// and "UTF-32BE" don't.
223-
if ("UTF-8".equals(encoding)) {
224-
if (getWriteUtf8BOM()) {
225-
out.write(UTF8_BOM, 0, UTF8_BOM.length);
226-
}
227-
}
228-
else if ("UTF-16LE".equals(encoding)) {
229-
out.write(UTF16LE_BOM, 0, UTF16LE_BOM.length);
230-
}
231-
else if (/*"UTF-16".equals(encoding) || */"UTF-16BE".equals(encoding)) {
232-
out.write(UTF16BE_BOM, 0, UTF16BE_BOM.length);
233-
}
234-
else if ("UTF-32LE".equals(encoding)) {
235-
out.write(UTF32LE_BOM, 0, UTF32LE_BOM.length);
236-
}
237-
else if ("UTF-32".equals(encoding) || "UTF-32BE".equals(encoding)) {
238-
out.write(UTF32BE_BOM, 0, UTF32BE_BOM.length);
223+
switch (encoding) {
224+
case "UTF-8":
225+
if (getWriteUtf8BOM()) {
226+
out.write(UTF8_BOM, 0, UTF8_BOM.length);
227+
}
228+
break;
229+
case "UTF-16LE":
230+
out.write(UTF16LE_BOM, 0, UTF16LE_BOM.length);
231+
break;
232+
//case "UTF-16": // Already writes the BOM, so we don't
233+
case "UTF-16BE":
234+
out.write(UTF16BE_BOM, 0, UTF16BE_BOM.length);
235+
break;
236+
case "UTF-32LE":
237+
out.write(UTF32LE_BOM, 0, UTF32LE_BOM.length);
238+
break;
239+
case "UTF-32":
240+
case "UTF-32BE":
241+
out.write(UTF32BE_BOM, 0, UTF32BE_BOM.length);
242+
break;
239243
}
240244

241245
}

third_party/RSyntaxTextArea/RSyntaxTextArea/src/main/java/org/fife/print/RPrintUtilities.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static int printDocumentMonospaced(Graphics g, Document doc, int fontSize
185185
}
186186
}
187187

188-
curLineString = curLineString.substring(maxCharsPerLine, curLineString.length());
188+
curLineString = curLineString.substring(maxCharsPerLine);
189189

190190
}
191191

@@ -298,7 +298,7 @@ public static int printDocumentMonospacedWordWrap(Graphics g, Document doc,
298298
}
299299

300300
// If this document line is too long to fit on one printed line on the page,
301-
// break it up into multpile lines.
301+
// break it up into multiple lines.
302302
while (curLineString.length() > maxCharsPerLine) {
303303

304304
int breakPoint = getLineBreakPoint(curLineString, maxCharsPerLine) + 1;
@@ -312,7 +312,7 @@ public static int printDocumentMonospacedWordWrap(Graphics g, Document doc,
312312
}
313313
}
314314

315-
curLineString = curLineString.substring(breakPoint, curLineString.length());
315+
curLineString = curLineString.substring(breakPoint);
316316

317317
}
318318

@@ -415,7 +415,7 @@ public static int printDocumentWordWrap(Graphics g, JTextComponent textComponent
415415
// Remove any spaces and/or tabs from the end of the segment (would cause problems if you left 'em).
416416
currentLineSeg = removeEndingWhitespace(currentLineSeg);
417417

418-
// Figger out how long the line is, in pixels.
418+
// Figure out how long the line is, in pixels.
419419
int currentLineLengthInPixels = Utilities.getTabbedTextWidth(currentLineSeg, fm, 0, tabExpander, 0);
420420

421421
//System.err.println("'" + currentLineSeg + "' - " + currentLineLengthInPixels + "/" + LINE_LENGTH_IN_PIXELS);
@@ -464,7 +464,7 @@ public static int printDocumentWordWrap(Graphics g, JTextComponent textComponent
464464
try {
465465
doc.getText(currentLineStart+startingOffset, currentPos, currentLineSeg);
466466
} catch (BadLocationException ble) {
467-
System.err.println(ble);
467+
ble.printStackTrace();
468468
return Printable.NO_SUCH_PAGE;
469469
}
470470
currentLineLengthInPixels = Utilities.

third_party/RSyntaxTextArea/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/DefaultTokenMakerFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ protected void initTokenMakerMap() {
5454
putMapping(SYNTAX_STYLE_JSON_WITH_COMMENTS, pkg + "JshintrcTokenMaker");
5555
putMapping(SYNTAX_STYLE_JSON, pkg + "JsonTokenMaker");
5656
putMapping(SYNTAX_STYLE_JSP, pkg + "JSPTokenMaker");
57+
putMapping(SYNTAX_STYLE_KOTLIN, pkg + "KotlinTokenMaker");
5758
putMapping(SYNTAX_STYLE_LATEX, pkg + "LatexTokenMaker");
5859
putMapping(SYNTAX_STYLE_LESS, pkg + "LessTokenMaker");
5960
putMapping(SYNTAX_STYLE_LISP, pkg + "LispTokenMaker");

third_party/RSyntaxTextArea/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/HtmlUtil.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,67 @@ private HtmlUtil() {
2828
public static String escapeForHtml(String s, String newlineReplacement,
2929
boolean inPreBlock) {
3030

31+
if (s==null) {
32+
return null;
33+
}
3134
if (newlineReplacement==null) {
3235
newlineReplacement = "";
3336
}
37+
38+
// Always all   instead of an initial ' ' so we always play
39+
// nice when there's intermixed spaces and tabs
3440
String tabString = inPreBlock ? " " : "    ";
41+
boolean lastWasSpace = false;
3542

3643
StringBuilder sb = new StringBuilder();
3744

3845
for (int i=0; i<s.length(); i++) {
3946
char ch = s.charAt(i);
4047
switch (ch) {
4148
case ' ':
42-
if (inPreBlock) {
49+
if (inPreBlock || !lastWasSpace) {
4350
sb.append(' ');
4451
}
4552
else {
4653
sb.append("&nbsp;");
4754
}
55+
lastWasSpace = true;
4856
break;
4957
case '\n':
5058
sb.append(newlineReplacement);
59+
lastWasSpace = false;
5160
break;
5261
case '&':
5362
sb.append("&amp;");
63+
lastWasSpace = false;
5464
break;
5565
case '\t':
5666
sb.append(tabString);
67+
lastWasSpace = true;
5768
break;
5869
case '<':
5970
sb.append("&lt;");
71+
lastWasSpace = false;
6072
break;
6173
case '>':
6274
sb.append("&gt;");
75+
lastWasSpace = false;
76+
break;
77+
case '\'':
78+
sb.append("&#39;");
79+
lastWasSpace = false;
80+
break;
81+
case '"':
82+
sb.append("&#34;");
83+
lastWasSpace = false;
84+
break;
85+
case '/': // OWASP-recommended even though unnecessary
86+
sb.append("&#47;");
87+
lastWasSpace = false;
6388
break;
6489
default:
6590
sb.append(ch);
91+
lastWasSpace = false;
6692
break;
6793
}
6894
}

third_party/RSyntaxTextArea/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/MatchedBracketPopup.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,48 @@
4242
* @author Robert Futrell
4343
* @version 1.0
4444
*/
45-
class MatchedBracketPopup extends JWindow {
45+
public class MatchedBracketPopup extends JWindow {
46+
47+
/**
48+
* If this system property is defined and set to {@code true},
49+
* matched bracket popups may render with the text area's background
50+
* color if necessary to facilitate contrast between their text content
51+
* (typically code) and their backgrounds. This is necessary for
52+
* good looking popups when a text area's background may be drastically
53+
* different than the Look and Feel's tool tip color (e.g. dark editor
54+
* embedded in a "light" themed application, or vice versa).
55+
* If this is omitted or does NOT evaluate to {@code true},
56+
* matched bracket popups will always render like "native" tool tips
57+
* according to the current Look and Feel.
58+
* Users typically don't need to set this to {@code true} unless
59+
* their application allows users to select a theme or color scheme
60+
* for {@code RSyntaxTextArea} instances separately from the Look
61+
* and Feel. For applications that instead only have one Look and
62+
* Feel/RSTA theme combo, or allow toggling between fixed light and
63+
* dark themes, the default of {@code false} is fine.
64+
*/
65+
public static final String PROPERTY_CONSIDER_TEXTAREA_BACKGROUND =
66+
"rsta.matchedBracket.considerTextAreaBackground";
4667

4768
private RSyntaxTextArea textArea;
4869

4970
private transient Listener listener;
5071

5172
private static final int LEFT_EMPTY_BORDER = 5;
52-
73+
private static final boolean CONSIDER_TEXTAREA_BG =
74+
Boolean.getBoolean(PROPERTY_CONSIDER_TEXTAREA_BACKGROUND);
5375

5476
MatchedBracketPopup(Window parent, RSyntaxTextArea textArea, int
5577
offsToRender) {
5678

5779
super(parent);
5880
this.textArea = textArea;
5981
JPanel cp = new JPanel(new BorderLayout());
82+
RSyntaxTextArea toolTipParam = CONSIDER_TEXTAREA_BG ? textArea : null;
6083
cp.setBorder(BorderFactory.createCompoundBorder(
61-
TipUtil.getToolTipBorder(),
84+
TipUtil.getToolTipBorder(toolTipParam),
6285
BorderFactory.createEmptyBorder(2, LEFT_EMPTY_BORDER, 5, 5)));
63-
cp.setBackground(TipUtil.getToolTipBackground());
86+
cp.setBackground(TipUtil.getToolTipBackground(toolTipParam));
6487
setContentPane(cp);
6588

6689
cp.add(new JLabel(getText(offsToRender)));

third_party/RSyntaxTextArea/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/RSyntaxTextArea.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
* </td>
9595
* <td style="vertical-align: top">
9696
* <ul>
97+
* <li>Kotlin
9798
* <li>LaTeX
9899
* <li>Lisp
99100
* <li>Lua

third_party/RSyntaxTextArea/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/RSyntaxUtilities.java

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -147,89 +147,6 @@ private RSyntaxUtilities() { // NOSONAR
147147
}
148148

149149

150-
/**
151-
* Returns a string with characters that are special to HTML (such as
152-
* <code>&lt;</code>, <code>&gt;</code> and <code>&amp;</code>) replaced
153-
* by their HTML escape sequences.
154-
*
155-
* @param s The input string.
156-
* @param newlineReplacement What to replace newline characters with.
157-
* If this is <code>null</code>, they are simply removed.
158-
* @param inPreBlock Whether this HTML will be in within <code>pre</code>
159-
* tags. If this is <code>true</code>, spaces will be kept as-is;
160-
* otherwise, they will be converted to "<code>&nbsp;</code>".
161-
* @return The escaped version of <code>s</code>.
162-
*/
163-
public static String escapeForHtml(String s,
164-
String newlineReplacement, boolean inPreBlock) {
165-
166-
if (s==null) {
167-
return null;
168-
}
169-
if (newlineReplacement==null) {
170-
newlineReplacement = "";
171-
}
172-
final String tabString = " ";
173-
boolean lastWasSpace = false;
174-
175-
StringBuilder sb = new StringBuilder();
176-
177-
for (int i=0; i<s.length(); i++) {
178-
char ch = s.charAt(i);
179-
switch (ch) {
180-
case ' ':
181-
if (inPreBlock || !lastWasSpace) {
182-
sb.append(' ');
183-
}
184-
else {
185-
sb.append("&nbsp;");
186-
}
187-
lastWasSpace = true;
188-
break;
189-
case '\n':
190-
sb.append(newlineReplacement);
191-
lastWasSpace = false;
192-
break;
193-
case '&':
194-
sb.append("&amp;");
195-
lastWasSpace = false;
196-
break;
197-
case '\t':
198-
sb.append(tabString);
199-
lastWasSpace = false;
200-
break;
201-
case '<':
202-
sb.append("&lt;");
203-
lastWasSpace = false;
204-
break;
205-
case '>':
206-
sb.append("&gt;");
207-
lastWasSpace = false;
208-
break;
209-
case '\'':
210-
sb.append("&#39;");
211-
lastWasSpace = false;
212-
break;
213-
case '"':
214-
sb.append("&#34;");
215-
lastWasSpace = false;
216-
break;
217-
case '/': // OWASP-recommended even though unnecessary
218-
sb.append("&#47;");
219-
lastWasSpace = false;
220-
break;
221-
default:
222-
sb.append(ch);
223-
lastWasSpace = false;
224-
break;
225-
}
226-
}
227-
228-
return sb.toString();
229-
230-
}
231-
232-
233150
/**
234151
* Returns the rendering hints for text that will most accurately reflect
235152
* those of the native windowing system.

third_party/RSyntaxTextArea/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/SyntaxConstants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ public interface SyntaxConstants {
197197
String SYNTAX_STYLE_JSP = "text/jsp";
198198

199199

200+
/**
201+
* Style for highlighting Kotlin.
202+
*/
203+
String SYNTAX_STYLE_KOTLIN = "text/kotlin";
204+
205+
200206
/**
201207
* Style for highlighting LaTeX.
202208
*/

0 commit comments

Comments
 (0)