Thread: Setting terminal size through c?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by Ravi Raj View Post
    I am using this code:

    Code:
    void
    term_size(int *rows, int *cols)
    {
        struct winsize ws = {*rows, *cols, 0, 0};
        int fd;
    
        /* Open the controlling terminal. */
        fd = open("/dev/tty", O_RDWR);
        if (fd < 0)
            exit(1);
    
        /* Get window size of terminal. */ 
        if (ioctl(fd, TIOCSWINSZ, &ws) < 0)
            exit(1);
    
        //*rows = ws.ws_row;
        //*cols = ws.ws_col;
    
        close(fd);    
    }
    In this case you would need to initialize your struct with *rows, *cols before you call ioctl(). But, it should not affect the actual Gnome window itself, but the used area inside. Have you looked for a Gnome api to see if there are something there that let's you do what you want?
    Last edited by Subsonics; 05-22-2012 at 09:28 AM. Reason: Changed the constant to TIOCSWINSZ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to tell ncurses program terminal size
    By apawamajawa in forum Linux Programming
    Replies: 1
    Last Post: 07-20-2011, 02:04 AM
  2. Getting screen size - unix/linux terminal
    By enok in forum C++ Programming
    Replies: 3
    Last Post: 11-21-2009, 04:56 AM
  3. terminal window size
    By eight8ball in forum C Programming
    Replies: 5
    Last Post: 01-08-2009, 08:48 AM
  4. Setting Console Size
    By twomers in forum C++ Programming
    Replies: 4
    Last Post: 08-20-2006, 03:24 PM
  5. Setting the font size
    By Exile in forum Linux Programming
    Replies: 3
    Last Post: 02-21-2005, 06:38 AM

Tags for this Thread