Questions tagged [ansi-escape]

ANSI escape code (or escape sequences) is the method of in-band signaling to control formatting, color, and other output options on video text terminals.

To encode this formatting information, it embeds certain sequences of bytes into the text, which have to be interpreted specially, not as codes of characters. Although hardware text terminals have become increasingly rare in the 21st century, the relevance of this standard persists because most terminal emulators interpret at least some of the ANSI escape sequences in the output text. One notable exception is the win32 console component of Microsoft Windows.

655 questions
18
votes
3 answers

Python module to enable ANSI colors for stdout on Windows?

I am looking for a Python module that would add ANSI support under Windows. This means that after importing the module, if you output ANSI escaped strings, they will appear accordingly.
sorin
  • 161,544
  • 178
  • 535
  • 806
18
votes
4 answers

Reading the Device Status Report ANSI escape sequence reply

I'm trying to retrieve the coordinates of cursor in a VT100 terminal using the following code: void getCursor(int* x, int* y) { printf("\033[6n"); scanf("\033[%d;%dR", x, y); } I'm using the following ANSI escape sequence: Device Status…
Witiko
  • 3,167
  • 3
  • 25
  • 43
16
votes
1 answer

Save and restore terminal content

I am writing automation scripts (perl/bash). Many of them benefit from some basic terminal GUI. I figured I'd use standard ANSI sequences for basic drawing. Before drawing in terminal I do clear but doing that I lose some terminal command history. I…
oᴉɹǝɥɔ
  • 1,796
  • 1
  • 18
  • 31
14
votes
6 answers

adding text decorations to console output

I have a c# .net 3.5 application that writes text to the console using a StreamWriter. Is there a way I can add text decorations like underline and strikethrough to the text that is printed to the console? Possibly using ANSI escape…
PaulH
  • 7,759
  • 8
  • 66
  • 143
14
votes
1 answer

How do I determine size of ANSI terminal?

Standard input and output are connected to a terminal that implements ANSI escape sequences, but is of unknown dimensions. I need to know how big the terminal so to facilitate drawing a full-screen text UI on it. How can I get the size? The correct…
Joshua
  • 40,822
  • 8
  • 72
  • 132
14
votes
1 answer

ANSI questions: "\x1B[?25h" and "\x1BE"

What does "\x1B[?25h" do? How is "\x1BE" different from "\n"? According to http://ascii-table.com/ansi-escape-sequences-vt-100.php it "moves to next line"? Seems like that's what "\n" does? I tried echo "xxx\nxxx\n" and echo "xxx\x1BExxx\n" in PHP…
neubert
  • 15,947
  • 24
  • 120
  • 212
13
votes
3 answers

ANSI-Coloring Console Output with .NET

I try to generate colored console output using ANSI escape codes with the following minimal C# program: using System; // test.cs class foo { static void Main(string[] args) { Console.WriteLine("\x1b[36mTEST\x1b[0m"); } } I am…
Tomalak
  • 332,285
  • 67
  • 532
  • 628
12
votes
5 answers

Is it possible to display text in a console with a strike-through effect?

I have already looked into ANSI escape codes, but it looks like only underlining is supported. Do I miss something or is there another option? If it is not possible, is there something equivalent in the meaning of "this is deprecated"?
soc
  • 27,983
  • 20
  • 111
  • 215
12
votes
2 answers

Check if console supports ANSI escape codes in Java

I'm building a program in Java that uses menus with different colors using ANSI escape codes. Something like System.out.println("\u001B[36m"+"Menu option"+"\u001B[0m"); The problem is that i want to check if the console where the code is going to…
Slye
  • 198
  • 2
  • 13
12
votes
4 answers

Bash printing color codes literally and not in actual color

For some reason my shell script stopped printing my menu in color and is actually printing the literal color code instead. Did I somehow escape the color coding? Script #!/bin/bash function showEnvironments { echo -e "\e[38;5;81m" echo -e " …
Adrian E
  • 1,884
  • 3
  • 21
  • 33
12
votes
3 answers

Removing color decorations from strings before writing them to logfile

I use the ruby logger like this: $logger = Logger.new MultiIO.new($stdout, log_file) Where the MultiIO is a class I got from this answer. This works great, mostly, but I am using 'colored' rubygem to give coloured output on the terminal. …
wim
  • 338,267
  • 99
  • 616
  • 750
12
votes
5 answers

256 color terminal library for Ruby?

Is there a gem like 'Term::ANSIColor' which works with 256 color terminals? The perl script 256colors2.pl works great in my terminal, and I'd like to use some of these colors in my ruby scripts without manually inserting the ANSI codes.
brianegge
  • 29,240
  • 13
  • 74
  • 99
12
votes
3 answers

How can I see the colored log using tail or less?

Reading a Rails log with vim, we can see a colored log. But when we use tail -f or less to watch the log, it isn't colorized anymore. Is there any way to see the colored log with tail or less or whatever?
Benjamin
  • 10,085
  • 19
  • 80
  • 130
11
votes
4 answers

How to load ANSI escape codes or get coloured file listing in WinXP cmd shell?

This is related to this question : How to get coloured file listing in windows cmd shell ? I'm trying to get, wouldn't you believe it, coloured file listing in windows cmd shell. Windows are XP SP2, if that matters. In the old DOS days there used to…
Rook
  • 60,248
  • 49
  • 165
  • 242
11
votes
2 answers

How do I apply formatting like italic or bold to text using ANSI escaping sequences in a console?

How do I format text with ANSI escaping? Like make things italic or bold and maybe strikethrough and super script.
jepjep40
  • 181
  • 1
  • 2
  • 12
1 2
3
43 44