mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-28 14:29:25 +08:00
getch2: Load the "ce", "ks" and "ke" caps into a static buffer
Fixes reports of printing of garbage (or anything else) other than clearing the status line to the end of line: the buffer returned by termcap_get could get moved, and if that happened then these 3 caps pointed to garbage.
This commit is contained in:
+6
-3
@@ -270,7 +270,10 @@ int load_termcap(char *termtype){
|
||||
#endif
|
||||
ensure_cap(&termcap_buf, 2048);
|
||||
|
||||
erase_to_end_of_line = termcap_get("ce");
|
||||
static char term_buf[64];
|
||||
char *buf_ptr = &term_buf[0];
|
||||
|
||||
erase_to_end_of_line = tgetstr("ce", &buf_ptr);
|
||||
|
||||
screen_width = tgetnum("co");
|
||||
screen_height = tgetnum("li");
|
||||
@@ -279,8 +282,8 @@ int load_termcap(char *termtype){
|
||||
if (screen_height < 1 || screen_height > 255)
|
||||
screen_height = 24;
|
||||
|
||||
term_smkx = termcap_get("ks");
|
||||
term_rmkx = termcap_get("ke");
|
||||
term_smkx = tgetstr("ks", &buf_ptr);
|
||||
term_rmkx = tgetstr("ke", &buf_ptr);
|
||||
|
||||
cap_key_pair keys[] = {
|
||||
{"kP", MP_KEY_PGUP}, {"kN", MP_KEY_PGDWN}, {"kh", MP_KEY_HOME}, {"kH", MP_KEY_END},
|
||||
|
||||
Reference in New Issue
Block a user