From 24fe4758941a5a59669f135e45ea7ec69d16fe9f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 5 Mar 2018 10:54:53 +0100 Subject: [PATCH 1/6] patch 8.0.1568: can't build on older Mac, header file is missing Problem: Can't build on older Mac, header file is missing. Solution: Remove the header file. (Ozaki Kiichi, closes #2691) --- src/os_unix.c | 1 - src/version.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/os_unix.c b/src/os_unix.c index 45fd261764..9819176b57 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -566,7 +566,6 @@ mch_check_messages(void) # ifdef MACOS_X_DARWIN # include # include -# include # endif /* diff --git a/src/version.c b/src/version.c index cbd28eedcd..96ac824ee4 100644 --- a/src/version.c +++ b/src/version.c @@ -766,6 +766,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1568, /**/ 1567, /**/ From 28ada699c13833219acaeb7e768acc2acae50e02 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 5 Mar 2018 12:42:42 +0100 Subject: [PATCH 2/6] patch 8.0.1569: warning for uninitialized variable from gcc Problem: Warning for uninitialized variable from gcc. Solution: Initialize the variable. --- src/quickfix.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/quickfix.c b/src/quickfix.c index 23cb92696e..7ee386dbbc 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -4099,7 +4099,7 @@ ex_cfile(exarg_T *eap) win_T *wp = NULL; qf_info_T *qi = &ql_info; char_u *au_name = NULL; - int save_qfid; + int save_qfid = 0; // init for gcc int res; switch (eap->cmdidx) diff --git a/src/version.c b/src/version.c index 96ac824ee4..2b64f36924 100644 --- a/src/version.c +++ b/src/version.c @@ -766,6 +766,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1569, /**/ 1568, /**/ From 29a2c08d792e4458a0af8371f5341394829fce29 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 5 Mar 2018 21:06:23 +0100 Subject: [PATCH 3/6] patch 8.0.1570: can't use :popup for a menu in the terminal Problem: Can't use :popup for a menu in the terminal. (Wei Zhang) Solution: Make :popup work in the terminal. Also fix that entries were included that don't work in the current state. --- src/ex_docmd.c | 17 ++++++++++++++--- src/menu.c | 18 +++++++++++------- src/popupmnu.c | 26 ++++++++++++++++++++++++-- src/proto/menu.pro | 1 + src/proto/popupmnu.pro | 1 + src/version.c | 2 ++ 6 files changed, 53 insertions(+), 12 deletions(-) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 0a51d8eb7d..f913fb5278 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -204,7 +204,8 @@ static void ex_tearoff(exarg_T *eap); #else # define ex_tearoff ex_ni #endif -#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) +#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ + || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) static void ex_popup(exarg_T *eap); #else # define ex_popup ex_ni @@ -8741,11 +8742,21 @@ ex_tearoff(exarg_T *eap) } #endif -#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) +#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ + || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) static void ex_popup(exarg_T *eap) { - gui_make_popup(eap->arg, eap->forceit); +# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) + if (gui.in_use) + gui_make_popup(eap->arg, eap->forceit); +# ifdef FEAT_TERM_POPUP_MENU + else +# endif +# endif +# ifdef FEAT_TERM_POPUP_MENU + pum_make_popup(eap->arg, eap->forceit); +# endif } #endif diff --git a/src/menu.c b/src/menu.c index 107cabce6c..c04cd49bbd 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1891,6 +1891,16 @@ get_menu_mode(void) return MENU_INDEX_INVALID; } + int +get_menu_mode_flag(void) +{ + int mode = get_menu_mode(); + + if (mode == MENU_INDEX_INVALID) + return 0; + return 1 << mode; +} + /* * Display the Special "PopUp" menu as a pop-up at the current mouse * position. The "PopUpn" menu is for Normal mode, "PopUpi" for Insert mode, @@ -2044,13 +2054,7 @@ gui_update_menus(int modes) if (modes != 0x0) mode = modes; else - { - mode = get_menu_mode(); - if (mode == MENU_INDEX_INVALID) - mode = 0; - else - mode = (1 << mode); - } + mode = get_menu_mode_flag(); if (force_menu_update || mode != prev_mode) { diff --git a/src/popupmnu.c b/src/popupmnu.c index 6cfd95a4e9..9b5f750f88 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -1132,12 +1132,16 @@ pum_show_popupmenu(vimmenu_T *menu) #ifdef FEAT_BEVAL_TERM int save_bevalterm = p_bevalterm; #endif + int mode; pum_undisplay(); pum_size = 0; + mode = get_menu_mode_flag(); for (mp = menu->children; mp != NULL; mp = mp->next) - ++pum_size; + if (menu_is_separator(mp->dname) + || (mp->modes & mp->enabled & mode)) + ++pum_size; array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size); if (array == NULL) @@ -1146,7 +1150,7 @@ pum_show_popupmenu(vimmenu_T *menu) for (mp = menu->children; mp != NULL; mp = mp->next) if (menu_is_separator(mp->dname)) array[idx++].pum_text = (char_u *)""; - else + else if (mp->modes & mp->enabled & mode) array[idx++].pum_text = mp->dname; pum_array = array; @@ -1231,6 +1235,24 @@ pum_show_popupmenu(vimmenu_T *menu) p_bevalterm = save_bevalterm; mch_setmouse(TRUE); # endif +} + + void +pum_make_popup(char_u *path_name, int use_mouse_pos) +{ + vimmenu_T *menu; + + if (!use_mouse_pos) + { + /* Hack: set mouse position at the cursor so that the menu pops up + * around there. */ + mouse_row = curwin->w_winrow + curwin->w_wrow; + mouse_col = curwin->w_wincol + curwin->w_wcol; + } + + menu = gui_find_menu(path_name); + if (menu != NULL) + pum_show_popupmenu(menu); } # endif diff --git a/src/proto/menu.pro b/src/proto/menu.pro index 4c8e710d8f..63f8d11bdd 100644 --- a/src/proto/menu.pro +++ b/src/proto/menu.pro @@ -12,6 +12,7 @@ int menu_is_popup(char_u *name); int menu_is_child_of_popup(vimmenu_T *menu); int menu_is_toolbar(char_u *name); int menu_is_separator(char_u *name); +int get_menu_mode_flag(void); void show_popupmenu(void); int check_menu_pointer(vimmenu_T *root, vimmenu_T *menu_to_check); void gui_create_initial_menus(vimmenu_T *menu); diff --git a/src/proto/popupmnu.pro b/src/proto/popupmnu.pro index d2f6baf46b..8fd4ac90f9 100644 --- a/src/proto/popupmnu.pro +++ b/src/proto/popupmnu.pro @@ -10,4 +10,5 @@ void ui_remove_balloon(void); void ui_post_balloon(char_u *mesg, list_T *list); void ui_may_remove_balloon(void); void pum_show_popupmenu(vimmenu_T *menu); +void pum_make_popup(char_u *path_name, int mouse_pos); /* vim: set ft=c : */ diff --git a/src/version.c b/src/version.c index 2b64f36924..6f498aa971 100644 --- a/src/version.c +++ b/src/version.c @@ -766,6 +766,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1570, /**/ 1569, /**/ From 40d77b0ec14a4999d8f0d52643a0ad289bf88dfa Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 5 Mar 2018 21:32:27 +0100 Subject: [PATCH 4/6] patch 8.0.1571: can't build without GUI Problem: Can't build without GUI. Solution: Adjust #ifdef for gui_find_menu(). --- src/menu.c | 1 + src/version.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/menu.c b/src/menu.c index c04cd49bbd..58429dc8aa 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2462,6 +2462,7 @@ winbar_click(win_T *wp, int col) } #if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ + || defined(FEAT_TERM_POPUP_MENU) \ || defined(FEAT_BEVAL_TIP) || defined(PROTO) /* * Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy. diff --git a/src/version.c b/src/version.c index 6f498aa971..2f045e4fd3 100644 --- a/src/version.c +++ b/src/version.c @@ -766,6 +766,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1571, /**/ 1570, /**/ From 362dc33835e3ec5d41b7f29d8877da0a9e74c15c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 5 Mar 2018 21:59:37 +0100 Subject: [PATCH 5/6] patch 8.0.1572: Mac: getting memory size doesn't work everywhere Problem: Mac: getting memory size doesn't work everywhere. Solution: Use MACOS_X instead of MACOS_X_DARWIN. (Kazunobu Kuriyama) --- src/os_unix.c | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/os_unix.c b/src/os_unix.c index 9819176b57..c28bda0aad 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -563,7 +563,7 @@ mch_check_messages(void) # if defined(HAVE_SYS_SYSINFO_H) && defined(HAVE_SYSINFO) # include # endif -# ifdef MACOS_X_DARWIN +# ifdef MACOS_X # include # include # endif @@ -578,7 +578,7 @@ mch_total_mem(int special UNUSED) long_u mem = 0; long_u shiftright = 10; /* how much to shift "mem" right for Kbyte */ -# ifdef MACOS_X_DARWIN +# ifdef MACOS_X { /* Mac (Darwin) way of getting the amount of RAM available */ mach_port_t host = mach_host_self(); diff --git a/src/version.c b/src/version.c index 2f045e4fd3..f1a3b950c1 100644 --- a/src/version.c +++ b/src/version.c @@ -766,6 +766,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1572, /**/ 1571, /**/ From 89894aa671ed1db03d95d38cab300702c242239d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 5 Mar 2018 22:43:10 +0100 Subject: [PATCH 6/6] patch 8.0.1573: getwinpos(1) may cause response to be handled as command Problem: getwinpos(1) may cause response to be handled as command. Solution: Handle any cursor position report once one was request. (partly by Hirohito Higashi) --- src/term.c | 44 +++++++++++++++++++++++++++++++++----------- src/version.c | 2 ++ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/term.c b/src/term.c index b063d9189c..5e7aeecae6 100644 --- a/src/term.c +++ b/src/term.c @@ -143,6 +143,9 @@ static int rbm_status = STATUS_GET; /* Request cursor style report: */ static int rcs_status = STATUS_GET; + +/* Request windos position report: */ +static int winpos_status = STATUS_GET; # endif /* @@ -2778,9 +2781,9 @@ can_get_termresponse() && p_ek; } -static int winpos_x; -static int winpos_y; -static int waiting_for_winpos = FALSE; +static int winpos_x = -1; +static int winpos_y = -1; +static int did_request_winpos = 0; /* * Try getting the Vim window position from the terminal. @@ -2790,29 +2793,43 @@ static int waiting_for_winpos = FALSE; term_get_winpos(int *x, int *y, varnumber_T timeout) { int count = 0; + int prev_winpos_x = winpos_x; + int prev_winpos_y = winpos_y; if (*T_CGP == NUL || !can_get_termresponse()) return FAIL; winpos_x = -1; winpos_y = -1; - waiting_for_winpos = TRUE; + ++did_request_winpos; + winpos_status = STATUS_SENT; OUT_STR(T_CGP); out_flush(); /* Try reading the result for "timeout" msec. */ - while (count++ < timeout / 10) + while (count++ <= timeout / 10 && !got_int) { (void)vpeekc_nomap(); if (winpos_x >= 0 && winpos_y >= 0) { *x = winpos_x; *y = winpos_y; - waiting_for_winpos = FALSE; return OK; } ui_delay(10, FALSE); } - waiting_for_winpos = FALSE; + /* Do not reset "did_request_winpos", if we timed out the response might + * still come later and we must consume it. */ + + winpos_x = prev_winpos_x; + winpos_y = prev_winpos_y; + if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_y >= 0) + { + /* Polling: return previous values if we have them. */ + *x = winpos_x; + *y = winpos_y; + return OK; + } + return FALSE; } # endif @@ -3365,7 +3382,8 @@ settmode(int tmode) #endif || rbg_status == STATUS_SENT || rbm_status == STATUS_SENT - || rcs_status == STATUS_SENT)) + || rcs_status == STATUS_SENT + || winpos_status == STATUS_SENT)) (void)vpeekc_nomap(); check_for_codes_from_term(); } @@ -3439,7 +3457,8 @@ stoptermcap(void) # endif || rbg_status == STATUS_SENT || rbm_status == STATUS_SENT - || rcs_status == STATUS_SENT) + || rcs_status == STATUS_SENT + || winpos_status == STATUS_SENT) { # ifdef UNIX /* Give the terminal a chance to respond. */ @@ -4468,7 +4487,7 @@ check_termcode( */ char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; - if ((*T_CRV != NUL || *T_U7 != NUL || waiting_for_winpos) + if ((*T_CRV != NUL || *T_U7 != NUL || did_request_winpos) && ((tp[0] == ESC && len >= 3 && tp[1] == '[') || (tp[0] == CSI && len >= 2)) && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?')) @@ -4730,7 +4749,7 @@ check_termcode( * Check for a window position response from the terminal: * {lead}3;{x}:{y}t */ - else if (waiting_for_winpos + else if (did_request_winpos && ((len >= 4 && tp[0] == ESC && tp[1] == '[') || (len >= 3 && tp[0] == CSI)) && tp[(j = 1 + (tp[0] == ESC))] == '3' @@ -4752,6 +4771,9 @@ check_termcode( key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; slen = i + 1; + + if (--did_request_winpos <= 0) + winpos_status = STATUS_GOT; } } if (i == len) diff --git a/src/version.c b/src/version.c index f1a3b950c1..8fd5ea7388 100644 --- a/src/version.c +++ b/src/version.c @@ -766,6 +766,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1573, /**/ 1572, /**/