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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <stdio.h> /* read, printf */
21 #include <stdlib.h> /* getenv */
22 #include <sys/types.h>
27 #include <malloc.h> /* malloc */
30 # include <sys/time.h> /* struct timeval */
31 #endif /* SCO_FLAVOR */
34 # include <sys/select.h>
37 #include "tty.h" /* move, addch */
38 #include "util.h" /* is_printable */
39 #include "cons.saver.h"
41 int rxvt_extensions
= 0;
43 int look_for_rxvt_extensions (void)
45 static int been_called
= 0;
49 e
= getenv ("RXVT_EXT");
51 if (!strcmp (e
, "1.0"))
57 return rxvt_extensions
;
60 /* my own wierd protocol base 16 - paul */
61 static int rxvt_getc (void)
65 while (read (0, &c
, 1) != 1);
69 while (read (0, &c
, 1) != 1);
74 extern int keybar_visible
;
76 static int anything_ready ()
85 return select (1, &fds
, 0, 0, &tv
);
88 void show_rxvt_contents (int starty
, unsigned char y1
, unsigned char y2
)
91 int bytes
, i
, j
, cols
= 0;
92 y1
+= (keybar_visible
!= 0); /* i don't knwo why we need this - paul */
93 y2
+= (keybar_visible
!= 0);
94 while (anything_ready ())
97 /* my own wierd protocol base 26 - paul */
98 printf ("\033CL%c%c%c%c\n",
99 (y1
/ 26) + 'A', (y1
% 26) + 'A',
100 (y2
/ 26) + 'A', (y2
% 26) + 'A');
102 bytes
= (y2
- y1
) * (COLS
+ 1) + 1; /* *should* be the number of bytes read */
112 for (cols
= 1;;cols
++) {
120 for (i
= 0; i
< j
; i
++) {
122 move (starty
+ (i
/ cols
), 0);
123 addch (is_printable (k
[i
]) ? k
[i
] : ' ');