Browse Source

Add "unstyled" formatter func to strip control codes.

Closes #755
pull/760/head
Chris Smith 7 years ago
parent
commit
65174b6ca6

+ 1
- 0
src/main/java/com/dmdirc/ui/messages/EventPropertyManager.java View File

@@ -54,6 +54,7 @@ public class EventPropertyManager {
54 54
         functions.put("lowercase", String::toLowerCase);
55 55
         functions.put("trim", String::trim);
56 56
         functions.put("bracketed", s -> Strings.isNullOrEmpty(s) ? "" : " (" + s + ')');
57
+        functions.put("unstyled", new StyledMessageUtils()::stripControlCodes);
57 58
     }
58 59
 
59 60
     public <S> Optional<Object> getProperty(final S object, final Class<? extends S> type, final String property) {

+ 1
- 0
src/test/java/com/dmdirc/ui/messages/EventPropertyManagerTest.java View File

@@ -56,6 +56,7 @@ public class EventPropertyManagerTest {
56 56
         assertEquals("test 123", manager.applyFunction("TeSt 123", "lowercase"));
57 57
         assertEquals("TEST 123", manager.applyFunction("TeSt 123", "uppercase"));
58 58
         assertEquals("TeSt 123", manager.applyFunction("  TeSt 123  ", "trim"));
59
+        assertEquals("TeSt 123", manager.applyFunction("\2TeSt \4FFFFFF123", "unstyled"));
59 60
     }
60 61
 
61 62
     @Test

Loading…
Cancel
Save