Skip to content

Commit 80e4532

Browse files
seiunekoDaniel Lange
authored andcommitted
fix: support *-256color in $TERM key detection
1 parent a270702 commit 80e4532

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

CRT.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,22 +1119,24 @@ static bool terminalSupportsDefinedKeys(const char* termType) {
11191119
return false;
11201120
}
11211121

1122+
#define IS_END_OR_DASH(ch) ((ch) == '-' || (ch) == '\0')
1123+
11221124
switch (termType[0]) {
11231125
case 'a':
11241126
if (String_eq(termType, "alacritty")) {
11251127
return true;
11261128
}
11271129
break;
11281130
case 's':
1129-
if (termType[1] == 't' && (termType[2] == '-' || !termType[2])) {
1131+
if (termType[1] == 't' && IS_END_OR_DASH(termType[2])) {
11301132
return true;
11311133
}
1132-
if (String_eq(termType, "screen")) {
1134+
if (String_startsWith(termType, "screen") && IS_END_OR_DASH(termType[6])) {
11331135
return true;
11341136
}
11351137
break;
11361138
case 't':
1137-
if (String_eq(termType, "tmux")) {
1139+
if (String_startsWith(termType, "tmux") && IS_END_OR_DASH(termType[4])) {
11381140
return true;
11391141
}
11401142
break;
@@ -1144,7 +1146,7 @@ static bool terminalSupportsDefinedKeys(const char* termType) {
11441146
}
11451147
break;
11461148
case 'x':
1147-
if (String_eq(termType, "xterm")) {
1149+
if (String_startsWith(termType, "xterm") && IS_END_OR_DASH(termType[5])) {
11481150
return true;
11491151
}
11501152
break;

0 commit comments

Comments
 (0)