author | viric@mandarina |
Mon, 28 Apr 2008 21:39:46 +0200 | |
changeset 91 | af6b072bb025 |
parent 53 | 07500c5c53cb |
permissions | -rw-r--r-- |
53 | 1 |
/* |
2 |
Terminal Mixer - multi-point multi-user access to terminal applications |
|
3 |
Copyright (C) 2007 LluĂs Batlle i Rossell |
|
4 |
||
5 |
Please find the license in the provided COPYING file. |
|
6 |
*/ |
|
34 | 7 |
#include <sys/ioctl.h> |
8 |
#include <termios.h> |
|
9 |
#include <sys/types.h> |
|
10 |
#include <stdio.h> |
|
47
8dcc45d8f3e5
xterm resizes sent on SIGWINCH. new terminal applications start a new session.
lbatlle@npdl268.bpo.hp.com
parents:
41
diff
changeset
|
11 |
#include <unistd.h> |
34 | 12 |
#include "main.h" |
13 |
||
14 |
static char xterm_resize_string[100]; |
|
15 |
||
16 |
char * get_xterm_resize_string() |
|
17 |
{ |
|
18 |
int rows, cols; |
|
41 | 19 |
extern struct winsize app_winsize; /* from app_term.c */ |
34 | 20 |
|
47
8dcc45d8f3e5
xterm resizes sent on SIGWINCH. new terminal applications start a new session.
lbatlle@npdl268.bpo.hp.com
parents:
41
diff
changeset
|
21 |
if (isatty(0)) |
8dcc45d8f3e5
xterm resizes sent on SIGWINCH. new terminal applications start a new session.
lbatlle@npdl268.bpo.hp.com
parents:
41
diff
changeset
|
22 |
{ |
8dcc45d8f3e5
xterm resizes sent on SIGWINCH. new terminal applications start a new session.
lbatlle@npdl268.bpo.hp.com
parents:
41
diff
changeset
|
23 |
int res; |
8dcc45d8f3e5
xterm resizes sent on SIGWINCH. new terminal applications start a new session.
lbatlle@npdl268.bpo.hp.com
parents:
41
diff
changeset
|
24 |
/* Get rows and cols from our connection to the terminal: fd 0 */ |
8dcc45d8f3e5
xterm resizes sent on SIGWINCH. new terminal applications start a new session.
lbatlle@npdl268.bpo.hp.com
parents:
41
diff
changeset
|
25 |
res = ioctl(0, TIOCGWINSZ, &app_winsize); |
8dcc45d8f3e5
xterm resizes sent on SIGWINCH. new terminal applications start a new session.
lbatlle@npdl268.bpo.hp.com
parents:
41
diff
changeset
|
26 |
if (res == -1) |
8dcc45d8f3e5
xterm resizes sent on SIGWINCH. new terminal applications start a new session.
lbatlle@npdl268.bpo.hp.com
parents:
41
diff
changeset
|
27 |
error("ioctl TIOCGWINSZ"); |
8dcc45d8f3e5
xterm resizes sent on SIGWINCH. new terminal applications start a new session.
lbatlle@npdl268.bpo.hp.com
parents:
41
diff
changeset
|
28 |
} |
41 | 29 |
rows = app_winsize.ws_row; |
30 |
cols = app_winsize.ws_col; |
|
34 | 31 |
|
32 |
/* Prepare the xterm resize string */ |
|
35 | 33 |
snprintf(xterm_resize_string, sizeof xterm_resize_string, |
34 |
"\033[8;%i;%it", rows, cols); |
|
34 | 35 |
|
36 |
return xterm_resize_string; |
|
37 |
} |