Skip Menu |

This queue is for tickets about the Curses-UI CPAN distribution.

Report information
The Basics
Id: 50142
Status: open
Priority: 0/
Queue: Curses-UI

People
Owner: Nobody in particular
Requestors: mikevs [...] xs4all.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Curses::UI and background color [PATCH] [WORKAROUND]
Date: Thu, 1 Oct 2009 14:29:13 +0200
To: bug-Curses-UI [...] rt.cpan.org
From: Miquel van Smoorenburg <mikevs [...] xs4all.net>
I implemented a simple test application with Curses::UI and color, and I noticed that the background color in a window is not set correctly if it is not initialized (i.e. if nothing is drawn on it by the application or a widget). This is also true for the main Curses::UI window, the background is not initialized. You can see the same thing happening with the sample color_editor application. I've tested this on the linux console, in an xterm, and in gnome-terminal. I'm using Curses::UI 0.9605 as found in debian and ubuntu. It took me a whole lot of searching, but I finally found the root cause: a missing bkgdset(). With this, I created a workaround that can be used in scripts that use Curses::UI Include the fixupbg() function below in you script and call it every time a curses window is initialized. sub fixupbg { my $win = shift; return if (!$Curses::UI::color_support); my $co = $Curses::UI::color_object; foreach my $object ($win, values %{$win->{-id2object}}) { my $scr = defined $object->{-borderscr} ? $object->{-borderscr} : $object->{-canvasscr}; next unless defined $scr; my $pair = $co->get_color_pair($object->{-fg}, $object->{-bg}); $scr->bkgdset(COLOR_PAIR($pair) | 32); } } Use it like this: my $cui = new Curses::UI( -color_support => 1, -fg => 'black', -bg => 'white' ); fixupbg($cui); my $dialog = $cui->add( ... ); fixupbg($dialog); I've also fixed Curses::UI itself, which makes the above workaround unnecessary. Curses::UI needs to call bkgdset() internally after a curses window is initialized. I've attached a patch that does this in the draw() method. It is a bit of overkill since it's probably only necessary once, but otherwise the patch would become more complicated - you'd need to call bkgdset every time -bg is updated, for example in all set_color_bg() functions, UI::set_color, etc. Perhaps the maintainer can fix it the 'right' way eventually. --- Widget.pm.ORIG 2008-03-03 06:30:35.000000000 +0100 +++ Widget.pm 2009-04-27 12:53:54.000000000 +0200 @@ -537,6 +537,12 @@ ? $this->{-borderscr} : $this->{-canvasscr}; return unless defined $scr; + + if ($Curses::UI::color_support) { + my $co = $Curses::UI::color_object; + my $pair = $co->get_color_pair( $this->{-fg}, $this->{-bg} ); + $scr->bkgdset(COLOR_PAIR($pair) | 32) if ($pair); + } $scr->erase; $scr->noutrefresh(); Mike.
Subject: [rt.cpan.org #50142]
Date: Wed, 4 Mar 2015 23:07:08 +0100
To: bug-Curses-UI [...] rt.cpan.org
From: Andreas Steinel <a.steinel [...] gmail.com>
Seams to be fixed in upstream. Bug can be closed, shouldn't it?
Subject: Re: [rt.cpan.org #50142]
Date: Thu, 05 Mar 2015 00:20:51 +0100
To: bug-Curses-UI [...] rt.cpan.org
From: Miquel van Smoorenburg <mikevs [...] xs4all.net>
On 04/03/15 23:07, Andreas Steinel via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=50142 > > > Seams to be fixed in upstream. Bug can be closed, shouldn't it?
I just checked - looks like it is fixed, indeed. Please close this bug. Thank you, Mike.