Skip to content

Commit 3f41c95

Browse files
committed
RichText was improved
1 parent 9a43ef6 commit 3f41c95

File tree

1 file changed

+6
-1
lines changed
  • app/src/main/java/com/avocat/http_wizard/ui/component

1 file changed

+6
-1
lines changed

app/src/main/java/com/avocat/http_wizard/ui/component/RichText.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ fun RichText(
2323
src: String,
2424
type: RichTextType = RichTextType.JSON
2525
) {
26+
val tokens =
27+
when (type) {
28+
RichTextType.JSON -> JSONTokens
29+
}
30+
2631
Text(buildAnnotatedString {
2732
var i = 0
2833
var result: MatchResult?
2934

3035
while (i < src.length) {
3136
var isMatched = false
32-
for (token in JSONTokens) {
37+
for (token in tokens) {
3338
result = token.first.matchAt(src, i)
3439
if (result != null) {
3540
append(AnnotatedString(src.substring(result.range), SpanStyle(token.second)))

0 commit comments

Comments
 (0)