Skip to content

Commit

Permalink
Ask locale for plain-text when Str desired
Browse files Browse the repository at this point in the history
  • Loading branch information
japhb committed Apr 9, 2024
1 parent 1afcb41 commit 52f0b46
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Terminal/Widgets/Input.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ role Terminal::Widgets::Input

#| Set the hint to a translatable
multi method set-hint($hint) {
self.set-hint(~$.terminal.locale.translate($hint))
self.set-hint($.terminal.locale.plain-text($hint))
}

# Set error state, then refresh
Expand Down
2 changes: 1 addition & 1 deletion lib/Terminal/Widgets/Input/Menu.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Terminal::Widgets::Input::Menu

my $item = $!items[$i];
my $icon = ($item<id> && %.icons{$item<id>}) // '';
my $title = $locale.translate($item<title>);
my $title = $locale.plain-text($item<title>);
my $formatted = ' ' ~ ($icon ~ ' ' if $icon) ~ $title ~ ' ';
my $extra = 0 max $w - $locale.width($formatted);
my $padding = ' ' x $extra;
Expand Down
5 changes: 3 additions & 2 deletions lib/Terminal/Widgets/Input/SimpleClickable.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ does Terminal::Widgets::Input::Labeled {
my $layout = self.layout.computed;
my $x = $layout.left-correction;
my $y = $layout.top-correction;
my $label = $.label ~~ TranslatableString
?? ~$.terminal.locale.translate($.label) !! ~$.label;

# XXXX: Temporary hack
my $label = $.terminal.locale.plain-text($.label);

self.draw-framing;
$.grid.set-span($x, $y, self.content-text($label), self.current-color);
Expand Down
2 changes: 1 addition & 1 deletion lib/Terminal/Widgets/Layout.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class SmokeChart is Leaf { }
#| A minimal plain text container
class PlainText is Leaf {
method default-styles(:$locale!, :$text = '') {
my @lines = $locale.translate($text).Str.lines;
my @lines = $locale.plain-text($text).lines;

%( min-h => @lines.elems,
min-w => 0 max @lines.map({ $locale.width($_) }).max )
Expand Down
2 changes: 1 addition & 1 deletion lib/Terminal/Widgets/Terminal.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class Terminal::Widgets::Terminal

#| Set terminal emulator window title to a translatable
multi method set-window-title($title) {
self.set-window-title(~$.locale.translate($title))
self.set-window-title($.locale.plain-text($title));
}

#| Exit from various per-terminal reactors and allow shutdown to proceed
Expand Down

0 comments on commit 52f0b46

Please sign in to comment.