From b6fe7e52fc19b58a1a7f34078409fbc3135aba26 Mon Sep 17 00:00:00 2001 From: Andrei Cheboksarov <37665782+0xaa4eb@users.noreply.github.com> Date: Sat, 9 Nov 2024 12:35:36 +0400 Subject: [PATCH] Render lists with square brackets in UI --- .../recording/objects/RenderedCollection.kt | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ulyp-ui/src/main/kotlin/com/ulyp/ui/elements/recording/objects/RenderedCollection.kt b/ulyp-ui/src/main/kotlin/com/ulyp/ui/elements/recording/objects/RenderedCollection.kt index fe046c65..3e2e264a 100644 --- a/ulyp-ui/src/main/kotlin/com/ulyp/ui/elements/recording/objects/RenderedCollection.kt +++ b/ulyp-ui/src/main/kotlin/com/ulyp/ui/elements/recording/objects/RenderedCollection.kt @@ -2,6 +2,7 @@ package com.ulyp.ui.elements.recording.objects import com.ulyp.core.recorders.collections.CollectionRecord import com.ulyp.core.recorders.ObjectRecord +import com.ulyp.core.recorders.collections.CollectionType import com.ulyp.ui.RenderSettings import com.ulyp.ui.util.Style import com.ulyp.ui.util.StyledText.of @@ -11,7 +12,7 @@ import java.util.stream.Collectors class RenderedCollection(record: CollectionRecord, renderSettings: RenderSettings) : RenderedObject() { init { - val recordedObjects = record.recordedItems + val recordedObjects = record.elements .stream() .map { record: ObjectRecord -> of(record, renderSettings) } .collect(Collectors.toList()) @@ -23,7 +24,13 @@ class RenderedCollection(record: CollectionRecord, renderSettings: RenderSetting nodes.add(of(": ", Style.CALL_TREE_NODE_SEPARATOR)) } - nodes.add(of("{", Style.CALL_TREE_COLLECTION_BRACKET)) + when (record.collectionType) { + CollectionType.LIST -> nodes.add(of("[", Style.CALL_TREE_COLLECTION_BRACKET)) + CollectionType.SET -> nodes.add(of("{", Style.CALL_TREE_COLLECTION_BRACKET)) + CollectionType.QUEUE -> nodes.add(of("<", Style.CALL_TREE_COLLECTION_BRACKET)) + CollectionType.OTHER -> nodes.add(of("{", Style.CALL_TREE_COLLECTION_BRACKET)) + null -> nodes.add(of("{", Style.CALL_TREE_COLLECTION_BRACKET)) + } for (i in recordedObjects.indices) { @@ -41,7 +48,15 @@ class RenderedCollection(record: CollectionRecord, renderSettings: RenderSetting ) ) } - nodes.add(of("}", Style.CALL_TREE_COLLECTION_BRACKET)) + + when (record.collectionType) { + CollectionType.LIST -> nodes.add(of("]", Style.CALL_TREE_COLLECTION_BRACKET)) + CollectionType.SET -> nodes.add(of("}", Style.CALL_TREE_COLLECTION_BRACKET)) + CollectionType.QUEUE -> nodes.add(of(">", Style.CALL_TREE_COLLECTION_BRACKET)) + CollectionType.OTHER -> nodes.add(of("}", Style.CALL_TREE_COLLECTION_BRACKET)) + null -> nodes.add(of("}", Style.CALL_TREE_COLLECTION_BRACKET)) + } + children.addAll(nodes) } } \ No newline at end of file