1
0
forked from aniani/vim

updated for version 7.3.597

Problem:    'clipboard' "autoselect" only applies to the * register. (Sergey
            Vakulenko)
Solution:   Make 'autoselect' work for the + register. (Christian Brabant)
            Add the "autoselectplus" option in 'clipboard' and the "P" flag in
            'guioptions'.
This commit is contained in:
Bram Moolenaar
2012-07-10 16:49:23 +02:00
parent f65e5667df
commit c0885aad5c
10 changed files with 113 additions and 58 deletions

View File

@@ -1452,6 +1452,7 @@ A jump table for the options with a short description can be found at |Q_op|.
This option is a list of comma separated names. This option is a list of comma separated names.
These names are recognized: These names are recognized:
*clipboard-unnamed*
unnamed When included, Vim will use the clipboard register '*' unnamed When included, Vim will use the clipboard register '*'
for all yank, delete, change and put operations which for all yank, delete, change and put operations which
would normally go to the unnamed register. When a would normally go to the unnamed register. When a
@@ -1481,9 +1482,16 @@ A jump table for the options with a short description can be found at |Q_op|.
"autoselect" flag is used. "autoselect" flag is used.
Also applies to the modeless selection. Also applies to the modeless selection.
*clipboard-autoselectplus*
autoselectplus Like "autoselect" but using the + register instead of
the * register. Compare to the 'P' flag in
'guioptions'.
*clipboard-autoselectml*
autoselectml Like "autoselect", but for the modeless selection autoselectml Like "autoselect", but for the modeless selection
only. Compare to the 'A' flag in 'guioptions'. only. Compare to the 'A' flag in 'guioptions'.
*clipboard-html*
html When the clipboard contains HTML, use this when html When the clipboard contains HTML, use this when
pasting. When putting text on the clipboard, mark it pasting. When putting text on the clipboard, mark it
as HTML. This works to copy rendered HTML from as HTML. This works to copy rendered HTML from
@@ -1494,6 +1502,7 @@ A jump table for the options with a short description can be found at |Q_op|.
Only supported for GTK version 2 and later. Only supported for GTK version 2 and later.
Only available with the |+multi_byte| feature. Only available with the |+multi_byte| feature.
*clipboard-exclude*
exclude:{pattern} exclude:{pattern}
Defines a pattern that is matched against the name of Defines a pattern that is matched against the name of
the terminal 'term'. If there is a match, no the terminal 'term'. If there is a match, no
@@ -3589,6 +3598,9 @@ A jump table for the options with a short description can be found at |Q_op|.
windowing system's global selection unless explicitly told to windowing system's global selection unless explicitly told to
by a yank or delete operation for the "* register. by a yank or delete operation for the "* register.
The same applies to the modeless selection. The same applies to the modeless selection.
*'go-P'*
'P' Like autoselect but using the "+ register instead of the "*
register.
*'go-A'* *'go-A'*
'A' Autoselect for the modeless selection. Like 'a', but only 'A' Autoselect for the modeless selection. Like 'a', but only
applies to the modeless selection. applies to the modeless selection.

View File

@@ -517,7 +517,8 @@ EXTERN VimClipboard clip_plus; /* CLIPBOARD selection in X11 */
# define CLIP_UNNAMED_PLUS 2 # define CLIP_UNNAMED_PLUS 2
EXTERN int clip_unnamed INIT(= 0); /* above two values or'ed */ EXTERN int clip_unnamed INIT(= 0); /* above two values or'ed */
EXTERN int clip_autoselect INIT(= FALSE); EXTERN int clip_autoselect_star INIT(= FALSE);
EXTERN int clip_autoselect_plus INIT(= FALSE);
EXTERN int clip_autoselectml INIT(= FALSE); EXTERN int clip_autoselectml INIT(= FALSE);
EXTERN int clip_html INIT(= FALSE); EXTERN int clip_html INIT(= FALSE);
EXTERN regprog_T *clip_exclude_prog INIT(= NULL); EXTERN regprog_T *clip_exclude_prog INIT(= NULL);

View File

@@ -3154,7 +3154,7 @@ button_set:
} }
if (clip_star.state != SELECT_CLEARED && !did_clip) if (clip_star.state != SELECT_CLEARED && !did_clip)
clip_clear_selection(); clip_clear_selection(&clip_star);
#endif #endif
/* Don't put events in the input queue now. */ /* Don't put events in the input queue now. */

View File

@@ -1451,7 +1451,7 @@ do_pending_operator(cap, old_col, gui_yank)
* This could call do_pending_operator() recursively, but that's OK * This could call do_pending_operator() recursively, but that's OK
* because gui_yank will be TRUE for the nested call. * because gui_yank will be TRUE for the nested call.
*/ */
if (clip_star.available if ((clip_star.available || clip_plus.available)
&& oap->op_type != OP_NOP && oap->op_type != OP_NOP
&& !gui_yank && !gui_yank
# ifdef FEAT_VISUAL # ifdef FEAT_VISUAL

View File

@@ -962,8 +962,14 @@ get_register(name, copy)
* selection too. */ * selection too. */
if (name == '*' && clip_star.available) if (name == '*' && clip_star.available)
{ {
if (clip_isautosel()) if (clip_isautosel_star())
clip_update_selection(); clip_update_selection(&clip_star);
may_get_selection(name);
}
if (name == '+' && clip_plus.available)
{
if (clip_isautosel_plus())
clip_update_selection(&clip_plus);
may_get_selection(name); may_get_selection(name);
} }
#endif #endif
@@ -3190,7 +3196,8 @@ op_yank(oap, deleting, mess)
clip_own_selection(&clip_plus); clip_own_selection(&clip_plus);
clip_gen_set_selection(&clip_plus); clip_gen_set_selection(&clip_plus);
if (!clip_isautosel() && !did_star && curr == &(y_regs[PLUS_REGISTER])) if (!clip_isautosel_star() && !did_star
&& curr == &(y_regs[PLUS_REGISTER]))
{ {
copy_yank_reg(&(y_regs[STAR_REGISTER])); copy_yank_reg(&(y_regs[STAR_REGISTER]));
clip_own_selection(&clip_star); clip_own_selection(&clip_star);

View File

@@ -229,6 +229,7 @@
#define GO_MENUS 'm' /* use menu bar */ #define GO_MENUS 'm' /* use menu bar */
#define GO_NOSYSMENU 'M' /* don't source system menu */ #define GO_NOSYSMENU 'M' /* don't source system menu */
#define GO_POINTER 'p' /* pointer enter/leave callbacks */ #define GO_POINTER 'p' /* pointer enter/leave callbacks */
#define GO_ASELPLUS 'P' /* autoselectPlus */
#define GO_RIGHT 'r' /* use right scrollbar */ #define GO_RIGHT 'r' /* use right scrollbar */
#define GO_VRIGHT 'R' /* right scrollbar with vert split */ #define GO_VRIGHT 'R' /* right scrollbar with vert split */
#define GO_TEAROFF 't' /* add tear-off menu items */ #define GO_TEAROFF 't' /* add tear-off menu items */

View File

@@ -11,17 +11,17 @@ void ui_set_shellsize __ARGS((int mustset));
void ui_new_shellsize __ARGS((void)); void ui_new_shellsize __ARGS((void));
void ui_breakcheck __ARGS((void)); void ui_breakcheck __ARGS((void));
void clip_init __ARGS((int can_use)); void clip_init __ARGS((int can_use));
void clip_update_selection __ARGS((void)); void clip_update_selection __ARGS((VimClipboard *clip));
void clip_own_selection __ARGS((VimClipboard *cbd)); void clip_own_selection __ARGS((VimClipboard *cbd));
void clip_lose_selection __ARGS((VimClipboard *cbd)); void clip_lose_selection __ARGS((VimClipboard *cbd));
void clip_copy_selection __ARGS((void));
void clip_auto_select __ARGS((void)); void clip_auto_select __ARGS((void));
int clip_isautosel __ARGS((void)); int clip_isautosel_star __ARGS((void));
int clip_isautosel_plus __ARGS((void));
void clip_modeless __ARGS((int button, int is_click, int is_drag)); void clip_modeless __ARGS((int button, int is_click, int is_drag));
void clip_start_selection __ARGS((int col, int row, int repeated_click)); void clip_start_selection __ARGS((int col, int row, int repeated_click));
void clip_process_selection __ARGS((int button, int col, int row, int_u repeated_click)); void clip_process_selection __ARGS((int button, int col, int row, int_u repeated_click));
void clip_may_redraw_selection __ARGS((int row, int col, int len)); void clip_may_redraw_selection __ARGS((int row, int col, int len));
void clip_clear_selection __ARGS((void)); void clip_clear_selection __ARGS((VimClipboard *cbd));
void clip_may_clear_selection __ARGS((int row1, int row2)); void clip_may_clear_selection __ARGS((int row1, int row2));
void clip_scroll_selection __ARGS((int rows)); void clip_scroll_selection __ARGS((int rows));
void clip_copy_modeless_selection __ARGS((int both)); void clip_copy_modeless_selection __ARGS((int both));

View File

@@ -519,8 +519,10 @@ update_screen(type)
# endif # endif
# ifdef FEAT_CLIPBOARD # ifdef FEAT_CLIPBOARD
/* When Visual area changed, may have to update selection. */ /* When Visual area changed, may have to update selection. */
if (clip_star.available && clip_isautosel()) if (clip_star.available && clip_isautosel_star())
clip_update_selection(); clip_update_selection(&clip_star);
if (clip_plus.available && clip_isautosel_plus())
clip_update_selection(&clip_plus);
# endif # endif
#ifdef FEAT_GUI #ifdef FEAT_GUI
/* Remove the cursor before starting to do anything, because /* Remove the cursor before starting to do anything, because
@@ -814,8 +816,10 @@ updateWindow(wp)
#ifdef FEAT_CLIPBOARD #ifdef FEAT_CLIPBOARD
/* When Visual area changed, may have to update selection. */ /* When Visual area changed, may have to update selection. */
if (clip_star.available && clip_isautosel()) if (clip_star.available && clip_isautosel_star())
clip_update_selection(); clip_update_selection(&clip_star);
if (clip_plus.available && clip_isautosel_plus())
clip_update_selection(&clip_plus);
#endif #endif
win_update(wp); win_update(wp);
@@ -3000,7 +3004,10 @@ win_line(wp, lnum, startrow, endrow, nochange)
area_highlighting = TRUE; area_highlighting = TRUE;
attr = hl_attr(HLF_V); attr = hl_attr(HLF_V);
#if defined(FEAT_CLIPBOARD) && defined(FEAT_X11) #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
if (clip_star.available && !clip_star.owned && clip_isautosel()) if ((clip_star.available && !clip_star.owned
&& clip_isautosel_star())
|| (clip_plus.available && !clip_plus.owned
&& clip_isautosel_plus()))
attr = hl_attr(HLF_VNC); attr = hl_attr(HLF_VNC);
#endif #endif
} }
@@ -9060,7 +9067,7 @@ screen_ins_lines(off, row, line_count, end, wp)
|| (wp != NULL && wp->w_width != Columns) || (wp != NULL && wp->w_width != Columns)
# endif # endif
) )
clip_clear_selection(); clip_clear_selection(&clip_star);
else else
clip_scroll_selection(-line_count); clip_scroll_selection(-line_count);
#endif #endif
@@ -9281,7 +9288,7 @@ screen_del_lines(off, row, line_count, end, force, wp)
|| (wp != NULL && wp->w_width != Columns) || (wp != NULL && wp->w_width != Columns)
# endif # endif
) )
clip_clear_selection(); clip_clear_selection(&clip_star);
else else
clip_scroll_selection(line_count); clip_scroll_selection(line_count);
#endif #endif

107
src/ui.c
View File

@@ -381,6 +381,8 @@ ui_breakcheck()
#if defined(FEAT_CLIPBOARD) || defined(PROTO) #if defined(FEAT_CLIPBOARD) || defined(PROTO)
static void clip_copy_selection __ARGS((VimClipboard *clip));
/* /*
* Selection stuff using Visual mode, for cutting and pasting text to other * Selection stuff using Visual mode, for cutting and pasting text to other
* windows. * windows.
@@ -423,9 +425,10 @@ clip_init(can_use)
* this is called whenever VIsual mode is ended. * this is called whenever VIsual mode is ended.
*/ */
void void
clip_update_selection() clip_update_selection(clip)
VimClipboard *clip;
{ {
pos_T start, end; pos_T start, end;
/* If visual mode is only due to a redo command ("."), then ignore it */ /* If visual mode is only due to a redo command ("."), then ignore it */
if (!redo_VIsual_busy && VIsual_active && (State & NORMAL)) if (!redo_VIsual_busy && VIsual_active && (State & NORMAL))
@@ -444,17 +447,17 @@ clip_update_selection()
start = curwin->w_cursor; start = curwin->w_cursor;
end = VIsual; end = VIsual;
} }
if (!equalpos(clip_star.start, start) if (!equalpos(clip->start, start)
|| !equalpos(clip_star.end, end) || !equalpos(clip->end, end)
|| clip_star.vmode != VIsual_mode) || clip->vmode != VIsual_mode)
{ {
clip_clear_selection(); clip_clear_selection(clip);
clip_star.start = start; clip->start = start;
clip_star.end = end; clip->end = end;
clip_star.vmode = VIsual_mode; clip->vmode = VIsual_mode;
clip_free_selection(&clip_star); clip_free_selection(clip);
clip_own_selection(&clip_star); clip_own_selection(clip);
clip_gen_set_selection(&clip_star); clip_gen_set_selection(clip);
} }
} }
} }
@@ -475,7 +478,7 @@ clip_own_selection(cbd)
int was_owned = cbd->owned; int was_owned = cbd->owned;
cbd->owned = (clip_gen_own_selection(cbd) == OK); cbd->owned = (clip_gen_own_selection(cbd) == OK);
if (!was_owned && cbd == &clip_star) if (!was_owned && (cbd == &clip_star || cbd == &clip_plus))
{ {
/* May have to show a different kind of highlighting for the /* May have to show a different kind of highlighting for the
* selected area. There is no specific redraw command for this, * selected area. There is no specific redraw command for this,
@@ -483,7 +486,8 @@ clip_own_selection(cbd)
if (cbd->owned if (cbd->owned
&& (get_real_state() == VISUAL && (get_real_state() == VISUAL
|| get_real_state() == SELECTMODE) || get_real_state() == SELECTMODE)
&& clip_isautosel() && (cbd == &clip_star ? clip_isautosel_star()
: clip_isautosel_plus())
&& hl_attr(HLF_V) != hl_attr(HLF_VNC)) && hl_attr(HLF_V) != hl_attr(HLF_VNC))
redraw_curbuf_later(INVERTED_ALL); redraw_curbuf_later(INVERTED_ALL);
} }
@@ -502,12 +506,15 @@ clip_lose_selection(cbd)
#ifdef FEAT_X11 #ifdef FEAT_X11
int was_owned = cbd->owned; int was_owned = cbd->owned;
#endif #endif
int visual_selection = (cbd == &clip_star); int visual_selection = FALSE;
if (cbd == &clip_star || cbd == &clip_plus)
visual_selection = TRUE;
clip_free_selection(cbd); clip_free_selection(cbd);
cbd->owned = FALSE; cbd->owned = FALSE;
if (visual_selection) if (visual_selection)
clip_clear_selection(); clip_clear_selection(cbd);
clip_gen_lose_selection(cbd); clip_gen_lose_selection(cbd);
#ifdef FEAT_X11 #ifdef FEAT_X11
if (visual_selection) if (visual_selection)
@@ -518,7 +525,8 @@ clip_lose_selection(cbd)
if (was_owned if (was_owned
&& (get_real_state() == VISUAL && (get_real_state() == VISUAL
|| get_real_state() == SELECTMODE) || get_real_state() == SELECTMODE)
&& clip_isautosel() && (cbd == &clip_star ?
clip_isautosel_star() : clip_isautosel_plus())
&& hl_attr(HLF_V) != hl_attr(HLF_VNC)) && hl_attr(HLF_V) != hl_attr(HLF_VNC))
{ {
update_curbuf(INVERTED_ALL); update_curbuf(INVERTED_ALL);
@@ -534,18 +542,18 @@ clip_lose_selection(cbd)
#endif #endif
} }
void static void
clip_copy_selection() clip_copy_selection(clip)
VimClipboard *clip;
{ {
if (VIsual_active && (State & NORMAL) && clip_star.available) if (VIsual_active && (State & NORMAL) && clip->available)
{ {
if (clip_isautosel()) clip_update_selection(clip);
clip_update_selection(); clip_free_selection(clip);
clip_free_selection(&clip_star); clip_own_selection(clip);
clip_own_selection(&clip_star); if (clip->owned)
if (clip_star.owned) clip_get_selection(clip);
clip_get_selection(&clip_star); clip_gen_set_selection(clip);
clip_gen_set_selection(&clip_star);
} }
} }
@@ -555,21 +563,38 @@ clip_copy_selection()
void void
clip_auto_select() clip_auto_select()
{ {
if (clip_isautosel()) if (clip_isautosel_star())
clip_copy_selection(); clip_copy_selection(&clip_star);
if (clip_isautosel_plus())
clip_copy_selection(&clip_plus);
} }
/* /*
* Return TRUE if automatic selection of Visual area is desired. * Return TRUE if automatic selection of Visual area is desired for the *
* register.
*/ */
int int
clip_isautosel() clip_isautosel_star()
{ {
return ( return (
#ifdef FEAT_GUI #ifdef FEAT_GUI
gui.in_use ? (vim_strchr(p_go, GO_ASEL) != NULL) : gui.in_use ? (vim_strchr(p_go, GO_ASEL) != NULL) :
#endif #endif
clip_autoselect); clip_autoselect_star);
}
/*
* Return TRUE if automatic selection of Visual area is desired for the +
* register.
*/
int
clip_isautosel_plus()
{
return (
#ifdef FEAT_GUI
gui.in_use ? (vim_strchr(p_go, GO_ASELPLUS) != NULL) :
#endif
clip_autoselect_plus);
} }
@@ -657,7 +682,7 @@ clip_start_selection(col, row, repeated_click)
VimClipboard *cb = &clip_star; VimClipboard *cb = &clip_star;
if (cb->state == SELECT_DONE) if (cb->state == SELECT_DONE)
clip_clear_selection(); clip_clear_selection(cb);
row = check_row(row); row = check_row(row);
col = check_col(col); col = check_col(col);
@@ -749,7 +774,7 @@ clip_process_selection(button, col, row, repeated_click)
printf("Selection ended: (%u,%u) to (%u,%u)\n", cb->start.lnum, printf("Selection ended: (%u,%u) to (%u,%u)\n", cb->start.lnum,
cb->start.col, cb->end.lnum, cb->end.col); cb->start.col, cb->end.lnum, cb->end.col);
#endif #endif
if (clip_isautosel() if (clip_isautosel_star()
|| ( || (
#ifdef FEAT_GUI #ifdef FEAT_GUI
gui.in_use ? (vim_strchr(p_go, GO_ASELML) != NULL) : gui.in_use ? (vim_strchr(p_go, GO_ASELML) != NULL) :
@@ -932,16 +957,16 @@ clip_may_redraw_selection(row, col, len)
* Called from outside to clear selected region from the display * Called from outside to clear selected region from the display
*/ */
void void
clip_clear_selection() clip_clear_selection(cbd)
VimClipboard *cbd;
{ {
VimClipboard *cb = &clip_star;
if (cb->state == SELECT_CLEARED) if (cbd->state == SELECT_CLEARED)
return; return;
clip_invert_area((int)cb->start.lnum, cb->start.col, (int)cb->end.lnum, clip_invert_area((int)cbd->start.lnum, cbd->start.col, (int)cbd->end.lnum,
cb->end.col, CLIP_CLEAR); cbd->end.col, CLIP_CLEAR);
cb->state = SELECT_CLEARED; cbd->state = SELECT_CLEARED;
} }
/* /*
@@ -954,7 +979,7 @@ clip_may_clear_selection(row1, row2)
if (clip_star.state == SELECT_DONE if (clip_star.state == SELECT_DONE
&& row2 >= clip_star.start.lnum && row2 >= clip_star.start.lnum
&& row1 <= clip_star.end.lnum) && row1 <= clip_star.end.lnum)
clip_clear_selection(); clip_clear_selection(&clip_star);
} }
/* /*

View File

@@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
597,
/**/ /**/
596, 596,
/**/ /**/