diff --git a/.hgtags b/.hgtags index 371cf98753..6ad8ef4bc2 100644 --- a/.hgtags +++ b/.hgtags @@ -1595,3 +1595,46 @@ c296c225736e4489706c62c95752a0c4788be1d3 v7-3-256 bdc3335bd72eea207b28fcf8af90a73c855c8847 v7-3-258 59130cd78dfc73bd04f22d201b8f7c0772d98e79 v7-3-259 cb4682b959098e486977eb4b5969c9eb07d2798e v7-3-260 +410d42e3d4da09284394456186143d595e9b2efc v7-3-261 +847733973bfdd716bfafc364a4102e76f88e7fe8 v7-3-262 +a56259157c935b4e78e9f5f4dfb1436e3461eefb v7-3-263 +aa40bddeea9a44c6c6b4ffa32c1ef373df437a16 v7-3-264 +eff686fb8de66a26367f5e6430d34729f1a0e336 v7-3-265 +25be7c9dda549e4cfa1eb57937dc2b38b3d1e997 v7-3-266 +ad404f2a4bfa5374e97f29335f41b7ef34cd6bfa v7-3-267 +ee17ee712512451a54046d6bcd3ddb9f70cb5cdf v7-3-268 +7f4f5ca70dbde4e31c2de494b982bfb9bd71ed75 v7-3-269 +b9182da84c7eeda221e5219ef4361cca201b3b41 v7-3-270 +32a52f06f33b9e2d4817330099b410c1fcf64db2 v7-3-271 +02f5abca10aee570d5a9cf00928ffaa663daba66 v7-3-272 +7d4e5e31d8c10c767cdf774a2b13aedd2f95f096 v7-3-273 +1bb6776fa8c445e0b3f9dd2ed14fdf2a56f5873e v7-3-274 +125c7bf52271461dfbf46cc33317eadc67aaf742 v7-3-275 +37a54a85413eae68932233e64a0ab88c99c9d811 v7-3-276 +e5b17a5f651696ad4c523a21822692115d371250 v7-3-277 +6622f28b7e87a93de6f1520945d1c5d2a1fc0dab v7-3-278 +342b176089678e86cde3e1afac4aaaa1e5153f99 v7-3-279 +58bba69b3371d9ff02b27fe24f044e229c8aa99a v7-3-280 +45ead8a0bedeade57c320d72e9f710a703e61cf0 v7-3-281 +92167bb91c95410a0550ff8c94370307bb7d9d80 v7-3-282 +47b6d37b60122f45eb147106b8da1322c1cdbc60 v7-3-283 +27d43855b72312500e6fc2122e167a579a1f35f2 v7-3-284 +6018c815e1205e7db9328fe6ed91b26b514465f3 v7-3-285 +3f822e54765c54a1112a953e3c37bb60185fd51c v7-3-286 +07bc2ccfe5559035e785f22851365b3a31dec67e v7-3-287 +e4f3fa1a474e677dce486ea07ee31270f92b2b4a v7-3-288 +44ffd0a8abcdba441216514cb711649eb1169876 v7-3-289 +df33dba4e553f8fa27ba467042f16315c613a00d v7-3-290 +e8ee4b4ebf41abb199ea9a9e9cc38f9b0c2f7192 v7-3-291 +b6af1c5dd22f08db2b9e52ae763f193ba82965ad v7-3-292 +6cd0d6413a2e03687aca8138b2843f1f2aac5b84 v7-3-293 +dbd73fe939cf772a8b07c19230e5ee60aa0cfcc7 v7-3-294 +0d8494c051131b6470fe8af67646e235bc63fcf7 v7-3-295 +c19c15a9e9bf2914b25748c0544936e84a5c77c0 v7-3-296 +22550986c713ce5f37f069f0c8f99a54dc4a421b v7-3-297 +43b1d031e3028248abcbd5099841d3aafda7f68d v7-3-298 +eb4972982bfea006ead5b461f319744d5ecd58f5 v7-3-299 +2665b456ee59652c7b590dff0fa522ce337e0f16 v7-3-300 +4a70971530899e32058207cae683a69e7b8f85dc v7-3-301 +61b2f26623104f75850b1568bf61663597fe7fb0 v7-3-302 +d832d642f520d426f111b35102450617922547d3 v7-3-303 diff --git a/src/GvimExt/gvimext.cpp b/src/GvimExt/gvimext.cpp index 7c7ec99d3f..975453cafa 100644 --- a/src/GvimExt/gvimext.cpp +++ b/src/GvimExt/gvimext.cpp @@ -142,6 +142,7 @@ static char *null_libintl_bindtextdomain(const char *, const char *); static int dyn_libintl_init(char *dir); static void dyn_libintl_end(void); +static wchar_t *oldenv = NULL; static HINSTANCE hLibintlDLL = 0; static char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext; static char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain; @@ -339,8 +340,10 @@ DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReserved */) inc_cRefThisDLL() { #ifdef FEAT_GETTEXT - if (g_cRefThisDll == 0) + if (g_cRefThisDll == 0) { dyn_gettext_load(); + oldenv = GetEnvironmentStringsW(); + } #endif InterlockedIncrement((LPLONG)&g_cRefThisDll); } @@ -349,8 +352,13 @@ inc_cRefThisDLL() dec_cRefThisDLL() { #ifdef FEAT_GETTEXT - if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0) + if (InterlockedDecrement((LPLONG)&g_cRefThisDll) == 0) { dyn_gettext_free(); + if (oldenv != NULL) { + FreeEnvironmentStringsW(oldenv); + oldenv = NULL; + } + } #else InterlockedDecrement((LPLONG)&g_cRefThisDll); #endif @@ -905,8 +913,8 @@ STDMETHODIMP CShellExt::InvokeGvim(HWND hParent, NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. + oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT, + oldenv, // Use unmodified environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi) // Pointer to PROCESS_INFORMATION structure. @@ -987,8 +995,8 @@ STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent, NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. + oldenv == NULL ? 0 : CREATE_UNICODE_ENVIRONMENT, + oldenv, // Use unmodified environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi) // Pointer to PROCESS_INFORMATION structure. diff --git a/src/VisVim/Commands.cpp b/src/VisVim/Commands.cpp index a346dea702..111b163c42 100644 --- a/src/VisVim/Commands.cpp +++ b/src/VisVim/Commands.cpp @@ -549,7 +549,7 @@ static BOOL VimOpenFile(BSTR& FileName, long LineNr) if (g_bNewTabs) { sprintf(VimCmd, ":tab drop "); - s = VimCmd + 11; + s = VimCmd + 10; } else { @@ -557,8 +557,7 @@ static BOOL VimOpenFile(BSTR& FileName, long LineNr) s = VimCmd + 6; } sprintf(FileNameTmp, "%S", (char *)FileName); - for (p = FileNameTmp; *p != '\0' && s < FileNameTmp + MAX_OLE_STR - 4; - ++p) + for (p = FileNameTmp; *p != '\0' && s < VimCmd + MAX_OLE_STR - 4; ++p) if (*p == '\\') *s++ = '/'; else diff --git a/src/ascii.h b/src/ascii.h index 5256fc32de..e824822b30 100644 --- a/src/ascii.h +++ b/src/ascii.h @@ -123,7 +123,7 @@ #define DCS 0x90 /* Device Control String */ #define STERM 0x9c /* String Terminator */ -#define POUND '£' +#define POUND '\xA3' #define CTRL_F_STR "\056" #define CTRL_H_STR "\026" diff --git a/src/auto/configure b/src/auto/configure index 75a6385e13..ff37e7294b 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -5992,7 +5992,7 @@ echo $ECHO_N "checking whether we can do without RTLD_GLOBAL for Python... $ECHO cflags_save=$CFLAGS CFLAGS="$CFLAGS $PYTHON_CFLAGS" ldflags_save=$LDFLAGS - LDFLAGS="$LDFLAGS -ldl" + LDFLAGS="-ldl $LDFLAGS" if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 @@ -6083,7 +6083,7 @@ echo $ECHO_N "checking whether we can do without RTLD_GLOBAL for Python3... $ECH cflags_save=$CFLAGS CFLAGS="$CFLAGS $PYTHON3_CFLAGS" ldflags_save=$LDFLAGS - LDFLAGS="$LDFLAGS -ldl" + LDFLAGS="-ldl $LDFLAGS" if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 @@ -20625,7 +20625,7 @@ do cat >>$CONFIG_STATUS <<_ACEOF # First, check the format of the line: cat >"\$tmp/defines.sed" <<\\CEOF -/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*/b def /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def b :def diff --git a/src/config.h.in b/src/config.h.in index 4c3a89b762..db07f863c8 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -346,6 +346,9 @@ /* Define if dynamic python does not require RTLD_GLOBAL */ #undef PY_NO_RTLD_GLOBAL +/* Define if dynamic python3 does not require RTLD_GLOBAL */ +#undef PY3_NO_RTLD_GLOBAL + /* Define if you want to include the Ruby interpreter. */ #undef FEAT_RUBY diff --git a/src/configure.in b/src/configure.in index 098ebe07e0..d6643234cb 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1193,7 +1193,8 @@ if test "$python_ok" = yes && test "$python3_ok" = yes; then cflags_save=$CFLAGS CFLAGS="$CFLAGS $PYTHON_CFLAGS" ldflags_save=$LDFLAGS - LDFLAGS="$LDFLAGS -ldl" + dnl -ldl must go first to make this work on Archlinux (Roland Puntaier) + LDFLAGS="-ldl $LDFLAGS" AC_RUN_IFELSE([ #include /* If this program fails, then RTLD_GLOBAL is needed. @@ -1237,7 +1238,8 @@ if test "$python_ok" = yes && test "$python3_ok" = yes; then cflags_save=$CFLAGS CFLAGS="$CFLAGS $PYTHON3_CFLAGS" ldflags_save=$LDFLAGS - LDFLAGS="$LDFLAGS -ldl" + dnl -ldl must go first to make this work on Archlinux (Roland Puntaier) + LDFLAGS="-ldl $LDFLAGS" AC_RUN_IFELSE([ #include #include diff --git a/src/eval.c b/src/eval.c index 76456c6c7c..a58f5c9012 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1357,7 +1357,11 @@ eval_to_string(arg, nextcmd, convert) { ga_init2(&ga, (int)sizeof(char), 80); if (tv.vval.v_list != NULL) + { list_join(&ga, tv.vval.v_list, (char_u *)"\n", TRUE, 0); + if (tv.vval.v_list->lv_len > 0) + ga_append(&ga, NL); + } ga_append(&ga, NUL); retval = (char_u *)ga.ga_data; } @@ -23229,6 +23233,7 @@ modify_fname(src, usedlen, fnamep, bufp, fnamelen) int c; int has_fullname = 0; #ifdef WIN3264 + char_u *fname_start = *fnamep; int has_shortname = 0; #endif @@ -23403,24 +23408,25 @@ repeat: } #ifdef WIN3264 - /* Check shortname after we have done 'heads' and before we do 'tails' + /* + * Handle ":8" after we have done 'heads' and before we do 'tails'. */ if (has_shortname) { - pbuf = NULL; - /* Copy the string if it is shortened by :h */ - if (*fnamelen < (int)STRLEN(*fnamep)) + /* Copy the string if it is shortened by :h and when it wasn't copied + * yet, because we are going to change it in place. Avoids changing + * the buffer name for "%:8". */ + if (*fnamelen < (int)STRLEN(*fnamep) || *fnamep == fname_start) { p = vim_strnsave(*fnamep, *fnamelen); - if (p == 0) + if (p == NULL) return -1; vim_free(*bufp); *bufp = *fnamep = p; } /* Split into two implementations - makes it easier. First is where - * there isn't a full name already, second is where there is. - */ + * there isn't a full name already, second is where there is. */ if (!has_fullname && !vim_isAbsName(*fnamep)) { if (shortpath_for_partial(fnamep, bufp, fnamelen) == FAIL) @@ -23428,18 +23434,16 @@ repeat: } else { - int l; + int l = *fnamelen; - /* Simple case, already have the full-name + /* Simple case, already have the full-name. * Nearly always shorter, so try first time. */ - l = *fnamelen; if (get_short_pathname(fnamep, bufp, &l) == FAIL) return -1; if (l == 0) { - /* Couldn't find the filename.. search the paths. - */ + /* Couldn't find the filename, search the paths. */ l = *fnamelen; if (shortpath_for_invalid_fname(fnamep, bufp, &l) == FAIL) return -1; diff --git a/src/ex_getln.c b/src/ex_getln.c index 24ded0cf26..5f63e8dc28 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -67,7 +67,7 @@ static int hislen = 0; /* actual length of history tables */ static int hist_char2type __ARGS((int c)); -static int in_history __ARGS((int, char_u *, int)); +static int in_history __ARGS((int, char_u *, int, int)); # ifdef FEAT_EVAL static int calc_hist_idx __ARGS((int histype, int num)); # endif @@ -1977,8 +1977,12 @@ getcmdline_prompt(firstc, prompt, attr, xp_context, xp_arg) # endif s = getcmdline(firstc, 1L, 0); restore_cmdline(&save_ccline); - /* Restore msg_col, the prompt from input() may have changed it. */ - msg_col = msg_col_save; + /* Restore msg_col, the prompt from input() may have changed it. + * But only if called recursively and the commandline is therefore being + * restored to an old one; if not, the input() prompt stays on the screen, + * so we need its modified msg_col left intact. */ + if (ccline.cmdbuff != NULL) + msg_col = msg_col_save; return s; } @@ -5303,13 +5307,15 @@ init_history() * If 'move_to_front' is TRUE, matching entry is moved to end of history. */ static int -in_history(type, str, move_to_front) +in_history(type, str, move_to_front, sep) int type; char_u *str; int move_to_front; /* Move the entry to the front if it exists */ + int sep; { int i; int last_i = -1; + char_u *p; if (hisidx[type] < 0) return FALSE; @@ -5318,7 +5324,12 @@ in_history(type, str, move_to_front) { if (history[type][i].hisstr == NULL) return FALSE; - if (STRCMP(str, history[type][i].hisstr) == 0) + + /* For search history, check that the separator character matches as + * well. */ + p = history[type][i].hisstr; + if (STRCMP(str, p) == 0 + && (type != HIST_SEARCH || sep == p[STRLEN(p) + 1])) { if (!move_to_front) return TRUE; @@ -5412,7 +5423,7 @@ add_to_history(histype, new_entry, in_map, sep) } last_maptick = -1; } - if (!in_history(histype, new_entry, TRUE)) + if (!in_history(histype, new_entry, TRUE, sep)) { if (++hisidx[histype] == hislen) hisidx[histype] = 0; @@ -5991,7 +6002,7 @@ read_viminfo_history(virp) if (val != NULL && *val != NUL) { if (!in_history(type, val + (type == HIST_SEARCH), - viminfo_add_at_front)) + viminfo_add_at_front, *val)) { /* Need to re-allocate to append the separator byte. */ len = STRLEN(val); diff --git a/src/fileio.c b/src/fileio.c index 158bdfa96c..2520dfea27 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3342,8 +3342,22 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit, } else if (reset_changed && whole) { - if (!(did_cmd = apply_autocmds_exarg(EVENT_BUFWRITECMD, - sfname, sfname, FALSE, curbuf, eap))) + int was_changed = curbufIsChanged(); + + did_cmd = apply_autocmds_exarg(EVENT_BUFWRITECMD, + sfname, sfname, FALSE, curbuf, eap); + if (did_cmd) + { + if (was_changed && !curbufIsChanged()) + { + /* Written everything correctly and BufWriteCmd has reset + * 'modified': Correct the undo information so that an + * undo now sets 'modified'. */ + u_unchanged(curbuf); + u_update_save_nr(curbuf); + } + } + else { #ifdef FEAT_QUICKFIX if (overwriting && bt_nofile(curbuf)) diff --git a/src/fold.c b/src/fold.c index 800db61ba6..3b7a9597cc 100644 --- a/src/fold.c +++ b/src/fold.c @@ -1469,11 +1469,14 @@ deleteFoldEntry(gap, idx, recursive) } else { - /* move nested folds one level up, to overwrite the fold that is + /* Move nested folds one level up, to overwrite the fold that is * deleted. */ moved = fp->fd_nested.ga_len; if (ga_grow(gap, (int)(moved - 1)) == OK) { + /* Get "fp" again, the array may have been reallocated. */ + fp = (fold_T *)gap->ga_data + idx; + /* adjust fd_top and fd_flags for the moved folds */ nfp = (fold_T *)fp->fd_nested.ga_data; for (i = 0; i < moved; ++i) @@ -1486,9 +1489,9 @@ deleteFoldEntry(gap, idx, recursive) } /* move the existing folds down to make room */ - if (idx < gap->ga_len) + if (idx + 1 < gap->ga_len) mch_memmove(fp + moved, fp + 1, - sizeof(fold_T) * (gap->ga_len - idx)); + sizeof(fold_T) * (gap->ga_len - (idx + 1))); /* move the contained folds one level up */ mch_memmove(fp, nfp, (size_t)(sizeof(fold_T) * moved)); vim_free(nfp); diff --git a/src/getchar.c b/src/getchar.c index 3fb30c3f5e..34c2f00db5 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -3262,9 +3262,9 @@ do_map(maptype, arg, mode, abbrev) validate_maphash(); /* - * find end of keys and skip CTRL-Vs (and backslashes) in it + * Find end of keys and skip CTRL-Vs (and backslashes) in it. * Accept backslash like CTRL-V when 'cpoptions' does not contain 'B'. - * with :unmap white space is included in the keys, no argument possible + * with :unmap white space is included in the keys, no argument possible. */ p = keys; do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); @@ -3964,7 +3964,17 @@ showmap(mp, local) if (*mp->m_str == NUL) msg_puts_attr((char_u *)"", hl_attr(HLF_8)); else - msg_outtrans_special(mp->m_str, FALSE); + { + /* Remove escaping of CSI, because "m_str" is in a format to be used + * as typeahead. */ + char_u *s = vim_strsave(mp->m_str); + if (s != NULL) + { + vim_unescape_csi(s); + msg_outtrans_special(s, FALSE); + vim_free(s); + } + } #ifdef FEAT_EVAL if (p_verbose > 0) last_set_msg(mp->m_script_ID); @@ -4506,12 +4516,23 @@ eval_map_expr(str, c) { char_u *res; char_u *p; + char_u *expr; char_u *save_cmd; pos_T save_cursor; + /* Remove escaping of CSI, because "str" is in a format to be used as + * typeahead. */ + expr = vim_strsave(str); + if (expr == NULL) + return NULL; + vim_unescape_csi(expr); + save_cmd = save_cmdline_alloc(); if (save_cmd == NULL) + { + vim_free(expr); return NULL; + } /* Forbid changing text or using ":normal" to avoid most of the bad side * effects. Also restore the cursor position. */ @@ -4521,7 +4542,7 @@ eval_map_expr(str, c) #endif set_vim_var_char(c); /* set v:char to the typed character */ save_cursor = curwin->w_cursor; - p = eval_to_string(str, NULL, FALSE); + p = eval_to_string(expr, NULL, FALSE); --textlock; #ifdef FEAT_EX_EXTRA --ex_normal_lock; @@ -4529,8 +4550,11 @@ eval_map_expr(str, c) curwin->w_cursor = save_cursor; restore_cmdline_alloc(save_cmd); + vim_free(expr); + if (p == NULL) return NULL; + /* Escape CSI in the result to be able to use the string as typeahead. */ res = vim_strsave_escape_csi(p); vim_free(p); diff --git a/src/gui.c b/src/gui.c index ebc306bd5f..b411d9ee18 100644 --- a/src/gui.c +++ b/src/gui.c @@ -1428,7 +1428,7 @@ gui_set_shellsize(mustset, fit_to_display, direction) if (!gui.shell_created) return; -#ifdef MSWIN +#if defined(MSWIN) || defined(FEAT_GUI_GTK) /* If not setting to a user specified size and maximized, calculate the * number of characters that fit in the maximized window. */ if (!mustset && gui_mch_maximized()) diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 9d95f1a48b..e2f9fc5be0 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -3899,6 +3899,21 @@ gui_mch_unmaximize() gtk_window_unmaximize(GTK_WINDOW(gui.mainwin)); } +/* + * Called when the font changed while the window is maximized. Compute the + * new Rows and Columns. This is like resizing the window. + */ + void +gui_mch_newfont() +{ + int w, h; + + gtk_window_get_size(GTK_WINDOW(gui.mainwin), &w, &h); + w -= get_menu_tool_width(); + h -= get_menu_tool_height(); + gui_resize_shell(w, h); +} + /* * Set the windows size. */ @@ -4409,14 +4424,9 @@ gui_mch_init_font(char_u *font_name, int fontset UNUSED) if (gui_mch_maximized()) { - int w, h; - /* Update lines and columns in accordance with the new font, keep the * window maximized. */ - gtk_window_get_size(GTK_WINDOW(gui.mainwin), &w, &h); - w -= get_menu_tool_width(); - h -= get_menu_tool_height(); - gui_resize_shell(w, h); + gui_mch_newfont(); } else { diff --git a/src/gui_photon.c b/src/gui_photon.c index d9017989ab..12005e58ad 100644 --- a/src/gui_photon.c +++ b/src/gui_photon.c @@ -32,9 +32,9 @@ #endif #define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a[0])) -#define RGB(r,g,b) PgRGB(r,g,b) +#define RGB(r, g, b) PgRGB(r, g, b) -#define EVENT_BUFFER_SIZE sizeof( PhEvent_t ) + 1000 +#define EVENT_BUFFER_SIZE sizeof(PhEvent_t) + 1000 /* Some defines for gui_mch_mousehide() */ #define MOUSE_HIDE TRUE @@ -206,53 +206,53 @@ static PtCallbackF_t gui_ph_handle_menu_resize; static PtCallbackF_t gui_ph_handle_menu_unrealized; #ifdef USE_PANEL_GROUP -static void gui_ph_get_panelgroup_margins( short*, short*, short*, short* ); +static void gui_ph_get_panelgroup_margins(short*, short*, short*, short*); #endif #ifdef FEAT_TOOLBAR -static PhImage_t *gui_ph_toolbar_find_icon( vimmenu_T *menu ); +static PhImage_t *gui_ph_toolbar_find_icon(vimmenu_T *menu); #endif -static void gui_ph_draw_start( void ); -static void gui_ph_draw_end( void ); +static void gui_ph_draw_start(void); +static void gui_ph_draw_end(void); /* Set the text for the balloon */ -static PtWidget_t * gui_ph_show_tooltip( PtWidget_t *window, +static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window, PtWidget_t *widget, int position, char *text, char *font, PgColor_t fill_color, - PgColor_t text_color ); + PgColor_t text_color); /****************************************************************************/ -static PtWidget_t * gui_ph_show_tooltip( PtWidget_t *window, +static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window, PtWidget_t *widget, int position, char *text, char *font, PgColor_t fill_color, - PgColor_t text_color ) + PgColor_t text_color) { PtArg_t arg; vimmenu_T *menu; char_u *tooltip; - PtSetArg( &arg, Pt_ARG_POINTER, &menu, 0 ); - PtGetResources( widget, 1, &arg ); + PtSetArg(&arg, Pt_ARG_POINTER, &menu, 0); + PtGetResources(widget, 1, &arg); /* Override the text and position */ tooltip = text; - if( menu != NULL ) + if (menu != NULL) { int index = MENU_INDEX_TIP; - if( menu->strings[ index ] != NULL ) + if (menu->strings[ index ] != NULL) tooltip = menu->strings[ index ]; } - return( PtInflateBalloon( + return PtInflateBalloon( window, widget, /* Don't put the balloon at the bottom, @@ -261,25 +261,25 @@ static PtWidget_t * gui_ph_show_tooltip( PtWidget_t *window, tooltip, font, fill_color, - text_color ) ); + text_color); } static void -gui_ph_resize_container( void ) +gui_ph_resize_container(void) { PhArea_t area; - PtWidgetArea( gui.vimWindow, &area ); - PtWidgetPos ( gui.vimContainer, &area.pos ); + PtWidgetArea(gui.vimWindow, &area); + PtWidgetPos (gui.vimContainer, &area.pos); - PtSetResource( gui.vimContainer, Pt_ARG_AREA, &area, 0 ); + PtSetResource(gui.vimContainer, Pt_ARG_AREA, &area, 0); } static int gui_ph_handle_menu_resize( PtWidget_t *widget, void *other, - PtCallbackInfo_t *info ) + PtCallbackInfo_t *info) { PtContainerCallback_t *sizes = info->cbdata; PtWidget_t *container; @@ -291,7 +291,7 @@ gui_ph_handle_menu_resize( /* Because vim treats the toolbar and menubar separately, * and here they're lumped together into a PtToolbarGroup, * we only need either menu_height or toolbar_height set at once */ - if( gui.menu_is_active ) + if (gui.menu_is_active) { gui.menu_height = height; gui.toolbar_height = 0; @@ -310,16 +310,16 @@ gui_ph_handle_menu_resize( container = gui.vimContainer; #endif - PtSetResource( container, Pt_ARG_POS, &below_menu, 0 ); + PtSetResource(container, Pt_ARG_POS, &below_menu, 0); gui_ph_resize_container(); #ifdef USE_PANEL_GROUP gui_ph_get_panelgroup_margins( &pg_margin_top, &pg_margin_bottom, - &pg_margin_left, &pg_margin_right ); + &pg_margin_left, &pg_margin_right); #endif - return( Pt_CONTINUE ); + return Pt_CONTINUE; } /* @@ -330,23 +330,23 @@ gui_ph_handle_menu_resize( gui_ph_handle_timer_cursor( PtWidget_t *widget, void *data, - PtCallbackInfo_t *info ) + PtCallbackInfo_t *info) { - if( blink_state == BLINK_ON ) + if (blink_state == BLINK_ON) { gui_undraw_cursor(); blink_state = BLINK_OFF; - PtSetResource( gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, - blink_offtime, 0 ); + PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, + blink_offtime, 0); } else { gui_update_cursor(TRUE, FALSE); blink_state = BLINK_ON; - PtSetResource( gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, - blink_ontime, 0 ); + PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, + blink_ontime, 0); } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } static int @@ -354,25 +354,25 @@ gui_ph_handle_timer_timeout(PtWidget_t *widget, void *data, PtCallbackInfo_t *in { is_timeout = TRUE; - return( Pt_CONTINUE ); + return Pt_CONTINUE; } static int -gui_ph_handle_window_cb( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) +gui_ph_handle_window_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { PhWindowEvent_t *we = info->cbdata; ushort_t *width, *height; - switch( we->event_f ) { + switch (we->event_f) { case Ph_WM_CLOSE: gui_shell_closed(); break; case Ph_WM_FOCUS: /* Just in case it's hidden and needs to be shown */ - gui_mch_mousehide( MOUSE_SHOW ); + gui_mch_mousehide(MOUSE_SHOW); - if( we->event_state == Ph_WM_EVSTATE_FOCUS ) + if (we->event_state == Ph_WM_EVSTATE_FOCUS) { gui_focus_change(TRUE); gui_mch_start_blink(); @@ -385,28 +385,28 @@ gui_ph_handle_window_cb( PtWidget_t *widget, void *data, PtCallbackInfo_t *info break; case Ph_WM_RESIZE: - PtGetResource( gui.vimWindow, Pt_ARG_WIDTH, &width, 0 ); - PtGetResource( gui.vimWindow, Pt_ARG_HEIGHT, &height, 0 ); + PtGetResource(gui.vimWindow, Pt_ARG_WIDTH, &width, 0); + PtGetResource(gui.vimWindow, Pt_ARG_HEIGHT, &height, 0); #ifdef USE_PANEL_GROUP width -= (pg_margin_left + pg_margin_right); height -= (pg_margin_top + pg_margin_bottom); #endif - gui_resize_shell( *width, *height ); - gui_set_shellsize( FALSE, FALSE, RESIZE_BOTH ); + gui_resize_shell(*width, *height); + gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH); is_ignore_draw = FALSE; - PtEndFlux( gui.vimContainer ); - PtContainerRelease( gui.vimContainer ); + PtEndFlux(gui.vimContainer); + PtContainerRelease(gui.vimContainer); break; default: break; } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } static int -gui_ph_handle_scrollbar( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) +gui_ph_handle_scrollbar(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { PtScrollbarCallback_t *scroll; scrollbar_T *sb; @@ -415,10 +415,10 @@ gui_ph_handle_scrollbar( PtWidget_t *widget, void *data, PtCallbackInfo_t *info scroll = info->cbdata; sb = (scrollbar_T *) data; - if( sb != NULL ) + if (sb != NULL) { value = scroll->position; - switch( scroll->action ) + switch (scroll->action) { case Pt_SCROLL_DRAGGED: dragging = TRUE; @@ -426,107 +426,107 @@ gui_ph_handle_scrollbar( PtWidget_t *widget, void *data, PtCallbackInfo_t *info case Pt_SCROLL_SET: /* FIXME: return straight away here? */ - return( Pt_CONTINUE ); + return Pt_CONTINUE; break; } gui_drag_scrollbar(sb, value, dragging); } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } static int -gui_ph_handle_keyboard( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) +gui_ph_handle_keyboard(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { PhKeyEvent_t *key; unsigned char string[6]; int len, i; int ch, modifiers; - key = PhGetData( info->event ); + key = PhGetData(info->event); ch = modifiers = len = 0; - if( p_mh ) - gui_mch_mousehide( MOUSE_HIDE ); + if (p_mh) + gui_mch_mousehide(MOUSE_HIDE); /* We're a good lil photon program, aren't we? yes we are, yeess wee arrr */ - if( key->key_flags & Pk_KF_Compose ) + if (key->key_flags & Pk_KF_Compose) { - return( Pt_CONTINUE ); + return Pt_CONTINUE; } - if( (key->key_flags & Pk_KF_Cap_Valid) && - PkIsKeyDown( key->key_flags ) ) + if ((key->key_flags & Pk_KF_Cap_Valid) && + PkIsKeyDown(key->key_flags)) { #ifdef FEAT_MENU /* * Only show the menu if the Alt key is down, and the Shift & Ctrl * keys aren't down, as well as the other conditions */ - if( ( ( key->key_mods & Pk_KM_Alt ) && - !( key->key_mods & Pk_KM_Shift ) && - !( key->key_mods & Pk_KM_Ctrl ) ) && + if (((key->key_mods & Pk_KM_Alt) && + !(key->key_mods & Pk_KM_Shift) && + !(key->key_mods & Pk_KM_Ctrl)) && gui.menu_is_active && - ( *p_wak == 'y' || - ( *p_wak == 'm' && - gui_is_menu_shortcut( key->key_cap ) ) ) ) + (*p_wak == 'y' || + (*p_wak == 'm' && + gui_is_menu_shortcut(key->key_cap)))) { /* Fallthrough and let photon look for the hotkey */ - return( Pt_CONTINUE ); + return Pt_CONTINUE; } #endif - for( i = 0; special_keys[i].key_sym != 0; i++ ) + for(i = 0; special_keys[i].key_sym != 0; i++) { - if( special_keys[i].key_sym == key->key_cap ) + if (special_keys[i].key_sym == key->key_cap) { len = 0; - if( special_keys[i].vim_code1 == NUL ) + if (special_keys[i].vim_code1 == NUL) ch = special_keys[i].vim_code0; else { /* Detect if a keypad number key has been pressed * and change the key if Num Lock is on */ - if( key->key_cap >= Pk_KP_Enter && key->key_cap <= Pk_KP_9 - && ( key->key_mods & Pk_KM_Num_Lock ) ) + if (key->key_cap >= Pk_KP_Enter && key->key_cap <= Pk_KP_9 + && (key->key_mods & Pk_KM_Num_Lock)) { /* FIXME: For now, just map the key to a ascii value * (see ) */ ch = key->key_cap - 0xf080; } else - ch = TO_SPECIAL( special_keys[i].vim_code0, - special_keys[i].vim_code1 ); + ch = TO_SPECIAL(special_keys[i].vim_code0, + special_keys[i].vim_code1); } break; } } - if( key->key_mods & Pk_KM_Ctrl ) + if (key->key_mods & Pk_KM_Ctrl) modifiers |= MOD_MASK_CTRL; - if( key->key_mods & Pk_KM_Alt ) + if (key->key_mods & Pk_KM_Alt) modifiers |= MOD_MASK_ALT; - if( key->key_mods & Pk_KM_Shift ) + if (key->key_mods & Pk_KM_Shift) modifiers |= MOD_MASK_SHIFT; /* Is this not a special key? */ - if( special_keys[i].key_sym == 0 ) + if (special_keys[i].key_sym == 0) { - ch = PhTo8859_1( key ); - if( ch == -1 + ch = PhTo8859_1(key); + if (ch == -1 #ifdef FEAT_MBYTE - || ( enc_utf8 && ch > 127 ) + || (enc_utf8 && ch > 127) #endif ) { #ifdef FEAT_MBYTE - len = PhKeyToMb( string, key ); - if( len > 0 ) + len = PhKeyToMb(string, key); + if (len > 0) { static char buf[6]; int src_taken, dst_made; - if( enc_utf8 != TRUE ) + if (enc_utf8 != TRUE) { PxTranslateFromUTF( charset_translate, @@ -535,70 +535,70 @@ gui_ph_handle_keyboard( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) &src_taken, buf, 6, - &dst_made ); + &dst_made); - add_to_input_buf( buf, dst_made ); + add_to_input_buf(buf, dst_made); } else { - add_to_input_buf( string, len ); + add_to_input_buf(string, len); } - return( Pt_CONSUME ); + return Pt_CONSUME; } len = 0; #endif ch = key->key_cap; - if( ch < 0xff ) + if (ch < 0xff) { /* FIXME: is this the right thing to do? */ - if( modifiers & MOD_MASK_CTRL ) + if (modifiers & MOD_MASK_CTRL) { modifiers &= ~MOD_MASK_CTRL; - if( ( ch >= 'a' && ch <= 'z' ) || + if ((ch >= 'a' && ch <= 'z') || ch == '[' || ch == ']' || - ch == '\\' ) - ch = Ctrl_chr( ch ); - else if( ch == '2' ) + ch == '\\') + ch = Ctrl_chr(ch); + else if (ch == '2') ch = NUL; - else if( ch == '6' ) + else if (ch == '6') ch = 0x1e; - else if( ch == '-' ) + else if (ch == '-') ch = 0x1f; else modifiers |= MOD_MASK_CTRL; } - if( modifiers & MOD_MASK_ALT ) + if (modifiers & MOD_MASK_ALT) { - ch = Meta( ch ); + ch = Meta(ch); modifiers &= ~MOD_MASK_ALT; } } else { - return( Pt_CONTINUE ); + return Pt_CONTINUE; } } else modifiers &= ~MOD_MASK_SHIFT; } - ch = simplify_key( ch, &modifiers ); - if( modifiers ) + ch = simplify_key(ch, &modifiers); + if (modifiers) { string[ len++ ] = CSI; string[ len++ ] = KS_MODIFIER; string[ len++ ] = modifiers; } - if( IS_SPECIAL( ch ) ) + if (IS_SPECIAL(ch)) { string[ len++ ] = CSI; - string[ len++ ] = K_SECOND( ch ); - string[ len++ ] = K_THIRD( ch ); + string[ len++ ] = K_SECOND(ch); + string[ len++ ] = K_THIRD(ch); } else { @@ -619,28 +619,28 @@ gui_ph_handle_keyboard( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) string[ len++ ] = KE_CSI; } - if( len > 0 ) + if (len > 0) { - add_to_input_buf( string, len ); - return( Pt_CONSUME ); + add_to_input_buf(string, len); + return Pt_CONSUME; } } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } static int -gui_ph_handle_mouse( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) +gui_ph_handle_mouse(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { PhPointerEvent_t *pointer; PhRect_t *pos; int button = 0, repeated_click, modifiers = 0x0; short mouse_x, mouse_y; - pointer = PhGetData( info->event ); - pos = PhGetRects( info->event ); + pointer = PhGetData(info->event); + pos = PhGetRects(info->event); - gui_mch_mousehide( MOUSE_SHOW ); + gui_mch_mousehide(MOUSE_SHOW); /* * Coordinates need to be relative to the base window, @@ -649,27 +649,27 @@ gui_ph_handle_mouse( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) mouse_x = pos->ul.x + gui.border_width; mouse_y = pos->ul.y + gui.border_width; - if( info->event->type == Ph_EV_PTR_MOTION_NOBUTTON ) + if (info->event->type == Ph_EV_PTR_MOTION_NOBUTTON) { - gui_mouse_moved( mouse_x, mouse_y ); - return( Pt_CONTINUE ); + gui_mouse_moved(mouse_x, mouse_y); + return Pt_CONTINUE; } - if( pointer->key_mods & Pk_KM_Shift ) + if (pointer->key_mods & Pk_KM_Shift) modifiers |= MOUSE_SHIFT; - if( pointer->key_mods & Pk_KM_Ctrl ) + if (pointer->key_mods & Pk_KM_Ctrl) modifiers |= MOUSE_CTRL; - if( pointer->key_mods & Pk_KM_Alt ) + if (pointer->key_mods & Pk_KM_Alt) modifiers |= MOUSE_ALT; /* * FIXME More than one button may be involved, but for * now just deal with one */ - if( pointer->buttons & Ph_BUTTON_SELECT ) + if (pointer->buttons & Ph_BUTTON_SELECT) button = MOUSE_LEFT; - if( pointer->buttons & Ph_BUTTON_MENU ) + if (pointer->buttons & Ph_BUTTON_MENU) { button = MOUSE_RIGHT; /* Need the absolute coordinates for the popup menu */ @@ -677,65 +677,65 @@ gui_ph_handle_mouse( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) abs_mouse.y = pointer->pos.y; } - if( pointer->buttons & Ph_BUTTON_ADJUST ) + if (pointer->buttons & Ph_BUTTON_ADJUST) button = MOUSE_MIDDLE; /* Catch a real release (not phantom or other releases */ - if( info->event->type == Ph_EV_BUT_RELEASE ) + if (info->event->type == Ph_EV_BUT_RELEASE) button = MOUSE_RELEASE; - if( info->event->type & Ph_EV_PTR_MOTION_BUTTON ) + if (info->event->type & Ph_EV_PTR_MOTION_BUTTON) button = MOUSE_DRAG; #if 0 /* Vim doesn't use button repeats */ - if( info->event->type & Ph_EV_BUT_REPEAT ) + if (info->event->type & Ph_EV_BUT_REPEAT) button = MOUSE_DRAG; #endif /* Don't do anything if it is one of the phantom mouse release events */ - if( ( button != MOUSE_RELEASE ) || - ( info->event->subtype == Ph_EV_RELEASE_REAL ) ) + if ((button != MOUSE_RELEASE) || + (info->event->subtype == Ph_EV_RELEASE_REAL)) { repeated_click = (pointer->click_count >= 2) ? TRUE : FALSE; - gui_send_mouse_event( button , mouse_x, mouse_y, repeated_click, modifiers ); + gui_send_mouse_event(button , mouse_x, mouse_y, repeated_click, modifiers); } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } /* Handle a focus change of the PtRaw widget */ static int -gui_ph_handle_focus( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) +gui_ph_handle_focus(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { - if( info->reason == Pt_CB_LOST_FOCUS ) + if (info->reason == Pt_CB_LOST_FOCUS) { - PtRemoveEventHandler( gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, - gui_ph_handle_mouse, NULL ); + PtRemoveEventHandler(gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, + gui_ph_handle_mouse, NULL); - gui_mch_mousehide( MOUSE_SHOW ); + gui_mch_mousehide(MOUSE_SHOW); } else { - PtAddEventHandler( gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, - gui_ph_handle_mouse, NULL ); + PtAddEventHandler(gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, + gui_ph_handle_mouse, NULL); } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } static void -gui_ph_handle_raw_draw( PtWidget_t *widget, PhTile_t *damage ) +gui_ph_handle_raw_draw(PtWidget_t *widget, PhTile_t *damage) { PhRect_t *r; PhPoint_t offset; PhPoint_t translation; - if( is_ignore_draw == TRUE ) + if (is_ignore_draw == TRUE) return; - PtSuperClassDraw( PtBasic, widget, damage ); - PgGetTranslation( &translation ); + PtSuperClassDraw(PtBasic, widget, damage); + PgGetTranslation(&translation); PgClearTranslation(); #if 0 @@ -750,21 +750,21 @@ gui_ph_handle_raw_draw( PtWidget_t *widget, PhTile_t *damage ) out_flush(); #endif - PtWidgetOffset( widget, &offset ); - PhTranslatePoint( &offset, PtWidgetPos( gui.vimTextArea, NULL ) ); + PtWidgetOffset(widget, &offset); + PhTranslatePoint(&offset, PtWidgetPos(gui.vimTextArea, NULL)); #if 1 /* Redraw individual damage regions */ - if( damage->next != NULL ) + if (damage->next != NULL) damage = damage->next; - while( damage != NULL ) + while(damage != NULL) { r = &damage->rect; gui_redraw( r->ul.x - offset.x, r->ul.y - offset.y, r->lr.x - r->ul.x + 1, - r->lr.y - r->ul.y + 1 ); + r->lr.y - r->ul.y + 1); damage = damage->next; } #else @@ -773,27 +773,27 @@ gui_ph_handle_raw_draw( PtWidget_t *widget, PhTile_t *damage ) gui_redraw( r->ul.x - offset.x, r->ul.y - offset.y, r->lr.x - r->ul.x + 1, - r->lr.y - r->ul.y + 1 ); + r->lr.y - r->ul.y + 1); #endif - PgSetTranslation( &translation, 0 ); + PgSetTranslation(&translation, 0); } static int gui_ph_handle_pulldown_menu( PtWidget_t *widget, void *data, - PtCallbackInfo_t *info ) + PtCallbackInfo_t *info) { - if( data != NULL ) + if (data != NULL) { vimmenu_T *menu = (vimmenu_T *) data; - PtPositionMenu( menu->submenu_id, NULL ); - PtRealizeWidget( menu->submenu_id ); + PtPositionMenu(menu->submenu_id, NULL); + PtRealizeWidget(menu->submenu_id); } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } /* This is used for pulldown/popup menus and also toolbar buttons */ @@ -805,7 +805,7 @@ gui_ph_handle_menu( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) vimmenu_T *menu = (vimmenu_T *) data; gui_menu_cb( menu ); } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } /* Stop focus from disappearing into the menubar... */ @@ -816,7 +816,7 @@ gui_ph_handle_menu_unrealized( PtCallbackInfo_t *info ) { PtGiveFocus( gui.vimTextArea, NULL ); - return( Pt_CONTINUE ); + return Pt_CONTINUE; } static int @@ -826,7 +826,7 @@ gui_ph_handle_window_open( PtCallbackInfo_t *info ) { gui_set_shellsize( FALSE, TRUE, RESIZE_BOTH ); - return( Pt_CONTINUE ); + return Pt_CONTINUE; } /****************************************************************************/ @@ -878,7 +878,7 @@ gui_ph_find_buffer_item( char_u *name ) ( STRCMP( items->dname, name ) != 0 ) ) items = items->next; } - return( items ); + return items; } static void @@ -927,7 +927,7 @@ gui_ph_handle_pg_change( gui_menu_cb( menu ); } } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } static void @@ -974,10 +974,10 @@ gui_ph_is_buffer_item( vimmenu_T *menu, vimmenu_T *parent ) mark++; if( *mark == ')' ) - return( TRUE); + return TRUE; } } - return( FALSE ); + return FALSE; } static void @@ -1057,7 +1057,7 @@ gui_ph_handle_buffer_remove( gui_ph_pg_remove_buffer( menu->dname ); } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } #endif @@ -1071,7 +1071,7 @@ gui_ph_pane_resize( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) PtContainerHold( gui.vimContainer ); } - return( Pt_CONTINUE ); + return Pt_CONTINUE; } /****************************************************************************/ @@ -1126,7 +1126,7 @@ gui_mch_init(void) gui.event_buffer = (PhEvent_t *) alloc( EVENT_BUFFER_SIZE ); if( gui.event_buffer == NULL ) - return( FAIL ); + return FAIL; /* Get a translation so we can convert from ISO Latin-1 to UTF */ charset_translate = PxTranslateSet( NULL, "latin1" ); @@ -1141,7 +1141,7 @@ gui_mch_init(void) PtSetArg( &args[ n++ ], Pt_ARG_DIM, &window_size, 0 ); gui.vimWindow = PtCreateWidget( PtWindow, NULL, n, args ); if( gui.vimWindow == NULL ) - return( FAIL ); + return FAIL; PtAddCallback( gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL ); PtAddCallback( gui.vimWindow, Pt_CB_WINDOW_OPENING, @@ -1158,7 +1158,7 @@ gui_mch_init(void) gui.vimPanelGroup = PtCreateWidget( PtPanelGroup, gui.vimWindow, n, args ); if( gui.vimPanelGroup == NULL ) - return( FAIL ); + return FAIL; PtAddCallback( gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING, gui_ph_handle_pg_change, NULL ); @@ -1172,7 +1172,7 @@ gui_mch_init(void) gui.vimContainer = PtCreateWidget( PtPane, gui.vimWindow, n, args ); if( gui.vimContainer == NULL ) - return( FAIL ); + return FAIL; PtAddCallback( gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL ); #endif @@ -1195,7 +1195,7 @@ gui_mch_init(void) gui.vimTextArea = PtCreateWidget( PtRaw, Pt_DFLT_PARENT, n, args ); if( gui.vimTextArea == NULL) - return( FAIL ); + return FAIL; /* TODO: use PtAddEventHandlers instead? */ /* Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway */ @@ -1220,11 +1220,11 @@ gui_mch_init(void) */ gui_ph_timer_cursor = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL ); if( gui_ph_timer_cursor == NULL ) - return( FAIL ); + return FAIL; gui_ph_timer_timeout = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL ); if( gui_ph_timer_timeout == NULL ) - return( FAIL ); + return FAIL; PtAddCallback( gui_ph_timer_cursor, Pt_CB_TIMER_ACTIVATE, gui_ph_handle_timer_cursor, NULL); @@ -1239,7 +1239,7 @@ gui_mch_init(void) gui.vimToolBarGroup = PtCreateWidget( PtToolbarGroup, gui.vimWindow, n, args ); if( gui.vimToolBarGroup == NULL ) - return( FAIL ); + return FAIL; PtAddCallback( gui.vimToolBarGroup, Pt_CB_RESIZE, gui_ph_handle_menu_resize, NULL ); @@ -1254,7 +1254,7 @@ gui_mch_init(void) } gui.vimMenuBar = PtCreateWidget( PtMenuBar, gui.vimToolBarGroup, n, args ); if( gui.vimMenuBar == NULL ) - return( FAIL ); + return FAIL; # ifdef FEAT_TOOLBAR n = 0; @@ -1273,7 +1273,7 @@ gui_mch_init(void) gui.vimToolBar = PtCreateWidget( PtToolbar, gui.vimToolBarGroup, n, args ); if( gui.vimToolBar == NULL ) - return( FAIL ); + return FAIL; /* * Size for the toolbar is fetched in gui_mch_show_toolbar, after @@ -1284,13 +1284,13 @@ gui_mch_init(void) #endif - return( OK ); + return OK; } int gui_mch_init_check(void) { - return( (is_photon_available == TRUE) ? OK : FAIL ); + return (is_photon_available == TRUE) ? OK : FAIL; } int @@ -1310,7 +1310,7 @@ gui_mch_open(void) if (gui_win_x != -1 && gui_win_y != -1) gui_mch_set_winpos(gui_win_x, gui_win_y); - return( (PtRealizeWidget( gui.vimWindow ) == 0) ? OK : FAIL ); + return (PtRealizeWidget( gui.vimWindow ) == 0) ? OK : FAIL; } void @@ -1336,7 +1336,7 @@ gui_mch_exit(int rc) exit_gui_mch_update( void *data ) { *(int *)data = FALSE; - return( Pt_END ); + return Pt_END; } void @@ -1365,10 +1365,10 @@ gui_mch_wait_for_chars(int wtime) if( input_available() ) { PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0 ); - return( OK ); + return OK; } else if( is_timeout == TRUE ) - return( FAIL ); + return FAIL; } } @@ -1446,9 +1446,9 @@ gui_mch_browse( vim_free( default_path ); if( file.ret == Pt_FSDIALOG_BTN1 ) - return( vim_strsave( file.path ) ); + return vim_strsave(file.path); } - return( NULL ); + return NULL; } #endif @@ -1470,7 +1470,7 @@ gui_ph_dialog_close( int button, void *data ) PtModalUnblock( modal_ctrl, (void *) button ); - return( Pt_TRUE ); + return Pt_TRUE; } static int @@ -1478,7 +1478,7 @@ gui_ph_dialog_text_enter( PtWidget_t *widget, void *data, PtCallbackInfo_t *info { if( info->reason_subtype == Pt_EDIT_ACTIVATE ) gui_ph_dialog_close( 1, data ); - return( Pt_CONTINUE ); + return Pt_CONTINUE; } static int @@ -1490,9 +1490,9 @@ gui_ph_dialog_esc( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) if( ( key->key_flags & Pk_KF_Cap_Valid ) && ( key->key_cap == Pk_Escape ) ) { gui_ph_dialog_close( 0, data ); - return( Pt_CONSUME ); + return Pt_CONSUME; } - return( Pt_PROCESS ); + return Pt_PROCESS; } int @@ -1519,7 +1519,7 @@ gui_mch_dialog( button_count = len = i = 0; if( buttons == NULL || *buttons == NUL ) - return( -1 ); + return -1; /* There is one less separator than buttons, so bump up the button count */ button_count = 1; @@ -1637,7 +1637,7 @@ gui_mch_dialog( vim_free( button_array ); vim_free( buttons_copy ); - return( dialog_result ); + return dialog_result; } #endif /****************************************************************************/ @@ -1653,7 +1653,7 @@ gui_mch_get_winpos(int *x, int *y) *x = pos->x; *y = pos->y; - return( OK ); + return OK; } void @@ -1975,11 +1975,11 @@ gui_mch_new_colors(void) hex_digit(int c) { if (VIM_ISDIGIT(c)) - return( c - '0' ); + return c - '0'; c = TOLOWER_ASC(c); if (c >= 'a' && c <= 'f') - return( c - 'a' + 10 ); - return( -1000 ); + return c - 'a' + 10; + return -1000; } @@ -2007,8 +2007,8 @@ gui_mch_get_color(char_u *name) static GuiColourTable table[] = { {"Black", RGB(0x00, 0x00, 0x00)}, - {"DarkGray", RGB(0x80, 0x80, 0x80)}, - {"DarkGrey", RGB(0x80, 0x80, 0x80)}, + {"DarkGray", RGB(0xA9, 0xA9, 0xA9)}, + {"DarkGrey", RGB(0xA9, 0xA9, 0xA9)}, {"Gray", RGB(0xC0, 0xC0, 0xC0)}, {"Grey", RGB(0xC0, 0xC0, 0xC0)}, {"LightGray", RGB(0xD3, 0xD3, 0xD3)}, @@ -2037,19 +2037,19 @@ gui_mch_get_color(char_u *name) {"LightRed", RGB(0xFF, 0xA0, 0xA0)}, {"DarkBlue", RGB(0x00, 0x00, 0x80)}, {"Blue", RGB(0x00, 0x00, 0xFF)}, - {"LightBlue", RGB(0xA0, 0xA0, 0xFF)}, + {"LightBlue", RGB(0xAD, 0xD8, 0xE6)}, {"DarkGreen", RGB(0x00, 0x80, 0x00)}, {"Green", RGB(0x00, 0xFF, 0x00)}, - {"LightGreen", RGB(0xA0, 0xFF, 0xA0)}, + {"LightGreen", RGB(0x90, 0xEE, 0x90)}, {"DarkCyan", RGB(0x00, 0x80, 0x80)}, {"Cyan", RGB(0x00, 0xFF, 0xFF)}, - {"LightCyan", RGB(0xA0, 0xFF, 0xFF)}, + {"LightCyan", RGB(0xE0, 0xFF, 0xFF)}, {"DarkMagenta", RGB(0x80, 0x00, 0x80)}, {"Magenta", RGB(0xFF, 0x00, 0xFF)}, {"LightMagenta", RGB(0xFF, 0xA0, 0xFF)}, {"Brown", RGB(0x80, 0x40, 0x40)}, {"Yellow", RGB(0xFF, 0xFF, 0x00)}, - {"LightYellow", RGB(0xFF, 0xFF, 0xA0)}, + {"LightYellow", RGB(0xFF, 0xFF, 0xE0)}, {"SeaGreen", RGB(0x2E, 0x8B, 0x57)}, {"Orange", RGB(0xFF, 0xA5, 0x00)}, {"Purple", RGB(0xA0, 0x20, 0xF0)}, @@ -2065,13 +2065,13 @@ gui_mch_get_color(char_u *name) b = hex_digit( name[5] ) * 16 + hex_digit( name[6] ); if( r < 0 || g < 0 || b < 0 ) return INVALCOLOR; - return( RGB( r, g, b ) ); + return RGB(r, g, b); } for( i = 0; i < ARRAY_LENGTH( table ); i++ ) { if( STRICMP( name, table[i].name ) == 0 ) - return( table[i].colour ); + return table[i].colour; } /* @@ -2115,7 +2115,7 @@ gui_mch_get_color(char_u *name) if (STRICMP(color, name) == 0) { fclose(fd); - return( (guicolor_T) RGB(r,g,b) ); + return (guicolor_T)RGB(r, g, b); } } @@ -2451,8 +2451,8 @@ gui_mch_haskey(char_u *name) for (i = 0; special_keys[i].key_sym != 0; i++) if (name[0] == special_keys[i].vim_code0 && name[1] == special_keys[i].vim_code1) - return( OK ); - return( FAIL ); + return OK; + return FAIL; } /****************************************************************************/ @@ -2512,7 +2512,7 @@ gui_ph_toolbar_load_icon( char_u *iconfile ) temp_phi = &external_icon; } - return( temp_phi ); + return temp_phi; } /* @@ -2541,16 +2541,16 @@ gui_ph_toolbar_find_icon( vimmenu_T *menu ) icon = gui_ph_toolbar_load_icon( full_pathname ); if( icon != NULL ) - return( icon ); + return icon; } if( menu->iconidx >= 0 && ( menu->iconidx < ARRAY_LENGTH( gui_ph_toolbar_images ) ) ) { - return( gui_ph_toolbar_images[ menu->iconidx ] ); + return gui_ph_toolbar_images[menu->iconidx]; } - return( NULL ); + return NULL; } #endif @@ -2895,11 +2895,11 @@ gui_ph_get_font( * at least has the bits we're checking for */ if( font_size == info.size && style == (info.style & style) ) - return( (GuiFont) font_tag ); + return (GuiFont)font_tag; } vim_free( font_tag ); } - return( NULL ); + return NULL; } /* @@ -2931,13 +2931,13 @@ gui_ph_parse_font_name( name_len = (int_u) ( mark - vim_font ); *font_name = vim_strnsave( vim_font, name_len ); - if( *font_name != NULL ) + if (*font_name != NULL) { - if( mark != NULL ) + if (mark != NULL) { - while( *mark != NUL && *mark++ == ':') + while (*mark != NUL && *mark++ == ':') { - switch( tolower( *mark++ ) ) + switch (tolower(*mark++)) { case 'a': *font_flags |= PF_STYLE_ANTIALIAS; break; case 'b': *font_flags |= PF_STYLE_BOLD; break; @@ -2946,7 +2946,7 @@ gui_ph_parse_font_name( case 's': size = getdigits( &mark ); /* Restrict the size to some vague limits */ - if( size < 1 || size > 100 ) + if (size < 1 || size > 100) size = 8; *font_size = size; @@ -2957,9 +2957,9 @@ gui_ph_parse_font_name( } } } - return( TRUE ); + return TRUE; } - return( FALSE ); + return FALSE; } int @@ -2973,19 +2973,19 @@ gui_mch_init_font(char_u *vim_font_name, int fontset) FontQueryInfo info; PhRect_t extent; - if( vim_font_name == NULL ) + if (vim_font_name == NULL) { /* Default font */ vim_font_name = "PC Terminal"; } - if( STRCMP( vim_font_name, "*" ) == 0 ) + if (STRCMP( vim_font_name, "*" ) == 0) { font_tag = PtFontSelection( gui.vimWindow, NULL, NULL, "pcterm12", -1, PHFONT_FIXED, NULL ); - if( font_tag == NULL ) - return( FAIL ); + if (font_tag == NULL) + return FAIL; gui_mch_free_font( gui.norm_font ); gui.norm_font = font_tag; @@ -2995,15 +2995,15 @@ gui_mch_init_font(char_u *vim_font_name, int fontset) } else { - if( gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags, - &font_size ) == FALSE ) - return( FAIL ); + if (gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags, + &font_size ) == FALSE) + return FAIL; font_tag = gui_ph_get_font( font_name, font_flags, font_size, 0 ); - if( font_tag == NULL ) + if (font_tag == NULL) { vim_free( font_name ); - return( FAIL ); + return FAIL; } gui_mch_free_font( gui.norm_font ); @@ -3026,7 +3026,7 @@ gui_mch_init_font(char_u *vim_font_name, int fontset) gui.char_ascent = - extent.ul.y; vim_free( font_name ); - return( OK ); + return OK; } /* @@ -3042,7 +3042,7 @@ gui_mch_adjust_charheight(void) gui.char_height = - info.ascender + info.descender + p_linespace; gui.char_ascent = - info.ascender + p_linespace / 2; - return( OK ); + return OK; } GuiFont @@ -3053,20 +3053,20 @@ gui_mch_get_font(char_u *vim_font_name, int report_error) int_u font_size = 12; int_u font_flags = 0; - if( gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags, - &font_size ) != FALSE ) + if (gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags, + &font_size ) != FALSE) { font_tag = gui_ph_get_font( font_name, font_flags, font_size, -1 ); vim_free( font_name ); - if( font_tag != NULL ) - return( (GuiFont) font_tag ); + if (font_tag != NULL) + return (GuiFont)font_tag; } - if( report_error ) + if (report_error) EMSG2(e_font, vim_font_name ); - return( FAIL ); + return FAIL; } #if defined(FEAT_EVAL) || defined(PROTO) diff --git a/src/gui_w32.c b/src/gui_w32.c index e4d25704f7..4a34cb4f2d 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -1270,6 +1270,25 @@ gui_mch_prepare(int *argc, char **argv) pGetMonitorInfo = (TGetMonitorInfo)GetProcAddress(user32_lib, "GetMonitorInfoA"); } + +#ifdef FEAT_MBYTE + /* If the OS is Windows NT, use wide functions; + * this enables common dialogs input unicode from IME. */ + if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + pDispatchMessage = DispatchMessageW; + pGetMessage = GetMessageW; + pIsDialogMessage = IsDialogMessageW; + pPeekMessage = PeekMessageW; + } + else + { + pDispatchMessage = DispatchMessageA; + pGetMessage = GetMessageA; + pIsDialogMessage = IsDialogMessageA; + pPeekMessage = PeekMessageA; + } +#endif } /* @@ -1379,7 +1398,8 @@ gui_mch_init(void) s_hwnd = CreateWindowEx( WS_EX_MDICHILD, szVimWndClass, "Vim MSWindows GUI", - WS_OVERLAPPEDWINDOW | WS_CHILD | WS_CLIPSIBLINGS | 0xC000, + WS_OVERLAPPEDWINDOW | WS_CHILD + | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 0xC000, gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x, gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y, 100, /* Any value will do */ @@ -1410,7 +1430,8 @@ gui_mch_init(void) * titlebar, it will be reparented below. */ s_hwnd = CreateWindow( szVimWndClass, "Vim MSWindows GUI", - win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP, + (win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP) + | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x, gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y, 100, /* Any value will do */ diff --git a/src/gui_w48.c b/src/gui_w48.c index 445104dae0..a6a8184a7c 100644 --- a/src/gui_w48.c +++ b/src/gui_w48.c @@ -390,7 +390,7 @@ _OnBlinkTimer( KillTimer(NULL, idEvent); /* Eat spurious WM_TIMER messages */ - while (PeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) + while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; if (blink_state == BLINK_ON) @@ -418,7 +418,7 @@ gui_mswin_rm_blink_timer(void) { KillTimer(NULL, blink_timer); /* Eat spurious WM_TIMER messages */ - while (PeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) + while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; blink_timer = 0; } @@ -476,7 +476,7 @@ _OnTimer( s_timed_out = TRUE; /* Eat spurious WM_TIMER messages */ - while (PeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) + while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; if (idEvent == s_wait_timer) s_wait_timer = 0; @@ -1411,12 +1411,12 @@ gui_mch_get_color(char_u *name) static guicolor_tTable table[] = { {"Black", RGB(0x00, 0x00, 0x00)}, - {"DarkGray", RGB(0x80, 0x80, 0x80)}, - {"DarkGrey", RGB(0x80, 0x80, 0x80)}, + {"DarkGray", RGB(0xA9, 0xA9, 0xA9)}, + {"DarkGrey", RGB(0xA9, 0xA9, 0xA9)}, {"Gray", RGB(0xC0, 0xC0, 0xC0)}, {"Grey", RGB(0xC0, 0xC0, 0xC0)}, - {"LightGray", RGB(0xE0, 0xE0, 0xE0)}, - {"LightGrey", RGB(0xE0, 0xE0, 0xE0)}, + {"LightGray", RGB(0xD3, 0xD3, 0xD3)}, + {"LightGrey", RGB(0xD3, 0xD3, 0xD3)}, {"Gray10", RGB(0x1A, 0x1A, 0x1A)}, {"Grey10", RGB(0x1A, 0x1A, 0x1A)}, {"Gray20", RGB(0x33, 0x33, 0x33)}, @@ -1441,19 +1441,19 @@ gui_mch_get_color(char_u *name) {"LightRed", RGB(0xFF, 0xA0, 0xA0)}, {"DarkBlue", RGB(0x00, 0x00, 0x80)}, {"Blue", RGB(0x00, 0x00, 0xFF)}, - {"LightBlue", RGB(0xA0, 0xA0, 0xFF)}, + {"LightBlue", RGB(0xAD, 0xD8, 0xE6)}, {"DarkGreen", RGB(0x00, 0x80, 0x00)}, {"Green", RGB(0x00, 0xFF, 0x00)}, - {"LightGreen", RGB(0xA0, 0xFF, 0xA0)}, + {"LightGreen", RGB(0x90, 0xEE, 0x90)}, {"DarkCyan", RGB(0x00, 0x80, 0x80)}, {"Cyan", RGB(0x00, 0xFF, 0xFF)}, - {"LightCyan", RGB(0xA0, 0xFF, 0xFF)}, + {"LightCyan", RGB(0xE0, 0xFF, 0xFF)}, {"DarkMagenta", RGB(0x80, 0x00, 0x80)}, {"Magenta", RGB(0xFF, 0x00, 0xFF)}, {"LightMagenta", RGB(0xFF, 0xA0, 0xFF)}, {"Brown", RGB(0x80, 0x40, 0x40)}, {"Yellow", RGB(0xFF, 0xFF, 0x00)}, - {"LightYellow", RGB(0xFF, 0xFF, 0xA0)}, + {"LightYellow", RGB(0xFF, 0xFF, 0xE0)}, {"DarkYellow", RGB(0xBB, 0xBB, 0x00)}, {"SeaGreen", RGB(0x2E, 0x8B, 0x57)}, {"Orange", RGB(0xFF, 0xA5, 0x00)}, @@ -1707,7 +1707,7 @@ process_message(void) static char_u k10[] = {K_SPECIAL, 'k', ';', 0}; #endif - GetMessage(&msg, NULL, 0, 0); + pGetMessage(&msg, NULL, 0, 0); #ifdef FEAT_OLE /* Look after OLE Automation commands */ @@ -1718,7 +1718,7 @@ process_message(void) { /* Message can't be ours, forward it. Fixes problem with Ultramon * 3.0.4 */ - DispatchMessage(&msg); + pDispatchMessage(&msg); } else { @@ -1749,14 +1749,14 @@ process_message(void) if (msg.message == WM_USER) { MyTranslateMessage(&msg); - DispatchMessage(&msg); + pDispatchMessage(&msg); return; } #endif #ifdef MSWIN_FIND_REPLACE /* Don't process messages used by the dialog */ - if (s_findrep_hwnd != NULL && IsDialogMessage(s_findrep_hwnd, &msg)) + if (s_findrep_hwnd != NULL && pIsDialogMessage(s_findrep_hwnd, &msg)) { HandleMouseHide(msg.message, msg.lParam); return; @@ -1928,7 +1928,7 @@ process_message(void) if (vk != VK_F10 || check_map(k10, State, FALSE, TRUE, FALSE, NULL, NULL) == NULL) #endif - DispatchMessage(&msg); + pDispatchMessage(&msg); } /* @@ -1943,7 +1943,7 @@ gui_mch_update(void) MSG msg; if (!s_busy_processing) - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) + while (pPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) && !vim_is_input_buf_full()) process_message(); } @@ -2019,7 +2019,7 @@ gui_mch_wait_for_chars(int wtime) KillTimer(NULL, s_wait_timer); /* Eat spurious WM_TIMER messages */ - while (PeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) + while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; s_wait_timer = 0; } diff --git a/src/if_perl.xs b/src/if_perl.xs index 545dc7b66f..e1e6ada220 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -147,7 +147,12 @@ typedef int perl_key; # define Perl_save_int dll_Perl_save_int # define Perl_stack_grow dll_Perl_stack_grow # define Perl_set_context dll_Perl_set_context +# if (PERL_REVISION == 5) && (PERL_VERSION >= 14) +# define Perl_sv_2bool_flags dll_Perl_sv_2bool_flags +# define Perl_xs_apiversion_bootcheck dll_Perl_xs_apiversion_bootcheck +# else # define Perl_sv_2bool dll_Perl_sv_2bool +# endif # define Perl_sv_2iv dll_Perl_sv_2iv # define Perl_sv_2mortal dll_Perl_sv_2mortal # if (PERL_REVISION == 5) && (PERL_VERSION >= 8) @@ -252,7 +257,12 @@ static void (*Perl_push_scope)(pTHX); static void (*Perl_save_int)(pTHX_ int*); static SV** (*Perl_stack_grow)(pTHX_ SV**, SV**p, int); static SV** (*Perl_set_context)(void*); +#if (PERL_REVISION == 5) && (PERL_VERSION >= 14) +static bool (*Perl_sv_2bool_flags)(pTHX_ SV*, I32); +static void (*Perl_xs_apiversion_bootcheck)(pTHX_ SV *module, const char *api_p, STRLEN api_len); +#else static bool (*Perl_sv_2bool)(pTHX_ SV*); +#endif static IV (*Perl_sv_2iv)(pTHX_ SV*); static SV* (*Perl_sv_2mortal)(pTHX_ SV*); #if (PERL_REVISION == 5) && (PERL_VERSION >= 8) @@ -360,7 +370,12 @@ static struct { {"Perl_save_int", (PERL_PROC*)&Perl_save_int}, {"Perl_stack_grow", (PERL_PROC*)&Perl_stack_grow}, {"Perl_set_context", (PERL_PROC*)&Perl_set_context}, +#if (PERL_REVISION == 5) && (PERL_VERSION >= 14) + {"Perl_sv_2bool_flags", (PERL_PROC*)&Perl_sv_2bool_flags}, + {"Perl_xs_apiversion_bootcheck",(PERL_PROC*)&Perl_xs_apiversion_bootcheck}, +#else {"Perl_sv_2bool", (PERL_PROC*)&Perl_sv_2bool}, +#endif {"Perl_sv_2iv", (PERL_PROC*)&Perl_sv_2iv}, {"Perl_sv_2mortal", (PERL_PROC*)&Perl_sv_2mortal}, #if (PERL_REVISION == 5) && (PERL_VERSION >= 8) @@ -407,6 +422,9 @@ static struct { {"Perl_sv_free2", (PERL_PROC*)&Perl_sv_free2}, {"Perl_sys_init", (PERL_PROC*)&Perl_sys_init}, {"Perl_sys_term", (PERL_PROC*)&Perl_sys_term}, + {"Perl_call_list", (PERL_PROC*)&Perl_call_list}, +# if (PERL_REVISION == 5) && (PERL_VERSION >= 14) +# else {"Perl_ISv_ptr", (PERL_PROC*)&Perl_ISv_ptr}, {"Perl_Istack_max_ptr", (PERL_PROC*)&Perl_Istack_max_ptr}, {"Perl_Istack_base_ptr", (PERL_PROC*)&Perl_Istack_base_ptr}, @@ -418,15 +436,18 @@ static struct { {"Perl_Imarkstack_max_ptr", (PERL_PROC*)&Perl_Imarkstack_max_ptr}, {"Perl_Istack_sp_ptr", (PERL_PROC*)&Perl_Istack_sp_ptr}, {"Perl_Iop_ptr", (PERL_PROC*)&Perl_Iop_ptr}, - {"Perl_call_list", (PERL_PROC*)&Perl_call_list}, {"Perl_Iscopestack_ix_ptr", (PERL_PROC*)&Perl_Iscopestack_ix_ptr}, {"Perl_Iunitcheckav_ptr", (PERL_PROC*)&Perl_Iunitcheckav_ptr}, +# endif #endif +#if (PERL_REVISION == 5) && (PERL_VERSION >= 14) +#else {"Perl_Idefgv_ptr", (PERL_PROC*)&Perl_Idefgv_ptr}, {"Perl_Ierrgv_ptr", (PERL_PROC*)&Perl_Ierrgv_ptr}, {"Perl_Isv_yes_ptr", (PERL_PROC*)&Perl_Isv_yes_ptr}, - {"boot_DynaLoader", (PERL_PROC*)&boot_DynaLoader}, {"Perl_Gthr_key_ptr", (PERL_PROC*)&Perl_Gthr_key_ptr}, +#endif + {"boot_DynaLoader", (PERL_PROC*)&boot_DynaLoader}, {"", NULL}, }; @@ -755,7 +776,7 @@ ex_perl(eap) #ifdef HAVE_SANDBOX if (sandbox) { - safe = perl_get_sv( "VIM::safe", FALSE ); + safe = perl_get_sv("VIM::safe", FALSE); # ifndef MAKE_TEST /* avoid a warning for unreachable code */ if (safe == NULL || !SvTRUE(safe)) EMSG(_("E299: Perl evaluation forbidden in sandbox without the Safe module")); @@ -1108,7 +1129,7 @@ Cursor(win, ...) VIWIN win PPCODE: - if(items == 1) + if (items == 1) { EXTEND(sp, 2); if (!win_valid(win)) @@ -1116,7 +1137,7 @@ Cursor(win, ...) PUSHs(sv_2mortal(newSViv(win->w_cursor.lnum))); PUSHs(sv_2mortal(newSViv(win->w_cursor.col))); } - else if(items == 3) + else if (items == 3) { int lnum, col; @@ -1249,9 +1270,9 @@ Delete(vimbuf, ...) { lnum = SvIV(ST(1)); count = 1 + SvIV(ST(2)) - lnum; - if(count == 0) + if (count == 0) count = 1; - if(count < 0) + if (count < 0) { lnum -= count; count = -count; diff --git a/src/if_py_both.h b/src/if_py_both.h index c7870bc10b..53c2167e14 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -74,7 +74,7 @@ OutputWrite(PyObject *self, PyObject *args) char *str = NULL; int error = ((OutputObject *)(self))->error; - if (!PyArg_ParseTuple(args, "es#", ENC_OPT, &str, &len)) + if (!PyArg_ParseTuple(args, "et#", ENC_OPT, &str, &len)) return NULL; Py_BEGIN_ALLOW_THREADS @@ -114,7 +114,7 @@ OutputWritelines(PyObject *self, PyObject *args) char *str = NULL; PyInt len; - if (!PyArg_Parse(line, "es#", ENC_OPT, &str, &len)) { + if (!PyArg_Parse(line, "et#", ENC_OPT, &str, &len)) { PyErr_SetString(PyExc_TypeError, _("writelines() requires list of strings")); Py_DECREF(list); return NULL; diff --git a/src/if_python.c b/src/if_python.c index adbafa2f98..69eb453fe8 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -373,7 +373,8 @@ python_runtime_link_init(char *libname, int verbose) * standard C extension libraries of one or both python versions. */ if (python3_loaded()) { - EMSG(_("E836: This Vim cannot execute :python after using :py3")); + if (verbose) + EMSG(_("E836: This Vim cannot execute :python after using :py3")); return FAIL; } #endif diff --git a/src/if_python3.c b/src/if_python3.c index 023a773e21..644cf188aa 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -367,7 +367,8 @@ py3_runtime_link_init(char *libname, int verbose) * standard C extension libraries of one or both python versions. */ if (python_loaded()) { - EMSG(_("E837: This Vim cannot execute :py3 after using :python")); + if (verbose) + EMSG(_("E837: This Vim cannot execute :py3 after using :python")); return FAIL; } # endif diff --git a/src/if_ruby.c b/src/if_ruby.c index 656da08d9a..566c840499 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -767,6 +767,7 @@ static VALUE vim_message(VALUE self UNUSED, VALUE str) str = rb_obj_as_string(str); if (RSTRING_LEN(str) > 0) { + /* Only do this when the string isn't empty, alloc(0) causes trouble. */ buff = ALLOCA_N(char, RSTRING_LEN(str)); strcpy(buff, RSTRING_PTR(str)); p = strchr(buff, '\n'); diff --git a/src/if_tcl.c b/src/if_tcl.c index e5eee2926e..5537b6356e 100644 --- a/src/if_tcl.c +++ b/src/if_tcl.c @@ -1884,14 +1884,14 @@ tclexit(error) { int newerr = OK; - if (error == TCL_EXIT ) + if (error == TCL_EXIT) { int retval; char buf[50]; Tcl_Obj *robj; robj = Tcl_GetObjResult(tclinfo.interp); - if( Tcl_GetIntFromObj(tclinfo.interp, robj, &retval) != TCL_OK ) + if (Tcl_GetIntFromObj(tclinfo.interp, robj, &retval) != TCL_OK) { EMSG(_("E281: TCL ERROR: exit code is not int!? Please report this to vim-dev@vim.org")); newerr = FAIL; @@ -1900,7 +1900,7 @@ tclexit(error) { sprintf(buf, _("E572: exit code %d"), retval); tclerrmsg(buf); - if (retval == 0 ) + if (retval == 0) { did_emsg = 0; newerr = OK; diff --git a/src/mbyte.c b/src/mbyte.c index fb1846a09b..41009c63dd 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -837,6 +837,27 @@ bomb_size() return n; } +/* + * Remove all BOM from "s" by moving remaining text. + */ + void +remove_bom(s) + char_u *s; +{ + if (enc_utf8) + { + char_u *p = s; + + while ((p = vim_strbyte(p, 0xef)) != NULL) + { + if (p[1] == 0xbb && p[2] == 0xbf) + STRMOVE(p, p + 3); + else + ++p; + } + } +} + /* * Get class of pointer: * 0 for blank or NUL @@ -5239,6 +5260,10 @@ xim_queue_key_press_event(GdkEventKey *event, int down) /* We had a keypad key, and XIM tried to thieve it */ return FALSE; + /* This is supposed to fix a problem with iBus, that space + * characters don't work in input mode. */ + xim_expected_char = NUL; + /* Normal processing */ return imresult; } diff --git a/src/message.c b/src/message.c index e30a661b7c..deea397eb2 100644 --- a/src/message.c +++ b/src/message.c @@ -1551,16 +1551,27 @@ str2special(sp, from) if (IS_SPECIAL(c) || modifiers) /* special key */ special = TRUE; } - *sp = str + 1; #ifdef FEAT_MBYTE - /* For multi-byte characters check for an illegal byte. */ - if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len)(str)) + if (has_mbyte && !IS_SPECIAL(c)) { - transchar_nonprint(buf, c); - return buf; + int len = (*mb_ptr2len)(str); + + /* For multi-byte characters check for an illegal byte. */ + if (has_mbyte && MB_BYTE2LEN(*str) > len) + { + transchar_nonprint(buf, c); + *sp = str + 1; + return buf; + } + /* Since 'special' is TRUE the multi-byte character 'c' will be + * processed by get_special_key_name() */ + c = (*mb_ptr2char)(str); + *sp = str + len; } + else #endif + *sp = str + 1; /* Make unprintable characters in <> form, also and . * Use only for lhs of a mapping. */ diff --git a/src/misc1.c b/src/misc1.c index 9bcc3e820b..fdb246cbc7 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -363,7 +363,7 @@ copy_indent(size, src) /* Fill to next tabstop with a tab, if possible */ tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts); - if (todo >= tab_pad) + if (todo >= tab_pad && !curbuf->b_p_et) { todo -= tab_pad; ++ind_len; @@ -372,7 +372,7 @@ copy_indent(size, src) } /* Add tabs required for indent */ - while (todo >= (int)curbuf->b_p_ts) + while (todo >= (int)curbuf->b_p_ts && !curbuf->b_p_et) { todo -= (int)curbuf->b_p_ts; ++ind_len; @@ -9125,7 +9125,9 @@ dos_expandpath( * all entries found with "matchname". */ if ((p[0] != '.' || starts_with_dot) && (matchname == NULL - || vim_regexec(®match, p, (colnr_T)0))) + || vim_regexec(®match, p, (colnr_T)0) + || ((flags & EW_NOTWILD) + && fnamencmp(path + (s - buf), p, e - s) == 0))) { #ifdef WIN3264 STRCPY(s, p); @@ -9329,7 +9331,7 @@ unix_expandpath(gap, path, wildoff, flags, didstar) e = p; *e = NUL; - /* now we have one wildcard component between "s" and "e" */ + /* Now we have one wildcard component between "s" and "e". */ /* Remove backslashes between "wildoff" and the start of the wildcard * component. */ for (p = buf + wildoff; p < s; ++p) @@ -9396,7 +9398,9 @@ unix_expandpath(gap, path, wildoff, flags, didstar) if (dp == NULL) break; if ((dp->d_name[0] != '.' || starts_with_dot) - && vim_regexec(®match, (char_u *)dp->d_name, (colnr_T)0)) + && (vim_regexec(®match, (char_u *)dp->d_name, (colnr_T)0) + || ((flags & EW_NOTWILD) + && fnamencmp(path + (s - buf), dp->d_name, e - s) == 0))) { STRCPY(s, dp->d_name); len = STRLEN(buf); diff --git a/src/misc2.c b/src/misc2.c index 54b055b991..b8de172410 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -2760,6 +2760,7 @@ find_special_key(srcp, modp, keycode, keep_x_key) int bit; int key; unsigned long n; + int l; src = *srcp; if (src[0] != '<') @@ -2772,26 +2773,32 @@ find_special_key(srcp, modp, keycode, keep_x_key) if (*bp == '-') { last_dash = bp; - if (bp[1] != NUL && bp[2] == '>') - ++bp; /* anything accepted, like */ + if (bp[1] != NUL) + { +#ifdef FEAT_MBYTE + if (has_mbyte) + l = mb_ptr2len(bp + 1); + else +#endif + l = 1; + if (bp[l + 1] == '>') + bp += l; /* anything accepted, like */ + } } if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) bp += 3; /* skip t_xx, xx may be '-' or '>' */ + else if (STRNICMP(bp, "char-", 5) == 0) + { + vim_str2nr(bp + 5, NULL, &l, TRUE, TRUE, NULL, NULL); + bp += l + 5; + break; + } } if (*bp == '>') /* found matching '>' */ { end_of_name = bp + 1; - if (STRNICMP(src + 1, "char-", 5) == 0 && VIM_ISDIGIT(src[6])) - { - /* or or */ - vim_str2nr(src + 6, NULL, NULL, TRUE, TRUE, NULL, &n); - *modp = 0; - *srcp = end_of_name; - return (int)n; - } - /* Which modifiers are given? */ modifiers = 0x0; for (bp = src + 1; bp < last_dash; bp++) @@ -2810,16 +2817,32 @@ find_special_key(srcp, modp, keycode, keep_x_key) */ if (bp >= last_dash) { - /* - * Modifier with single letter, or special key name. - */ - if (modifiers != 0 && last_dash[2] == '>') - key = last_dash[1]; + if (STRNICMP(last_dash + 1, "char-", 5) == 0 + && VIM_ISDIGIT(last_dash[6])) + { + /* or or */ + vim_str2nr(last_dash + 6, NULL, NULL, TRUE, TRUE, NULL, &n); + key = (int)n; + } else { - key = get_special_key_code(last_dash + 1); - if (!keep_x_key) - key = handle_x_keys(key); + /* + * Modifier with single letter, or special key name. + */ +#ifdef FEAT_MBYTE + if (has_mbyte) + l = mb_ptr2len(last_dash + 1); + else +#endif + l = 1; + if (modifiers != 0 && last_dash[l + 1] == '>') + key = PTR2CHAR(last_dash + 1); + else + { + key = get_special_key_code(last_dash + 1); + if (!keep_x_key) + key = handle_x_keys(key); + } } /* @@ -4659,9 +4682,8 @@ vim_findfile_stopdir(buf) { if (r_ptr[0] == '\\' && r_ptr[1] == ';') { - /* overwrite the escape char, - * use STRLEN(r_ptr) to move the trailing '\0' - */ + /* Overwrite the escape char, + * use STRLEN(r_ptr) to move the trailing '\0'. */ STRMOVE(r_ptr, r_ptr + 1); r_ptr++; } @@ -4920,10 +4942,13 @@ vim_findfile(search_ctx_arg) stackp->ffs_filearray_size = 0; } else + /* Add EW_NOTWILD because the expanded path may contain + * wildcard characters that are to be taken literally. + * This is a bit of a hack. */ expand_wildcards((dirptrs[1] == NULL) ? 1 : 2, dirptrs, &stackp->ffs_filearray_size, &stackp->ffs_filearray, - EW_DIR|EW_ADDSLASH|EW_SILENT); + EW_DIR|EW_ADDSLASH|EW_SILENT|EW_NOTWILD); stackp->ffs_filearray_cur = 0; stackp->ffs_stage = 0; diff --git a/src/ops.c b/src/ops.c index bdc53de33b..41193566db 100644 --- a/src/ops.c +++ b/src/ops.c @@ -6311,7 +6311,7 @@ line_count_info(line, wc, cc, limit, eol_size) *wc += words; /* Add eol_size if the end of line was reached before hitting limit. */ - if (line[i] == NUL && i < limit) + if (i < limit && line[i] == NUL) { i += eol_size; chars += eol_size; diff --git a/src/option.h b/src/option.h index 95dd431844..942794a20c 100644 --- a/src/option.h +++ b/src/option.h @@ -33,7 +33,7 @@ # ifdef EBCDIC #define DFLT_EFM "%*[^ ] %*[^ ] %f:%l%*[ ]%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f:%l:%c:%m,%f(%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.),%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-Gfrom %f:%l:%c,%-Gfrom %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%D%*\\a: Entering directory `%f',%X%*\\a: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m" +#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.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-Gfrom %f:%l:%c,%-Gfrom %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%D%*\\a: Entering directory `%f',%X%*\\a: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m" # endif # endif # endif diff --git a/src/os_mswin.c b/src/os_mswin.c index 1c1348a4e7..49b142895b 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -1856,12 +1856,12 @@ AbortProc(HDC hdcPrn, int iCode) { MSG msg; - while (!*bUserAbort && PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + while (!*bUserAbort && pPeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (!hDlgPrint || !IsDialogMessage(hDlgPrint, &msg)) + if (!hDlgPrint || !pIsDialogMessage(hDlgPrint, &msg)) { TranslateMessage(&msg); - DispatchMessage(&msg); + pDispatchMessage(&msg); } } return !*bUserAbort; @@ -3132,10 +3132,10 @@ serverProcessPendingMessages(void) { MSG msg; - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + while (pPeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); - DispatchMessage(&msg); + pDispatchMessage(&msg); } } diff --git a/src/os_unix.c b/src/os_unix.c index 3001a22254..a51eed0623 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -154,6 +154,13 @@ static int did_set_icon = FALSE; static void may_core_dump __ARGS((void)); +#ifdef HAVE_UNION_WAIT +typedef union wait waitstatus; +#else +typedef int waitstatus; +#endif +static pid_t wait4pid __ARGS((pid_t, waitstatus *)); + static int WaitForChar __ARGS((long)); #if defined(__BEOS__) int RealWaitForChar __ARGS((int, long, int *)); @@ -3666,6 +3673,47 @@ mch_new_shellsize() /* Nothing to do. */ } +/* + * Wait for process "child" to end. + * Return "child" if it exited properly, <= 0 on error. + */ + static pid_t +wait4pid(child, status) + pid_t child; + waitstatus *status; +{ + pid_t wait_pid = 0; + + while (wait_pid != child) + { +# ifdef _THREAD_SAFE + /* Ugly hack: when compiled with Python threads are probably + * used, in which case wait() sometimes hangs for no obvious + * reason. Use waitpid() instead and loop (like the GUI). */ +# ifdef __NeXT__ + wait_pid = wait4(child, status, WNOHANG, (struct rusage *)0); +# else + wait_pid = waitpid(child, status, WNOHANG); +# endif + if (wait_pid == 0) + { + /* Wait for 1/100 sec before trying again. */ + mch_delay(10L, TRUE); + continue; + } +# else + wait_pid = wait(status); +# endif + if (wait_pid <= 0 +# ifdef ECHILD + && errno == ECHILD +# endif + ) + break; + } + return wait_pid; +} + int mch_call_shell(cmd, options) char_u *cmd; @@ -3807,8 +3855,10 @@ mch_call_shell(cmd, options) int retval = -1; char **argv = NULL; int argc; + char_u *p_shcf_copy = NULL; int i; char_u *p; + char_u *s; int inquote; int pty_master_fd = -1; /* for pty's */ # ifdef FEAT_GUI @@ -3873,6 +3923,19 @@ mch_call_shell(cmd, options) } if (argv == NULL) { + /* + * Account for possible multiple args in p_shcf. + */ + p = p_shcf; + for (;;) + { + p = skiptowhite(p); + if (*p == NUL) + break; + ++argc; + p = skipwhite(p); + } + argv = (char **)alloc((unsigned)((argc + 4) * sizeof(char *))); if (argv == NULL) /* out of memory */ goto error; @@ -3882,7 +3945,23 @@ mch_call_shell(cmd, options) { if (extra_shell_arg != NULL) argv[argc++] = (char *)extra_shell_arg; - argv[argc++] = (char *)p_shcf; + + /* Break 'shellcmdflag' into white separated parts. This doesn't + * handle quoted strings, they are very unlikely to appear. */ + p_shcf_copy = alloc((unsigned)STRLEN(p_shcf) + 1); + if (p_shcf_copy == NULL) /* out of memory */ + goto error; + s = p_shcf_copy; + p = p_shcf; + while (*p != NUL) + { + argv[argc++] = (char *)s; + while (*p && *p != ' ' && *p != TAB) + *s++ = *p++; + *s++ = NUL; + p = skipwhite(p); + } + argv[argc++] = (char *)cmd; } argv[argc] = NULL; @@ -3909,12 +3988,13 @@ mch_call_shell(cmd, options) pty_master_fd = OpenPTY(&tty_name); /* open pty */ if (pty_master_fd >= 0) { -#if !defined(MACOS) || defined(USE_CARBONIZED) - pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0); -#else /* Leaving out O_NOCTTY may lead to waitpid() always returning - * 0 on Mac OS X 10.7 thereby causing freezes. */ - pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA); + * 0 on Mac OS X 10.7 thereby causing freezes. Let's assume + * adding O_NOCTTY always works when defined. */ +#ifdef O_NOCTTY + pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0); +#else + pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0); #endif if (pty_slave_fd < 0) { @@ -4220,7 +4300,7 @@ mch_call_shell(cmd, options) { MSG_PUTS(_("\nCannot fork\n")); } - else if (wpid == 0) + else if (wpid == 0) /* child */ { linenr_T lnum = curbuf->b_op_start.lnum; int written = 0; @@ -4228,7 +4308,6 @@ mch_call_shell(cmd, options) char_u *s; size_t l; - /* child */ close(fromshell_fd); for (;;) { @@ -4273,7 +4352,7 @@ mch_call_shell(cmd, options) } _exit(0); } - else + else /* parent */ { close(toshell_fd); toshell_fd = -1; @@ -4574,7 +4653,7 @@ mch_call_shell(cmd, options) * typed characters (otherwise we would lose typeahead). */ # ifdef __NeXT__ - wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *) 0); + wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *)0); # else wait_pid = waitpid(pid, &status, WNOHANG); # endif @@ -4623,33 +4702,8 @@ finished: * Don't wait if wait_pid was already set above, indicating the * child already exited. */ - while (wait_pid != pid) - { -# ifdef _THREAD_SAFE - /* Ugly hack: when compiled with Python threads are probably - * used, in which case wait() sometimes hangs for no obvious - * reason. Use waitpid() instead and loop (like the GUI). */ -# ifdef __NeXT__ - wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *)0); -# else - wait_pid = waitpid(pid, &status, WNOHANG); -# endif - if (wait_pid == 0) - { - /* Wait for 1/100 sec before trying again. */ - mch_delay(10L, TRUE); - continue; - } -# else - wait_pid = wait(&status); -# endif - if (wait_pid <= 0 -# ifdef ECHILD - && errno == ECHILD -# endif - ) - break; - } + if (wait_pid != pid) + wait_pid = wait4pid(pid, &status); # ifdef FEAT_GUI /* Close slave side of pty. Only do this after the child has @@ -4662,7 +4716,10 @@ finished: /* Make sure the child that writes to the external program is * dead. */ if (wpid > 0) + { kill(wpid, SIGKILL); + wait4pid(wpid, NULL); + } /* * Set to raw mode right now, otherwise a CTRL-C after @@ -4698,6 +4755,7 @@ finished: } } vim_free(argv); + vim_free(p_shcf_copy); error: if (!did_settmode) @@ -4808,7 +4866,8 @@ WaitForChar(msec) /* * Wait "msec" msec until a character is available from file descriptor "fd". - * Time == -1 will block forever. + * "msec" == 0 will check for characters once. + * "msec" == -1 will block until a character is available. * When a GUI is being used, this will not be used for input -- webb * Returns also, when a request from Sniff is waiting -- toni. * Or when a Linux GPM mouse event is waiting. @@ -5046,7 +5105,8 @@ RealWaitForChar(fd, msec, check_for_gpm) /* * Select on ready for reading and exceptional condition (end of file). */ - FD_ZERO(&rfds); /* calls bzero() on a sun */ +select_eintr: + FD_ZERO(&rfds); FD_ZERO(&efds); FD_SET(fd, &rfds); # if !defined(__QNX__) && !defined(__CYGWIN32__) @@ -5106,6 +5166,14 @@ RealWaitForChar(fd, msec, check_for_gpm) # else ret = select(maxfd + 1, &rfds, NULL, &efds, tvp); # endif +# ifdef EINTR + if (ret == -1 && errno == EINTR) + /* Interrupted by a signal, need to try again. We ignore msec + * here, because we do want to check even after a timeout if + * characters are available. Needed for reading output of an + * external command after the process has finished. */ + goto select_eintr; +# endif # ifdef __TANDEM if (ret == -1 && errno == ENOTSUP) { @@ -5113,7 +5181,7 @@ RealWaitForChar(fd, msec, check_for_gpm) FD_ZERO(&efds); ret = 0; } -#endif +# endif # ifdef FEAT_MZSCHEME if (ret == 0 && mzquantum_used) /* loop if MzThreads must be scheduled and timeout occurred */ diff --git a/src/os_win32.c b/src/os_win32.c index 88ead6fd63..fbf077f6f7 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -152,6 +152,14 @@ static PFNGCKLN s_pfnGetConsoleKeyboardLayoutName = NULL; # define wcsicmp(a, b) wcscmpi((a), (b)) #endif +/* Enable common dialogs input unicode from IME if posible. */ +#ifdef FEAT_MBYTE +LRESULT (WINAPI *pDispatchMessage)(LPMSG) = DispatchMessage; +BOOL (WINAPI *pGetMessage)(LPMSG, HWND, UINT, UINT) = GetMessage; +BOOL (WINAPI *pIsDialogMessage)(HWND, LPMSG) = IsDialogMessage; +BOOL (WINAPI *pPeekMessage)(LPMSG, HWND, UINT, UINT, UINT) = PeekMessage; +#endif + #ifndef FEAT_GUI_W32 /* Win32 Console handles for input and output */ static HANDLE g_hConIn = INVALID_HANDLE_VALUE; @@ -3284,10 +3292,10 @@ mch_system_classic(char *cmd, int options) { MSG msg; - if (PeekMessage(&msg, (HWND)NULL, 0, 0, PM_REMOVE)) + if (pPeekMessage(&msg, (HWND)NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); - DispatchMessage(&msg); + pDispatchMessage(&msg); } if (WaitForSingleObject(pi.hProcess, delay) != WAIT_TIMEOUT) break; @@ -3411,8 +3419,6 @@ dump_pipe(int options, { DWORD availableBytes = 0; DWORD i; - int c; - char_u *p; int ret; DWORD len; DWORD toRead; @@ -3471,6 +3477,8 @@ dump_pipe(int options, else if (has_mbyte) { int l; + int c; + char_u *p; len += *buffer_off; buffer[len] = NUL; @@ -3550,9 +3558,7 @@ mch_system_piped(char *cmd, int options) int noread_cnt = 0; garray_T ga; int delay = 1; -# ifdef FEAT_MBYTE DWORD buffer_off = 0; /* valid bytes in buffer[] */ -# endif SECURITY_ATTRIBUTES saAttr; @@ -3769,14 +3775,12 @@ mch_system_piped(char *cmd, int options) if (WaitForSingleObject(pi.hProcess, delay) != WAIT_TIMEOUT) { - dump_pipe(options, g_hChildStd_OUT_Rd, - &ga, buffer, &buffer_off); + dump_pipe(options, g_hChildStd_OUT_Rd, &ga, buffer, &buffer_off); break; } ++noread_cnt; - dump_pipe(options, g_hChildStd_OUT_Rd, - &ga, buffer, &buffer_off); + dump_pipe(options, g_hChildStd_OUT_Rd, &ga, buffer, &buffer_off); /* We start waiting for a very short time and then increase it, so * that we respond quickly when the process is quick, and don't diff --git a/src/os_win32.h b/src/os_win32.h index 41a44bf0d7..5303d6ddcc 100644 --- a/src/os_win32.h +++ b/src/os_win32.h @@ -193,3 +193,17 @@ Trace(char *pszFormat, ...); #else # define vim_mkdir(x, y) mch_mkdir(x) #endif + +/* Enable common dialogs input unicode from IME if posible. */ +#ifdef FEAT_MBYTE + /* The variables are defined in os_win32.c. */ +extern LRESULT (WINAPI *pDispatchMessage)(LPMSG); +extern BOOL (WINAPI *pGetMessage)(LPMSG, HWND, UINT, UINT); +extern BOOL (WINAPI *pIsDialogMessage)(HWND, LPMSG); +extern BOOL (WINAPI *pPeekMessage)(LPMSG, HWND, UINT, UINT, UINT); +#else +# define pDispatchMessage DispatchMessage +# define pGetMessage GetMessage +# define pIsDialogMessage IsDialogMessage +# define pPeekMessage PeekMessage +#endif diff --git a/src/proto/gui_gtk_x11.pro b/src/proto/gui_gtk_x11.pro index 2484082b79..e395a0cfe6 100644 --- a/src/proto/gui_gtk_x11.pro +++ b/src/proto/gui_gtk_x11.pro @@ -20,6 +20,7 @@ int gui_mch_get_winpos __ARGS((int *x, int *y)); void gui_mch_set_winpos __ARGS((int x, int y)); int gui_mch_maximized __ARGS((void)); void gui_mch_unmaximize __ARGS((void)); +void gui_mch_newfont __ARGS((void)); void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height, int direction)); void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h)); void gui_mch_settitle __ARGS((char_u *title, char_u *icon)); diff --git a/src/proto/mbyte.pro b/src/proto/mbyte.pro index 88496ccf06..8c0788c7fa 100644 --- a/src/proto/mbyte.pro +++ b/src/proto/mbyte.pro @@ -2,6 +2,7 @@ int enc_canon_props __ARGS((char_u *name)); char_u *mb_init __ARGS((void)); int bomb_size __ARGS((void)); +void remove_bom __ARGS((char_u *s)); int mb_get_class __ARGS((char_u *p)); int dbcs_class __ARGS((unsigned lead, unsigned trail)); int latin_char2len __ARGS((int c)); diff --git a/src/quickfix.c b/src/quickfix.c index 999c66ed9b..0502392c92 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -126,6 +126,7 @@ static int is_qf_win __ARGS((win_T *win, qf_info_T *qi)); static win_T *qf_find_win __ARGS((qf_info_T *qi)); static buf_T *qf_find_buf __ARGS((qf_info_T *qi)); static void qf_update_buffer __ARGS((qf_info_T *qi)); +static void qf_set_title __ARGS((qf_info_T *qi)); static void qf_fill_buffer __ARGS((qf_info_T *qi)); #endif static char_u *get_mef_name __ARGS((void)); @@ -561,6 +562,10 @@ qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast, break; IObuff[CMDBUFFSIZE - 2] = NUL; /* for very long lines */ +#ifdef FEAT_MBYTE + remove_bom(IObuff); +#endif + if ((efmp = vim_strrchr(IObuff, '\n')) != NULL) *efmp = NUL; #ifdef USE_CRNL @@ -2384,8 +2389,7 @@ ex_copen(eap) qf_fill_buffer(qi); if (qi->qf_lists[qi->qf_curlist].qf_title != NULL) - set_internal_string_var((char_u *)"w:quickfix_title", - qi->qf_lists[qi->qf_curlist].qf_title); + qf_set_title(qi); curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index; curwin->w_cursor.col = 0; @@ -2522,6 +2526,8 @@ qf_update_buffer(qi) qf_info_T *qi; { buf_T *buf; + win_T *win; + win_T *curwin_save; aco_save_T aco; /* Check if a buffer for the quickfix list exists. Update it. */ @@ -2533,6 +2539,16 @@ qf_update_buffer(qi) qf_fill_buffer(qi); + if (qi->qf_lists[qi->qf_curlist].qf_title != NULL + && (win = qf_find_win(qi)) != NULL) + { + curwin_save = curwin; + curwin = win; + qf_set_title(qi); + curwin = curwin_save; + + } + /* restore curwin/curbuf and a few other things */ aucmd_restbuf(&aco); @@ -2540,6 +2556,14 @@ qf_update_buffer(qi) } } + static void +qf_set_title(qi) + qf_info_T *qi; +{ + set_internal_string_var((char_u *)"w:quickfix_title", + qi->qf_lists[qi->qf_curlist].qf_title); +} + /* * Fill current buffer with quickfix errors, replacing any previous contents. * curbuf must be the quickfix buffer! diff --git a/src/screen.c b/src/screen.c index 5becb3ce93..47b925f470 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2531,7 +2531,9 @@ fold_line(wp, fold_count, foldinfo, lnum, row) /* Visual block mode: highlight the chars part of the block */ if (wp->w_old_cursor_fcol + txtcol < (colnr_T)W_WIDTH(wp)) { - if (wp->w_old_cursor_lcol + txtcol < (colnr_T)W_WIDTH(wp)) + if (wp->w_old_cursor_lcol != MAXCOL + && wp->w_old_cursor_lcol + txtcol + < (colnr_T)W_WIDTH(wp)) len = wp->w_old_cursor_lcol; else len = W_WIDTH(wp) - txtcol; @@ -4252,7 +4254,7 @@ win_line(wp, lnum, startrow, endrow, nochange) { /* tab amount depends on current column */ n_extra = (int)wp->w_buffer->b_p_ts - - vcol % (int)wp->w_buffer->b_p_ts - 1; + - VCOL_HLC % (int)wp->w_buffer->b_p_ts - 1; #ifdef FEAT_MBYTE mb_utf8 = FALSE; /* don't draw as UTF-8 */ #endif diff --git a/src/spell.c b/src/spell.c index eade2f7c75..464d4d0d18 100644 --- a/src/spell.c +++ b/src/spell.c @@ -11197,7 +11197,7 @@ allcap_copy(word, wcopy) c = *s++; #ifdef FEAT_MBYTE - /* We only change ß to SS when we are certain latin1 is used. It + /* We only change 0xdf to SS when we are certain latin1 is used. It * would cause weird errors in other 8-bit encodings. */ if (enc_latin1like && c == 0xdf) { diff --git a/src/testdir/test10.in b/src/testdir/test10.in index 6d0c721ddd..50ef86eb0c 100644 --- a/src/testdir/test10.in +++ b/src/testdir/test10.in @@ -2,9 +2,19 @@ Test for 'errorformat'. This will fail if the quickfix feature was disabled. STARTTEST :so small.vim -:/start of errorfile/,/end of errorfile/w! Xerrorfile +:" Also test a BOM is ignored. +:so mbyte.vim +:set encoding=utf-8 +:7/start of errorfile/,/end of errorfile/w! Xerrorfile1 +:7/start of errorfile/,/end of errorfile/-1w! Xerrorfile2 :/start of testfile/,/end of testfile/w! Xtestfile -:cf Xerrorfile +:cf Xerrorfile2 +:clast +:copen +:let a=w:quickfix_title +:wincmd p +gR=a  +:cf Xerrorfile1 rA :cn rB @@ -14,13 +24,18 @@ rC rD :cn rE +:cn +:wincmd w +:let a=w:quickfix_title +:wincmd p +gR=a  :w! test.out " Write contents of this file :qa! ENDTEST start of errorfile "Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set. -"Xtestfile", line 7 col 19; this is an error +"Xtestfile", line 7 col 19; this is an error gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c Xtestfile:13: parse error before `asd' make: *** [vim] Error 1 @@ -30,6 +45,8 @@ in file "Xtestfile" linenr 16: there is an error "Xtestfile", linenr 19: yet another problem Does anyone know what is the problem and how to correction it? +"Xtestfile", line 21 col 9: What is the title of the quickfix window? +"Xtestfile", line 22 col 9: What is the title of the quickfix window? end of errorfile start of testfile diff --git a/src/testdir/test10.ok b/src/testdir/test10.ok index 2c86889c18..01d47e8f35 100644 --- a/src/testdir/test10.ok +++ b/src/testdir/test10.ok @@ -18,6 +18,6 @@ line 17 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Eine 19 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -line 21 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -line 22 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +line 21 :cf Xerrorfile1xxxxxxxxxxxxxxx +line 22 :cf Xerrorfile2xxxxxxxxxxxxxxx end of testfile diff --git a/src/testdir/test19.in b/src/testdir/test19.in index bdcfb77dba..cbb4dd2c22 100644 --- a/src/testdir/test19.in +++ b/src/testdir/test19.in @@ -1,6 +1,7 @@ Tests for "r" with 'smarttab' and 'expandtab' set/not set. STARTTEST +:so small.vim :set smarttab expandtab ts=8 sw=4 :" make sure that backspace works, no matter what termcap is used :set t_kD=x7f t_kb=x08 @@ -12,7 +13,10 @@ r 0wR  :" Test replacing with Tabs 0wR  -:?^start?,$w! test.out +:" Test that copyindent works with expandtab set +:set expandtab smartindent copyindent ts=8 sw=8 sts=8 +o{ +x:?^start?,$w! test.out :qa! ENDTEST diff --git a/src/testdir/test19.ok b/src/testdir/test19.ok index ba4eb63beb..23d51507db 100644 --- a/src/testdir/test19.ok +++ b/src/testdir/test19.ok @@ -5,3 +5,5 @@ test text a cde hi test text +{ + x diff --git a/src/testdir/test75.in b/src/testdir/test75.in index 2de7a089be..5369d8a3df 100644 --- a/src/testdir/test75.in +++ b/src/testdir/test75.in @@ -2,6 +2,7 @@ STARTTEST :so small.vim +:set cpo-=< :" Test maparg() with a string result :map foo isfoo :vnoremap