terminfo

I want to handle keyboard through terminfo database.


#include <stdio.h>
#include <curses.h>
#include <signal.h>

static void finish(int sig)
{
/* do your non-curses wrapup here */

endwin();

exit(0);
}

main(int argc, char argv[])
{
/
initialize your non-curses data structures here /
(void) initscr(); /
initialize the curses library /
keypad(stdscr, TRUE); /
enable keyboard mapping /
(void) nonl(); /
tell curses not to do NL->CR/NL on output /
(void) cbreak(); /
take input chars one at a time, no wait for \n
/
(void) noecho(); /
don’t echo input /



for (;:wink:
{
int c;
c = getch(); /
refresh, accept single keystroke of input */

printf(“c = %d\n”, c );
}

finish(0); /* we’re done */
}


In the following code almost everything works expect the printf.
It’s not flushed. I have to fflush(stdout).

I have tried to turn on/off every terminal device flag I could
thing of with no success.

Anyone with a suggestion?

  • Mario

    \

mcharest@zinformatic.com || www.zinformatic.com
“The more I know, the more I know I don’t know”

I have always had to use the ncurses output functions like wprintw etc instead
of just printf.

KenR

Mario Charest wrote:

I want to handle keyboard through terminfo database.

#include <stdio.h
#include <curses.h
#include <signal.h

static void finish(int sig)
{
/* do your non-curses wrapup here */

endwin();

exit(0);
}

main(int argc, char argv[])
{
/
initialize your non-curses data structures here /
(void) initscr(); /
initialize the curses library /
keypad(stdscr, TRUE); /
enable keyboard mapping /
(void) nonl(); /
tell curses not to do NL->CR/NL on output /
(void) cbreak(); /
take input chars one at a time, no wait for \n
/
(void) noecho(); /
don’t echo input */

for (;:wink:
{
int c;
c = getch(); /* refresh, accept single keystroke of input */

printf(“c = %d\n”, c );
}

finish(0); /* we’re done */
}

In the following code almost everything works expect the printf.
It’s not flushed. I have to fflush(stdout).

I have tried to turn on/off every terminal device flag I could
thing of with no success.

Anyone with a suggestion?

  • Mario

mcharest@zinformatic.com > || > www.zinformatic.com
“The more I know, the more I know I don’t know”

For now I can’t ;-( , this is hook up with program that has a bunch of
printf.

Plus in the futur I don’t think I can get everyone to not ever
use printf. I’m sure some one will come to me and say,
hey my printf is doing weird stuff…

“Ken Recchia” <rectech@nctimes.net> wrote in message
news:39B93929.80C573D4@nctimes.net

I have always had to use the ncurses output functions like wprintw etc
instead
of just printf.

KenR

Mario Charest wrote:

I want to handle keyboard through terminfo database.

#include <stdio.h
#include <curses.h
#include <signal.h

static void finish(int sig)
{
/* do your non-curses wrapup here */

endwin();

exit(0);
}

main(int argc, char argv[])
{
/
initialize your non-curses data structures here /
(void) initscr(); /
initialize the curses library /
keypad(stdscr, TRUE); /
enable keyboard mapping /
(void) nonl(); /
tell curses not to do NL->CR/NL on output
/
(void) cbreak(); /
take input chars one at a time, no wait
for \n
/
(void) noecho(); /
don’t echo input */

for (;:wink:
{
int c;
c = getch(); /* refresh, accept single keystroke of input */

printf(“c = %d\n”, c );
}

finish(0); /* we’re done */
}

In the following code almost everything works expect the printf.
It’s not flushed. I have to fflush(stdout).

I have tried to turn on/off every terminal device flag I could
thing of with no success.

Anyone with a suggestion?

  • Mario

mcharest@zinformatic.com > || > www.zinformatic.com
“The more I know, the more I know I don’t know”

Mario Charest <mcharest@zinformatic.com> wrote:

For now I can’t ;-( , this is hook up with program that has a bunch of
printf.

Plus in the futur I don’t think I can get everyone to not ever
use printf. I’m sure some one will come to me and say,
hey my printf is doing weird stuff…

I agree with Ken that if you start initscr(), you supposed to using
ncurses library functions to update screen.

The initscr() of ncurses lib, will clear these flags:

.c_lflag &= ~(ECHO|ECHONL);
.c_iflag &= ~(ICRNL|INLCR|IGNCR);
.c_oflag &= ~(ONLCR);

You can get the source code from “ftp://ftp.qnx.com/usr/free/qnx4/os/libs/ncurses-4.2*”.

-xtang


“Ken Recchia” <> rectech@nctimes.net> > wrote in message
news:> 39B93929.80C573D4@nctimes.net> …
I have always had to use the ncurses output functions like wprintw etc
instead
of just printf.

KenR

Mario Charest wrote:

I want to handle keyboard through terminfo database.

#include <stdio.h
#include <curses.h
#include <signal.h

static void finish(int sig)
{
/* do your non-curses wrapup here */

endwin();

exit(0);
}

main(int argc, char argv[])
{
/
initialize your non-curses data structures here /
(void) initscr(); /
initialize the curses library /
keypad(stdscr, TRUE); /
enable keyboard mapping /
(void) nonl(); /
tell curses not to do NL->CR/NL on output
/
(void) cbreak(); /
take input chars one at a time, no wait
for \n
/
(void) noecho(); /
don’t echo input */

for (;:wink:
{
int c;
c = getch(); /* refresh, accept single keystroke of input */

printf(“c = %d\n”, c );
}

finish(0); /* we’re done */
}

In the following code almost everything works expect the printf.
It’s not flushed. I have to fflush(stdout).

I have tried to turn on/off every terminal device flag I could
thing of with no success.

Anyone with a suggestion?

  • Mario

mcharest@zinformatic.com > || > www.zinformatic.com
“The more I know, the more I know I don’t know”

I don’t understand. You are going to link with other programs which are using
printf’s? Then you will process or format these?

Mario Charest wrote:

For now I can’t ;-( , this is hook up with program that has a bunch of
printf.

Plus in the futur I don’t think I can get everyone to not ever
use printf. I’m sure some one will come to me and say,
hey my printf is doing weird stuff…

“Ken Recchia” <> rectech@nctimes.net> > wrote in message
news:> 39B93929.80C573D4@nctimes.net> …
I have always had to use the ncurses output functions like wprintw etc
instead
of just printf.

KenR

Mario Charest wrote:

I want to handle keyboard through terminfo database.

#include <stdio.h
#include <curses.h
#include <signal.h

static void finish(int sig)
{
/* do your non-curses wrapup here */

endwin();

exit(0);
}

main(int argc, char argv[])
{
/
initialize your non-curses data structures here /
(void) initscr(); /
initialize the curses library /
keypad(stdscr, TRUE); /
enable keyboard mapping /
(void) nonl(); /
tell curses not to do NL->CR/NL on output
/
(void) cbreak(); /
take input chars one at a time, no wait
for \n
/
(void) noecho(); /
don’t echo input */

for (;:wink:
{
int c;
c = getch(); /* refresh, accept single keystroke of input */

printf(“c = %d\n”, c );
}

finish(0); /* we’re done */
}

In the following code almost everything works expect the printf.
It’s not flushed. I have to fflush(stdout).

I have tried to turn on/off every terminal device flag I could
thing of with no success.

Anyone with a suggestion?

  • Mario

mcharest@zinformatic.com > || > www.zinformatic.com
“The more I know, the more I know I don’t know”

Can you switch to fprintf(stderr, …)? Output to stderr does not
require flushing.

Mario Charest wrote:

I want to handle keyboard through terminfo database.

#include <stdio.h
#include <curses.h
#include <signal.h

static void finish(int sig)
{
/* do your non-curses wrapup here */

endwin();

exit(0);
}

main(int argc, char argv[])
{
/
initialize your non-curses data structures here /
(void) initscr(); /
initialize the curses library /
keypad(stdscr, TRUE); /
enable keyboard mapping /
(void) nonl(); /
tell curses not to do NL->CR/NL on output /
(void) cbreak(); /
take input chars one at a time, no wait for \n
/
(void) noecho(); /
don’t echo input */

for (;:wink:
{
int c;
c = getch(); /* refresh, accept single keystroke of input */

printf(“c = %d\n”, c );
}

finish(0); /* we’re done */
}

In the following code almost everything works expect the printf.
It’s not flushed. I have to fflush(stdout).

I have tried to turn on/off every terminal device flag I could
thing of with no success.

Anyone with a suggestion?

  • Mario

mcharest@zinformatic.com > || > www.zinformatic.com
“The more I know, the more I know I don’t know”

Bob Harris In short, you may buy a servant or slave,
Bath, NH but you cannot buy a friend.
bob@microprograms.com (Thoreau: Wild Fruits)

“Xiaodan Tang” <xtang@ottawa.com> wrote in message
news:8pbfco$1c1$1@nntp.qnx.com

Mario Charest <> mcharest@zinformatic.com> > wrote:

For now I can’t ;-( , this is hook up with program that has a bunch of
printf.

Plus in the futur I don’t think I can get everyone to not ever
use printf. I’m sure some one will come to me and say,
hey my printf is doing weird stuff…

I agree with Ken that if you start initscr(), you supposed to using
ncurses library functions to update screen.

The initscr() of ncurses lib, will clear these flags:

.c_lflag &= ~(ECHO|ECHONL);
.c_iflag &= ~(ICRNL|INLCR|IGNCR);
.c_oflag &= ~(ONLCR);

You can get the source code from
“> ftp://ftp.qnx.com/usr/free/qnx4/os/libs/ncurses-4.2> *”.

Ok great, I have looked at /usr/free/qnx4/os/terminfo/ncurses, but they
seemed outdated :wink:

-xtang


“Ken Recchia” <> rectech@nctimes.net> > wrote in message
news:> 39B93929.80C573D4@nctimes.net> …
I have always had to use the ncurses output functions like wprintw etc
instead
of just printf.

KenR

Mario Charest wrote:

I want to handle keyboard through terminfo database.

#include <stdio.h
#include <curses.h
#include <signal.h

static void finish(int sig)
{
/* do your non-curses wrapup here */

endwin();

exit(0);
}

main(int argc, char argv[])
{
/
initialize your non-curses data structures here /
(void) initscr(); /
initialize the curses library /
keypad(stdscr, TRUE); /
enable keyboard mapping /
(void) nonl(); /
tell curses not to do NL->CR/NL on
output
/
(void) cbreak(); /
take input chars one at a time, no wait
for \n
/
(void) noecho(); /
don’t echo input */

for (;:wink:
{
int c;
c = getch(); /* refresh, accept single keystroke of input
*/

printf(“c = %d\n”, c );
}

finish(0); /* we’re done */
}

In the following code almost everything works expect the printf.
It’s not flushed. I have to fflush(stdout).

I have tried to turn on/off every terminal device flag I could
thing of with no success.

Anyone with a suggestion?

  • Mario

mcharest@zinformatic.com > || > www.zinformatic.com
“The more I know, the more I know I don’t know”

I’m not sure if it is possible to do what you want. Ask on the ncurses bug
e-mail list at bug-ncurses@gnu.org and Thomas Dickey (the maintainer of
ncurses) may have some advice. Also the latest version is 5.1 but that is not
ported to QNX yet.

Another reference is: ftp://dickey.his.com/ncurses/ncurses.html

KenR



Mario Charest wrote:

I want to handle keyboard through terminfo database.

#include <stdio.h
#include <curses.h
#include <signal.h

static void finish(int sig)
{
/* do your non-curses wrapup here */

endwin();

exit(0);
}

main(int argc, char argv[])
{
/
initialize your non-curses data structures here /
(void) initscr(); /
initialize the curses library /
keypad(stdscr, TRUE); /
enable keyboard mapping /
(void) nonl(); /
tell curses not to do NL->CR/NL on output /
(void) cbreak(); /
take input chars one at a time, no wait for \n
/
(void) noecho(); /
don’t echo input */

for (;:wink:
{
int c;
c = getch(); /* refresh, accept single keystroke of input */

printf(“c = %d\n”, c );
}

finish(0); /* we’re done */
}

In the following code almost everything works expect the printf.
It’s not flushed. I have to fflush(stdout).

I have tried to turn on/off every terminal device flag I could
thing of with no success.

Anyone with a suggestion?

  • Mario

mcharest@zinformatic.com > || > www.zinformatic.com
“The more I know, the more I know I don’t know”

Ken Recchia <rectech@nctimes.net> wrote:

I’m not sure if it is possible to do what you want. Ask on the ncurses bug
e-mail list at > bug-ncurses@gnu.org > and Thomas Dickey (the maintainer of
ncurses) may have some advice. Also the latest version is 5.1 but that is not
ported to QNX yet.

Another reference is: > ftp://dickey.his.com/ncurses/ncurses.html
http://dickey.his.com/ncurses/ncurses.html

ftp://dickey.his.com/ncurses/


Thomas E. Dickey <dickey@radix.net> <dickey@herndon4.his.com>
http://dickey.his.com
ftp://dickey.his.com

“Mario Charest” <mcharest@zinformatic.com> wrote in message
news:8pdeuu$k5b$1@inn.qnx.com

“Xiaodan Tang” <> xtang@ottawa.com> > wrote in message
news:8pbfco$1c1$> 1@nntp.qnx.com> …
Mario Charest <> mcharest@zinformatic.com> > wrote:

For now I can’t ;-( , this is hook up with program that has a bunch of
printf.

Plus in the futur I don’t think I can get everyone to not ever
use printf. I’m sure some one will come to me and say,
hey my printf is doing weird stuff…

I agree with Ken that if you start initscr(), you supposed to using
ncurses library functions to update screen.

The initscr() of ncurses lib, will clear these flags:

.c_lflag &= ~(ECHO|ECHONL);
.c_iflag &= ~(ICRNL|INLCR|IGNCR);
.c_oflag &= ~(ONLCR);

Got it:

setvbuf ( stdout, NULL, _IOLBF, 2048 )

I’m not sure how “robust” this solution is. I would have rather
use some low level ncurse function to do the input translation,
but I’ve spend enough time on this already ;-(

  • Mario

Robert L. Harris <bob@microprograms.com> wrote:

Can you switch to fprintf(stderr, …)? Output to stderr does not
require flushing.

Actually, it’s just that stderr automatically flushes every
character.

It’s a really, really big hammer to use to solve this.