简体   繁体   中英

Ncurses C++ print text with foreground/background colors swapped

I would like to be able to print text with foreground/background colors swapped, like for example, the top bar in nano . But I want to use the default terminal colors. I am already calling use_default_colors() . Calling pair_content(0, &c1, &c2) just gives me c1=-1, c2=-1 , so I don't have any values to pass in to init_pair() , since -1 means both default foreground and background color. How can I swap those colors in another color pair, or how can I get default foreground/background color rgb values so I can reinitialize some colors to be the default terminal foreground and background colors?

short: color pairs don't do that.

longer: you could apply the attribute for reverse-video A_REVERSE , but it's not a color. It gets passed around as easily as color pairs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM