diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-03-22 23:03:44 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-03-22 23:03:44 +0000 |
commit | 6bb683663ad7ae9c303284c335a731a13233c6c2 (patch) | |
tree | ae1a51eb5403b7182a3bdd4d16c86b4bc1705a7a /src | |
parent | fc73515f7ba66b47705265bb8d01c6bec5df09c4 (diff) | |
download | vim-6bb683663ad7ae9c303284c335a731a13233c6c2.zip |
updated for version 7.0063
Diffstat (limited to 'src')
-rw-r--r-- | src/Make_bc3.mak | 1 | ||||
-rw-r--r-- | src/Make_ming.mak | 1 | ||||
-rw-r--r-- | src/Make_ro.mak | 6 | ||||
-rw-r--r-- | src/Make_w16.mak | 1 | ||||
-rw-r--r-- | src/charset.c | 103 | ||||
-rw-r--r-- | src/globals.h | 2 | ||||
-rw-r--r-- | src/mbyte.c | 2 | ||||
-rw-r--r-- | src/misc2.c | 2 | ||||
-rw-r--r-- | src/option.c | 12 | ||||
-rw-r--r-- | src/os_unix.c | 2 | ||||
-rw-r--r-- | src/screen.c | 2 | ||||
-rw-r--r-- | src/structs.h | 1 | ||||
-rw-r--r-- | src/syntax.c | 17 | ||||
-rw-r--r-- | src/term.c | 8 | ||||
-rw-r--r-- | src/version.h | 4 |
15 files changed, 140 insertions, 24 deletions
diff --git a/src/Make_bc3.mak b/src/Make_bc3.mak index df219ba60..e48575051 100644 --- a/src/Make_bc3.mak +++ b/src/Make_bc3.mak @@ -83,6 +83,7 @@ EXE_dependencies = \ regexp.obj \ screen.obj \ search.obj \ + spell.obj \ syntax.obj \ tag.obj \ term.obj \ diff --git a/src/Make_ming.mak b/src/Make_ming.mak index 1633b6586..ead13c740 100644 --- a/src/Make_ming.mak +++ b/src/Make_ming.mak @@ -392,6 +392,7 @@ OBJ = \ $(OUTDIR)/regexp.o \ $(OUTDIR)/screen.o \ $(OUTDIR)/search.o \ + $(OUTDIR)/spell.o \ $(OUTDIR)/syntax.o \ $(OUTDIR)/tag.o \ $(OUTDIR)/term.o \ diff --git a/src/Make_ro.mak b/src/Make_ro.mak index 65f176cd4..4297568ad 100644 --- a/src/Make_ro.mak +++ b/src/Make_ro.mak @@ -15,8 +15,8 @@ OBJS = o.buffer o.charset o.diff o.digraph o.edit o.eval o.ex_cmds o.ex_cmds2 o.ex_docmd o.ex_eval o.ex_getln o.fileio o.fold o.getchar o.hashtable o.main o.mark o.mbyte \ o.memfile o.memline o.menu o.message o.misc1 o.misc2 o.move \ o.normal o.ops o.option o.quickfix o.regexp o.screen o.search \ - o.syntax o.tag o.term o.termlib o.ui o.undo o.version o.window \ - o.os_riscos o.swis o.gui o.gui_riscos + o.spell o.syntax o.tag o.term o.termlib o.ui o.undo o.version \ + o.window o.os_riscos o.swis o.gui o.gui_riscos Vim: $(OBJS) $(GCC) -o Vim $(OBJS) @@ -109,6 +109,8 @@ o.screen: c.screen o.search: c.search +o.spell: c.spell + o.syntax: c.syntax o.tag: c.tag diff --git a/src/Make_w16.mak b/src/Make_w16.mak index 1b71f313e..303c66275 100644 --- a/src/Make_w16.mak +++ b/src/Make_w16.mak @@ -110,6 +110,7 @@ ObjFiles = \ $(INTDIR)\regexp.obj\ $(INTDIR)\screen.obj\ $(INTDIR)\search.obj\ + $(INTDIR)\spell.obj\ $(INTDIR)\syntax.obj\ $(INTDIR)\tag.obj\ $(INTDIR)\term.obj\ diff --git a/src/charset.c b/src/charset.c index b51d07208..bd319ffe7 100644 --- a/src/charset.c +++ b/src/charset.c @@ -130,12 +130,13 @@ buf_init_chartab(buf, global) */ vim_memset(buf->b_chartab, 0, (size_t)32); #ifdef FEAT_MBYTE - for (c = 0; c < 256; ++c) - { - /* double-byte characters are probably word characters */ - if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2) - SET_CHARTAB(buf, c); - } + if (enc_dbcs != 0) + for (c = 0; c < 256; ++c) + { + /* double-byte characters are probably word characters */ + if (MB_BYTE2LEN(c) == 2) + SET_CHARTAB(buf, c); + } #endif #ifdef FEAT_LISP @@ -913,6 +914,96 @@ vim_iswordc_buf(p, buf) # endif return (GET_CHARTAB(buf, *p) != 0); } + +static char spell_chartab[256]; + +/* + * Init the chartab used for spelling. Only depends on 'encoding'. + * Called once while starting up and when 'encoding' was changed. + * Unfortunately, we can't use isalpha() here, since the current locale may + * differ from 'encoding'. + */ + void +init_spell_chartab() +{ + int i; + + /* ASCII is always the same, no matter what 'encoding' is used. + * EBCDIC is not supported! */ + for (i = 0; i < '0'; ++i) + spell_chartab[i] = FALSE; + /* We include numbers. A word shouldn't start with a number, but handling + * that is done separately. */ + for ( ; i <= '9'; ++i) + spell_chartab[i] = TRUE; + for ( ; i < 'A'; ++i) + spell_chartab[i] = FALSE; + for ( ; i <= 'Z'; ++i) + spell_chartab[i] = TRUE; + for ( ; i < 'a'; ++i) + spell_chartab[i] = FALSE; + for ( ; i <= 'z'; ++i) + spell_chartab[i] = TRUE; +#ifdef FEAT_MBYTE + if (enc_dbcs) + { + /* DBCS: assume double-wide characters are word characters. */ + for ( ; i <= 255; ++i) + if (MB_BYTE2LEN(i) == 2) + spell_chartab[i] = TRUE; + else + spell_chartab[i] = FALSE; + } + else if (STRCMP(p_enc, "cp850") == 0) +#endif +#if defined(MSDOS) || defined(FEAT_MBYTE) + { + /* cp850, MS-DOS */ + for ( ; i < 128; ++i) + spell_chartab[i] = FALSE; + for ( ; i <= 0x9a; ++i) + spell_chartab[i] = TRUE; + for ( ; i < 0xa0; ++i) + spell_chartab[i] = FALSE; + for ( ; i <= 0xa5; ++i) + spell_chartab[i] = TRUE; + for ( ; i <= 255; ++i) + spell_chartab[i] = FALSE; + } +#endif +#ifdef FEAT_MBYTE + else +#endif +#if defined(FEAT_MBYTE) || !defined(MSDOS) + { + /* Rough guess: anything we don't recognize assumes word characters + * like latin1. */ + for ( ; i < 0xc0; ++i) + spell_chartab[i] = FALSE; + for ( ; i <= 255; ++i) + spell_chartab[i] = TRUE; +# ifdef FEAT_MBYTE + if (STRCMP(p_enc, "latin1") == 0) +# endif + spell_chartab[0xf7] = FALSE; /* divide-by */ + } +#endif +} + +/* + * Return TRUE if "p" points to a word character. + * This only depends on 'encoding', not on 'iskeyword'. + */ + int +spell_iswordc(p) + char_u *p; +{ +# ifdef FEAT_MBYTE + if (has_mbyte && MB_BYTE2LEN(*p) > 1) + return mb_get_class(p) >= 2; +# endif + return spell_chartab[*p]; +} #endif /* diff --git a/src/globals.h b/src/globals.h index 1253f35d1..af4eed0f3 100644 --- a/src/globals.h +++ b/src/globals.h @@ -362,7 +362,7 @@ EXTERN int mouse_dragging INIT(= 0); /* extending Visual area with * When the DEC mouse has been pressed but not yet released we enable * automatic querys for the mouse position. */ -EXTERN int WantQueryMouse INIT(= 0); +EXTERN int WantQueryMouse INIT(= FALSE); # endif # ifdef FEAT_GUI diff --git a/src/mbyte.c b/src/mbyte.c index 695b651bb..7f8400d5c 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -3096,7 +3096,7 @@ iconv_string(vcp, str, slen, unconvlenp) else { l = (*mb_ptr2len_check)((char_u *)from); - if (l > fromlen) + if (l > (int)fromlen) l = fromlen; } from += l; diff --git a/src/misc2.c b/src/misc2.c index d4d975dda..ebf3933e8 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -3146,7 +3146,7 @@ update_mouseshape(shape_idx) int new_mouse_shape; /* Only works in GUI mode. */ - if (!gui.in_use) + if (!gui.in_use || gui.starting) return; /* Postpone the updating when more is to come. Speeds up executing of diff --git a/src/option.c b/src/option.c index b4593a7e0..1e94dc8c2 100644 --- a/src/option.c +++ b/src/option.c @@ -2029,7 +2029,7 @@ static struct vimoption (char_u *)NULL, PV_NONE, #endif {(char_u *)FALSE, (char_u *)0L}}, - {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA, + {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF, #ifdef FEAT_SYN_HL (char_u *)&p_spl, PV_SPL, {(char_u *)"", (char_u *)0L} @@ -2825,6 +2825,11 @@ set_init_1() /* Must be before option_expand(), because that one needs vim_isIDc() */ didset_options(); +#ifdef FEAT_SYN_HL + /* Use the current chartab for the generic chartab. */ + init_spell_chartab(); +#endif + #ifdef FEAT_LINEBREAK /* * initialize the table for 'breakat'. @@ -5558,7 +5563,8 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, errmsg = e_invarg; else check_mouse_termcode(); - setmouse(); /* may switch it on again */ + if (termcap_active) + setmouse(); /* may switch it on again */ } #endif @@ -5656,7 +5662,7 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, #endif #ifdef FEAT_SYN_HL - /* When 'spellang' is set, load the wordlists. */ + /* When 'spelllang' is set, load the wordlists. */ else if (varp == &(curbuf->b_p_spl)) { errmsg = did_set_spelllang(curbuf); diff --git a/src/os_unix.c b/src/os_unix.c index 284a68e3d..f41ed464b 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4273,7 +4273,7 @@ WaitForChar(msec) /* May need to query the mouse position. */ if (WantQueryMouse) { - WantQueryMouse = 0; + WantQueryMouse = FALSE; mch_write((char_u *)IF_EB("\033[1'|", ESC_STR "[1'|"), 5); } #endif diff --git a/src/screen.c b/src/screen.c index fe3368579..28565fa42 100644 --- a/src/screen.c +++ b/src/screen.c @@ -3600,7 +3600,7 @@ win_line(wp, lnum, startrow, endrow) 1); spell_attr = 0; - iswordc = vim_iswordc_buf(prev_ptr, wp->w_buffer); + iswordc = spell_iswordc(prev_ptr); if (iswordc && !prev_iswordc) { word_end = v + spell_check(wp, prev_ptr, diff --git a/src/structs.h b/src/structs.h index 78f292944..a45a98ee4 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1424,6 +1424,7 @@ struct file_buffer garray_T b_syn_patterns; /* table for syntax patterns */ garray_T b_syn_clusters; /* table for syntax clusters */ int b_spell_cluster_id; /* @Spell cluster ID or 0 */ + int b_nospell_cluster_id; /* @NoSpell cluster ID or 0 */ int b_syn_containedin; /* TRUE when there is an item with a "containedin" argument */ int b_syn_sync_flags; /* flags about how to sync */ diff --git a/src/syntax.c b/src/syntax.c index 662b8a59c..a6741cf17 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -2202,9 +2202,20 @@ syn_current_attr(syncing, displaying, can_spell) * done in the current item. */ - /* Always do spelling if there is no @Spell cluster. */ + /* If there is no @Spell cluster: Do spelling for items without + * @NoSpell. Otherwise only in items with @Spell */ if (syn_buf->b_spell_cluster_id == 0) - *can_spell = TRUE; + { + if (syn_buf->b_nospell_cluster_id == 0 || current_trans_id == 0) + *can_spell = TRUE; + else + { + sps.inc_tag = 0; + sps.id = syn_buf->b_nospell_cluster_id; + sps.cont_in_list = NULL; + *can_spell = !in_id_list(sip, sip->si_cont_list, &sps, 0); + } + } else if (current_trans_id == 0) *can_spell = FALSE; else @@ -5094,6 +5105,8 @@ syn_add_cluster(name) if (STRICMP(name, "Spell") == 0) curbuf->b_spell_cluster_id = len + SYNID_CLUSTER; + if (STRICMP(name, "NoSpell") == 0) + curbuf->b_nospell_cluster_id = len + SYNID_CLUSTER; return len + SYNID_CLUSTER; } diff --git a/src/term.c b/src/term.c index 2f9568a64..c4f2d9f8e 100644 --- a/src/term.c +++ b/src/term.c @@ -4521,23 +4521,23 @@ check_termcode(max_offset, buf, buflen) { held_button = mouse_code; mouse_code |= MOUSE_DRAG; - WantQueryMouse = 1; + WantQueryMouse = TRUE; } is_drag = TRUE; showmode(); break; case 2: mouse_code = MOUSE_LEFT; - WantQueryMouse = 1; + WantQueryMouse = TRUE; break; case 3: mouse_code = MOUSE_RELEASE | MOUSE_LEFT; break; case 4: mouse_code = MOUSE_MIDDLE; - WantQueryMouse = 1; + WantQueryMouse = TRUE; break; case 5: mouse_code = MOUSE_RELEASE | MOUSE_MIDDLE; break; case 6: mouse_code = MOUSE_RIGHT; - WantQueryMouse = 1; + WantQueryMouse = TRUE; break; case 7: mouse_code = MOUSE_RELEASE | MOUSE_RIGHT; break; diff --git a/src/version.h b/src/version.h index 5d04e57d5..2f2da8bab 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 Mar 20)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Mar 20, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Mar 22)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Mar 22, compiled " |