ansi-escape

Python module to enable ANSI colors for stdout on Windows?

孤街浪徒 提交于 2019-11-26 20:56:23
问题 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. 回答1: There are two python modules that are able to do this colorama and tendo.ansiterm module, which was originally written for waf. By initial tests indicate that colorama is more mature, even if it requires two lines of code instead of one. import sys try: import colorama colorama.init() except: try: import

List of ANSI color escape sequences

a 夏天 提交于 2019-11-26 13:57:29
On most terminals it is possible to colorize output using the \033 ANSI escape sequence. I'm looking for a list of all supported colors and options (like bright and blinking). As there are probably differences between the terminals supporting them, I'm mainly interested in sequences supported by xterm-compatible terminals. The ANSI escape sequences you're looking for are the Select Graphic Rendition subset. All of these have the form \033[XXXm where XXX is a series of semicolon-separated parameters. To say, make text red, bold, and underlined (we'll discuss many other options below) in C you

A library to convert ANSI escapes (terminal formatting/color codes) to HTML [closed]

血红的双手。 提交于 2019-11-26 12:35:14
问题 I\'m looking for a code library that converts ANSI escape sequences into HTML color, via plain tags or CSS. For example, something that would convert this: ESC[00mESC[01;34mbinESC[00m ESC[01;34mcodeESC[00m ESC[01;31mdropbox-lnx.x86-0.6.404.tar.gzESC[00m ESC[00mfooESC[00m Into this: <span style=\"color:blue\">bin</span> <span style=\"color:blue\">code</span> <span style=\"color:red\">dropbox-lnx.x86-0.6.404.tar.gz</span> foo Converting breaks into <br/> isn\'t necessary, it\'s just the escape

Python: How can I make the ANSI escape codes to work also in Windows?

爱⌒轻易说出口 提交于 2019-11-26 09:51:36
问题 If I run this in python under linux it works: start = \"\\033[1;31m\" end = \"\\033[0;0m\" print \"File is: \" + start + \"<placeholder>\" + end But if I run it in Windows it doesn\'t work, how can I make the ANSI escape codes work also on Windows? 回答1: You could check Python module to enable ANSI colors for stdout on Windows? to see if it's useful. The colorama module seems to be cross-platform. You install colorama: pip install colorama Then: import colorama colorama.init() start = "\033[1

Removing colors from output

倖福魔咒の 提交于 2019-11-26 05:19:10
问题 I have some script that produces output with colors and I need to remove the ANSI codes. #!/bin/bash exec > >(tee log) # redirect the output to a file but keep it on stdout exec 2>&1 ./somescript The output is (in log file): java (pid 12321) is running...@[60G[@[0;32m OK @[0;39m] I didn\'t know how to put the ESC character here, so I put @ in its place. I changed the script into: #!/bin/bash exec > >(tee log) # redirect the output to a file but keep it on stdout exec 2>&1 ./somescript | sed

List of ANSI color escape sequences

坚强是说给别人听的谎言 提交于 2019-11-26 03:46:21
问题 On most terminals it is possible to colorize output using the \\033 ANSI escape sequence. I\'m looking for a list of all supported colors and options (like bright and blinking). As there are probably differences between the terminals supporting them, I\'m mainly interested in sequences supported by xterm-compatible terminals. 回答1: The ANSI escape sequences you're looking for are the Select Graphic Rendition subset. All of these have the form \033[XXXm where XXX is a series of semicolon

How can I remove the ANSI escape sequences from a string in python

那年仲夏 提交于 2019-11-26 00:38:13
问题 This is my string: \'ls\\r\\n\\x1b[00m\\x1b[01;31mexamplefile.zip\\x1b[00m\\r\\n\\x1b[01;31m\' I was using code to retrieve the output from a SSH command and I want my string to only contain \'examplefile.zip\' What I can use to remove the extra escape sequences? 回答1: Delete them with a regular expression: import re # 7-bit C1 ANSI sequences ansi_escape = re.compile(r''' \x1B # ESC [@-_] # 7-bit C1 Fe [0-?]* # Parameter bytes [ -/]* # Intermediate bytes [@-~] # Final byte ''', re.VERBOSE)

How to make win32 console recognize ANSI/VT100 escape sequences?

瘦欲@ 提交于 2019-11-26 00:14:38
问题 I\'m building a lightweight version of the ncurses library. So far, it works pretty well with VT100-compatible terminals, but win32 console fails to recognise the \\033 code as the beginning of an escape sequence: # include <stdio.h> # include \"term.h\" int main(void) { puts(BOLD COLOR(FG, RED) \"Bold text\" NOT_BOLD \" is cool!\" CLEAR); return 0; } What needs to be done on the C code level, in order that the ANSI.SYS driver is loaded and the ANSI/VT100 escape sequences recognized? 回答1:

What are carriage return, linefeed, and form feed?

一世执手 提交于 2019-11-25 23:47:40
问题 What is the meaning of the following control characters: Carriage return Line feed Form feed 回答1: Carriage return means to return to the beginning of the current line without advancing downward. The name comes from a printer's carriage, as monitors were rare when the name was coined. This is commonly escaped as "\r", abbreviated CR, and has ASCII value 13 or 0x0D. Linefeed means to advance downward to the next line; however, it has been repurposed and renamed. Used as "newline", it terminates