Skip to content

Commit ee3224d

Browse files
committed
Support scroll-mark selection based on symbol-set
1 parent cf0aa92 commit ee3224d

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/Terminal/LineEditor/DuospaceInput.rakumod

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# ABSTRACT: Input widgets for duospace (Unicode terminal) text input
22

33
use Text::MiscUtils::Layout;
4+
use Terminal::Capabilities;
5+
46
use Terminal::LineEditor::EditableBuffer;
57

68

@@ -46,18 +48,31 @@ class Terminal::LineEditor::ScrollingSingleLineInput
4648
does Terminal::LineEditor::DuospaceLayoutCache {
4749
has UInt:D $.display-width is required;
4850

49-
has Str:D $.left-scroll-mark = '';
50-
has Str:D $.right-scroll-mark = '';
51+
# For backwards compatibility, default to symbol-set Uni1
52+
has Terminal::Capabilities:D $.caps .= new(symbol-set => symbol-set('Uni1'));
53+
54+
has Str $.left-scroll-mark;
55+
has Str $.right-scroll-mark;
5156
has Str:D $.left-no-scroll-mark = ' ';
5257
has Str:D $.right-no-scroll-mark = ' ';
5358

5459
has Str $.mask;
5560
has $.scroll-cursor;
5661

5762

58-
# Initialize scroll-cursor in TWEAK so buffer is ready
5963
submethod TWEAK() {
64+
# Initialize scroll-cursor so buffer is ready
6065
$!scroll-cursor = self.buffer.add-cursor(:!auto-edit-move);
66+
67+
# Default scroll marks to match symbol set
68+
my constant %marks = ASCII => « < > »,
69+
Latin1 => < « » >,
70+
WGL4 => < ◄ ► >,
71+
Uni1 => < ◀ ▶ >,
72+
Uni7 => < ⯇ ⯈ >;
73+
my $marks = $!caps.best-symbol-choice(%marks);
74+
$!left-scroll-mark //= $marks[0];
75+
$!right-scroll-mark //= $marks[1];
6176
}
6277

6378

0 commit comments

Comments
 (0)