'\x1b'

O

Olaf \El Blanco\

ESC = '\x1b'
BACKSPACE = '\b'

How can I know (maybe a short program) the full list?
I want to make a menu in C, and I want to use the 'left' 'up' 'down', etc...
 
R

Richard Bos

Olaf \"El Blanco\" said:
ESC = '\x1b'

You do not know this...
BACKSPACE = '\b'

....but you do know this.
How can I know (maybe a short program) the full list?

These are guaranteed by the Standard:

\a is alert (whether this means a bleep, a flash, or something else, is
implementation-dependant).
\b is backspace.
\f is form feed.
\n is new line. It is the character which represents a new line in files
opened in text mode.
\r is carriage return.
\t is a horizontal tab. Size depends on the implementation.
\v is a vertical tab, whatever that is on modern devices.
\' is a literal single quote mark.
\" is a literal double quote mark.
\? is a literal question mark (trigrahps, avoidance, ftpo).
\\ is a literal backslash.

\<octal digits> is the character represented by that octal number, and
\x<hex digits> is the character represented by that hexadecimal number.
The only ones of these of which you reliably know the meaning are
\0, \x0, and equivalent, all of which are character 0, the null
character.

\x1b, as you mention above, is the character with hex value 1b, i.e.
decimal 27. This may or may not represent ESC. It is the character point
for ESC in a very common character set; whether this means that your
implementation also transmits it as an Escape, and whether the OS then
does something sensible with it, is up to them. The Standard neither
does nor reasonably can require it.
I want to make a menu in C, and I want to use the 'left' 'up' 'down', etc...

Can't do that portably. However, if you happen to have a character table
lying around for your OS, and that happens to include cursor key keycode
values, _and_ your implementation gives you these keycodes as input from
the keyboard, you may be able to use these.
Note that any function your implementation may give you to get these
codes without pressing Enter afterwards is non-ISO, unportable, and
therefore off-topic here.

Richard
 
K

Kevin Handy

Olaf said:
ESC = '\x1b'
BACKSPACE = '\b'

How can I know (maybe a short program) the full list?
I want to make a menu in C, and I want to use the 'left' 'up' 'down', etc...

This all greatly depends on what terminal you are
using, and is thus off-topic for this group, as is
mentioned in this groups FAQ.

Also, instead of hard-coding for a specific terminal,
you should probably be using some version of the curses
library (look for 'ncurses' for a popular version).

And, 'curses' is also off-topic for this group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top