aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2004-12-11 02:13:31 +0000
committerKenichi Handa2004-12-11 02:13:31 +0000
commitaee31bf1068104d11065752ded7278f0423821ec (patch)
treec370eb352720536c3f1928664c4e96bf6175f8ad /src
parent0ff61e786c7fdeb3413020c9b633fc417be21323 (diff)
downloademacs-aee31bf1068104d11065752ded7278f0423821ec.tar.gz
emacs-aee31bf1068104d11065752ded7278f0423821ec.zip
Sync to the change in HEAD on 2004-12-01.
Diffstat (limited to 'src')
-rw-r--r--src/w32console.c103
1 files changed, 37 insertions, 66 deletions
diff --git a/src/w32console.c b/src/w32console.c
index 170ce5508be..e16a89e52a9 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -294,8 +294,6 @@ w32con_insert_glyphs (register struct glyph *start, register int len)
294 } 294 }
295} 295}
296 296
297extern unsigned char *terminal_encode_buffer;
298
299extern unsigned char *encode_terminal_code P_ ((struct glyph *, int, 297extern unsigned char *encode_terminal_code P_ ((struct glyph *, int,
300 struct coding_system *)); 298 struct coding_system *));
301 299
@@ -306,10 +304,17 @@ w32con_write_glyphs (register struct glyph *string, register int len)
306 DWORD r; 304 DWORD r;
307 struct frame * f = PICK_FRAME (); 305 struct frame * f = PICK_FRAME ();
308 WORD char_attr; 306 WORD char_attr;
307 unsigned char *conversion_buffer;
308 struct coding_system *coding;
309 309
310 if (len <= 0) 310 if (len <= 0)
311 return; 311 return;
312 312
313 /* If terminal_coding does any conversion, use it, otherwise use
314 safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here
315 because it always return 1 if the member src_multibyte is 1. */
316 coding = (terminal_coding.common_flags & CODING_REQUIRE_ENCODING_MASK
317 ? &terminal_coding : &safe_terminal_coding);
313 /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at 318 /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at
314 the tail. */ 319 the tail. */
315 terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK; 320 terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK;
@@ -327,71 +332,37 @@ w32con_write_glyphs (register struct glyph *string, register int len)
327 /* Turn appearance modes of the face of the run on. */ 332 /* Turn appearance modes of the face of the run on. */
328 char_attr = w32_face_attributes (f, face_id); 333 char_attr = w32_face_attributes (f, face_id);
329 334
330 while (n > 0) 335 if (n == len)
331 { 336 /* This is the last run. */
332 produced = encode_terminal_code (string, 337 coding->mode |= CODING_MODE_LAST_BLOCK;
333 n, 338 conversion_buffer = encode_terminal_code (string, n, coding);
334 &consumed); 339 if (coding->produced > 0)
335 if (produced > 0) 340 {
341 /* Set the attribute for these characters. */
342 if (!FillConsoleOutputAttribute (cur_screen, char_attr,
343 coding->produced, cursor_coords,
344 &r))
336 { 345 {
337 /* Set the attribute for these characters. */ 346 printf ("Failed writing console attributes: %d\n",
338 if (!FillConsoleOutputAttribute (cur_screen, char_attr, 347 GetLastError ());
339 produced, cursor_coords, &r)) 348 fflush (stdout);
340 { 349 }
341 printf ("Failed writing console attributes: %d\n", 350
342 GetLastError ()); 351 /* Write the characters. */
343 fflush (stdout); 352 if (!WriteConsoleOutputCharacter (cur_screen, terminal_encode_buffer,
344 } 353 coding->produced, cursor_coords,
345 354 &r))
346 /* Write the characters. */ 355 {
347 if (!WriteConsoleOutputCharacter (cur_screen, terminal_encode_buffer, 356 printf ("Failed writing console characters: %d\n",
348 produced, cursor_coords, &r)) 357 GetLastError ());
349 { 358 fflush (stdout);
350 printf ("Failed writing console characters: %d\n", 359 }
351 GetLastError ()); 360
352 fflush (stdout); 361 cursor_coords.X += coding->produced;
353 } 362 w32con_move_cursor (cursor_coords.Y, cursor_coords.X);
354 363 }
355 cursor_coords.X += produced; 364 len -= n;
356 w32con_move_cursor (cursor_coords.Y, cursor_coords.X); 365 string += n;
357 }
358 len -= consumed;
359 n -= consumed;
360 string += consumed;
361 }
362 }
363
364 /* We may have to output some codes to terminate the writing. */
365 if (CODING_REQUIRE_FLUSHING (&terminal_coding))
366 {
367 Lisp_Object blank_string = build_string ("");
368 int conversion_buffer_size = 1024;
369
370 terminal_coding.mode |= CODING_MODE_LAST_BLOCK;
371 terminal_coding.destination = (unsigned char *) xmalloc (conversion_buffer_size);
372 encode_coding_object (&terminal_coding, blank_string, 0, 0,
373 0, conversion_buffer_size, Qnil);
374 if (terminal_coding.produced > 0)
375 {
376 if (!FillConsoleOutputAttribute (cur_screen, char_attr_normal,
377 terminal_coding.produced,
378 cursor_coords, &r))
379 {
380 printf ("Failed writing console attributes: %d\n",
381 GetLastError ());
382 fflush (stdout);
383 }
384
385 /* Write the characters. */
386 if (!WriteConsoleOutputCharacter (cur_screen, terminal_coding.destination,
387 produced, cursor_coords, &r))
388 {
389 printf ("Failed writing console characters: %d\n",
390 GetLastError ());
391 fflush (stdout);
392 }
393 }
394 xfree (terminal_coding.destination);
395 } 366 }
396} 367}
397 368