Mercurial > vim
comparison src/screen.c @ 36:125e80798a85 v7.0021
updated for version 7.0021
author | vimboss |
---|---|
date | Thu, 09 Dec 2004 21:34:53 +0000 |
parents | f6033dcbaf31 |
children | 410fa1a31baf |
comparison
equal
deleted
inserted
replaced
35:8f3a526c2fe1 | 36:125e80798a85 |
---|---|
108 buf_T *buf; /* the buffer to search for a match */ | 108 buf_T *buf; /* the buffer to search for a match */ |
109 linenr_T lnum; /* the line to search for a match */ | 109 linenr_T lnum; /* the line to search for a match */ |
110 int attr; /* attributes to be used for a match */ | 110 int attr; /* attributes to be used for a match */ |
111 int attr_cur; /* attributes currently active in win_line() */ | 111 int attr_cur; /* attributes currently active in win_line() */ |
112 linenr_T first_lnum; /* first lnum to search for multi-line pat */ | 112 linenr_T first_lnum; /* first lnum to search for multi-line pat */ |
113 char_u *startp; /* in win_line() points to char where HL starts */ | 113 colnr_T startcol; /* in win_line() points to char where HL starts */ |
114 char_u *endp; /* in win_line() points to char where HL ends */ | 114 colnr_T endcol; /* in win_line() points to char where HL ends */ |
115 } match_T; | 115 } match_T; |
116 | 116 |
117 static match_T search_hl; /* used for 'hlsearch' highlight matching */ | 117 static match_T search_hl; /* used for 'hlsearch' highlight matching */ |
118 static match_T match_hl; /* used for ":match" highlight matching */ | 118 static match_T match_hl; /* used for ":match" highlight matching */ |
119 #endif | 119 #endif |
942 } | 942 } |
943 #endif | 943 #endif |
944 | 944 |
945 /* When a change starts above w_topline and the end is below | 945 /* When a change starts above w_topline and the end is below |
946 * w_topline, start redrawing at w_topline. | 946 * w_topline, start redrawing at w_topline. |
947 * If the end of the change is above w_topline: do like no changes was | 947 * If the end of the change is above w_topline: do like no change was |
948 * maded, but redraw the first line to find changes in syntax. */ | 948 * made, but redraw the first line to find changes in syntax. */ |
949 if (mod_top != 0 && mod_top < wp->w_topline) | 949 if (mod_top != 0 && mod_top < wp->w_topline) |
950 { | 950 { |
951 if (mod_bot > wp->w_topline) | 951 if (mod_bot > wp->w_topline) |
952 mod_top = wp->w_topline; | 952 mod_top = wp->w_topline; |
953 #ifdef FEAT_SYN_HL | 953 #ifdef FEAT_SYN_HL |
954 else if (syntax_present(buf)) | 954 else if (syntax_present(buf)) |
955 top_end = 1; | 955 top_end = 1; |
956 #endif | 956 #endif |
957 } | 957 } |
958 | |
959 /* When line numbers are displayed need to redraw all lines below | |
960 * inserted/deleted lines. */ | |
961 if (mod_top != 0 && buf->b_mod_xlines != 0 && wp->w_p_nu) | |
962 mod_bot = MAXLNUM; | |
958 } | 963 } |
959 | 964 |
960 /* | 965 /* |
961 * When only displaying the lines at the top, set top_end. Used when | 966 * When only displaying the lines at the top, set top_end. Used when |
962 * window has scrolled down for msg_scrolled. | 967 * window has scrolled down for msg_scrolled. |
1623 wp->w_lines[i--].wl_valid = FALSE; | 1628 wp->w_lines[i--].wl_valid = FALSE; |
1624 } | 1629 } |
1625 } | 1630 } |
1626 } | 1631 } |
1627 } | 1632 } |
1628 | |
1629 /* When inserting or deleting lines and 'number' is set: | |
1630 * Redraw all lines below the change to update the line | |
1631 * numbers. */ | |
1632 if (buf->b_mod_xlines != 0 && wp->w_p_nu) | |
1633 bot_start = 0; | |
1634 } | 1633 } |
1635 | 1634 |
1636 #ifdef FEAT_FOLDING | 1635 #ifdef FEAT_FOLDING |
1637 /* | 1636 /* |
1638 * When lines are folded, display one line for all of them. | 1637 * When lines are folded, display one line for all of them. |
2640 ) | 2639 ) |
2641 { | 2640 { |
2642 fromcol = -10; | 2641 fromcol = -10; |
2643 tocol = MAXCOL; | 2642 tocol = MAXCOL; |
2644 } | 2643 } |
2644 else if (bot->col == MAXCOL) | |
2645 tocol = MAXCOL; | |
2645 else | 2646 else |
2646 { | 2647 { |
2647 pos = *bot; | 2648 pos = *bot; |
2648 if (*p_sel == 'e') | 2649 if (*p_sel == 'e') |
2649 getvvcol(wp, &pos, (colnr_T *)&tocol, NULL, NULL); | 2650 getvvcol(wp, &pos, (colnr_T *)&tocol, NULL, NULL); |
2850 * Do this for both search_hl and match_hl. | 2851 * Do this for both search_hl and match_hl. |
2851 */ | 2852 */ |
2852 shl = &search_hl; | 2853 shl = &search_hl; |
2853 for (;;) | 2854 for (;;) |
2854 { | 2855 { |
2855 shl->startp = NULL; | 2856 shl->startcol = MAXCOL; |
2856 shl->endp = NULL; | 2857 shl->endcol = MAXCOL; |
2857 shl->attr_cur = 0; | 2858 shl->attr_cur = 0; |
2858 if (shl->rm.regprog != NULL) | 2859 if (shl->rm.regprog != NULL) |
2859 { | 2860 { |
2860 v = (long)(ptr - line); | 2861 v = (long)(ptr - line); |
2861 next_search_hl(wp, shl, lnum, (colnr_T)v); | 2862 next_search_hl(wp, shl, lnum, (colnr_T)v); |
2866 ptr = line + v; | 2867 ptr = line + v; |
2867 | 2868 |
2868 if (shl->lnum != 0 && shl->lnum <= lnum) | 2869 if (shl->lnum != 0 && shl->lnum <= lnum) |
2869 { | 2870 { |
2870 if (shl->lnum == lnum) | 2871 if (shl->lnum == lnum) |
2871 shl->startp = line + shl->rm.startpos[0].col; | 2872 shl->startcol = shl->rm.startpos[0].col; |
2872 else | 2873 else |
2873 shl->startp = line; | 2874 shl->startcol = 0; |
2874 if (lnum == shl->lnum + shl->rm.endpos[0].lnum | 2875 if (lnum == shl->lnum + shl->rm.endpos[0].lnum |
2875 - shl->rm.startpos[0].lnum) | 2876 - shl->rm.startpos[0].lnum) |
2876 shl->endp = line + shl->rm.endpos[0].col; | 2877 shl->endcol = shl->rm.endpos[0].col; |
2877 else | 2878 else |
2878 shl->endp = line + MAXCOL; | 2879 shl->endcol = MAXCOL; |
2879 /* Highlight one character for an empty match. */ | 2880 /* Highlight one character for an empty match. */ |
2880 if (shl->startp == shl->endp) | 2881 if (shl->startcol == shl->endcol) |
2881 { | 2882 { |
2882 #ifdef FEAT_MBYTE | 2883 #ifdef FEAT_MBYTE |
2883 if (has_mbyte && *shl->endp != NUL) | 2884 if (has_mbyte && line[shl->endcol] != NUL) |
2884 shl->endp += (*mb_ptr2len_check)(shl->endp); | 2885 shl->endcol += (*mb_ptr2len_check)(line + shl->endcol); |
2885 else | 2886 else |
2886 #endif | 2887 #endif |
2887 ++shl->endp; | 2888 ++shl->endcol; |
2888 } | 2889 } |
2889 if (shl->startp < ptr) /* match at leftcol */ | 2890 if ((long)shl->startcol < v) /* match at leftcol */ |
2890 { | 2891 { |
2891 shl->attr_cur = shl->attr; | 2892 shl->attr_cur = shl->attr; |
2892 search_attr = shl->attr; | 2893 search_attr = shl->attr; |
2893 } | 2894 } |
2894 area_highlighting = TRUE; | 2895 area_highlighting = TRUE; |
3148 * When another match, have to check for start again. | 3149 * When another match, have to check for start again. |
3149 * Watch out for matching an empty string! | 3150 * Watch out for matching an empty string! |
3150 * Do this first for search_hl, then for match_hl, so that | 3151 * Do this first for search_hl, then for match_hl, so that |
3151 * ":match" overrules 'hlsearch'. | 3152 * ":match" overrules 'hlsearch'. |
3152 */ | 3153 */ |
3154 v = (long)(ptr - line); | |
3153 shl = &search_hl; | 3155 shl = &search_hl; |
3154 for (;;) | 3156 for (;;) |
3155 { | 3157 { |
3156 while (shl->rm.regprog != NULL) | 3158 while (shl->rm.regprog != NULL) |
3157 { | 3159 { |
3158 if (shl->startp != NULL | 3160 if (shl->startcol != MAXCOL |
3159 && ptr >= shl->startp | 3161 && v >= (long)shl->startcol |
3160 && ptr < shl->endp) | 3162 && v < (long)shl->endcol) |
3161 { | 3163 { |
3162 shl->attr_cur = shl->attr; | 3164 shl->attr_cur = shl->attr; |
3163 } | 3165 } |
3164 else if (ptr == shl->endp) | 3166 else if (v == (long)shl->endcol) |
3165 { | 3167 { |
3166 shl->attr_cur = 0; | 3168 shl->attr_cur = 0; |
3167 | 3169 |
3168 v = (long)(ptr - line); | |
3169 next_search_hl(wp, shl, lnum, (colnr_T)v); | 3170 next_search_hl(wp, shl, lnum, (colnr_T)v); |
3170 | 3171 |
3171 /* Need to get the line again, a multi-line regexp | 3172 /* Need to get the line again, a multi-line regexp |
3172 * may have made it invalid. */ | 3173 * may have made it invalid. */ |
3173 line = ml_get_buf(wp->w_buffer, lnum, FALSE); | 3174 line = ml_get_buf(wp->w_buffer, lnum, FALSE); |
3174 ptr = line + v; | 3175 ptr = line + v; |
3175 | 3176 |
3176 if (shl->lnum == lnum) | 3177 if (shl->lnum == lnum) |
3177 { | 3178 { |
3178 shl->startp = line + shl->rm.startpos[0].col; | 3179 shl->startcol = shl->rm.startpos[0].col; |
3179 if (shl->rm.endpos[0].lnum == 0) | 3180 if (shl->rm.endpos[0].lnum == 0) |
3180 shl->endp = line + shl->rm.endpos[0].col; | 3181 shl->endcol = shl->rm.endpos[0].col; |
3181 else | 3182 else |
3182 shl->endp = line + MAXCOL; | 3183 shl->endcol = MAXCOL; |
3183 | 3184 |
3184 if (shl->startp == shl->endp) | 3185 if (shl->startcol == shl->endcol) |
3185 { | 3186 { |
3186 /* highlight empty match, try again after | 3187 /* highlight empty match, try again after |
3187 * it */ | 3188 * it */ |
3188 #ifdef FEAT_MBYTE | 3189 #ifdef FEAT_MBYTE |
3189 if (has_mbyte) | 3190 if (has_mbyte) |
3190 shl->endp += | 3191 shl->endcol += (*mb_ptr2len_check)(line |
3191 (*mb_ptr2len_check)(shl->endp); | 3192 + shl->endcol); |
3192 else | 3193 else |
3193 #endif | 3194 #endif |
3194 ++shl->endp; | 3195 ++shl->endcol; |
3195 } | 3196 } |
3196 | 3197 |
3197 /* Loop to check if the match starts at the | 3198 /* Loop to check if the match starts at the |
3198 * current position */ | 3199 * current position */ |
3199 continue; | 3200 continue; |
3633 { | 3634 { |
3634 c_extra = ' '; | 3635 c_extra = ' '; |
3635 c = ' '; | 3636 c = ' '; |
3636 } | 3637 } |
3637 } | 3638 } |
3638 else if (c == NUL && wp->w_p_list && lcs_eol_one > 0) | 3639 else if (c == NUL |
3639 { | 3640 && ((wp->w_p_list && lcs_eol > 0) |
3641 || ((fromcol >= 0 || fromcol_prev >= 0) | |
3642 && tocol > vcol | |
3643 && VIsual_mode != Ctrl_V | |
3644 && ( | |
3645 # ifdef FEAT_RIGHTLEFT | |
3646 wp->w_p_rl ? (col >= 0) : | |
3647 # endif | |
3648 (col < W_WIDTH(wp))) | |
3649 && !(noinvcur | |
3650 && (colnr_T)vcol == wp->w_virtcol))) | |
3651 && lcs_eol_one >= 0) | |
3652 { | |
3653 /* Display a '$' after the line or highlight an extra | |
3654 * character if the line break is included. */ | |
3640 #if defined(FEAT_DIFF) || defined(LINE_ATTR) | 3655 #if defined(FEAT_DIFF) || defined(LINE_ATTR) |
3641 /* For a diff line the highlighting continues after the | 3656 /* For a diff line the highlighting continues after the |
3642 * "$". */ | 3657 * "$". */ |
3643 if ( | 3658 if ( |
3644 # ifdef FEAT_DIFF | 3659 # ifdef FEAT_DIFF |
3665 p_extra = at_end_str; | 3680 p_extra = at_end_str; |
3666 n_extra = 1; | 3681 n_extra = 1; |
3667 c_extra = NUL; | 3682 c_extra = NUL; |
3668 } | 3683 } |
3669 } | 3684 } |
3670 c = lcs_eol; | 3685 if (wp->w_p_list) |
3686 c = lcs_eol; | |
3687 else | |
3688 c = ' '; | |
3671 lcs_eol_one = -1; | 3689 lcs_eol_one = -1; |
3672 --ptr; /* put it back at the NUL */ | 3690 --ptr; /* put it back at the NUL */ |
3673 if (area_attr == 0 && search_attr == 0) | 3691 if (area_attr == 0 && search_attr == 0) |
3674 { | 3692 { |
3675 extra_attr = hl_attr(HLF_AT); | 3693 extra_attr = hl_attr(HLF_AT); |
3845 * needed when a '$' was displayed for 'list'. */ | 3863 * needed when a '$' was displayed for 'list'. */ |
3846 if (lcs_eol == lcs_eol_one | 3864 if (lcs_eol == lcs_eol_one |
3847 && ((area_attr != 0 && vcol == fromcol) | 3865 && ((area_attr != 0 && vcol == fromcol) |
3848 #ifdef FEAT_SEARCH_EXTRA | 3866 #ifdef FEAT_SEARCH_EXTRA |
3849 /* highlight 'hlsearch' match at end of line */ | 3867 /* highlight 'hlsearch' match at end of line */ |
3850 || ptr - 1 == search_hl.startp | 3868 || (ptr - line) - 1 == (long)search_hl.startcol |
3851 || ptr - 1 == match_hl.startp | 3869 || (ptr - line) - 1 == (long)match_hl.startcol |
3852 #endif | 3870 #endif |
3853 )) | 3871 )) |
3854 { | 3872 { |
3855 int n = 0; | 3873 int n = 0; |
3856 | 3874 |
3883 #endif | 3901 #endif |
3884 } | 3902 } |
3885 #ifdef FEAT_SEARCH_EXTRA | 3903 #ifdef FEAT_SEARCH_EXTRA |
3886 if (area_attr == 0) | 3904 if (area_attr == 0) |
3887 { | 3905 { |
3888 if (ptr - 1 == match_hl.startp) | 3906 if ((ptr - line) - 1 == (long)match_hl.startcol) |
3889 char_attr = match_hl.attr; | 3907 char_attr = match_hl.attr; |
3890 else | 3908 else |
3891 char_attr = search_hl.attr; | 3909 char_attr = search_hl.attr; |
3892 } | 3910 } |
3893 #endif | 3911 #endif |