mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-26 04:40:20 +00:00
osdep/terminal: Add function to get terminal pixel dimensions
This commit is contained in:
@@ -21,6 +21,10 @@ void terminal_get_size(int *w, int *h)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void mp_write_console_ansi(void *wstream, char *buf)
|
void mp_write_console_ansi(void *wstream, char *buf)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -493,6 +493,19 @@ void terminal_get_size(int *w, int *h)
|
|||||||
*h = ws.ws_row;
|
*h = ws.ws_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height)
|
||||||
|
{
|
||||||
|
struct winsize ws;
|
||||||
|
if (ioctl(tty_in, TIOCGWINSZ, &ws) < 0 || !ws.ws_row || !ws.ws_col
|
||||||
|
|| !ws.ws_xpixel || !ws.ws_ypixel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*rows = ws.ws_row;
|
||||||
|
*cols = ws.ws_col;
|
||||||
|
*px_width = ws.ws_xpixel;
|
||||||
|
*px_height = ws.ws_ypixel;
|
||||||
|
}
|
||||||
|
|
||||||
void terminal_init(void)
|
void terminal_init(void)
|
||||||
{
|
{
|
||||||
assert(!getch2_enabled);
|
assert(!getch2_enabled);
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ void terminal_get_size(int *w, int *h)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static bool has_input_events(HANDLE h)
|
static bool has_input_events(HANDLE h)
|
||||||
{
|
{
|
||||||
DWORD num_events;
|
DWORD num_events;
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ bool terminal_in_background(void);
|
|||||||
/* Get terminal-size in columns/rows. */
|
/* Get terminal-size in columns/rows. */
|
||||||
void terminal_get_size(int *w, int *h);
|
void terminal_get_size(int *w, int *h);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
// Windows only.
|
// Windows only.
|
||||||
void mp_write_console_ansi(void *wstream, char *buf);
|
void mp_write_console_ansi(void *wstream, char *buf);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user