summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2014-09-16 18:53:36 +0300
committerEli Zaretskii <eliz@gnu.org>2014-09-16 18:53:36 +0300
commit534f1f7cb6b25f05472d59b6b4757cb345f29b8d (patch)
tree49780e6748f0b201c6bce106373188354f7e6754
parentc20b4c2de5a8c5ef4ac0655d74dd28c002b7aad3 (diff)
downloademacs-534f1f7cb6b25f05472d59b6b4757cb345f29b8d.tar.gz
Fix display of hollow-box and hbar cursors on r2L lines.
src/xterm.c (x_draw_hollow_cursor, x_draw_bar_cursor): src/w32term.c (x_draw_hollow_cursor, x_draw_bar_cursor): In R2L lines, draw the hollow-box and hbar cursors on the right side of cursor-glyph. Thanks to Martin Rudalics <rudalics@gmx.at> for testing on X.
-rw-r--r--src/ChangeLog6
-rw-r--r--src/w32term.c11
-rw-r--r--src/xterm.c18
3 files changed, 31 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 49ff8efc794..c86f6de1575 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
2014-09-16 Eli Zaretskii <eliz@gnu.org>
+ * xterm.c (x_draw_hollow_cursor, x_draw_bar_cursor):
+ * w32term.c (x_draw_hollow_cursor, x_draw_bar_cursor): In R2L
+ lines, draw the hollow-box and hbar cursors on the right side of
+ cursor-glyph. Thanks to martin rudalics <rudalics@gmx.at> for
+ testing on X.
+
* xterm.c (x_draw_stretch_glyph_string):
* w32term.c (x_draw_stretch_glyph_string): Fix a thinko that
caused the block cursor to disappear on a TAB in R2L lines in
diff --git a/src/w32term.c b/src/w32term.c
index e4813e9e02f..5f15798eeeb 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -5086,6 +5086,12 @@ x_draw_hollow_cursor (struct window *w, struct glyph_row *row)
/* Compute frame-relative coordinates for phys cursor. */
get_phys_cursor_geometry (w, row, cursor_glyph, &left, &top, &h);
rect.left = left;
+ /* When on R2L character, show cursor at the right edge of the
+ glyph, unless the cursor box is as wide as the glyph or wider
+ (the latter happens when x-stretch-cursor is non-nil). */
+ if ((cursor_glyph->resolved_level & 1) != 0
+ && cursor_glyph->pixel_width > w->phys_cursor_width)
+ rect.left += cursor_glyph->pixel_width - w->phys_cursor_width;
rect.top = top;
rect.bottom = rect.top + h;
rect.right = rect.left + w->phys_cursor_width;
@@ -5167,7 +5173,7 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row,
WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
width, row->height);
}
- else
+ else /* HBAR_CURSOR */
{
int dummy_x, dummy_y, dummy_h;
@@ -5178,6 +5184,9 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row,
get_phys_cursor_geometry (w, row, cursor_glyph, &dummy_x,
&dummy_y, &dummy_h);
+ if ((cursor_glyph->resolved_level & 1) != 0
+ && cursor_glyph->pixel_width > w->phys_cursor_width)
+ x += cursor_glyph->pixel_width - w->phys_cursor_width;
w32_fill_area (f, hdc, cursor_color, x,
WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y +
row->height - width),
diff --git a/src/xterm.c b/src/xterm.c
index f426755e401..717df452569 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7126,6 +7126,15 @@ x_draw_hollow_cursor (struct window *w, struct glyph_row *row)
GCForeground, &xgcv);
gc = dpyinfo->scratch_cursor_gc;
+ /* When on R2L character, show cursor at the right edge of the
+ glyph, unless the cursor box is as wide as the glyph or wider
+ (the latter happens when x-stretch-cursor is non-nil). */
+ if ((cursor_glyph->resolved_level & 1) != 0
+ && cursor_glyph->pixel_width > w->phys_cursor_width)
+ {
+ x += cursor_glyph->pixel_width - w->phys_cursor_width;
+ wd -= 1;
+ }
/* Set clipping, draw the rectangle, and reset clipping again. */
x_clip_to_row (w, row, TEXT_AREA, gc);
XDrawRectangle (dpy, FRAME_X_WINDOW (f), gc, x, y, wd, h - 1);
@@ -7211,9 +7220,10 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text
WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
width, row->height);
}
- else
+ else /* HBAR_CURSOR */
{
int dummy_x, dummy_y, dummy_h;
+ int x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
if (width < 0)
width = row->height;
@@ -7223,8 +7233,10 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text
get_phys_cursor_geometry (w, row, cursor_glyph, &dummy_x,
&dummy_y, &dummy_h);
- XFillRectangle (dpy, window, gc,
- WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
+ if ((cursor_glyph->resolved_level & 1) != 0
+ && cursor_glyph->pixel_width > w->phys_cursor_width)
+ x += cursor_glyph->pixel_width - w->phys_cursor_width;
+ XFillRectangle (dpy, window, gc, x,
WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y +
row->height - width),
w->phys_cursor_width, width);