Path: csiph.com!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Parsing multi-byte keystrokes Date: Sun, 25 Jun 2023 15:06:29 -0700 Organization: None to speak of Lines: 39 Message-ID: <87mt0n19ju.fsf@nosuchdomain.example.com> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="a44f767d52f7a9230c899799d3560062"; logging-data="650754"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+p3AJJsgTNP6f6AOVrNHCV" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:9R81w29TbqW/PDICpvG4jgsHtHY= sha1:P299eJN2jNQMfSNlEpvFg4fNEF0= Xref: csiph.com comp.lang.c++:90716 "Alf P. Steinbach" writes: > On 2023-06-25 7:45 PM, R.Wieser wrote: >> Hello all, >> >> I've set the console input to raw so I can see keys coming in when >> they are pressed. >> >> For that I've been writing a big "switch ... case" to parse the >> multi-byte keystrokes into "records" that than can be easily worked >> with or discarded. >> >> As this parsing needs to be done by pretty-much every console-based >> program which wants to do any kind of interactive stuff I was >> wondering if this perhaps is already part of Linux ... >> >> If it is (and thats still a big "if"), where can I find it ? > > curses library curses takes over the entire (text / terminal) screen, keeping track of what character is shown at each location and using minimal output to update it as needed. If that's what you want, that's great, but as far as I can tell curses is not suitable for, for example, detecting the user pressing an arrow key *without* controlling the whole screen. The GNU readline library may be closer, but it's at a higher level; it handles things like arrow key input, but it doesn't give you information like "the user just pressed up-arrow". In the past, I've tried and failed to find a library that gives access to that kind of information. (The terminfo database gives you the character sequences corresponding to the various keys, but I don't think it provides code to detect them on input.) -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */