Up/Down Arrow Key prompts

Brian K. White brian at aljex.com
Sun Mar 9 18:11:46 PDT 2008


----- Original Message ----- 
From: "Fairlight" <fairlite at fairlite.com>
To: "'filepro list'" <filepro-list at lists.celestial.com>
Sent: Sunday, March 09, 2008 2:04 PM
Subject: Re: Up/Down Arrow Key prompts


> This public service announcement was brought to you by Scott Walker:
>> Is there a way to show the up/down arrow keys as a symbol, ie an image
>> of the arrow pointing up and an image of the arrow pointing down,
>> instead of having to spell it out in text?
> 
> No.  They don't even exists in codepage 437.

http://en.wikipedia.org/wiki/Code_page_437#Characters begs to differ. 
Not only do the characters exist, but two different forms even. Lines with arrowheads and big triangles.

The problem is merely that displaying them is tricky because they are mapped to bytes that are usually control characters, not printing characters.

The answer will involve:
1) Ensure that the font being used in your terminal emulator actually has those glyphs.
2) Determine the necessary escape sequences to tell the terminal to flip to the alternate character set, or alternate mapping, where some/all of the glyphs for bytes 0 to 127 are shifted to 128 to 255

So, assuming your font has the glyphs, and assuming you wanted to display character 24 (decimal) up-arrow, you'd send some escape sequence and then display character 151 decimal (127+24)

at the command line it would be like this (151 decimal is 227 octal):
tput smacs ;echo -en "\227";tput rmacs
or more usefully:
SMACS=`tput smacs`
RMACS=`tput rmacs`
echo -e "This is an up arrow: ${SMACS}\227${RMACS}"

For filepro you'd unfortunately just about have to hard code the app for a particular terminal type and character set, because there's relly no good way to do the equivalent of "tput smacs", which means: "find the proper escape codes for 'set mode alternate character set' for your $TERM from the terminfo database and output them to the screen". Instead you have to just log in using the same terminal everyone else uses, and capture the escape code for that terminal once to see what it is and embed that in the app:

tput smacs |od -t x1c
0000000   27   91   49   49  109
        033   [   1   1   m
0000005

That's two different renditions of the same byte sequence. -t x1 shows decimal values, which is handy for filepros chr() function, but most bytes are ordinary characters so -t c shows ordinary characters where possible and octal for the rest. You could also do:
tput smacs |cat -sv ;echo
which shows
^[[11m
And it'd be up to you to recognize that ^[ is really a single escape character.

In filepro you'd take the info from above and do:

then: smacs=chr("27")&"[11m"  ' set alt charset (ansi)
then: rmacs=chr("27")&"[10m"  ' reset alt charset (ansi)
then: uarr=smacs&chr("151")&rmacs   ' display up-arrow character
then: show "Previous-\I "&uarr&" \I"

Now... the exact details you still have to work out. These exact values didn't actually work on my usual terminal for example. The commands are good, merely, either my font doesn't have those glyphs, or "smacs" is not the right escape sequence to use. (I get a reverse-accented lowercase u)
There is more than one form of alternate character set or alternat glyph mapping commands. smacs was just an easy example to work with.

But, it can be done and that's how you'd do it if it was worth it.

If you want to assume a windows terminal emulator for the terminal, these days with most terminal emulators you can probably send an escape sequence to switch into unicode mode, then send the unicode bytes for any character under the sun, then send the escape sequence to switch back out of unicode.

-- 
Brian K. White    brian at aljex.com    http://www.myspace.com/KEYofR
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro  BBx    Linux  SCO  FreeBSD    #callahans  Satriani  Filk!



More information about the Filepro-list mailing list