ajalt / mordant

Multiplatform text styling for Kotlin command-line applications
https://ajalt.github.io/mordant/
Apache License 2.0
982 stars 34 forks source link

Redundant vertical space between table caption and table body if table is too wide #216

Closed mikaelstaldal closed 1 month ago

mikaelstaldal commented 1 month ago

If you have a table with captionTop, and the table is too wide for the terminal (truncation of content occurs), extra blank lines are inserted between the caption and the table body.

ajalt commented 1 month ago

Can you provide a minimal example of a table that exhibits the issue? I can't reproduce this.

mikaelstaldal commented 1 month ago
import com.github.ajalt.mordant.rendering.TextAlign
import com.github.ajalt.mordant.table.table
import com.github.ajalt.mordant.terminal.Terminal

fun main(args: Array<String>) {
    Terminal().println(table {
        captionTop("TopCaption", TextAlign.LEFT)
        header { row("Column 1", "Column 2", "Column 3", "Column 4", "Column 5", "Column 6", "Column 7", "Column 8", "Column 9") }
        body {
            row("Long important content in here", "Content 2", "Content 3", "Content 4", "Content 5", "Content 6", "Content 7", "Content 8", "Content 9")
        }
    })
}
mikaelstaldal commented 1 month ago

But it seems like the problem only occurs in certain situations, such as when running within a Docker container.

Build a Docker image with the above program with Gradle:

plugins {
    kotlin("jvm") version "2.0.10"
    id("com.bmuschko.docker-java-application") version "9.4.0"
}

group = "com.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    implementation("com.github.ajalt.mordant:mordant:2.7.2")
}

kotlin {
    jvmToolchain(21)
}

docker {
    javaApplication {
        baseImage.set("eclipse-temurin:21")
    }
}

And run it with docker run -it com.example/mordant-test:1.0-snapshot

If the terminal is less than 130 chars wide, than you see the problem. Try resize the terminal window after running it to see the problem come and go in real time.

I am using Ubuntu desktop Linux 24.04

ajalt commented 1 month ago

Thanks for the repro!

mikaelstaldal commented 1 month ago

I see that this fix has been released in 3.0.0. I am using both Clikt and Mordant, is the latest Clikt (4.4.0) compatible with Mordant 3.0.0?

ajalt commented 1 month ago

No, but I'll release a new version of Clikt soon.