v1.4.02026-07-30
The killer feature in this release is that Kotter sections are now dynamically aware of their parent window size.
``kotlin
section {
text("$width x $height")
}.runUntilKeyPressed(Keys.Q)
`
Code sample in action
But 1.4.0 also brings big performance improvements on top of 1.3.0, thanks to FFM support and a reworking of core concurrency algorithms.
Changes
* Support for responsive terminals (that is, rendering which responds to window size changing)
- sections that reference either width or height will be repainted automatically as the size changes
- Added a new onTerminalSizeChanged event that you can listen to in run blocks.
- The grid example has been updated to showcase an example of responsive design.
* Expected performance improvements for system terminals in JVM projects
- Previous versions of Kotter already used a JNI solution before, but now FFM, a newer standard, will be chosen if possible (requires JDK22+ installed on the user's machine). If you're not familiar, these technologies are approaches to making native OS calls from the JVM (pretty important for the CLI!)
Support for italics_
- We introduce the new italic font decoration method (alongside bold, underline, etc.)
- May not work on every terminal but it is a fairly widespread feature.
* Sections now strip their final newline while actively rendering
- For example, if the last line in your section is something like textLine("Hello World"), Kotter now won't shove an extra blank line between you and the bottom of the screen -- that is probably never the user's intention. However, once the section is finished rendering for the final time, that newline will be added (to ensure that any followup section will always start on a new line).
Fixed LiveList mutable_ iterators not working
- Before, we lazily sidestepped a thread-safety issue with iterating live lists by returning an iterator on top of a copy our underlying live list. However, iterators are mutable, so anyone who tried to update state would find that the original list would not update as expected. Worse, the Kotlin stdlib provides extension methods which do this under the hood (e.g. removeIf), so the experience was those methods just silently failed. At this point, we did a full reimplementation of live list mutable iterators, so this is no longer an issue.
* The virtual terminal's internals were overhauled
- This was done to better support the new responsive experience.
- The virtual terminal should also look better and, hopefully, feel a bit snappier.
- Added an option where you could set showExitPrompt to false, so that the terminal simply exits when done, instead of showing a Press any key to continue prompt.
- Occasionally, the virtual terminal can reach out to external fonts as a fallback if certain glyphs weren't found in the system monospace font. The problem was, those could subtly break the clean, monospace alignment users expect with a terminal. These non-monospace fonts are now handled better and, if necessary, shrunk to fit into the expected cell size.
* Core internal concurrency algorithms reworked, which as a side effect improved performance significantly
- Especially if you are using LiveList or other reactive collection classes.
- We also increased test coverage as part of the refactoring.
* Added an awaitActiveRender method which you can call in the run` block which can be particularly useful for tests.
Thanks!
* As with v1.3.0, @239 provided a ton of feedback, support, and validation, which made this release so much better than it would have been without their help.
---
Full Changelog: https://github.com/varabyte/kotter/compare/v1.3.0...v1.4.0
v1.3.02026-05-07
This major release brings robust Unicode support to Kotter, plus a slew improvements to the input and grid features. We also spent a lot of time enhancing the Virtual Terminal experience.
``
/\ \/\ \ /\ \/\ \
\ \ \/'/' \ \ ,\ \ ,\
\ \ , < / \ \ \/\ \ \/ /'\/\'__\
\ \ \\\ /\ \L\ \ \ \\ \ \/\ __/\ \ \/
\ \\ \\ \_/\ \\\ \\ \\\ \\
\//\//\// \// \//\// \//
/' \ /'__\
/\, \ /\\L\ \
\//\ \ \//\<_
\ \ \ __/\ \L\ \
\ \\/\\ \____/
\//\//\/___/
``
Changes
Unicode
Unicode support has been improved across the board.
* You can now put emojis and other wide characters (e.g. CJK) inside bordered areas and grids, and the widths will be calculated correctly. No more broken borders!
* We now expose a TextMetrics instance in the session scope which provides useful Unicode utility methods.
* For example: textMetrics.renderWidthOf("日本語") // returns 6, not 3
* Please see its README section for more information.
* The text metrics class additionally provides a very useful truncateToWidth method which can help you fit long strings into areas of limited width.
* You can pass in an optional ellipsis value for a softer truncate, e.g. "Hello Wor" vs. "Hello Wo…"
* ... and you can specify if that truncate happens at the end, start, or middle of the string, e.g. "Hel…", "…llo", "He…o"
Input improvements
* Added a new onInputCursorChanged callback which lets you intercept the cursor position navigating around text inputs.
* onInputChanged now includes an edit parameter which contains detailed information about the exact edit that caused it
* This tells you if the text was added, removed by backspace, or removed by delete.
* You can now control the cursor width, allowing you to highlight chunks of text as the user navigates around the input string.
* Please see the added hiragana example to see these new features in action.
Virtual Terminal
* We now support a new twemoji dependency, which, if added to your project, allows the virtual terminal to access a huge collection of "twemoji" SVG emojis, providing a richer, more consistent cross-platform experience for people intentionally using the virtual terminal.
* Please see the relevant README section for more information.
* Fixed a ton of emoji / unicode issues (for example, emojis now line up with regular text)
* The terminal repainting logic was updated and should feel more performant.
* The scrollbar designs have been updated to something that feels more modern and elegant.
* You can now also optionally pass in a boolean to disable the vscroll bar from ever showing up, which can be useful if you know you won't ever need it and want to remove the tiny amount of space reserved for it.
* We revisited the color values and tweaked them to significantly improve readability.
Grid improvements
* You can now prevent some / all of your grid's horizontal separator lines from rendering.
* This can help you make dense grids that fit into very limited vertical space.
* Common configurations are: All, None, TopAndBottom, and HeaderAndBottom
* We updated the grid example to demonstrate this new feature.
* You can optionally reference a CellMetrics object passed into the cell callback, which for now lets you know the cell's width (potentially useful for "fit" and "star" columns)
`kotlin
grid(...) {
cell { cellMetrics ->
text(textMetrics.truncateToWidth(longString, metrics.width))
}
}
`
* Grids now default to GridCharacters.BoxThin (used to be Ascii) for a nicer out-of-the-box look.
Misc
Updated some value names from SCREAMINGSNAKE_CASE to PascalCase, in line with the Kotlin style guide for singleton objects.
* For example, Keys.SPACE is now Keys.Space
* The old names have been deprecated and will be removed in a future release.
* ⚠️ Key matching is now case-insensitive
* So for example: when(key) { Keys.Q -> ... } will match both lower and upper-case Q keypresses.
Values like UPPERQ are now deprecated.
* If you really need to distinguish case , use isUpper:
`
when(key) {
Keys.Q -> if (key.isUpper() quit() else checkForQuitConfirmation())
}
`
* Fixed a gnarly timing issue where escape-sequence keys (arrows, function keys, etc.) could occasionally fire a spurious bare ESC keypress.
* Delay auto-appending a newline to a section until it is finished running.
* Kotter always finishes a section with a newline before starting the next, but now we at least wait until the section is finished first. This allows information-dense TUI applications to avoid wasting valuable space on a blank line at the bottom of the window.
Test utils
* You can now set the width of the in-memory test terminal, which will result in wrapped text, similar to a real terminal.
Thanks!
* @239 offered a ton of feedback, support, and validation, raising a lot of excellent issues and making a huge impact on this release. Specifically, he worked on the grid feature and helped drive a lot of the unicode and Virtual Terminal improvements.
* loke who connected with me and described the problem that led to the input` fixes in this release.
---
Full Changelog: https://github.com/varabyte/kotter/compare/v1.2.1...v1.3.0
v1.2.12024-12-14
This release is functionally identical to 1.2.0 but has some tweaks that makes the internals of the input system much more robust.
In other words, there's no urgency to update, but there should be no harm, either.
Background
For users, Kotter 1.2.0 works just fine. But there are a handful of milliseconds where the input system takes some time to hook itself up - some tricky coroutine / flow setup. Again, humans using your kotter application would never notice this!
But if you're trying to write tests that send keypresses at tremendously fast rates, then they might sneak a few keypresses in that were getting dropped very occasionally.
After spending a week investigating this, we now have an implementation system under the hood that is much more robust, so even blazingly fast tests shouldn't be able to sneak keypresses past it. Despite this benefit, the code is actually slightly more straightforward than it was before.
At the same time, there is an additional benefit where Kotter sections will now only pay for the cost of handling input if that section is using input APIs (such as input, onKeyPressed, etc.).
Before, the first section you ran that used an input API would spin up some state that would remain alive for the remainder of your application. This is nothing significant that any application should ever worry about, but still, from a technical perspective, the lifecycle of input state is now a lot more sensible (and the code easier to reason about).
Thanks
Huge thanks to users @nereboss and @phanlezz. After reporting #114, which raised an issue about occasional flakes they were seeing in tests (side note: awesome effort by these developers to write such comprehensive tests!), both users showed a ton of patience and understanding as it took me a long time to both figure the issue out and even get time to look into it deeply in the first place.
They provided excellent repro examples and were very active in coordinating on the issue thread.
Check out their GitHub project, Codecharta! It's extremely well tested!
Thanks to these two developers, I feel so much better about Kotter's input system now.
---
Full Changelog: https://github.com/varabyte/kotter/compare/v1.2.0...v1.2.1
v1.2.02024-11-19
Technically, this release does not add any major features on top of 1.1.2, but due to issues with the CI failing to work with really old versions of the JDK, we bumped up the Kotlin / JDK versions a bit.
https://github.com/user-attachments/assets/eeb8009b-9069-4bd3-9d3c-61e9d6e7e56e
Changes
* Made a handful of improvements to the testing library, including adding its own README
* Introduced InMemoryTerminal, which collects all ANSI output into a queryable memory buffer instead of rendering it directly into the terminal.
* Also exposed a convenient buildAnsiLines utility method which works by creating an InMemoryTerminal behind the scenes.
* Updated Kotlin to 1.9.10 / JDK to 11
---
Full Changelog: https://github.com/varabyte/kotter/compare/v1.1.2...v1.2.0
v1.1.22024-02-19
This release introduces the very powerful grid widget into Kotter.
In other words, you can create tables in Kotter now. :tada:
``kotlin
section {
// A grid with two columns, each with space for 6 characters
grid(Cols(6, 6), characters = GridCharacters.CURVED) {
cell { textLine("Cell1") }
cell { textLine("Cell2") }
cell { textLine("Cell3") }
cell { textLine("Cell4") }
// Jump over cell row=2,col=0
cell(row = 2, col = 1) { textLine("Cell6") }
}
}.run()
`
image
Be sure to review the Grid section in the README as there are a bunch of other features discussed in there, such as fit- and star-sized columns, row and column spanning cells, and more.
---
Release notes
* New grid widget(!!!)
* Fixed a bug where a session wouldn't correctly shut down its key input processing when finished.
* This would result in a first session unexpectedly interfering with a second session if one was started later before exiting the application.
If you check the width value when using the virtual terminal, it now returns the width that the terminal was constructed with, not Int.MAXVALUE`.
Full Changelog: https://github.com/varabyte/kotter/compare/v1.1.1...v1.1.2
---
Thanks!
HUGE thanks to @grnt426 for their support around grids. They initiated progress on the feature and provided a ton of real-world testing using an impressive project they are working on. I mean, just look at this:
image
v1.1.12023-07-28
The biggest change of this release is the new multilineInput method, which lets a user type in input with newlines.
``kotlin
section {
black(isBright = true) { text("Send a text message (press CTRL-D when finished)") }
multilineInput()
}.runUntilInputEntered {
onInputEntered { sendMessage(input.trim()) }
}
`
Code sample in action
You can press arrow keys / home+end / page up+down to navigate around the answer. In order to allow this, the multiline input area always begins on a newline and ends with a newline.
---
* Add the new multilineInput, which is better described above.
* Tweaked repaint logic. Hopefully this means no more flickering on Windows if the amount of text being rendered doesn't fit on the screen.
* Now using the current terminal's height to only erase lines that are visible on screen.
* Improve logic around auto-wrap handling, especially with non-ASCII (e.g. Chinese character) text
* Add a new customFormat parameter (to input and mutlilineInput`) which can be used to change text color / add text effects to user input as they type it.
* This could be useful, for example, to highlight invalid characters that the user typed in, coloring them red.
* Misc. improvements to the test library for writing readable tests
---
Full Changelog: https://github.com/varabyte/kotter/compare/v1.1.0...v1.1.1
v1.1.02023-03-29
:tada: :tada: :tada: Kotter 1.1.0 introduces Kotlin/Native support. :tada: :tada: :tada:
In other words, you can now target the JVM or you can compile against 64-bit Linux, Mac, or Windows hosts directly via the Kotlin multiplatform plugin. Review the README on how to set this up.
If you have an application that is using v1.0.x, be sure to follow all steps in the migration doc. It should be relatively straightforward.
v1.1.0-rc4预发布2023-03-24
Hopefully getting close to a v1.1.0 release. Maybe this is the one! :crossed_fingers:
This release adds the following changes:
Kotlin/Native
* Native terminals will now throw an exception if they aren't run in an interactive environment
* Such as a legacy terminal (like win7 cmd), or if the program is run indirectly by another (like Gradle), or if the program's stdin/stdout sources are not TTYs (e.g. kotter-app < input.txt is not allowed)
* This behavior is now identical to the JVM system terminal
* Fixed a case in Linux/Mac where the "hide cursor" command wasn't getting picked up
All targets
* Added new runFor(duration) extension methods, so you can now write:
* section { ... }.runFor(5.seconds)
* Convenient if you just want to render an animation for a little while.
* section { ... }.runForAtLeast(5.seconds) { ... }
* Like runFor but doesn't aggressively abort in case you're still doing more work after the time runs out.
* section { ... }.runForAtMost(5.seconds) { ... }
* Convenient if you want to cap some long running operation, such as a download for example.
Test
* Added new assertMatches test method, which prints a clear error message if your Kotter output doesn't match what's expected.
v1.1.0-rc3预发布2023-03-20
Two additional fixes in this release:
* Avoid appending some extra newlines when the program is shutting down.
[Windows]* Fix an issue where Kotter wouldn't process ANSI commands if you ran it in a legacy Windows console host (due to incorrect setup values).
* In other words, instead of clean Kotter behavior, you got text interlaced with bizarre commands like [OK and [1F
Note that this release changes K/N targets only. If you are using v1.1.0-rc1 (or rc2) to target the JVM, then this release will be identical.
v1.1.0-rc2预发布2023-03-18
This release is the same as v1.1.0-rc1 except with one bug fixed: repainting was broken whenever any line ended up being longer than the width of your terminal, leaving old text around. (There was an issue calculating how many lines needed to be erased caused by the fact that one line got broken up into two)
Note that this bug affected K/N targets only. If you are using v1.1.0-rc1 to target the JVM, then this release will be identical.