Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill .ws_xpixel and .ws_ypixel values in winsize #3098

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kruna1Pate1
Copy link

This allows to get terminal size in pixels using TIOCGWINSZ ioctl.

Set .ws_xpixel using columns * cell_width and set .ws_ypixel using rows * cell_height. Cell width and height are font width and line spacing, respectively.

Before

~ $ ./size
rows: 29, cols: 48, xpixel: 0, ypixel: 0
~ $ ./size
rows: 26, cols: 44, xpixel: 0, ypixel: 0
~ $ ./size
rows: 23, cols: 39, xpixel: 0, ypixel: 0
~ $

After

~ $ ./size
rows: 29, cols: 48, xpixel: 1056, ypixel: 1160
~ $ ./size
rows: 26, cols: 44, xpixel: 1056, ypixel: 1144
~ $ ./size
rows: 23, cols: 39, xpixel: 1053, ypixel: 1150
~ $

Use this snippet to check behaviour,

#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>

int main(void) {
    struct winsize ws;
    ioctl(STDIN_FILENO, TIOCGWINSZ, &ws);

    printf("rows: %d, cols: %d, xpixel: %d, ypixel: %d \n", ws.ws_row, ws.ws_col, ws.ws_xpixel, ws.ws_ypixel);

    return 0;
}

Closes: #3092

This allows to get terminal size in pixel using `TIOCGWINSZ` ioctl.
Set `.ws_xpixel` using `columns * cell_width` and set `.ws_ypixel` using `rows * cell_height`.
Cell width and height is font width and line spacing, respectively.
@agnostic-apollo
Copy link
Member

Thanks, will look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants