Mercurial > vim
comparison src/screen.c @ 348:7e819e81117e
updated for version 7.0090
author | vimboss |
---|---|
date | Wed, 22 Jun 2005 22:35:10 +0000 |
parents | 2d8c2622e1fa |
children | 3161473d6462 |
comparison
equal
deleted
inserted
replaced
347:fb380b964d53 | 348:7e819e81117e |
---|---|
2500 #ifdef FEAT_SYN_HL | 2500 #ifdef FEAT_SYN_HL |
2501 int syntax_attr = 0; /* attributes desired by syntax */ | 2501 int syntax_attr = 0; /* attributes desired by syntax */ |
2502 int has_syntax = FALSE; /* this buffer has syntax highl. */ | 2502 int has_syntax = FALSE; /* this buffer has syntax highl. */ |
2503 int save_did_emsg; | 2503 int save_did_emsg; |
2504 int has_spell = FALSE; /* this buffer has spell checking */ | 2504 int has_spell = FALSE; /* this buffer has spell checking */ |
2505 # define SPWORDLEN 150 | |
2506 char_u nextline[SPWORDLEN * 2];/* text with start of the next line */ | |
2507 int nextlinecol; /* column where nextline[] starts */ | |
2508 int nextline_idx; /* index in nextline[] where next line | |
2509 starts */ | |
2505 int spell_attr = 0; /* attributes desired by spelling */ | 2510 int spell_attr = 0; /* attributes desired by spelling */ |
2506 int word_end = 0; /* last byte with same spell_attr */ | 2511 int word_end = 0; /* last byte with same spell_attr */ |
2512 static linenr_T checked_lnum = 0; /* line number for checked_col */ | |
2513 static int checked_col = 0; /* column in checked_lnum up to which | |
2514 * there are no spell errors */ | |
2515 int cur_checked_col = 0; /* checked column for current line */ | |
2507 #endif | 2516 #endif |
2508 int extra_check; /* has syntax or linebreak */ | 2517 int extra_check; /* has syntax or linebreak */ |
2509 #ifdef FEAT_MBYTE | 2518 #ifdef FEAT_MBYTE |
2510 int multi_attr = 0; /* attributes desired by multibyte */ | 2519 int multi_attr = 0; /* attributes desired by multibyte */ |
2511 int mb_l = 1; /* multi-byte byte length */ | 2520 int mb_l = 1; /* multi-byte byte length */ |
2607 && *(char **)(wp->w_buffer->b_langp.ga_data) != NULL) | 2616 && *(char **)(wp->w_buffer->b_langp.ga_data) != NULL) |
2608 { | 2617 { |
2609 /* Prepare for spell checking. */ | 2618 /* Prepare for spell checking. */ |
2610 has_spell = TRUE; | 2619 has_spell = TRUE; |
2611 extra_check = TRUE; | 2620 extra_check = TRUE; |
2621 | |
2622 /* Get the start of the next line, so that words that wrap to the next | |
2623 * line are found too: "et<line-break>al.". | |
2624 * Trick: skip a few chars for C/shell/Vim comments */ | |
2625 nextline[SPWORDLEN] = NUL; | |
2626 if (lnum < wp->w_buffer->b_ml.ml_line_count) | |
2627 { | |
2628 line = ml_get_buf(wp->w_buffer, lnum + 1, FALSE); | |
2629 spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN); | |
2630 } | |
2631 | |
2632 /* When a word wrapped from the previous line the start of the current | |
2633 * line is valid. */ | |
2634 if (lnum == checked_lnum) | |
2635 cur_checked_col = checked_col; | |
2636 checked_lnum = 0; | |
2612 } | 2637 } |
2613 #endif | 2638 #endif |
2614 | 2639 |
2615 /* | 2640 /* |
2616 * handle visual active in this window | 2641 * handle visual active in this window |
2771 area_highlighting = TRUE; | 2796 area_highlighting = TRUE; |
2772 #endif | 2797 #endif |
2773 | 2798 |
2774 line = ml_get_buf(wp->w_buffer, lnum, FALSE); | 2799 line = ml_get_buf(wp->w_buffer, lnum, FALSE); |
2775 ptr = line; | 2800 ptr = line; |
2801 | |
2802 #ifdef FEAT_SYN_HL | |
2803 if (has_spell) | |
2804 { | |
2805 /* To be able to spell-check over line boundaries copy the end of the | |
2806 * current line into nextline[]. Above the start of the next line was | |
2807 * copied to nextline[SPWORDLEN]. */ | |
2808 if (nextline[SPWORDLEN] == NUL) | |
2809 { | |
2810 /* No next line or it is empty. */ | |
2811 nextlinecol = MAXCOL; | |
2812 nextline_idx = 0; | |
2813 } | |
2814 else | |
2815 { | |
2816 v = STRLEN(line); | |
2817 if (v < SPWORDLEN) | |
2818 { | |
2819 /* Short line, use it completely and append the start of the | |
2820 * next line. */ | |
2821 nextlinecol = 0; | |
2822 mch_memmove(nextline, line, (size_t)v); | |
2823 mch_memmove(nextline + v, nextline + SPWORDLEN, | |
2824 STRLEN(nextline + SPWORDLEN) + 1); | |
2825 nextline_idx = v + 1; | |
2826 } | |
2827 else | |
2828 { | |
2829 /* Long line, use only the last SPWORDLEN bytes. */ | |
2830 nextlinecol = v - SPWORDLEN; | |
2831 mch_memmove(nextline, line + nextlinecol, SPWORDLEN); | |
2832 nextline_idx = SPWORDLEN + 1; | |
2833 } | |
2834 } | |
2835 } | |
2836 #endif | |
2776 | 2837 |
2777 /* find start of trailing whitespace */ | 2838 /* find start of trailing whitespace */ |
2778 if (wp->w_p_list && lcs_trail) | 2839 if (wp->w_p_list && lcs_trail) |
2779 { | 2840 { |
2780 trailcol = (colnr_T)STRLEN(ptr); | 2841 trailcol = (colnr_T)STRLEN(ptr); |
3585 | 3646 |
3586 /* Check spelling (unless at the end of the line). | 3647 /* Check spelling (unless at the end of the line). |
3587 * Only do this when there is no syntax highlighting, the | 3648 * Only do this when there is no syntax highlighting, the |
3588 * @Spell cluster is not used or the current syntax item | 3649 * @Spell cluster is not used or the current syntax item |
3589 * contains the @Spell cluster. */ | 3650 * contains the @Spell cluster. */ |
3590 if (has_spell && v >= word_end) | 3651 if (has_spell && v >= word_end && v > cur_checked_col) |
3591 { | 3652 { |
3592 spell_attr = 0; | 3653 spell_attr = 0; |
3593 if (area_attr == 0 && search_attr == 0) | 3654 if (area_attr == 0 && search_attr == 0) |
3594 char_attr = syntax_attr; | 3655 char_attr = syntax_attr; |
3595 if (c != 0 && (!has_syntax || can_spell)) | 3656 if (c != 0 && (!has_syntax || can_spell)) |
3596 { | 3657 { |
3597 char_u *prev_ptr; | 3658 char_u *prev_ptr, *p; |
3659 int len; | |
3598 # ifdef FEAT_MBYTE | 3660 # ifdef FEAT_MBYTE |
3599 if (has_mbyte) | 3661 if (has_mbyte) |
3600 { | 3662 { |
3601 prev_ptr = ptr - mb_l; | 3663 prev_ptr = ptr - mb_l; |
3602 v -= mb_l - 1; | 3664 v -= mb_l - 1; |
3603 } | 3665 } |
3604 else | 3666 else |
3605 # endif | 3667 # endif |
3606 prev_ptr = ptr - 1; | 3668 prev_ptr = ptr - 1; |
3607 word_end = v + spell_check(wp, prev_ptr, &spell_attr); | 3669 |
3670 /* Use nextline[] if possible, it has the start of the | |
3671 * next line concatenated. */ | |
3672 if ((prev_ptr - line) - nextlinecol >= 0) | |
3673 p = nextline + (prev_ptr - line) - nextlinecol; | |
3674 else | |
3675 p = prev_ptr; | |
3676 len = spell_check(wp, p, &spell_attr); | |
3677 word_end = v + len; | |
3608 | 3678 |
3609 /* In Insert mode only highlight a word that | 3679 /* In Insert mode only highlight a word that |
3610 * doesn't touch the cursor. */ | 3680 * doesn't touch the cursor. */ |
3611 if (spell_attr != 0 | 3681 if (spell_attr != 0 |
3612 && (State & INSERT) != 0 | 3682 && (State & INSERT) != 0 |
3616 && wp->w_cursor.col < (colnr_T)word_end) | 3686 && wp->w_cursor.col < (colnr_T)word_end) |
3617 { | 3687 { |
3618 spell_attr = 0; | 3688 spell_attr = 0; |
3619 spell_redraw_lnum = lnum; | 3689 spell_redraw_lnum = lnum; |
3620 } | 3690 } |
3691 | |
3692 if (spell_attr == 0 && p != prev_ptr | |
3693 && (p - nextline) + len > nextline_idx) | |
3694 { | |
3695 /* Remember that the good word continues at the | |
3696 * start of the next line. */ | |
3697 checked_lnum = lnum + 1; | |
3698 checked_col = (p - nextline) + len - nextline_idx; | |
3699 } | |
3621 } | 3700 } |
3622 } | 3701 } |
3623 if (spell_attr != 0) | 3702 if (spell_attr != 0) |
3624 char_attr = hl_combine_attr(char_attr, spell_attr); | 3703 { |
3704 if (area_attr == 0 && search_attr == 0) | |
3705 char_attr = hl_combine_attr(char_attr, spell_attr); | |
3706 else | |
3707 char_attr = hl_combine_attr(spell_attr, char_attr); | |
3708 } | |
3625 #endif | 3709 #endif |
3626 #ifdef FEAT_LINEBREAK | 3710 #ifdef FEAT_LINEBREAK |
3627 /* | 3711 /* |
3628 * Found last space before word: check for line break. | 3712 * Found last space before word: check for line break. |
3629 */ | 3713 */ |