dankamongmen / notcurses

blingful character graphics/TUI library. definitely not curses.
https://nick-black.com/dankwiki/index.php/Notcurses
Other
3.58k stars 112 forks source link

add default fg/bg lookup handling to linux console #2499

Open dankamongmen opened 2 years ago

dankamongmen commented 2 years ago

The Linux console doesn't support looking up default background/foreground, which can be changed (try e.g. printf %b '\e[41m' '\e[8]' '\e[H\e[J'). It's not safe to just rely on 0xfffff foreground and 0x000000 background. Add handling for the default fg/bg lookups to the Linux console code.

dankamongmen commented 2 years ago

https://lkml.org/lkml/2022/1/14/50 fixes some formatting on console_codes(4), yummmy groff

dankamongmen commented 2 years ago

so we have

// query background, replies in X color https://www.x.org/releases/X11R7.7/doc/man/man7/X.7.xhtml#heading11                         
// GNU screen passes this on to the underlying terminal rather than answering itself,                                               
// unlike most other queries, so send this first since it will take longer to be                                                    
// answered. note the "\x1b]"; this is an Operating System Command, not CSI.                                                        
#define DEFBGQ "\x1b]11;?\e\\"                                                                                                      
#define DEFFGQ "\x1b]10;?\e\\"                                                                                                      
dankamongmen commented 2 years ago

so a few details:

to get a different default background color, you use the linux private CSI sequence:

ESC [ 8 ] Make the current color pair the default attributes.

dankamongmen commented 2 years ago

works perfectly. notcurses-info reports:

notcurses 3.0.4 on FBcon 5.16.0nlb (Linux 5.16.0nlb)
48 rows (16px) 128 cols (8px) 768x1024 8 colors
gcc-11.2.0 (LE)
terminfo 6.3.20211021 libdeflate 1.8 GPM n/a
avformat 59.10.100 avutil 57.13.100 swscale 6.1.102 avcodec 59.15.100
default fg 0xaaaaaa default bg 0x000000

i then ran printf %b '\e[46m' '\e[8]' '\e[H\e[J (or some other color)

notcurses 3.0.4 on FBcon 5.16.0nlb (Linux 5.16.0nlb)
48 rows (16px) 128 cols (8px) 768x1024 8 colors                                                                           
gcc-11.2.0 (LE)                                                                                                                 
terminfo 6.3.20211021 libdeflate 1.8 GPM n/a                                                                                    
avformat 59.10.100 avutil 57.13.100 swscale 6.1.102 avcodec 59.15.100   
default fg 0xaaaaaa default bg 0xaa5500 

yay!

dankamongmen commented 2 years ago

https://lkml.org/lkml/2022/1/14/413

the rest is in god's hands

dankamongmen commented 2 years ago

sent v2 of this patch just now

https://lkml.org/lkml/2022/1/24/16