diff options
| author | Andrew Innes | 1999-05-02 10:34:21 +0000 |
|---|---|---|
| committer | Andrew Innes | 1999-05-02 10:34:21 +0000 |
| commit | e12ca9c2ece5970bb6b131f1705d648ebddd7e2b (patch) | |
| tree | 8c923123d4316640d135f19e7f0cb93d5ce43814 /src/w32term.c | |
| parent | 43df7d0b43a076687570eeabbcca97c6220a78e3 (diff) | |
| download | emacs-e12ca9c2ece5970bb6b131f1705d648ebddd7e2b.tar.gz emacs-e12ca9c2ece5970bb6b131f1705d648ebddd7e2b.zip | |
[andrewi]
(dumpglyphs): On Windows NT, do output in Unicode even
for ASCII, if enabled, to avoid memory allocation overhead for
implicit Unicode conversion. Also, recognize that ASCII and
Latin-1 have a trivial conversion to Unicode, so x_2byte_buffer
lready contains the Unicode characters in that case.
(construct_drag_n_drop): Remove old code that was
trashing the drop location.
[jasonr]
(w32_write_glyphs, w32_clear_end_of_line,
w32_clear_frame, clear_cursor, x_display_bar_cursor,
x_display_box_cursor, x_set_window_size): Use phys_cursor_on
field in frame.
(do_line_dance): Updated WRT xterm.c. Use macros where possible.
(dumprectangle): Take into account the width of a left-side
scroll bar.
Diffstat (limited to 'src/w32term.c')
| -rw-r--r-- | src/w32term.c | 122 |
1 files changed, 81 insertions, 41 deletions
diff --git a/src/w32term.c b/src/w32term.c index a6f9425f421..4139ec8eabd 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -26,6 +26,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 26 | #include "fontset.h" | 26 | #include "fontset.h" |
| 27 | #include "blockinput.h" | 27 | #include "blockinput.h" |
| 28 | 28 | ||
| 29 | #include "w32heap.h" | ||
| 29 | #include "w32term.h" | 30 | #include "w32term.h" |
| 30 | #include <shellapi.h> | 31 | #include <shellapi.h> |
| 31 | 32 | ||
| @@ -880,17 +881,6 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 880 | } | 881 | } |
| 881 | } | 882 | } |
| 882 | 883 | ||
| 883 | /* Convert x_2byte_buffer into a buffer of single byte | ||
| 884 | characters - possibly containing MBCS runs. */ | ||
| 885 | bp = x_1byte_buffer; | ||
| 886 | for (i = 0; i < len; i++) | ||
| 887 | { | ||
| 888 | if (BYTE1 (*(x_2byte_buffer + i))) | ||
| 889 | *bp++ = BYTE1 (*(x_2byte_buffer + i)); | ||
| 890 | *bp++ = BYTE2 (*(x_2byte_buffer + i)); | ||
| 891 | } | ||
| 892 | n_chars = bp - x_1byte_buffer; | ||
| 893 | |||
| 894 | fg = face->foreground; | 884 | fg = face->foreground; |
| 895 | bg = face->background; | 885 | bg = face->background; |
| 896 | 886 | ||
| @@ -972,10 +962,54 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 972 | SetBkColor (hdc, bg); | 962 | SetBkColor (hdc, bg); |
| 973 | SetTextAlign (hdc, TA_BASELINE | TA_LEFT); | 963 | SetTextAlign (hdc, TA_BASELINE | TA_LEFT); |
| 974 | 964 | ||
| 975 | if (print_via_unicode) | 965 | /* On NT, where conversion to Unicode has to happen sometime |
| 976 | n_chars = MultiByteToWideChar | 966 | when using the normal ExtTextOut facility, we might as well |
| 977 | (codepage, 0, x_1byte_buffer, n_chars, | 967 | take advantage of x_2byte_buffer which is already allocated, |
| 978 | x_2byte_buffer, FRAME_WINDOW_WIDTH (f)); | 968 | to avoid the allocation overhead for implicit conversion. */ |
| 969 | |||
| 970 | if (!print_via_unicode | ||
| 971 | && codepage == CP_DEFAULT | ||
| 972 | && w32_enable_unicode_output | ||
| 973 | && os_subtype == OS_NT | ||
| 974 | && font && !font->bdf) | ||
| 975 | { | ||
| 976 | print_via_unicode = TRUE; | ||
| 977 | } | ||
| 978 | |||
| 979 | /* Note that we can special-case the conversion to Unicode when | ||
| 980 | the charset is CHARSET_ASCII (an important case) or Latin-1, | ||
| 981 | because x_2byte_buffer in fact already contains the unicode | ||
| 982 | characters. So avoid setting up x_1byte_buffer in that case. */ | ||
| 983 | if (!print_via_unicode | ||
| 984 | || (charset != CHARSET_ASCII && charset != charset_latin_iso8859_1)) | ||
| 985 | { | ||
| 986 | /* Convert x_2byte_buffer into a buffer of single byte | ||
| 987 | characters - possibly containing MBCS runs. */ | ||
| 988 | bp = x_1byte_buffer; | ||
| 989 | for (i = 0; i < len; i++) | ||
| 990 | { | ||
| 991 | if (BYTE1 (*(x_2byte_buffer + i))) | ||
| 992 | *bp++ = BYTE1 (*(x_2byte_buffer + i)); | ||
| 993 | *bp++ = BYTE2 (*(x_2byte_buffer + i)); | ||
| 994 | } | ||
| 995 | n_chars = bp - x_1byte_buffer; | ||
| 996 | } | ||
| 997 | else | ||
| 998 | n_chars = len; | ||
| 999 | |||
| 1000 | if (print_via_unicode | ||
| 1001 | && charset != CHARSET_ASCII && charset != charset_latin_iso8859_1) | ||
| 1002 | { | ||
| 1003 | i = MultiByteToWideChar | ||
| 1004 | (codepage, 0, x_1byte_buffer, n_chars, | ||
| 1005 | x_2byte_buffer, FRAME_WINDOW_WIDTH (f)); | ||
| 1006 | |||
| 1007 | /* Make sure we don't display nothing if conversion fails. */ | ||
| 1008 | if (i == 0) | ||
| 1009 | print_via_unicode = FALSE; | ||
| 1010 | else | ||
| 1011 | n_chars = i; | ||
| 1012 | } | ||
| 979 | 1013 | ||
| 980 | if (font) | 1014 | if (font) |
| 981 | { | 1015 | { |
| @@ -1282,7 +1316,7 @@ w32_write_glyphs (start, len) | |||
| 1282 | if (curs_y == f->phys_cursor_y | 1316 | if (curs_y == f->phys_cursor_y |
| 1283 | && curs_x <= f->phys_cursor_x | 1317 | && curs_x <= f->phys_cursor_x |
| 1284 | && curs_x + len > f->phys_cursor_x) | 1318 | && curs_x + len > f->phys_cursor_x) |
| 1285 | f->phys_cursor_x = -1; | 1319 | f->phys_cursor_on = 0; |
| 1286 | 1320 | ||
| 1287 | if (updating_frame == 0) | 1321 | if (updating_frame == 0) |
| 1288 | { | 1322 | { |
| @@ -1328,7 +1362,7 @@ w32_clear_end_of_line (first_unused) | |||
| 1328 | if (curs_y == f->phys_cursor_y | 1362 | if (curs_y == f->phys_cursor_y |
| 1329 | && curs_x <= f->phys_cursor_x | 1363 | && curs_x <= f->phys_cursor_x |
| 1330 | && f->phys_cursor_x < first_unused) | 1364 | && f->phys_cursor_x < first_unused) |
| 1331 | f->phys_cursor_x = -1; | 1365 | f->phys_cursor_on = 0; |
| 1332 | 1366 | ||
| 1333 | w32_clear_area (f, NULL, | 1367 | w32_clear_area (f, NULL, |
| 1334 | CHAR_TO_PIXEL_COL (f, curs_x), | 1368 | CHAR_TO_PIXEL_COL (f, curs_x), |
| @@ -1347,7 +1381,7 @@ w32_clear_frame () | |||
| 1347 | if (f == 0) | 1381 | if (f == 0) |
| 1348 | f = selected_frame; | 1382 | f = selected_frame; |
| 1349 | 1383 | ||
| 1350 | f->phys_cursor_x = -1; /* Cursor not visible. */ | 1384 | f->phys_cursor_on = 0; /* Cursor not visible. */ |
| 1351 | curs_x = 0; /* Nominal cursor position is top left. */ | 1385 | curs_x = 0; /* Nominal cursor position is top left. */ |
| 1352 | curs_y = 0; | 1386 | curs_y = 0; |
| 1353 | 1387 | ||
| @@ -1507,7 +1541,7 @@ do_line_dance () | |||
| 1507 | abort (); | 1541 | abort (); |
| 1508 | 1542 | ||
| 1509 | ht = f->height; | 1543 | ht = f->height; |
| 1510 | intborder = f->output_data.w32->internal_border_width; | 1544 | intborder = CHAR_TO_PIXEL_COL (f, FRAME_LEFT_SCROLL_BAR_WIDTH (f)); |
| 1511 | 1545 | ||
| 1512 | x_display_cursor (updating_frame, 0); | 1546 | x_display_cursor (updating_frame, 0); |
| 1513 | 1547 | ||
| @@ -1521,8 +1555,8 @@ do_line_dance () | |||
| 1521 | /* Copy [i,j) upward from [i+distance, j+distance) */ | 1555 | /* Copy [i,j) upward from [i+distance, j+distance) */ |
| 1522 | BitBlt (hdc, | 1556 | BitBlt (hdc, |
| 1523 | intborder, CHAR_TO_PIXEL_ROW (f, i+distance), | 1557 | intborder, CHAR_TO_PIXEL_ROW (f, i+distance), |
| 1524 | f->width * FONT_WIDTH (f->output_data.w32->font), | 1558 | FRAME_WINDOW_WIDTH (f) * FONT_WIDTH (FRAME_FONT (f)), |
| 1525 | (j-i) * f->output_data.w32->line_height, | 1559 | (j-i) * FRAME_LINE_HEIGHT (f), |
| 1526 | hdc, | 1560 | hdc, |
| 1527 | intborder, CHAR_TO_PIXEL_ROW (f, i), | 1561 | intborder, CHAR_TO_PIXEL_ROW (f, i), |
| 1528 | SRCCOPY); | 1562 | SRCCOPY); |
| @@ -1537,8 +1571,8 @@ do_line_dance () | |||
| 1537 | /* Copy (j, i] downward from (j+distance, i+distance] */ | 1571 | /* Copy (j, i] downward from (j+distance, i+distance] */ |
| 1538 | BitBlt (hdc, | 1572 | BitBlt (hdc, |
| 1539 | intborder, CHAR_TO_PIXEL_ROW (f, j+1+distance), | 1573 | intborder, CHAR_TO_PIXEL_ROW (f, j+1+distance), |
| 1540 | f->width * FONT_WIDTH (f->output_data.w32->font), | 1574 | FRAME_WINDOW_WIDTH (f) * FONT_WIDTH (FRAME_FONT (f)), |
| 1541 | (i-j) * f->output_data.w32->line_height, | 1575 | (i-j) * FRAME_LINE_HEIGHT (f), |
| 1542 | hdc, | 1576 | hdc, |
| 1543 | intborder, CHAR_TO_PIXEL_ROW (f, j+1), | 1577 | intborder, CHAR_TO_PIXEL_ROW (f, j+1), |
| 1544 | SRCCOPY); | 1578 | SRCCOPY); |
| @@ -1553,8 +1587,8 @@ do_line_dance () | |||
| 1553 | w32_clear_area (f, hdc, | 1587 | w32_clear_area (f, hdc, |
| 1554 | intborder, | 1588 | intborder, |
| 1555 | CHAR_TO_PIXEL_ROW (f, i), | 1589 | CHAR_TO_PIXEL_ROW (f, i), |
| 1556 | f->width * FONT_WIDTH (f->output_data.w32->font), | 1590 | FRAME_WINDOW_WIDTH (f) * FONT_WIDTH (FRAME_FONT (f)), |
| 1557 | (j-i) * f->output_data.w32->line_height); | 1591 | (j-i) * FRAME_LINE_HEIGHT (f)); |
| 1558 | i = j-1; | 1592 | i = j-1; |
| 1559 | } | 1593 | } |
| 1560 | line_dance_in_progress = 0; | 1594 | line_dance_in_progress = 0; |
| @@ -1598,12 +1632,12 @@ dumprectangle (f, left, top, cols, rows) | |||
| 1598 | right = PIXEL_TO_CHAR_COL (f, right); | 1632 | right = PIXEL_TO_CHAR_COL (f, right); |
| 1599 | 1633 | ||
| 1600 | /* Clip the rectangle to what can be visible. */ | 1634 | /* Clip the rectangle to what can be visible. */ |
| 1601 | if (left < 0) | 1635 | if (left < FRAME_LEFT_SCROLL_BAR_WIDTH (f)) |
| 1602 | left = 0; | 1636 | left = FRAME_LEFT_SCROLL_BAR_WIDTH (f); |
| 1603 | if (top < 0) | 1637 | if (top < 0) |
| 1604 | top = 0; | 1638 | top = 0; |
| 1605 | if (right > f->width) | 1639 | if (right > f->width + FRAME_LEFT_SCROLL_BAR_WIDTH (f)) |
| 1606 | right = f->width; | 1640 | right = f->width + FRAME_LEFT_SCROLL_BAR_WIDTH (f); |
| 1607 | if (bottom > f->height) | 1641 | if (bottom > f->height) |
| 1608 | bottom = f->height; | 1642 | bottom = f->height; |
| 1609 | 1643 | ||
| @@ -1975,9 +2009,12 @@ construct_drag_n_drop (result, msg, f) | |||
| 1975 | hdrop = (HDROP) msg->msg.wParam; | 2009 | hdrop = (HDROP) msg->msg.wParam; |
| 1976 | DragQueryPoint (hdrop, &p); | 2010 | DragQueryPoint (hdrop, &p); |
| 1977 | 2011 | ||
| 2012 | #if 0 | ||
| 1978 | p.x = LOWORD (msg->msg.lParam); | 2013 | p.x = LOWORD (msg->msg.lParam); |
| 1979 | p.y = HIWORD (msg->msg.lParam); | 2014 | p.y = HIWORD (msg->msg.lParam); |
| 1980 | ScreenToClient (msg->msg.hwnd, &p); | 2015 | ScreenToClient (msg->msg.hwnd, &p); |
| 2016 | #endif | ||
| 2017 | |||
| 1981 | XSETINT (result->x, p.x); | 2018 | XSETINT (result->x, p.x); |
| 1982 | XSETINT (result->y, p.y); | 2019 | XSETINT (result->y, p.y); |
| 1983 | 2020 | ||
| @@ -3911,11 +3948,11 @@ clear_cursor (f) | |||
| 3911 | struct frame *f; | 3948 | struct frame *f; |
| 3912 | { | 3949 | { |
| 3913 | if (! FRAME_VISIBLE_P (f) | 3950 | if (! FRAME_VISIBLE_P (f) |
| 3914 | || f->phys_cursor_x < 0) | 3951 | || !f->phys_cursor_on) |
| 3915 | return; | 3952 | return; |
| 3916 | 3953 | ||
| 3917 | x_display_cursor (f, 0); | 3954 | x_display_cursor (f, 0); |
| 3918 | f->phys_cursor_x = -1; | 3955 | f->phys_cursor_on = 0; |
| 3919 | } | 3956 | } |
| 3920 | 3957 | ||
| 3921 | /* Redraw the glyph at ROW, COLUMN on frame F, in the style | 3958 | /* Redraw the glyph at ROW, COLUMN on frame F, in the style |
| @@ -3948,11 +3985,11 @@ x_display_bar_cursor (f, on) | |||
| 3948 | if (! FRAME_VISIBLE_P (f) || FRAME_GARBAGED_P (f)) | 3985 | if (! FRAME_VISIBLE_P (f) || FRAME_GARBAGED_P (f)) |
| 3949 | return; | 3986 | return; |
| 3950 | 3987 | ||
| 3951 | if (! on && f->phys_cursor_x < 0) | 3988 | if (! on && ! f->phys_cursor_on) |
| 3952 | return; | 3989 | return; |
| 3953 | 3990 | ||
| 3954 | /* If there is anything wrong with the current cursor state, remove it. */ | 3991 | /* If there is anything wrong with the current cursor state, remove it. */ |
| 3955 | if (f->phys_cursor_x >= 0 | 3992 | if (f->phys_cursor_on |
| 3956 | && (!on | 3993 | && (!on |
| 3957 | || f->phys_cursor_x != curs_x | 3994 | || f->phys_cursor_x != curs_x |
| 3958 | || f->phys_cursor_y != curs_y | 3995 | || f->phys_cursor_y != curs_y |
| @@ -3962,12 +3999,12 @@ x_display_bar_cursor (f, on) | |||
| 3962 | x_draw_single_glyph (f, f->phys_cursor_y, f->phys_cursor_x, | 3999 | x_draw_single_glyph (f, f->phys_cursor_y, f->phys_cursor_x, |
| 3963 | f->phys_cursor_glyph, | 4000 | f->phys_cursor_glyph, |
| 3964 | current_glyphs->highlight[f->phys_cursor_y]); | 4001 | current_glyphs->highlight[f->phys_cursor_y]); |
| 3965 | f->phys_cursor_x = -1; | 4002 | f->phys_cursor_on = 0; |
| 3966 | } | 4003 | } |
| 3967 | 4004 | ||
| 3968 | /* If we now need a cursor in the new place or in the new form, do it so. */ | 4005 | /* If we now need a cursor in the new place or in the new form, do it so. */ |
| 3969 | if (on | 4006 | if (on |
| 3970 | && (f->phys_cursor_x < 0 | 4007 | && (! f->phys_cursor_on |
| 3971 | || (f->output_data.w32->current_cursor != bar_cursor))) | 4008 | || (f->output_data.w32->current_cursor != bar_cursor))) |
| 3972 | { | 4009 | { |
| 3973 | f->phys_cursor_glyph | 4010 | f->phys_cursor_glyph |
| @@ -3983,6 +4020,7 @@ x_display_bar_cursor (f, on) | |||
| 3983 | 4020 | ||
| 3984 | f->phys_cursor_x = curs_x; | 4021 | f->phys_cursor_x = curs_x; |
| 3985 | f->phys_cursor_y = curs_y; | 4022 | f->phys_cursor_y = curs_y; |
| 4023 | f->phys_cursor_on = 1; | ||
| 3986 | 4024 | ||
| 3987 | f->output_data.w32->current_cursor = bar_cursor; | 4025 | f->output_data.w32->current_cursor = bar_cursor; |
| 3988 | } | 4026 | } |
| @@ -4007,14 +4045,14 @@ x_display_box_cursor (f, on) | |||
| 4007 | return; | 4045 | return; |
| 4008 | 4046 | ||
| 4009 | /* If cursor is off and we want it off, return quickly. */ | 4047 | /* If cursor is off and we want it off, return quickly. */ |
| 4010 | if (!on && f->phys_cursor_x < 0) | 4048 | if (!on && ! f->phys_cursor_on) |
| 4011 | return; | 4049 | return; |
| 4012 | 4050 | ||
| 4013 | /* If cursor is currently being shown and we don't want it to be | 4051 | /* If cursor is currently being shown and we don't want it to be |
| 4014 | or it is in the wrong place, | 4052 | or it is in the wrong place, |
| 4015 | or we want a hollow box and it's not so, (pout!) | 4053 | or we want a hollow box and it's not so, (pout!) |
| 4016 | erase it. */ | 4054 | erase it. */ |
| 4017 | if (f->phys_cursor_x >= 0 | 4055 | if (f->phys_cursor_on |
| 4018 | && (!on | 4056 | && (!on |
| 4019 | || f->phys_cursor_x != curs_x | 4057 | || f->phys_cursor_x != curs_x |
| 4020 | || f->phys_cursor_y != curs_y | 4058 | || f->phys_cursor_y != curs_y |
| @@ -4053,14 +4091,14 @@ x_display_box_cursor (f, on) | |||
| 4053 | (mouse_face_here | 4091 | (mouse_face_here |
| 4054 | ? 3 | 4092 | ? 3 |
| 4055 | : current_glyphs->highlight[f->phys_cursor_y])); | 4093 | : current_glyphs->highlight[f->phys_cursor_y])); |
| 4056 | f->phys_cursor_x = -1; | 4094 | f->phys_cursor_on = 0; |
| 4057 | } | 4095 | } |
| 4058 | 4096 | ||
| 4059 | /* If we want to show a cursor, | 4097 | /* If we want to show a cursor, |
| 4060 | or we want a box cursor and it's not so, | 4098 | or we want a box cursor and it's not so, |
| 4061 | write it in the right place. */ | 4099 | write it in the right place. */ |
| 4062 | if (on | 4100 | if (on |
| 4063 | && (f->phys_cursor_x < 0 | 4101 | && (! f->phys_cursor_on |
| 4064 | || (f->output_data.w32->current_cursor != filled_box_cursor | 4102 | || (f->output_data.w32->current_cursor != filled_box_cursor |
| 4065 | && f == FRAME_W32_DISPLAY_INFO (f)->w32_highlight_frame))) | 4103 | && f == FRAME_W32_DISPLAY_INFO (f)->w32_highlight_frame))) |
| 4066 | { | 4104 | { |
| @@ -4083,6 +4121,7 @@ x_display_box_cursor (f, on) | |||
| 4083 | 4121 | ||
| 4084 | f->phys_cursor_x = curs_x; | 4122 | f->phys_cursor_x = curs_x; |
| 4085 | f->phys_cursor_y = curs_y; | 4123 | f->phys_cursor_y = curs_y; |
| 4124 | f->phys_cursor_on = 1; | ||
| 4086 | } | 4125 | } |
| 4087 | } | 4126 | } |
| 4088 | 4127 | ||
| @@ -4388,8 +4427,9 @@ x_set_window_size (f, change_gravity, cols, rows) | |||
| 4388 | if (f->phys_cursor_y >= rows | 4427 | if (f->phys_cursor_y >= rows |
| 4389 | || f->phys_cursor_x >= cols) | 4428 | || f->phys_cursor_x >= cols) |
| 4390 | { | 4429 | { |
| 4391 | f->phys_cursor_x = -1; | 4430 | f->phys_cursor_x = 0; |
| 4392 | f->phys_cursor_y = -1; | 4431 | f->phys_cursor_y = 0; |
| 4432 | f->phys_cursor_on = 0; | ||
| 4393 | } | 4433 | } |
| 4394 | 4434 | ||
| 4395 | /* Clear out any recollection of where the mouse highlighting was, | 4435 | /* Clear out any recollection of where the mouse highlighting was, |