Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

terminal escape sequences for fonts

What I want to develop: Terminal which can use at least 2 fonts in the same time. One font I will use for shell input lines, another font for command output. For example:

user@host$ ls /home
user user1 user2 user3

Why: More readable terminal/shell

How: Here I have problem. Probably shell needs to generate some new escape sequences. And terminal need to load different fonts and handle those sequences. Where to start? How to define new escaping sequence, where are standards?

Future: Maybe somebody want to join me in this project?

like image 504
Tomek Wyderka Avatar asked Nov 16 '12 04:11

Tomek Wyderka


People also ask

What is an escape sequence in terminal?

An escape sequence is a series of characters that performs a control function on the terminal, such as moving the cursor forward or backward or erasing part of the screen. The first character of an escape sequence is an ESC.

What is ANSI in terminal?

ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an ASCII escape character and a bracket character, are embedded into text.

Do ANSI escape sequences work on Windows?

The Win32 console does not natively support ANSI escape sequences at all. Software such as Ansicon can however act as a wrapper around the standard Win32 console and add support for ANSI escape sequences.


1 Answers

The standard for control sequences is pretty much the Xterm Control Sequences document ctlseqs.ms in the XTerm source code. (You can turn it into a PDF with the command groff -ms -Tps ctlseqs.ms | ps2pdf - ctlseqs.pdf, though the -ms option seems to be broken on Ubuntu 12.04).

XTerm already supports control sequences to change the font, but for the entire terminal at once. Open xterm and type into your shell—

echo -e "\033[?35h\033]50;#+1^G\033\\" # aka CSI ? 35 h OSC 50 ; #+1 BEL ST

the font for the entire terminal should change. This control sequence actually supports the names of True-Type fonts as well; see page 21.

If you'd like to change an existing terminal to support changing the font inline, you're welcome to choose pretty much any control sequences not already allocated in ctrlseqs.ms and use them. However, it's a good idea to choose new control sequences similar to the control sequences for functionality that already exists.

Your next step is to get the source code for an existing terminal and start digging. What terminal do you use right now? The source code for Konsole or gnome-terminal is probably going to be easier to work with than that for XTerm.

like image 155
andrewdotn Avatar answered Sep 17 '22 02:09

andrewdotn