… | |
… | |
173 | } |
173 | } |
174 | #endif |
174 | #endif |
175 | |
175 | |
176 | ///////////////////////////////////////////////////////////////////////////// |
176 | ///////////////////////////////////////////////////////////////////////////// |
177 | |
177 | |
178 | static void *enc_buf; |
|
|
179 | static uint32_t enc_len; |
|
|
180 | |
|
|
181 | static inline void * |
|
|
182 | get_enc_buf (uint32_t len) |
|
|
183 | { |
|
|
184 | if (len > enc_len) |
|
|
185 | { |
|
|
186 | free (enc_buf); |
|
|
187 | enc_buf = malloc (len); |
|
|
188 | enc_len = len; |
|
|
189 | } |
|
|
190 | |
|
|
191 | return enc_buf; |
|
|
192 | } |
|
|
193 | |
|
|
194 | static const char * |
178 | static const char * |
195 | enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) |
179 | enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) |
196 | { |
180 | { |
197 | uint8_t *buf = (uint8_t *)get_enc_buf (len); |
181 | uint8_t *buf = rxvt_temp_buf<uint8_t> (len); |
|
|
182 | uint8_t *res = buf; |
198 | |
183 | |
199 | while (len--) |
184 | while (len--) |
200 | { |
185 | { |
201 | uint32_t c = FROM_UNICODE (cs, *text++); |
186 | uint32_t c = FROM_UNICODE (cs, *text++); |
202 | |
187 | |
… | |
… | |
207 | } |
192 | } |
208 | |
193 | |
209 | *buf++ = c; |
194 | *buf++ = c; |
210 | } |
195 | } |
211 | |
196 | |
212 | return (const char *)enc_buf; |
197 | return (const char *)res; |
213 | } |
198 | } |
214 | |
199 | |
215 | static const XChar2b * |
200 | static const XChar2b * |
216 | enc_xchar2b (const text_t *text, uint32_t len, codeset cs, bool &zero) |
201 | enc_xchar2b (const text_t *text, uint32_t len, codeset cs, bool &zero) |
217 | { |
202 | { |
218 | XChar2b *buf = (XChar2b *)get_enc_buf (len * sizeof (XChar2b)); |
203 | XChar2b *buf = rxvt_temp_buf<XChar2b> (len); |
|
|
204 | XChar2b *res = buf; |
219 | |
205 | |
220 | while (len--) |
206 | while (len--) |
221 | { |
207 | { |
222 | uint32_t c = FROM_UNICODE (cs, *text++); |
208 | uint32_t c = FROM_UNICODE (cs, *text++); |
223 | |
209 | |
… | |
… | |
230 | buf->byte1 = c >> 8; |
216 | buf->byte1 = c >> 8; |
231 | buf->byte2 = c; |
217 | buf->byte2 = c; |
232 | buf++; |
218 | buf++; |
233 | } |
219 | } |
234 | |
220 | |
235 | return (XChar2b *)enc_buf; |
221 | return res; |
236 | } |
222 | } |
237 | |
223 | |
238 | ///////////////////////////////////////////////////////////////////////////// |
224 | ///////////////////////////////////////////////////////////////////////////// |
239 | |
225 | |
240 | void |
226 | void |
… | |
… | |
1280 | int fg, int bg) |
1266 | int fg, int bg) |
1281 | { |
1267 | { |
1282 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
1268 | clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); |
1283 | |
1269 | |
1284 | XGlyphInfo extents; |
1270 | XGlyphInfo extents; |
1285 | XftGlyphSpec *enc = (XftGlyphSpec *)get_enc_buf (len * sizeof (XftGlyphSpec)); |
1271 | XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); |
1286 | XftGlyphSpec *ep = enc; |
1272 | XftGlyphSpec *ep = enc; |
1287 | |
1273 | |
1288 | dTermDisplay; |
1274 | dTermDisplay; |
1289 | dTermGC; |
1275 | dTermGC; |
1290 | |
1276 | |