diff options
| author | Eli Zaretskii | 2012-05-26 12:31:59 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2012-05-26 12:31:59 +0300 |
| commit | eb3f6f01890259b11fa72b21aee4bf900abd18a9 (patch) | |
| tree | 5e74acd317fd96956f2cbdb8839689df14e779b8 /src | |
| parent | 4446092afffb588fec435785b9c7bfa4acac20d1 (diff) | |
| download | emacs-eb3f6f01890259b11fa72b21aee4bf900abd18a9.tar.gz emacs-eb3f6f01890259b11fa72b21aee4bf900abd18a9.zip | |
Support mouse highlight on w32 text-mode frames.
src/xdisp.c (draw_row_with_mouse_face): Call
tty_draw_row_with_mouse_face for WINDOWSNT as well.
src/w32inevt.c (mouse_moved_to): When the mouse moves, call
note_mouse_highlight.
src/w32console.c: Include window.h.
(w32con_write_glyphs_with_face, tty_draw_row_with_mouse_face): New
functions.
(initialize_w32_display): Initialize mouse-highlight data.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/w32console.c | 89 | ||||
| -rw-r--r-- | src/w32inevt.c | 14 | ||||
| -rw-r--r-- | src/xdisp.c | 2 |
4 files changed, 113 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index acae070f068..173ed04da73 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,19 @@ | |||
| 1 | 2012-05-26 Eli Zaretskii <eliz@gnu.org> | 1 | 2012-05-26 Eli Zaretskii <eliz@gnu.org> |
| 2 | 2 | ||
| 3 | Support mouse highlight on w32 text-mode frames. | ||
| 4 | * xdisp.c (draw_row_with_mouse_face): Call | ||
| 5 | tty_draw_row_with_mouse_face for WINDOWSNT as well. | ||
| 6 | |||
| 7 | * w32inevt.c (mouse_moved_to): When the mouse moves, call | ||
| 8 | note_mouse_highlight. | ||
| 9 | |||
| 10 | * w32console.c: Include window.h. | ||
| 11 | (w32con_write_glyphs_with_face, tty_draw_row_with_mouse_face): New | ||
| 12 | functions. | ||
| 13 | (initialize_w32_display): Initialize mouse-highlight data. | ||
| 14 | |||
| 15 | 2012-05-26 Eli Zaretskii <eliz@gnu.org> | ||
| 16 | |||
| 3 | * bidi.c (bidi_mirror_char): Revert last change: an int is | 17 | * bidi.c (bidi_mirror_char): Revert last change: an int is |
| 4 | definitely wide enough here. | 18 | definitely wide enough here. |
| 5 | 19 | ||
diff --git a/src/w32console.c b/src/w32console.c index e8b0f621b4f..22f329e239d 100644 --- a/src/w32console.c +++ b/src/w32console.c | |||
| @@ -33,6 +33,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 33 | #include "coding.h" | 33 | #include "coding.h" |
| 34 | #include "disptab.h" | 34 | #include "disptab.h" |
| 35 | #include "frame.h" | 35 | #include "frame.h" |
| 36 | #include "window.h" | ||
| 36 | #include "termhooks.h" | 37 | #include "termhooks.h" |
| 37 | #include "termchar.h" | 38 | #include "termchar.h" |
| 38 | #include "dispextern.h" | 39 | #include "dispextern.h" |
| @@ -339,6 +340,84 @@ w32con_write_glyphs (struct frame *f, register struct glyph *string, | |||
| 339 | } | 340 | } |
| 340 | } | 341 | } |
| 341 | 342 | ||
| 343 | /* Used for mouse highlight. */ | ||
| 344 | static void | ||
| 345 | w32con_write_glyphs_with_face (struct frame *f, register int x, register int y, | ||
| 346 | register struct glyph *string, register int len, | ||
| 347 | register int face_id) | ||
| 348 | { | ||
| 349 | unsigned char *conversion_buffer; | ||
| 350 | struct coding_system *coding; | ||
| 351 | |||
| 352 | if (len <= 0) | ||
| 353 | return; | ||
| 354 | |||
| 355 | /* If terminal_coding does any conversion, use it, otherwise use | ||
| 356 | safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here | ||
| 357 | because it always return 1 if the member src_multibyte is 1. */ | ||
| 358 | coding = (FRAME_TERMINAL_CODING (f)->common_flags & CODING_REQUIRE_ENCODING_MASK | ||
| 359 | ? FRAME_TERMINAL_CODING (f) : &safe_terminal_coding); | ||
| 360 | /* We are going to write the entire block of glyphs in one go, as | ||
| 361 | they all have the same face. So this _is_ the last block. */ | ||
| 362 | coding->mode |= CODING_MODE_LAST_BLOCK; | ||
| 363 | |||
| 364 | conversion_buffer = encode_terminal_code (string, len, coding); | ||
| 365 | if (coding->produced > 0) | ||
| 366 | { | ||
| 367 | DWORD filled, written; | ||
| 368 | /* Compute the character attributes corresponding to the face. */ | ||
| 369 | DWORD char_attr = w32_face_attributes (f, face_id); | ||
| 370 | COORD start_coords; | ||
| 371 | |||
| 372 | start_coords.X = x; | ||
| 373 | start_coords.Y = y; | ||
| 374 | /* Set the attribute for these characters. */ | ||
| 375 | if (!FillConsoleOutputAttribute (cur_screen, char_attr, | ||
| 376 | coding->produced, start_coords, | ||
| 377 | &filled)) | ||
| 378 | DebPrint (("Failed writing console attributes: %d\n", GetLastError ())); | ||
| 379 | else | ||
| 380 | { | ||
| 381 | /* Write the characters. */ | ||
| 382 | if (!WriteConsoleOutputCharacter (cur_screen, conversion_buffer, | ||
| 383 | filled, start_coords, &written)) | ||
| 384 | DebPrint (("Failed writing console characters: %d\n", | ||
| 385 | GetLastError ())); | ||
| 386 | } | ||
| 387 | } | ||
| 388 | } | ||
| 389 | |||
| 390 | /* Implementation of draw_row_with_mouse_face for W32 console. */ | ||
| 391 | void | ||
| 392 | tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row, | ||
| 393 | int start_hpos, int end_hpos, | ||
| 394 | enum draw_glyphs_face draw) | ||
| 395 | { | ||
| 396 | int nglyphs = end_hpos - start_hpos; | ||
| 397 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | ||
| 398 | struct tty_display_info *tty = FRAME_TTY (f); | ||
| 399 | int face_id = tty->mouse_highlight.mouse_face_face_id; | ||
| 400 | int pos_x, pos_y; | ||
| 401 | |||
| 402 | if (end_hpos >= row->used[TEXT_AREA]) | ||
| 403 | nglyphs = row->used[TEXT_AREA] - start_hpos; | ||
| 404 | |||
| 405 | pos_y = row->y + WINDOW_TOP_EDGE_Y (w); | ||
| 406 | pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos + WINDOW_LEFT_EDGE_X (w); | ||
| 407 | |||
| 408 | if (draw == DRAW_MOUSE_FACE) | ||
| 409 | w32con_write_glyphs_with_face (f, pos_x, pos_y, | ||
| 410 | row->glyphs[TEXT_AREA] + start_hpos, | ||
| 411 | nglyphs, face_id); | ||
| 412 | else if (draw == DRAW_NORMAL_TEXT) | ||
| 413 | { | ||
| 414 | COORD save_coords = cursor_coords; | ||
| 415 | |||
| 416 | w32con_move_cursor (f, pos_y, pos_x); | ||
| 417 | write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs); | ||
| 418 | w32con_move_cursor (f, save_coords.Y, save_coords.X); | ||
| 419 | } | ||
| 420 | } | ||
| 342 | 421 | ||
| 343 | static void | 422 | static void |
| 344 | w32con_delete_glyphs (struct frame *f, int n) | 423 | w32con_delete_glyphs (struct frame *f, int n) |
| @@ -570,6 +649,7 @@ void | |||
| 570 | initialize_w32_display (struct terminal *term) | 649 | initialize_w32_display (struct terminal *term) |
| 571 | { | 650 | { |
| 572 | CONSOLE_SCREEN_BUFFER_INFO info; | 651 | CONSOLE_SCREEN_BUFFER_INFO info; |
| 652 | Mouse_HLInfo *hlinfo; | ||
| 573 | 653 | ||
| 574 | term->rif = 0; /* No window based redisplay on the console. */ | 654 | term->rif = 0; /* No window based redisplay on the console. */ |
| 575 | term->cursor_to_hook = w32con_move_cursor; | 655 | term->cursor_to_hook = w32con_move_cursor; |
| @@ -600,6 +680,15 @@ initialize_w32_display (struct terminal *term) | |||
| 600 | term->judge_scroll_bars_hook = 0; | 680 | term->judge_scroll_bars_hook = 0; |
| 601 | term->frame_up_to_date_hook = 0; | 681 | term->frame_up_to_date_hook = 0; |
| 602 | 682 | ||
| 683 | /* Initialize the mouse-highlight data. */ | ||
| 684 | hlinfo = &term->display_info.tty->mouse_highlight; | ||
| 685 | hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; | ||
| 686 | hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; | ||
| 687 | hlinfo->mouse_face_face_id = DEFAULT_FACE_ID; | ||
| 688 | hlinfo->mouse_face_mouse_frame = NULL; | ||
| 689 | hlinfo->mouse_face_window = Qnil; | ||
| 690 | hlinfo->mouse_face_hidden = 0; | ||
| 691 | |||
| 603 | /* Initialize interrupt_handle. */ | 692 | /* Initialize interrupt_handle. */ |
| 604 | init_crit (); | 693 | init_crit (); |
| 605 | 694 | ||
diff --git a/src/w32inevt.c b/src/w32inevt.c index e7a8bf629d6..cd4a8dd1d49 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c | |||
| @@ -562,14 +562,17 @@ w32_console_mouse_position (FRAME_PTR *f, | |||
| 562 | UNBLOCK_INPUT; | 562 | UNBLOCK_INPUT; |
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | /* Remember mouse motion and notify emacs. */ | 565 | /* Remember mouse motion, notify emacs, and trigger mouse highlight. */ |
| 566 | static void | 566 | static void |
| 567 | mouse_moved_to (int x, int y) | 567 | mouse_moved_to (int x, int y) |
| 568 | { | 568 | { |
| 569 | /* If we're in the same place, ignore it */ | 569 | /* If we're in the same place, ignore it. */ |
| 570 | if (x != movement_pos.X || y != movement_pos.Y) | 570 | if (x != movement_pos.X || y != movement_pos.Y) |
| 571 | { | 571 | { |
| 572 | SELECTED_FRAME ()->mouse_moved = 1; | 572 | FRAME_PTR f = SELECTED_FRAME (); |
| 573 | |||
| 574 | f->mouse_moved = 1; | ||
| 575 | note_mouse_highlight (f, x, y); | ||
| 573 | movement_pos.X = x; | 576 | movement_pos.X = x; |
| 574 | movement_pos.Y = y; | 577 | movement_pos.Y = y; |
| 575 | movement_time = GetTickCount (); | 578 | movement_time = GetTickCount (); |
| @@ -604,8 +607,9 @@ do_mouse_event (MOUSE_EVENT_RECORD *event, | |||
| 604 | 607 | ||
| 605 | if (event->dwEventFlags == MOUSE_MOVED) | 608 | if (event->dwEventFlags == MOUSE_MOVED) |
| 606 | { | 609 | { |
| 607 | /* For movement events we just note that the mouse has moved | 610 | /* For movement events we just note that the mouse has moved so |
| 608 | so that emacs will generate drag events. */ | 611 | that emacs will generate drag events and perhaps trigger |
| 612 | mouse highlighting. */ | ||
| 609 | mouse_moved_to (event->dwMousePosition.X, event->dwMousePosition.Y); | 613 | mouse_moved_to (event->dwMousePosition.X, event->dwMousePosition.Y); |
| 610 | return 0; | 614 | return 0; |
| 611 | } | 615 | } |
diff --git a/src/xdisp.c b/src/xdisp.c index 0a25eab1cbc..794355af153 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -25832,7 +25832,7 @@ draw_row_with_mouse_face (struct window *w, int start_x, struct glyph_row *row, | |||
| 25832 | return; | 25832 | return; |
| 25833 | } | 25833 | } |
| 25834 | #endif | 25834 | #endif |
| 25835 | #if defined (HAVE_GPM) || defined (MSDOS) | 25835 | #if defined (HAVE_GPM) || defined (MSDOS) || defined (WINDOWSNT) |
| 25836 | tty_draw_row_with_mouse_face (w, row, start_hpos, end_hpos, draw); | 25836 | tty_draw_row_with_mouse_face (w, row, start_hpos, end_hpos, draw); |
| 25837 | #endif | 25837 | #endif |
| 25838 | } | 25838 | } |