diff options
| author | Kim F. Storm | 2004-08-02 15:06:06 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-08-02 15:06:06 +0000 |
| commit | 361f14bf1184bbac4076cb123d109b034ee11fa4 (patch) | |
| tree | 3e8fb22f49af7006d07f0d07c7cd97b339f8d881 /src | |
| parent | 39b1da208b66d626706391d06715c39bdce7adaa (diff) | |
| download | emacs-361f14bf1184bbac4076cb123d109b034ee11fa4.tar.gz emacs-361f14bf1184bbac4076cb123d109b034ee11fa4.zip | |
(compute_motion): Use actual window width if WIDTH is -1,
properly accounting for continuation glyph on non-window systems.
(Fcompute_motion): Use actual window width if WIDTH is nil, and
actual window width/height if TOPOS is nil, properly accounting for
continuation glyphs on non-window systems, and optional header lines.
(vmotion): Let compute_motion calculate actual window width.
Diffstat (limited to 'src')
| -rw-r--r-- | src/indent.c | 69 |
1 files changed, 48 insertions, 21 deletions
diff --git a/src/indent.c b/src/indent.c index 091c702ac2c..6cb82c18f04 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -1131,6 +1131,9 @@ struct position val_compute_motion; | |||
| 1131 | 1131 | ||
| 1132 | WIDTH is the number of columns available to display text; | 1132 | WIDTH is the number of columns available to display text; |
| 1133 | compute_motion uses this to handle continuation lines and such. | 1133 | compute_motion uses this to handle continuation lines and such. |
| 1134 | If WIDTH is -1, use width of window's text area adjusted for | ||
| 1135 | continuation glyph when needed. | ||
| 1136 | |||
| 1134 | HSCROLL is the number of columns not being displayed at the left | 1137 | HSCROLL is the number of columns not being displayed at the left |
| 1135 | margin; this is usually taken from a window's hscroll member. | 1138 | margin; this is usually taken from a window's hscroll member. |
| 1136 | TAB_OFFSET is the number of columns of the first tab that aren't | 1139 | TAB_OFFSET is the number of columns of the first tab that aren't |
| @@ -1245,6 +1248,17 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1245 | if (tab_width <= 0 || tab_width > 1000) | 1248 | if (tab_width <= 0 || tab_width > 1000) |
| 1246 | tab_width = 8; | 1249 | tab_width = 8; |
| 1247 | 1250 | ||
| 1251 | /* Negative width means use all available text columns. */ | ||
| 1252 | if (width < 0) | ||
| 1253 | { | ||
| 1254 | width = window_box_text_cols (win); | ||
| 1255 | /* We must make room for continuation marks if we don't have fringes. */ | ||
| 1256 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 1257 | if (!FRAME_WINDOW_P (XFRAME (win->frame))) | ||
| 1258 | #endif | ||
| 1259 | width -= 1; | ||
| 1260 | } | ||
| 1261 | |||
| 1248 | immediate_quit = 1; | 1262 | immediate_quit = 1; |
| 1249 | QUIT; | 1263 | QUIT; |
| 1250 | 1264 | ||
| @@ -1368,7 +1382,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, | |||
| 1368 | { | 1382 | { |
| 1369 | if (hscroll | 1383 | if (hscroll |
| 1370 | || (truncate_partial_width_windows | 1384 | || (truncate_partial_width_windows |
| 1371 | && width + 1 < FRAME_COLS (XFRAME (WINDOW_FRAME (win)))) | 1385 | && width < FRAME_COLS (XFRAME (WINDOW_FRAME (win)))) |
| 1372 | || !NILP (current_buffer->truncate_lines)) | 1386 | || !NILP (current_buffer->truncate_lines)) |
| 1373 | { | 1387 | { |
| 1374 | /* Truncating: skip to newline, unless we are already past | 1388 | /* Truncating: skip to newline, unless we are already past |
| @@ -1737,12 +1751,14 @@ assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)-- | |||
| 1737 | to position TO or position TOPOS--another cons of the form (HPOS . VPOS)-- | 1751 | to position TO or position TOPOS--another cons of the form (HPOS . VPOS)-- |
| 1738 | and return the ending buffer position and screen location. | 1752 | and return the ending buffer position and screen location. |
| 1739 | 1753 | ||
| 1754 | If TOPOS is nil, the actual width and height of the window's | ||
| 1755 | text area are used. | ||
| 1756 | |||
| 1740 | There are three additional arguments: | 1757 | There are three additional arguments: |
| 1741 | 1758 | ||
| 1742 | WIDTH is the number of columns available to display text; | 1759 | WIDTH is the number of columns available to display text; |
| 1743 | this affects handling of continuation lines. | 1760 | this affects handling of continuation lines. A value of nil |
| 1744 | This is usually the value returned by `window-width', less one (to allow | 1761 | corresponds to the actual number of available text columns. |
| 1745 | for the continuation glyph). | ||
| 1746 | 1762 | ||
| 1747 | OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET). | 1763 | OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET). |
| 1748 | HSCROLL is the number of columns not being displayed at the left | 1764 | HSCROLL is the number of columns not being displayed at the left |
| @@ -1774,6 +1790,7 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */) | |||
| 1774 | Lisp_Object from, frompos, to, topos; | 1790 | Lisp_Object from, frompos, to, topos; |
| 1775 | Lisp_Object width, offsets, window; | 1791 | Lisp_Object width, offsets, window; |
| 1776 | { | 1792 | { |
| 1793 | struct window *w; | ||
| 1777 | Lisp_Object bufpos, hpos, vpos, prevhpos; | 1794 | Lisp_Object bufpos, hpos, vpos, prevhpos; |
| 1778 | struct position *pos; | 1795 | struct position *pos; |
| 1779 | int hscroll, tab_offset; | 1796 | int hscroll, tab_offset; |
| @@ -1783,10 +1800,15 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */) | |||
| 1783 | CHECK_NUMBER_CAR (frompos); | 1800 | CHECK_NUMBER_CAR (frompos); |
| 1784 | CHECK_NUMBER_CDR (frompos); | 1801 | CHECK_NUMBER_CDR (frompos); |
| 1785 | CHECK_NUMBER_COERCE_MARKER (to); | 1802 | CHECK_NUMBER_COERCE_MARKER (to); |
| 1786 | CHECK_CONS (topos); | 1803 | if (!NILP (topos)) |
| 1787 | CHECK_NUMBER_CAR (topos); | 1804 | { |
| 1788 | CHECK_NUMBER_CDR (topos); | 1805 | CHECK_CONS (topos); |
| 1789 | CHECK_NUMBER (width); | 1806 | CHECK_NUMBER_CAR (topos); |
| 1807 | CHECK_NUMBER_CDR (topos); | ||
| 1808 | } | ||
| 1809 | if (!NILP (width)) | ||
| 1810 | CHECK_NUMBER (width); | ||
| 1811 | |||
| 1790 | if (!NILP (offsets)) | 1812 | if (!NILP (offsets)) |
| 1791 | { | 1813 | { |
| 1792 | CHECK_CONS (offsets); | 1814 | CHECK_CONS (offsets); |
| @@ -1802,6 +1824,7 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */) | |||
| 1802 | window = Fselected_window (); | 1824 | window = Fselected_window (); |
| 1803 | else | 1825 | else |
| 1804 | CHECK_LIVE_WINDOW (window); | 1826 | CHECK_LIVE_WINDOW (window); |
| 1827 | w = XWINDOW (window); | ||
| 1805 | 1828 | ||
| 1806 | if (XINT (from) < BEGV || XINT (from) > ZV) | 1829 | if (XINT (from) < BEGV || XINT (from) > ZV) |
| 1807 | args_out_of_range_3 (from, make_number (BEGV), make_number (ZV)); | 1830 | args_out_of_range_3 (from, make_number (BEGV), make_number (ZV)); |
| @@ -1810,9 +1833,20 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */) | |||
| 1810 | 1833 | ||
| 1811 | pos = compute_motion (XINT (from), XINT (XCDR (frompos)), | 1834 | pos = compute_motion (XINT (from), XINT (XCDR (frompos)), |
| 1812 | XINT (XCAR (frompos)), 0, | 1835 | XINT (XCAR (frompos)), 0, |
| 1813 | XINT (to), XINT (XCDR (topos)), | 1836 | XINT (to), |
| 1814 | XINT (XCAR (topos)), | 1837 | (NILP (topos) |
| 1815 | XINT (width), hscroll, tab_offset, | 1838 | ? window_internal_height (w) |
| 1839 | : XINT (XCDR (topos))), | ||
| 1840 | (NILP (topos) | ||
| 1841 | ? (window_box_text_cols (w) | ||
| 1842 | - ( | ||
| 1843 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 1844 | FRAME_WINDOW_P (XFRAME (w->frame)) ? 0 : | ||
| 1845 | #endif | ||
| 1846 | 1)) | ||
| 1847 | : XINT (XCAR (topos))), | ||
| 1848 | (NILP (width) ? -1 : XINT (width)), | ||
| 1849 | hscroll, tab_offset, | ||
| 1816 | XWINDOW (window)); | 1850 | XWINDOW (window)); |
| 1817 | 1851 | ||
| 1818 | XSETFASTINT (bufpos, pos->bufpos); | 1852 | XSETFASTINT (bufpos, pos->bufpos); |
| @@ -1837,7 +1871,6 @@ vmotion (from, vtarget, w) | |||
| 1837 | register int from, vtarget; | 1871 | register int from, vtarget; |
| 1838 | struct window *w; | 1872 | struct window *w; |
| 1839 | { | 1873 | { |
| 1840 | int width = window_box_text_cols (w); | ||
| 1841 | int hscroll = XINT (w->hscroll); | 1874 | int hscroll = XINT (w->hscroll); |
| 1842 | struct position pos; | 1875 | struct position pos; |
| 1843 | /* vpos is cumulative vertical position, changed as from is changed */ | 1876 | /* vpos is cumulative vertical position, changed as from is changed */ |
| @@ -1858,12 +1891,6 @@ vmotion (from, vtarget, w) | |||
| 1858 | 1891 | ||
| 1859 | XSETWINDOW (window, w); | 1892 | XSETWINDOW (window, w); |
| 1860 | 1893 | ||
| 1861 | /* We must make room for continuation marks if we don't have fringes. */ | ||
| 1862 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 1863 | if (!FRAME_WINDOW_P (XFRAME (w->frame))) | ||
| 1864 | #endif | ||
| 1865 | width -= 1; | ||
| 1866 | |||
| 1867 | /* If the window contains this buffer, use it for getting text properties. | 1894 | /* If the window contains this buffer, use it for getting text properties. |
| 1868 | Otherwise use the current buffer as arg for doing that. */ | 1895 | Otherwise use the current buffer as arg for doing that. */ |
| 1869 | if (EQ (w->buffer, Fcurrent_buffer ())) | 1896 | if (EQ (w->buffer, Fcurrent_buffer ())) |
| @@ -1905,7 +1932,7 @@ vmotion (from, vtarget, w) | |||
| 1905 | 1 << (BITS_PER_SHORT - 1), | 1932 | 1 << (BITS_PER_SHORT - 1), |
| 1906 | /* ... nor HPOS. */ | 1933 | /* ... nor HPOS. */ |
| 1907 | 1 << (BITS_PER_SHORT - 1), | 1934 | 1 << (BITS_PER_SHORT - 1), |
| 1908 | width, hscroll, | 1935 | -1, hscroll, |
| 1909 | /* This compensates for start_hpos | 1936 | /* This compensates for start_hpos |
| 1910 | so that a tab as first character | 1937 | so that a tab as first character |
| 1911 | still occupies 8 columns. */ | 1938 | still occupies 8 columns. */ |
| @@ -1964,7 +1991,7 @@ vmotion (from, vtarget, w) | |||
| 1964 | 1 << (BITS_PER_SHORT - 1), | 1991 | 1 << (BITS_PER_SHORT - 1), |
| 1965 | /* ... nor HPOS. */ | 1992 | /* ... nor HPOS. */ |
| 1966 | 1 << (BITS_PER_SHORT - 1), | 1993 | 1 << (BITS_PER_SHORT - 1), |
| 1967 | width, hscroll, | 1994 | -1, hscroll, |
| 1968 | (XFASTINT (prevline) == BEG ? -start_hpos : 0), | 1995 | (XFASTINT (prevline) == BEG ? -start_hpos : 0), |
| 1969 | w); | 1996 | w); |
| 1970 | did_motion = 1; | 1997 | did_motion = 1; |
| @@ -1978,7 +2005,7 @@ vmotion (from, vtarget, w) | |||
| 1978 | } | 2005 | } |
| 1979 | return compute_motion (from, vpos, pos.hpos, did_motion, | 2006 | return compute_motion (from, vpos, pos.hpos, did_motion, |
| 1980 | ZV, vtarget, - (1 << (BITS_PER_SHORT - 1)), | 2007 | ZV, vtarget, - (1 << (BITS_PER_SHORT - 1)), |
| 1981 | width, hscroll, | 2008 | -1, hscroll, |
| 1982 | pos.tab_offset - (from == BEG ? start_hpos : 0), | 2009 | pos.tab_offset - (from == BEG ? start_hpos : 0), |
| 1983 | w); | 2010 | w); |
| 1984 | } | 2011 | } |