ansi-escape

How can I unit/integration test a program's ANSI escape code behavior?

柔情痞子 提交于 2019-12-20 03:08:13
问题 I've started adding some coloring and other functionality (line resets, etc.) to my application and would like to have some unit tests covering the behavior. I know I could just assert that the output contains the appropriate \e[... codes, but that's brittle. For one, it would fail if it were swapped to \033 or otherwise refactored in trivial but not identical ways. More to the point however, testing the sequence of characters doesn't really do what I want. I want to assert or verify that the

Java framework for reading / writing ANSI escape-sequenced character streams

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 16:58:14
问题 Reading ANSI escape sequences is nitty gritty and very easy to get wrong. I am after a library that includes an abstraction for reading escaped sequences preferrably as instances of some nice type. It would be nice if the library offered strongly types rather than everything is a strong and good luck do the stuff yourself. Any pointers to a foss library would be appreciated. A similar question A library to convert ANSI escapes (terminal formatting/color codes) to HTML which seems to have a

Java framework for reading / writing ANSI escape-sequenced character streams

大憨熊 提交于 2019-12-18 16:58:05
问题 Reading ANSI escape sequences is nitty gritty and very easy to get wrong. I am after a library that includes an abstraction for reading escaped sequences preferrably as instances of some nice type. It would be nice if the library offered strongly types rather than everything is a strong and good luck do the stuff yourself. Any pointers to a foss library would be appreciated. A similar question A library to convert ANSI escapes (terminal formatting/color codes) to HTML which seems to have a

How to use ANSI escape codes inside mvwprintw in ncurses?

假装没事ソ 提交于 2019-12-17 16:49:24
问题 Is there a way to use ANSI escape codes inside mvwprintw ? mvwprintw(window, 0, 0,"%c[%dmCOLORED_TEXT!\n", 0x1B, 32);//doesn't work even though: printf("%c[%dmCOLORED_TEXT\n", 0x1B, 32); //works This would be for cases where using wattron / wattroff is not convenient; for example, when redirecting output from stdout of a process that outputs such escape codes. 回答1: No. The only way to make that work would be to parse the string yourself, turning escape codes back into the appropriate curses

Is there a simple way to get rid of junk values that come when you SSH using Python's Paramiko library and fetch output from CLI of a remote machine?

早过忘川 提交于 2019-12-17 02:24:32
问题 I am using Python's Paramiko library to SSH a remote machine and fetch some output from command-line. I see a lot of junk printing along with the actual output. How to get rid of this? chan1.send("ls\n") output = chan1.recv(1024).decode("utf-8") print(output) [u'Last login: Wed Oct 21 18:08:53 2015 from 172.16.200.77\r', u'\x1b[2J\x1b[1;1H[local]cli@BENU>enable', u'[local]cli@BENU#Configure', I want to eliminate, [2J\x1b[1;1H and u from the output. They are junk. 回答1: It's not a junk. These

buggy ANSI escape sequences in R prompt

微笑、不失礼 提交于 2019-12-14 02:35:38
问题 When R is run interactively in a terminal which supports colors, it is possible to use ANSI escape sequences in order to put colors in the prompt, such as options(prompt = "\033[0;31mThis is red\033[0m> ") Unfortunately, something goes wrong because for long command lines, the line continuation override the prompt instead of being written in the next line. The problem gets worse when using several colors, because somehow each escape sequence "takes up some space" in the command line, up to

Color termcaps Konsole?

久未见 提交于 2019-12-13 04:54:19
问题 I've got a problem with ANSI escape codes in my terminal on OpenSuse 13.2. My Makefile use to display pretty colors on OSX at work but at home when I use it I get the litteral termcaps such as \033[1;30m ... \033[0m I know close to nothing about termcaps, I just found these escape characters that seemed to be working fine ! The strangest is that both my OSX and Linux terminal are configured with TERM=xterm-256color so I really don't know where to look for the correct setting I'm currently

Best Ansi Escape beginning

倾然丶 夕夏残阳落幕 提交于 2019-12-13 01:19:34
问题 Which Ansi escape sequence is the most portable and/or simply best and why? 1. "\u001B[32;1mThis is bright green\u001B[0m" 2. "\x1B[33;1mThis is bright yellow\x1B[0m" 3. "\e[35;4;1mThis is bright purple underlined\e[0m" I have been using printf "\x1B[32;1mgreen\x1B[0m" (that's an example in unix bash script for example) out of habit, but I was wondering if there were any reasons to use one over the other. Is one more portable than the others? That would be my assumption. Also, if you know of

Want to use double quote inside a double quote

有些话、适合烂在心里 提交于 2019-12-12 20:26:37
问题 #!/opt/sfw/bin/expect -- spawn telnet -e ! [lindex $argv 0] expect "<" send "ACT-USER::ABCDEFG:123::\"ABCD\";" Above is not working giving error due to double quote inside a double quote Error: spawn telnet -e ! Telnet escape character is '!'. invalid flags send: spawn id exp7 not open while executing "send "ACT-USER::ABCDEFG:123::'\"ABCD\"';"" (file "./get-amp-pms.sh" line 4) 回答1: Use curly braces instead of the double quotes for the send, as follows: send {ACT-USER::ABCDEFG:123::"ABCD";}

Want to resize terminal windows in python, working but not quite right

拟墨画扇 提交于 2019-12-12 13:34:25
问题 I'm attempted to resize the terminal window on launch of a python script to ensure the display will be static size. It's working but not quite what I expected. I've tried a few methods: import sys sys.stdout.write("\x1b[8;40;120t") and import subprocess subprocess.call(["echo","-e","\x1b[8;40;120t"]) and even just print "\x1b[8;40;80t" They all work and resize the real terminal. However, if my terminal is, let's say 25x80 to start, the script starts, it resizes, then exits. It will not