changeset 638:593092a5362b

updated for version 7.0185
author vimboss
date Sun, 22 Jan 2006 23:22:22 +0000
parents a420bba0d851
children c79d4df4686e
files runtime/doc/visual.txt src/diff.c src/normal.c src/os_win32.h src/spell.c
diffstat 5 files changed, 59 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/visual.txt
+++ b/runtime/doc/visual.txt
@@ -1,4 +1,4 @@
-*visual.txt*    For Vim version 7.0aa.  Last change: 2005 Oct 09
+*visual.txt*    For Vim version 7.0aa.  Last change: 2006 Jan 22
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -258,6 +258,11 @@ operator character: "v{move-around}3>" (
 The {move-around} is any sequence of movement commands.  Note the difference
 with {motion}, which is only ONE movement command.
 
+Another way to operate on the Visual area is using the |/\%V| item in a
+pattern.  For example, to replace all '(' in the Visual area with '#': >
+
+	:%s/\%V(/X/g
+
 ==============================================================================
 5. Blockwise operators					*blockwise-operators*
 
--- a/src/diff.c
+++ b/src/diff.c
@@ -441,9 +441,10 @@ diff_mark_adjust(line1, line2, amount, a
     }
     diff_redraw(TRUE);
 
-    /* Recompute the scroll binding, may remove or add filler lines (e.g.,
-     * when adding lines above w_topline). */
-    check_scrollbind((linenr_T)0, 0L);
+    /* Need to recompute the scroll binding, may remove or add filler lines
+     * (e.g., when adding lines above w_topline). But it's slow when making
+     * many changes, postpone until redrawing. */
+    diff_need_scrollbind = TRUE;
 }
 
 /*
--- a/src/normal.c
+++ b/src/normal.c
@@ -3076,7 +3076,7 @@ check_visual_highlight()
 }
 
 /*
- * End visual mode.
+ * End Visual mode.
  * This function should ALWAYS be called to end Visual mode, except from
  * do_pending_operator().
  */
@@ -4843,7 +4843,7 @@ dozet:
 		break;
 
     case '=':	/* "z=": suggestions for a badly spelled word  */
-		if (!checkclearopq(cap->oap))
+		if (!checkclearop(cap->oap))
 		    spell_suggest((int)cap->count0);
 		break;
 #endif
--- a/src/os_win32.h
+++ b/src/os_win32.h
@@ -15,6 +15,12 @@
 #include <direct.h>		/* for _mkdir() */
 #endif
 
+/* Stop the VC2005 compiler from nagging. */
+#if _MSC_VER >= 1400
+# define _CRT_SECURE_NO_DEPRECATE
+# define _CRT_NONSTDC_NO_DEPRECATE
+#endif
+
 #define BINARY_FILE_IO
 #define USE_EXE_NAME		/* use argv[0] for $VIM */
 #define SYNC_DUP_CLOSE		/* sync() a file with dup() and close() */
--- a/src/spell.c
+++ b/src/spell.c
@@ -845,7 +845,7 @@ static void set_spell_charflags __ARGS((
 static int set_spell_chartab __ARGS((char_u *fol, char_u *low, char_u *upp));
 static int spell_casefold __ARGS((char_u *p, int len, char_u *buf, int buflen));
 static int check_need_cap __ARGS((linenr_T lnum, colnr_T col));
-static void spell_find_suggest __ARGS((char_u *badptr, suginfo_T *su, int maxcount, int banbadword, int need_cap, int interactive));
+static void spell_find_suggest __ARGS((char_u *badptr, int badlen, suginfo_T *su, int maxcount, int banbadword, int need_cap, int interactive));
 #ifdef FEAT_EVAL
 static void spell_suggest_expr __ARGS((suginfo_T *su, char_u *expr));
 #endif
@@ -4461,7 +4461,6 @@ typedef struct afffile_S
 {
     char_u	*af_enc;	/* "SET", normalized, alloc'ed string or NULL */
     int		af_flagtype;	/* AFT_CHAR, AFT_LONG, AFT_NUM or AFT_CAPLONG */
-    int		af_slash;	/* character used in word for slash */
     unsigned	af_rare;	/* RARE ID for rare word */
     unsigned	af_keepcase;	/* KEEPCASE ID for keep-case word */
     unsigned	af_bad;		/* BAD ID for banned word */
@@ -4985,14 +4984,6 @@ spell_read_aff(spin, fname)
 	    {
 		/* ignored, we look in the tree for what chars may appear */
 	    }
-	    else if (STRCMP(items[0], "SLASH") == 0 && itemcnt == 2
-							&& aff->af_slash == 0)
-	    {
-		aff->af_slash = items[1][0];
-		if (items[1][1] != NUL)
-		    smsg((char_u *)_("Character used for SLASH must be ASCII; in %s line %d: %s"),
-			    fname, lnum, items[1]);
-	    }
 	    /* TODO: remove "RAR" later */
 	    else if ((STRCMP(items[0], "RAR") == 0
 			|| STRCMP(items[0], "RARE") == 0) && itemcnt == 2
@@ -6060,13 +6051,13 @@ spell_read_dic(spin, fname, affile)
 	    continue;	/* empty line */
 	line[l] = NUL;
 
-	/* Find the optional affix names.  Replace the SLASH character by a
-	 * slash. */
+	/* Truncate the word at the "/", set "afflist" to what follows.
+	 * Replace "\/" by "/" and "\\" by "\". */
 	afflist = NULL;
 	for (p = line; *p != NUL; mb_ptr_adv(p))
 	{
-	    if (*p == affile->af_slash)
-		*p = '/';
+	    if (*p == '\\' && (p[1] == '\\' || p[1] == '/'))
+		mch_memmove(p, p + 1, STRLEN(p));
 	    else if (*p == '/')
 	    {
 		*p = NUL;
@@ -9358,6 +9349,7 @@ spell_check_sps()
 /*
  * "z?": Find badly spelled word under or after the cursor.
  * Give suggestions for the properly spelled word.
+ * In Visual mode use the highlighted word as the bad word.
  * When "count" is non-zero use that suggestion.
  */
     void
@@ -9376,14 +9368,35 @@ spell_suggest(count)
     int		need_cap;
     int		limit;
     int		selected = count;
-
-    /* Find the start of the badly spelled word. */
-    if (spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL) == 0
+    int		badlen = 0;
+
+    if (no_spell_checking(curwin))
+	return;
+
+#ifdef FEAT_VISUAL
+    if (VIsual_active)
+    {
+	/* Use the Visually selected text as the bad word.  But reject
+	 * a multi-line selection. */
+	if (curwin->w_cursor.lnum != VIsual.lnum)
+	{
+	    vim_beep();
+	    return;
+	}
+	badlen = (int)curwin->w_cursor.col - (int)VIsual.col;
+	if (badlen < 0)
+	    badlen = -badlen;
+	else
+	    curwin->w_cursor.col = VIsual.col;
+	++badlen;
+	end_visual_mode();
+    }
+    else
+#endif
+	/* Find the start of the badly spelled word. */
+	if (spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL) == 0
 	    || curwin->w_cursor.col > prev_cursor.col)
     {
-	if (!curwin->w_p_spell || *curbuf->b_p_spl == NUL)
-	    return;
-
 	/* No bad word or it starts after the cursor: use the word under the
 	 * cursor. */
 	curwin->w_cursor = prev_cursor;
@@ -9417,7 +9430,7 @@ spell_suggest(count)
 	limit = (int)Rows - 2;
     else
 	limit = sps_limit;
-    spell_find_suggest(line + curwin->w_cursor.col, &sug, limit,
+    spell_find_suggest(line + curwin->w_cursor.col, badlen, &sug, limit,
 							TRUE, need_cap, TRUE);
 
     if (sug.su_ga.ga_len == 0)
@@ -9728,7 +9741,7 @@ spell_suggest_list(gap, word, maxcount, 
     suggest_T	*stp;
     char_u	*wcopy;
 
-    spell_find_suggest(word, &sug, maxcount, FALSE, need_cap, interactive);
+    spell_find_suggest(word, 0, &sug, maxcount, FALSE, need_cap, interactive);
 
     /* Make room in "gap". */
     ga_init2(gap, sizeof(char_u *), sug.su_ga.ga_len + 1);
@@ -9761,8 +9774,9 @@ spell_suggest_list(gap, word, maxcount, 
  * This is based on the mechanisms of Aspell, but completely reimplemented.
  */
     static void
-spell_find_suggest(badptr, su, maxcount, banbadword, need_cap, interactive)
+spell_find_suggest(badptr, badlen, su, maxcount, banbadword, need_cap, interactive)
     char_u	*badptr;
+    int		badlen;		/* length of bad word or 0 if unknown */
     suginfo_T	*su;
     int		maxcount;
     int		banbadword;	/* don't include badword in suggestions */
@@ -9792,7 +9806,10 @@ spell_find_suggest(badptr, su, maxcount,
     hash_init(&su->su_banned);
 
     su->su_badptr = badptr;
-    su->su_badlen = spell_check(curwin, su->su_badptr, &attr, NULL, FALSE);
+    if (badlen != 0)
+	su->su_badlen = badlen;
+    else
+	su->su_badlen = spell_check(curwin, su->su_badptr, &attr, NULL, FALSE);
     su->su_maxcount = maxcount;
     su->su_maxscore = SCORE_MAXINIT;