[fpc-pascal]text color problems under linux w/ocrt

Stephen Hurd shurd at sasktel.net
Tue Jul 1 03:00:49 CEST 2003


On Mon, 30 Jun 2003 19:32:42 -0400
Alex Dingle <adingle at crud.net> wrote:

> 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.




More information about the fpc-pascal mailing list