History

terminal: add terminal_set_mouse_input function

This function is used to enable/disable mouse input for win32 and unix.

nanahi committed 2 years ago

Commit c2ed2e71 parent abc0b0e6 files · +19 −6Browse files

Unified · Split

6 files
  1. osdep/terminal-unix.c +6 −0
  2. osdep/terminal-win.c +4 −0
  3. osdep/terminal.h +3 −0
  4. video/out/vo_kitty.c +2 −2
  5. video/out/vo_sixel.c +2 −2
  6. video/out/vo_tct.c +2 −2
osdep/terminal-unix.c+6−0
@@ -588,6 +588,12 @@ void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height) · 587 unmodified lines
588 *px_height = ws.ws_ypixel;588 *px_height = ws.ws_ypixel;
589}589}
590 590
591void terminal_set_mouse_input(bool enable)
592{
593 printf(enable ? TERM_ESC_ENABLE_MOUSE : TERM_ESC_DISABLE_MOUSE);
594 fflush(stdout);
595}
596
591void terminal_init(void)597void terminal_init(void)
592{598{
593 assert(!getch2_enabled);599 assert(!getch2_enabled);
osdep/terminal-win.c+4−0
@@ -556,6 +556,10 @@ bool terminal_try_attach(void) · 555 unmodified lines
556 return true;556 return true;
557}557}
558 558
559void terminal_set_mouse_input(bool enable)
560{
561}
562
559void terminal_init(void)563void terminal_init(void)
560{564{
561 CONSOLE_SCREEN_BUFFER_INFO cinfo;565 CONSOLE_SCREEN_BUFFER_INFO cinfo;
osdep/terminal.h+3−0
@@ -58,6 +58,9 @@ void terminal_get_size(int *w, int *h); · 57 unmodified lines
58/* Get terminal-size in columns/rows and width/height in pixels. */58/* Get terminal-size in columns/rows and width/height in pixels. */
59void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height);59void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height);
60 60
61/* Enable/Disable mouse input. */
62void terminal_set_mouse_input(bool enable);
63
61// Windows only.64// Windows only.
62int mp_console_vfprintf(void *wstream, const char *format, va_list args);65int mp_console_vfprintf(void *wstream, const char *format, va_list args);
63int mp_console_write(void *wstream, bstr str);66int mp_console_write(void *wstream, bstr str);
video/out/vo_kitty.c+2−2
@@ -362,7 +362,7 @@ static int preinit(struct vo *vo) · 361 unmodified lines
362#endif362#endif
363 363
364 write_str(TERM_ESC_HIDE_CURSOR);364 write_str(TERM_ESC_HIDE_CURSOR);
365 write_str(TERM_ESC_ENABLE_MOUSE);365 terminal_set_mouse_input(true);
366 if (p->opts.alt_screen)366 if (p->opts.alt_screen)
367 write_str(TERM_ESC_ALT_SCREEN);367 write_str(TERM_ESC_ALT_SCREEN);
368 368
@@ -390,7 +390,7 @@ static void uninit(struct vo *vo) · 21 unmodified lines
390#endif390#endif
391 391
392 write_str(TERM_ESC_RESTORE_CURSOR);392 write_str(TERM_ESC_RESTORE_CURSOR);
393 write_str(TERM_ESC_DISABLE_MOUSE);393 terminal_set_mouse_input(false);
394 394
395 if (p->opts.alt_screen) {395 if (p->opts.alt_screen) {
396 write_str(TERM_ESC_NORMAL_SCREEN);396 write_str(TERM_ESC_NORMAL_SCREEN);
video/out/vo_sixel.c+2−2
@@ -520,7 +520,7 @@ static int preinit(struct vo *vo) · 519 unmodified lines
520 sixel_strwrite(TERM_ESC_ALT_SCREEN);520 sixel_strwrite(TERM_ESC_ALT_SCREEN);
521 521
522 sixel_strwrite(TERM_ESC_HIDE_CURSOR);522 sixel_strwrite(TERM_ESC_HIDE_CURSOR);
523 sixel_strwrite(TERM_ESC_ENABLE_MOUSE);523 terminal_set_mouse_input(true);
524 524
525 /* don't use private color registers for each frame. */525 /* don't use private color registers for each frame. */
526 sixel_strwrite(TERM_ESC_USE_GLOBAL_COLOR_REG);526 sixel_strwrite(TERM_ESC_USE_GLOBAL_COLOR_REG);
@@ -560,7 +560,7 @@ static void uninit(struct vo *vo) · 33 unmodified lines
560 struct priv *priv = vo->priv;560 struct priv *priv = vo->priv;
561 561
562 sixel_strwrite(TERM_ESC_RESTORE_CURSOR);562 sixel_strwrite(TERM_ESC_RESTORE_CURSOR);
563 sixel_strwrite(TERM_ESC_DISABLE_MOUSE);563 terminal_set_mouse_input(false);
564 564
565 if (priv->opts.alt_screen)565 if (priv->opts.alt_screen)
566 sixel_strwrite(TERM_ESC_NORMAL_SCREEN);566 sixel_strwrite(TERM_ESC_NORMAL_SCREEN);
video/out/vo_tct.c+2−2
@@ -299,7 +299,7 @@ static void flip_page(struct vo *vo) · 298 unmodified lines
299static void uninit(struct vo *vo)299static void uninit(struct vo *vo)
300{300{
301 WRITE_STR(TERM_ESC_RESTORE_CURSOR);301 WRITE_STR(TERM_ESC_RESTORE_CURSOR);
302 WRITE_STR(TERM_ESC_DISABLE_MOUSE);302 terminal_set_mouse_input(false);
303 WRITE_STR(TERM_ESC_NORMAL_SCREEN);303 WRITE_STR(TERM_ESC_NORMAL_SCREEN);
304 struct priv *p = vo->priv;304 struct priv *p = vo->priv;
305 talloc_free(p->frame);305 talloc_free(p->frame);
@@ -329,7 +329,7 @@ static int preinit(struct vo *vo) · 23 unmodified lines
329 }329 }
330 330
331 WRITE_STR(TERM_ESC_HIDE_CURSOR);331 WRITE_STR(TERM_ESC_HIDE_CURSOR);
332 WRITE_STR(TERM_ESC_ENABLE_MOUSE);332 terminal_set_mouse_input(true);
333 WRITE_STR(TERM_ESC_ALT_SCREEN);333 WRITE_STR(TERM_ESC_ALT_SCREEN);
334 334
335 return 0;335 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t