Mercurial > vim
comparison src/screen.c @ 2250:1bac28a53fae vim73
Add the conceal patch from Vince Negri.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 05 Jun 2010 23:22:07 +0200 |
parents | 770485470e59 |
children | e5265e4d4725 |
comparison
equal
deleted
inserted
replaced
2249:6d3d35ff2c2b | 2250:1bac28a53fae |
---|---|
483 # endif | 483 # endif |
484 if ( | 484 if ( |
485 # ifdef FEAT_WINDOWS | 485 # ifdef FEAT_WINDOWS |
486 wwp == wp && | 486 wwp == wp && |
487 # endif | 487 # endif |
488 syntax_present(wp->w_buffer)) | 488 syntax_present(wp)) |
489 syn_stack_apply_changes(wp->w_buffer); | 489 syn_stack_apply_changes(wp->w_buffer); |
490 } | 490 } |
491 } | 491 } |
492 #endif | 492 #endif |
493 | 493 |
582 gui_update_cursor(FALSE, FALSE); | 582 gui_update_cursor(FALSE, FALSE); |
583 gui_update_scrollbars(FALSE); | 583 gui_update_scrollbars(FALSE); |
584 } | 584 } |
585 #endif | 585 #endif |
586 } | 586 } |
587 | |
588 #if defined(FEAT_CONCEAL) || defined(PROTO) | |
589 void | |
590 update_single_line(wp, lnum) | |
591 win_T *wp; | |
592 linenr_T lnum; | |
593 { | |
594 int row; | |
595 int j; | |
596 | |
597 if (lnum >= wp->w_topline && lnum < wp->w_botline | |
598 && foldedCount(wp, lnum, NULL) == 0) | |
599 { | |
600 # ifdef FEAT_GUI | |
601 /* Remove the cursor before starting to do anything, because scrolling | |
602 * may make it difficult to redraw the text under it. */ | |
603 if (gui.in_use) | |
604 gui_undraw_cursor(); | |
605 # endif | |
606 row = 0; | |
607 for (j = 0; j < wp->w_lines_valid; ++j) | |
608 { | |
609 if (lnum == wp->w_lines[j].wl_lnum) | |
610 { | |
611 screen_start(); /* not sure of screen cursor */ | |
612 # if defined(FEAT_SEARCH_EXTRA) | |
613 start_search_hl(); | |
614 prepare_search_hl(wp, lnum); | |
615 # endif | |
616 win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE); | |
617 # if defined(FEAT_SEARCH_EXTRA) | |
618 end_search_hl(); | |
619 # endif | |
620 break; | |
621 } | |
622 row += wp->w_lines[j].wl_size; | |
623 } | |
624 # ifdef FEAT_GUI | |
625 /* Redraw the cursor */ | |
626 if (gui.in_use) | |
627 { | |
628 out_flush(); /* required before updating the cursor */ | |
629 gui_update_cursor(FALSE, FALSE); | |
630 } | |
631 # endif | |
632 } | |
633 } | |
634 #endif | |
587 | 635 |
588 #if defined(FEAT_SIGNS) || defined(FEAT_GUI) | 636 #if defined(FEAT_SIGNS) || defined(FEAT_GUI) |
589 static void update_prepare __ARGS((void)); | 637 static void update_prepare __ARGS((void)); |
590 static void update_finish __ARGS((void)); | 638 static void update_finish __ARGS((void)); |
591 | 639 |
915 { | 963 { |
916 mod_top = buf->b_mod_top; | 964 mod_top = buf->b_mod_top; |
917 #ifdef FEAT_SYN_HL | 965 #ifdef FEAT_SYN_HL |
918 /* Need to redraw lines above the change that may be included | 966 /* Need to redraw lines above the change that may be included |
919 * in a pattern match. */ | 967 * in a pattern match. */ |
920 if (syntax_present(buf)) | 968 if (syntax_present(wp)) |
921 { | 969 { |
922 mod_top -= buf->b_syn_sync_linebreaks; | 970 mod_top -= buf->b_s.b_syn_sync_linebreaks; |
923 if (mod_top < 1) | 971 if (mod_top < 1) |
924 mod_top = 1; | 972 mod_top = 1; |
925 } | 973 } |
926 #endif | 974 #endif |
927 } | 975 } |
1008 if (mod_top != 0 && mod_top < wp->w_topline) | 1056 if (mod_top != 0 && mod_top < wp->w_topline) |
1009 { | 1057 { |
1010 if (mod_bot > wp->w_topline) | 1058 if (mod_bot > wp->w_topline) |
1011 mod_top = wp->w_topline; | 1059 mod_top = wp->w_topline; |
1012 #ifdef FEAT_SYN_HL | 1060 #ifdef FEAT_SYN_HL |
1013 else if (syntax_present(buf)) | 1061 else if (syntax_present(wp)) |
1014 top_end = 1; | 1062 top_end = 1; |
1015 #endif | 1063 #endif |
1016 } | 1064 } |
1017 | 1065 |
1018 /* When line numbers are displayed need to redraw all lines below | 1066 /* When line numbers are displayed need to redraw all lines below |
1543 || (lnum >= mod_top | 1591 || (lnum >= mod_top |
1544 && (lnum < mod_bot | 1592 && (lnum < mod_bot |
1545 #ifdef FEAT_SYN_HL | 1593 #ifdef FEAT_SYN_HL |
1546 || did_update == DID_FOLD | 1594 || did_update == DID_FOLD |
1547 || (did_update == DID_LINE | 1595 || (did_update == DID_LINE |
1548 && syntax_present(buf) | 1596 && syntax_present(wp) |
1549 && ( | 1597 && ( |
1550 # ifdef FEAT_FOLDING | 1598 # ifdef FEAT_FOLDING |
1551 (foldmethodIsSyntax(wp) | 1599 (foldmethodIsSyntax(wp) |
1552 && hasAnyFolding(wp)) || | 1600 && hasAnyFolding(wp)) || |
1553 # endif | 1601 # endif |
1769 prepare_search_hl(wp, lnum); | 1817 prepare_search_hl(wp, lnum); |
1770 #endif | 1818 #endif |
1771 #ifdef FEAT_SYN_HL | 1819 #ifdef FEAT_SYN_HL |
1772 /* Let the syntax stuff know we skipped a few lines. */ | 1820 /* Let the syntax stuff know we skipped a few lines. */ |
1773 if (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum | 1821 if (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum |
1774 && syntax_present(buf)) | 1822 && syntax_present(wp)) |
1775 syntax_end_parsing(syntax_last_parsed + 1); | 1823 syntax_end_parsing(syntax_last_parsed + 1); |
1776 #endif | 1824 #endif |
1777 | 1825 |
1778 /* | 1826 /* |
1779 * Display one line. | 1827 * Display one line. |
1841 | 1889 |
1842 #ifdef FEAT_SYN_HL | 1890 #ifdef FEAT_SYN_HL |
1843 /* | 1891 /* |
1844 * Let the syntax stuff know we stop parsing here. | 1892 * Let the syntax stuff know we stop parsing here. |
1845 */ | 1893 */ |
1846 if (syntax_last_parsed != 0 && syntax_present(buf)) | 1894 if (syntax_last_parsed != 0 && syntax_present(wp)) |
1847 syntax_end_parsing(syntax_last_parsed + 1); | 1895 syntax_end_parsing(syntax_last_parsed + 1); |
1848 #endif | 1896 #endif |
1849 | 1897 |
1850 /* | 1898 /* |
1851 * If we didn't hit the end of the file, and we didn't finish the last | 1899 * If we didn't hit the end of the file, and we didn't finish the last |
2724 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | 2772 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
2725 int feedback_col = 0; | 2773 int feedback_col = 0; |
2726 int feedback_old_attr = -1; | 2774 int feedback_old_attr = -1; |
2727 #endif | 2775 #endif |
2728 | 2776 |
2777 #ifdef FEAT_CONCEAL | |
2778 int syntax_flags = 0; | |
2779 int conceal_attr = hl_attr(HLF_CONCEAL); | |
2780 int first_conceal = (wp->w_p_conceal != 3); | |
2781 int is_concealing = FALSE; | |
2782 int boguscols = 0; /* nonexistent columns added to force | |
2783 wrapping */ | |
2784 #endif | |
2729 | 2785 |
2730 if (startrow > endrow) /* past the end already! */ | 2786 if (startrow > endrow) /* past the end already! */ |
2731 return startrow; | 2787 return startrow; |
2732 | 2788 |
2733 row = startrow; | 2789 row = startrow; |
2741 extra_check = wp->w_p_lbr; | 2797 extra_check = wp->w_p_lbr; |
2742 #else | 2798 #else |
2743 extra_check = 0; | 2799 extra_check = 0; |
2744 #endif | 2800 #endif |
2745 #ifdef FEAT_SYN_HL | 2801 #ifdef FEAT_SYN_HL |
2746 if (syntax_present(wp->w_buffer) && !wp->w_buffer->b_syn_error) | 2802 if (syntax_present(wp) && !wp->w_s->b_syn_error) |
2747 { | 2803 { |
2748 /* Prepare for syntax highlighting in this line. When there is an | 2804 /* Prepare for syntax highlighting in this line. When there is an |
2749 * error, stop syntax highlighting. */ | 2805 * error, stop syntax highlighting. */ |
2750 save_did_emsg = did_emsg; | 2806 save_did_emsg = did_emsg; |
2751 did_emsg = FALSE; | 2807 did_emsg = FALSE; |
2752 syntax_start(wp, lnum); | 2808 syntax_start(wp, lnum); |
2753 if (did_emsg) | 2809 if (did_emsg) |
2754 wp->w_buffer->b_syn_error = TRUE; | 2810 wp->w_s->b_syn_error = TRUE; |
2755 else | 2811 else |
2756 { | 2812 { |
2757 did_emsg = save_did_emsg; | 2813 did_emsg = save_did_emsg; |
2758 has_syntax = TRUE; | 2814 has_syntax = TRUE; |
2759 extra_check = TRUE; | 2815 extra_check = TRUE; |
2761 } | 2817 } |
2762 #endif | 2818 #endif |
2763 | 2819 |
2764 #ifdef FEAT_SPELL | 2820 #ifdef FEAT_SPELL |
2765 if (wp->w_p_spell | 2821 if (wp->w_p_spell |
2766 && *wp->w_buffer->b_p_spl != NUL | 2822 && *wp->w_s->b_p_spl != NUL |
2767 && wp->w_buffer->b_langp.ga_len > 0 | 2823 && wp->w_s->b_langp.ga_len > 0 |
2768 && *(char **)(wp->w_buffer->b_langp.ga_data) != NULL) | 2824 && *(char **)(wp->w_s->b_langp.ga_data) != NULL) |
2769 { | 2825 { |
2770 /* Prepare for spell checking. */ | 2826 /* Prepare for spell checking. */ |
2771 has_spell = TRUE; | 2827 has_spell = TRUE; |
2772 extra_check = TRUE; | 2828 extra_check = TRUE; |
2773 | 2829 |
3111 if (len == 0 || (int)wp->w_cursor.col > ptr - line) | 3167 if (len == 0 || (int)wp->w_cursor.col > ptr - line) |
3112 { | 3168 { |
3113 /* no bad word found at line start, don't check until end of a | 3169 /* no bad word found at line start, don't check until end of a |
3114 * word */ | 3170 * word */ |
3115 spell_hlf = HLF_COUNT; | 3171 spell_hlf = HLF_COUNT; |
3116 word_end = (int)(spell_to_word_end(ptr, wp->w_buffer) | 3172 word_end = (int)(spell_to_word_end(ptr, wp) |
3117 - line + 1); | 3173 - line + 1); |
3118 } | 3174 } |
3119 else | 3175 else |
3120 { | 3176 { |
3121 /* bad word found, use attributes until end of word */ | 3177 /* bad word found, use attributes until end of word */ |
3960 * is an error, disable syntax highlighting. */ | 4016 * is an error, disable syntax highlighting. */ |
3961 save_did_emsg = did_emsg; | 4017 save_did_emsg = did_emsg; |
3962 did_emsg = FALSE; | 4018 did_emsg = FALSE; |
3963 | 4019 |
3964 syntax_attr = get_syntax_attr((colnr_T)v - 1, | 4020 syntax_attr = get_syntax_attr((colnr_T)v - 1, |
4021 # ifdef FEAT_CONCEAL | |
4022 &syntax_flags, | |
4023 # else | |
4024 NULL, | |
4025 # endif | |
3965 # ifdef FEAT_SPELL | 4026 # ifdef FEAT_SPELL |
3966 has_spell ? &can_spell : | 4027 has_spell ? &can_spell : |
3967 # endif | 4028 # endif |
3968 NULL, FALSE); | 4029 NULL, FALSE); |
3969 | 4030 |
3970 if (did_emsg) | 4031 if (did_emsg) |
3971 { | 4032 { |
3972 wp->w_buffer->b_syn_error = TRUE; | 4033 wp->w_s->b_syn_error = TRUE; |
3973 has_syntax = FALSE; | 4034 has_syntax = FALSE; |
3974 } | 4035 } |
3975 else | 4036 else |
3976 did_emsg = save_did_emsg; | 4037 did_emsg = save_did_emsg; |
3977 | 4038 |
4302 } | 4363 } |
4303 # endif | 4364 # endif |
4304 } | 4365 } |
4305 #endif | 4366 #endif |
4306 } | 4367 } |
4368 | |
4369 #ifdef FEAT_CONCEAL | |
4370 if ( wp->w_p_conceal | |
4371 && (!area_highlighting) | |
4372 && ((lnum != wp->w_cursor.lnum) | |
4373 || (curwin != wp) || (wp->w_buffer->b_p_ma == FALSE)) | |
4374 && ((syntax_flags & HL_CONCEAL) != 0)) | |
4375 | |
4376 { | |
4377 char_attr = conceal_attr; | |
4378 if (first_conceal | |
4379 && (syn_get_sub_char() != NUL || wp->w_p_conceal == 1)) | |
4380 { | |
4381 if (syn_get_sub_char() != NUL) | |
4382 c = syn_get_sub_char(); | |
4383 else if (lcs_conceal != NUL) | |
4384 c = lcs_conceal; | |
4385 else | |
4386 c = ' '; | |
4387 | |
4388 first_conceal = FALSE; | |
4389 | |
4390 # ifdef FEAT_HLCOLUMN | |
4391 if (hlc > 0 && n_extra > 0) | |
4392 hlc += n_extra; | |
4393 # endif | |
4394 vcol += n_extra; | |
4395 if (wp->w_p_wrap && n_extra > 0) | |
4396 { | |
4397 # ifdef FEAT_RIGHTLEFT | |
4398 if (wp->w_p_rl) | |
4399 { | |
4400 col -= n_extra; | |
4401 boguscols -= n_extra; | |
4402 } | |
4403 else | |
4404 # endif | |
4405 { | |
4406 boguscols += n_extra; | |
4407 col += n_extra; | |
4408 } | |
4409 } | |
4410 n_extra = 0; | |
4411 n_attr = 0; | |
4412 } | |
4413 else if (n_skip == 0) | |
4414 { | |
4415 is_concealing = TRUE; | |
4416 n_skip = 1; | |
4417 } | |
4418 # ifdef FEAT_MBYTE | |
4419 mb_c = c; | |
4420 if (enc_utf8 && (*mb_char2len)(c) > 1) | |
4421 { | |
4422 mb_utf8 = TRUE; | |
4423 u8cc[0] = 0; | |
4424 c = 0xc0; | |
4425 } | |
4426 else | |
4427 mb_utf8 = FALSE; /* don't draw as UTF-8 */ | |
4428 # endif | |
4429 } | |
4430 else | |
4431 { | |
4432 first_conceal = (wp->w_p_conceal != 3); | |
4433 is_concealing = FALSE; | |
4434 } | |
4435 #endif /* FEAT_CONCEAL */ | |
4307 } | 4436 } |
4308 | 4437 |
4309 /* Don't override visual selection highlighting. */ | 4438 /* Don't override visual selection highlighting. */ |
4310 if (n_attr > 0 | 4439 if (n_attr > 0 |
4311 && draw_state == WL_LINE | 4440 && draw_state == WL_LINE |
4568 ++vcol; | 4697 ++vcol; |
4569 } | 4698 } |
4570 } | 4699 } |
4571 #endif | 4700 #endif |
4572 | 4701 |
4573 SCREEN_LINE(screen_row, W_WINCOL(wp), col, (int)W_WIDTH(wp), | 4702 #ifdef FEAT_CONCEAL |
4574 wp->w_p_rl); | 4703 SCREEN_LINE(screen_row, W_WINCOL(wp), col - boguscols, |
4704 (int)W_WIDTH(wp), wp->w_p_rl); | |
4705 boguscols = 0; | |
4706 #else | |
4707 SCREEN_LINE(screen_row, W_WINCOL(wp), col, | |
4708 (int)W_WIDTH(wp), wp->w_p_rl); | |
4709 #endif | |
4575 row++; | 4710 row++; |
4576 | 4711 |
4577 /* | 4712 /* |
4578 * Update w_cline_height and w_cline_folded if the cursor line was | 4713 * Update w_cline_height and w_cline_folded if the cursor line was |
4579 * updated (saves a call to plines() later). | 4714 * updated (saves a call to plines() later). |
4728 { | 4863 { |
4729 ++off; | 4864 ++off; |
4730 ++col; | 4865 ++col; |
4731 } | 4866 } |
4732 } | 4867 } |
4868 #ifdef FEAT_CONCEAL | |
4869 else if (wp->w_p_conceal && is_concealing) | |
4870 { | |
4871 --n_skip; | |
4872 # ifdef FEAT_HLCOLUMN | |
4873 if (hlc) | |
4874 { | |
4875 ++hlc; | |
4876 if (n_extra > 0) | |
4877 hlc += n_extra; | |
4878 } | |
4879 # endif | |
4880 if (wp->w_p_wrap) | |
4881 { | |
4882 /* | |
4883 * Special voodoo required if 'wrap' is on. | |
4884 * | |
4885 * Advance the column indicator to force the line | |
4886 * drawing to wrap early. This will make the line | |
4887 * take up the same screen space when parts are concealed, | |
4888 * so that cursor line computations aren't messed up. | |
4889 * | |
4890 * To avoid the fictitious advance of 'col' causing | |
4891 * trailing junk to be written out of the screen line | |
4892 * we are building, 'boguscols' keeps track of the number | |
4893 * of bad columns we have advanced. | |
4894 */ | |
4895 if (n_extra > 0) | |
4896 { | |
4897 vcol += n_extra; | |
4898 # ifdef FEAT_RIGHTLEFT | |
4899 if (wp->w_p_rl) | |
4900 { | |
4901 col -= n_extra; | |
4902 boguscols -= n_extra; | |
4903 } | |
4904 else | |
4905 # endif | |
4906 { | |
4907 col += n_extra; | |
4908 boguscols += n_extra; | |
4909 } | |
4910 n_extra = 0; | |
4911 n_attr = 0; | |
4912 } | |
4913 | |
4914 | |
4915 # ifdef FEAT_MBYTE | |
4916 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) | |
4917 { | |
4918 /* Need to fill two screen columns. */ | |
4919 # ifdef FEAT_RIGHTLEFT | |
4920 if (wp->w_p_rl) | |
4921 { | |
4922 --boguscols; | |
4923 --col; | |
4924 } | |
4925 else | |
4926 # endif | |
4927 { | |
4928 ++boguscols; | |
4929 ++col; | |
4930 } | |
4931 } | |
4932 # endif | |
4933 | |
4934 # ifdef FEAT_RIGHTLEFT | |
4935 if (wp->w_p_rl) | |
4936 { | |
4937 --boguscols; | |
4938 --col; | |
4939 } | |
4940 else | |
4941 # endif | |
4942 { | |
4943 ++boguscols; | |
4944 ++col; | |
4945 } | |
4946 } | |
4947 else | |
4948 { | |
4949 if (n_extra > 0) | |
4950 { | |
4951 vcol += n_extra; | |
4952 n_extra = 0; | |
4953 n_attr = 0; | |
4954 } | |
4955 } | |
4956 | |
4957 } | |
4958 #endif /* FEAT_CONCEAL */ | |
4733 else | 4959 else |
4734 --n_skip; | 4960 --n_skip; |
4735 | 4961 |
4736 /* Only advance the "vcol" when after the 'number' or 'relativenumber' | 4962 /* Only advance the "vcol" when after the 'number' or 'relativenumber' |
4737 * column. */ | 4963 * column. */ |
4770 #endif | 4996 #endif |
4771 || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str) | 4997 || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str) |
4772 || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL))) | 4998 || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL))) |
4773 ) | 4999 ) |
4774 { | 5000 { |
4775 SCREEN_LINE(screen_row, W_WINCOL(wp), col, (int)W_WIDTH(wp), | 5001 #ifdef FEAT_CONCEAL |
4776 wp->w_p_rl); | 5002 SCREEN_LINE(screen_row, W_WINCOL(wp), col - boguscols, |
5003 (int)W_WIDTH(wp), wp->w_p_rl); | |
5004 boguscols = 0; | |
5005 #else | |
5006 SCREEN_LINE(screen_row, W_WINCOL(wp), col, | |
5007 (int)W_WIDTH(wp), wp->w_p_rl); | |
5008 #endif | |
4777 ++row; | 5009 ++row; |
4778 ++screen_row; | 5010 ++screen_row; |
4779 | 5011 |
4780 /* When not wrapping and finished diff lines, or when displayed | 5012 /* When not wrapping and finished diff lines, or when displayed |
4781 * '$' and highlighting until last column, break here. */ | 5013 * '$' and highlighting until last column, break here. */ |