Re: [Anjuta-list] executing a program in 1.8



On Mon, 2002-01-07 at 13:06, Naba Kumar wrote:
> On Mon, 2002-01-07 at 03:23, Andy Piper wrote:
> > On 2002.01.06 21:23 Greg Sarsons wrote:
> > > I tried executing a program in a terminal and after the program
> > > was done the bottom of the message was "Press any key to
> > > close this terminal ..." was displayed.
> My idea was to really accept "any key", but it seems the getchar() call
> in anjuta_launcher.c isn't working properly.
> 
> Limiting it to "Enter", obviously, will not be a problem, because the
> "Enter" key will be always there on the keyboard along with the rest of
> the keys. :)
On UNIX systems, the default terminal mode requires that a user
press the Enter key to submit a line of text. This mode allows the use
of line-editing characters, like backspace, before the input goes to the
program. The terminal is known as in "cooked" mode. So we need to use
the "raw" mode, which enables one char-at-a-time mode.

Either we use the harder way (system calls) or the easy way is to use
stty like this (this works on any Unix system) :

	system("stty raw");

	c = getchar();
	printf("%c (%d)\n", c, c);

	system("stty cooked");

Do you like this way or system calls (but I don't know about the
portability issue) ? Tell me before I do it.

Regards,

--Stef










[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]