Subversion Repositories planix.SVN

Rev

Rev 119 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * Copyright (c) 2019 The PLANIX Project,
 * All rights reserved.  
 *
 * The Berkeley software License Agreement specifies the terms 
 * and conditions for redistribution.
 *
 */

#include <stdlib.h>
#include <termios.h>
#include <unistd.h>

struct termios orig_termios;

void
disable_raw()
{
        tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}

void
enable_raw()
{
        struct termios raw;
        tcgetattr(STDIN_FILENO, &orig_termios);
        atexit(disable_raw);
        raw = orig_termios;
        raw.c_iflag &= ~(IXON);
        raw.c_lflag &= ~(ECHO | ICANON | ISIG);
        tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}

#include <stdio.h>


void 
get_size(short *columns, short *lines)
{
        struct winsize win;
        int x,y;
        if (ioctl(0, TIOCGWINSZ, &win) < 0) {
                *lines = tgetnum("li");
                *columns = tgetnum("co");
                return;
        } 

        *lines = win.ws_row;    
        *columns = win.ws_col;  


        printf("Here is the terminal size: %d x %d\n", *columns, *lines );
        /*      
        
        
        else {
                if ((LINES = winsz.ws_row = win.ws_row) == 0)
                        LINES = tgetnum("li");
                i = LINES;
                if ((COLUMNS = winsz.ws_col = win.ws_col) == 0)
                        COLUMNS = tgetnum("co");
        }
*/

}