StevieD
StevieD

Reputation: 7443

How can I get unbuffered input to a program?

I can't figure out how to get unbuffered input.

I tried:

    method get-selection() {
        getc();
    }

Also tried Term::ReadKey module:

use Term::ReadKey;
    method get-selection() {
        read-key();
    }

But I still have to hit enter before I can capture the input. Couldn't find anything in the docs that might help.

I'm on macOS.

Upvotes: 6

Views: 368

Answers (1)

Elizabeth Mattijsen
Elizabeth Mattijsen

Reputation: 26969

https://docs.raku.org/type/IO::Handle#routine_getc states:

Using getc to get a single keypress from a terminal will only work properly if you've set the terminal to "unbuffered".

For MacOS, a Google search gets me to:

https://apple.stackexchange.com/questions/193138/to-install-unbuffer-in-osx

Upvotes: 3

Related Questions