head 1.18; access; symbols OPENPKG_E1_MP_HEAD:1.13 OPENPKG_E1_MP:1.13 OPENPKG_E1_MP_2_STABLE:1.13 OPENPKG_E1_FP:1.13 OPENPKG_2_STABLE_20061018:1.13 OPENPKG_2_STABLE:1.13.0.12 OPENPKG_2_STABLE_BP:1.13 OPENPKG_2_5_SOLID:1.13.0.10 OPENPKG_2_5_SOLID_BP:1.13 OPENPKG_2_4_RELEASE:1.13 OPENPKG_2_4_SOLID:1.13.0.8 OPENPKG_2_4_SOLID_BP:1.13 OPENPKG_2_3_RELEASE:1.13 OPENPKG_2_3_SOLID:1.13.0.6 OPENPKG_2_3_SOLID_BP:1.13 OPENPKG_2_2_RELEASE:1.13 OPENPKG_2_2_SOLID:1.13.0.4 OPENPKG_2_2_SOLID_BP:1.13 OPENPKG_2_1_RELEASE:1.13 OPENPKG_2_1_SOLID:1.13.0.2 OPENPKG_2_1_SOLID_BP:1.13 OPENPKG_2_0_RELEASE:1.12.2.1 OPENPKG_2_0_SOLID:1.12.0.2 OPENPKG_2_0_SOLID_BP:1.12 OPENPKG_1_3_RELEASE:1.4.2.1 OPENPKG_1_3_SOLID:1.4.2.1.0.2 OPENPKG_1_3_SOLID_BP:1.4.2.1 OPENPKG_1_STABLE_MP:1.9 OPENPKG_1_2_RELEASE:1.4 OPENPKG_1_2_SOLID:1.4.0.4 OPENPKG_1_2_SOLID_BP:1.4 OPENPKG_1_STABLE:1.4.0.2 OPENPKG_1_STABLE_BP:1.4; locks; strict; comment @# @; 1.18 date 2008.12.28.09.29.22; author rse; state dead; branches; next 1.17; commitid yrCFIY4YZlhrodwt; 1.17 date 2008.07.05.08.07.46; author rse; state Exp; branches; next 1.16; commitid 8b7ulJB51qacBA9t; 1.16 date 2008.07.04.07.56.54; author rse; state Exp; branches; next 1.15; commitid 2uvIbbMbob6tzs9t; 1.15 date 2008.03.11.20.01.50; author rse; state Exp; branches; next 1.14; commitid WDKZhQt5PxdkhKUs; 1.14 date 2008.03.03.06.51.53; author rse; state Exp; branches; next 1.13; commitid OCrqwjFXeHPgaETs; 1.13 date 2004.02.20.07.56.47; author rse; state dead; branches; next 1.12; 1.12 date 2003.10.16.17.56.12; author rse; state Exp; branches 1.12.2.1; next 1.11; 1.11 date 2003.10.09.18.15.20; author rse; state Exp; branches; next 1.10; 1.10 date 2003.09.01.07.41.30; author rse; state Exp; branches; next 1.9; 1.9 date 2003.04.27.18.46.07; author rse; state Exp; branches; next 1.8; 1.8 date 2003.04.21.08.58.39; author rse; state Exp; branches; next 1.7; 1.7 date 2003.04.14.10.19.10; author rse; state Exp; branches; next 1.6; 1.6 date 2003.03.29.11.11.06; author rse; state Exp; branches; next 1.5; 1.5 date 2003.03.28.08.30.29; author rse; state Exp; branches; next 1.4; 1.4 date 2002.11.25.15.18.00; author thl; state Exp; branches 1.4.2.1; next 1.3; 1.3 date 2002.11.21.20.46.16; author rse; state Exp; branches; next 1.2; 1.2 date 2002.11.21.20.18.30; author rse; state Exp; branches; next 1.1; 1.1 date 2002.11.20.15.52.48; author rse; state Exp; branches; next ; 1.12.2.1 date 2004.02.22.08.55.33; author rse; state dead; branches; next ; 1.4.2.1 date 2003.07.24.20.44.43; author rse; state Exp; branches; next ; desc @@ 1.18 log @modifying package: perl-curses-5.10.0 20080910 -> 20081228 @ text @Index: Curses-UI-0.9605/Makefile.PL --- Curses-UI-0.9605/Makefile.PL.orig 2008-03-02 05:25:42 +0100 +++ Curses-UI-0.9605/Makefile.PL 2008-03-03 07:46:44 +0100 @@@@ -8,8 +8,8 @@@@ # Specific dependencies requires 'Curses' => 0; requires 'Term::ReadKey' => 0; -build_requires 'Test::More' => 0; -build_requires 'Test::Pod' => 0; +#build_requires 'Test::More' => 0; +#build_requires 'Test::Pod' => 0; no_index 'directory' => 'examples'; @ 1.17 log @modifying package: perl-curses-5.10.0 20080704 -> 20080705 @ text @@ 1.16 log @modifying package: perl-curses-5.10.0 20080311 -> 20080704 @ text @d1 3 a3 3 Index: Curses-UI-0.9604/Makefile.PL --- Curses-UI-0.9604/Makefile.PL.orig 2008-03-02 05:25:42 +0100 +++ Curses-UI-0.9604/Makefile.PL 2008-03-03 07:46:44 +0100 @ 1.15 log @modifying package: perl-curses-5.10.0 20080310 -> 20080311 @ text @d1 3 a3 3 Index: Curses-UI-0.9603/Makefile.PL --- Curses-UI-0.9603/Makefile.PL.orig 2008-03-02 05:25:42 +0100 +++ Curses-UI-0.9603/Makefile.PL 2008-03-03 07:46:44 +0100 @ 1.14 log @modifying package: perl-curses-5.10.0 20080229 -> 20080303 @ text @d1 3 a3 3 Index: Curses-UI-0.9602/Makefile.PL --- Curses-UI-0.9602/Makefile.PL.orig 2008-03-02 05:25:42 +0100 +++ Curses-UI-0.9602/Makefile.PL 2008-03-03 07:46:44 +0100 @ 1.13 log @modifying package: perl-curses-5.8.3 20040218 -> 20040220 @ text @d1 11 a11 57 Index: CHANGES.RSE =================================================================== RCS file: CHANGES.RSE diff -N CHANGES.RSE --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ CHANGES.RSE 16 Oct 2003 17:52:29 -0000 1.8 @@@@ -0,0 +1,25 @@@@ + + The following changes were made by Ralf S. Engelschall + to the excellent Curses::UI by Maurice Makaay . + + o Make sure that Curses::UI::Listbox draws the selected values in bold + also under "multi" and "radio" options to be consistent in look & + feel with the standard list box. + + o Add support for root->overlapping(1) (default) and + root->overlapping(0) to optimize the redrawing by reducing to + the old and new focused widgets. The default is still to redraw + everything which is necessary to support overlapping windows. + + o Add -reverse option to Curses::UI::TextEditor. + + o Fix reverse rendering for Label demo in demo-widgets. + + o Add -htmltext option to Curses::UI::Widget, corresponding + text_chop(), text_length() and text_draw() functions to + Curses::UI::Common and used the stuff in Curses::UI::Listbox + to allow in-line markup. + + o Fix top-level DESTROY (destructor) function to correctly + shutdown Curses and allow re-initializations. + Index: lib/Curses/UI.pm =================================================================== RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI.pm,v retrieving revision 1.1.1.7 retrieving revision 1.11 diff -u -d -u -d -r1.1.1.7 -r1.11 --- lib/Curses/UI.pm 16 Oct 2003 17:51:37 -0000 1.1.1.7 +++ lib/Curses/UI.pm 16 Oct 2003 17:52:30 -0000 1.11 @@@@ -70,6 +70,7 @@@@ -debug => undef, # Turn on debugging mode? -language => undef, # Which language to use? -mouse_support => 1, # Do we want mouse support + -overlapping => 1, # Whether overlapping widgets are supported -color_support => 0, -default_colors=> 1, #user data @@@@ -114,8 +115,11 @@@@ DESTROY { my $this = shift; + my $scr = $this->{-canvasscr}; + $scr->delwin() if (defined($scr)); endwin(); $Curses::UI::rootobject = undef; + $Curses::UI::initialized = 0; d13 1 a13 331 if ($this->{-clear_on_exit}) { @@@@ -135,6 +139,7 @@@@ sub clear_on_exit(;$) { shift()->accessor('-clear_on_exit', shift()) } sub cursor_mode(;$) { shift()->accessor('-cursor_mode', shift()) } sub lang(;$) { shift()->accessor('-language_object', shift()) } +sub overlapping(;$) { shift()->accessor('-overlapping', shift()) } # TODO: document sub debug(;$) Index: lib/Curses/UI/Common.pm =================================================================== RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Common.pm,v retrieving revision 1.1.1.3 retrieving revision 1.3 diff -u -d -u -d -r1.1.1.3 -r1.3 --- lib/Curses/UI/Common.pm 9 Oct 2003 18:09:43 -0000 1.1.1.3 +++ lib/Curses/UI/Common.pm 9 Oct 2003 18:10:02 -0000 1.3 @@@@ -35,6 +35,9 @@@@ @@EXPORT = qw( keys_to_lowercase text_wrap + text_draw + text_length + text_chop scrlength split_to_lines text_dimension @@@@ -213,6 +216,125 @@@@ } return \@@wrapped; +} + +sub text_tokenize { + my ($text) = @@_; + + my @@tokens = (); + while ($text ne '') { + if ($text =~ m/^<\/?[a-zA-Z0-9_]+>/s) { + push(@@tokens, $&); + $text = $'; + } + elsif ($text =~ m/^.+?(?=<\/?[a-zA-Z0-9_]+>)/s) { + push(@@tokens, $&); + $text = $'; + } + else { + push(@@tokens, $text); + last; + } + } + return @@tokens; +} + +sub text_draw($$;) +{ + my $this = shift; + my ($y, $x, $text) = @@_; + + if ($this->{-htmltext}) { + my @@tokens = &text_tokenize($text); + foreach my $token (@@tokens) { + if ($token =~ m/^<(standout|reverse|bold|underline|blink|dim)>$/s) { + my $type = $1; + if ($type eq 'standout') { $this->{-canvasscr}->attron(A_STANDOUT); } + elsif ($type eq 'reverse') { $this->{-canvasscr}->attron(A_REVERSE); } + elsif ($type eq 'bold') { $this->{-canvasscr}->attron(A_BOLD); } + elsif ($type eq 'underline') { $this->{-canvasscr}->attron(A_UNDERLINE); } + elsif ($type eq 'blink') { $this->{-canvasscr}->attron(A_BLINK); } + elsif ($type eq 'dim') { $this->{-canvasscr}->attron(A_DIM); } + } + elsif ($token =~ m/^<\/(standout|reverse|bold|underline|blink|dim)>$/s) { + my $type = $1; + if ($type eq 'standout') { $this->{-canvasscr}->attroff(A_STANDOUT); } + elsif ($type eq 'reverse') { $this->{-canvasscr}->attroff(A_REVERSE); } + elsif ($type eq 'bold') { $this->{-canvasscr}->attroff(A_BOLD); } + elsif ($type eq 'underline') { $this->{-canvasscr}->attroff(A_UNDERLINE); } + elsif ($type eq 'blink') { $this->{-canvasscr}->attroff(A_BLINK); } + elsif ($type eq 'dim') { $this->{-canvasscr}->attroff(A_DIM); } + } + else { + $this->{-canvasscr}->addstr($y, $x, $token); + $x += length($token); + } + } + } + else { + $this->{-canvasscr}->addstr($y, $x, $text); + } +} + +sub text_length { + my $this = shift; + my ($text) = @@_; + + my $length = 0; + if ($this->{-htmltext}) { + my @@tokens = &text_tokenize($text); + foreach my $token (@@tokens) { + if ($token !~ m/^<\/?(reverse|bold|underline|blink|dim)>$/s) { + $length += length($token); + } + } + } + else { + $length = length($text); + } + return $length; +} + +sub text_chop { + my $this = shift; + my ($text, $max_length) = @@_; + + if ($this->{-htmltext}) { + my @@open = (); + my @@tokens = &text_tokenize($text); + my $length = 0; + $text = ''; + foreach my $token (@@tokens) { + if ($token =~ m/^<(\/?)(reverse|bold|underline|blink|dim)>/s) { + my ($type, $name) = ($1, $2); + if (defined($type) and $type eq '/') { + pop(@@open); + } + else { + push(@@open, $name); + } + $text .= $token; + } + else { + $text .= $token; + $length += length($token); + if ($length > $max_length) { + $text = substr($text, 0, $max_length); + $text =~ s/.$/\$/; + while (defined($token = pop(@@open))) { + $text .= ""; + } + last; + } + } + } + } + else { + if (length($text) > $max_length) { + $text = substr($text, 0, $max_length); + } + } + return $text; } sub text_dimension ($;) Index: lib/Curses/UI/Label.pm =================================================================== RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Label.pm,v retrieving revision 1.1.1.4 retrieving revision 1.6 diff -u -d -u -d -r1.1.1.4 -r1.6 Index: lib/Curses/UI/Listbox.pm =================================================================== RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Listbox.pm,v retrieving revision 1.1.1.5 retrieving revision 1.7 diff -u -d -u -d -r1.1.1.5 -r1.7 --- lib/Curses/UI/Listbox.pm 9 Oct 2003 18:09:41 -0000 1.1.1.5 +++ lib/Curses/UI/Listbox.pm 9 Oct 2003 18:10:02 -0000 1.7 @@@@ -303,10 +303,7 @@@@ (($this->{-multi} or $this->{-radio}) ? 4 : 0); # Chop length if needed. - if (($prefix_len + length($label)) > $this->canvaswidth) { - $label = substr($label, 0, ($this->canvaswidth-$prefix_len)); - $label =~ s/.$/\$/; - } + $label = $this->text_chop($label, ($this->canvaswidth-$prefix_len)); # Show current entry in reverse mode and # save cursor position. @@@@ -318,10 +315,12 @@@@ } # Show selected element bold. - if (not $this->{-multi} and - not $this->{-radio} and - defined $this->{-selected} and - $this->{-selected} == $i) { + if ( ( not $this->{-multi} + and defined $this->{-selected} + and $this->{-selected} == $i) + or ( $this->{-multi} + and defined $this->{-selected} + and $this->{-selected}->{$i}) ) { $this->{-canvasscr}->attron(A_BOLD); } @@@@ -332,10 +331,7 @@@@ ); # Show label - $this->{-canvasscr}->addstr( - $y, $prefix_len, - $label - ); + $this->text_draw($y, $prefix_len, $label); $this->{-canvasscr}->attroff(A_REVERSE); $this->{-canvasscr}->attroff(A_BOLD); Index: lib/Curses/UI/TextEditor.pm =================================================================== RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/TextEditor.pm,v retrieving revision 1.1.1.6 retrieving revision 1.7 diff -u -d -u -d -r1.1.1.6 -r1.7 --- lib/Curses/UI/TextEditor.pm 16 Oct 2003 17:51:38 -0000 1.1.1.6 +++ lib/Curses/UI/TextEditor.pm 16 Oct 2003 17:51:55 -0000 1.7 @@@@ -151,6 +151,7 @@@@ -vscrollbar => 0, # show vertical scrollbar -hscrollbar => 0, # show horizontal scrollbar -readonly => 0, # only used as viewer? + -reverse => 0, # show in reverse # Single line options -password => undef, # masquerade chars with given char @@@@ -456,9 +457,10 @@@@ # Turn on underlines and fill the screen with lines # if neccessary. - if ($this->{-showlines}) + if ($this->{-showlines} or $this->{-reverse}) { - $this->{-canvasscr}->attron(A_UNDERLINE); + $this->{-canvasscr}->attron(A_UNDERLINE) if ($this->{-showlines});; + $this->{-canvasscr}->attron(A_REVERSE) if ($this->{-reverse}); for my $y (0..$this->canvasheight-1) { $this->{-canvasscr}->addstr($y, 0, " "x($this->canvaswidth)); } @@@@ -480,9 +482,11 @@@@ if (defined $this->{-search_highlight} and $this->{-search_highlight} == ($id+$this->{-yscrpos})) { - $this->{-canvasscr}->attron(A_REVERSE); + $this->{-canvasscr}->attron(A_REVERSE) if (not $this->{-reverse}); + $this->{-canvasscr}->attroff(A_REVERSE) if ($this->{-reverse}); } else { - $this->{-canvasscr}->attroff(A_REVERSE); + $this->{-canvasscr}->attroff(A_REVERSE) if (not $this->{-reverse}); + $this->{-canvasscr}->attron(A_REVERSE) if ($this->{-reverse}); } my $l = $this->{-scr_lines}->[$id + $this->{-yscrpos}]; @@@@ -576,6 +580,7 @@@@ } $this->{-canvasscr}->attroff(A_UNDERLINE) if $this->{-showlines}; + $this->{-canvasscr}->attroff(A_REVERSE) if $this->{-reverse}; $this->{-canvasscr}->noutrefresh(); doupdate() unless $no_doupdate; return $this; Index: lib/Curses/UI/Widget.pm =================================================================== RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Widget.pm,v retrieving revision 1.1.1.6 retrieving revision 1.9 diff -u -d -u -d -r1.1.1.6 -r1.9 --- lib/Curses/UI/Widget.pm 16 Oct 2003 17:51:38 -0000 1.1.1.6 +++ lib/Curses/UI/Widget.pm 16 Oct 2003 17:52:30 -0000 1.9 @@@@ -85,6 +85,7 @@@@ -onblur => undef, # onBlur event handler -intellidraw => 1, # Support intellidraw()? -focusable => 1, # This widget can get focus + -htmltext => 1, # Recognize HTML tags in drawn text #user data -userdata => undef, #user internal data @@@@ -482,7 +483,7 @@@@ my $parent = $this->parent; $parent->focus($this) if defined $parent; - $this->draw(1); + $this->draw(1) if ($this->root->overlapping); return $this; } @@@@ -1017,6 +1018,8 @@@@ my $show_cursor = $this->{-nocursor} ? 0 : 1; $this->root->cursor_mode($show_cursor); + $this->draw(1) if (not $this->root->overlapping); + return $this; } @@@@ -1025,6 +1028,7 @@@@ my $this = shift; $this->{-focus} = 0; $this->run_event('-onblur'); + $this->draw(1) if (not $this->root->overlapping); return $this; } Index: examples/demo-widgets =================================================================== RCS file: /u/rse/wrk/cui/cvs/cui/examples/demo-widgets,v retrieving revision 1.1.1.4 retrieving revision 1.9 diff -u -d -u -d -r1.1.1.4 -r1.9 --- examples/demo-widgets 1 Sep 2003 07:24:37 -0000 1.1.1.4 +++ examples/demo-widgets 16 Oct 2003 17:52:29 -0000 1.9 @@@@ -1,6 +1,11 @@@@ -#!/usr/bin/perl -w +#!/usr/lpkg/bin/perl -w use strict; use File::Temp qw( :POSIX ); +use lib "../lib"; + +# make KEY_BTAB (shift-tab) working in XTerm +# and also at the same time enable colors +#$ENV{TERM} = "xterm-vt220" if ($ENV{TERM} eq 'xterm'); my $debug = 0; if (@@ARGV and $ARGV[0] eq '-d') { @@@@ -150,7 +155,7 @@@@ $w{1}->add(undef,'Label',-text=>"dim font",-y=>5,-dim=>1 ); $w{1}->add(undef,'Label',-text=>"bold font",-y=>7,-bold=>1 ); -$w{1}->add(undef,'Label',-text=>"reversed font",-y=>9,-reversed => 1 ); +$w{1}->add(undef,'Label',-text=>"reversed font",-y=>9,-reverse => 1 ); $w{1}->add(undef,'Label',-text=>"underlined font",-x=>15,-y=>5,-underline=>1 ); $w{1}->add(undef,'Label',-text=>"blinking font",-x=>15,-y=>7,-blink=>1 ); @ 1.12 log @upgrading package: perl-curses 20031009 -> 20031016 @ text @@ 1.12.2.1 log @MFC: upgrade to Curses::UI 0.91 @ text @@ 1.11 log @upgrading package: perl-curses 20030918 -> 20031009 @ text @d6 1 a6 1 +++ CHANGES.RSE 1 Sep 2003 07:33:15 -0000 d36 5 a40 4 retrieving revision 1.1.1.6 diff -u -d -u -d -r1.1.1.6 UI.pm --- lib/Curses/UI.pm 9 Oct 2003 18:09:41 -0000 1.1.1.6 +++ lib/Curses/UI.pm 9 Oct 2003 18:10:11 -0000 d213 6 d271 5 a275 5 retrieving revision 1.1.1.5 retrieving revision 1.6 diff -u -d -u -d -r1.1.1.5 -r1.6 --- lib/Curses/UI/TextEditor.pm 9 Oct 2003 18:09:42 -0000 1.1.1.5 +++ lib/Curses/UI/TextEditor.pm 9 Oct 2003 18:10:02 -0000 1.6 d322 5 a326 4 retrieving revision 1.1.1.5 diff -u -d -u -d -r1.1.1.5 Widget.pm --- lib/Curses/UI/Widget.pm 9 Oct 2003 18:09:42 -0000 1.1.1.5 +++ lib/Curses/UI/Widget.pm 9 Oct 2003 18:10:11 -0000 d365 2 a366 1 diff -u -d -u -d -r1.1.1.4 demo-widgets d368 1 a368 1 +++ examples/demo-widgets 1 Sep 2003 07:36:29 -0000 @ 1.10 log @upgrading package: perl-curses 20030723 -> 20030901 @ text @d36 4 a39 4 retrieving revision 1.1.1.5 diff -u -d -u -d -r1.1.1.5 UI.pm --- lib/Curses/UI.pm 1 Sep 2003 07:24:35 -0000 1.1.1.5 +++ lib/Curses/UI.pm 1 Sep 2003 07:33:38 -0000 d71 5 a75 5 retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -d -u -d -r1.1.1.2 -r1.2 --- lib/Curses/UI/Common.pm 28 Mar 2003 08:22:36 -0000 1.1.1.2 +++ lib/Curses/UI/Common.pm 1 Sep 2003 07:29:04 -0000 1.2 d215 5 a219 5 retrieving revision 1.1.1.4 retrieving revision 1.6 diff -u -d -u -d -r1.1.1.4 -r1.6 --- lib/Curses/UI/Listbox.pm 1 Sep 2003 07:24:35 -0000 1.1.1.4 +++ lib/Curses/UI/Listbox.pm 1 Sep 2003 07:29:04 -0000 1.6 d264 5 a268 5 retrieving revision 1.1.1.4 retrieving revision 1.5 diff -u -d -u -d -r1.1.1.4 -r1.5 --- lib/Curses/UI/TextEditor.pm 1 Sep 2003 07:24:36 -0000 1.1.1.4 +++ lib/Curses/UI/TextEditor.pm 1 Sep 2003 07:27:51 -0000 1.5 d315 4 a318 4 retrieving revision 1.1.1.4 diff -u -d -u -d -r1.1.1.4 Widget.pm --- lib/Curses/UI/Widget.pm 1 Sep 2003 07:24:35 -0000 1.1.1.4 +++ lib/Curses/UI/Widget.pm 1 Sep 2003 07:32:21 -0000 d359 1 a359 1 +++ examples/demo-widgets 1 Sep 2003 07:30:05 -0000 @ 1.9 log @Upgrade Curses::UI @ text @d6 2 a7 2 +++ CHANGES.RSE 14 Apr 2003 10:18:10 -0000 @@@@ -0,0 +1,27 @@@@ a22 2 + o Add color support. + d36 5 a40 5 retrieving revision 1.1.1.4 diff -u -d -u -d -r1.1.1.4 UI.pm --- lib/Curses/UI.pm 27 Apr 2003 18:42:07 -0000 1.1.1.4 +++ lib/Curses/UI.pm 27 Apr 2003 18:43:05 -0000 @@@@ -67,6 +67,8 @@@@ d44 3 a46 3 + -overlapping => 1, # Whether overlapping widgets are supported + -colors => 0, # Whether colors are used d48 1 a48 2 -userdata => undef, #user internal data @@@@ -106,8 +108,11 @@@@ d60 1 a60 1 @@@@ -126,6 +131,8 @@@@ a64 1 +sub colors(;$) { shift()->accessor('-colors', shift()) } a67 86 @@@@ -136,6 +143,61 @@@@ } # ---------------------------------------------------------------------- +# Color support +# ---------------------------------------------------------------------- + +$Curses::UI::colorpairs = 0; +$Curses::UI::colorpair = {}; + +sub colorpair ($$;$$) +{ + my $this = shift; + my ($name, $fg, $bg) = @@_; + my $colors_name2num = { + 'black' => COLOR_BLACK, + 'red' => COLOR_RED, + 'green' => COLOR_GREEN, + 'yellow' => COLOR_YELLOW, + 'blue' => COLOR_BLUE, + 'magenta' => COLOR_MAGENTA, + 'cyan' => COLOR_CYAN, + 'white' => COLOR_WHITE + }; + + if (not $this->{-colors}) { + return 0; + } + if (not defined($fg) and not defined($bg)) { + return ($Curses::UI::colorpair->{$name} || 0); + } + else { + my $n = $Curses::UI::colorpair->{$name}; + if (not defined($n)) { + $Curses::UI::colorpairs++; + $n = $Curses::UI::colorpairs; + } + $fg = $colors_name2num->{$fg} || 'default'; + if ($fg eq 'default') { + my ($fg_d, $bg_d) = (0, 0); + pair_content(0, $fg_d, $bg_d); + $fg = $fg_d; + } + $bg = $colors_name2num->{$bg} || 'default'; + if ($bg eq 'default') { + my ($fg_d, $bg_d) = (0, 0); + pair_content(0, $fg_d, $bg_d); + $bg = $bg_d; + } + init_pair($n, $fg, $bg); + if ($name eq 'default') { + assume_default_colors($fg, $bg); + } + $Curses::UI::colorpair->{$name} = $n; + return $n; + } +} + +# ---------------------------------------------------------------------- # Window resizing support # ---------------------------------------------------------------------- @@@@ -151,6 +213,23 @@@@ initscr(); noecho(); raw(); + + # Color support + if ($this->{-colors}) { + if (has_colors()) { + start_color(); + #my $bg = -1; + #use_default_colors(); + my $bg = COLOR_BLACK; + assume_default_colors(COLOR_WHITE, $bg); + $Curses::UI::colorpair->{"default"} = 0; + $Curses::UI::colorpairs = 1; + $this->colorpair('selected', 'default', 'default'); + } + else { + $this->{-colors} = 0; + } + } # Mouse events if possible my $old = 0; d72 2 a73 1 diff -u -d -u -d -r1.1.1.2 Common.pm d75 1 a75 1 +++ lib/Curses/UI/Common.pm 13 Apr 2003 11:11:53 -0000 a211 32 Index: lib/Curses/UI/Label.pm =================================================================== RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Label.pm,v retrieving revision 1.1.1.2 retrieving revision 1.3 diff -u -d -u -d -r1.1.1.2 -r1.3 --- lib/Curses/UI/Label.pm 28 Mar 2003 08:22:35 -0000 1.1.1.2 +++ lib/Curses/UI/Label.pm 28 Mar 2003 08:24:58 -0000 1.3 @@@@ -51,6 +51,7 @@@@ -dim => 0, -blink => 0, -paddingspaces => 0, # Pad text with spaces? + -colorpair => undef, # Color-pair attribute %userargs, @@@@ -104,6 +105,7 @@@@ sub underline ($;$) { shift()->set_attribute('-underline', shift()) } sub dim ($;$) { shift()->set_attribute('-dim', shift()) } sub blink ($;$) { shift()->set_attribute('-blink', shift()) } +sub colorpair ($;$) { shift()->set_attribute('-colorpair', shift()) } sub set_attribute($$;) { @@@@ -183,6 +185,7 @@@@ $this->{-canvasscr}->attron(A_UNDERLINE) if $this->{-underline}; $this->{-canvasscr}->attron(A_BLINK) if $this->{-blink}; $this->{-canvasscr}->attron(A_DIM) if $this->{-dim}; + $this->{-canvasscr}->attron(COLOR_PAIR($this->root->colorpair($this->{-colorpair}))) if $this->{-colorpair}; # Draw the text. Clip it if it is too long. my $ypos = 0; d215 6 a220 5 retrieving revision 1.1.1.3 diff -u -d -u -d -r1.1.1.3 Listbox.pm --- lib/Curses/UI/Listbox.pm 29 Mar 2003 10:41:56 -0000 1.1.1.3 +++ lib/Curses/UI/Listbox.pm 13 Apr 2003 11:08:27 -0000 @@@@ -289,10 +289,7 @@@@ d232 1 a232 1 @@@@ -304,10 +301,12 @@@@ d249 1 a249 1 @@@@ -318,10 +317,7 @@@@ d264 5 a268 5 retrieving revision 1.1.1.3 retrieving revision 1.4 diff -u -d -u -d -r1.1.1.3 -r1.4 --- lib/Curses/UI/TextEditor.pm 29 Mar 2003 10:41:57 -0000 1.1.1.3 +++ lib/Curses/UI/TextEditor.pm 29 Mar 2003 10:42:44 -0000 1.4 d277 1 a277 1 @@@@ -451,9 +452,10 @@@@ d290 2 a291 2 @@@@ -464,9 +466,11 @@@@ { d304 1 a304 1 @@@@ -560,6 +564,7 @@@@ d315 4 a318 4 retrieving revision 1.1.1.3 diff -u -d -u -d -r1.1.1.3 Widget.pm --- lib/Curses/UI/Widget.pm 29 Mar 2003 10:41:57 -0000 1.1.1.3 +++ lib/Curses/UI/Widget.pm 13 Apr 2003 11:14:54 -0000 d327 1 a327 1 @@@@ -472,7 +473,7 @@@@ d336 1 a336 62 @@@@ -523,6 +524,7 @@@@ if ($this->{-sbborder}) # Square bracket ([,]) border { $this->{-borderscr}->attron(A_BOLD) if $this->{-focus}; + $this->{-borderscr}->attron(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus}; my $offset = 1; $offset++ if $this->{-vscrollbar}; for my $y (0 .. $this->{-sh}-1) @@@@ -532,10 +534,12 @@@@ $this->{-borderscr}->addstr($rel_y, $this->{-bw}-$offset, ']'); } $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus}; + $this->{-borderscr}->attroff(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus}; } elsif ($this->{-border}) # Normal border { $this->{-borderscr}->attron(A_BOLD) if $this->{-focus}; + $this->{-borderscr}->attron(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus}; if ($this->root->compat) { $this->{-borderscr}->border( '|','|','-','-', @@@@ -545,6 +549,7 @@@@ $this->{-borderscr}->box(ACS_VLINE, ACS_HLINE); } $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus}; + $this->{-borderscr}->attroff(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus}; # Draw a title if needed. if (defined $this->{-title}) @@@@ -628,6 +633,7 @@@@ # Draw the base of the scrollbar, in case # there is no border. $this->{-borderscr}->attron(A_BOLD) if $this->{-focus}; + $this->{-borderscr}->attron(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus}; $this->{-borderscr}->move($ypos_min, $xpos); $this->{-borderscr}->vline(ACS_VLINE,$scrlen); if ($this->root->compat) { @@@@ -636,6 +642,7 @@@@ $this->{-borderscr}->vline(ACS_VLINE,$scrlen); } $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus}; + $this->{-borderscr}->attroff(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus}; # Should an active region be drawn? my $scroll_active = ($this->{-vscrolllen} > $scrlen); @@@@ -693,6 +700,7 @@@@ # Draw the base of the scrollbar, in case # there is no border. $this->{-borderscr}->attron(A_BOLD) if $this->{-focus}; + $this->{-borderscr}->attron(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus}; $this->{-borderscr}->move($ypos, $xpos_min); if ($this->root->compat) { $this->{-borderscr}->hline('-',$scrlen); @@@@ -700,6 +708,7 @@@@ $this->{-borderscr}->hline(ACS_HLINE,$scrlen); } $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus}; + $this->{-borderscr}->attroff(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus}; # Should an active region be drawn? my $scroll_active = ($this->{-hscrolllen} > $scrlen); @@@@ -959,6 +968,8 @@@@ d345 1 a345 1 @@@@ -967,6 +978,7 @@@@ d356 5 a360 5 retrieving revision 1.1.1.3 diff -u -d -u -d -r1.1.1.3 demo-widgets --- examples/demo-widgets 27 Apr 2003 18:42:10 -0000 1.1.1.3 +++ examples/demo-widgets 27 Apr 2003 18:43:05 -0000 @@@@ -1,5 +1,11 @@@@ d364 1 a364 1 +use File::Temp qw( :POSIX ); d373 1 a373 12 @@@@ -19,7 +25,10 @@@@ my $cui = new Curses::UI ( -clear_on_exit => 1, -debug => $debug, + -colors => 1, ); +$cui->colorpair('selected', 'red', 'default'); +$cui->colorpair('white-on-red', 'white', 'red'); # Demo index my $current_demo = 1; @@@@ -147,9 +156,10 @@@@ a380 1 +$w{1}->add(undef,'Label',-text=>"colorized font",-x=>15,-y=>9,-colorpair => 'white-on-red' ); a381 2 # ---------------------------------------------------------------------- # Buttons demo @ 1.8 log @try to fix a shutdown issue @ text @d38 4 a41 4 retrieving revision 1.1.1.3 diff -u -d -u -d -r1.1.1.3 UI.pm --- lib/Curses/UI.pm 29 Mar 2003 10:41:56 -0000 1.1.1.3 +++ lib/Curses/UI.pm 21 Apr 2003 08:57:23 -0000 d537 5 a541 5 retrieving revision 1.1.1.2 diff -u -d -u -d -r1.1.1.2 demo-widgets --- examples/demo-widgets 29 Mar 2003 10:41:58 -0000 1.1.1.2 +++ examples/demo-widgets 12 Apr 2003 19:07:10 -0000 @@@@ -1,6 +1,11 @@@@ d545 1 a545 1 use File::Temp qw( :POSIX ); d554 1 a554 1 @@@@ -22,7 +27,10 @@@@ d565 1 a565 1 @@@@ -150,9 +158,10 @@@@ @ 1.7 log @upgrade to my latest Curses::UI patches @ text @d41 1 a41 1 +++ lib/Curses/UI.pm 14 Apr 2003 10:17:22 -0000 d51 1 a51 1 @@@@ -106,8 +108,10 @@@@ d55 2 a56 1 + $this->{-canvasscr}->delwin(); d63 1 a63 1 @@@@ -126,6 +130,8 @@@@ d72 1 a72 1 @@@@ -136,6 +142,61 @@@@ d134 1 a134 1 @@@@ -151,6 +212,23 @@@@ @ 1.6 log @upgrading package: perl-curses 20030328 -> 20030329 @ text @d6 2 a7 2 +++ CHANGES.RSE 29 Mar 2003 10:43:45 -0000 1.6 @@@@ -0,0 +1,19 @@@@ d27 8 d39 1 a39 2 retrieving revision 1.5 diff -u -d -u -d -r1.1.1.3 -r1.5 d41 1 a41 1 +++ lib/Curses/UI.pm 29 Mar 2003 10:42:44 -0000 1.5 d51 12 a62 1 @@@@ -126,6 +128,8 @@@@ d71 1 a71 1 @@@@ -136,6 +140,61 @@@@ d133 1 a133 1 @@@@ -151,6 +210,23 @@@@ d157 143 d336 1 a336 2 retrieving revision 1.4 diff -u -d -u -d -r1.1.1.3 -r1.4 d338 14 a351 2 +++ lib/Curses/UI/Listbox.pm 29 Mar 2003 10:42:44 -0000 1.4 @@@@ -304,10 +304,12 @@@@ d368 12 d435 1 a435 2 retrieving revision 1.4 diff -u -d -u -d -r1.1.1.3 -r1.4 d437 10 a446 2 +++ lib/Curses/UI/Widget.pm 29 Mar 2003 10:42:44 -0000 1.4 @@@@ -472,7 +472,7 @@@@ d455 1 a455 1 @@@@ -523,6 +523,7 @@@@ d463 1 a463 1 @@@@ -532,10 +533,12 @@@@ d476 1 a476 1 @@@@ -545,6 +548,7 @@@@ d484 1 a484 1 @@@@ -628,6 +632,7 @@@@ d492 1 a492 1 @@@@ -636,6 +641,7 @@@@ d500 1 a500 1 @@@@ -693,6 +699,7 @@@@ d508 1 a508 1 @@@@ -700,6 +707,7 @@@@ d516 1 a516 1 @@@@ -959,6 +967,8 @@@@ d525 1 a525 1 @@@@ -967,6 +977,7 @@@@ d537 1 a537 2 retrieving revision 1.5 diff -u -d -u -d -r1.1.1.2 -r1.5 d539 1 a539 1 +++ examples/demo-widgets 29 Mar 2003 10:42:44 -0000 1.5 d549 1 a549 1 +$ENV{TERM} = "xterm-vt220" if ($ENV{TERM} eq 'xterm'); @ 1.5 log @upgrading package: perl-curses 20030123 -> 20030328 @ text @d6 1 a6 1 +++ CHANGES.RSE 28 Mar 2003 08:24:58 -0000 1.5 d10 1 a10 1 + to the excellent Curses::UI 0.72 by Maurice Makaay . d30 5 a34 5 retrieving revision 1.1.1.2 retrieving revision 1.4 diff -u -d -u -d -r1.1.1.2 -r1.4 --- lib/Curses/UI.pm 28 Mar 2003 08:22:34 -0000 1.1.1.2 +++ lib/Curses/UI.pm 28 Mar 2003 08:24:58 -0000 1.4 d42 3 a44 3 %userargs, @@@@ -123,6 +125,8 @@@@ d53 1 a53 1 @@@@ -133,6 +137,61 @@@@ d115 1 a115 1 @@@@ -148,6 +207,23 @@@@ d174 6 a179 6 retrieving revision 1.1.1.2 retrieving revision 1.3 diff -u -d -u -d -r1.1.1.2 -r1.3 --- lib/Curses/UI/Listbox.pm 28 Mar 2003 08:22:35 -0000 1.1.1.2 +++ lib/Curses/UI/Listbox.pm 28 Mar 2003 08:24:58 -0000 1.3 @@@@ -306,10 +306,12 @@@@ d199 5 a203 5 retrieving revision 1.1.1.2 retrieving revision 1.3 diff -u -d -u -d -r1.1.1.2 -r1.3 --- lib/Curses/UI/TextEditor.pm 28 Mar 2003 08:22:36 -0000 1.1.1.2 +++ lib/Curses/UI/TextEditor.pm 28 Mar 2003 08:24:58 -0000 1.3 d250 6 a255 6 retrieving revision 1.1.1.2 retrieving revision 1.3 diff -u -d -u -d -r1.1.1.2 -r1.3 --- lib/Curses/UI/Widget.pm 28 Mar 2003 08:22:35 -0000 1.1.1.2 +++ lib/Curses/UI/Widget.pm 28 Mar 2003 08:24:58 -0000 1.3 @@@@ -461,7 +461,7 @@@@ d264 1 a264 1 @@@@ -513,6 +513,7 @@@@ d272 1 a272 1 @@@@ -522,10 +523,12 @@@@ d285 1 a285 1 @@@@ -535,6 +538,7 @@@@ d293 1 a293 1 @@@@ -614,6 +618,7 @@@@ d301 1 a301 1 @@@@ -622,6 +627,7 @@@@ d309 1 a309 1 @@@@ -679,6 +685,7 @@@@ d317 1 a317 1 @@@@ -686,6 +693,7 @@@@ d325 1 a325 1 @@@@ -945,6 +953,8 @@@@ d334 1 a334 1 @@@@ -953,6 +963,7 @@@@ d345 6 a350 6 retrieving revision 1.1.1.1 retrieving revision 1.4 diff -u -d -u -d -r1.1.1.1 -r1.4 --- examples/demo-widgets 20 Nov 2002 15:00:36 -0000 1.1.1.1 +++ examples/demo-widgets 21 Nov 2002 20:14:59 -0000 1.4 @@@@ -1,5 +1,10 @@@@ d354 1 d363 1 a363 1 @@@@ -19,7 +24,10 @@@@ d374 1 a374 1 @@@@ -147,9 +155,10 @@@@ @ 1.4 log @patch the pathes in the patch @ text @d5 2 a6 2 --- /dev/null Thu Nov 21 21:45:01 2002 +++ CHANGES.RSE Thu Nov 21 21:45:22 2002 d10 1 a10 1 + to the excellent Curses::UI 0.71 by Maurice Makaay . d29 7 a35 8 RCS file: lib/Curses/UI.pm,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -d -u -d -r1.1.1.1 -r1.3 --- lib/Curses/UI.pm 2002/11/20 15:00:33 1.1.1.1 +++ lib/Curses/UI.pm 2002/11/21 20:44:25 1.3 @@@@ -65,6 +65,8 @@@@ -cursor_mode => 0, # What is the current cursor_mode? d38 1 d44 1 a44 1 @@@@ -118,6 +120,8 @@@@ d53 1 a53 1 @@@@ -128,6 +132,61 @@@@ d115 1 a115 1 @@@@ -143,6 +202,23 @@@@ d142 6 a147 6 retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -u -d -r1.1.1.1 -r1.2 --- lib/Curses/UI/Label.pm 2002/11/20 15:00:33 1.1.1.1 +++ lib/Curses/UI/Label.pm 2002/11/21 18:14:03 1.2 @@@@ -50,6 +50,7 @@@@ d155 1 a155 1 @@@@ -103,6 +104,7 @@@@ d163 1 a163 1 @@@@ -182,6 +184,7 @@@@ d174 6 a179 6 retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -u -d -r1.1.1.1 -r1.2 --- lib/Curses/UI/Listbox.pm 2002/11/20 15:00:33 1.1.1.1 +++ lib/Curses/UI/Listbox.pm 2002/11/21 18:14:03 1.2 @@@@ -289,10 +289,12 @@@@ d199 6 a204 6 retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -u -d -r1.1.1.1 -r1.2 --- lib/Curses/UI/TextEditor.pm 2002/11/20 15:00:34 1.1.1.1 +++ lib/Curses/UI/TextEditor.pm 2002/11/21 20:13:17 1.2 @@@@ -150,6 +150,7 @@@@ d212 1 a212 1 @@@@ -450,9 +451,10 @@@@ d225 1 a225 1 @@@@ -463,9 +465,11 @@@@ d239 1 a239 1 @@@@ -559,6 +563,7 @@@@ d250 6 a255 6 retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -u -d -r1.1.1.1 -r1.2 --- lib/Curses/UI/Widget.pm 2002/11/20 15:00:33 1.1.1.1 +++ lib/Curses/UI/Widget.pm 2002/11/21 18:14:03 1.2 @@@@ -460,7 +460,7 @@@@ d264 1 a264 1 @@@@ -511,6 +511,7 @@@@ d272 1 a272 1 @@@@ -520,10 +521,12 @@@@ d285 1 a285 1 @@@@ -533,6 +536,7 @@@@ d293 1 a293 1 @@@@ -612,6 +616,7 @@@@ d301 1 a301 1 @@@@ -620,6 +625,7 @@@@ d309 1 a309 1 @@@@ -677,6 +683,7 @@@@ d317 1 a317 1 @@@@ -684,6 +691,7 @@@@ d325 1 a325 1 @@@@ -943,6 +951,8 @@@@ d334 1 a334 1 @@@@ -951,6 +961,7 @@@@ d348 2 a349 2 --- examples/demo-widgets 2002/11/20 15:00:36 1.1.1.1 +++ examples/demo-widgets 2002/11/21 20:14:59 1.4 @ 1.4.2.1 log @mass Merge-From-CURRENT (MFC) in preparation for OpenPKG 1.3 [class BASE only] @ text @d5 3 a7 3 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ CHANGES.RSE 14 Apr 2003 10:18:10 -0000 @@@@ -0,0 +1,27 @@@@ d10 1 a10 1 + to the excellent Curses::UI by Maurice Makaay . a26 8 + o Add -htmltext option to Curses::UI::Widget, corresponding + text_chop(), text_length() and text_draw() functions to + Curses::UI::Common and used the stuff in Curses::UI::Listbox + to allow in-line markup. + + o Fix top-level DESTROY (destructor) function to correctly + shutdown Curses and allow re-initializations. + d29 8 a36 6 RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI.pm,v retrieving revision 1.1.1.4 diff -u -d -u -d -r1.1.1.4 UI.pm --- lib/Curses/UI.pm 27 Apr 2003 18:42:07 -0000 1.1.1.4 +++ lib/Curses/UI.pm 27 Apr 2003 18:43:05 -0000 @@@@ -67,6 +67,8 @@@@ a38 1 -mouse_support => 1, # Do we want mouse support d42 1 a42 11 #user data -userdata => undef, #user internal data @@@@ -106,8 +108,11 @@@@ DESTROY { my $this = shift; + my $scr = $this->{-canvasscr}; + $scr->delwin() if (defined($scr)); endwin(); $Curses::UI::rootobject = undef; + $Curses::UI::initialized = 0; d44 1 a44 3 if ($this->{-clear_on_exit}) { @@@@ -126,6 +131,8 @@@@ d53 1 a53 1 @@@@ -136,6 +143,61 @@@@ d115 1 a115 1 @@@@ -151,6 +213,23 @@@@ a138 143 Index: lib/Curses/UI/Common.pm =================================================================== RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Common.pm,v retrieving revision 1.1.1.2 diff -u -d -u -d -r1.1.1.2 Common.pm --- lib/Curses/UI/Common.pm 28 Mar 2003 08:22:36 -0000 1.1.1.2 +++ lib/Curses/UI/Common.pm 13 Apr 2003 11:11:53 -0000 @@@@ -35,6 +35,9 @@@@ @@EXPORT = qw( keys_to_lowercase text_wrap + text_draw + text_length + text_chop scrlength split_to_lines text_dimension @@@@ -213,6 +216,125 @@@@ } return \@@wrapped; +} + +sub text_tokenize { + my ($text) = @@_; + + my @@tokens = (); + while ($text ne '') { + if ($text =~ m/^<\/?[a-zA-Z0-9_]+>/s) { + push(@@tokens, $&); + $text = $'; + } + elsif ($text =~ m/^.+?(?=<\/?[a-zA-Z0-9_]+>)/s) { + push(@@tokens, $&); + $text = $'; + } + else { + push(@@tokens, $text); + last; + } + } + return @@tokens; +} + +sub text_draw($$;) +{ + my $this = shift; + my ($y, $x, $text) = @@_; + + if ($this->{-htmltext}) { + my @@tokens = &text_tokenize($text); + foreach my $token (@@tokens) { + if ($token =~ m/^<(standout|reverse|bold|underline|blink|dim)>$/s) { + my $type = $1; + if ($type eq 'standout') { $this->{-canvasscr}->attron(A_STANDOUT); } + elsif ($type eq 'reverse') { $this->{-canvasscr}->attron(A_REVERSE); } + elsif ($type eq 'bold') { $this->{-canvasscr}->attron(A_BOLD); } + elsif ($type eq 'underline') { $this->{-canvasscr}->attron(A_UNDERLINE); } + elsif ($type eq 'blink') { $this->{-canvasscr}->attron(A_BLINK); } + elsif ($type eq 'dim') { $this->{-canvasscr}->attron(A_DIM); } + } + elsif ($token =~ m/^<\/(standout|reverse|bold|underline|blink|dim)>$/s) { + my $type = $1; + if ($type eq 'standout') { $this->{-canvasscr}->attroff(A_STANDOUT); } + elsif ($type eq 'reverse') { $this->{-canvasscr}->attroff(A_REVERSE); } + elsif ($type eq 'bold') { $this->{-canvasscr}->attroff(A_BOLD); } + elsif ($type eq 'underline') { $this->{-canvasscr}->attroff(A_UNDERLINE); } + elsif ($type eq 'blink') { $this->{-canvasscr}->attroff(A_BLINK); } + elsif ($type eq 'dim') { $this->{-canvasscr}->attroff(A_DIM); } + } + else { + $this->{-canvasscr}->addstr($y, $x, $token); + $x += length($token); + } + } + } + else { + $this->{-canvasscr}->addstr($y, $x, $text); + } +} + +sub text_length { + my $this = shift; + my ($text) = @@_; + + my $length = 0; + if ($this->{-htmltext}) { + my @@tokens = &text_tokenize($text); + foreach my $token (@@tokens) { + if ($token !~ m/^<\/?(reverse|bold|underline|blink|dim)>$/s) { + $length += length($token); + } + } + } + else { + $length = length($text); + } + return $length; +} + +sub text_chop { + my $this = shift; + my ($text, $max_length) = @@_; + + if ($this->{-htmltext}) { + my @@open = (); + my @@tokens = &text_tokenize($text); + my $length = 0; + $text = ''; + foreach my $token (@@tokens) { + if ($token =~ m/^<(\/?)(reverse|bold|underline|blink|dim)>/s) { + my ($type, $name) = ($1, $2); + if (defined($type) and $type eq '/') { + pop(@@open); + } + else { + push(@@open, $name); + } + $text .= $token; + } + else { + $text .= $token; + $length += length($token); + if ($length > $max_length) { + $text = substr($text, 0, $max_length); + $text =~ s/.$/\$/; + while (defined($token = pop(@@open))) { + $text .= ""; + } + last; + } + } + } + } + else { + if (length($text) > $max_length) { + $text = substr($text, 0, $max_length); + } + } + return $text; } sub text_dimension ($;) d142 6 a147 6 retrieving revision 1.1.1.2 retrieving revision 1.3 diff -u -d -u -d -r1.1.1.2 -r1.3 --- lib/Curses/UI/Label.pm 28 Mar 2003 08:22:35 -0000 1.1.1.2 +++ lib/Curses/UI/Label.pm 28 Mar 2003 08:24:58 -0000 1.3 @@@@ -51,6 +51,7 @@@@ d155 1 a155 1 @@@@ -104,6 +105,7 @@@@ d163 1 a163 1 @@@@ -183,6 +185,7 @@@@ d174 6 a179 17 retrieving revision 1.1.1.3 diff -u -d -u -d -r1.1.1.3 Listbox.pm --- lib/Curses/UI/Listbox.pm 29 Mar 2003 10:41:56 -0000 1.1.1.3 +++ lib/Curses/UI/Listbox.pm 13 Apr 2003 11:08:27 -0000 @@@@ -289,10 +289,7 @@@@ (($this->{-multi} or $this->{-radio}) ? 4 : 0); # Chop length if needed. - if (($prefix_len + length($label)) > $this->canvaswidth) { - $label = substr($label, 0, ($this->canvaswidth-$prefix_len)); - $label =~ s/.$/\$/; - } + $label = $this->text_chop($label, ($this->canvaswidth-$prefix_len)); # Show current entry in reverse mode and # save cursor position. @@@@ -304,10 +301,12 @@@@ a195 12 @@@@ -318,10 +317,7 @@@@ ); # Show label - $this->{-canvasscr}->addstr( - $y, $prefix_len, - $label - ); + $this->text_draw($y, $prefix_len, $label); $this->{-canvasscr}->attroff(A_REVERSE); $this->{-canvasscr}->attroff(A_BOLD); d199 6 a204 6 retrieving revision 1.1.1.3 retrieving revision 1.4 diff -u -d -u -d -r1.1.1.3 -r1.4 --- lib/Curses/UI/TextEditor.pm 29 Mar 2003 10:41:57 -0000 1.1.1.3 +++ lib/Curses/UI/TextEditor.pm 29 Mar 2003 10:42:44 -0000 1.4 @@@@ -151,6 +151,7 @@@@ d212 1 a212 1 @@@@ -451,9 +452,10 @@@@ d225 1 a225 1 @@@@ -464,9 +466,11 @@@@ d239 1 a239 1 @@@@ -560,6 +564,7 @@@@ d250 6 a255 13 retrieving revision 1.1.1.3 diff -u -d -u -d -r1.1.1.3 Widget.pm --- lib/Curses/UI/Widget.pm 29 Mar 2003 10:41:57 -0000 1.1.1.3 +++ lib/Curses/UI/Widget.pm 13 Apr 2003 11:14:54 -0000 @@@@ -85,6 +85,7 @@@@ -onblur => undef, # onBlur event handler -intellidraw => 1, # Support intellidraw()? -focusable => 1, # This widget can get focus + -htmltext => 1, # Recognize HTML tags in drawn text #user data -userdata => undef, #user internal data @@@@ -472,7 +473,7 @@@@ d264 1 a264 1 @@@@ -523,6 +524,7 @@@@ d272 1 a272 1 @@@@ -532,10 +534,12 @@@@ d285 1 a285 1 @@@@ -545,6 +549,7 @@@@ d293 1 a293 1 @@@@ -628,6 +633,7 @@@@ d301 1 a301 1 @@@@ -636,6 +642,7 @@@@ d309 1 a309 1 @@@@ -693,6 +700,7 @@@@ d317 1 a317 1 @@@@ -700,6 +708,7 @@@@ d325 1 a325 1 @@@@ -959,6 +968,8 @@@@ d334 1 a334 1 @@@@ -967,6 +978,7 @@@@ d345 6 a350 5 retrieving revision 1.1.1.3 diff -u -d -u -d -r1.1.1.3 demo-widgets --- examples/demo-widgets 27 Apr 2003 18:42:10 -0000 1.1.1.3 +++ examples/demo-widgets 27 Apr 2003 18:43:05 -0000 @@@@ -1,5 +1,11 @@@@ a353 1 +use File::Temp qw( :POSIX ); d358 1 a358 1 +#$ENV{TERM} = "xterm-vt220" if ($ENV{TERM} eq 'xterm'); d362 1 a362 1 @@@@ -19,7 +25,10 @@@@ d373 1 a373 1 @@@@ -147,9 +156,10 @@@@ @ 1.3 log @allow default colors to be set, too @ text @d6 1 a6 1 +++ /tmp/rse/cvswnxWiC Thu Nov 21 21:45:22 2002 d29 1 a29 1 RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI.pm,v @ 1.2 log @add latest RSE patches @ text @d5 2 a6 2 --- /dev/null Thu Nov 21 21:15:00 2002 +++ /tmp/rse/cvsWYEhjj Thu Nov 21 21:17:26 2002 d31 2 a32 2 retrieving revision 1.2 diff -u -d -u -d -r1.1.1.1 -r1.2 d34 1 a34 1 +++ lib/Curses/UI.pm 2002/11/21 18:14:03 1.2 d53 1 a53 1 @@@@ -128,6 +132,58 @@@@ d103 3 d115 1 a115 1 @@@@ -143,6 +199,23 @@@@ @ 1.1 log @add explicit (non-)overlapping support to Curses::UI @ text @d1 26 d31 2 a32 1 diff -u -d -u -d -r1.1.1.1 UI.pm d34 2 a35 2 +++ lib/Curses/UI.pm 2002/11/20 15:12:54 @@@@ -65,6 +65,7 @@@@ d40 1 d44 1 a44 1 @@@@ -118,6 +119,7 @@@@ d49 1 d53 191 d248 2 a249 1 diff -u -d -u -d -r1.1.1.1 Widget.pm d251 1 a251 1 +++ lib/Curses/UI/Widget.pm 2002/11/20 15:41:37 d261 62 a322 1 @@@@ -943,6 +943,8 @@@@ d331 1 a331 1 @@@@ -951,6 +953,7 @@@@ d339 43 @