[Previous]
[Contents]
[Next]

console_size()

change or report the size of a console

Synopsis:

#include <sys/console.h>
int console_size( struct _console_ctrl *cc,
                  int console,
                  int set_rows,
                  int set_columns,
                  int *rows,
                  int *columns );

Description:

The console_size() function changes and or reports the size of the indicated console.

The argument cc is a pointer to a control structure that was returned by a previous call to console_open(). console has a value of 1 to represent the device named /dev/con1, a value of 2 for /dev/con2, and so on. A value of 0 for console indicates the default console (that is, the one used by console_open()). A value of -1 for console indicates the currently visible console.

If set_rows is nonzero, the console size is changed to have that number of rows (if that size is supported by the system).

If set_columns is nonzero, the console size is changed to have that number of columns. (if that size is supported by the system).

If the pointers rows and columns are nonzero, the resulting console size is placed in those variables.

Returns:

The console_size() function returns 0 on success, and optionally sets rows and columns to the resulting screen size. If an error occurs, -1 is returned and errno is set.

Errors:

EACCES
You don't have write permission for the console.
EINVAL
The control structure is in the wrong format.
ENXIO
The console value is invalid.

Examples:

#include <sys/console.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>

int main( void )
  {
    struct _console_ctrl *cc;
    int fd;
    int rows, columns;

    /* Open up a channel to the console driver */
    fd = open( "/dev/con1", O_RDWR );
    cc = console_open( fd, O_RDWR );
    close( fd );

    /* Get the size of the currently visible console */
    console_size( cc, 0, 0, 0, &rows, &columns);
    printf( "rows = %d, cols = %d\n", rows, columns );

    /* Set /dev/con1 to 25x80 size */
    console_size( cc, 1, 25, 80, 0, 0 );

    /* Close the channel */
    console_close( cc );
    return (EXIT_SUCCESS);
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

console_active(), console_arm(), console_close(), console_ctrl(), console_font(), console_info(), console_open(), console_protocol(), console_read(), console_state(), console_write(), errno


[Previous]
[Contents]
[Next]