Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-06

text color problems under linux w/ocrt

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alex Dingle

In the process of porting an old DOS game to linux using fpc, I'm having some trouble getting the textcolor(0)/textbackground(0) and textcolor(8)/textbackground(0) color combinations to display properly using ocrt and ncrt. textcolor(0)/textbackground(0) displays as white text on a black background (the same as
textcolor(7)/textbackground(0)), and textcolor(8)/textcolor(0) displays as bright white text on a black background. (the same as textcolor(15)/textbackground(0))

Interestingly enough, these combinations work as expected when using the regular crt module.

I suspect this might be happenning because these color combinations are being mapped to ncurses color pair 0 (with and without the bold attribute), and in ncurses color pair 0 can't be modified via the init_pair function. Ncurses provides an additional function, assume_default_colors, which can be used to modify color pair 0. However, it seems that no wrapper for this function is provided in the fpc ncurses package. Is there a good reason for this? Any suggestions for a workaround to this problem?

Thanks.

-Alex

Stephen Hurd
to Alex Dingle
Show quoted text 20 lines
In the process of porting an old DOS game to linux using fpc, I'm having some trouble getting the textcolor(0)/textbackground(0) and textcolor(8)/textbackground(0) color combinations to display properly using ocrt and ncrt. textcolor(0)/textbackground(0) displays as white text on a black background (the same as textcolor(7)/textbackground(0)), and textcolor(8)/textcolor(0) displays as bright white text on a black background. (the same as textcolor(15)/textbackground(0)) Interestingly enough, these combinations work as expected when using the regular crt module. I suspect this might be happenning because these color combinations are being mapped to ncurses color pair 0 (with and without the bold attribute), and in ncurses color pair 0 can't be modified via the init_pair function. Ncurses provides an additional function, assume_default_colors, which can be used to modify color pair 0. However, it seems that no wrapper for this function is provided in the fpc ncurses package. Is there a good reason for this? Any suggestions for a workaround to this problem?

I submitted a patch to the ncrt/ocrt guy a bit ago... my *crt unit is now heavily modifed and does not work as documented or I would send you it...

In ncrt.inc:

After the lines

   { load the color pairs array with color pair indices (0..63 }
   For bg := 0 to 7 Do For fg := 0 to 7 do cp[bg,fg] := (bg*8)+fg;

Add:

   { Set color 0 to black on black (Also used for dark grey }
   cp[COLOR_BLACK,COLOR_BLACK]:=7;
   cp[COLOR_BLACK,COLOR_WHITE]:=0;

I think that was all that was required for the colour fixes.