From dcd33221821843049025fc14ce29a84b2157955d Mon Sep 17 00:00:00 2001 From: edyfox Date: Thu, 2 Jul 2009 06:41:41 +0000 Subject: [PATCH] Merged from the latest developing branch. git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1547 2a77ed30-b011-0410-a7ad-c7884a0aa172 --- src/ex_docmd.c | 5 ++++ src/fileio.c | 9 +++++-- src/gui_gtk_x11.c | 19 +------------- src/gui_photon.c | 7 ++++- src/message.c | 2 +- src/ops.c | 23 +++++++++++++++++ src/proto/ui.pro | 1 + src/ui.c | 66 +++++++++++++++++++++++++++++++++++++++-------- src/version.c | 8 ++++++ 9 files changed, 107 insertions(+), 33 deletions(-) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 54d5b2d..47c460c 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -8686,6 +8686,8 @@ ex_mkrc(eap) } #ifdef FEAT_SESSION + /* Use the short file name until ":lcd" is used. We also don't use the + * short file name when 'acd' is set, that is checked later. */ did_lcd = FALSE; /* ":mkview" or ":mkview 9": generate file name with 'viewdir' */ @@ -10573,6 +10575,9 @@ ses_fname(fd, buf, flagp) if (buf->b_sfname != NULL && flagp == &ssop_flags && (ssop_flags & (SSOP_CURDIR | SSOP_SESDIR)) +#ifdef FEAT_AUTOCHDIR + && !p_acd +#endif && !did_lcd) name = buf->b_sfname; else diff --git a/src/fileio.c b/src/fileio.c index 61c2148..b17806b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -8441,13 +8441,16 @@ aucmd_prepbuf(aco, buf) win_init_empty(aucmd_win); /* set cursor and topline to safe values */ #ifdef FEAT_WINDOWS - /* Split the current window, put the aucmd_win in the upper half. */ + /* Split the current window, put the aucmd_win in the upper half. + * We don't want the BufEnter or WinEnter autocommands. */ + block_autocmds(); make_snapshot(SNAP_AUCMD_IDX); save_ea = p_ea; p_ea = FALSE; (void)win_split_ins(0, WSP_TOP, aucmd_win, 0); (void)win_comp_pos(); /* recompute window positions */ p_ea = save_ea; + unblock_autocmds(); #endif curwin = aucmd_win; } @@ -8474,7 +8477,8 @@ aucmd_restbuf(aco) --curbuf->b_nwindows; #ifdef FEAT_WINDOWS /* Find "aucmd_win", it can't be closed, but it may be in another tab - * page. */ + * page. Do not trigger autocommands here. */ + block_autocmds(); if (curwin != aucmd_win) { tabpage_T *tp; @@ -8498,6 +8502,7 @@ aucmd_restbuf(aco) last_status(FALSE); /* may need to remove last status line */ restore_snapshot(SNAP_AUCMD_IDX, FALSE); (void)win_comp_pos(); /* recompute window positions */ + unblock_autocmds(); if (win_valid(aco->save_curwin)) curwin = aco->save_curwin; diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 29ab9a7..33fdaed 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -6717,8 +6717,6 @@ clip_mch_request_selection(VimClipboard *cbd) { GdkAtom target; unsigned i; - int nbytes; - char_u *buffer; time_t start; for (i = 0; i < N_SELECTION_TARGETS; ++i) @@ -6746,22 +6744,7 @@ clip_mch_request_selection(VimClipboard *cbd) } /* Final fallback position - use the X CUT_BUFFER0 store */ - nbytes = 0; - buffer = (char_u *)XFetchBuffer(GDK_WINDOW_XDISPLAY(gui.mainwin->window), - &nbytes, 0); - if (nbytes > 0) - { - /* Got something */ - clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd); - if (p_verbose > 0) - { - verbose_enter(); - smsg((char_u *)_("Used CUT_BUFFER0 instead of empty selection")); - verbose_leave(); - } - } - if (buffer != NULL) - XFree(buffer); + yank_cut_buffer0(GDK_WINDOW_XDISPLAY(gui.mainwin->window), cbd); } /* diff --git a/src/gui_photon.c b/src/gui_photon.c index a8ee1c4..42b1242 100644 --- a/src/gui_photon.c +++ b/src/gui_photon.c @@ -838,7 +838,12 @@ gui_ph_handle_window_open( static void gui_ph_draw_start( void ) { + PhGC_t *gc; + + gc = PgGetGC(); PgSetRegion( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ) ); + PgClearClippingsCx( gc ); + PgClearTranslationCx( gc ); PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset ); PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos( gui.vimTextArea, NULL ) ); @@ -2970,7 +2975,7 @@ gui_mch_init_font(char_u *vim_font_name, int fontset) if( vim_font_name == NULL ) { /* Default font */ - vim_font_name = "PC Term"; + vim_font_name = "PC Terminal"; } if( STRCMP( vim_font_name, "*" ) == 0 ) diff --git a/src/message.c b/src/message.c index c0f661b..e29f5f8 100644 --- a/src/message.c +++ b/src/message.c @@ -107,7 +107,7 @@ msg(s) } #if defined(FEAT_EVAL) || defined(FEAT_X11) || defined(USE_XSMP) \ - || defined(PROTO) + || defined(FEAT_GUI_GTK) || defined(PROTO) /* * Like msg() but keep it silent when 'verbosefile' is set. */ diff --git a/src/ops.c b/src/ops.c index 3e595fd..f75613d 100644 --- a/src/ops.c +++ b/src/ops.c @@ -5591,6 +5591,29 @@ x11_export_final_selection() if (dpy != NULL && str != NULL && motion_type >= 0 && len < 1024*1024 && len > 0) { +#ifdef FEAT_MBYTE + /* The CUT_BUFFER0 is supposed to always contain latin1. Convert from + * 'enc' when it is a multi-byte encoding. When 'enc' is an 8-bit + * encoding conversion usually doesn't work, so keep the text as-is. + */ + if (has_mbyte) + { + char_u *conv_str = str; + vimconv_T vc; + + vc.vc_type = CONV_NONE; + if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK) + { + conv_str = string_convert(&vc, str, (int*)&len); + if (conv_str != NULL) + { + vim_free(str); + str = conv_str; + } + convert_setup(&vc, NULL, NULL); + } + } +#endif XStoreBuffer(dpy, (char *)str, (int)len, 0); XFlush(dpy); } diff --git a/src/proto/ui.pro b/src/proto/ui.pro index 8825b6a..2bc0c31 100644 --- a/src/proto/ui.pro +++ b/src/proto/ui.pro @@ -48,6 +48,7 @@ int check_row __ARGS((int row)); void open_app_context __ARGS((void)); void x11_setup_atoms __ARGS((Display *dpy)); void clip_x11_request_selection __ARGS((Widget myShell, Display *dpy, VimClipboard *cbd)); +void yank_cut_buffer0 __ARGS((Display *dpy, VimClipboard *cbd)); void clip_x11_lose_selection __ARGS((Widget myShell, VimClipboard *cbd)); int clip_x11_own_selection __ARGS((Widget myShell, VimClipboard *cbd)); void clip_x11_set_selection __ARGS((VimClipboard *cbd)); diff --git a/src/ui.c b/src/ui.c index 443f9c4..aa8a8ac 100644 --- a/src/ui.c +++ b/src/ui.c @@ -2104,8 +2104,6 @@ clip_x11_request_selection(myShell, dpy, cbd) Atom type; static int success; int i; - int nbytes = 0; - char_u *buffer; time_t start_time; int timed_out = FALSE; @@ -2185,15 +2183,7 @@ clip_x11_request_selection(myShell, dpy, cbd) } /* Final fallback position - use the X CUT_BUFFER0 store */ - buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0); - if (nbytes > 0) - { - /* Got something */ - clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd); - XFree((void *)buffer); - if (p_verbose > 0) - verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection")); - } + yank_cut_buffer0(dpy, cbd); } static Boolean clip_x11_convert_selection_cb __ARGS((Widget, Atom *, Atom *, Atom *, XtPointer *, long_u *, int *)); @@ -2369,6 +2359,60 @@ clip_x11_set_selection(cbd) } #endif +#if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11) \ + || defined(FEAT_GUI_GTK) || defined(PROTO) +/* + * Get the contents of the X CUT_BUFFER0 and put it in "cbd". + */ + void +yank_cut_buffer0(dpy, cbd) + Display *dpy; + VimClipboard *cbd; +{ + int nbytes = 0; + char_u *buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0); + + if (nbytes > 0) + { +#ifdef FEAT_MBYTE + int done = FALSE; + + /* CUT_BUFFER0 is supposed to be always latin1. Convert to 'enc' when + * using a multi-byte encoding. Conversion between two 8-bit + * character sets usually fails and the text might actually be in + * 'enc' anyway. */ + if (has_mbyte) + { + char_u *conv_buf = buffer; + vimconv_T vc; + + vc.vc_type = CONV_NONE; + if (convert_setup(&vc, (char_u *)"latin1", p_enc) == OK) + { + conv_buf = string_convert(&vc, buffer, &nbytes); + if (conv_buf != NULL) + { + clip_yank_selection(MCHAR, conv_buf, (long)nbytes, cbd); + vim_free(conv_buf); + done = TRUE; + } + convert_setup(&vc, NULL, NULL); + } + } + if (!done) /* use the text without conversion */ +#endif + clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd); + XFree((void *)buffer); + if (p_verbose > 0) + { + verbose_enter(); + verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection")); + verbose_leave(); + } + } +} +#endif + #if defined(FEAT_MOUSE) || defined(PROTO) /* diff --git a/src/version.c b/src/version.c index 6017cfd..3a95242 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,14 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 222, +/**/ + 221, +/**/ + 220, +/**/ + 219, /**/ 218, /**/