🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #15897

linux, ncurses & non-blocking I/O

#15897
From: Alain
Date: Sun, 16 Jul 2000 00:00
63 lines
1982 bytes
Greetings all,

Ik heb een vraag in verband met ncurses en non-blocking i/o.
Ik wil graag dat er binnen een lus dingen worden uitgevoerd tot men op 
de 'q'-toets drukt. De statements binnen de lus worden wel uitgevoerd, 
maar slechts eenmaal per ingedrukte toets. Terwijl het de bedoeling is 
dat de lus uitgevoerd blijft worden tot de 'q'-toets wordt ingedrukt.
Kan iemand me aub. vertellen wat ik verkeerd doe ?
(ik dacht dat je met ncurses aan non-blocking i/o kon doen, als je de
terminal
darvoor initialiseerde met "raw ();" ?? Niet dan ?? )


Regards,
Alain


Het proggie:

#include <ncurses.h>
#include <stdlib.h>
#include <ctype.h>
#include <tgmath.h>
#include <unistd.h>
#include <sys/io.h>

#define DATA 0x378
#define STATUS 0x379
#define CONTROL 0x37A

int main (void)
{
	int ch;
	 
	if (ioperm (DATA, 3, 1)) {perror ("ioperm"); exit (EXIT_FAILURE);}
	if (initscr() == NULL) {perror ("initscr"); exit (EXIT_FAILURE);}

	raw ();
	nonl ();
	noecho ();
	
	while (toupper(ch = getch()) != 'Q')
	{
		/*hier wacht ie dus steeds tot er op een toets wordt gedrukt.*
		 *Is er een andere manier om te testen of er een toets is    *
		 *ingedrukt ??                                               */
		for (ch = 0; ch <=7; ++ch)
		{
			outb (pow(2, ch), DATA);
			usleep(6000);
		}
		for (ch = 7; ch <=0; --ch)
		{
			outb (pow(2, ch), DATA);
			usleep(6000);
		}	
	}

	endwin ();
	
	exit (EXIT_SUCCESS);
}
Technical Details
Message-ID: <3971A0F4.4652E91D@village.uunet.be>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: fcea4,585e7a1c361ac46,start
X-Google-Attributes: gidfcea4,public
From: Alain <zidaya@village.uunet.be>
Subject: linux, ncurses & non-blocking I/O
Date: 2000/07/16
Message-ID: <3971A0F4.4652E91D@village.uunet.be>
X-Deja-AN: 646955673
Content-Transfer-Encoding: 7bit
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Trace: bru5-newsr2.be.uu.net 963748011 12150 212.190.6.111
MIME-Version: 1.0
Newsgroups: be.comp.programming