Skip to content

Commit

Permalink
Render lists with square brackets in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
0xaa4eb committed Nov 9, 2024
1 parent 69eda91 commit b6fe7e5
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -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) {

Expand All @@ -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)
}
}

0 comments on commit b6fe7e5

Please # to comment.