gnuports@2rosenthals.com ?????????????? ????? #30

???: "Dave Yeo" <gnuports@2rosenthals.com> ?? ????
?????????
??: Re: [GNU Ports] Terminal width?
??: Sat, 14 May 2022 18:52:07 -0700
??: GNU Ports for eCS Mailing List <gnuports@2rosenthals.com>

On 05/14/22 11:35 AM, Steven Levine wrote:
In <list-3690493@2rosenthals.com>, on 05/14/22
   at 10:29 AM, "Dave Yeo" <gnuports@2rosenthals.com> said:

Hi Dave,

Need something like this, but we are missing TIOCGWINSZ()
int term_width(int fd)
{
        struct winsize geometry;
        geometry.ws_col = 0;
        if(ioctl(fd, TIOCGWINSZ, &geometry) >= 0)
                return (int)geometry.ws_col;
        return -1;
}

Ideas? Even OS/2 API?

Assuming this is a VIO app, the Vio functions are your friends.
VioGetMode should give you what you need.


Hunting for example code, I found in libc (and EMX where it is documented),

Headers:

#include <stdlib.h>


Prototype:

void _scrsize (int *dst);

Compatibility:

emx

Description:

Retrieve the screen (window) size. The number of text columns (width) is stored to dst[0], the number of text rows (height) is stored to dst[1].

See also: v_dimen()

Does this code make sense?

/* Also serves as a way to detect if we have an interactive terminal. */
#ifndef __OS2__
int term_width(int fd)
{
        struct winsize geometry;
        geometry.ws_col = 0;
        if(ioctl(fd, TIOCGWINSZ, &geometry) >= 0)
                return (int)geometry.ws_col;
        return -1;
}
#else
int term_width(int fd)
{
        int dst[1];
        void _scrsize (int *dst);
                 return dst[0];
}
#endif

Thanks,
Dave

???????: ????, ??????, ??????.
?????????
??? ????????