diff options
| author | Kim F. Storm | 2005-01-27 22:33:52 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-01-27 22:33:52 +0000 |
| commit | 2049265a5b75d5d5b4899116c27dfaafdbcd13e3 (patch) | |
| tree | 8293a4ba1d6548fabd8a42330976e13f53a31768 /src | |
| parent | 4d91ce74c7a8eb5a2edca77925f2999bf2acd23d (diff) | |
| download | emacs-2049265a5b75d5d5b4899116c27dfaafdbcd13e3.tar.gz emacs-2049265a5b75d5d5b4899116c27dfaafdbcd13e3.zip | |
(get_phys_cursor_geometry): New function to calculate
phys cursor position and size for hollow cursor. Position is
aligned with get_glyph_string_clip_rect and ensures that a hollow
cursor is shown, even when the actual glyph is not visible.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index e83004d1741..aec14bcadde 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -1876,6 +1876,64 @@ get_glyph_string_clip_rect (s, nr) | |||
| 1876 | #endif | 1876 | #endif |
| 1877 | } | 1877 | } |
| 1878 | 1878 | ||
| 1879 | |||
| 1880 | /* EXPORT: | ||
| 1881 | Return the position and height of the phys cursor in window W. | ||
| 1882 | Set w->phys_cursor_width to width of phys cursor. | ||
| 1883 | */ | ||
| 1884 | |||
| 1885 | int | ||
| 1886 | get_phys_cursor_geometry (w, row, glyph, heightp) | ||
| 1887 | struct window *w; | ||
| 1888 | struct glyph_row *row; | ||
| 1889 | struct glyph *glyph; | ||
| 1890 | int *heightp; | ||
| 1891 | { | ||
| 1892 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | ||
| 1893 | int x, y, wd, h, h0, y0; | ||
| 1894 | |||
| 1895 | /* Compute the width of the rectangle to draw. If on a stretch | ||
| 1896 | glyph, and `x-stretch-block-cursor' is nil, don't draw a | ||
| 1897 | rectangle as wide as the glyph, but use a canonical character | ||
| 1898 | width instead. */ | ||
| 1899 | wd = glyph->pixel_width - 1; | ||
| 1900 | #ifdef HAVE_NTGUI | ||
| 1901 | wd++; /* Why? */ | ||
| 1902 | #endif | ||
| 1903 | if (glyph->type == STRETCH_GLYPH | ||
| 1904 | && !x_stretch_cursor_p) | ||
| 1905 | wd = min (FRAME_COLUMN_WIDTH (f), wd); | ||
| 1906 | w->phys_cursor_width = wd; | ||
| 1907 | |||
| 1908 | y = w->phys_cursor.y + row->ascent - glyph->ascent; | ||
| 1909 | |||
| 1910 | /* If y is below window bottom, ensure that we still see a cursor. */ | ||
| 1911 | h0 = min (FRAME_LINE_HEIGHT (f), row->visible_height); | ||
| 1912 | |||
| 1913 | h = max (h0, glyph->ascent + glyph->descent); | ||
| 1914 | h0 = min (h0, glyph->ascent + glyph->descent); | ||
| 1915 | |||
| 1916 | y0 = WINDOW_HEADER_LINE_HEIGHT (w); | ||
| 1917 | if (y < y0) | ||
| 1918 | { | ||
| 1919 | h = max (h - (y0 - y) + 1, h0); | ||
| 1920 | y = y0 - 1; | ||
| 1921 | } | ||
| 1922 | else | ||
| 1923 | { | ||
| 1924 | y0 = window_text_bottom_y (w) - h0; | ||
| 1925 | if (y > y0) | ||
| 1926 | { | ||
| 1927 | h += y - y0; | ||
| 1928 | y = y0; | ||
| 1929 | } | ||
| 1930 | } | ||
| 1931 | |||
| 1932 | *heightp = h - 1; | ||
| 1933 | return WINDOW_TO_FRAME_PIXEL_Y (w, y); | ||
| 1934 | } | ||
| 1935 | |||
| 1936 | |||
| 1879 | #endif /* HAVE_WINDOW_SYSTEM */ | 1937 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 1880 | 1938 | ||
| 1881 | 1939 | ||