diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-07-02 23:19:16 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-07-02 23:19:16 +0000 |
commit | 0d9c26dd8333aae4b20015f13fe2e8e1f07037bd (patch) | |
tree | bb7411a26272fdb19424741790f1d3b4a2c61f20 /src | |
parent | f9184a1d3151b5b727fec86c2ac0946c9c68df4d (diff) |
updated for version 7.0100
Diffstat (limited to 'src')
-rw-r--r-- | src/option.c | 58 | ||||
-rw-r--r-- | src/proto/spell.pro | 4 | ||||
-rw-r--r-- | src/screen.c | 43 | ||||
-rw-r--r-- | src/structs.h | 2 | ||||
-rw-r--r-- | src/syntax.c | 2 | ||||
-rw-r--r-- | src/version.h | 4 |
6 files changed, 106 insertions, 7 deletions
diff --git a/src/option.c b/src/option.c index eef61292b6..57d2951d9b 100644 --- a/src/option.c +++ b/src/option.c @@ -121,6 +121,7 @@ typedef enum , PV_SI , PV_SN , PV_SPELL + , PV_SPC , PV_SPF , PV_SPL , PV_STL @@ -235,6 +236,7 @@ static long p_sw; static int p_swf; #ifdef FEAT_SYN_HL static char_u *p_syn; +static char_u *p_spc; static char_u *p_spf; static char_u *p_spl; #endif @@ -1113,7 +1115,7 @@ static struct vimoption {(char_u *)FALSE, (char_u *)0L}}, {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP, (char_u *)&p_hl, PV_NONE, - {(char_u *)"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,B:SpellBad,R:SpellRare,L:SpellLocal", + {(char_u *)"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal", (char_u *)0L}}, {"history", "hi", P_NUM|P_VIM, (char_u *)&p_hi, PV_NONE, @@ -2031,7 +2033,16 @@ static struct vimoption (char_u *)NULL, PV_NONE, #endif {(char_u *)FALSE, (char_u *)0L}}, - {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE, + {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE|P_RBUF, +#ifdef FEAT_SYN_HL + (char_u *)&p_spc, PV_SPC, + {(char_u *)"[.?!][])'\" \\t\\n]\\+", (char_u *)0L} +#else + (char_u *)NULL, PV_NONE, + {(char_u *)0L, (char_u *)0L} +#endif + }, + {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA, #ifdef FEAT_SYN_HL (char_u *)&p_spf, PV_SPF, {(char_u *)"", (char_u *)0L} @@ -2593,6 +2604,9 @@ static char_u *set_chars_option __ARGS((char_u **varp)); #ifdef FEAT_CLIPBOARD static char_u *check_clipboard_option __ARGS((void)); #endif +#ifdef FEAT_SYN_HL +static char_u *compile_cap_prog __ARGS((void)); +#endif static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags)); static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags)); static void check_redraw __ARGS((long_u flags)); @@ -4596,6 +4610,7 @@ didset_options() #endif #ifdef FEAT_SYN_HL (void)spell_check_sps(); + (void)compile_cap_prog(); #endif #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE); @@ -4668,6 +4683,7 @@ check_buf_options(buf) #endif #ifdef FEAT_SYN_HL check_string_option(&buf->b_p_syn); + check_string_option(&buf->b_p_spc); check_string_option(&buf->b_p_spf); check_string_option(&buf->b_p_spl); #endif @@ -5755,6 +5771,11 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, } } } + /* When 'spellcapcheck' is set compile the regexp program. */ + else if (varp == &(curbuf->b_p_spc)) + { + errmsg = compile_cap_prog(); + } /* 'spellsuggest' */ else if (varp == &p_sps) { @@ -6410,6 +6431,37 @@ check_clipboard_option() } #endif +#ifdef FEAT_SYN_HL +/* + * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'. + * Return error message when failed, NULL when OK. + */ + static char_u * +compile_cap_prog() +{ + regprog_T *rp = curbuf->b_cap_prog; + + if (*curbuf->b_p_spc == NUL) + { + curbuf->b_cap_prog = NULL; + vim_free(rp); + return NULL; + } + + /* Prepend a ^ so that we only match at one column */ + vim_snprintf((char *)IObuff, IOSIZE, "^%s", curbuf->b_p_spc); + curbuf->b_cap_prog = vim_regcomp(IObuff, RE_MAGIC); + if (curbuf->b_cap_prog == NULL) + { + curbuf->b_cap_prog = rp; + return e_invarg; + } + + vim_free(rp); + return NULL; +} +#endif + /* * Set the value of a boolean option, and take care of side effects. * Returns NULL for success, or an error message for an error. @@ -8393,6 +8445,7 @@ get_varp(p) case PV_SWF: return (char_u *)&(curbuf->b_p_swf); #ifdef FEAT_SYN_HL case PV_SYN: return (char_u *)&(curbuf->b_p_syn); + case PV_SPC: return (char_u *)&(curbuf->b_p_spc); case PV_SPF: return (char_u *)&(curbuf->b_p_spf); case PV_SPL: return (char_u *)&(curbuf->b_p_spl); #endif @@ -8704,6 +8757,7 @@ buf_copy_options(buf, flags) #ifdef FEAT_SYN_HL /* Don't copy 'syntax', it must be set */ buf->b_p_syn = empty_option; + buf->b_p_spc = vim_strsave(p_spc); buf->b_p_spf = vim_strsave(p_spf); buf->b_p_spl = vim_strsave(p_spl); #endif diff --git a/src/proto/spell.pro b/src/proto/spell.pro index 91fcf72932..1b47b313a0 100644 --- a/src/proto/spell.pro +++ b/src/proto/spell.pro @@ -1,5 +1,5 @@ /* spell.c */ -int spell_check __ARGS((win_T *wp, char_u *ptr, int *attrp)); +int spell_check __ARGS((win_T *wp, char_u *ptr, int *attrp, int *capcol)); int spell_move_to __ARGS((int dir, int allwords, int curline)); void spell_cat_line __ARGS((char_u *buf, char_u *line, int maxlen)); char_u *did_set_spelllang __ARGS((buf_T *buf)); @@ -8,7 +8,7 @@ void spell_reload __ARGS((void)); void put_bytes __ARGS((FILE *fd, long_u nr, int len)); void ex_mkspell __ARGS((exarg_T *eap)); void ex_spell __ARGS((exarg_T *eap)); -void spell_add_word __ARGS((char_u *word, int len, int bad, int temp)); +void spell_add_word __ARGS((char_u *word, int len, int bad, int index)); void init_spell_chartab __ARGS((void)); int spell_check_sps __ARGS((void)); void spell_suggest __ARGS((void)); diff --git a/src/screen.c b/src/screen.c index f1a7c7ad03..3e11c532ea 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2512,6 +2512,8 @@ win_line(wp, lnum, startrow, endrow) static linenr_T checked_lnum = 0; /* line number for "checked_col" */ static int checked_col = 0; /* column in "checked_lnum" up to which * there are no spell errors */ + static int cap_col = -1; /* column to check for Cap word */ + static linenr_T capcol_lnum = 0; /* line number where "cap_col" used */ int cur_checked_col = 0; /* checked column for current line */ #endif int extra_check; /* has syntax or linebreak */ @@ -2634,6 +2636,15 @@ win_line(wp, lnum, startrow, endrow) if (lnum == checked_lnum) cur_checked_col = checked_col; checked_lnum = 0; + + /* When there was a sentence end in the previous line may require a + * word starting with capital in this line. In line 1 always check + * the first word. */ + if (lnum != capcol_lnum) + cap_col = -1; + if (lnum == 1) + cap_col = 0; + capcol_lnum = 0; } #endif @@ -2802,6 +2813,10 @@ win_line(wp, lnum, startrow, endrow) #ifdef FEAT_SYN_HL if (has_spell) { + /* For checking first word with a capital skip white space. */ + if (cap_col == 0) + cap_col = skipwhite(line) - line; + /* To be able to spell-check over line boundaries copy the end of the * current line into nextline[]. Above the start of the next line was * copied to nextline[SPWORDLEN]. */ @@ -3673,7 +3688,8 @@ win_line(wp, lnum, startrow, endrow) p = nextline + (prev_ptr - line) - nextlinecol; else p = prev_ptr; - len = spell_check(wp, p, &spell_attr); + cap_col -= (prev_ptr - line); + len = spell_check(wp, p, &spell_attr, &cap_col); word_end = v + len; /* In Insert mode only highlight a word that @@ -3697,6 +3713,22 @@ win_line(wp, lnum, startrow, endrow) checked_lnum = lnum + 1; checked_col = (p - nextline) + len - nextline_idx; } + + if (cap_col > 0) + { + if (p != prev_ptr + && (p - nextline) + cap_col >= nextline_idx) + { + /* Remember that the word in the next line + * must start with a capital. */ + capcol_lnum = lnum + 1; + cap_col = (p - nextline) + cap_col + - nextline_idx; + } + else + /* Compute the actual column. */ + cap_col += (prev_ptr - line); + } } } if (spell_attr != 0) @@ -4367,6 +4399,15 @@ win_line(wp, lnum, startrow, endrow) } /* for every character in the line */ +#ifdef FEAT_SYN_HL + /* After an empty line check first word for capital. */ + if (*skipwhite(line) == NUL) + { + capcol_lnum = lnum + 1; + cap_col = 0; + } +#endif + return row; } diff --git a/src/structs.h b/src/structs.h index bc2b1bbd58..7e144447d6 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1345,6 +1345,8 @@ struct file_buffer int b_p_swf; /* 'swapfile' */ #ifdef FEAT_SYN_HL char_u *b_p_syn; /* 'syntax' */ + char_u *b_p_spc; /* 'spellcapcheck' */ + regprog_T *b_cap_prog; /* program for 'spellcapcheck' */ char_u *b_p_spf; /* 'spellfile' */ char_u *b_p_spl; /* 'spelllang' */ #endif diff --git a/src/syntax.c b/src/syntax.c index 7a94df71c5..6639df0b8c 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -6031,6 +6031,7 @@ static char *(highlight_init_light[]) = "Question term=standout ctermfg=DarkGreen gui=bold guifg=SeaGreen", "Search term=reverse ctermbg=Yellow ctermfg=NONE guibg=Yellow guifg=NONE", "SpellBad term=reverse ctermbg=LightRed guisp=Red gui=undercurl", + "SpellCap term=reverse ctermbg=LightBlue guisp=Blue gui=undercurl", "SpellRare term=reverse ctermbg=LightMagenta guisp=Magenta gui=undercurl", "SpellLocal term=underline ctermbg=Cyan guisp=DarkCyan gui=undercurl", "SpecialKey term=bold ctermfg=DarkBlue guifg=Blue", @@ -6057,6 +6058,7 @@ static char *(highlight_init_dark[]) = "Search term=reverse ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black", "SpecialKey term=bold ctermfg=LightBlue guifg=Cyan", "SpellBad term=reverse ctermbg=Red guisp=Red gui=undercurl", + "SpellCap term=reverse ctermbg=Blue guisp=Blue gui=undercurl", "SpellRare term=reverse ctermbg=Magenta guisp=Magenta gui=undercurl", "SpellLocal term=underline ctermbg=Cyan guisp=Cyan gui=undercurl", "Title term=bold ctermfg=LightMagenta gui=bold guifg=Magenta", diff --git a/src/version.h b/src/version.h index 7655ee182c..7728e9ade7 100644 --- a/src/version.h +++ b/src/version.h @@ -36,5 +36,5 @@ #define VIM_VERSION_NODOT "vim70aa" #define VIM_VERSION_SHORT "7.0aa" #define VIM_VERSION_MEDIUM "7.0aa ALPHA" -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 1)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 1, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 2)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 2, compiled " |