mirror of
https://github.com/mpv-player/mpv
synced 2025-04-20 14:16:36 +00:00
terminal: add terminal_set_mouse_input function
This function is used to enable/disable mouse input for win32 and unix.
This commit is contained in:
parent
abc0b0e8c9
commit
c2ed2e7bc8
@ -588,6 +588,12 @@ void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height)
|
|||||||
*px_height = ws.ws_ypixel;
|
*px_height = ws.ws_ypixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void terminal_set_mouse_input(bool enable)
|
||||||
|
{
|
||||||
|
printf(enable ? TERM_ESC_ENABLE_MOUSE : TERM_ESC_DISABLE_MOUSE);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
void terminal_init(void)
|
void terminal_init(void)
|
||||||
{
|
{
|
||||||
assert(!getch2_enabled);
|
assert(!getch2_enabled);
|
||||||
|
@ -556,6 +556,10 @@ bool terminal_try_attach(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void terminal_set_mouse_input(bool enable)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void terminal_init(void)
|
void terminal_init(void)
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO cinfo;
|
CONSOLE_SCREEN_BUFFER_INFO cinfo;
|
||||||
|
@ -58,6 +58,9 @@ void terminal_get_size(int *w, int *h);
|
|||||||
/* Get terminal-size in columns/rows and width/height in pixels. */
|
/* Get terminal-size in columns/rows and width/height in pixels. */
|
||||||
void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height);
|
void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height);
|
||||||
|
|
||||||
|
/* Enable/Disable mouse input. */
|
||||||
|
void terminal_set_mouse_input(bool enable);
|
||||||
|
|
||||||
// Windows only.
|
// Windows only.
|
||||||
int mp_console_vfprintf(void *wstream, const char *format, va_list args);
|
int mp_console_vfprintf(void *wstream, const char *format, va_list args);
|
||||||
int mp_console_write(void *wstream, bstr str);
|
int mp_console_write(void *wstream, bstr str);
|
||||||
|
@ -362,7 +362,7 @@ static int preinit(struct vo *vo)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
write_str(TERM_ESC_HIDE_CURSOR);
|
write_str(TERM_ESC_HIDE_CURSOR);
|
||||||
write_str(TERM_ESC_ENABLE_MOUSE);
|
terminal_set_mouse_input(true);
|
||||||
if (p->opts.alt_screen)
|
if (p->opts.alt_screen)
|
||||||
write_str(TERM_ESC_ALT_SCREEN);
|
write_str(TERM_ESC_ALT_SCREEN);
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ static void uninit(struct vo *vo)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
write_str(TERM_ESC_RESTORE_CURSOR);
|
write_str(TERM_ESC_RESTORE_CURSOR);
|
||||||
write_str(TERM_ESC_DISABLE_MOUSE);
|
terminal_set_mouse_input(false);
|
||||||
|
|
||||||
if (p->opts.alt_screen) {
|
if (p->opts.alt_screen) {
|
||||||
write_str(TERM_ESC_NORMAL_SCREEN);
|
write_str(TERM_ESC_NORMAL_SCREEN);
|
||||||
|
@ -520,7 +520,7 @@ static int preinit(struct vo *vo)
|
|||||||
sixel_strwrite(TERM_ESC_ALT_SCREEN);
|
sixel_strwrite(TERM_ESC_ALT_SCREEN);
|
||||||
|
|
||||||
sixel_strwrite(TERM_ESC_HIDE_CURSOR);
|
sixel_strwrite(TERM_ESC_HIDE_CURSOR);
|
||||||
sixel_strwrite(TERM_ESC_ENABLE_MOUSE);
|
terminal_set_mouse_input(true);
|
||||||
|
|
||||||
/* don't use private color registers for each frame. */
|
/* don't use private color registers for each frame. */
|
||||||
sixel_strwrite(TERM_ESC_USE_GLOBAL_COLOR_REG);
|
sixel_strwrite(TERM_ESC_USE_GLOBAL_COLOR_REG);
|
||||||
@ -560,7 +560,7 @@ static void uninit(struct vo *vo)
|
|||||||
struct priv *priv = vo->priv;
|
struct priv *priv = vo->priv;
|
||||||
|
|
||||||
sixel_strwrite(TERM_ESC_RESTORE_CURSOR);
|
sixel_strwrite(TERM_ESC_RESTORE_CURSOR);
|
||||||
sixel_strwrite(TERM_ESC_DISABLE_MOUSE);
|
terminal_set_mouse_input(false);
|
||||||
|
|
||||||
if (priv->opts.alt_screen)
|
if (priv->opts.alt_screen)
|
||||||
sixel_strwrite(TERM_ESC_NORMAL_SCREEN);
|
sixel_strwrite(TERM_ESC_NORMAL_SCREEN);
|
||||||
|
@ -299,7 +299,7 @@ static void flip_page(struct vo *vo)
|
|||||||
static void uninit(struct vo *vo)
|
static void uninit(struct vo *vo)
|
||||||
{
|
{
|
||||||
WRITE_STR(TERM_ESC_RESTORE_CURSOR);
|
WRITE_STR(TERM_ESC_RESTORE_CURSOR);
|
||||||
WRITE_STR(TERM_ESC_DISABLE_MOUSE);
|
terminal_set_mouse_input(false);
|
||||||
WRITE_STR(TERM_ESC_NORMAL_SCREEN);
|
WRITE_STR(TERM_ESC_NORMAL_SCREEN);
|
||||||
struct priv *p = vo->priv;
|
struct priv *p = vo->priv;
|
||||||
talloc_free(p->frame);
|
talloc_free(p->frame);
|
||||||
@ -329,7 +329,7 @@ static int preinit(struct vo *vo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WRITE_STR(TERM_ESC_HIDE_CURSOR);
|
WRITE_STR(TERM_ESC_HIDE_CURSOR);
|
||||||
WRITE_STR(TERM_ESC_ENABLE_MOUSE);
|
terminal_set_mouse_input(true);
|
||||||
WRITE_STR(TERM_ESC_ALT_SCREEN);
|
WRITE_STR(TERM_ESC_ALT_SCREEN);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user