summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-08-11 20:09:58 +0000
committerBram Moolenaar <Bram@vim.org>2005-08-11 20:09:58 +0000
commit488c6512d9fbe998b2d6ef64bd50d323ccb6607f (patch)
tree9e73a6df9accd1ad5c03e4271e4144708b5722d3 /src
parent8b1e71fa25088fa133b440327cb4f500a3a61767 (diff)
updated for version 7.0128
Diffstat (limited to 'src')
-rw-r--r--src/edit.c79
-rw-r--r--src/option.c2
-rw-r--r--src/proto/spell.pro4
-rw-r--r--src/version.h4
4 files changed, 69 insertions, 20 deletions
diff --git a/src/edit.c b/src/edit.c
index 41214b837b..fe130e6ab0 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -32,14 +32,15 @@
#define CTRL_X_CMDLINE 11
#define CTRL_X_FUNCTION 12
#define CTRL_X_OCCULT 13
-#define CTRL_X_LOCAL_MSG 14 /* only used in "ctrl_x_msgs" */
+#define CTRL_X_SPELL 14
+#define CTRL_X_LOCAL_MSG 15 /* only used in "ctrl_x_msgs" */
#define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT]
static char *ctrl_x_msgs[] =
{
N_(" Keyword completion (^N^P)"), /* ctrl_x_mode == 0, ^P/^N compl. */
- N_(" ^X mode (^E^Y^L^]^F^I^K^D^U^V^N^P)"),
+ N_(" ^X mode (^]^D^E^F^I^K^L^N^O^P^S^U^V^Y)"),
NULL,
N_(" Whole line completion (^L^N^P)"),
N_(" File name completion (^F^N^P)"),
@@ -52,6 +53,7 @@ static char *ctrl_x_msgs[] =
N_(" Command-line completion (^V^N^P)"),
N_(" User defined completion (^U^N^P)"),
N_(" Occult completion (^O^N^P)"),
+ N_(" Spelling suggestion (^S^N^P)"),
N_(" Keyword Local completion (^N^P)"),
};
@@ -152,7 +154,7 @@ static int cindent_on __ARGS((void));
static void ins_reg __ARGS((void));
static void ins_ctrl_g __ARGS((void));
static void ins_ctrl_hat __ARGS((void));
-static int ins_esc __ARGS((long *count, int cmdchar, int c));
+static int ins_esc __ARGS((long *count, int cmdchar, int nomove));
#ifdef FEAT_RIGHTLEFT
static void ins_ctrl_ __ARGS((void));
#endif
@@ -266,6 +268,7 @@ edit(cmdchar, startln, count)
int inserted_space = FALSE; /* just inserted a space */
int replaceState = REPLACE;
int did_restart_edit = restart_edit;
+ int nomove = FALSE; /* don't move cursor on return */
/* sleep before redrawing, needed for "CTRL-O :" that results in an
* error message */
@@ -658,8 +661,9 @@ edit(cmdchar, startln, count)
ins_compl_prep(c);
#endif
- /* CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to mode
- * selected with 'insertmode'. */
+ /* CTRL-\ CTRL-N goes to Normal mode,
+ * CTRL-\ CTRL-G goes to mode selected with 'insertmode',
+ * CTRL-\ CTRL-O is like CTRL-O but without moving the cursor. */
if (c == Ctrl_BSL)
{
/* may need to redraw when no more chars available now */
@@ -669,8 +673,9 @@ edit(cmdchar, startln, count)
c = safe_vgetc();
--no_mapping;
--allow_keys;
- if (c != Ctrl_N && c != Ctrl_G) /* it's something else */
+ if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O)
{
+ /* it's something else */
vungetc(c);
c = Ctrl_BSL;
}
@@ -678,6 +683,12 @@ edit(cmdchar, startln, count)
continue;
else
{
+ if (c == Ctrl_O)
+ {
+ ins_ctrl_o();
+ ins_at_eol = FALSE; /* cursor keeps its column */
+ nomove = TRUE;
+ }
count = 0;
goto doESCkey;
}
@@ -787,7 +798,7 @@ doESCkey:
if (ins_at_eol && gchar_cursor() == NUL)
o_lnum = curwin->w_cursor.lnum;
- if (ins_esc(&count, cmdchar, c))
+ if (ins_esc(&count, cmdchar, nomove))
{
#ifdef FEAT_AUTOCMD
if (cmdchar != 'r' && cmdchar != 'v')
@@ -1117,6 +1128,12 @@ doESCkey:
if (ctrl_x_mode != CTRL_X_FILES)
goto normalchar;
goto docomplete;
+
+ case 's': /* Spelling completion after ^X */
+ case Ctrl_S:
+ if (ctrl_x_mode != CTRL_X_SPELL)
+ goto normalchar;
+ goto docomplete;
#endif
case Ctrl_L: /* Whole line completion after ^X */
@@ -1799,7 +1816,8 @@ vim_is_ctrl_x_key(c)
|| c == Ctrl_L || c == Ctrl_F || c == Ctrl_RSB
|| c == Ctrl_I || c == Ctrl_D || c == Ctrl_P
|| c == Ctrl_N || c == Ctrl_T || c == Ctrl_V
- || c == Ctrl_Q || c == Ctrl_U || c == Ctrl_O);
+ || c == Ctrl_Q || c == Ctrl_U || c == Ctrl_O
+ || c == Ctrl_S || c == 's');
case CTRL_X_SCROLL:
return (c == Ctrl_Y || c == Ctrl_E);
case CTRL_X_WHOLE_LINE:
@@ -1827,6 +1845,8 @@ vim_is_ctrl_x_key(c)
#endif
case CTRL_X_OCCULT:
return (c == Ctrl_O || c == Ctrl_P || c == Ctrl_N);
+ case CTRL_X_SPELL:
+ return (c == Ctrl_S || c == Ctrl_P || c == Ctrl_N);
}
EMSG(_(e_internal));
return FALSE;
@@ -2342,6 +2362,10 @@ ins_compl_prep(c)
case Ctrl_O:
ctrl_x_mode = CTRL_X_OCCULT;
break;
+ case 's':
+ case Ctrl_S:
+ ctrl_x_mode = CTRL_X_SPELL;
+ break;
case Ctrl_RSB:
ctrl_x_mode = CTRL_X_TAGS;
break;
@@ -2855,6 +2879,15 @@ ins_compl_get_exp(ini, dir)
ins_compl_add_matches(num_matches, matches, dir);
break;
+ case CTRL_X_SPELL:
+#ifdef FEAT_SYN_HL
+ num_matches = expand_spelling(first_match_pos.lnum,
+ first_match_pos.col, compl_pattern, &matches);
+ if (num_matches > 0)
+ ins_compl_add_matches(num_matches, matches, dir);
+#endif
+ break;
+
default: /* normal ^P/^N and ^X^L */
/*
* If 'infercase' is set, don't use 'smartcase' here
@@ -3496,6 +3529,18 @@ ins_complete(c)
if (compl_pattern == NULL)
return FAIL;
}
+ else if (ctrl_x_mode == CTRL_X_SPELL)
+ {
+#ifdef FEAT_SYN_HL
+ compl_col = spell_word_start(startcol);
+ if (compl_col == startcol)
+ return FAIL;
+ compl_length = (int)curs_col - compl_col;
+ compl_pattern = vim_strnsave(line + compl_col, compl_length);
+ if (compl_pattern == NULL)
+#endif
+ return FAIL;
+ }
else
{
EMSG2(_(e_intern2), "ins_complete()");
@@ -6272,10 +6317,10 @@ ins_ctrl_hat()
* insert.
*/
static int
-ins_esc(count, cmdchar, c)
+ins_esc(count, cmdchar, nomove)
long *count;
int cmdchar;
- int c; /* typed character */
+ int nomove; /* don't move cursor */
{
int temp;
static int disabled_redraw = FALSE;
@@ -6353,18 +6398,20 @@ ins_esc(count, cmdchar, c)
/*
* The cursor should end up on the last inserted character.
- * Don't do it for CTRL-O or CTRL-L.
+ * Don't do it for CTRL-O, unless past the end of the line.
*/
- if ((curwin->w_cursor.col != 0
+ if (!nomove
+ && (curwin->w_cursor.col != 0
#ifdef FEAT_VIRTUALEDIT
|| curwin->w_cursor.coladd > 0
#endif
- ) && ((restart_edit == NUL && c != Ctrl_L)
- || (gchar_cursor() == NUL
+ )
+ && (restart_edit == NUL
+ || (gchar_cursor() == NUL
#ifdef FEAT_VISUAL
- && !VIsual_active
+ && !VIsual_active
#endif
- ))
+ ))
#ifdef FEAT_RIGHTLEFT
&& !revins_on
#endif
diff --git a/src/option.c b/src/option.c
index ab66727869..d1444fbf4f 100644
--- a/src/option.c
+++ b/src/option.c
@@ -2035,7 +2035,7 @@ static struct vimoption
(char_u *)NULL, PV_NONE,
#endif
{(char_u *)FALSE, (char_u *)0L}},
- {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE|P_RBUF,
+ {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
#ifdef FEAT_SYN_HL
(char_u *)&p_spc, PV_SPC,
{(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
diff --git a/src/proto/spell.pro b/src/proto/spell.pro
index 1b47b313a0..2123440160 100644
--- a/src/proto/spell.pro
+++ b/src/proto/spell.pro
@@ -13,7 +13,9 @@ void init_spell_chartab __ARGS((void));
int spell_check_sps __ARGS((void));
void spell_suggest __ARGS((void));
void ex_spellrepall __ARGS((exarg_T *eap));
-void spell_suggest_list __ARGS((garray_T *gap, char_u *word, int maxcount));
+void spell_suggest_list __ARGS((garray_T *gap, char_u *word, int maxcount, int need_cap));
char_u *eval_soundfold __ARGS((char_u *word));
void ex_spelldump __ARGS((exarg_T *eap));
+int spell_word_start __ARGS((int startcol));
+int expand_spelling __ARGS((linenr_T lnum, int col, char_u *pat, char_u ***matchp));
/* vim: set ft=c : */
diff --git a/src/version.h b/src/version.h
index 85a221e202..9d047e0c68 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 Aug 10)"
-#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Aug 10, compiled "
+#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Aug 11)"
+#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Aug 11, compiled "