Why is my fucking code waiting to a EOL to get stuff if I'm calling a read which is supposed to get just one char?

WHAT THE FUCK?

Should I flush anything?

What's going on here?

Follow

I need to put my terminal in character mode and what the fuck.

How is it this difficult in Java/Clojure.

I think in C it comes by default...?

@ekaitz_zarraga I don't think so? In C and C++ when I read from the terminal it's always line buffered. You have to do some hoop jumping to make it unbuffered.

@CharredStencil
This is a feature of the Unix terminal interface and has nothing to with the language used. Even when you call the read() system call directly you have the same behaviour.

You need to set the terminal to raw mode in order to be able to read character by character.
@ekaitz_zarraga

@loke @CharredStencil Exactly. My research took me there.
There's a POSIX interface for this. You have to choose the non-canonical mode.

I thought C was like that but nope. I'm getting old very fast.

Sign in to participate in the conversation
Mastodon

Invite-only Mastodon server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!