Skip to content

Commit 67fb62c

Browse files
committed
Take advantage of span-tree(Str:D) affordance
1 parent 1b21579 commit 67fb62c

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

lib/Terminal/Widgets/Input/Button.rakumod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ class Terminal::Widgets::Input::Button
2525

2626
my $has-border = self.layout.computed.has-border;
2727
my @string = $locale.flat-string-spans($label // '');
28-
29-
my @spans = $has-border ?? @string !!
30-
$has-Uni1 ?? (string-span(''), |@string, string-span('')) !!
31-
(string-span('['), |@string, string-span(']'));
28+
my @spans = $has-border ?? @string !!
29+
$has-Uni1 ?? ('', |@string, '') !!
30+
('[', |@string, ']');
3231
span-tree(|@spans);
3332
}
3433

lib/Terminal/Widgets/Input/Checkbox.rakumod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ class Terminal::Widgets::Input::Checkbox
2222
Uni1 => « ☐ ☒ »,
2323
Uni7 => « 🞏 🞕 »;
2424

25-
# XXXX: Hoist string-span up into constant?
26-
$caps.best-symbol-choice(%boxes).map({ string-span($_) })
25+
$caps.best-symbol-choice(%boxes)
2726
}
2827

2928
#| Content (text inside framing)

lib/Terminal/Widgets/Input/RadioButton.rakumod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ class Terminal::Widgets::Input::RadioButton
2222
Uni1 => « ○ ⊙ »,
2323
Uni7 => « 🞅 🞊 »;
2424

25-
# XXXX: Hoist string-span up into constant?
26-
$caps.best-symbol-choice(%buttons).map({ string-span($_) })
25+
$caps.best-symbol-choice(%buttons)
2726
}
2827

2928
#| Content (text inside framing)

lib/Terminal/Widgets/Input/ToggleButton.rakumod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ class Terminal::Widgets::Input::ToggleButton
2626

2727
my $has-border = self.layout.computed.has-border;
2828
my @string = $locale.flat-string-spans($label // '');
29-
30-
my @spans = $has-border ?? @string !!
31-
$has-Uni1 ?? (string-span(''), |@string, string-span('')) !!
32-
(string-span('['), |@string, string-span(']'));
29+
my @spans = $has-border ?? @string !!
30+
$has-Uni1 ?? ('', |@string, '') !!
31+
('[', |@string, ']');
3332

3433
$.state ?? span-tree(color => 'white on_blue', |@spans)
3534
!! span-tree(|@spans)

lib/Terminal/Widgets/Viewer/Log.rakumod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ class Terminal::Widgets::Viewer::Log
6363
constant TC = Terminal::Widgets::TextContent;
6464

6565
my $as-tree = do given $entry.content {
66-
when Str { TC::span-tree(string-span($_)) }
6766
when SS::Span { SS::span-tree('', [$_]) }
68-
when TC::StringSpan { TC::span-tree($_) }
6967
when SS::SpanTree { $_ }
68+
69+
when Str { TC::span-tree($_) }
70+
when TC::StringSpan { TC::span-tree($_) }
7071
when TC::SpanTree { $_ }
72+
7173
default { die "Unrecognized LogEntry.content type {.^name.raku}" }
7274
};
7375

0 commit comments

Comments
 (0)