curses icon indicating copy to clipboard operation
curses copied to clipboard

Use NUM2CHTYPE()/CHTYPE2NUM() in window_attron/attroff/attrset/color_pair?

Open bashirley opened this issue 2 years ago • 0 comments

Hi, on mingw Ruby26-x64, on Windows 7, using curses-1.4.4 and the statically-linked default PDCurses, attron(color_pair(n)) doesn't have any effect, and I only get the default gray-on-black, from this example:

require 'curses'
include Curses
init_screen
start_color
init_pair(6, COLOR_BLUE, COLOR_RED)
attron(color_pair(6)) do
  setpos(5,5)
  addstr('this should be in blue on red')
end
getch
close_screen

It looks like PDCurses is compiled in 64-bit chtype mode by default, and the color bits are shifting off the end of a regular 32-bit long and getting truncated in window_attron(), window_attroff(), window_attrset(), and curses_color_pair() by the INT2FIX()/NUM2INT() macros.

Replacing these macros with NUM2CHTYPE() and CHTYPE2NUM() in the color/attr functions seems to resolve the problem and the example above works as expected.

bashirley avatar Aug 28 '22 17:08 bashirley