This source file includes following definitions.
- rxvt_getc
- anything_ready
- show_rxvt_contents
- look_for_rxvt_extensions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #include <config.h>
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #ifdef HAVE_SYS_SELECT_H
36 #include <sys/select.h>
37 #else
38 #include <sys/time.h>
39 #include <sys/types.h>
40 #include <unistd.h>
41 #endif
42
43 #include "lib/global.h"
44 #include "lib/util.h"
45 #include "tty-internal.h"
46 #include "tty.h"
47 #include "win.h"
48
49
50
51 char *smcup = NULL;
52 char *rmcup = NULL;
53
54
55
56
57
58
59
60
61
62 static gboolean rxvt_extensions = FALSE;
63
64
65
66
67
68
69 static int
70 rxvt_getc (void)
71 {
72 int r;
73 unsigned char c;
74
75 while (read (0, &c, 1) != 1);
76 if (c == '\n')
77 return -1;
78 r = (c - 'A') * 16;
79 while (read (0, &c, 1) != 1);
80 r += (c - 'A');
81 return r;
82 }
83
84
85
86 static int
87 anything_ready (void)
88 {
89 fd_set fds;
90 struct timeval tv;
91
92 FD_ZERO (&fds);
93 FD_SET (0, &fds);
94 tv.tv_sec = 0;
95 tv.tv_usec = 0;
96 return select (1, &fds, 0, 0, &tv);
97 }
98
99
100
101
102
103 void
104 show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
105 {
106 unsigned char *k;
107 int bytes, i, j, cols = 0;
108
109 y1 += mc_global.keybar_visible != 0 ? 1 : 0;
110 y2 += mc_global.keybar_visible != 0 ? 1 : 0;
111 while (anything_ready ())
112 tty_lowlevel_getch ();
113
114
115 printf (ESC_STR "CL%c%c%c%c\n", (y1 / 26) + 'A', (y1 % 26) + 'A', (y2 / 26) + 'A',
116 (y2 % 26) + 'A');
117
118 bytes = (y2 - y1) * (COLS + 1) + 1;
119 j = 0;
120 k = g_malloc (bytes);
121 while (TRUE)
122 {
123 int c;
124
125 c = rxvt_getc ();
126 if (c < 0)
127 break;
128 if (j < bytes)
129 k[j++] = c;
130 for (cols = 1;; cols++)
131 {
132 c = rxvt_getc ();
133 if (c < 0)
134 break;
135 if (j < bytes)
136 k[j++] = c;
137 }
138 }
139 for (i = 0; i < j; i++)
140 {
141 if ((i % cols) == 0)
142 tty_gotoyx (starty + (i / cols), 0);
143 tty_print_char (is_printable (k[i]) ? k[i] : ' ');
144 }
145 g_free (k);
146 }
147
148
149
150 gboolean
151 look_for_rxvt_extensions (void)
152 {
153 static gboolean been_called = FALSE;
154
155 if (!been_called)
156 {
157 const char *e = getenv ("RXVT_EXT");
158 rxvt_extensions = ((e != NULL) && (strcmp (e, "1.0") == 0));
159 been_called = TRUE;
160 }
161
162 if (rxvt_extensions)
163 mc_global.tty.console_flag = '\004';
164
165 return rxvt_extensions;
166 }
167
168