Message348855
curses.addch() ignores color information if I pass it a string of length one. Color works fine if I pass it a byte string or an int. Here's a reproducer:
### start of example ###
import curses
def main(stdscr):
curses.start_color()
curses.use_default_colors()
curses.init_pair(1, curses.COLOR_RED, -1)
curses.init_pair(2, curses.COLOR_GREEN, -1)
curses.curs_set(0)
stdscr.addch("a", curses.color_pair(1))
stdscr.addch("b", curses.color_pair(2) | curses.A_BOLD)
stdscr.addch(b"c", curses.color_pair(1))
stdscr.addch(b"d", curses.color_pair(2) | curses.A_BOLD)
stdscr.addch(ord("e"), curses.color_pair(1))
stdscr.addch(ord("f"), curses.color_pair(2) | curses.A_BOLD)
stdscr.refresh()
stdscr.getch()
curses.wrapper(main)
### end of example ###
On Python 2.7 this prints 'abcdef' in alternating red and green. On Python 3.5 through 3.8 this prints 'ab' in white and the rest in red/green.
Note that only color pair information is lost -- the bold attribute is correctly set on the 'b'. |
|
Date |
User |
Action |
Args |
2019-08-01 13:45:15 | mgedmin | set | recipients:
+ mgedmin |
2019-08-01 13:45:15 | mgedmin | set | messageid: <1564667115.2.0.875397124654.issue37738@roundup.psfhosted.org> |
2019-08-01 13:45:15 | mgedmin | link | issue37738 messages |
2019-08-01 13:45:14 | mgedmin | create | |
|