Skip to content

Commit 733acad

Browse files
unrealapexBenBE
andcommitted
Move termType check into its own function
Co-authored-by: Benny Baumann <[email protected]>
1 parent 58efa4e commit 733acad

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

CRT.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,27 @@ void CRT_setMouse(bool enabled) {
10011001
}
10021002
#endif
10031003

1004+
static bool terminalSupportsDefinedKeys(const char* termType) {
1005+
if (!termType) {
1006+
return false;
1007+
}
1008+
1009+
switch (termType[0]) {
1010+
case 'v':
1011+
if (String_eq(termType, "vt220")) {
1012+
return true;
1013+
}
1014+
break;
1015+
case 'x':
1016+
if (String_eq(termType, "xterm")) {
1017+
return true;
1018+
}
1019+
break;
1020+
}
1021+
1022+
return false;
1023+
}
1024+
10041025
void CRT_init(const Settings* settings, bool allowUnicode, bool retainScreenOnExit) {
10051026
initscr();
10061027

@@ -1046,7 +1067,7 @@ void CRT_init(const Settings* settings, bool allowUnicode, bool retainScreenOnEx
10461067
CRT_scrollHAmount = 5;
10471068
}
10481069

1049-
if (termType && (String_startsWith(termType, "xterm") || String_eq(termType, "vt220"))) {
1070+
if (terminalSupportsDefinedKeys(termType)) {
10501071
#ifdef HTOP_NETBSD
10511072
#define define_key(s_, k_) define_key((char*)s_, k_)
10521073
IGNORE_WCASTQUAL_BEGIN

0 commit comments

Comments
 (0)