diff options
author | Bram Moolenaar <Bram@vim.org> | 2004-12-09 21:34:53 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2004-12-09 21:34:53 +0000 |
commit | 293ee4d421cd55f4a3c014c1c26edf02f718cc83 (patch) | |
tree | ae4856e718b752ea0c6c807912bfbb51967fae80 /src | |
parent | 741b07e0092eb6d7b81c9cbe149196c6cf9d5bbe (diff) | |
download | vim-git-293ee4d421cd55f4a3c014c1c26edf02f718cc83.tar.gz |
updated for version 7.0021v7.0021
Diffstat (limited to 'src')
41 files changed, 546 insertions, 257 deletions
diff --git a/src/Make_ro.mak b/src/Make_ro.mak index 6ac2f94b5..82708f41f 100644 --- a/src/Make_ro.mak +++ b/src/Make_ro.mak @@ -2,18 +2,16 @@ # Makefile for Vim on RISC OS - Andy Wingate # -GCC = gcc -mthrowback -CFLAGS = -DRISCOS -DFEAT_GUI -# Optimising on ex_docmd.c seems to cause segfaults on compilation. Needs investigation. -CCEX_DOCMD = $(GCC) $(CFLAGS) -CC = $(GCC) $(CFLAGS) -O2 +GCC = gcc -mthrowback +CFLAGS = -DRISCOS -DFEAT_GUI +CC = $(GCC) $(CFLAGS) -O2 # -DUP_BC_PC_EXTERN for term.c needed as BC defined in termlib.c and term.c TERMFLAG = -DUP_BC_PC_EXTERN ASMFLAGS = -throwback -objasm -gcc -OBJS = o.buffer o.charset o.digraph o.edit o.eval o.ex_cmds o.ex_cmds2 o.diff \ +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.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 \ @@ -26,7 +24,7 @@ Vim: $(OBJS) install: Vim squeeze -v Vim @.!Vim.Vim -clean: +clean: create o.!fake! 0 wipe o.* ~cf remove Vim @@ -35,134 +33,93 @@ o.swis: s.swis as $(ASMFLAGS) -o o.swis s.swis # Rules for object files -# You shouldn't need to put all this information in as all but term.c have the same -# rule (and only then to save extra defines) but some versions of make are awkward. + +o.%: c.% + $(CC) -c $< -o $@ o.buffer: c.buffer - $(CC) -c c.buffer -o o.buffer o.charset: c.charset - $(CC) -c c.charset -o o.charset o.digraph: c.digraph - $(CC) -c c.digraph -o o.digraph o.diff: c.diff - $(CC) -c c.diff -o o.diff o.edit: c.edit - $(CC) -c c.edit -o o.edit o.eval: c.eval - $(CC) -c c.eval -o o.eval o.ex_cmds: c.ex_cmds - $(CC) -c c.ex_cmds -o o.ex_cmds o.ex_cmds2: c.ex_cmds2 - $(CC) -c c.ex_cmds2 -o o.ex_cmds2 o.ex_docmd: c.ex_docmd - $(CCEX_DOCMD) -c c.ex_docmd -o o.ex_docmd o.ex_eval: c.ex_eval - $(CCEX_DOCMD) -c c.ex_eval -o o.ex_eval o.ex_getln: c.ex_getln - $(CC) -c c.ex_getln -o o.ex_getln o.fileio: c.fileio - $(CC) -c c.fileio -o o.fileio o.fold: c.fold - $(CC) -c c.fold -o o.fold o.getchar: c.getchar - $(CC) -c c.getchar -o o.getchar o.gui: c.gui - $(CC) -c c.gui -o o.gui o.gui_riscos: c.gui_riscos - $(CC) -c c.gui_riscos -o o.gui_riscos o.main: c.main - $(CC) -c c.main -o o.main o.mark: c.mark - $(CC) -c c.mark -o o.mark o.mbyte: c.mbyte - $(CC) -c c.mbyte -o o.mbyte o.memfile: c.memfile - $(CC) -c c.memfile -o o.memfile o.memline: c.memline - $(CC) -c c.memline -o o.memline o.menu: c.menu - $(CC) -c c.menu -o o.menu o.message: c.message - $(CC) -c c.message -o o.message o.misc1: c.misc1 - $(CC) -c c.misc1 -o o.misc1 o.misc2: c.misc2 - $(CC) -c c.misc2 -o o.misc2 o.move: c.move - $(CC) -c c.move -o o.move o.normal: c.normal - $(CC) -c c.normal -o o.normal o.ops: c.ops - $(CC) -c c.ops -o o.ops o.option: c.option - $(CC) -c c.option -o o.option o.os_riscos: c.os_riscos - $(CC) -c c.os_riscos -o o.os_riscos o.pty: c.pty - $(CC) -c c.pty -o p.pty o.quickfix: c.quickfix - $(CC) -c c.quickfix -o o.quickfix o.regexp: c.regexp - $(CC) -c c.regexp -o o.regexp o.screen: c.screen - $(CC) -c c.screen -o o.screen o.search: c.search - $(CC) -c c.search -o o.search o.syntax: c.syntax - $(CC) -c c.syntax -o o.syntax o.tag: c.tag - $(CC) -c c.tag -o o.tag o.term: c.term $(CC) $(TERMFLAG) -c c.term -o o.term o.termlib: c.termlib - $(CC) -c c.termlib -o o.termlib o.ui: c.ui - $(CC) -c c.ui -o o.ui o.undo: c.undo - $(CC) -c c.undo -o o.undo o.version: c.version - $(CC) -c c.version -o o.version o.window: c.window - $(CC) -c c.window -o o.window diff --git a/src/buffer.c b/src/buffer.c index a1d593dab..f02c00d25 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -538,8 +538,7 @@ buf_freeall(buf, del_buf, wipe_buf) return; } # ifdef FEAT_EVAL - /* autocmds may abort script processing */ - if (aborting()) + if (aborting()) /* autocmds may abort script processing */ return; # endif @@ -755,7 +754,6 @@ handle_swap_exists(old_curbuf) # endif } swap_exists_action = SEA_NONE; - } #endif @@ -1031,8 +1029,12 @@ do_buffer(action, start, dir, count, forceit) * now. */ return FAIL; # endif + /* If it's still changed fail silently, the dialog already + * mentioned why it fails. */ + if (bufIsChanged(buf)) + return FAIL; } - if (bufIsChanged(buf)) + else #endif { EMSGN(_("E89: No write since last change for buffer %ld (add ! to override)"), @@ -1518,8 +1520,7 @@ buflist_new(ffname, sfname, lnum, flags) if (buf == curbuf) apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf); # ifdef FEAT_EVAL - /* autocmds may abort script processing */ - if (aborting()) + if (aborting()) /* autocmds may abort script processing */ return NULL; # endif #endif @@ -1572,8 +1573,7 @@ buflist_new(ffname, sfname, lnum, flags) if (buf != curbuf) /* autocommands deleted the buffer! */ return NULL; #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) - /* autocmds may abort script processing */ - if (aborting()) + if (aborting()) /* autocmds may abort script processing */ return NULL; #endif /* buf->b_nwindows = 0; why was this here? */ @@ -1649,8 +1649,7 @@ buflist_new(ffname, sfname, lnum, flags) if (flags & BLN_LISTED) apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, buf); # ifdef FEAT_EVAL - /* autocmds may abort script processing */ - if (aborting()) + if (aborting()) /* autocmds may abort script processing */ return NULL; # endif } diff --git a/src/eval.c b/src/eval.c index 88b954971..27783792f 100644 --- a/src/eval.c +++ b/src/eval.c @@ -4485,7 +4485,16 @@ f_foldtext(argvars, retvar) s = skipwhite(ml_get(lnum)); /* skip C comment-start */ if (s[0] == '/' && (s[1] == '*' || s[1] == '/')) + { s = skipwhite(s + 2); + if (*skipwhite(s) == NUL + && lnum + 1 < (linenr_T)vimvars[VV_FOLDEND].val) + { + s = skipwhite(ml_get(lnum + 1)); + if (*s == '*') + s = skipwhite(s + 1); + } + } txt = _("+-%s%3ld lines: "); r = alloc((unsigned)(STRLEN(txt) + STRLEN(vimvars[VV_FOLDDASHES].val) /* for %s */ diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 30a5f3a8a..7ad5513bc 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -7892,7 +7892,6 @@ update_topline_cursor() ex_normal(eap) exarg_T *eap; { - oparg_T oa; int save_msg_scroll = msg_scroll; int save_restart_edit = restart_edit; int save_msg_didout = msg_didout; @@ -7996,30 +7995,17 @@ ex_normal(eap) */ do { - clear_oparg(&oa); - finish_op = FALSE; if (eap->addr_count != 0) { curwin->w_cursor.lnum = eap->line1++; curwin->w_cursor.col = 0; } - /* - * Stuff the argument into the typeahead buffer. - * Execute normal_cmd() until there is no typeahead left. - */ - ins_typebuf( + exec_normal_cmd( #ifdef FEAT_MBYTE arg != NULL ? arg : #endif - eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, 0, - TRUE, FALSE); - while ((!stuff_empty() || (!typebuf_typed() && typebuf.tb_len > 0)) - && !got_int) - { - update_topline_cursor(); - normal_cmd(&oa, FALSE); /* execute a Normal mode cmd */ - } + eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); } while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); } @@ -8085,6 +8071,35 @@ ex_stopinsert(eap) } #endif +#if defined(FEAT_EX_EXTRA) || defined(FEAT_MENU) || defined(PROTO) +/* + * Execute normal mode command "cmd". + * "remap" can be REMAP_NONE or REMAP_YES. + */ + void +exec_normal_cmd(cmd, remap, silent) + char_u *cmd; + int remap; + int silent; +{ + oparg_T oa; + + /* + * Stuff the argument into the typeahead buffer. + * Execute normal_cmd() until there is no typeahead left. + */ + clear_oparg(&oa); + finish_op = FALSE; + ins_typebuf(cmd, remap, 0, TRUE, silent); + while ((!stuff_empty() || (!typebuf_typed() && typebuf.tb_len > 0)) + && !got_int) + { + update_topline_cursor(); + normal_cmd(&oa, FALSE); /* execute a Normal mode cmd */ + } +} +#endif + #ifdef FEAT_FIND_ID static void ex_checkpath(eap) @@ -8742,6 +8757,17 @@ makeopens(fd, dirnow) } /* + * If there is an empty, unnamed buffer we will wipe it out later. + * Remember the buffer number. + */ + if (put_line(fd, "if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''") == FAIL) + return FAIL; + if (put_line(fd, " let s:wipebuf = bufnr('%')") == FAIL) + return FAIL; + if (put_line(fd, "endif") == FAIL) + return FAIL; + + /* * Now save the current files, current buffer first. */ if (put_line(fd, "set shortmess=aoO") == FAIL) @@ -8876,6 +8902,18 @@ makeopens(fd, dirnow) return FAIL; /* + * Wipe out an empty unnamed buffer we started in. + */ + if (put_line(fd, "if exists('s:wipebuf')") == FAIL) + return FAIL; + if (put_line(fd, " exe 'bwipe ' . s:wipebuf") == FAIL) + return FAIL; + if (put_line(fd, "endif") == FAIL) + return FAIL; + if (put_line(fd, "unlet! s:wipebuf") == FAIL) + return FAIL; + + /* * Restore window sizes again after jumping around in windows, because the * current window has a minimum size while others may not. */ diff --git a/src/ex_eval.c b/src/ex_eval.c index 8be11e13b..e2699bc74 100644 --- a/src/ex_eval.c +++ b/src/ex_eval.c @@ -1820,19 +1820,25 @@ ex_endtry(eap) } /* - * Function to be called before a failed command invokes a sequence of - * autocommands for cleanup. (Failure means here that a call to emsg() has - * been made, an interrupt occurred, or there is an uncaught exception from a - * previous autocommand execution of the same command.) This function works a - * bit like ex_finally() except that there was not actually an extra try block - * around the part that failed and an error or interrupt has not (yet) been - * converted to an exception. This function saves the - * error/interrupt/exception state and prepares for the call to do_cmdline() - * that is going to be made for the cleanup autocommand execution. + * enter_cleanup() and leave_cleanup() * - * Stores the pending error/interrupt/exception state in the cleanup_T - * structure pointed to by "csp", which has to be passed as an argument to - * leave_cleanup() after the autocommand execution has finished. + * Functions to be called before/after invoking a sequence of autocommands for + * cleanup for a failed command. (Failure means here that a call to emsg() + * has been made, an interrupt occurred, or there is an uncaught exception + * from a previous autocommand execution of the same command.) + * + * Call enter_cleanup() with a pointer to a cleanup_T and pass the same + * pointer to leave_cleanup(). The cleanup_T structure stores the pending + * error/interrupt/exception state. + */ + +/* + * This function works a bit like ex_finally() except that there was not + * actually an extra try block around the part that failed and an error or + * interrupt has not (yet) been converted to an exception. This function + * saves the error/interrupt/ exception state and prepares for the call to + * do_cmdline() that is going to be made for the cleanup autocommand + * execution. */ void enter_cleanup(csp) @@ -1883,16 +1889,19 @@ enter_cleanup(csp) } /* - * Function to be called after a failed command invoked a sequence of - * autocommands for cleanup. It is a bit like ex_endtry() except that there - * was not actually an extra try block around the part that failed and an - * error or interrupt had not (yet) been converted to an exception when the - * cleanup autocommand sequence was invoked. This function has to be called - * with the address of the cleanup_T structure filled by enter_cleanup() as an - * argument; it restores the error/interrupt/exception state saved by that - * function - except there was an aborting error, an interrupt or an uncaught - * exception during execution of the cleanup autocommands. In the latter - * case, the saved error/interrupt/ exception state is discarded. + * See comment above enter_cleanup() for how this function is used. + * + * This function is a bit like ex_endtry() except that there was not actually + * an extra try block around the part that failed and an error or interrupt + * had not (yet) been converted to an exception when the cleanup autocommand + * sequence was invoked. + * + * This function has to be called with the address of the cleanup_T structure + * filled by enter_cleanup() as an argument; it restores the error/interrupt/ + * exception state saved by that function - except there was an aborting + * error, an interrupt or an uncaught exception during execution of the + * cleanup autocommands. In the latter case, the saved error/interrupt/ + * exception state is discarded. */ void leave_cleanup(csp) @@ -1959,7 +1968,7 @@ leave_cleanup(csp) /* Report if required by the 'verbose' option or when debugging. */ report_resume_pending(pending, - (pending & CSTP_THROW) ? (void *)current_exception : NULL); + (pending & CSTP_THROW) ? (void *)current_exception : NULL); } } diff --git a/src/fileio.c b/src/fileio.c index 029a33938..c37c96a1d 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3985,8 +3985,9 @@ restore_backup: * journalled. Syncing the file slows down the system, but assures it has * been written to disk and we don't lose it. * For a device do try the fsync() but don't complain if it does not work - * (could be a pipe). */ - if (fsync(fd) != 0 && !device) + * (could be a pipe). + * If the 'fsync' option is FALSE, don't fsync(). Useful for laptops. */ + if (p_fs && fsync(fd) != 0 && !device) { errmsg = (char_u *)_("E667: Fsync failed"); end = 0; diff --git a/src/fold.c b/src/fold.c index 1aee87ce2..bb268fb25 100644 --- a/src/fold.c +++ b/src/fold.c @@ -902,6 +902,8 @@ foldMoveTo(updown, dir, count) int level; int last; + checkupdate(curwin); + /* Repeat "count" times. */ for (n = 0; n < count; ++n) { @@ -2883,7 +2885,7 @@ foldRemove(gap, top, bot) { /* Found an entry below top. */ fold_changed = TRUE; - if (fp->fd_top + fp->fd_len > bot) + if (fp->fd_top + fp->fd_len - 1 > bot) { /* 5: Make fold that includes bot start below bot. */ foldMarkAdjustRecurse(&fp->fd_nested, diff --git a/src/getchar.c b/src/getchar.c index f05054091..dd52ac4e9 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -1514,6 +1514,17 @@ vgetc() continue; } #endif +#ifdef HAVE_GTK2 + /* GTK: <F10> normally selects the menu, but it's passed until + * here to allow mapping it. Intercept and invoke the GTK + * behavior if it's not mapped. */ + if (c == K_F10 && gui.menubar != NULL) + { + gtk_menu_shell_select_first(GTK_MENU_SHELL(gui.menubar), FALSE); + continue; + } +#endif + #ifdef FEAT_GUI /* Translate K_CSI to CSI. The special key is only used to avoid * it being recognized as the start of a special key. */ @@ -1540,7 +1551,14 @@ vgetc() case K_KDIVIDE: c = '/'; break; case K_KMULTIPLY: c = '*'; break; case K_KENTER: c = CAR; break; - case K_KPOINT: c = '.'; break; + case K_KPOINT: +#ifdef WIN32 + /* Can be either '.' or a ',', * + * depending on the type of keypad. */ + c = MapVirtualKey(VK_DECIMAL, 2); break; +#else + c = '.'; break; +#endif case K_K0: c = '0'; break; case K_K1: c = '1'; break; case K_K2: c = '2'; break; diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 6d6d55d09..b67b6f2d2 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -3080,6 +3080,17 @@ gui_mch_init(void) gui.menubar = gtk_menu_bar_new(); gtk_widget_set_name(gui.menubar, "vim-menubar"); +# ifdef HAVE_GTK2 + /* Avoid that GTK takes <F10> away from us. */ + { + GtkSettings *gtk_settings; + + gtk_settings = gtk_settings_get_for_screen(gdk_screen_get_default()); + g_object_set(gtk_settings, "gtk-menu-bar-accel", NULL, NULL); + } +# endif + + # ifdef FEAT_GUI_GNOME if (using_gnome) { diff --git a/src/gui_mac.c b/src/gui_mac.c index f60567e57..7ad96fc29 100644 --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -3792,6 +3792,27 @@ gui_mch_draw_string(row, col, s, len, flags) (void)SwapQDTextFlags(qd_flags); } + /* + * When antialiasing we're using srcOr mode, we have to clear the block + * before drawing the text. + * Also needed when 'linespace' is non-zero to remove the cursor and + * underlining. + * But not when drawing transparently. + * The following is like calling gui_mch_clear_block(row, col, row, col + + * len - 1), but without setting the bg color to gui.back_pixel. + */ + if (((sys_version >= 0x1020 && p_antialias) || p_linespace != 0) + && !(flags & DRAW_TRANSP)) + { + Rect rc; + + rc.left = FILL_X(col); + rc.top = FILL_Y(row); + rc.right = FILL_X(col + len) + (col + len == Columns); + rc.bottom = FILL_Y(row + 1); + EraseRect(&rc); + } + if (sys_version >= 0x1020 && p_antialias) { StyleParameter face; @@ -3806,22 +3827,6 @@ gui_mch_draw_string(row, col, s, len, flags) /* Quartz antialiasing works only in srcOr transfer mode. */ TextMode(srcOr); - if (!(flags & DRAW_TRANSP)) - { - /* - * Since we're using srcOr mode, we have to clear the block - * before drawing the text. The following is like calling - * gui_mch_clear_block(row, col, row, col + len - 1), - * but without setting the bg color to gui.back_pixel. - */ - Rect rc; - rc.left = FILL_X(col); - rc.top = FILL_Y(row); - rc.right = FILL_X(col + len) + (col + len == Columns); - rc.bottom = FILL_Y(row + 1); - EraseRect(&rc); - } - MoveTo(TEXT_X(col), TEXT_Y(row)); DrawText((char*)s, 0, len); } diff --git a/src/gui_w32.c b/src/gui_w32.c index 0afa12de2..461dcefc5 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -789,8 +789,7 @@ _WndProc( break; } #ifdef MSWIN_FIND_REPLACE - else - if (uMsg == s_findrep_msg && s_findrep_msg != 0) + else if (uMsg == s_findrep_msg && s_findrep_msg != 0) { _OnFindRepl(); } @@ -1411,20 +1410,6 @@ gui_mch_set_bg_color(guicolor_T color) #include <imm.h> /* - * display composition string(korean) - */ - static void -DisplayCompStringOpaque(char_u *s, int len) -{ - int OldBkMode = GetBkMode(s_hdc); - - SetBkMode(s_hdc, OPAQUE); - gui_outstr_nowrap(s, len, GUI_MON_TRS_CURSOR, - (guicolor_T)0, (guicolor_T)0, 0); - SetBkMode(s_hdc, OldBkMode); -} - -/* * handle WM_IME_NOTIFY message */ static LRESULT diff --git a/src/gui_w48.c b/src/gui_w48.c index 4f0bab700..516d070eb 100644 --- a/src/gui_w48.c +++ b/src/gui_w48.c @@ -488,27 +488,49 @@ char_to_string(int ch, char_u *string, int slen) WCHAR wstring[2]; char_u *ws = NULL;; - /* "ch" is a UTF-16 character. Convert it to a string of bytes. When - * "enc_codepage" is non-zero use the standard Win32 function, otherwise - * use our own conversion function (e.g., for UTF-8). */ - wstring[0] = ch; - if (enc_codepage > 0) - len = WideCharToMultiByte(enc_codepage, 0, wstring, 1, string, slen, - 0, NULL); + if (os_version.dwPlatformId != VER_PLATFORM_WIN32_NT) + { + /* On Windows 95/98 we apparently get the character in the active + * codepage, not in UCS-2. If conversion is needed convert it to + * UCS-2 first. */ + if ((int)GetACP() == enc_codepage) + len = 0; /* no conversion required */ + else + { + string[0] = ch; + len = MultiByteToWideChar(GetACP(), 0, string, 1, wstring, 2); + } + } else { + wstring[0] = ch; len = 1; - ws = ucs2_to_enc(wstring, &len); - if (ws == NULL) - len = 0; + } + + if (len > 0) + { + /* "ch" is a UTF-16 character. Convert it to a string of bytes. When + * "enc_codepage" is non-zero use the standard Win32 function, + * otherwise use our own conversion function (e.g., for UTF-8). */ + if (enc_codepage > 0) + len = WideCharToMultiByte(enc_codepage, 0, wstring, len, + string, slen, 0, NULL); else { - if (len > slen) /* just in case */ - len = slen; - mch_memmove(string, ws, len); - vim_free(ws); + len = 1; + ws = ucs2_to_enc(wstring, &len); + if (ws == NULL) + len = 0; + else + { + if (len > slen) /* just in case */ + len = slen; + mch_memmove(string, ws, len); + vim_free(ws); + } } } + if (len == 0) #endif { @@ -682,9 +704,10 @@ _OnMouseButtonDown( * Holding down the left and right buttons simulates pushing the middle * button. */ - if (repeated_click && - ((button == MOUSE_LEFT && s_button_pending == MOUSE_RIGHT) || - (button == MOUSE_RIGHT && s_button_pending == MOUSE_LEFT))) + if (repeated_click + && ((button == MOUSE_LEFT && s_button_pending == MOUSE_RIGHT) + || (button == MOUSE_RIGHT + && s_button_pending == MOUSE_LEFT))) { /* * Hmm, gui.c will ignore more than one button down at a time, so @@ -745,7 +768,7 @@ _OnMouseMoveOrRelease( { /* Delayed action for mouse down event */ _OnMouseEvent(s_button_pending, s_x_pending, - s_y_pending, FALSE, s_kFlags_pending); + s_y_pending, FALSE, s_kFlags_pending); s_button_pending = -1; } if (s_uMsg == WM_MOUSEMOVE) @@ -1532,6 +1555,9 @@ process_message(void) int i; int modifiers = 0; int key; +#ifdef FEAT_MENU + static char_u k10[] = {K_SPECIAL, 'k', ';', 0}; +#endif GetMessage(&msg, NULL, 0, 0); @@ -1619,11 +1645,11 @@ process_message(void) && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000))) { #ifdef FEAT_MENU - /* Check for <F10>: Windows selects the menu. Ignore it when - * 'winaltkeys' is "yes" or "menu" */ + /* Check for <F10>: Windows selects the menu. When <F10> is + * mapped we want to use the mapping instead. */ if (vk == VK_F10 && gui.menu_is_active - && (*p_wak == 'y' || *p_wak == 'm')) + && check_map(k10, State, FALSE) == NULL) break; #endif if (GetKeyState(VK_SHIFT) & 0x8000) @@ -1734,9 +1760,10 @@ process_message(void) #endif #ifdef FEAT_MENU - /* Check for <F10>: Windows selects the menu. Don't let Windows handle it - * when 'winaltkeys' is "no" */ - if (vk != VK_F10 || *p_wak != 'n') + /* Check for <F10>: Default effect is to select the menu. When <F10> is + * mapped we need to stop it here to avoid strange effects (e.g., for the + * key-up event) */ + if (vk != VK_F10 || check_map(k10, State, FALSE) == NULL) #endif DispatchMessage(&msg); } @@ -1829,6 +1856,11 @@ gui_mch_wait_for_chars(int wtime) s_wait_timer = 0; } allow_scrollbar = FALSE; + + /* Clear pending mouse button, the release event may have been + * taken by the dialog window. */ + s_button_pending = -1; + return OK; } } diff --git a/src/if_cscope.c b/src/if_cscope.c index 012e86c76..f218ea421 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -1092,7 +1092,7 @@ cs_find_common(opt, pat, forceit, verbose) return FALSE; } } - if (qfpos != NULL && *qfpos != '0' && totmatches > 1) + if (qfpos != NULL && *qfpos != '0' && totmatches > 0) { /* fill error list */ FILE *f; diff --git a/src/if_python.c b/src/if_python.c index 8f4fdfd19..511378a0d 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -381,13 +381,14 @@ typedef PyObject PyThreadState; #endif /* Python 1.4 */ #ifndef PY_CAN_RECURSE -static PyThreadState* saved_python_thread = NULL; +static PyThreadState *saved_python_thread = NULL; /* * Suspend a thread of the Python interpreter, other threads are allowed to * run. */ -static void Python_SaveThread(void) + static void +Python_SaveThread(void) { saved_python_thread = PyEval_SaveThread(); } @@ -396,7 +397,8 @@ static void Python_SaveThread(void) * Restore a thread of the Python interpreter, waits for other threads to * block. */ -static void Python_RestoreThread(void) + static void +Python_RestoreThread(void) { PyEval_RestoreThread(saved_python_thread); saved_python_thread = NULL; @@ -456,8 +458,10 @@ Python_Init(void) if (PythonMod_Init()) goto fail; -#ifndef PY_CAN_RECURSE - /* the first python thread is vim's */ + /* the first python thread is vim's, release the lock */ +#ifdef PY_CAN_RECURSE + PyEval_SaveThread(); +#else Python_SaveThread(); #endif diff --git a/src/keymap.h b/src/keymap.h index 24b0d61d8..cb79ad1e1 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -383,7 +383,7 @@ enum key_extra #define K_KDIVIDE TERMCAP2KEY('K', '8') /* keypad / */ #define K_KMULTIPLY TERMCAP2KEY('K', '9') /* keypad * */ #define K_KENTER TERMCAP2KEY('K', 'A') /* keypad Enter */ -#define K_KPOINT TERMCAP2KEY('K', 'B') /* keypad . */ +#define K_KPOINT TERMCAP2KEY('K', 'B') /* keypad . or ,*/ #define K_K0 TERMCAP2KEY('K', 'C') /* keypad 0 */ #define K_K1 TERMCAP2KEY('K', 'D') /* keypad 1 */ diff --git a/src/main.c b/src/main.c index 3976a4433..5791bb640 100644 --- a/src/main.c +++ b/src/main.c @@ -2228,6 +2228,12 @@ main_loop(cmdwin) getout_preserve_modified(exitval) int exitval; { +#if defined(UNIX) + /* Ignore SIGHUP, because a dropped connection may make Vim exit and then + * get a SIGHUP while exiting, which causes various reentrent problems. */ + signal(SIGHUP, SIG_IGN); +#endif + ml_close_notmod(); /* close all not-modified buffers */ ml_sync_all(FALSE, FALSE); /* preserve all swap files */ ml_close_all(FALSE); /* close all memfiles, without deleting */ diff --git a/src/menu.c b/src/menu.c index 258b84da9..a64745bcc 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2107,8 +2107,9 @@ ex_emenu(eap) return; } - /* Found the menu, so execute. */ - if (restart_edit) + /* Found the menu, so execute. + * Use the Insert mode entry when returning to Insert mode. */ + if (restart_edit && !current_SID) { mode = (char_u *)"Insert"; idx = MENU_INDEX_INSERT; @@ -2123,8 +2124,7 @@ ex_emenu(eap) /* GEDDES: This is not perfect - but it is a * quick way of detecting whether we are doing this from a * selection - see if the range matches up with the visual - * select start and end. - */ + * select start and end. */ if ((curbuf->b_visual_start.lnum == eap->line1) && (curbuf->b_visual_end.lnum) == eap->line2) { @@ -2144,8 +2144,7 @@ ex_emenu(eap) tpos.col = MAXCOL; } - /* Activate visual mode - */ + /* Activate visual mode */ VIsual_active = TRUE; VIsual_reselect = TRUE; check_cursor(); @@ -2155,8 +2154,7 @@ ex_emenu(eap) check_cursor(); /* Adjust the cursor to make sure it is in the correct pos - * for exclusive mode - */ + * for exclusive mode */ if (*p_sel == 'e' && gchar_cursor() != NUL) ++curwin->w_cursor.col; } @@ -2168,7 +2166,13 @@ ex_emenu(eap) if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL) { - ins_typebuf(menu->strings[idx], menu->noremap[idx], 0, + /* When executing a script or function execute the commands right now. + * Otherwise put them in the typeahead buffer. */ + if (current_SID != 0) + exec_normal_cmd(menu->strings[idx], menu->noremap[idx], + menu->silent[idx]); + else + ins_typebuf(menu->strings[idx], menu->noremap[idx], 0, TRUE, menu->silent[idx]); } else diff --git a/src/message.c b/src/message.c index d678bf3b9..caf7ac0a4 100644 --- a/src/message.c +++ b/src/message.c @@ -487,7 +487,7 @@ msg_source(attr) } /* remember the last sourcing name printed, also when it's empty */ - if (sourcing_name == NULL || other_sourcing_name) + if (sourcing_name == NULL || other_sourcing_name()) { vim_free(last_sourcing_name); if (sourcing_name == NULL) diff --git a/src/misc1.c b/src/misc1.c index ec744861e..4dc5a4179 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -7653,6 +7653,12 @@ get_lisp_indent() void prepare_to_exit() { +#if defined(UNIX) + /* Ignore SIGHUP, because a dropped connection may make Vim exit and then + * get a SIGHUP while exiting, which causes various reentrent problems. */ + signal(SIGHUP, SIG_IGN); +#endif + #ifdef FEAT_GUI if (gui.in_use) { diff --git a/src/move.c b/src/move.c index 0c37aa0d2..d1eb0257c 100644 --- a/src/move.c +++ b/src/move.c @@ -1551,7 +1551,12 @@ scrollup_clamp() --curwin->w_topfill; else #endif + { +#ifdef FEAT_FOLDING + (void)hasFolding(curwin->w_topline, NULL, &curwin->w_topline); +#endif ++curwin->w_topline; + } ++curwin->w_botline; /* approximate w_botline */ curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE); } diff --git a/src/netbeans.c b/src/netbeans.c index 50ea1886c..b51ddfbd3 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -2380,7 +2380,7 @@ special_keys(char_u *args) if ((sep = strchr(tok, '-')) != NULL) { - *sep = NULL; + *sep = NUL; while (*tok) { switch (*tok) diff --git a/src/normal.c b/src/normal.c index b252e2e48..83759b72c 100644 --- a/src/normal.c +++ b/src/normal.c @@ -1127,6 +1127,11 @@ getcount: #endif } + /* get the length of mapped chars again after typing a count, second + * character or "z333<cr>". */ + if (old_mapped_len > 0) + old_mapped_len = typebuf_maplen(); + /* * If an operation is pending, handle it... */ @@ -2886,6 +2886,15 @@ op_yank(oap, deleting, mess) */ curbuf->b_op_start = oap->start; curbuf->b_op_end = oap->end; + if (yanktype == MLINE +#ifdef FEAT_VISUAL + && !oap->block_mode +#endif + ) + { + curbuf->b_op_start.col = 0; + curbuf->b_op_end.col = MAXCOL; + } #ifdef FEAT_CLIPBOARD /* diff --git a/src/option.c b/src/option.c index 6c62196ea..d3e47ebaa 100644 --- a/src/option.c +++ b/src/option.c @@ -302,6 +302,7 @@ struct vimoption #define P_SECURE 0x40000L/* cannot change in modeline or secure mode */ #define P_GETTEXT 0x80000L/* expand default value with _() */ #define P_NOGLOB 0x100000L/* do not use local value for global vimrc */ +#define P_NFNAME 0x200000L/* only normal file name chars allowed */ /* * options[] is initialized here. @@ -422,7 +423,7 @@ static struct vimoption {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE, (char_u *)&p_bdir, PV_NONE, {(char_u *)DFLT_BDIR, (char_u *)0L}}, - {"backupext", "bex", P_STRING|P_VI_DEF, + {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME, (char_u *)&p_bex, PV_NONE, { #ifdef VMS @@ -864,7 +865,7 @@ static struct vimoption {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP, (char_u *)&p_ffs, PV_NONE, {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}}, - {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, + {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, #ifdef FEAT_AUTOCMD (char_u *)&p_ft, PV_FT, {(char_u *)"", (char_u *)0L} @@ -953,6 +954,15 @@ static struct vimoption {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, (char_u *)&p_fp, PV_NONE, {(char_u *)"", (char_u *)0L}}, + {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF, +#ifdef HAVE_FSYNC + (char_u *)&p_fs, PV_NONE, + {(char_u *)TRUE, (char_u *)0L} +#else + (char_u *)NULL, PV_NONE, + {(char_u *)FALSE, (char_u *)0L} +#endif + }, {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM, (char_u *)&p_gd, PV_NONE, {(char_u *)FALSE, (char_u *)0L}}, @@ -1278,7 +1288,8 @@ static struct vimoption {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, (char_u *)&p_isp, PV_NONE, { -#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \ +#if defined(MSDOS) || defined(MSWIN) || defined(OS2) \ + || (defined(MACOS) && !defined(MACOS_X)) \ || defined(VMS) (char_u *)"@,~-255", #else @@ -1302,7 +1313,7 @@ static struct vimoption {(char_u *)0L, (char_u *)0L} #endif }, - {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT, + {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME, #ifdef FEAT_KEYMAP (char_u *)&p_keymap, PV_KMAP, {(char_u *)"", (char_u *)0L} @@ -1348,7 +1359,7 @@ static struct vimoption {(char_u *)NULL, #endif (char_u *)0L}}, - {"langmenu", "lm", P_STRING|P_VI_DEF, + {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME, #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG) (char_u *)&p_lm, PV_NONE, #else @@ -1594,7 +1605,7 @@ static struct vimoption {(char_u *)0L, (char_u *)0L} #endif }, - {"patchmode", "pm", P_STRING|P_VI_DEF, + {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME, (char_u *)&p_pm, PV_NONE, {(char_u *)"", (char_u *)0L}}, {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, @@ -1627,7 +1638,7 @@ static struct vimoption (char_u *)NULL, PV_NONE, #endif {(char_u *)FALSE, (char_u *)0L}}, - {"printdevice", "pdev", P_STRING|P_VI_DEF, + {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE, #ifdef FEAT_PRINTER (char_u *)&p_pdev, PV_NONE, {(char_u *)"", (char_u *)0L} @@ -2040,7 +2051,7 @@ static struct vimoption {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, (char_u *)&p_swb, PV_NONE, {(char_u *)"", (char_u *)0L}}, - {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, + {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, #ifdef FEAT_SYN_HL (char_u *)&p_syn, PV_SYN, {(char_u *)"", (char_u *)0L} @@ -2145,7 +2156,7 @@ static struct vimoption (char_u *)NULL, PV_NONE, #endif {(char_u *)85L, (char_u *)0L}}, - {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT, + {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE, #ifdef FEAT_TITLE (char_u *)&p_titleold, PV_NONE, {(char_u *)N_("Thanks for flying Vim"), @@ -2380,7 +2391,7 @@ static struct vimoption {(char_u *)0L, (char_u *)0L}}, /* terminal output codes */ -#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL, \ +#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \ (char_u *)&vvv, PV_NONE, \ {(char_u *)"", (char_u *)0L}}, @@ -2435,6 +2446,8 @@ static struct vimoption p_term("t_vs", T_VS) p_term("t_WP", T_CWP) p_term("t_WS", T_CWS) + p_term("t_SI", T_CSI) + p_term("t_EI", T_CEI) p_term("t_xs", T_XS) p_term("t_ZH", T_CZH) p_term("t_ZR", T_CZR) @@ -3388,7 +3401,8 @@ do_set(arg, opt_flags) errmsg = NULL; startarg = arg; /* remember for error message */ - if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])) + if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) + && !(opt_flags & OPT_MODELINE)) { /* * ":set all" show all options. @@ -3404,7 +3418,7 @@ do_set(arg, opt_flags) else showoptions(1, opt_flags); } - else if (STRNCMP(arg, "termcap", 7) == 0) + else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) { showoptions(2, opt_flags); show_termcodes(); @@ -4704,6 +4718,15 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, errmsg = e_secure; } + /* Check for a "normal" file name in some options. Disallow a path + * separator (slash and/or backslash), wildcards and characters that are + * often illegal in a file name. */ + else if ((options[opt_idx].flags & P_NFNAME) + && vim_strpbrk(*varp, "/\\*?[|<>") != NULL) + { + errmsg = e_invarg; + } + /* 'term' */ else if (varp == &T_NAME) { diff --git a/src/option.h b/src/option.h index acb23de34..566a56117 100644 --- a/src/option.h +++ b/src/option.h @@ -19,26 +19,30 @@ # endif #endif -/* default values for p_efm 'errorformat' */ +/* + * Default values for 'errorformat'. + * The "%f|%l| %m" one is used for when the contents of the quickfix window is + * written to a file. + */ #ifdef AMIGA -# define DFLT_EFM "%f>%l:%c:%t:%n:%m,%f:%l: %t%*\\D%n: %m,%f %l %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f:%l:%m" +# define DFLT_EFM "%f>%l:%c:%t:%n:%m,%f:%l: %t%*\\D%n: %m,%f %l %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f:%l:%m,%f|%l| %m" #else # if defined(MSDOS) || defined(WIN3264) -# define DFLT_EFM "%f(%l) : %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) : %m,%*[^ ] %f %l: %m,%f:%l:%m" +# define DFLT_EFM "%f(%l) : %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) : %m,%*[^ ] %f %l: %m,%f:%l:%m,%f|%l| %m" # else # if defined(__EMX__) /* put most common here (i.e. gcc format) at front */ -# define DFLT_EFM "%f:%l:%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f(%l:%c) : %m" +# define DFLT_EFM "%f:%l:%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f(%l:%c) : %m,%f|%l| %m" # else # if defined(__QNX__) -# define DFLT_EFM "%f(%l):%*[^WE]%t%*\\D%n:%m" +# define DFLT_EFM "%f(%l):%*[^WE]%t%*\\D%n:%m,%f|%l| %m" # else # ifdef VMS -# define DFLT_EFM "%A%p^,%C%%CC-%t-%m,%Cat line number %l in file %f" +# define DFLT_EFM "%A%p^,%C%%CC-%t-%m,%Cat line number %l in file %f,%f|%l| %m" # else /* Unix, probably */ # ifdef EBCDIC -#define DFLT_EFM "%*[^ ] %*[^ ] %f:%l%*[ ]%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%DMaking %*\\a in %f" +#define DFLT_EFM "%*[^ ] %*[^ ] %f:%l%*[ ]%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m" # else -#define DFLT_EFM "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%DMaking %*\\a in %f" +#define DFLT_EFM "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m" # endif # endif # endif @@ -445,6 +449,7 @@ static char *(p_fdo_values[]) = {"all", "block", "hor", "mark", "percent", # define FDO_JUMP 0x400 #endif EXTERN char_u *p_fp; /* 'formatprg' */ +EXTERN int p_fs; /* 'fsync' */ EXTERN int p_gd; /* 'gdefault' */ #ifdef FEAT_PRINTER EXTERN char_u *p_pdev; /* 'printdevice' */ diff --git a/src/os_msdos.c b/src/os_msdos.c index 92b14ea30..1056fe0e5 100644 --- a/src/os_msdos.c +++ b/src/os_msdos.c @@ -505,14 +505,14 @@ mch_restore_cursor_shape(int restore) if (restore) { if (saved) - regs.h.ah = 0x01; /*Set Cursor*/ + regs.h.ah = 0x01; /* Set Cursor */ else return; } else { - regs.h.ah = 0x03; /*Get Cursor*/ - regs.h.bh = 0x00; /*Page */ + regs.h.ah = 0x03; /* Get Cursor */ + regs.h.bh = 0x00; /* Page */ saved = TRUE; } @@ -528,9 +528,9 @@ mch_set_cursor_shape(int thickness) { union REGS regs; - regs.h.ch = 7 - thickness; /*Starting Line*/ - regs.h.cl = 7; /*Ending Line*/ - regs.h.ah = 0x01; /*Set Cursor*/ + regs.h.ch = 7 - thickness; /* Starting Line */ + regs.h.cl = 7; /* Ending Line */ + regs.h.ah = 0x01; /* Set Cursor */ (void)int86(0x10, ®s, ®s); } diff --git a/src/os_unix.c b/src/os_unix.c index 08e9fc8d2..373dce1c0 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -903,6 +903,13 @@ deathtrap SIGDEFARG(sigarg) } #endif +#ifdef SIGHASARG + /* When SIGHUP is blocked: postpone its effect and return here. This + * avoids that a non-reentrant function is interrupted, e.g., free(). */ + if (entered == 0 && sigarg == SIGHUP && !handle_sighup(SIGHUP_RCV)) + SIGRETURN; +#endif + /* Remember how often we have been called. */ ++entered; @@ -1174,6 +1181,39 @@ catch_signals(func_deadly, func_other) } /* + * Handling of SIGHUP: + * "when" == SIGHUP_RCV: when busy, postpone, otherwise return TRUE + * "when" == SIGHUP_BLOCK: Going to be busy, block SIGHUP + * "when" == SIGHUP_UNBLOCK: Going wait, unblock SIGHUP + * Returns TRUE when Vim should exit. + */ + int +handle_sighup(when) + int when; +{ + static int got_sighup = FALSE; + static int blocked = FALSE; + + switch (when) + { + case SIGHUP_RCV: if (!blocked) + return TRUE; /* exit! */ + got_sighup = TRUE; + got_int = TRUE; /* break any loops */ + break; + + case SIGHUP_BLOCK: blocked = TRUE; + break; + + case SIGHUP_UNBLOCK: blocked = FALSE; + if (got_sighup) + kill(getpid(), SIGHUP); + break; + } + return FALSE; +} + +/* * Check_win checks whether we have an interactive stdout. */ /* ARGSUSED */ diff --git a/src/os_win32.c b/src/os_win32.c index fce48f9fc..23a31f36e 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -228,15 +228,18 @@ get_exe_name(void) # define GETTEXT_DLL "libintl.dll" # endif /* Dummy funcitons */ -static char* null_libintl_gettext(const char *); -static char* null_libintl_textdomain(const char *); -static char* null_libintl_bindtextdomain(const char *, const char *); +static char *null_libintl_gettext(const char *); +static char *null_libintl_textdomain(const char *); +static char *null_libintl_bindtextdomain(const char *, const char *); +static char *null_libintl_bind_textdomain_codeset(const char *, const char *); static HINSTANCE hLibintlDLL = 0; -char* (*dyn_libintl_gettext)(const char *) = null_libintl_gettext; -char* (*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain; -char* (*dyn_libintl_bindtextdomain)(const char *, const char *) +char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext; +char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain; +char *(*dyn_libintl_bindtextdomain)(const char *, const char *) = null_libintl_bindtextdomain; +char *(*dyn_libintl_bind_textdomain_codeset)(const char *, const char *) + = null_libintl_bind_textdomain_codeset; int dyn_libintl_init(char *libname) @@ -287,6 +290,15 @@ dyn_libintl_init(char *libname) return 0; } } + + /* The bind_textdomain_codeset() function is optional. */ + (FARPROC)dyn_libintl_bind_textdomain_codeset = + (FARPROC)GetProcAddress(hLibintlDLL, + "bind_textdomain_codeset"); + if (dyn_libintl_bind_textdomain_codeset == NULL) + dyn_libintl_bind_textdomain_codeset = + null_libintl_bind_textdomain_codeset; + return 1; } @@ -299,6 +311,7 @@ dyn_libintl_end() dyn_libintl_gettext = null_libintl_gettext; dyn_libintl_textdomain = null_libintl_textdomain; dyn_libintl_bindtextdomain = null_libintl_bindtextdomain; + dyn_libintl_bind_textdomain_codeset = null_libintl_bind_textdomain_codeset; } static char * @@ -314,6 +327,13 @@ null_libintl_bindtextdomain(const char *domainname, const char *dirname) } static char * +null_libintl_bind_textdomain_codeset(const char *domainname, + const char *codeset) +{ + return NULL; +} + + static char * null_libintl_textdomain(const char *domainname) { return NULL; diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro index b3a2d2d16..b6f3b7a7a 100644 --- a/src/proto/ex_docmd.pro +++ b/src/proto/ex_docmd.pro @@ -34,6 +34,7 @@ void do_exedit __ARGS((exarg_T *eap, win_T *old_curwin)); void do_sleep __ARGS((long msec)); FILE *open_exfile __ARGS((char_u *fname, int forceit, char *mode)); void update_topline_cursor __ARGS((void)); +void exec_normal_cmd __ARGS((char_u *cmd, int remap, int silent)); char_u *eval_vars __ARGS((char_u *src, int *usedlen, linenr_T *lnump, char_u **errormsg, char_u *srcstart)); char_u *expand_sfile __ARGS((char_u *arg)); int put_eol __ARGS((FILE *fd)); diff --git a/src/proto/os_unix.pro b/src/proto/os_unix.pro index 9a3908b49..6018c8fce 100644 --- a/src/proto/os_unix.pro +++ b/src/proto/os_unix.pro @@ -11,6 +11,7 @@ void mch_didjmp __ARGS((void)); void mch_suspend __ARGS((void)); void mch_init __ARGS((void)); void reset_signals __ARGS((void)); +int handle_sighup __ARGS((int when)); int mch_check_win __ARGS((int argc, char **argv)); int mch_input_isatty __ARGS((void)); int mch_can_restore_title __ARGS((void)); diff --git a/src/proto/term.pro b/src/proto/term.pro index 16924badc..3215b0e28 100644 --- a/src/proto/term.pro +++ b/src/proto/term.pro @@ -40,6 +40,7 @@ int mouse_model_popup __ARGS((void)); void scroll_start __ARGS((void)); void cursor_on __ARGS((void)); void cursor_off __ARGS((void)); +void term_cursor_shape __ARGS((void)); void scroll_region_set __ARGS((win_T *wp, int off)); void scroll_region_reset __ARGS((void)); void clear_termcodes __ARGS((void)); diff --git a/src/screen.c b/src/screen.c index 68f6da1ae..88b17d4be 100644 --- a/src/screen.c +++ b/src/screen.c @@ -110,8 +110,8 @@ typedef struct int attr; /* attributes to be used for a match */ int attr_cur; /* attributes currently active in win_line() */ linenr_T first_lnum; /* first lnum to search for multi-line pat */ - char_u *startp; /* in win_line() points to char where HL starts */ - char_u *endp; /* in win_line() points to char where HL ends */ + colnr_T startcol; /* in win_line() points to char where HL starts */ + colnr_T endcol; /* in win_line() points to char where HL ends */ } match_T; static match_T search_hl; /* used for 'hlsearch' highlight matching */ @@ -944,8 +944,8 @@ win_update(wp) /* When a change starts above w_topline and the end is below * w_topline, start redrawing at w_topline. - * If the end of the change is above w_topline: do like no changes was - * maded, but redraw the first line to find changes in syntax. */ + * If the end of the change is above w_topline: do like no change was + * made, but redraw the first line to find changes in syntax. */ if (mod_top != 0 && mod_top < wp->w_topline) { if (mod_bot > wp->w_topline) @@ -955,6 +955,11 @@ win_update(wp) top_end = 1; #endif } + + /* When line numbers are displayed need to redraw all lines below + * inserted/deleted lines. */ + if (mod_top != 0 && buf->b_mod_xlines != 0 && wp->w_p_nu) + mod_bot = MAXLNUM; } /* @@ -1625,12 +1630,6 @@ win_update(wp) } } } - - /* When inserting or deleting lines and 'number' is set: - * Redraw all lines below the change to update the line - * numbers. */ - if (buf->b_mod_xlines != 0 && wp->w_p_nu) - bot_start = 0; } #ifdef FEAT_FOLDING @@ -2642,6 +2641,8 @@ win_line(wp, lnum, startrow, endrow) fromcol = -10; tocol = MAXCOL; } + else if (bot->col == MAXCOL) + tocol = MAXCOL; else { pos = *bot; @@ -2852,8 +2853,8 @@ win_line(wp, lnum, startrow, endrow) shl = &search_hl; for (;;) { - shl->startp = NULL; - shl->endp = NULL; + shl->startcol = MAXCOL; + shl->endcol = MAXCOL; shl->attr_cur = 0; if (shl->rm.regprog != NULL) { @@ -2868,25 +2869,25 @@ win_line(wp, lnum, startrow, endrow) if (shl->lnum != 0 && shl->lnum <= lnum) { if (shl->lnum == lnum) - shl->startp = line + shl->rm.startpos[0].col; + shl->startcol = shl->rm.startpos[0].col; else - shl->startp = line; + shl->startcol = 0; if (lnum == shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum) - shl->endp = line + shl->rm.endpos[0].col; + shl->endcol = shl->rm.endpos[0].col; else - shl->endp = line + MAXCOL; + shl->endcol = MAXCOL; /* Highlight one character for an empty match. */ - if (shl->startp == shl->endp) + if (shl->startcol == shl->endcol) { #ifdef FEAT_MBYTE - if (has_mbyte && *shl->endp != NUL) - shl->endp += (*mb_ptr2len_check)(shl->endp); + if (has_mbyte && line[shl->endcol] != NUL) + shl->endcol += (*mb_ptr2len_check)(line + shl->endcol); else #endif - ++shl->endp; + ++shl->endcol; } - if (shl->startp < ptr) /* match at leftcol */ + if ((long)shl->startcol < v) /* match at leftcol */ { shl->attr_cur = shl->attr; search_attr = shl->attr; @@ -3150,22 +3151,22 @@ win_line(wp, lnum, startrow, endrow) * Do this first for search_hl, then for match_hl, so that * ":match" overrules 'hlsearch'. */ + v = (long)(ptr - line); shl = &search_hl; for (;;) { while (shl->rm.regprog != NULL) { - if (shl->startp != NULL - && ptr >= shl->startp - && ptr < shl->endp) + if (shl->startcol != MAXCOL + && v >= (long)shl->startcol + && v < (long)shl->endcol) { shl->attr_cur = shl->attr; } - else if (ptr == shl->endp) + else if (v == (long)shl->endcol) { shl->attr_cur = 0; - v = (long)(ptr - line); next_search_hl(wp, shl, lnum, (colnr_T)v); /* Need to get the line again, a multi-line regexp @@ -3175,23 +3176,23 @@ win_line(wp, lnum, startrow, endrow) if (shl->lnum == lnum) { - shl->startp = line + shl->rm.startpos[0].col; + shl->startcol = shl->rm.startpos[0].col; if (shl->rm.endpos[0].lnum == 0) - shl->endp = line + shl->rm.endpos[0].col; + shl->endcol = shl->rm.endpos[0].col; else - shl->endp = line + MAXCOL; + shl->endcol = MAXCOL; - if (shl->startp == shl->endp) + if (shl->startcol == shl->endcol) { /* highlight empty match, try again after * it */ #ifdef FEAT_MBYTE if (has_mbyte) - shl->endp += - (*mb_ptr2len_check)(shl->endp); + shl->endcol += (*mb_ptr2len_check)(line + + shl->endcol); else #endif - ++shl->endp; + ++shl->endcol; } /* Loop to check if the match starts at the @@ -3635,8 +3636,22 @@ win_line(wp, lnum, startrow, endrow) c = ' '; } } - else if (c == NUL && wp->w_p_list && lcs_eol_one > 0) + else if (c == NUL + && ((wp->w_p_list && lcs_eol > 0) + || ((fromcol >= 0 || fromcol_prev >= 0) + && tocol > vcol + && VIsual_mode != Ctrl_V + && ( +# ifdef FEAT_RIGHTLEFT + wp->w_p_rl ? (col >= 0) : +# endif + (col < W_WIDTH(wp))) + && !(noinvcur + && (colnr_T)vcol == wp->w_virtcol))) + && lcs_eol_one >= 0) { + /* Display a '$' after the line or highlight an extra + * character if the line break is included. */ #if defined(FEAT_DIFF) || defined(LINE_ATTR) /* For a diff line the highlighting continues after the * "$". */ @@ -3667,7 +3682,10 @@ win_line(wp, lnum, startrow, endrow) c_extra = NUL; } } - c = lcs_eol; + if (wp->w_p_list) + c = lcs_eol; + else + c = ' '; lcs_eol_one = -1; --ptr; /* put it back at the NUL */ if (area_attr == 0 && search_attr == 0) @@ -3847,8 +3865,8 @@ win_line(wp, lnum, startrow, endrow) && ((area_attr != 0 && vcol == fromcol) #ifdef FEAT_SEARCH_EXTRA /* highlight 'hlsearch' match at end of line */ - || ptr - 1 == search_hl.startp - || ptr - 1 == match_hl.startp + || (ptr - line) - 1 == (long)search_hl.startcol + || (ptr - line) - 1 == (long)match_hl.startcol #endif )) { @@ -3885,7 +3903,7 @@ win_line(wp, lnum, startrow, endrow) #ifdef FEAT_SEARCH_EXTRA if (area_attr == 0) { - if (ptr - 1 == match_hl.startp) + if ((ptr - line) - 1 == (long)match_hl.startcol) char_attr = match_hl.attr; else char_attr = search_hl.attr; diff --git a/src/search.c b/src/search.c index 4513ea110..6a915e170 100644 --- a/src/search.c +++ b/src/search.c @@ -4031,7 +4031,7 @@ find_pattern_in_path(ptr, dir, len, whole, skip_comments, #ifdef RISCOS /* UnixLib knows best how to munge c file names - turn munging back on. */ - __riscosify_control = __RISCOSIFY_LONG_TRUNCATE; + int __riscosify_control = 0; #endif if (type != CHECK_PATH && type != FIND_DEFINE diff --git a/src/syntax.c b/src/syntax.c index 4956aec44..0c706c82d 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -2339,6 +2339,10 @@ check_state_ends() cur_si->si_h_endpos = cur_si->si_eoe_pos; cur_si->si_flags |= HL_MATCH; update_si_attr(current_state.ga_len - 1); + + /* what matches next may be different now, clear it */ + next_match_idx = 0; + next_match_col = MAXCOL; break; } else @@ -2439,6 +2443,8 @@ update_si_attr(idx) { sip->si_attr = CUR_STATE(idx - 1).si_attr; sip->si_trans_id = CUR_STATE(idx - 1).si_trans_id; + sip->si_h_startpos = CUR_STATE(idx - 1).si_h_startpos; + sip->si_h_endpos = CUR_STATE(idx - 1).si_h_endpos; if (sip->si_cont_list == NULL) { sip->si_flags |= HL_TRANS_CONT; @@ -5620,7 +5626,8 @@ in_id_list(cur_si, list, ssp, contained) int r; /* If spp has a "containedin" list and "cur_si" is in it, return TRUE. */ - if (cur_si != NULL && ssp->cont_in_list != NULL) + if (cur_si != NULL && ssp->cont_in_list != NULL + && !(cur_si->si_flags & HL_MATCH)) { /* Ignore transparent items without a contains argument. Double check * that we don't go back past the first one. */ @@ -2382,7 +2382,15 @@ get_tagfname(first, buf) ga_init2(&tag_fnames, (int)sizeof(char_u *), 10); do_in_runtimepath((char_u *) #ifdef FEAT_MULTI_LANG +# ifdef VMS + /* Functions decc$to_vms() and decc$translate_vms() crash + * on some VMS systems with wildcards "??". Seems ECO + * patches do fix the problem in C RTL, but we can't use + * an #ifdef for that. */ + "doc/tags doc/tags-*" +# else "doc/tags doc/tags-??" +# endif #else "doc/tags" #endif diff --git a/src/term.c b/src/term.c index 71b19116c..a83f50679 100644 --- a/src/term.c +++ b/src/term.c @@ -1643,6 +1643,7 @@ set_termname(term) {KS_CIS, "IS"}, {KS_CIE, "IE"}, {KS_TS, "ts"}, {KS_FS, "fs"}, {KS_CWP, "WP"}, {KS_CWS, "WS"}, + {KS_CSI, "SI"}, {KS_CEI, "EI"}, {(enum SpecialKey)0, NULL} }; @@ -3400,6 +3401,31 @@ cursor_off() } /* + * Set cursor shape to match Insert mode. + */ + void +term_cursor_shape() +{ + static int showing_insert_mode = MAYBE; + + if (!full_screen || *T_CSI == NUL || *T_CEI == NUL) + return; + + if (State & INSERT) + { + if (showing_insert_mode != TRUE) + out_str(T_CSI); /* disable cursor */ + showing_insert_mode = TRUE; + } + else + { + if (showing_insert_mode != FALSE) + out_str(T_CEI); /* disable cursor */ + showing_insert_mode = FALSE; + } +} + +/* * Set scrolling region for window 'wp'. * The region starts 'off' lines from the start of the window. * Also set the vertical scroll region for a vertically split window. Always diff --git a/src/term.h b/src/term.h index 17b1065ca..c400020b5 100644 --- a/src/term.h +++ b/src/term.h @@ -76,6 +76,8 @@ enum SpecialKey KS_CWP, /* set window position in pixels */ KS_CWS, /* set window size in characters */ KS_CRV, /* request version string */ + KS_CSI, /* start insert mode (bar cursor) */ + KS_CEI, /* end insert mode (block cursor) */ #ifdef FEAT_VERTSPLIT KS_CSV, /* scroll region vertical */ #endif @@ -148,6 +150,8 @@ extern char_u *(term_strings[]); /* current terminal strings */ #define T_FS (term_str(KS_FS)) /* set window title end */ #define T_CWP (term_str(KS_CWP)) /* window position */ #define T_CWS (term_str(KS_CWS)) /* window size */ +#define T_CSI (term_str(KS_CSI)) /* start insert mode */ +#define T_CEI (term_str(KS_CEI)) /* end insert mode */ #define T_CRV (term_str(KS_CRV)) /* request version string */ #define T_OP (term_str(KS_OP)) /* original color pair */ @@ -176,7 +176,13 @@ ui_inchar(buf, maxlen, wtime, tb_change_cnt) # ifdef FEAT_GUI else # endif + { + if (wtime == -1) + handle_sighup(SIGHUP_UNBLOCK); /* allow SIGHUP to kill us */ retval = mch_inchar(buf, maxlen, wtime, tb_change_cnt); + if (wtime == -1) + handle_sighup(SIGHUP_BLOCK); /* block SIGHUP */ + } #endif ctrl_c_interrupts = TRUE; @@ -1852,7 +1858,10 @@ ui_cursor_shape() # ifdef FEAT_GUI if (gui.in_use) gui_update_cursor_later(); + else # endif + term_cursor_shape(); + # ifdef MCH_CURSOR_SHAPE mch_update_cursor(); # endif diff --git a/src/version.h b/src/version.h index 67b47d570..e8f1078c1 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 (2004 Oct 4)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2004 Oct 4, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2004 Dec 9)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2004 Dec 9, compiled " @@ -434,9 +434,10 @@ typedef unsigned short u8char_T; # define FEAT_GETTEXT # endif /* These are in os_win32.c */ -extern char* (*dyn_libintl_gettext)(const char* msgid); -extern char* (*dyn_libintl_bindtextdomain)(const char* domainname, const char* dirname); -extern char* (*dyn_libintl_textdomain)(const char* domainname); +extern char *(*dyn_libintl_gettext)(const char *msgid); +extern char *(*dyn_libintl_bindtextdomain)(const char *domainname, const char *dirname); +extern char *(*dyn_libintl_bind_textdomain_codeset)(const char *domainname, const char *codeset); +extern char *(*dyn_libintl_textdomain)(const char *domainname); #endif @@ -448,7 +449,11 @@ extern char* (*dyn_libintl_textdomain)(const char* domainname); # ifdef DYNAMIC_GETTEXT # define _(x) (*dyn_libintl_gettext)((char *)(x)) # define N_(x) x -# define bindtextdomain(domain,dir) (*dyn_libintl_bindtextdomain)(domain,dir) +# define bindtextdomain(domain, dir) (*dyn_libintl_bindtextdomain)((domain), (dir)) +# define bind_textdomain_codeset(domain, codeset) (*dyn_libintl_bind_textdomain_codeset)((domain), (codeset)) +# if !defined(HAVE_BIND_TEXTDOMAIN_CODESET) +# define HAVE_BIND_TEXTDOMAIN_CODESET 1 +# endif # define textdomain(domain) (*dyn_libintl_textdomain)(domain) # else # include <libintl.h> @@ -466,6 +471,10 @@ extern char* (*dyn_libintl_textdomain)(const char* domainname); # undef bindtextdomain # endif # define bindtextdomain(x, y) /* empty */ +# ifdef bind_textdomain_codeset +# undef bind_textdomain_codeset +# endif +# define bind_textdomain_codeset(x, y) /* empty */ # ifdef textdomain # undef textdomain # endif @@ -1834,4 +1843,12 @@ typedef int VimClipboard; /* This is required for the prototypes. */ # include <XSUB.h> #endif +/* values for handle_sighup() */ +#define SIGHUP_RCV 1 +#define SIGHUP_BLOCK 2 +#define SIGHUP_UNBLOCK 3 +#ifndef UNIX +# define handle_sighup(x) /* nothing */ +#endif + #endif /* VIM__H */ diff --git a/src/window.c b/src/window.c index 47da663b5..ad3222a33 100644 --- a/src/window.c +++ b/src/window.c @@ -1924,7 +1924,11 @@ win_close(win, free_buf) curbuf = curwin->w_buffer; close_curwin = TRUE; } - if (p_ea) + if (p_ea +#ifdef FEAT_VERTSPLIT + && (*p_ead == 'b' || *p_ead == dir) +#endif + ) win_equal(curwin, TRUE, #ifdef FEAT_VERTSPLIT dir |