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 static gboolean rxvt_extensions = FALSE;
61
62
63
64
65
66 static int
67 rxvt_getc (void)
68 {
69 int r;
70 unsigned char c;
71
72 while (read (0, &c, 1) != 1);
73 if (c == '\n')
74 return -1;
75 r = (c - 'A') * 16;
76 while (read (0, &c, 1) != 1);
77 r += (c - 'A');
78 return r;
79 }
80
81
82
83 static int
84 anything_ready (void)
85 {
86 fd_set fds;
87 struct timeval tv;
88
89 FD_ZERO (&fds);
90 FD_SET (0, &fds);
91 tv.tv_sec = 0;
92 tv.tv_usec = 0;
93 return select (1, &fds, 0, 0, &tv);
94 }
95
96
97
98
99
100 void
101 show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
102 {
103 unsigned char *k;
104 int bytes, i, j, cols = 0;
105
106 y1 += mc_global.keybar_visible != 0 ? 1 : 0;
107 y2 += mc_global.keybar_visible != 0 ? 1 : 0;
108 while (anything_ready ())
109 tty_lowlevel_getch ();
110
111
112 printf (ESC_STR "CL%c%c%c%c\n", (y1 / 26) + 'A', (y1 % 26) + 'A', (y2 / 26) + 'A',
113 (y2 % 26) + 'A');
114
115 bytes = (y2 - y1) * (COLS + 1) + 1;
116 j = 0;
117 k = g_malloc (bytes);
118 while (TRUE)
119 {
120 int c;
121
122 c = rxvt_getc ();
123 if (c < 0)
124 break;
125 if (j < bytes)
126 k[j++] = c;
127 for (cols = 1;; cols++)
128 {
129 c = rxvt_getc ();
130 if (c < 0)
131 break;
132 if (j < bytes)
133 k[j++] = c;
134 }
135 }
136 for (i = 0; i < j; i++)
137 {
138 if ((i % cols) == 0)
139 tty_gotoyx (starty + (i / cols), 0);
140 tty_print_char (is_printable (k[i]) ? k[i] : ' ');
141 }
142 g_free (k);
143 }
144
145
146
147 gboolean
148 look_for_rxvt_extensions (void)
149 {
150 static gboolean been_called = FALSE;
151
152 if (!been_called)
153 {
154 const char *e = getenv ("RXVT_EXT");
155 rxvt_extensions = ((e != NULL) && (strcmp (e, "1.0") == 0));
156 been_called = TRUE;
157 }
158
159 if (rxvt_extensions)
160 mc_global.tty.console_flag = '\004';
161
162 return rxvt_extensions;
163 }
164
165