varabyte / kotter

A declarative, Kotlin-idiomatic API for writing dynamic console applications.
Apache License 2.0
546 stars 16 forks source link

Windows Virtual Terminal Incorrectly Sizes Border #105

Open grnt426 opened 6 months ago

grnt426 commented 6 months ago

Describe the bug Virtual terminals on Windows 10 incorrectly calculate the length of bordered text, causing the header and footer to be shorter than expected.

To Reproduce

build.gradle.kts

plugins {
    kotlin("jvm") version "1.9.0"
    application
}

dependencies {
    implementation("com.varabyte.kotter:kotter-jvm:1.1.1")
}

kotlin {
    jvmToolchain(17)
}

application {
    mainClass.set("MainKt")
}

Main.KT

session{
    section {
        bordered {
            textLine("Hello World!")
            textLine("Row 2!")
        }
    }.run()
}

Expected behavior After bundling the above application into a jar and executing it on Powershell 7.4.1, I see the below

┌────────────┐
│Hello World!│
│Row 2!      │
└────────────┘
┌──┐
│AA│
│b │
└──┘

Screenshots When running inside a virtual terminal launched from IntelliJ, or forcibly launched from the Jar with the session(terminal = VirtualTerminal.create()) option, it renders with incorrect length calculated for the header and footer.

base example

very long border

AAb

Desktop (please complete the following information):

Additional Notes: I included the text from Powershell as it formatted and displayed correctly, however I couldn't get the text copied out of the virtual terminal (is that possible?), so included only screenshots. I can include screenshots of the correct Powershell 7 behavior if requested.

bitspittle commented 5 months ago

I'm not sure I can do anything about that, unfortunately. I recommend the ASCII border set in that case, or changing the font?

grnt426 commented 5 months ago

How can the font of a VirtualTerminal be selected? I don't see the option inside VirtualTerminal, Session, or Section.

bitspittle commented 5 months ago

@grnt426 https://github.com/varabyte/kotter/blob/62173802985117c8e6e53dc2b7b533cbdcf7daf2/kotter/src/jvmMain/kotlin/com/varabyte/kotter/terminal/virtual/VirtualTerminal.kt#L92

bitspittle commented 4 months ago

@grnt426 did you ever resolve this issue on your end, with the recommendation for changing the font?

ShawSumma commented 1 week ago

I too have this issue. I don't know what to set the font to. It wants a path.

bitspittle commented 1 week ago

@ShawSumma it's been a while. I believe you put a ttf inside your resources for and the path is to that file, relative to the resource root. So probably something like "fonts/ex.ttf"

ShawSumma commented 1 week ago

Thanks for the suggestion. That sounds right.