ansi-colors

ANSI escape sequences: save and restore a row position

☆樱花仙子☆ 提交于 2021-02-07 17:23:15
问题 I'm writing a very simple little console application and I'm playing around with some ANSI escape sequences to get some nicer output. What I'm trying to do is something like this. There's a header with a name, and then underneath, as the program runs, several lines are printed. As each line is printed, I'd like to update the header row with a progress meter. eg: My header row [ 0/5 ] ------------------------------------- then after some processing My header row [ 1/5 ] -----------------------

ANSI escape codes not displaying correctly

放肆的年华 提交于 2021-02-05 09:14:05
问题 I have the following defines: #define ANSI_COLOR_RED "\e[31m" #define ANSI_COLOR_GREEN "\e[32m" #define ANSI_COLOR_YELLOW "\e[33m" #define ANSI_COLOR_BLUE "\e[34m" #define ANSI_COLOR_MAGENTA "\e[35m" #define ANSI_COLOR_CYAN "\e[36m" #define ANSI_COLOR_RESET "\e[0m" I then use these like so: char *getStatusColour(eTaskState state) { switch (state) { case eRunning: return ANSI_COLOR_GREEN; break; case eReady: return ANSI_COLOR_YELLOW; break; case eBlocked: return ANSI_COLOR_RED; break; case

Is there a list of ANSI color escape codes somewhere in the standard libraries?

寵の児 提交于 2021-01-27 17:50:35
问题 I write a lot of little helper scripts, and often these print coloured text in the terminal. For the simplicity of their packaging and distribution, I often want these little scripts to be without any dependencies. Hence I'm duplicating data like this a lot in scripts: ansi_colors = { None: '\x1b[0m', # actually black but whatevs 'red': '\x1b[31m', 'green' : '\x1b[32m', ... } Does this data exist anywhere in the core libraries? I dug around and found that curses has some COLOR_* constants,

output of [31m text instead of color

ぃ、小莉子 提交于 2020-07-06 07:47:03
问题 I am trying to print coloured text with colorama but when I compile an exe and run following... from colorama import Fore, Back, Style print(Fore.RED + 'text') print(Back.GREEN + 'and with a green background') print(Style.DIM + 'and in dim text') print(Style.RESET_ALL) print('back to normal now') I get output of:: Output: [31mtext [0m back to normal now Is it possible to print colors when compiling to pyinstaller exe or is this simply not possible? 回答1: On Windows, you have to initialize

output of [31m text instead of color

a 夏天 提交于 2020-07-06 07:43:24
问题 I am trying to print coloured text with colorama but when I compile an exe and run following... from colorama import Fore, Back, Style print(Fore.RED + 'text') print(Back.GREEN + 'and with a green background') print(Style.DIM + 'and in dim text') print(Style.RESET_ALL) print('back to normal now') I get output of:: Output: [31mtext [0m back to normal now Is it possible to print colors when compiling to pyinstaller exe or is this simply not possible? 回答1: On Windows, you have to initialize

Python’s `str.format()`, fill characters, and ANSI colors

丶灬走出姿态 提交于 2020-06-24 08:39:17
问题 In Python 2, I’m using str.format() to align a bunch of columns of text I’m printing to a terminal. Basically, it’s a table, but I’m not printing any borders or anything—it’s simply rows of text, aligned into columns. With no color-fiddling, everything prints as expected. If I wrap an entire row (i.e., one print statement) with ANSI color codes, everything prints as expected. However: If I try to make each column a different color within a row, the alignment is thrown off. Technically, the

ANSI colors in Java Swing text fields

我们两清 提交于 2020-02-01 03:18:09
问题 Is there any simple way to parse Ansi colors in log files, and use it in text fields in Swing (JTextArea, JTextPAne,...)? 回答1: Not tried it, but there's some code here (which needs some formatting to look nice) which claims to be an ANSI colored JTextPane subclass... For posterity, here is the class run through NetBeans to format the code import javax.swing.*; import javax.swing.text.*; import java.awt.Color; public class ColorPane extends JTextPane { static final Color D_Black = Color

Better ruby terminal coloring library

梦想的初衷 提交于 2020-01-01 12:10:38
问题 There are plenty of coloring libraries: colored, term-ansicolor. But is there any which can do this: puts "#{'hello'.red} world!".bold And world! should be bold. To make it clear, I want to get this: "\e[1m\e[31mhello\e[0m\e[1m world!\e[0m" or better even this (just shorter): "\e[1;31mhello\e[0;1m world!\e[0m" instead of this: "\e[1m\e[31mhello\e[0m world!\e[0m" 回答1: As there is none, I wrote my own, with blackjack and hookers smart one — smart_colored gem install smart_colored and run

Printing to STDOUT and log file while removing ANSI color codes

£可爱£侵袭症+ 提交于 2019-12-13 12:05:09
问题 I have the following functions for colorizing my screen messages: def error(string): return '\033[31;1m' + string + '\033[0m' def standout(string): return '\033[34;1m' + string + '\033[0m' I use them as follows: print error('There was a problem with the program') print "This is normal " + standout("and this stands out") I want to log the output to a file (in addition to STDOUT) WITHOUT the ANSI color codes, hopefully without having to add a second "logging" line to each print statement. The