kotter icon indicating copy to clipboard operation
kotter copied to clipboard

Windows Virtual Terminal Incorrectly Sizes Border

Open grnt426 opened this issue 1 year ago • 7 comments

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):

  • OS: Windows 10 64bit
  • Java 17
  • Kotlin 1.9.0
  • Kotter 1.1.1
  • IntelliJ
  • Gradle 8.2

** 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.

grnt426 avatar Jan 13 '24 16:01 grnt426

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

bitspittle avatar Jan 22 '24 20:01 bitspittle

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

grnt426 avatar Jan 31 '24 21:01 grnt426

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

bitspittle avatar Feb 03 '24 07:02 bitspittle

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

bitspittle avatar Mar 14 '24 20:03 bitspittle

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

ShawSumma avatar Jul 06 '24 13:07 ShawSumma

@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"

bitspittle avatar Jul 09 '24 15:07 bitspittle

Thanks for the suggestion. That sounds right.

ShawSumma avatar Jul 09 '24 15:07 ShawSumma