Skip to content

Commit b1b8daa

Browse files
committed
Recurse terminal autodetection for tmux/screen
1 parent 63c30ae commit b1b8daa

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

Changes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Revision history for Terminal-Capabilities
22

33
{{$NEXT}}
4+
[Features]
5+
- Recursively detect underlying terminal when detecting tmux or screen,
6+
forcing disabled any capabilities broken by the multiplexer app
7+
48

59
0.0.7 2025-10-06T00:24:02-07:00
610
[Bug Fix]

bin/terminal-autodetect

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ sub show-env() {
2222
section('Konsole', < KONSOLE_DBUS_SERVICE KONSOLE_DBUS_SESSION KONSOLE_DBUS_WINDOW >);
2323
section('MLTerm', [ 'MLTERM', ]);
2424
section('Qt', < D_DISABLE_RT_SCREEN_SCALE QT_SCALE_FACTOR_ROUNDING_POLICY >);
25+
section('screen', < STY WINDOW TERMCAP >);
2526
section('Terminator', < TERMINATOR_DBUS_NAME TERMINATOR_DBUS_PATH TERMINATOR_UUID >);
2627
section('Terminology', < TERMINOLOGY XTERM_256_COLORS >);
2728
section('tmux', < TMUX TMUX_PANE >);

lib/Terminal/Capabilities/Autodetect.rakumod

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,41 @@ sub terminal-env-detect() is export {
177177
$terminal = 'tmux';
178178
$version = %*ENV<TERM_PROGRAM_VERSION>;
179179

180-
# XXXX: Limited by symbol-set of underlying terminal emulator too
181-
$symbol-set = symbol-set('Full') if $has-utf8;
182-
183-
# XXXX: Detection of underlying terminal emulator to AND with these?
184-
$italic = True;
185-
$emoji-text = True;
186-
$emoji-color = True;
187-
$emoji-skin = True;
188-
$emoji-iso = True;
180+
# tmux breaks these, regardless of underlying terminal
181+
$color24bit = False;
189182
$emoji-reg = False;
190183
$emoji-zwj = False;
184+
185+
# Try to recurse to detect underlying terminal's capabilities
186+
temp %*ENV<TERM> = $term eq 'tmux-256color' ?? 'xterm-256color' !! 'xterm';
187+
my ($under-caps, $under-terminal, $under-version) = terminal-env-detect;
188+
189+
my $caps = $under-caps.clone(:$color24bit, :$emoji-reg, :$emoji-zwj);
190+
$terminal ~= ' on ' ~ $under-terminal;
191+
$terminal ~= ' version ' ~ $under-version if $under-version;
192+
193+
return ($caps, $terminal, $version);
194+
}
195+
elsif ?$term.starts-with('screen') {
196+
$terminal = 'screen';
197+
198+
# Screen breaks these, regardless of underlying terminal
199+
$italic = False;
200+
$color24bit = False;
201+
202+
# Try to recurse to detect underlying terminal's capabilities
203+
if $term ~~ /^ 'screen.' (.+) $/ {
204+
temp %*ENV<TERM> = ~$0;
205+
my ($under-caps, $under-terminal, $under-version) = terminal-env-detect;
206+
207+
my $caps = $under-caps.clone(:$italic, :$color24bit);
208+
$terminal ~= ' on ' ~ $under-terminal;
209+
$terminal ~= ' version ' ~ $under-version if $under-version;
210+
211+
return ($caps, $terminal, $version);
212+
}
191213
}
192-
elsif ?$term.starts-with('screen'|'vt220'|'vt420')
214+
elsif ?$term.starts-with('vt220'|'vt420')
193215
|| ?$term.lc.contains('color'|'ansi'|'cygwin'|'linux') {
194216
$terminal = $term;
195217
$color3bit = True;

0 commit comments

Comments
 (0)