beryx / text-io

A library for creating interactive console applications in Java
http://text-io.beryx.org/
Apache License 2.0
342 stars 45 forks source link

Add ability to print from another thread #4

Open asm0dey opened 7 years ago

asm0dey commented 7 years ago

My usecase: By default I'm waiting for some input from user. But sometimes my program's background thread needs to print some output. If I do this — this outputs is being inserted as answer into console and, of course, it's not correct behaviour. Minimalistic example:

        fun main(args: Array<String>) {
            thread {
                Thread.sleep(3000)
                textio.textTerminal.println("Some text here")
                Thread.sleep(1000)
                textio.textTerminal.println("Some text here")
            }
            textio
                    .newStringInputReader()
                    .withMaxLength(2)
                    .read("some input")
        }

Is it possible to make terminal redraw question if another thread is trying to print something?

siordache commented 7 years ago

I think this would be a nice feature. I'm currently working on another project, which will keep me busy for several months. Therefore, I put the label "up-for-grabs" on this issue, to indicate that this feature has been specifically chosen to be implemented by contributors.

Some guidelines for contributors:

In order to prevent that two people work on the same thing, leave a comment here to claim this issue before starting to work on it.

ghandhikus commented 4 years ago

Any plans on introducing it? This library is pretty useless without this feature.

siordache commented 4 years ago

Sorry, currently I have no time to implement this feature and no one stepped in to do this. Would you be interested perhaps in sending a pull request for implementing this feature?