Skip to content

Commit

Permalink
allow commenting lines in json layouts by starting the line with //
Browse files Browse the repository at this point in the history
  • Loading branch information
Helium314 committed May 17, 2024
1 parent 82705e5 commit 1a91ce5
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object RawKeyboardParser {
* codes of multi_text_key not used, only the label
* (currently) popups is always read to [number, main, relevant] layoutPopupKeys, no choice of which to use or which hint is provided
*/
fun parseJsonString(layoutText: String): List<List<AbstractKeyData>> = florisJsonConfig.decodeFromString(layoutText)
fun parseJsonString(layoutText: String): List<List<AbstractKeyData>> = florisJsonConfig.decodeFromString(layoutText.stripCommentLines())

/** Parse simple layouts, defined only as rows of (normal) keys with popup keys. */
fun parseSimpleString(layoutText: String): List<List<KeyData>> {
Expand Down Expand Up @@ -166,6 +166,10 @@ object RawKeyboardParser {
}
}

// allow commenting lines by starting them with "//"
private fun String.stripCommentLines(): String =
split("\n").filterNot { it.startsWith("//") }.joinToString("\n")

/*
* Copyright (C) 2021 Patrick Goldinger
* modified
Expand Down

0 comments on commit 1a91ce5

Please sign in to comment.