1 /* rxvt.c - gives output lines on rxvt with a special rxvt patch
2 Copyright (C) 1997 Paul Sheer
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include <stdio.h> /* read, printf */
21 #include <sys/types.h>
28 # include <sys/time.h> /* struct timeval */
29 #endif /* SCO_FLAVOR */
32 # include <sys/select.h>
35 #include "tty.h" /* move, addch */
37 #include "cons.saver.h"
39 int rxvt_extensions
= 0;
41 int look_for_rxvt_extensions (void)
43 static int been_called
= 0;
47 e
= getenv ("RXVT_EXT");
49 if (!strcmp (e
, "1.0"))
55 return rxvt_extensions
;
58 /* my own wierd protocol base 16 - paul */
59 static int rxvt_getc (void)
63 while (read (0, &c
, 1) != 1);
67 while (read (0, &c
, 1) != 1);
72 extern int keybar_visible
;
74 static int anything_ready ()
83 return select (1, &fds
, 0, 0, &tv
);
86 void show_rxvt_contents (int starty
, unsigned char y1
, unsigned char y2
)
89 int bytes
, i
, j
, cols
= 0;
90 y1
+= (keybar_visible
!= 0); /* i don't knwo why we need this - paul */
91 y2
+= (keybar_visible
!= 0);
92 while (anything_ready ())
95 /* my own wierd protocol base 26 - paul */
96 printf ("\033CL%c%c%c%c\n",
97 (y1
/ 26) + 'A', (y1
% 26) + 'A',
98 (y2
/ 26) + 'A', (y2
% 26) + 'A');
100 bytes
= (y2
- y1
) * (COLS
+ 1) + 1; /* *should* be the number of bytes read */
102 k
= g_malloc (bytes
);
110 for (cols
= 1;;cols
++) {
118 for (i
= 0; i
< j
; i
++) {
120 move (starty
+ (i
/ cols
), 0);
121 addch (is_printable (k
[i
]) ? k
[i
] : ' ');