Author: Andreas Tille <tille@debian.org>
Last-Update: 2025-06-14
Bug-Debian: https://bugs.debian.org/755055
Bug: https://rt.cpan.org/Public/Bug/Display.html?id=94539
Description: wide character support
 Following the advise given at CPAN https://rt.cpan.org/Public/Bug/Display.html?id=94539

--- a/lib/Curses/UI/Common.pm
+++ b/lib/Curses/UI/Common.pm
@@ -279,13 +279,13 @@ sub text_draw($$;)
 		$this->{-canvasscr}->hline( $y, $x, $type, $scrlen );
 		$x += $scrlen;
 	    } else {
-                $this->{-canvasscr}->addstr($y, $x, $token);
+                $this->{-canvasscr}->addstring($y, $x, $token);
                 $x += length($token);
             }
         }
     }
     else {
-        $this->{-canvasscr}->addstr($y, $x, $text);
+        $this->{-canvasscr}->addstring($y, $x, $text);
     }
 }
 
@@ -434,7 +434,7 @@ sub char_read(;$)
 	print STDERR "DEBUG: get_key() -> select() -> $!\n"
 	    if $Curses::UI::debug; 
     } elsif ($found) {
-	$key = $s->getch();
+	$key = $s->getchar();
     }
 
     return $key;
--- a/lib/Curses/UI.pm
+++ b/lib/Curses/UI.pm
@@ -497,7 +497,7 @@ sub draw()
     {
         my $s = $self->{-canvasscr};
         $s->clear;
-        $s->addstr(0, 0, $self->lang->get('screen_too_small'));
+        $s->addstring(0, 0, $self->lang->get('screen_too_small'));
         $s->move(4,0);
         $s->noutrefresh();
 	doupdate();
@@ -817,7 +817,7 @@ sub fatalerror($$;$)
 
     my $s = $self->{-canvasscr};
     $s->clear;
-    $s->addstr(0,0,"Fatal program error:\n"
+    $s->addstring(0,0,"Fatal program error:\n"
     	     . "-"x($ENV{COLS}-1) . "\n"
     	     . $error 
     	     . "-"x($ENV{COLS}-1) . "\n"
--- a/lib/Curses/UI/Buttonbox.pm
+++ b/lib/Curses/UI/Buttonbox.pm
@@ -337,7 +337,7 @@ sub draw(;$)
         }
  
         # Draw the button.
-        $this->{-canvasscr}->addstr(
+        $this->{-canvasscr}->addstring(
             $y, $this->{-xpos} + $x, 
             $button->{-label}
         );    
--- a/lib/Curses/UI/Calendar.pm
+++ b/lib/Curses/UI/Calendar.pm
@@ -266,14 +266,14 @@ sub draw(;$)
     # Draw day, month and year. If the widget has focus,
     # show the cursor position. Else show the selected position.
     my $c = $this->{-focus} ? 'c' : '';    
-    $this->{-canvasscr}->addstr(0,0," "x$this->canvaswidth);
-    $this->{-canvasscr}->addstr(0,0, $months[$this->{"-${c}month"}] 
+    $this->{-canvasscr}->addstring(0,0," "x$this->canvaswidth);
+    $this->{-canvasscr}->addstring(0,0, $months[$this->{"-${c}month"}] 
                     . " " . $this->{"-${c}day"});
-    $this->{-canvasscr}->addstr(0,$this->canvaswidth-4,$this->{"-${c}year"});
+    $this->{-canvasscr}->addstring(0,$this->canvaswidth-4,$this->{"-${c}year"});
 
     # Draw daynames
     $this->{-canvasscr}->attron(A_BOLD) if $this->{-focus};
-    $this->{-canvasscr}->addstr(2,0,join " ", @days);
+    $this->{-canvasscr}->addstring(2,0,join " ", @days);
 
     # Reset bold font attribute.
     $this->{-canvasscr}->attroff(A_BOLD) if $this->{-focus};
@@ -313,7 +313,7 @@ sub draw(;$)
 	       $this->{-cyear}  == $year;
 
         # Draw the day.
-        $this->{-canvasscr}->addstr($y, $weekday*3, sprintf("%2d",$day));
+        $this->{-canvasscr}->addstring($y, $weekday*3, sprintf("%2d",$day));
 
         # Reset attributes.
         $this->{-canvasscr}->attroff(A_REVERSE);
--- a/lib/Curses/UI/Checkbox.pm
+++ b/lib/Curses/UI/Checkbox.pm
@@ -217,8 +217,8 @@ sub draw(;$) {
     }
 
     $this->{-canvasscr}->attron(A_BOLD) if $this->{-focus};    
-    $this->{-canvasscr}->addstr(0, 0, '[ ]');
-    $this->{-canvasscr}->addstr(0, 1, 'X') if $this->{-checked};
+    $this->{-canvasscr}->addstring(0, 0, '[ ]');
+    $this->{-canvasscr}->addstring(0, 1, 'X') if $this->{-checked};
     $this->{-canvasscr}->attroff(A_BOLD) if $this->{-focus};    
 
     $this->{-canvasscr}->move(0,1);
--- a/lib/Curses/UI/Dialog/Error.pm
+++ b/lib/Curses/UI/Dialog/Error.pm
@@ -66,10 +66,10 @@ sub draw(;$)
     $this->SUPER::draw(1) or return $this;
 
     # Draw sign
-    $this->{-borderscr}->addstr(2, 1, "    _"); 
-    $this->{-borderscr}->addstr(3, 1, "   / \\"); 
-    $this->{-borderscr}->addstr(4, 1, "  / ! \\"); 
-    $this->{-borderscr}->addstr(5, 1, " /_____\\"); 
+    $this->{-borderscr}->addstring(2, 1, "    _"); 
+    $this->{-borderscr}->addstring(3, 1, "   / \\"); 
+    $this->{-borderscr}->addstring(4, 1, "  / ! \\"); 
+    $this->{-borderscr}->addstring(5, 1, " /_____\\"); 
     $this->{-borderscr}->noutrefresh();
 
     $this->{-canvasscr}->noutrefresh();
--- a/lib/Curses/UI/Label.pm
+++ b/lib/Curses/UI/Label.pm
@@ -209,11 +209,11 @@ sub draw(;$)
             $line = substr($line, 0, $this->canvaswidth);
             $line =~ s/.$/\$/;
         } elsif ($this->{-paddingspaces}) {
-            $this->{-canvasscr}->addstr($ypos, 0, " "x$this->canvaswidth);
+            $this->{-canvasscr}->addstring($ypos, 0, " "x$this->canvaswidth);
         }
 
         my $xpos = $this->compute_xpos($line);
-        $this->{-canvasscr}->addstr($ypos, $xpos, $line);
+        $this->{-canvasscr}->addstring($ypos, $xpos, $line);
 
         $ypos++;
     }
--- a/lib/Curses/UI/Listbox.pm
+++ b/lib/Curses/UI/Listbox.pm
@@ -340,7 +340,7 @@ sub draw(;$)
     if (not @{$this->{-values}})
     {
         $this->{-canvasscr}->attron(A_DIM);    
-        $this->{-canvasscr}->addstr(0,0,'- no values -');
+        $this->{-canvasscr}->addstring(0,0,'- no values -');
         $this->{-canvasscr}->attroff(A_DIM);    
 
     # There are values. Show them!
@@ -388,7 +388,7 @@ sub draw(;$)
             }
             
             # Make full line reverse or blank
-            $this->{-canvasscr}->addstr(
+            $this->{-canvasscr}->addstring(
                 $y, $prefix_len, 
                 " "x($this->canvaswidth-$prefix_len)
             );
@@ -404,9 +404,9 @@ sub draw(;$)
             if ($this->{-multi}) {
                 if (defined $this->{-selected} and    
                     $this->{-selected}->{$i}) {
-		    $this->{-canvasscr}->addstr($y, 0, '[X]');
+		    $this->{-canvasscr}->addstring($y, 0, '[X]');
                 } else {
-                    $this->{-canvasscr}->addstr($y, 0, '[ ]');
+                    $this->{-canvasscr}->addstring($y, 0, '[ ]');
                 }
             }
 
@@ -414,9 +414,9 @@ sub draw(;$)
             elsif ($this->{-radio}) {
                 if (defined $this->{-selected} 
                     and $i == $this->{-selected}) {
-                    $this->{-canvasscr}->addstr($y, 0, '<o>');
+                    $this->{-canvasscr}->addstring($y, 0, '<o>');
                 } else {
-                    $this->{-canvasscr}->addstr($y, 0, '< >');
+                    $this->{-canvasscr}->addstring($y, 0, '< >');
                 }
             }
             $this->{-canvasscr}->attroff(A_BOLD) if $this->{-focus};
--- a/lib/Curses/UI/Menubar.pm
+++ b/lib/Curses/UI/Menubar.pm
@@ -420,7 +420,7 @@ sub draw()
 	$this->{-canvasscr}->attron(COLOR_PAIR($pair));
     }
  
-    $this->{-canvasscr}->addstr(0, 0, " "x$this->canvaswidth);
+    $this->{-canvasscr}->addstring(0, 0, " "x$this->canvaswidth);
 
     # Create menu-items.
     my $x = 1;
@@ -447,7 +447,7 @@ sub draw()
         }
 
         my $label = $item->{-label};
-        $this->{-canvasscr}->addstr(0, $x, " " . $item->{-label} . " ");
+        $this->{-canvasscr}->addstring(0, $x, " " . $item->{-label} . " ");
         $x += length($label) + 2;
 
         $idx++;
--- a/lib/Curses/UI/Notebook.pm
+++ b/lib/Curses/UI/Notebook.pm
@@ -350,7 +350,7 @@ sub draw($;$) {
 
         debug_msg "    writing page name at x=$x";
         $page_win->attron(A_REVERSE) if ($page eq $active_page);
-        $page_win->addstr($y, $x, $page);
+        $page_win->addstring($y, $x, $page);
         $page_win->attroff(A_REVERSE) if ($page eq $active_page);
         if ($this->{-border} or $this->{-sbborder}) {
             for (my $i = 0; $i < length($page); $i++) {
--- a/lib/Curses/UI/Popupmenu.pm
+++ b/lib/Curses/UI/Popupmenu.pm
@@ -245,8 +245,8 @@ sub draw(;$)
         $sellabel = "-"x$width;
     }
 
-    $this->{-canvasscr}->addstr(0,0, " "x$width);
-    $this->{-canvasscr}->addstr(0,0, $sellabel);
+    $this->{-canvasscr}->addstring(0,0, " "x$width);
+    $this->{-canvasscr}->addstring(0,0, $sellabel);
     $this->{-canvasscr}->move(0,$this->canvaswidth-1);
     $this->{-canvasscr}->attroff(A_DIM);
     $this->{-canvasscr}->attroff(A_REVERSE);
--- a/lib/Curses/UI/Progressbar.pm
+++ b/lib/Curses/UI/Progressbar.pm
@@ -121,12 +121,12 @@ sub draw(;$)
 	$this->{-pos} != $this->{-max}) { $blocks-- }
 
     # Draw center line
-    $this->{-canvasscr}->addstr(0, 0, "-"x$this->canvaswidth)
+    $this->{-canvasscr}->addstring(0, 0, "-"x$this->canvaswidth)
         unless $this->{-nocenterline};
 
     # Draw blocks.
     $this->{-canvasscr}->attron(A_REVERSE);
-    $this->{-canvasscr}->addstr(0, 0, " "x$blocks);
+    $this->{-canvasscr}->addstring(0, 0, " "x$blocks);
     $this->{-canvasscr}->attroff(A_REVERSE);
 
     # Draw percentage
@@ -147,9 +147,9 @@ sub draw(;$)
         my $rev = substr($str, 0, $revlen);
         my $norev = substr($str, $revlen, $len-$revlen);
         $this->{-canvasscr}->attron(A_REVERSE);
-        $this->{-canvasscr}->addstr(0, $xpos, $rev);
+        $this->{-canvasscr}->addstring(0, $xpos, $rev);
         $this->{-canvasscr}->attroff(A_REVERSE);
-        $this->{-canvasscr}->addstr(0, $xpos+$revlen, $norev);
+        $this->{-canvasscr}->addstring(0, $xpos+$revlen, $norev);
     }
 
     $this->{-canvasscr}->move(0,$this->canvaswidth-1);
--- a/lib/Curses/UI/TextEditor.pm
+++ b/lib/Curses/UI/TextEditor.pm
@@ -461,7 +461,7 @@ sub draw_text(;$)
         $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));
+            $this->{-canvasscr}->addstring($y, 0, " "x($this->canvaswidth));
         }
     }
 
@@ -515,7 +515,7 @@ sub draw_text(;$)
             }
 
             # Clear line.
-            $this->{-canvasscr}->addstr(
+            $this->{-canvasscr}->addstring(
                 $id, 0, 
 		" "x$this->canvaswidth
 	    );
@@ -525,7 +525,7 @@ sub draw_text(;$)
             if ($inscreen =~ /\n/)
             {
                 $inscreen =~ s/\n//;
-                $this->{-canvasscr}->addstr($id, 0, $inscreen);
+                $this->{-canvasscr}->addstring($id, 0, $inscreen);
                 if ($this->{-showhardreturns})
                 {
                     if ($this->root->compat)
@@ -538,7 +538,7 @@ sub draw_text(;$)
                     }
                 }
             } else {
-                $this->{-canvasscr}->addstr($id, 0, $inscreen);
+                $this->{-canvasscr}->addstring($id, 0, $inscreen);
             }
             
             # Draw overflow characters.
--- a/lib/Curses/UI/Widget.pm
+++ b/lib/Curses/UI/Widget.pm
@@ -567,8 +567,8 @@ sub draw(;$)
         for my $y (0 .. $this->{-sh}-1)
         {
             my $rel_y = $y + $this->{-sy} - $this->{-by};
-            $this->{-borderscr}->addstr($rel_y, 0, '[');
-            $this->{-borderscr}->addstr($rel_y, $this->{-bw}-$offset, ']');
+            $this->{-borderscr}->addstring($rel_y, 0, '[');
+            $this->{-borderscr}->addstring($rel_y, $this->{-bw}-$offset, ']');
         }
         $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus};
         }
@@ -602,7 +602,7 @@ sub draw(;$)
             if ($this->{-titlefullwidth} 
                 and $this->{-titlereverse}) {
             	$this->{-borderscr}->attron(A_BOLD); 
-                $this->{-borderscr}->addstr(0, 1, " "x($this->{-bw}-2));
+                $this->{-borderscr}->addstring(0, 1, " "x($this->{-bw}-2));
                 $this->{-borderscr}->attroff(A_BOLD);
             }
             my $t = $this->{-title};
@@ -613,7 +613,7 @@ sub draw(;$)
                 $t =~ s/.$/\$/;
             }
             $this->{-borderscr}->attron(A_BOLD);   
-            $this->{-borderscr}->addstr(0, 1, " $t ");
+            $this->{-borderscr}->addstring(0, 1, " $t ");
             $this->{-borderscr}->attroff(A_REVERSE);
             $this->{-borderscr}->attroff(A_BOLD);   
         }
@@ -1849,7 +1849,7 @@ new(), layout(), draw() and focus(), it
         $this->SUPER::draw(1);
 
         ....your own draw stuff....
-        $this->{-canvasscr}->addstr(0, 0, "Fixed string");
+        $this->{-canvasscr}->addstring(0, 0, "Fixed string");
         ....your own draw stuff....
 
         $this->{-canvasscr}->noutrefresh;
--- a/t/fakelib/Curses.pm
+++ b/t/fakelib/Curses.pm
@@ -25,7 +25,7 @@ sub new      {
 
 sub DESTROY  { }
 
-sub printw   { addstr(sprintf shift, @_) }
+sub printw   { addstring(sprintf shift, @_) }
 
 $LINES = 25;
 $COLS = 80;
@@ -40,12 +40,12 @@ $COLOR_PAIRS = "";
     LINES $LINES COLS $COLS stdscr $stdscr curscr $curscr COLORS $COLORS
     COLOR_PAIRS $COLOR_PAIRS
 
-    addch echochar addchstr addchnstr addstr addnstr attroff attron attrset
+    addch echochar addchstr addchnstr addstring addnstr attroff attron attrset
     standend standout attr_get attr_off attr_on attr_set chgat COLOR_PAIR
     PAIR_NUMBER beep flash bkgd bkgdset getbkgd border box hline vline
     erase clear clrtobot clrtoeol start_color init_pair init_color
     has_colors can_change_color color_content pair_content delch deleteln
-    insdelln insertln getch ungetch has_key KEY_F getstr getnstr getyx
+    insdelln insertln getchar ungetch has_key KEY_F getstr getnstr getyx
     getparyx getbegyx getmaxyx inch inchstr inchnstr initscr endwin
     isendwin newterm set_term delscreen cbreak nocbreak echo noecho
     halfdelay intrflush keypad meta nodelay notimeout raw noraw qiflush
@@ -161,11 +161,11 @@ sub getbegxy{ $_[1] = 1; $_[2] = 2; }
 sub getbegyx{ $_[1] = 1; $_[2] = 2; }
 sub getmaxyx{ $_[1] = 24; $_[2] = 80; }
 
-sub getch{
+sub getchar{
 # ok, I got a problem here ... mess with the internals
     my $badboy = caller();
     no strict 'refs';
-    #    print STDERR "getch called for $badboy\n";
+    #    print STDERR "getchar called for $badboy\n";
     *{$badboy . "::get_key"} = sub(;$) { 
 	$foo = rand 2; #there is a deep dispute in curses UI
 	               #about if get_key returns a string or
