Skip to content

Commit

Permalink
Move termType check into its own function
Browse files Browse the repository at this point in the history
Co-authored-by: Benny Baumann <[email protected]>
  • Loading branch information
unrealapex and BenBE committed Jun 28, 2024
1 parent 58efa4e commit 733acad
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion CRT.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,27 @@ void CRT_setMouse(bool enabled) {
}
#endif

static bool terminalSupportsDefinedKeys(const char* termType) {
if (!termType) {
return false;
}

switch (termType[0]) {
case 'v':
if (String_eq(termType, "vt220")) {
return true;
}
break;
case 'x':
if (String_eq(termType, "xterm")) {
return true;
}
break;
}

return false;
}

void CRT_init(const Settings* settings, bool allowUnicode, bool retainScreenOnExit) {
initscr();

Expand Down Expand Up @@ -1046,7 +1067,7 @@ void CRT_init(const Settings* settings, bool allowUnicode, bool retainScreenOnEx
CRT_scrollHAmount = 5;
}

if (termType && (String_startsWith(termType, "xterm") || String_eq(termType, "vt220"))) {
if (terminalSupportsDefinedKeys(termType)) {
#ifdef HTOP_NETBSD
#define define_key(s_, k_) define_key((char*)s_, k_)
IGNORE_WCASTQUAL_BEGIN
Expand Down

0 comments on commit 733acad

Please sign in to comment.