varabyte / kotter

A declarative, Kotlin-idiomatic API for writing dynamic console applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add "transform" callback to input() method

bitspittle opened this issue · comments

Imagine you're typing a password. It could be nice to do something like this:

input(transform { ch -> '*' })

If you do this, the underlying value is still valid. It's only what's printed to the screen that is changed.

Question: Should the transformation work per character? Or on the whole input?

e.g. password could be this:

input(transform { str -> "*".repeat(str.length) })

The transform method should definitely return a single character. There's a bunch of logic around cursor movement that would be really weird if the transformation was not one to one.