]> git.pld-linux.org Git - packages/vim.git/blame - vim-ispell.patch
- added ispell patch with online spell checking feature
[packages/vim.git] / vim-ispell.patch
CommitLineData
24ec98f0
JB
1diff -Nur vim60am.old/src/Makefile vim60am/src/Makefile
2--- vim60am.old/src/Makefile Wed Jul 4 20:42:09 2001
3+++ vim60am/src/Makefile Tue Jul 3 18:55:58 2001
4@@ -1077,6 +1077,22 @@
5 # Use this for cproto 3 patchlevel 7 or above (use "cproto -V" to check):
6 PROTO_FLAGS = -m -M__ARGS -d -E"$(CPP)" $(NO_ATTR)
7
8+SPELL_SRC = spell.c \
9+ spell/good.c \
10+ spell/lookup.c \
11+ spell/hash.c \
12+ spell/makedent.c \
13+ spell/tree.c \
14+ spell/tgood.c \
15+ spell/util.c
16+SPELL_OBJ = objects/spell.o \
17+ objects/good.o \
18+ objects/lookup.o \
19+ objects/hash.o \
20+ objects/makedent.o \
21+ objects/tree.o \
22+ objects/tgood.o \
23+ objects/util.o
24
25 ################################################
26 ## no changes required below this line ##
27@@ -1087,7 +1103,7 @@
28 .SUFFIXES:
29 .SUFFIXES: .cc .c .o .pro
30
31-PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS)
32+PRE_DEFS = -Iproto -Ispell $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS)
33 POST_DEFS = $(X_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(TCL_CFLAGS) $(RUBY_CFLAGS) $(EXTRA_DEFS)
34
35 ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(POST_DEFS)
36@@ -1167,6 +1183,7 @@
37 screen.c \
38 search.c \
39 syntax.c \
40+ $(SPELL_SRC) \
41 tag.c \
42 term.c \
43 ui.c \
44@@ -1232,6 +1249,7 @@
45 objects/screen.o \
46 objects/search.o \
47 objects/syntax.o \
48+ $(SPELL_OBJ) \
49 $(SNIFF_OBJ) \
50 objects/tag.o \
51 objects/term.o \
52@@ -2094,6 +2112,9 @@
53 objects/undo.o: undo.c
54 $(CCC) -o $@ undo.c
55
56+objects/spell.o: spell.c spell/local.h
57+ $(CCC) -o $@ spell.c
58+
59 objects/window.o: window.c
60 $(CCC) -o $@ window.c
61
62@@ -2212,6 +2233,9 @@
63 objects/search.o: search.c vim.h auto/config.h feature.h os_unix.h \
64 auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \
65 gui.h option.h ex_cmds.h proto.h globals.h farsi.h
66+objects/spell.o: spell.c vim.h spell/config.h feature.h os_unix.h auto/osdef.h ascii.h \
67+ keymap.h term.h macros.h regexp.h structs.h gui.h globals.h farsi.h \
68+ option.h ex_cmds.h proto.h spell/local.h spell/wm.h spell/ispell.h
69 objects/syntax.o: syntax.c vim.h auto/config.h feature.h os_unix.h \
70 auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \
71 gui.h option.h ex_cmds.h proto.h globals.h farsi.h
72@@ -2334,3 +2358,26 @@
73 objects/integration.o: integration.c vim.h auto/config.h feature.h os_unix.h \
74 auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \
75 gui.h option.h ex_cmds.h proto.h globals.h farsi.h integration.h
76+
77+SPELL_CFLAGS=$(CFLAGS) -pedantic -DUSG=1
78+
79+objects/good.o: spell/good.c spell/config.h spell/ispell.h spell/i_proto.h spell/msgs.h spell/local.h
80+ $(CC) -c $(SPELL_CFLAGS) spell/good.c -o objects/good.o
81+
82+objects/lookup.o: spell/lookup.c spell/config.h spell/ispell.h spell/i_proto.h spell/msgs.h spell/local.h
83+ $(CC) -c $(SPELL_CFLAGS) spell/lookup.c -o objects/lookup.o
84+
85+objects/hash.o: spell/hash.c spell/config.h spell/ispell.h spell/i_proto.h spell/local.h
86+ $(CC) -c $(SPELL_CFLAGS) spell/hash.c -o objects/hash.o
87+
88+objects/makedent.o: spell/makedent.c spell/config.h spell/ispell.h spell/i_proto.h spell/msgs.h spell/local.h
89+ $(CC) -c $(SPELL_CFLAGS) spell/makedent.c -o objects/makedent.o
90+
91+objects/tree.o: spell/tree.c spell/config.h spell/ispell.h spell/i_proto.h spell/msgs.h spell/local.h
92+ $(CC) -c $(SPELL_CFLAGS) spell/tree.c -o objects/tree.o
93+
94+objects/tgood.o: spell/tgood.c spell/config.h spell/ispell.h spell/i_proto.h spell/local.h
95+ $(CC) -c $(SPELL_CFLAGS) spell/tgood.c -o objects/tgood.o
96+
97+objects/util.o: spell/util.c spell/config.h spell/ispell.h spell/i_proto.h spell/local.h
98+ $(CC) -c $(SPELL_CFLAGS) spell/util.c -o objects/util.o
99diff -Nur vim60am.old/src/edit.c vim60am/src/edit.c
100--- vim60am.old/src/edit.c Wed Jul 4 20:42:09 2001
101+++ vim60am/src/edit.c Tue Jul 3 18:50:12 2001
102@@ -613,7 +613,11 @@
103 if (c == Ctrl_V && ctrl_x_mode == CTRL_X_CMDLINE)
104 goto docomplete;
105 #endif
106- if (c == Ctrl_V || c == Ctrl_Q)
107+ if (c == Ctrl_V
108+#ifndef FEAT_SPELL_HL /* WM */
109+ || c == Ctrl_Q
110+#endif
111+ )
112 {
113 ins_ctrl_v();
114 c = Ctrl_V; /* pretend CTRL-V is last typed character */
115@@ -1133,6 +1137,20 @@
116 continue_status = 0;
117 break;
118 #endif /* FEAT_INS_EXPAND */
119+#ifdef FEAT_SPELL_HL /* WM */
120+ case Ctrl_Q:
121+ if(set_to_private_dict(
122+ ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE),
123+ curwin->w_cursor.col, FALSE))
124+ vim_beep();
125+ break;
126+ case Ctrl_S:
127+ if(set_to_private_dict(
128+ ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE),
129+ curwin->w_cursor.col, TRUE))
130+ vim_beep();
131+ break;
132+#endif
133
134 case Ctrl_Y: /* copy from previous line or scroll down */
135 case Ctrl_E: /* copy from next line or scroll up */
136diff -Nur vim60am.old/src/ex_cmds.h vim60am/src/ex_cmds.h
137--- vim60am.old/src/ex_cmds.h Wed Jul 4 20:42:09 2001
138+++ vim60am/src/ex_cmds.h Tue Jul 3 18:49:12 2001
139@@ -700,6 +700,8 @@
140 RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY),
141 EX(CMD_source, "source", ex_source,
142 BANG|FILE1|TRLBAR|SBOXOK|CMDWIN),
143+EX(CMD_spell, "spell", ex_spell,
144+ EXTRA|NOTRLCOM|CMDWIN),
145 EX(CMD_split, "split", ex_splitview,
146 BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR),
147 EX(CMD_sprevious, "sprevious", ex_previous,
148diff -Nur vim60am.old/src/ex_docmd.c vim60am/src/ex_docmd.c
149--- vim60am.old/src/ex_docmd.c Wed Jul 4 20:42:09 2001
150+++ vim60am/src/ex_docmd.c Tue Jul 3 18:47:38 2001
151@@ -218,6 +218,9 @@
152 #ifndef FEAT_SYN_HL
153 # define ex_syntax ex_ni
154 #endif
155+#ifndef FEAT_SPELL_HL
156+# define ex_spell ex_ni
157+#endif
158 #ifndef FEAT_PERL
159 # define ex_perl ex_ni
160 # define ex_perldo ex_ni
161@@ -2546,6 +2549,12 @@
162 set_context_in_syntax_cmd(xp, arg);
163 break;
164 #endif
165+#ifdef FEAT_SPELL_HL
166+ case CMD_spell:
167+ return arg;
168+ break;
169+#endif
170+
171 #ifdef FEAT_EVAL
172 case CMD_let:
173 case CMD_if:
174diff -Nur vim60am.old/src/feature.h vim60am/src/feature.h
175--- vim60am.old/src/feature.h Wed Jul 4 20:42:09 2001
176+++ vim60am/src/feature.h Tue Jul 3 18:46:14 2001
177@@ -315,6 +315,12 @@
178 # endif
179 # define FEAT_FKMAP
180 #endif
181+#ifdef FEAT_BIG
182+#undef FEAT_RIGHTLEFT
183+#undef FEAT_FKMAP
184+#define FEAT_SPELL_HL /*WM*/
185+#endif
186+/* # define FEAT_PRINTER */
187
188 /*
189 * +emacs_tags When FEAT_EMACS_TAGS defined: Include support for
190diff -Nur vim60am.old/src/globals.h vim60am/src/globals.h
191--- vim60am.old/src/globals.h Wed Jul 4 20:42:09 2001
192+++ vim60am/src/globals.h Tue Jul 3 18:45:54 2001
193@@ -718,6 +718,9 @@
194 #ifdef USE_TERM_CONSOLE
195 EXTERN int term_console INIT(= FALSE); /* set to TRUE when console used */
196 #endif
197+#ifdef FEAT_SPELL_HL
198+EXTERN char_u hashname[MAXPATHL]; /* name of the dictionary */
199+#endif
200 EXTERN int termcap_active INIT(= FALSE); /* set by starttermcap() */
201 EXTERN int cur_tmode INIT(= TMODE_COOK); /* input terminal mode */
202 EXTERN int bangredo INIT(= FALSE); /* set to TRUE whith ! command */
203diff -Nur vim60am.old/src/main.c vim60am/src/main.c
204--- vim60am.old/src/main.c Wed Jul 4 20:42:09 2001
205+++ vim60am/src/main.c Tue Jul 3 18:45:08 2001
206@@ -1901,6 +1901,9 @@
207 }
208 }
209 #endif /* FEAT_VIMINFO */
210+#ifdef FEAT_SPELL_HL
211+ spell_save_private_dict();
212+#endif
213
214 #ifdef FEAT_AUTOCMD
215 apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf);
216diff -Nur vim60am.old/src/normal.c vim60am/src/normal.c
217--- vim60am.old/src/normal.c Wed Jul 4 20:42:09 2001
218+++ vim60am/src/normal.c Tue Jul 3 18:44:28 2001
219@@ -85,6 +85,10 @@
220 #ifdef FEAT_VISUAL
221 static int get_visual_text __ARGS((cmdarg_T *cap, char_u **pp, int *lenp));
222 #endif
223+#ifdef FEAT_SPELL_HL
224+static void nv_settodict_q __ARGS((cmdarg_T *cap));
225+static void nv_settodict_s __ARGS((cmdarg_T *cap));
226+#endif
227 static void nv_tagpop __ARGS((cmdarg_T *cap));
228 static void nv_scroll __ARGS((cmdarg_T *cap));
229 static void nv_kright __ARGS((cmdarg_T *cap));
230@@ -226,9 +230,17 @@
231 {Ctrl_N, nv_down, NV_STS, FALSE},
232 {Ctrl_O, nv_ctrlo, 0, 0},
233 {Ctrl_P, nv_up, NV_STS, FALSE},
234+#ifdef FEAT_SPELL_HL
235+ {Ctrl_Q, nv_settodict_q, 0, 0},
236+#else
237 {Ctrl_Q, nv_ignore, 0, 0},
238+#endif
239 {Ctrl_R, nv_redo, 0, 0},
240+#ifdef FEAT_SPELL_HL
241+ {Ctrl_S, nv_settodict_s, 0, 0},
242+#else
243 {Ctrl_S, nv_ignore, 0, 0},
244+#endif
245 {Ctrl_T, nv_tagpop, NV_NCW, 0},
246 {Ctrl_U, nv_halfpage, 0, 0},
247 #ifdef FEAT_VISUAL
248@@ -7316,6 +7328,28 @@
249 #endif
250 }
251
252+#ifdef FEAT_SPELL_HL
253+static void
254+nv_settodict_q(cap)
255+ cmdarg_T *cap;
256+{
257+ if(set_to_private_dict(
258+ ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE),
259+ curwin->w_cursor.col, FALSE))
260+ clearopbeep(cap->oap);
261+}
262+
263+static void
264+nv_settodict_s(cap)
265+ cmdarg_T *cap;
266+{
267+ if(set_to_private_dict(
268+ ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE),
269+ curwin->w_cursor.col, TRUE))
270+ clearopbeep(cap->oap);
271+}
272+#endif
273+
274 #ifdef FEAT_VISUAL
275 /*
276 * In exclusive Visual mode, may include the last character.
277diff -Nur vim60am.old/src/option.c vim60am/src/option.c
278--- vim60am.old/src/option.c Wed Jul 4 20:42:09 2001
279+++ vim60am/src/option.c Tue Jul 3 18:42:14 2001
280@@ -116,6 +116,8 @@
281 , PV_SW
282 , PV_SWF
283 , PV_SYN
284+ , PV_SPELL_DIR
285+ , PV_SPELL_LANG
286 , PV_TAGS
287 , PV_TS
288 , PV_TSR
289@@ -216,6 +218,10 @@
290 #ifdef FEAT_SYN_HL
291 static char_u *p_syn;
292 #endif
293+#ifdef FEAT_SPELL_HL
294+static char_u *p_spelldirectory;
295+static char_u *p_language;
296+#endif
297 static long p_ts;
298 static long p_tw;
299 static int p_tx;
300@@ -1001,7 +1007,7 @@
301 {(char_u *)FALSE, (char_u *)0L}},
302 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
303 (char_u *)&p_hl, PV_NONE,
304- {(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",
305+ {(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,Z:Spell",
306 (char_u *)0L}},
307 {"history", "hi", P_NUM|P_VIM,
308 (char_u *)&p_hi, PV_NONE,
309@@ -1247,6 +1253,13 @@
310 (char_u *)NULL, PV_NONE,
311 #endif
312 {(char_u *)"", (char_u *)0L}},
313+ {"language", "lang", P_STRING|P_ALLOCED|P_VI_DEF,
314+#ifdef FEAT_SPELL_HL
315+ (char_u *)&p_language, PV_SPELL_LANG,
316+#else
317+ (char_u *)NULL, PV_NONE,
318+#endif
319+ {(char_u *)"", (char_u *)0L}},
320 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
321 #ifdef FEAT_WINDOWS
322 (char_u *)&p_ls, PV_NONE,
323@@ -1815,6 +1828,14 @@
324 {"sourceany", NULL, P_BOOL|P_VI_DEF,
325 (char_u *)NULL, PV_NONE,
326 {(char_u *)FALSE, (char_u *)0L}},
327+ {"spelldirectory", "spelldir", P_STRING|P_ALLOCED|P_VI_DEF|P_EXPAND,
328+#ifdef FEAT_SPELL_HL
329+ (char_u *)&p_spelldirectory, PV_SPELL_DIR,
330+ {(char_u *)"/usr/lib/ispell", (char_u *)0L}},
331+#else
332+ (char_u *)NULL, PV_NONE,
333+ {(char_u *)"", (char_u *)0L}},
334+#endif
335 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
336 #ifdef FEAT_WINDOWS
337 (char_u *)&p_sb, PV_NONE,
338@@ -4337,6 +4357,26 @@
339 errmsg = e_invarg;
340 }
341 #endif
342+#ifdef FEAT_SPELL_HL
343+ else if (varp == &p_spell_dir)
344+ {
345+ STRCPY(hashname, p_spell_dir);
346+ STRCAT(hashname, "/");
347+ STRCAT(hashname, p_spell_lang);
348+ STRCAT(hashname, ".hash");
349+ reload_dict();
350+ redraw_all_later(NOT_VALID);
351+ }
352+ else if (varp == &p_spell_lang)
353+ {
354+ STRCPY(hashname, p_spell_dir);
355+ STRCAT(hashname, "/");
356+ STRCAT(hashname, p_spell_lang);
357+ STRCAT(hashname, ".hash");
358+ reload_dict();
359+ redraw_all_later(NOT_VALID);
360+ }
361+#endif
362
363 #ifdef FEAT_MBYTE
364 /* 'encoding' and 'fileencoding' */
365@@ -6998,6 +7038,10 @@
366 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
367 #ifdef FEAT_SYN_HL
368 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
369+#endif
370+#ifdef FEAT_SPELL_HL
371+ case PV_SPELL_DIR: return (char_u *)&(p_spell_dir);
372+ case PV_SPELL_LANG: return (char_u *)&(p_spell_lang);
373 #endif
374 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
375 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
376diff -Nur vim60am.old/src/option.h vim60am/src/option.h
377--- vim60am.old/src/option.h Wed Jul 4 20:42:09 2001
378+++ vim60am/src/option.h Tue Jul 3 18:40:28 2001
379@@ -336,6 +336,8 @@
380 EXTERN char_u *p_dex; /* 'diffexpr' */
381 # endif
382 #endif
383+EXTERN char_u *p_spell_dir; /* directory with spell hash*/
384+EXTERN char_u *p_spell_lang; /* name of language (spell hash file)*/
385 #ifdef FEAT_INS_EXPAND
386 EXTERN char_u *p_dict; /* 'dictionary' */
387 #endif
388diff -Nur vim60am.old/src/os_msdos.c vim60am/src/os_msdos.c
389--- vim60am.old/src/os_msdos.c Wed Jul 4 20:42:09 2001
390+++ vim60am/src/os_msdos.c Tue Jul 3 18:39:48 2001
391@@ -78,7 +78,7 @@
392 */
393
394 unsigned long S_ulScreenBase = 0xb8000;
395-unsigned short S_uiAttribute = 0;
396+unsigned short S_uiAttribute = 7 << 8;
397 int S_iCurrentRow = 0; /* These are 0 offset */
398 int S_iCurrentColumn = 0;
399 int S_iLeft = 0; /* Scroll window; these are 1 offset */
400@@ -248,6 +248,9 @@
401 }
402 else
403 {
404+ if(iChar == ' ')
405+ uiValue = ((S_uiAttribute & 0xf700) | 0x700) | ' ';
406+ else
407 uiValue = S_uiAttribute | (unsigned char)iChar;
408
409 /*
410@@ -309,6 +312,7 @@
411 mytextattr(int iAttribute)
412 {
413 S_uiAttribute = (unsigned short)iAttribute << 8;
414+ textattr(iAttribute); /* for delline() etc */
415 }
416
417 static void
418@@ -322,6 +326,7 @@
419 {
420 S_uiAttribute = (unsigned short)((S_uiAttribute & 0xf000)
421 | (unsigned short)iTextColor << 8);
422+ textattr(S_uiAttribute >> 8); /* for delline() etc */
423 }
424
425 static void
426@@ -329,6 +334,7 @@
427 {
428 S_uiAttribute = (unsigned short)((S_uiAttribute & 0x0f00)
429 | (unsigned short)(iBkgColor << 12));
430+ textattr(S_uiAttribute >> 8); /* for delline() etc */
431 }
432 /*
433 * Getdigits: Get a number from a string and skip over it.
434@@ -470,6 +476,7 @@
435 static union REGS regs;
436 static int saved = FALSE;
437
438+ return; /* WM */
439 if (restore)
440 {
441 if (saved)
442@@ -495,6 +502,7 @@
443 mch_set_cursor_shape(int thickness)
444 {
445 union REGS regs;
446+ return; /* WM */
447
448 regs.h.ch = 7 - thickness; /*Starting Line*/
449 regs.h.cl = 7; /*Ending Line*/
450@@ -508,6 +516,7 @@
451 int idx;
452 int thickness;
453
454+ return; /* WM */
455 /*
456 * How the cursor is drawn depends on the current mode.
457 */
458@@ -2226,6 +2235,7 @@
459 char *
460 djgpp_setlocale(void)
461 {
462+ char *country;
463 __dpmi_regs regs;
464 struct { char id; unsigned short off, seg; } __attribute__ ((packed)) info;
465 unsigned char buffer[0x82], lower, upper;
466@@ -2267,6 +2277,127 @@
467 __dj_ctype_tolower[upper+1] = lower;
468 }
469 }
470+ if ((country = getenv("COUNTRY")) != NULL)
471+ {
472+ if(!strcmp(country, "MAZOWIA"))
473+ {
474