GNU Screen doesnt show colors or ascii full block - linux

I`ve codet a simple cli app. This app uses ansi codes like \x1B[48;2;190;190;0m for color. In addition it uses ascii full block (█) to display qr-codes.
When I run my application in the normal linux bash it all works just fine, but if I run it into a gnu screen no colors are showing up and instead of an qr-code I only see many blank lines.
What am I missing ?

Related

About QT5 Qprocess output in Ubuntu

I use QT to call external programs under Ubuntu and put the output on textbrowser. However, because the external programs I want to call have colors in the shell output, the output of textbrowser is mixed with color codes. How can I remove them?
enter image description here
enter image description here
Normally programs perform check if output is tty (terminal) and only output text with colors if it is. Do you have escape codes when you redirect output to file?
To strip color codes from terminal you can use regular expression. Check answers to this question: Removing colors from output
In SWI-Prolog Qt console I wrote this class for matching ANSI coloring sequences that must be cleaned. I replace them with the appropriate QTextCharFormat commands, you can work out something similar, replacing instead with empty strings or the CSS styling as required by your application.
Inside the source (both ansi_esc_seq.h and ansi_esc_seq.cpp) you also find a bit of documentation about the ANSI escape sequences behaviour.

Python ANSI Color Codes

Python 3.7, on Windows print does not work as expected for ANSI color codes until shell=True once in subprocess.call().
In the below links it appears to imply that the ANSI color codes should work using the "print" command out of the box.
How to print colour/color in python?
Print in terminal with colors using Python?
the second one mentions VT100 emulation... not sure what exactly that means. I am able to write a batch file that outputs the color fine so I would think (naively) that it should work the same way in Python.
However I am not able to use the ANSI color codes as it seems that the ESC character is being "commented out"(?) because for instance when I
print(u"\u001b[31mHelloWorld")
I am not able to see the colored output, as the ESC character seems to be necessary in Windows and prints in the python shell as "[?]" (a box with a question mark)
Is there something I am missing here?
I found myself an answer. As often happens I just did not look far enough.
the Colorama module can be installed with
py -m pip install colorama
and comes with a method definition at the root of the module called init
colorama.init()
This is a cross platform function in that it is only useful on windows (it saves the active Terminal state for reversal and writes the Terminal to preprocess ANSI codes), it does nothing for other operating systems.
I am thinking about implementing an even more lightweight solution using ctypes and setting the Interpret flags on the active terminal myself.
If you are interested in more information, see here:
https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
Output Sequences
The following terminal sequences are intercepted by the console host when written into the output stream, if the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is set on the screen buffer handle using the SetConsoleMode flag. Note that the DISABLE_NEWLINE_AUTO_RETURN flag may also be useful in emulating the cursor positioning and scrolling behavior of other terminal emulators in relation to characters written to the final column in any row.
Emphasis mine.

linux console how to change the codepage to dos cp437

I want to view some ansi-art on the linux local-console. (my setup:raspberry pi3 / newest raspbian - no x11)
i've tried many different settings in raspi-config, dpkg-reconfigure console-setup, /etc files, environment vars but i had no luck yet. do i need a special pcf font to get it working?
a reliable way to enable it for remote terminals would also be great.
thanks in advance
It depends on what your data uses (see chart). Codes 0..31 are a problem unless you have a program that can map those codes to a printable value (as noted in Why does showconsolefont have different output in tmux?, the showconsolefont program does this mapping of 0..31).
Most of the usable fonts for the Linux console are "psf" fonts: having a header which tells which Unicode values each glyph corresponds to. Using that, along with a known character set (cp437), you could convert the data or "play" it using an application which knows how to do this:
You could convert it using iconv or recode, or
The line-drawing (128..255) could be done using luit in a UTF-8 console.

Unicode and 256 colors in Raspberry Pi Terminal Environment

I'm working with a bunch of Raspberry Pi 2s running Raspbian, building interactive puzzles for a performance installation. The puzzles are meant to be played on the command line. My background is in web development, so while I'm very comfortable on the Linux command line, I don't have a lot of experience tailoring a local terminal environment. I have a number of distinct requirements and I can never quite fulfill all of them at once. Namely:
I would like the game to be loaded from the kernel console, without starting LXDE. This is mostly because in a terminal environment, I can catch any keystrokes that someone would use to try to exit the game, and put a password up to prevent it. Also, I have not yet determined whether I could start a terminal window in LXDE and hide all the windowing chrome to make the game appear to be CLI only.
I need 256 color display.
The game is played in English, but contains some Cyrillic characters, so I need unicode support. A sample of the characters used:
0x1440
0x1437
0x143d
I can get the 256 color display in xterm using TERM=xterm-256color, but ONLY if I launch it in a window in LXDE. Same goes for Unicode support. When I try starting xterm from the kernel console, I can pass a number of options to customize the display of the terminal (-fg, -bg, -fa), but can't make it display 256 colors or unicode characters. I've tried using a .Xresource file and loading it with xrdb -merge ~/.Xresource, but it doesn't seem to have any effect at all. Currently, I have a .xinitrc file that contains
`which xterm` \
-fg white \
-bg black \
-fa *-fixed-*-*-*-18-*
-en en_US.UTF-8
-tn xterm-256color
and I launch xterm by simply running xinit. When I do so, xterm starts and respects the foreground, background, and font properties, but only displays 8 colors and won't display unicode characters. Can anyone offer any insight for how to meet all three of my requirements above? I would also accept an answer that shows how I can simply start the game from an LXDE window, but full-screen that window with absolutely no chrome, and prevent the user from being able to exit that environement (there will not be a mouse attached to the machine)
Thanks!
It's a shame, someone posted an answer here and pointed out that I had a typo in the .xinitrc that I posted (missing \ characters after a couple of the lines). After going back and double checking, that did turn out to be part of the problem. He or she or someone else apparently took down the answer though, so I can't give credit.
The other part of the problem was that the unicode characters I'm trying to display are not Cyrillic, but are rather part of the Unified Canadian Aboriginal Syllabics block, which simply wasn't part of any of the terminal fonts I was using. After some digging, I found what appears to be the only monospaced font that contains these characters, Everson Mono. I installed that to /usr/local/share/fonts, and amended my .xinitrc file thusly:
`which xterm` \
-fg white \
-bg black \
-fa 'Everson Mono' \
-en en_US.UTF-8 \
-tn xterm-256color
...and now I can load xterm with xinit and run my app and all is right with the world.

Changing one word's color in Linux terminal/Putty?

Do you think there is a way of changing a specific word's color on the Linux terminal or on Putty?
I'm using the "make" command though terminal (and putty sometimes), and I just thought of how nice it would be if among all the warnings, the printed line containing the "error:" would be in red/marked somehow.
It doesn't really matter, because I guess the solution would be somehow terminal recognizing a specific word related, but just for clarafication - I'm compiling a makefile of C/Assembly code.
There is off course the solution of not printing the warnings at all, but I want to see the warnings.
Thanks,
Barak.
See the ANSI terminal escape sequences. Most terminals implement them.
For example, to display a word in red:
The word at the end is in <Esc>[31m red <Esc>[30m .
I have inserted some spaces for clarity, which should be removed.
Unfortunately, this assumes that the foreground color is initially black. If the text is originally white on a black background, this will make subsequent text seem to disappear. (I say seem because it is there and can be viewed by selecting the text.)

Resources