diff options
| author | Kenichi Handa | 2004-12-01 10:48:38 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-12-01 10:48:38 +0000 |
| commit | 853895f64098ff1872dea2da99dea511e501f442 (patch) | |
| tree | 59870c1a58fbc14d2199b40719b05f99de8c4c5b /src | |
| parent | 9607552590f9b42cec2f0430a0b6d8ba973d694c (diff) | |
| download | emacs-853895f64098ff1872dea2da99dea511e501f442.tar.gz emacs-853895f64098ff1872dea2da99dea511e501f442.zip | |
(w32con_write_glyphs): Decide coding here.
Adjusted for the change of encode_terminal_code.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32console.c | 104 |
1 files changed, 40 insertions, 64 deletions
diff --git a/src/w32console.c b/src/w32console.c index 74a8fd6338e..f30d66aeda5 100644 --- a/src/w32console.c +++ b/src/w32console.c | |||
| @@ -294,6 +294,9 @@ w32con_insert_glyphs (register struct glyph *start, register int len) | |||
| 294 | } | 294 | } |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | extern unsigned char *encode_terminal_code P_ ((struct glyph *, int, | ||
| 298 | struct coding-system *)); | ||
| 299 | |||
| 297 | static void | 300 | static void |
| 298 | w32con_write_glyphs (register struct glyph *string, register int len) | 301 | w32con_write_glyphs (register struct glyph *string, register int len) |
| 299 | { | 302 | { |
| @@ -301,12 +304,17 @@ w32con_write_glyphs (register struct glyph *string, register int len) | |||
| 301 | DWORD r; | 304 | DWORD r; |
| 302 | struct frame * f = PICK_FRAME (); | 305 | struct frame * f = PICK_FRAME (); |
| 303 | WORD char_attr; | 306 | WORD char_attr; |
| 304 | unsigned char conversion_buffer[1024]; | 307 | unsigned char *conversion_buffer; |
| 305 | int conversion_buffer_size = sizeof conversion_buffer; | 308 | struct coding_system *coding; |
| 306 | 309 | ||
| 307 | if (len <= 0) | 310 | if (len <= 0) |
| 308 | return; | 311 | return; |
| 309 | 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); | ||
| 310 | /* 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 |
| 311 | the tail. */ | 319 | the tail. */ |
| 312 | terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK; | 320 | terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK; |
| @@ -324,69 +332,37 @@ w32con_write_glyphs (register struct glyph *string, register int len) | |||
| 324 | /* Turn appearance modes of the face of the run on. */ | 332 | /* Turn appearance modes of the face of the run on. */ |
| 325 | char_attr = w32_face_attributes (f, face_id); | 333 | char_attr = w32_face_attributes (f, face_id); |
| 326 | 334 | ||
| 327 | while (n > 0) | 335 | if (n == len) |
| 328 | { | 336 | /* This is the last run. */ |
| 329 | /* We use a fixed size (1024 bytes) of conversion buffer. | 337 | coding->mode |= CODING_MODE_LAST_BLOCK; |
| 330 | Usually it is sufficient, but if not, we just repeat the | 338 | conversion_buffer = encode_terminal_code (string, n, coding); |
| 331 | loop. */ | 339 | if (coding->produced > 0) |
| 332 | produced = encode_terminal_code (string, conversion_buffer, | 340 | { |
| 333 | n, conversion_buffer_size, | 341 | /* Set the attribute for these characters. */ |
| 334 | &consumed); | 342 | if (!FillConsoleOutputAttribute (cur_screen, char_attr, |
| 335 | if (produced > 0) | 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, conversion_buffer, |
| 344 | } | 353 | coding->produced, cursor_coords, |
| 345 | 354 | &r)) | |
| 346 | /* Write the characters. */ | 355 | { |
| 347 | if (!WriteConsoleOutputCharacter (cur_screen, conversion_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 | terminal_coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 368 | encode_coding (&terminal_coding, "", conversion_buffer, | ||
| 369 | 0, conversion_buffer_size); | ||
| 370 | if (terminal_coding.produced > 0) | ||
| 371 | { | ||
| 372 | if (!FillConsoleOutputAttribute (cur_screen, char_attr_normal, | ||
| 373 | terminal_coding.produced, | ||
| 374 | cursor_coords, &r)) | ||
| 375 | { | ||
| 376 | printf ("Failed writing console attributes: %d\n", | ||
| 377 | GetLastError ()); | ||
| 378 | fflush (stdout); | ||
| 379 | } | ||
| 380 | |||
| 381 | /* Write the characters. */ | ||
| 382 | if (!WriteConsoleOutputCharacter (cur_screen, conversion_buffer, | ||
| 383 | produced, cursor_coords, &r)) | ||
| 384 | { | ||
| 385 | printf ("Failed writing console characters: %d\n", | ||
| 386 | GetLastError ()); | ||
| 387 | fflush (stdout); | ||
| 388 | } | ||
| 389 | } | ||
| 390 | } | 366 | } |
| 391 | } | 367 | } |
| 392 | 368 | ||