Browse Source

Introduce string literal syntax and load some icon colors trough deferred property resolution at patch time.

pull/235/head
weisj 4 years ago
parent
commit
09083f0bfb
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 4
      core/src/main/resources/com/github/weisj/darklaf/properties/icons/files.properties
  2. 22
      core/src/main/resources/com/github/weisj/darklaf/properties/icons/frame.properties
  3. 10
      property-loader/src/main/java/com/github/weisj/darklaf/parser/ParserUtil.java
  4. 8
      property-loader/src/main/java/com/github/weisj/darklaf/parser/PrimitiveParser.java

4
core/src/main/resources/com/github/weisj/darklaf/properties/icons/files.properties

@ -24,5 +24,5 @@
#
# suppress inspection "UnusedProperty" for whole file
#
Icons.image.sky.color = %palette.teal
Icons.image.grass.color = %palette.green
Icons.image.sky.color = '%palette.teal'
Icons.image.grass.color = '%palette.green'

22
core/src/main/resources/com/github/weisj/darklaf/properties/icons/frame.properties

@ -24,19 +24,19 @@
#
# suppress inspection "UnusedProperty" for whole file
#
Icons.windowClose.color = %windowButton
Icons.windowCloseHover.color = %windowCloseHovered
Icons.windowCloseInactive.color = %windowButtonDisabled
Icons.windowClose.color = '%windowButton'
Icons.windowCloseHover.color = '%windowCloseHovered'
Icons.windowCloseInactive.color = '%windowButtonDisabled'
Icons.windowHelp.color = %windowButton
Icons.windowHelpInactive.color = %windowButtonDisabled
Icons.windowHelp.color = '%windowButton'
Icons.windowHelpInactive.color = '%windowButtonDisabled'
Icons.windowMaximize.color = %windowButton
Icons.windowMaximizeInactive.color = %windowButtonDisabled
Icons.windowMaximize.color = '%windowButton'
Icons.windowMaximizeInactive.color = '%windowButtonDisabled'
Icons.windowMinimize.color = %windowButton
Icons.windowMinimizeInactive.color = %windowButtonDisabled
Icons.windowMinimize.color = '%windowButton'
Icons.windowMinimizeInactive.color = '%windowButtonDisabled'
Icons.windowRestore.color = %windowButton
Icons.windowRestoreInactive.color = %windowButtonDisabled
Icons.windowRestore.color = '%windowButton'
Icons.windowRestoreInactive.color = '%windowButtonDisabled'

10
property-loader/src/main/java/com/github/weisj/darklaf/parser/ParserUtil.java

@ -53,6 +53,14 @@ final class ParserUtil implements Delimiters {
return parser != null ? parser.parse(p, c) : p;
}
static boolean startsWith(final ParseResult parseResult, final String prefix) {
return parseResult.value.startsWith(prefix);
}
static boolean startsWith(final ParseResult parseResult, final char prefix) {
return parseResult.value.length() > 0 && parseResult.value.charAt(0) == prefix;
}
static boolean stripPrefixFromKey(final ParseResult parseResult, final String prefix) {
if (parseResult.key.startsWith(prefix)) {
parseResult.key = parseResult.key.substring(prefix.length());
@ -62,7 +70,7 @@ final class ParserUtil implements Delimiters {
}
static boolean stripPrefixFromValue(final ParseResult parseResult, final String prefix) {
if (parseResult.value.startsWith(prefix)) {
if (startsWith(parseResult, prefix)) {
parseResult.value = parseResult.value.substring(prefix.length());
return true;
}

8
property-loader/src/main/java/com/github/weisj/darklaf/parser/PrimitiveParser.java

@ -30,6 +30,7 @@ import com.github.weisj.darklaf.util.PropertyValue;
public class PrimitiveParser implements PropertyParser {
public static final String COLOR_PREFIX = "#";
public static final char STRING_DELIMITER = '\'';
@Override
public ParseResult doParse(final ParseResult parseResult, final ParserContext context) {
@ -45,6 +46,13 @@ public class PrimitiveParser implements PropertyParser {
}
}
if (parseResult.finished) return parseResult;
if (ParserUtil.startsWith(parseResult, STRING_DELIMITER)) {
ParserUtil.setNonNull(parseResult,
ParserUtil.parseBetween(STRING_DELIMITER, STRING_DELIMITER,
PropertyParser.of(String::valueOf), String.class,
parseResult, context).orElse(null));
}
if (parseResult.finished) return parseResult;
ParserUtil.setNonNull(parseResult, getInteger(parseResult.value));
if (parseResult.finished) return parseResult;
ParserUtil.setNonNull(parseResult, getBoolean(parseResult.value));

Loading…
Cancel
Save