forked from bobbylight/RSyntaxTextArea
-
Notifications
You must be signed in to change notification settings - Fork 0
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
79ddef3
commit b1e8364
Showing
7 changed files
with
177 additions
and
21 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
26 changes: 26 additions & 0 deletions
26
RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/DefaultTokenPainterFactory.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,26 @@ | ||
/* | ||
* This library is distributed under a modified BSD license. See the included | ||
* LICENSE file for details. | ||
*/ | ||
package org.fife.ui.rsyntaxtextarea; | ||
|
||
|
||
/** | ||
* Standard implementation of a token painter factory. | ||
* | ||
* @author Robert Futrell | ||
* @version 1.0 | ||
* @see DefaultTokenPainter | ||
* @see VisibleWhitespaceTokenPainter | ||
*/ | ||
public class DefaultTokenPainterFactory implements TokenPainterFactory { | ||
|
||
|
||
@Override | ||
public TokenPainter getTokenPainter(RSyntaxTextArea textArea) { | ||
return textArea.isWhitespaceVisible() ? new VisibleWhitespaceTokenPainter() : | ||
new DefaultTokenPainter(); | ||
} | ||
|
||
|
||
} |
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
26 changes: 26 additions & 0 deletions
26
RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/TokenPainterFactory.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,26 @@ | ||
/* | ||
* This library is distributed under a modified BSD license. See the included | ||
* LICENSE file for details. | ||
*/ | ||
package org.fife.ui.rsyntaxtextarea; | ||
|
||
|
||
/** | ||
* Returns the {@link TokenPainter} to use for a text area. | ||
* | ||
* @author Robert Futrell | ||
* @version 1.0 | ||
*/ | ||
public interface TokenPainterFactory { | ||
|
||
|
||
/** | ||
* Returns the text area to use. | ||
* | ||
* @param textArea The text area. | ||
* @return The token painter. | ||
*/ | ||
TokenPainter getTokenPainter(RSyntaxTextArea textArea); | ||
|
||
|
||
} |
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
44 changes: 44 additions & 0 deletions
44
...taxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/DefaultTokenPainterFactoryTest.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,44 @@ | ||
/* | ||
* This library is distributed under a modified BSD license. See the included | ||
* LICENSE file for details. | ||
*/ | ||
package org.fife.ui.rsyntaxtextarea; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
|
||
/** | ||
* Unit tests for the {@link DefaultTokenPainterFactory} class. | ||
* | ||
* @author Robert Futrell | ||
* @version 1.0 | ||
*/ | ||
class DefaultTokenPainterFactoryTest extends AbstractRSyntaxTextAreaTest { | ||
|
||
private RSyntaxTextArea textArea; | ||
private DefaultTokenPainterFactory factory; | ||
|
||
|
||
@BeforeEach | ||
void setUp() { | ||
textArea = createTextArea(); | ||
factory = new DefaultTokenPainterFactory(); | ||
} | ||
|
||
|
||
@Test | ||
void testGetTokenPainter_dontShowWhitespace() { | ||
Assertions.assertEquals(DefaultTokenPainter.class, | ||
factory.getTokenPainter(textArea).getClass()); | ||
} | ||
|
||
|
||
@Test | ||
void testGetTokenPainter_showWhitespace() { | ||
textArea.setWhitespaceVisible(true); | ||
Assertions.assertEquals(VisibleWhitespaceTokenPainter.class, | ||
factory.getTokenPainter(textArea).getClass()); | ||
} | ||
} |