My question & current states:
I'm writing TUI software that is on fbterm
using python-curses
library.
- My objective here is to get some colors, most importantly PURE WHITE color.
- My current state: Instead of white, I'm getting somewhat gray color (not full brightness).
- Or If get white full brightness, I got my boxes (rectangles) get scrambled up
How I set color in python-curses:
I initialed color pair as below (documentation here), & used this pair of color all over my code:
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
It's not full white, I've seen full white in this display.
My guess what is happening:
Note: if you examined the black white values, those are 0 7 respectively.
>>> import curses
>>> print(curses.COLOR_BLACK, curses.COLOR_WHITE)
0 7
And when list out the available color on fbterm with for i in {0..255}; do echo -ne "\E[2;$i}$i "; done; tput sgr0; echo
(read from this thread or just see the image). 0=black, 7=gray, 15=white
So, when my python is trying to send a white color (python-curses
thinks white is 7) and gives to fbterm
. fbterm
receives 7 and thinks it is gray.
What things I've tried so far:
1st-Try. set my white in color pair to 15:
My rationale: If python-curses
send 15 to fbterm
, it might think it is a white.
curses.init_pair(1, curses.COLOR_BLACK, 15)
with this I come to following 2 results:
- if executed within
fbterm
, it get err:_curses.error: init_pair() returned ERR
- if executed from my laptop (
ssh
-ed), Software is working and white is more WHITE.
My guess on 1st try:
These 2 different outputs, might be caused different environmental variables:
- my laptop (on
lxterminal
):$TERM
isxterm-256color
- on the device (on
fbterm
):$TERM
islinux
2nd-Try. set TERM
variable to fbterm
My rationale: fbterm
didn't set correct env variables -> can't use 256 colors. (below is from man page):
... By default, FbTerm sets environment variable "TERM" to value "linux", user need run "TERM=fbterm /path/to/program" to enable 256 color mode.
So I set manually executed TERM=fbterm
(or TERM=fbterm python3 main.py
), and executed my python code.
It shows full-bright white color, but texts are all scrambled:
ÚÄÄÄÄÄ¿
³Meas.³
ÀÄÄÄÄÄÙ ÚÄÄÄÄÄÄÄÄÄÄÄÄ¿ÚÄÄÄÄÄÄÄÄÄÄÄÄ¿
ÚÄÄÄÄÄ¿ ³1-shot ³³n-shot ³
³Setup³ ³ ³³ ³
ÀÄÄÄÄÄÙ ³ ³³ ³
ÚÄÄÄÄÄ¿ ³ ³³ ³
³Data ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÙÀÄÄÄÄÄÄÄÄÄÄÄÄÙ
ÀÄÄÄÄÄÙ
ÚÄÄÄÄÄ¿
³About³ ÚÄÄÄÄÄÄÄÄÄÄÄÄ¿ÚÄÄÄÄÄÄÄÄÄÄÄÄ¿
ÀÄÄÄÄÄÙ ³Target ³³Weather ³
ÚÄÄÄÄÄ¿ ³ ³³ ³
³Sys. ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÙÀÄÄÄÄÄÄÄÄÄÄÄÄÙ
ÀÄÄÄÄÄÙ
My guess on 2nd-try: NO IDEA
It seems characters like |
-
(and 90 deg thingy) for drawing boxes are scrambled, but the actual text-strings are OK.
/ps: these rectangles were drawn by window.box()
which it self generated by curses.newwin()
/
Can you help me to get color here? without scrambling my text?.
What Should I try next?
/P.S Reason of trying get PURE WHITE: is to increase contrast to black color parts for visibility. (the device (which is handheld) is going to be used in daylight/outside). Also, tips for better visibility are welcome. Thank you. /
Can you help me to get color here? without scrambling my text?.
According to its documentation, fbterm supports a variant of xterm's 256-color extension:
With the xterm 256-color palette, your pure white is color number 15:
ncurses provides a terminal description for
fbterm
, which you may find in the complete terminal database, e.g., "ncurses-term".Neither "linux" (with 8 colors) nor "xterm-256color" (different escape sequences needed for both color and line-drawing) will work for fbterm. Use infocmp to show the differences.