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 "tty.h" /* move, addch */
29 #include "cons.saver.h"
31 static int rxvt_extensions
= 0;
33 int look_for_rxvt_extensions (void)
35 static int been_called
= 0;
39 e
= getenv ("RXVT_EXT");
41 if (!strcmp (e
, "1.0"))
47 return rxvt_extensions
;
50 /* my own wierd protocol base 16 - paul */
51 static int rxvt_getc (void)
55 while (read (0, &c
, 1) != 1);
59 while (read (0, &c
, 1) != 1);
64 extern int keybar_visible
;
66 static int anything_ready (void)
75 return select (1, &fds
, 0, 0, &tv
);
78 void show_rxvt_contents (int starty
, unsigned char y1
, unsigned char y2
)
81 int bytes
, i
, j
, cols
= 0;
82 y1
+= (keybar_visible
!= 0); /* i don't knwo why we need this - paul */
83 y2
+= (keybar_visible
!= 0);
84 while (anything_ready ())
87 /* my own wierd protocol base 26 - paul */
88 printf ("\033CL%c%c%c%c\n",
89 (y1
/ 26) + 'A', (y1
% 26) + 'A',
90 (y2
/ 26) + 'A', (y2
% 26) + 'A');
92 bytes
= (y2
- y1
) * (COLS
+ 1) + 1; /* *should* be the number of bytes read */
102 for (cols
= 1;;cols
++) {
110 for (i
= 0; i
< j
; i
++) {
112 move (starty
+ (i
/ cols
), 0);
113 addch (is_printable (k
[i
]) ? k
[i
] : ' ');