Ask a Question related to UNIX Programming, Design and Development.
-
C.Hagedorn #1
Re: howto grab key strokes directly?
ups, ok hier nochmal auf deutsch:
Wie veranlasse ich mein C Programm dazu direkt auf Tastendruecke zu
reagieren?
Standardmaessig wird das doch (soweit ich weiss) in einem
Line-Puffer zwischengepseichert. Erst mit <return> bemerkt
select() etwas am Eingang. Ich moechte aber beispielsweise direkt
in einer Endlos-Schleife mitbekommen, wenn Ctrl-q gedrueckt wurde.
Wie mache ich das?
Nach welchen Schlagworten muss man da eigentlich suchen?
Kann man einfach so den Standard Modus von stdin aendern und kurz vor
Programmende wieder herstellen oder gibt es da Komplokationen?
Vielen Dank schonmal,
Christoph
C.Hagedorn Guest
-
Grab ID or DIV sections From ASP
Hi, Is it possible to grab some sections or tags using ID on a HTML page ? I m working on a adserver project that allows to track users on... -
Grab HTML
I'm looking for a way to grab the HTML behind one of my pages and display it to the user. The page I'm trying to get the HTML from is an ASP page,... -
Content grab / extraction
Dear all, Hopefully there´s someone who can help me. I´m looking for an ASP/Javascript possibility to grab content from another website and... -
is there a way to grab more memory for Director to use?
Hi! Post some of your animation code, and we wil have a look at it. Sounds strange that it's slow, so it must be something with the code. ... -
How to grab HTML source?
"Mike Darrett" <mike-nospam@darrettenterprises.com> schrieb im Newsbeitrag news:d945119c.0305021419.3f461b9f@posting.google.com... hey mike -... -
Raymundo M. Vega #2
Re: howto grab key strokes directly?
there must be several ways of doing this, here is one:
- in your program include <termio.h>
- have a statmement: struct termio save, term;
- use ioctl to read terminal settings into term structure
- save a copy of term into save structure
- term.c_lflag&= ~ICANON;
- term.c_cc[VMIN] = 1;
- term.c_cc[VTIME] = 0;
- set nbew state with new call to ioctl(0, TCSETA, &term);
- your loop follows here, reading one char from stdin each time:
read(0, &in, 1);
where in is a char variable.
- process every input
- when loop is broken then reset old state with:
ioctl(0, TCSETA, &save);
It may help.
raymundo
C.Hagedorn wrote:> Hi all,
>
> i want to write a console application with an infinite loop, which
> reacts on key strokes like Ctrl-q for example to end the loop .
>
> How can i do this?
>
> I figured out to use select() to get noticed if stdin has data to read,
> but i still have to press Enter to confirm the input.
>
> How can i set stdin again within my application to get
> unbuffered, non-blocking (no suspend of the process) input?
>
> The select() function is a good step, but how to switch off <cr>?
>
> Thanks in advance,
> Christoph
>
>Raymundo M. Vega Guest
-
Floyd Davidson #3
Re: howto grab key strokes directly?
[email]mdanko@tesla.rcub.bg.ac.yu[/email] (Darko M.) wrote:
I've been posting that to Usenet for well over a decade. It has>Wow! This is really something. Is it yours or did you pick it up in
>some header? I the answer is "It's mine" then please tell me where's
>all the terminals' stuff documentation, because it definitely isn't in
>Stevens (not that much).
>
>It would be a really precious information, thank you.
evolved significantly because it originally used termio and
pre-dated ANSI C, but since about 1993 has used termios.
Actually, that particular version has modifications that were
not in it the last time I posted it. I changed all uses of file
descriptor 0 to use STDIN_FILENO instead, and reformatted it
eliminate lines longer than 64 characters. There are a couple
of other changes that I'm thinking of, which might be made the
next time it is posted.
I believe, but have not verified, that virtually everything
needed to understand what it does is in fact in Stevens, though
it might be spread around in too many different places to be
obvious. That is why I've bundled it with an example "menu
program" as a demo.
Other sources of information are also spread out. The man pages
for stty, termios, and each function used in the program should
all be read. The C FAQ and the FAQ for this newsgroup are also
required reading.
--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) [email]floyd@barrow.com[/email]
Floyd Davidson Guest
-
Morris Dovey #4
Re: howto grab key strokes directly?
C.Hagedorn wrote:
Christoph> Hi all,
>
> i want to write a console application with an infinite loop, which
> reacts on key strokes like Ctrl-q for example to end the loop .
>
> How can i do this?
>
> I figured out to use select() to get noticed if stdin has data to read,
> but i still have to press Enter to confirm the input.
>
> How can i set stdin again within my application to get
> unbuffered, non-blocking (no suspend of the process) input?
>
> The select() function is a good step, but how to switch off <cr>?
Take a quick look at [url]http://www.iedu.com/mrd/c/getch.c[/url] for a
program written with info from Stevens' "Advanced Programming in
the UNIX Environment".
HTH
--
Morris Dovey
West Des Moines, Iowa USA
C links at [url]http://www.iedu.com/c[/url]
Morris Dovey Guest



Reply With Quote

