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 19:10:44 -0700 Organization: None to speak of Lines: 46 Message-ID: <87bkh30y8r.fsf@nosuchdomain.example.com> References: <87mt0n19ju.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="a44f767d52f7a9230c899799d3560062"; logging-data="829018"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Kg6m967LZ3VBUMhVwdA84" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:yO7U1RtkffaGrQCkGHVBikiNN9w= sha1:GrGrWzw2xUodWVlmlZMdOLlCWxU= Xref: csiph.com comp.lang.c++:90722 Pavel writes: > Keith Thompson wrote: >> "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. > > These codes are terminal-specific but basic things like up-arrww are > more or less standardized in ANSI terminal. These days, yes, mostly. Termcap, terminfo, and [n]curses were developed when there were a wide variety of terminals (not just emulators) with incompatible control sequences. Today if you assume VT100-compatible codes, you can probably get away with it. But there are still a lot of libraries that support other terminal types. -- 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 */