Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #90713 > unrolled thread
| Started by | "R.Wieser" <address@is.invalid> |
|---|---|
| First post | 2023-06-25 19:45 +0200 |
| Last post | 2023-06-26 19:24 +0200 |
| Articles | 20 on this page of 143 — 19 participants |
Back to article view | Back to comp.lang.c++
Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-25 19:45 +0200
Re: Parsing multi-byte keystrokes "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-06-25 20:34 +0200
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-25 21:39 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-25 15:06 -0700
Re: Parsing multi-byte keystrokes Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-06-25 20:18 -0400
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-25 19:10 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 08:46 +0200
Re: Parsing multi-byte keystrokes Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-06-25 18:39 -0400
Re: Parsing multi-byte keystrokes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-06-26 00:53 +0100
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 09:11 +0200
Re: Parsing multi-byte keystrokes Christian Gollwitzer <auriocus@gmx.de> - 2023-06-26 09:32 +0200
Re: Parsing multi-byte keystrokes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-06-26 13:50 +0100
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 15:03 +0200
Re: Parsing multi-byte keystrokes Christian Gollwitzer <auriocus@gmx.de> - 2023-06-26 22:27 +0200
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 22:48 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 14:35 -0700
Re: Parsing multi-byte keystrokes Christian Gollwitzer <auriocus@gmx.de> - 2023-06-26 23:58 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 16:26 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 08:50 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 01:39 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 13:43 +0200
Re: Parsing multi-byte keystrokes Muttley@dastardlyhq.com - 2023-06-26 15:26 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 18:04 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 12:01 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 21:59 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 14:15 -0700
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-26 22:35 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-29 13:15 +0200
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-26 14:03 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 17:49 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 12:23 -0700
Re: Parsing multi-byte keystrokes red floyd <no.spam.here@its.invalid> - 2023-06-28 14:35 -0700
Re: Parsing multi-byte keystrokes gazelle@shell.xmission.com (Kenny McCormack) - 2023-06-29 00:17 +0000
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-29 00:43 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-29 14:04 +0200
Re: Parsing multi-byte keystrokes gazelle@shell.xmission.com (Kenny McCormack) - 2023-06-29 15:44 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-29 18:37 +0200
Re: Parsing multi-byte keystrokes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-06-30 14:14 +0100
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-30 18:12 +0200
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-30 20:32 +0200
Re: Parsing multi-byte keystrokes Paavo Helde <eesnimi@osa.pri.ee> - 2023-06-30 22:57 +0300
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-01 09:49 +0200
Re: Parsing multi-byte keystrokes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-06-30 21:36 +0100
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-30 13:45 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-01 10:33 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-07-01 11:58 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-02 11:03 +0200
Re: Parsing multi-byte keystrokes Christian Gollwitzer <auriocus@gmx.de> - 2023-07-02 23:15 +0200
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-03 09:12 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-07-02 15:39 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-03 10:12 +0200
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-07-03 13:28 +0000
Re: Parsing multi-byte keystrokes James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-07-03 12:43 -0400
Re: Parsing multi-byte keystrokes Muttley@dastardlyhq.com - 2023-07-03 15:41 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-03 21:32 +0200
Re: Parsing multi-byte keystrokes gazelle@shell.xmission.com (Kenny McCormack) - 2023-07-03 21:06 +0000
Re: Parsing multi-byte keystrokes James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-07-04 05:20 -0400
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-07-04 13:56 +0000
Re: Parsing multi-byte keystrokes James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-07-04 16:03 -0400
Re: Parsing multi-byte keystrokes kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-07-04 21:03 +0000
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-07-04 14:33 -0700
Re: Parsing multi-byte keystrokes kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-07-04 21:55 +0000
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-07-05 13:58 +0000
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-07-05 13:56 +0000
Re: Parsing multi-byte keystrokes Muttley@dastardlyhq.com - 2023-07-04 15:54 +0000
Re: Parsing multi-byte keystrokes David Brown <david.brown@hesbynett.no> - 2023-07-04 18:03 +0200
Re: Parsing multi-byte keystrokes kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-07-04 16:33 +0000
Re: Parsing multi-byte keystrokes gazelle@shell.xmission.com (Kenny McCormack) - 2023-07-04 16:41 +0000
Re: Parsing multi-byte keystrokes kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-07-04 16:52 +0000
Re: Parsing multi-byte keystrokes David Brown <david.brown@hesbynett.no> - 2023-07-05 09:50 +0200
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-07-05 14:00 +0000
Re: Parsing multi-byte keystrokes "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-07-05 11:21 -0700
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-07-05 20:24 +0000
Re: Parsing multi-byte keystrokes kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-07-05 19:31 +0000
Re: Parsing multi-byte keystrokes Muttley@dastardlyhq.com - 2023-07-04 19:05 +0000
Re: Parsing multi-byte keystrokes red floyd <no.spam.here@its.invalid> - 2023-07-05 18:31 -0700
Cars (Was: Parsing what is Linux?) gazelle@shell.xmission.com (Kenny McCormack) - 2023-07-06 08:40 +0000
Re: Parsing multi-byte keystrokes Muttley@dastardlyhq.com - 2023-07-06 08:55 +0000
Cars (Was: Parsing multi-byte keystrokes) gazelle@shell.xmission.com (Kenny McCormack) - 2023-07-06 09:27 +0000
Re: Cars (Was: Parsing multi-byte keystrokes) Muttley@dastardlyhq.com - 2023-07-06 15:43 +0000
Totally insane (Was: Cars (Was: Parsing multi-byte keystrokes)) gazelle@shell.xmission.com (Kenny McCormack) - 2023-07-06 16:53 +0000
Re: Totally insane (Was: Cars (Was: Parsing multi-byte keystrokes)) Muttley@dastardlyhq.com - 2023-07-07 07:15 +0000
Re: Parsing multi-byte keystrokes James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-06-30 17:00 -0400
Re: Parsing multi-byte keystrokes gazelle@shell.xmission.com (Kenny McCormack) - 2023-07-01 07:53 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-01 10:30 +0200
Re: Parsing multi-byte keystrokes James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-07-02 04:04 -0400
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-02 11:27 +0200
Re: Parsing multi-byte keystrokes James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-07-02 14:51 -0400
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-02 22:49 +0200
Re: Parsing multi-byte keystrokes James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-07-02 18:56 -0400
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-03 10:59 +0200
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-07-03 13:34 +0000
Re: Parsing multi-byte keystrokes James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-07-03 12:20 -0400
Re: Parsing multi-byte keystrokes Richard Harnden <richard.nospam@gmail.com> - 2023-07-03 18:02 +0100
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-07-03 14:40 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-03 22:50 +0200
Re: Parsing multi-byte keystrokes James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-07-04 05:47 -0400
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-07-03 14:36 -0700
Re: Parsing multi-byte keystrokes David Brown <david.brown@hesbynett.no> - 2023-07-03 11:38 +0200
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-03 13:04 +0200
Re: Parsing multi-byte keystrokes David Brown <david.brown@hesbynett.no> - 2023-07-03 15:11 +0200
Re: Parsing multi-byte keystrokes Christian Gollwitzer <auriocus@gmx.de> - 2023-07-03 20:35 +0200
Re: Parsing multi-byte keystrokes gazelle@shell.xmission.com (Kenny McCormack) - 2023-07-03 19:16 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-03 22:55 +0200
Re: Parsing multi-byte keystrokes Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-07-01 03:03 -0700
Re: Parsing multi-byte keystrokes Muttley@dastardlyhq.com - 2023-07-01 10:30 +0000
Re: Parsing multi-byte keystrokes "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-07-01 22:37 +0200
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-07-02 09:42 +0200
Re: Parsing multi-byte keystrokes Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-06-29 22:21 -0400
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-30 17:50 +0200
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-25 23:20 +0000
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-25 17:10 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 09:21 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 01:29 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 13:30 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 12:18 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 22:37 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 14:32 -0700
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-26 22:41 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-29 13:58 +0200
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-29 13:59 -0700
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 01:30 -0700
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-26 14:00 +0000
Re: Parsing multi-byte keystrokes "Fred. Zwarts" <F.Zwarts@HetNet.nl> - 2023-06-26 12:31 +0200
Re: Parsing multi-byte keystrokes "Fred. Zwarts" <F.Zwarts@HetNet.nl> - 2023-06-26 12:47 +0200
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 13:56 +0200
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-26 13:58 +0000
Re: Parsing multi-byte keystrokes Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-26 12:08 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 08:56 +0200
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-26 14:02 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 17:46 +0200
Re: Parsing multi-byte keystrokes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-06-26 18:19 +0100
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-26 18:36 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 21:24 +0200
Re: Parsing multi-byte keystrokes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-06-26 22:12 +0100
Re: Parsing multi-byte keystrokes wij <wyniijj5@gmail.com> - 2023-06-26 02:06 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 13:49 +0200
Re: Parsing multi-byte keystrokes scott@slp53.sl.home (Scott Lurndal) - 2023-06-26 14:05 +0000
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 17:58 +0200
Re: Parsing multi-byte keystrokes wij <wyniijj5@gmail.com> - 2023-06-27 13:32 -0700
Re: Parsing multi-byte keystrokes gazelle@shell.xmission.com (Kenny McCormack) - 2023-06-28 02:17 +0000
Re: Parsing multi-byte keystrokes wij <wyniijj5@gmail.com> - 2023-06-27 20:26 -0700
Re: Parsing multi-byte keystrokes "R.Wieser" <address@is.invalid> - 2023-06-26 19:24 +0200
Page 1 of 8 [1] 2 3 4 5 6 7 8 Next page →
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2023-06-25 19:45 +0200 |
| Subject | Parsing multi-byte keystrokes |
| Message-ID | <u79ug0$i1ks$1@dont-email.me> |
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 ? Second question : How do I check for modifier keys (like alt, shift, ctrl) on the pressed keys or seperatily ? I would like to be able to, as an example, catch a ctrl-cursor-left as well as a normal or a shift-curor-left. Regards, Rudy Wieser
[toc] | [next] | [standalone]
| From | "Alf P. Steinbach" <alf.p.steinbach@gmail.com> |
|---|---|
| Date | 2023-06-25 20:34 +0200 |
| Message-ID | <u7a1bg$ids6$1@dont-email.me> |
| In reply to | #90713 |
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 > Second question : How do I check for modifier keys (like alt, shift, ctrl) > on the pressed keys or seperatily ? I would like to be able to, as an > example, catch a ctrl-cursor-left as well as a normal or a shift-curor-left.
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2023-06-25 21:39 +0200 |
| Message-ID | <u7a569$iueq$1@dont-email.me> |
| In reply to | #90714 |
Alf, >> If it is (and thats still a big "if"), where can I find it ? > > curses library Thats was the first thing I checked for, but it does not seem to be part of my "bullseye lite" installation ... But assuming I go and install it, its "man" page shows that it has got quite a number of functions. Any suggestions to where to look how to use it for what I described ? Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2023-06-25 15:06 -0700 |
| Message-ID | <87mt0n19ju.fsf@nosuchdomain.example.com> |
| In reply to | #90714 |
"Alf P. Steinbach" <alf.p.steinbach@gmail.com> 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 */
[toc] | [prev] | [next] | [standalone]
| From | Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> |
|---|---|
| Date | 2023-06-25 20:18 -0400 |
| Message-ID | <kP4mM.83591$8uge.70991@fx14.iad> |
| In reply to | #90716 |
Keith Thompson wrote:
> "Alf P. Steinbach" <alf.p.steinbach@gmail.com> 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.
Unsure if this is what you were looking for, but works for me:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <readline/readline.h>
int
up_callback(int count, int key) {
printf ("the user just pressed up-arrow\n");
return 0;
}
int
main(int argc, char *argv[])
{
rl_bind_keyseq ("\\e[A", up_callback);
free(readline("press a button > "));
printf("\n");
return 0;
}
> (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.)
>
HTH
-Pavel
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2023-06-25 19:10 -0700 |
| Message-ID | <87bkh30y8r.fsf@nosuchdomain.example.com> |
| In reply to | #90721 |
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> writes:
> Keith Thompson wrote:
>> "Alf P. Steinbach" <alf.p.steinbach@gmail.com> 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 */
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2023-06-26 08:46 +0200 |
| Message-ID | <u7bee0$sht9$1@dont-email.me> |
| In reply to | #90716 |
Keith, > curses takes over the entire (text / terminal) screen ... > 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. That indeed makes it pretty-much unusable for me. > In the past, I've tried and failed to find a library that gives access > to that kind of information. IOW, it probably doesn't exist and I need to create my own solution for it. You telling me that saves me a /lot/ of further googeling. Thanks. > (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.) Its something to look at and see if it can be used to do the reverse. Thanks for the info and heads-up. Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> |
|---|---|
| Date | 2023-06-25 18:39 -0400 |
| Message-ID | <Xm3mM.7635$3XE8.5950@fx42.iad> |
| In reply to | #90713 |
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 ? On Linux (strictly speaking, on a GNU system) specifically, try readline function. AFAIK, it is available everywhere bash is so your system should already have it. Try "man readline". > > Second question : How do I check for modifier keys (like alt, shift, ctrl) > on the pressed keys or seperatily ? I would like to be able to, as an > example, catch a ctrl-cursor-left as well as a normal or a shift-curor-left. > > Regards, > Rudy Wieser > > HTH -Pavel
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2023-06-26 00:53 +0100 |
| Message-ID | <87edlz5cax.fsf@bsb.me.uk> |
| In reply to | #90717 |
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> writes: > 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 ? > > On Linux (strictly speaking, on a GNU system) specifically, try readline > function. > > AFAIK, it is available everywhere bash is so your system should already > have it. Try "man readline". I don't know if it's what's wanted but the rlwrap program is not as well know as it should be. Essentially it "wraps" any interactive program with a readline-driven editing, completion and history interface. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2023-06-26 09:11 +0200 |
| Message-ID | <u7bee2$sht9$4@dont-email.me> |
| In reply to | #90719 |
Ben, > Essentially it "wraps" any interactive program with a > readline-driven editing, completion and history interface. Thats pretty-much the opposite of what I currently want/need. I'm trying to write something thats interactive - For example, imagine a list of items you can move thru using the cursor keys and select pressing the spacebar. Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Christian Gollwitzer <auriocus@gmx.de> |
|---|---|
| Date | 2023-06-26 09:32 +0200 |
| Message-ID | <u7bev4$si0u$1@dont-email.me> |
| In reply to | #90726 |
Hi Rudy, Am 26.06.23 um 09:11 schrieb R.Wieser: >> Essentially it "wraps" any interactive program with a >> readline-driven editing, completion and history interface. > > Thats pretty-much the opposite of what I currently want/need. > > I'm trying to write something thats interactive - For example, imagine a > list of items you can move thru using the cursor keys and select pressing > the spacebar. Then you might want something even more higher level than curses. For example, CDK gives you widgets in order to program a GUI that runs in the terminal: https://github.com/lnkgyv/cdk_examples If you are actually looking to do it on your own, you might want to look at termcap, which tells you the raw codes involved: https://www.gnu.org/software/termutils/manual/termcap-1.3/html_node/termcap_37.html Christian
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2023-06-26 13:50 +0100 |
| Message-ID | <877crq4cbp.fsf@bsb.me.uk> |
| In reply to | #90726 |
"R.Wieser" <address@is.invalid> writes: > Ben, > >> Essentially it "wraps" any interactive program with a >> readline-driven editing, completion and history interface. > > Thats pretty-much the opposite of what I currently want/need. Good to know. I suspected it was not the right thing but I had not read every post carefully. > I'm trying to write something thats interactive - For example, imagine a > list of items you can move thru using the cursor keys and select pressing > the spacebar. There used to be libraries built on top of curses (and/or ncurses) that provided higher-level user interaction widgets like this. I can't remember if any caught on, but it might be worth looking before building your own. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2023-06-26 15:03 +0200 |
| Message-ID | <u7c3qt$v2jh$1@dont-email.me> |
| In reply to | #90739 |
Ben, > There used to be libraries built on top of curses (and/or ncurses) > that provided higher-level user interaction widgets like this. I'm not looking for specifically the widgets (the example was just that, something to be able to relate to), but for how to be able to do something interactive with the keyboard. And for that I need to be able to extract keystrokes from the input stream. Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Christian Gollwitzer <auriocus@gmx.de> |
|---|---|
| Date | 2023-06-26 22:27 +0200 |
| Message-ID | <u7csb8$12hso$1@dont-email.me> |
| In reply to | #90740 |
Am 26.06.23 um 15:03 schrieb R.Wieser: >> There used to be libraries built on top of curses (and/or ncurses) >> that provided higher-level user interaction widgets like this. > > I'm not looking for specifically the widgets (the example was just that, > something to be able to relate to), but for how to be able to do something > interactive with the keyboard. And for that I need to be able to extract > keystrokes from the input stream. As written above, you can use the termcap or terminfo library. It tells you what keystrokes correspond to which keys. Christian
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2023-06-26 22:48 +0200 |
| Message-ID | <u7ctic$12pk1$3@dont-email.me> |
| In reply to | #90759 |
Christian, > As written above, you can use the termcap or terminfo library. It tells > you what keystrokes correspond to which keys. A quick search shows me that "termcap" is a textfile which as been marked obsolete and that both are used to translate keystrokes into escape sequences. There where no results shown in regard to translating escape sequences back to keystrokes though. IOW, do you have any link(s) that show how the latter is supposed to be done ? Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2023-06-26 14:35 -0700 |
| Message-ID | <877crpzz39.fsf@nosuchdomain.example.com> |
| In reply to | #90762 |
"R.Wieser" <address@is.invalid> writes:
> Christian,
>
>> As written above, you can use the termcap or terminfo library. It tells
>> you what keystrokes correspond to which keys.
>
> A quick search shows me that "termcap" is a textfile which as been marked
> obsolete and that both are used to translate keystrokes into escape
> sequences. There where no results shown in regard to translating escape
> sequences back to keystrokes though.
>
> IOW, do you have any link(s) that show how the latter is supposed to be done
> ?
termcap and terminfo are specific to Unix-like systems, not to C++.
I suggest asking elsewhere.
--
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 */
[toc] | [prev] | [next] | [standalone]
| From | Christian Gollwitzer <auriocus@gmx.de> |
|---|---|
| Date | 2023-06-26 23:58 +0200 |
| Message-ID | <u7d1ma$13bem$1@dont-email.me> |
| In reply to | #90762 |
Am 26.06.23 um 22:48 schrieb R.Wieser: > Christian, > >> As written above, you can use the termcap or terminfo library. It tells >> you what keystrokes correspond to which keys. > > A quick search shows me that "termcap" is a textfile which as been marked > obsolete and that both are used to translate keystrokes into escape > sequences. There where no results shown in regard to translating escape > sequences back to keystrokes though. > > IOW, do you have any link(s) that show how the latter is supposed to be done > ? The termcap library is only a way to do the forward translation, i.e. you can ask it for a key and get back the string that is represented like this: https://stackoverflow.com/questions/55090078/termcap-tgetstr-getting-arrow-keys However, I still believe you are much better off using the ncurses library, which also does the backwards translation. Look, e.g. at this example: https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/keys.html As you can see here, the getch() function translates the special keys to their symbolic code liek KEY_UP etc. But cave: I gave up text mode programming a long time ago. Christian
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2023-06-26 16:26 -0700 |
| Message-ID | <87zg4lyfdd.fsf@nosuchdomain.example.com> |
| In reply to | #90767 |
Christian Gollwitzer <auriocus@gmx.de> writes:
> Am 26.06.23 um 22:48 schrieb R.Wieser:
>> Christian,
>>
>>> As written above, you can use the termcap or terminfo library. It tells
>>> you what keystrokes correspond to which keys.
>> A quick search shows me that "termcap" is a textfile which as been
>> marked
>> obsolete and that both are used to translate keystrokes into escape
>> sequences. There where no results shown in regard to translating escape
>> sequences back to keystrokes though.
>> IOW, do you have any link(s) that show how the latter is supposed to
>> be done
>> ?
>
> The termcap library is only a way to do the forward translation,
> i.e. you can ask it for a key and get back the string that is
> represented like this:
> https://stackoverflow.com/questions/55090078/termcap-tgetstr-getting-arrow-keys
No, terminfo is newer and is intended to replace termcap, and provides
the same information. If you're starting something new, ignore termcap
and use terminfo (unless you have some specific requirement to use
termcap).
> However, I still believe you are much better off using the ncurses
> library, which also does the backwards translation. Look, e.g. at this
> example:
>
> https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/keys.html
>
> As you can see here, the getch() function translates the special keys
> to their symbolic code liek KEY_UP etc.
Yes, but it's not suitable for the OP's purposes. getch() implicitly
refers to the current ncurses screen (stdscr), and it can't be used
without first setting things up properly, which takes over the terminal
screen. (And comp.lang.c++ isn't the place to ask about it.)
--
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 */
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@is.invalid> |
|---|---|
| Date | 2023-06-26 08:50 +0200 |
| Message-ID | <u7bee1$sht9$2@dont-email.me> |
| In reply to | #90717 |
Pavel, > On Linux (strictly speaking, on a GNU system) specifically, try readline > function. The problem with that is that I need the keys at the moment they are pressed (and released ?), not only after "enter" is pressed. Regards, Rudy Wieser
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2023-06-26 01:39 -0700 |
| Message-ID | <871qhy1usn.fsf@nosuchdomain.example.com> |
| In reply to | #90724 |
"R.Wieser" <address@is.invalid> writes:
>> On Linux (strictly speaking, on a GNU system) specifically, try readline
>> function.
>
> The problem with that is that I need the keys at the moment they are pressed
> (and released ?), not only after "enter" is pressed.
You might take a look at the readline source code to see how it does
that. It's certainly able to recognize the user pressing up-arrow
(which typically sends Esc-[-A) and acting on it immediately,
even if it doesn't expose that ability directly to the user.
--
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 */
[toc] | [prev] | [next] | [standalone]
Page 1 of 8 [1] 2 3 4 5 6 7 8 Next page →
Back to top | Article view | comp.lang.c++
csiph-web