Just a little correction at the it.po file.
[midnight-commander.git] / src / rxvt.c
blob4170c883d58fe0995a3eb22301577e3a4f2cc07d
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.
19 #include <config.h>
20 #include <stdio.h> /* read, printf */
21 #include <sys/types.h>
22 #include <string.h>
23 #ifdef HAVE_UNISTD_H
24 # include <unistd.h>
25 #endif
27 #include "global.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;
36 char *e;
37 if (!been_called) {
38 rxvt_extensions = 0;
39 e = getenv ("RXVT_EXT");
40 if (e)
41 if (!strcmp (e, "1.0"))
42 rxvt_extensions = 1;
43 been_called = 1;
45 if (rxvt_extensions)
46 console_flag = 4;
47 return rxvt_extensions;
50 /* my own wierd protocol base 16 - paul */
51 static int rxvt_getc (void)
53 int r;
54 unsigned char c;
55 while (read (0, &c, 1) != 1);
56 if (c == '\n')
57 return -1;
58 r = (c - 'A') * 16;
59 while (read (0, &c, 1) != 1);
60 r += (c - 'A');
61 return r;
64 extern int keybar_visible;
66 static int anything_ready (void)
68 fd_set fds;
69 struct timeval tv;
71 FD_ZERO (&fds);
72 FD_SET (0, &fds);
73 tv.tv_sec = 0;
74 tv.tv_usec = 0;
75 return select (1, &fds, 0, 0, &tv);
78 void show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
80 unsigned char *k;
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 ())
85 getch ();
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 */
93 j = 0;
94 k = g_malloc (bytes);
95 for (;;) {
96 int c;
97 c = rxvt_getc ();
98 if (c < 0)
99 break;
100 if (j < bytes)
101 k[j++] = c;
102 for (cols = 1;;cols++) {
103 c = rxvt_getc ();
104 if (c < 0)
105 break;
106 if (j < bytes)
107 k[j++] = c;
110 for (i = 0; i < j; i++) {
111 if ((i % cols) == 0)
112 move (starty + (i / cols), 0);
113 addch (is_printable (k[i]) ? k[i] : ' ');
115 g_free (k);