Skip to content

Commit 0248eca

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents b1949f8 + 89894aa commit 0248eca

9 files changed

Lines changed: 104 additions & 27 deletions

File tree

src/ex_docmd.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ static void ex_tearoff(exarg_T *eap);
204204
#else
205205
# define ex_tearoff ex_ni
206206
#endif
207-
#if defined(FEAT_MENU) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \
208-
|| defined(FEAT_GUI_MACVIM))
207+
#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \
208+
|| defined(FEAT_GUI_MACVIM) \
209+
|| defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU)
209210
static void ex_popup(exarg_T *eap);
210211
#else
211212
# define ex_popup ex_ni
@@ -8759,12 +8760,26 @@ ex_tearoff(exarg_T *eap)
87598760
}
87608761
#endif
87618762

8763+
<<<<<<< HEAD
87628764
#if defined(FEAT_MENU) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \
87638765
|| defined(FEAT_GUI_MACVIM))
8766+
=======
8767+
#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \
8768+
|| defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU)
8769+
>>>>>>> vim/master
87648770
static void
87658771
ex_popup(exarg_T *eap)
87668772
{
8767-
gui_make_popup(eap->arg, eap->forceit);
8773+
# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)
8774+
if (gui.in_use)
8775+
gui_make_popup(eap->arg, eap->forceit);
8776+
# ifdef FEAT_TERM_POPUP_MENU
8777+
else
8778+
# endif
8779+
# endif
8780+
# ifdef FEAT_TERM_POPUP_MENU
8781+
pum_make_popup(eap->arg, eap->forceit);
8782+
# endif
87688783
}
87698784
#endif
87708785

src/menu.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,16 @@ get_menu_mode(void)
18971897
return MENU_INDEX_INVALID;
18981898
}
18991899

1900+
int
1901+
get_menu_mode_flag(void)
1902+
{
1903+
int mode = get_menu_mode();
1904+
1905+
if (mode == MENU_INDEX_INVALID)
1906+
return 0;
1907+
return 1 << mode;
1908+
}
1909+
19001910
/*
19011911
* Display the Special "PopUp" menu as a pop-up at the current mouse
19021912
* position. The "PopUpn" menu is for Normal mode, "PopUpi" for Insert mode,
@@ -2050,13 +2060,7 @@ gui_update_menus(int modes)
20502060
if (modes != 0x0)
20512061
mode = modes;
20522062
else
2053-
{
2054-
mode = get_menu_mode();
2055-
if (mode == MENU_INDEX_INVALID)
2056-
mode = 0;
2057-
else
2058-
mode = (1 << mode);
2059-
}
2063+
mode = get_menu_mode_flag();
20602064

20612065
if (force_menu_update || mode != prev_mode)
20622066
{
@@ -2485,6 +2489,7 @@ winbar_click(win_T *wp, int col)
24852489
}
24862490

24872491
#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \
2492+
|| defined(FEAT_TERM_POPUP_MENU) \
24882493
|| defined(FEAT_GUI_MACVIM) \
24892494
|| defined(FEAT_BEVAL_TIP) || defined(PROTO)
24902495
/*

src/os_unix.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,9 @@ mch_check_messages(void)
563563
# if defined(HAVE_SYS_SYSINFO_H) && defined(HAVE_SYSINFO)
564564
# include <sys/sysinfo.h>
565565
# endif
566-
# ifdef MACOS_X_DARWIN
566+
# ifdef MACOS_X
567567
# include <mach/mach_host.h>
568568
# include <mach/mach_port.h>
569-
# include <mach/vm_page_size.h>
570569
# endif
571570

572571
/*
@@ -579,7 +578,7 @@ mch_total_mem(int special UNUSED)
579578
long_u mem = 0;
580579
long_u shiftright = 10; /* how much to shift "mem" right for Kbyte */
581580

582-
# ifdef MACOS_X_DARWIN
581+
# ifdef MACOS_X
583582
{
584583
/* Mac (Darwin) way of getting the amount of RAM available */
585584
mach_port_t host = mach_host_self();

src/popupmnu.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,12 +1132,16 @@ pum_show_popupmenu(vimmenu_T *menu)
11321132
#ifdef FEAT_BEVAL_TERM
11331133
int save_bevalterm = p_bevalterm;
11341134
#endif
1135+
int mode;
11351136

11361137
pum_undisplay();
11371138
pum_size = 0;
1139+
mode = get_menu_mode_flag();
11381140

11391141
for (mp = menu->children; mp != NULL; mp = mp->next)
1140-
++pum_size;
1142+
if (menu_is_separator(mp->dname)
1143+
|| (mp->modes & mp->enabled & mode))
1144+
++pum_size;
11411145

11421146
array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size);
11431147
if (array == NULL)
@@ -1146,7 +1150,7 @@ pum_show_popupmenu(vimmenu_T *menu)
11461150
for (mp = menu->children; mp != NULL; mp = mp->next)
11471151
if (menu_is_separator(mp->dname))
11481152
array[idx++].pum_text = (char_u *)"";
1149-
else
1153+
else if (mp->modes & mp->enabled & mode)
11501154
array[idx++].pum_text = mp->dname;
11511155

11521156
pum_array = array;
@@ -1231,6 +1235,24 @@ pum_show_popupmenu(vimmenu_T *menu)
12311235
p_bevalterm = save_bevalterm;
12321236
mch_setmouse(TRUE);
12331237
# endif
1238+
}
1239+
1240+
void
1241+
pum_make_popup(char_u *path_name, int use_mouse_pos)
1242+
{
1243+
vimmenu_T *menu;
1244+
1245+
if (!use_mouse_pos)
1246+
{
1247+
/* Hack: set mouse position at the cursor so that the menu pops up
1248+
* around there. */
1249+
mouse_row = curwin->w_winrow + curwin->w_wrow;
1250+
mouse_col = curwin->w_wincol + curwin->w_wcol;
1251+
}
1252+
1253+
menu = gui_find_menu(path_name);
1254+
if (menu != NULL)
1255+
pum_show_popupmenu(menu);
12341256
}
12351257
# endif
12361258

src/proto/menu.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ int menu_is_popup(char_u *name);
1212
int menu_is_child_of_popup(vimmenu_T *menu);
1313
int menu_is_toolbar(char_u *name);
1414
int menu_is_separator(char_u *name);
15+
int get_menu_mode_flag(void);
1516
void show_popupmenu(void);
1617
int check_menu_pointer(vimmenu_T *root, vimmenu_T *menu_to_check);
1718
void gui_create_initial_menus(vimmenu_T *menu);

src/proto/popupmnu.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ void ui_remove_balloon(void);
1010
void ui_post_balloon(char_u *mesg, list_T *list);
1111
void ui_may_remove_balloon(void);
1212
void pum_show_popupmenu(vimmenu_T *menu);
13+
void pum_make_popup(char_u *path_name, int mouse_pos);
1314
/* vim: set ft=c : */

src/quickfix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4099,7 +4099,7 @@ ex_cfile(exarg_T *eap)
40994099
win_T *wp = NULL;
41004100
qf_info_T *qi = &ql_info;
41014101
char_u *au_name = NULL;
4102-
int save_qfid;
4102+
int save_qfid = 0; // init for gcc
41034103
int res;
41044104

41054105
switch (eap->cmdidx)

src/term.c

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ static int rbm_status = STATUS_GET;
143143

144144
/* Request cursor style report: */
145145
static int rcs_status = STATUS_GET;
146+
147+
/* Request windos position report: */
148+
static int winpos_status = STATUS_GET;
146149
# endif
147150

148151
/*
@@ -2784,9 +2787,9 @@ can_get_termresponse()
27842787
&& p_ek;
27852788
}
27862789

2787-
static int winpos_x;
2788-
static int winpos_y;
2789-
static int waiting_for_winpos = FALSE;
2790+
static int winpos_x = -1;
2791+
static int winpos_y = -1;
2792+
static int did_request_winpos = 0;
27902793

27912794
/*
27922795
* Try getting the Vim window position from the terminal.
@@ -2796,29 +2799,43 @@ static int waiting_for_winpos = FALSE;
27962799
term_get_winpos(int *x, int *y, varnumber_T timeout)
27972800
{
27982801
int count = 0;
2802+
int prev_winpos_x = winpos_x;
2803+
int prev_winpos_y = winpos_y;
27992804

28002805
if (*T_CGP == NUL || !can_get_termresponse())
28012806
return FAIL;
28022807
winpos_x = -1;
28032808
winpos_y = -1;
2804-
waiting_for_winpos = TRUE;
2809+
++did_request_winpos;
2810+
winpos_status = STATUS_SENT;
28052811
OUT_STR(T_CGP);
28062812
out_flush();
28072813

28082814
/* Try reading the result for "timeout" msec. */
2809-
while (count++ < timeout / 10)
2815+
while (count++ <= timeout / 10 && !got_int)
28102816
{
28112817
(void)vpeekc_nomap();
28122818
if (winpos_x >= 0 && winpos_y >= 0)
28132819
{
28142820
*x = winpos_x;
28152821
*y = winpos_y;
2816-
waiting_for_winpos = FALSE;
28172822
return OK;
28182823
}
28192824
ui_delay(10, FALSE);
28202825
}
2821-
waiting_for_winpos = FALSE;
2826+
/* Do not reset "did_request_winpos", if we timed out the response might
2827+
* still come later and we must consume it. */
2828+
2829+
winpos_x = prev_winpos_x;
2830+
winpos_y = prev_winpos_y;
2831+
if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_y >= 0)
2832+
{
2833+
/* Polling: return previous values if we have them. */
2834+
*x = winpos_x;
2835+
*y = winpos_y;
2836+
return OK;
2837+
}
2838+
28222839
return FALSE;
28232840
}
28242841
# endif
@@ -3371,7 +3388,8 @@ settmode(int tmode)
33713388
#endif
33723389
|| rbg_status == STATUS_SENT
33733390
|| rbm_status == STATUS_SENT
3374-
|| rcs_status == STATUS_SENT))
3391+
|| rcs_status == STATUS_SENT
3392+
|| winpos_status == STATUS_SENT))
33753393
(void)vpeekc_nomap();
33763394
check_for_codes_from_term();
33773395
}
@@ -3445,7 +3463,8 @@ stoptermcap(void)
34453463
# endif
34463464
|| rbg_status == STATUS_SENT
34473465
|| rbm_status == STATUS_SENT
3448-
|| rcs_status == STATUS_SENT)
3466+
|| rcs_status == STATUS_SENT
3467+
|| winpos_status == STATUS_SENT)
34493468
{
34503469
# ifdef UNIX
34513470
/* Give the terminal a chance to respond. */
@@ -4474,7 +4493,7 @@ check_termcode(
44744493
*/
44754494
char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1;
44764495

4477-
if ((*T_CRV != NUL || *T_U7 != NUL || waiting_for_winpos)
4496+
if ((*T_CRV != NUL || *T_U7 != NUL || did_request_winpos)
44784497
&& ((tp[0] == ESC && len >= 3 && tp[1] == '[')
44794498
|| (tp[0] == CSI && len >= 2))
44804499
&& (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?'))
@@ -4736,7 +4755,7 @@ check_termcode(
47364755
* Check for a window position response from the terminal:
47374756
* {lead}3;{x}:{y}t
47384757
*/
4739-
else if (waiting_for_winpos
4758+
else if (did_request_winpos
47404759
&& ((len >= 4 && tp[0] == ESC && tp[1] == '[')
47414760
|| (len >= 3 && tp[0] == CSI))
47424761
&& tp[(j = 1 + (tp[0] == ESC))] == '3'
@@ -4758,6 +4777,9 @@ check_termcode(
47584777
key_name[0] = (int)KS_EXTRA;
47594778
key_name[1] = (int)KE_IGNORE;
47604779
slen = i + 1;
4780+
4781+
if (--did_request_winpos <= 0)
4782+
winpos_status = STATUS_GOT;
47614783
}
47624784
}
47634785
if (i == len)

src/version.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,18 @@ static char *(features[]) =
781781

782782
static int included_patches[] =
783783
{ /* Add new patch number below this line */
784+
/**/
785+
1573,
786+
/**/
787+
1572,
788+
/**/
789+
1571,
790+
/**/
791+
1570,
792+
/**/
793+
1569,
794+
/**/
795+
1568,
784796
/**/
785797
1567,
786798
/**/

0 commit comments

Comments
 (0)