PC character set (0x00 to 0x1f) and ncurses

Earlier documentation mentioned that there was a way of causing ncurses
to display the graphic characters between 0x00 and 0x1f instead of a
two-character control sequence – by setting an attribute for the
window. I cannot find that “feature” in the QNX version of ncurses.

Does anyone know how to get ncurses to display these character codes as
graphics?


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)

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

Earlier documentation mentioned that there was a way of causing ncurses
to display the graphic characters between 0x00 and 0x1f instead of a
two-character control sequence – by setting an attribute for the
window. I cannot find that “feature” in the QNX version of ncurses.

It’s dependent on the terminal: Linux console’s terminfo says it
supports this feature (smpch and rmpch strings). The same thing
(or equivalent) may/may not work on QNX.


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

On Thu, 17 Aug 2000 19:35:03 -0400, “Robert L. Harris”
<bob@microprograms.com> wrote:

Earlier documentation mentioned that there was a way of causing ncurses
to display the graphic characters between 0x00 and 0x1f instead of a
two-character control sequence – by setting an attribute for the
window. I cannot find that “feature” in the QNX version of ncurses.

Does anyone know how to get ncurses to display these character codes as
graphics?

I don’t know how to do it by setting an attribute for the window.
I do it by passing each character through echochar().
See the documentation under curs_addch.

Carlos

Carlos Clarke <carlos@ptdprolog.net> wrote:

On Thu, 17 Aug 2000 19:35:03 -0400, “Robert L. Harris”
bob@microprograms.com> > wrote:

Earlier documentation mentioned that there was a way of causing ncurses
to display the graphic characters between 0x00 and 0x1f instead of a
two-character control sequence – by setting an attribute for the
window. I cannot find that “feature” in the QNX version of ncurses.

Does anyone know how to get ncurses to display these character codes as
graphics?

I don’t know how to do it by setting an attribute for the window.
I do it by passing each character through echochar().
See the documentation under curs_addch.

curs_addch(3X) Miscellaneous Library Functions curs_addch(3X)

The echochar() and wechochar() routines are functionally
equivalent to a call to addch() followed by a call to
refresh(), or a call to waddch followed by a call to
wrefresh(). The knowledge that only a single character is
being output is taken into consideration and, for non-
control characters, a considerable performance gain might be
seen by using these routines instead of their equivalents.

but addch translates those code to 2-character form. He wants something
that switches to an alternate font (or tells ncurses that it can).

Perhaps echochar isn’t working properly - it should do the same thing.
I see an entry from 970830 for making it work properly, but that’s
still before 4.2.


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

On 18 Aug 2000 18:50:18 GMT, Thomas Dickey <dickey@saltmine.radix.net>
wrote:

Carlos Clarke <> carlos@ptdprolog.net> > wrote:
On Thu, 17 Aug 2000 19:35:03 -0400, “Robert L. Harris”
bob@microprograms.com> > wrote:

Earlier documentation mentioned that there was a way of causing ncurses
to display the graphic characters between 0x00 and 0x1f instead of a
two-character control sequence – by setting an attribute for the
window. I cannot find that “feature” in the QNX version of ncurses.

Does anyone know how to get ncurses to display these character codes as
graphics?

I don’t know how to do it by setting an attribute for the window.
I do it by passing each character through echochar().
See the documentation under curs_addch.

curs_addch(3X) Miscellaneous Library Functions curs_addch(3X)

The echochar() and wechochar() routines are functionally
equivalent to a call to addch() followed by a call to
refresh(), or a call to waddch followed by a call to
wrefresh(). The knowledge that only a single character is
being output is taken into consideration and, for non-
control characters, a considerable performance gain might be
seen by using these routines instead of their equivalents.

but addch translates those code to 2-character form. He wants something
that switches to an alternate font (or tells ncurses that it can).

I’m not telling him to use addch(). The documentation for echochar is
under addch().

Perhaps echochar isn’t working properly - it should do the same thing.

From the Miscellaneous Utilites Bookset documentation under Photon in
the section: Writing Programs with NCURSES by Eric S. Raymond and
Zeyd M. Ben-Halim under the DESCRIPTION section of addch():

“If ch is any control character other than tab, newline, or backspace,
it is drawn in ^X notation. Calling winch after adding a control
character does not return the character itself, but instead returns
the ^-representation of the control character. (To emit control
characters literally, use echochar.)”

I see an entry from 970830 for making it work properly, but that’s
still before 4.2.

I’m not sure what entry you are referring to but I think we are
looking at different documentation.

Carlos Clarke <carlos@ptdprolog.net> wrote:

On 18 Aug 2000 18:50:18 GMT, Thomas Dickey <> dickey@saltmine.radix.net
wrote:

The echochar() and wechochar() routines are functionally
equivalent to a call to addch() followed by a call to

but addch translates those code to 2-character form. He wants something
that switches to an alternate font (or tells ncurses that it can).

I’m not telling him to use addch(). The documentation for echochar is
under addch().

yes, I quoted the paragraph that tells how echochar is handled.

Perhaps echochar isn’t working properly - it should do the same thing.

From the Miscellaneous Utilites Bookset documentation under Photon in
the section: Writing Programs with NCURSES by Eric S. Raymond and
Zeyd M. Ben-Halim under the DESCRIPTION section of addch():

I don’t see this in the current source (for ncurses-intro.html).
There are a lot of old versions around on the net.

“If ch is any control character other than tab, newline, or backspace,
it is drawn in ^X notation. Calling winch after adding a control
character does not return the character itself, but instead returns
the ^-representation of the control character. (To emit control
characters literally, use echochar.)”

I see an entry from 970830 for making it work properly, but that’s
still before 4.2.

I’m not sure what entry you are referring to but I think we are
looking at different documentation.

I’m the fellow who maintains ncurses. I’m referring to the NEWS file
in the source distribution, which records changes made to the code.
970930 is the entry for 1997, September 30.

The current version of ncurses is 5.1 (20000708)
There’s an faq at
http://dickey.his.com/ncurses/ncurses.faq.html


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

Thomas Dickey <dickey@saltmine.radix.net> wrote:

I’m the fellow who maintains ncurses. I’m referring to the NEWS file
in the source distribution, which records changes made to the code.
970930 is the entry for 1997, September 30.

The current version of ncurses is 5.1 (20000708)
There’s an faq at
http://dickey.his.com/ncurses/ncurses.faq.html

The current QNX porting of ncurses is free (with src) on:

ftp://ftp.qnx.com/usr/free/qnx4/os/libs/ncurses-4.2-*

It is ncurses 4.2 patch 980245 (plus some QNX extantion).
Maybe it’s a time to do a port again…

(The fact that Thomas showing up in this group increased
that presure :slight_smile:

-xiaodan

Xiaodan Tang <xtang@ottawa.com> wrote:

Thomas Dickey <> dickey@saltmine.radix.net> > wrote:

The current QNX porting of ncurses is free (with src) on:

ftp://ftp.qnx.com/usr/free/qnx4/os/libs/ncurses-4.2-> *

It is ncurses 4.2 patch 980245 (plus some QNX extantion).
Maybe it’s a time to do a port again…

If we could get the mouse code integrated this time, it would be simpler
for both of us to maintain. I didn’t add the patch before, because it
modified the arrangement of the xterm code, which will involve retesting
on both sides.

(The fact that Thomas showing up in this group increased
that presure > :slight_smile:

well, if people are asking questions, I try to answer them. It really sounds
as if he’s using the 1.9.8a version (I saw something like that on QNX’s ftp
site a few months ago, though I may be looking at the wrong place).

-xiaodan


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

On 18 Aug 2000 19:53:07 GMT, Thomas Dickey <dickey@saltmine.radix.net>
wrote:


I’m the fellow who maintains ncurses. I’m referring to the NEWS file
in the source distribution, which records changes made to the code.
970930 is the entry for 1997, September 30.

O.K., I’m not trying to be argumentative. I’m just referring to the
QNX documentation which does say that echochar can be used to ‘emit
control characters literally’. It does work under QNX.
I don’t know why there is this discrepancy between your version and
the QNX version. Maybe Xiodan can explain.

If there is a problem with the port I would like to know because I
depend upon this ‘feature’ of the QNX port. This is especially
problematic if a new port makes it go away.

In any case, is there a standard way to do what I have been
getting away with?

On 18 Aug 2000 21:18:38 GMT, Thomas Dickey <dickey@saltmine.radix.net>
wrote:

Xiaodan Tang <> xtang@ottawa.com> > wrote:
Thomas Dickey <> dickey@saltmine.radix.net> > wrote:

The current QNX porting of ncurses is free (with src) on:

ftp://ftp.qnx.com/usr/free/qnx4/os/libs/ncurses-4.2-> *

It is ncurses 4.2 patch 980245 (plus some QNX extantion).
I missed this on the first read ^^^^^^^^^^^^^^^^^^^^^.

Xiaodan, is there something that defines the QNX extentions?
Is the operation of echochar one of the extentions?

Maybe it’s a time to do a port again…

If we could get the mouse code integrated this time, it would be simpler
for both of us to maintain. I didn’t add the patch before, because it
modified the arrangement of the xterm code, which will involve retesting
on both sides.

(The fact that Thomas showing up in this group increased
that presure > :slight_smile:

well, if people are asking questions, I try to answer them. It really sounds
as if he’s using the 1.9.8a version (I saw something like that on QNX’s ftp
site a few months ago, though I may be looking at the wrong place).

-xiaodan

Carlos Clarke <carlos@ptdprolog.net> wrote:

On 18 Aug 2000 19:53:07 GMT, Thomas Dickey <> dickey@saltmine.radix.net
wrote:



I’m the fellow who maintains ncurses. I’m referring to the NEWS file
in the source distribution, which records changes made to the code.
970930 is the entry for 1997, September 30.

O.K., I’m not trying to be argumentative. I’m just referring to the
QNX documentation which does say that echochar can be used to ‘emit
control characters literally’. It does work under QNX.
I don’t know why there is this discrepancy between your version and
the QNX version. Maybe Xiodan can explain.

If there is a problem with the port I would like to know because I
depend upon this ‘feature’ of the QNX port. This is especially
problematic if a new port makes it go away.

I think it’s a case where you were relying on a bug that was fixed a while
back.

In any case, is there a standard way to do what I have been
getting away with?

I think so. You should be able to add smpch/rmpch entries to the terminal
description (even if empty, as you imply), to tell ncurses that it can use
the PC character set. There’s an example in the distribution which uses
that (test/blue.c), which I’ve tested recently.

What terminal type are you using, btw, and does it have printable characters
for all 0-31? (doesn’t seem that the carriage-control stuff like CR, LF
and TAB would would - that’s the point of the smpch/rmpch strings, to switch
the terminal into a different character set temporarily).


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

Carlos Clarke <carlos@ptdprolog.net> wrote:

On 18 Aug 2000 21:18:38 GMT, Thomas Dickey <> dickey@saltmine.radix.net
wrote:

Xiaodan Tang <> xtang@ottawa.com> > wrote:
Thomas Dickey <> dickey@saltmine.radix.net> > wrote:

The current QNX porting of ncurses is free (with src) on:

ftp://ftp.qnx.com/usr/free/qnx4/os/libs/ncurses-4.2-> *

It is ncurses 4.2 patch 980245 (plus some QNX extantion).
I missed this on the first read ^^^^^^^^^^^^^^^^^^^^^.
Xiaodan, is there something that defines the QNX extentions?
Is the operation of echochar one of the extentions?

shouldn’t be. from the diffs he showed me (early 1998), most of it was the
code to support mouse. echochar isn’t mentioned.


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

Thomas Dickey <dickey@saltmine.radix.net> wrote:

I think so. You should be able to add smpch/rmpch entries to the terminal
description (even if empty, as you imply), to tell ncurses that it can use
the PC character set. There’s an example in the distribution which uses
that (test/blue.c), which I’ve tested recently.

…to expand on that a little (I don’t have a QNX system to experiment with,
but have read some documentation which may apply), “devansi” documents escape
sequences which can be used to switch the terminal into PC character mode.


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

I will try to reply to all the question in different posts :slight_smile:

Thomas Dickey <dickey@saltmine.radix.net> wrote:

Xiaodan Tang <> xtang@ottawa.com> > wrote:
Thomas Dickey <> dickey@saltmine.radix.net> > wrote:

The current QNX porting of ncurses is free (with src) on:

ftp://ftp.qnx.com/usr/free/qnx4/os/libs/ncurses-4.2-> *

It is ncurses 4.2 patch 980245 (plus some QNX extantion).
Maybe it’s a time to do a port again…

If we could get the mouse code integrated this time, it would be simpler
for both of us to maintain. I didn’t add the patch before, because it
modified the arrangement of the xterm code, which will involve retesting
on both sides.

(The fact that Thomas showing up in this group increased
that presure > :slight_smile:

well, if people are asking questions, I try to answer them. It really sounds
as if he’s using the 1.9.8a version (I saw something like that on QNX’s ftp
site a few months ago, though I may be looking at the wrong place).

The first port of ncurses to QNX is 1.9.8a, and there still
a lot people using it :frowning:

The most troubled :slight_smile: “mouse code” is to handle a “qnxm” terminal.
That terminal don’t generate “mouse key”, so that the library
have to “query” mouse event. Basically it setup so that every
time a mouse event happened, it will notify the application. (a mouse
event proxy in QNX word).

The “extantion” of QNX port is a “user callback” function.
This is done because ncurses application also want to be
notified by other resource. For example, geting data from
network. Now since socket is “selectable”, this is good,
but lot of QNX application are “Receive()ing” from pids
which is not “selectable”. Thus the user callback.

Basically the ncurses library do not using “select()” or
“pull()”, but really do a “Receive()”. It receives everything,
a mouse event, a key event, timer expired notification,
or if it is something it don’t understand, the message
will pass to “user callback”. An additional function
(set_qnx_callback()) is add to allow user setup/cancel their
own callback function.

I don’t think QNX port have anything to do with “echochar()”.
As Thomas point out, this might be a bug but not feature.

Now, on Neutrino, things going to be better. First we don’t
support qnxm terminal anymore. Second it is multi-threaded.
(Thomas, we will have a “Free QNX” called Realtime Platform
for downloading, very soon :slight_smile:

So next port, I am going to drop the mouse support on
“qnxm” terminal (is any body still using it? I doubt).

Thomas, is the current 5.1 thread safe ?

-xiaodan

Xiaodan Tang <xtang@ottawa.com> wrote:
[snip]

: So next port, I am going to drop the mouse support on
: “qnxm” terminal (is any body still using it? I doubt).

Yes, I rely on the mouse support, for THE and Rexx/Curses under QNX. I’m
using ncurses 4.2.

Cheers, Mark

Xiaodan Tang <xtang@ottawa.com> wrote:

I will try to reply to all the question in different posts > :slight_smile:

well, if people are asking questions, I try to answer them. It really sounds
as if he’s using the 1.9.8a version (I saw something like that on QNX’s ftp
site a few months ago, though I may be looking at the wrong place).

The first port of ncurses to QNX is 1.9.8a, and there still
a lot people using it > :frowning:

aside from bug fixes that would require some minor coding changes
(I’d forgotten about echochar, but there’s also echo),
there’s little reason for them to use the older version.

Now, on Neutrino, things going to be better. First we don’t
support qnxm terminal anymore. Second it is multi-threaded.
(Thomas, we will have a “Free QNX” called Realtime Platform
for downloading, very soon > :slight_smile:

I’m interested, but don’t know much about the hardware requirements.
Can it install into a FAT16 extended partition? (If so, it would be
easy to add to the machine I usually develop on - but I’ve got 10
systems installed on it).

So next port, I am going to drop the mouse support on
“qnxm” terminal (is any body still using it? I doubt).

Thomas, is the current 5.1 thread safe ?

for output or input? We’re using a separate thread to make the mouse
work on OS/2 without problems. Output is a different matter, since there
are several global variables that would have to be disguised.


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

Thomas Dickey <dickey@saltmine.radix.net> wrote:

Xiaodan Tang <> xtang@ottawa.com> > wrote:
Thomas, is the current 5.1 thread safe ?

for output or input? We’re using a separate thread to make the mouse
work on OS/2 without problems. Output is a different matter, since there
are several global variables that would have to be disguised.

…also, BeOS’s patch for ‘select()’ uses a separate thread (I didn’t
use that patch when I released 5.0 because the comments on it indicated
it wasn’t free for reuse/redistribution). But my point is that handling
a separate thread for input is relatively simple.


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

Thomas Dickey wrote:

I think so. You should be able to add smpch/rmpch entries to the terminal
description (even if empty, as you imply), to tell ncurses that it can use
the PC character set. There’s an example in the distribution which uses
that (test/blue.c), which I’ve tested recently.

What terminal type are you using, btw, and does it have printable characters
for all 0-31? (doesn’t seem that the carriage-control stuff like CR, LF
and TAB would would - that’s the point of the smpch/rmpch strings, to switch
the terminal into a different character set temporarily).

Yes, all 32 positions have graphics characters. CR = quarter-note, LF
= inverse circle, TAB = circle.

The item that got me (and this thread) started was from the announce
dated January, 27, 1999 (or, at least that is file date on my PC):

  • (PC-clone boxes only) Support for access to the IBM PC ROM
    characters 0-32 through the highlight A_ALTCHARSET.

So, if I do a wattr_on(window, A_ALTCHARSET), I should get a IBM PC ROM
character if I do a waddch(window, ‘\031’)? I don’t.


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)

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


Thomas Dickey wrote:

I think so. You should be able to add smpch/rmpch entries to the terminal
description (even if empty, as you imply), to tell ncurses that it can use
the PC character set. There’s an example in the distribution which uses
that (test/blue.c), which I’ve tested recently.

What terminal type are you using, btw, and does it have printable characters
for all 0-31? (doesn’t seem that the carriage-control stuff like CR, LF
and TAB would would - that’s the point of the smpch/rmpch strings, to switch
the terminal into a different character set temporarily).


Yes, all 32 positions have graphics characters. CR = quarter-note, LF
= inverse circle, TAB = circle.

…and how do you tell the terminal to display a quarter-note rather than
moving the cursor to the left margin (CR)?

The item that got me (and this thread) started was from the announce
dated January, 27, 1999 (or, at least that is file date on my PC):

  • (PC-clone boxes only) Support for access to the IBM PC ROM
    characters 0-32 through the highlight A_ALTCHARSET.

So, if I do a wattr_on(window, A_ALTCHARSET), I should get a IBM PC ROM
character if I do a waddch(window, ‘\031’)? I don’t.

if the terminal supports it, and if the terminfo describes it - it’s a special
case of the alternate character set support. But it’s only afaik been tested
for Linux console: now that my attention’s on it, I see that it’s relying on a
coincidence in the Linux terminfo. From infocmp:

enter_alt_charset_mode=\E[11m,
enter_pc_charset_mode=\E[11m,
exit_alt_charset_mode=\E[10m,
exit_attribute_mode=\E[0;10m,
exit_pc_charset_mode=\E[10m,

while QNX console (from the webpage) uses an SCS-style control sequence for
different character sets (that is, ncurses is setting only one alternate
character set, while QNX may need support more than one). You can probably
make it work as is, by adding rmacs/smacs strings that tell it how to switch
into the PC-character set (I don’t see any in the ‘qnx’ terminfo, though there
is an acsc string which probably wouldn’t work with a different character set).


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

The plot thickens.

If I use (for example) waddch(window, ‘\031’ | A_ALTCHARSET), I get the
desired effect most of the time.

BEL, BS, HT, CR, LF, and FF do not display the IBM graphics.

waddch(window, ‘\033’ | A_ALTCHARSET) yields the desired character (left
arrow) plus a “}”.

While I would like to use waddstr(), I can use the above in a loop if I
can get ‘\033’ to behave. (I have a long string of “unprintables” that
indicate the start/end of messages for radio communications. The
programmer for an earlier version used 4 characters in the alternate set
to display CR, LF, FIGS, and LTRS and I am supposed to maintain the same
interface in the upgrade to QNX 4; hence this exercise).

As GE used to say, “Progress is our most important product”

Thomas Dickey wrote:

if the terminal supports it, and if the terminfo describes it - it’s a special
case of the alternate character set support. But it’s only afaik been tested
for Linux console: now that my attention’s on it, I see that it’s relying on a
coincidence in the Linux terminfo. From infocmp:

enter_alt_charset_mode=\E[11m,
enter_pc_charset_mode=\E[11m,
exit_alt_charset_mode=\E[10m,
exit_attribute_mode=\E[0;10m,
exit_pc_charset_mode=\E[10m,

while QNX console (from the webpage) uses an SCS-style control sequence for
different character sets (that is, ncurses is setting only one alternate
character set, while QNX may need support more than one). You can probably
make it work as is, by adding rmacs/smacs strings that tell it how to switch
into the PC-character set (I don’t see any in the ‘qnx’ terminfo, though there
is an acsc string which probably wouldn’t work with a different character set).


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)