Skip to content

Commit 381aa9a

Browse files
committed
Merge remote-tracking branch 'vim/master'
1 parent 2cefa1e commit 381aa9a

29 files changed

+522
-270
lines changed

src/Makefile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,9 +2105,9 @@ run_memfile_test: $(MEMFILE_TEST_TARGET)
21052105
run_message_test: $(MESSAGE_TEST_TARGET)
21062106
$(VALGRIND) ./$(MESSAGE_TEST_TARGET) || exit 1; echo $* passed;
21072107

2108-
# Run individual OLD style test, assuming that Vim was already compiled.
2108+
# Run individual OLD style test.
2109+
# These do not depend on the executable, compile it when needed.
21092110
test1 \
2110-
test_autoformat_join \
21112111
test_changelist \
21122112
test_close_count \
21132113
test_erasebackword \
@@ -2117,20 +2117,19 @@ test1 \
21172117
test_listchars \
21182118
test_search_mbyte \
21192119
test_wordcount \
2120-
test3 test8 \
2121-
test11 test12 test14 test15 test17 test19 \
2120+
test3 test11 test12 test14 test15 test17 test19 \
21222121
test20 test25 test28 test29 \
2123-
test30 test32 test34 test36 test37 test38 test39 \
2122+
test30 test32 test36 test37 test38 test39 \
21242123
test40 test42 test44 test45 test48 test49 \
2125-
test50 test52 test54 test55 test59 \
2124+
test50 test52 test55 test59 \
21262125
test64 test66 test68 test69 \
21272126
test70 test72 test73 test77 test79 \
21282127
test83 test85 test86 test87 test88 \
2129-
test94 test95 test99 \
2130-
test108:
2128+
test94 test95 test99 test108:
21312129
cd testdir; rm -f [email protected]; $(MAKE) -f Makefile [email protected] VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
21322130

2133-
# Run individual NEW style test, assuming that Vim was already compiled.
2131+
# Run individual NEW style test.
2132+
# These do not depend on the executable, compile it when needed.
21342133
test_arglist \
21352134
test_arabic \
21362135
test_assert \

src/buffer.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,6 +3893,8 @@ build_stl_str_hl(
38933893
int width;
38943894
int itemcnt;
38953895
int curitem;
3896+
int group_end_userhl;
3897+
int group_start_userhl;
38963898
int groupitem[STL_MAX_ITEM];
38973899
int groupdepth;
38983900
struct stl_item
@@ -4033,11 +4035,20 @@ build_stl_str_hl(
40334035
if (curitem > groupitem[groupdepth] + 1
40344036
&& item[groupitem[groupdepth]].minwid == 0)
40354037
{
4036-
/* remove group if all items are empty */
4038+
/* remove group if all items are empty and highlight group
4039+
* doesn't change */
4040+
group_start_userhl = group_end_userhl = 0;
4041+
for (n = 0; n < groupitem[groupdepth]; n++)
4042+
if (item[n].type == Highlight)
4043+
group_start_userhl = item[n].minwid;
40374044
for (n = groupitem[groupdepth] + 1; n < curitem; n++)
4038-
if (item[n].type == Normal || item[n].type == Highlight)
4045+
{
4046+
if (item[n].type == Normal)
40394047
break;
4040-
if (n == curitem)
4048+
if (item[n].type == Highlight)
4049+
group_end_userhl = item[n].minwid;
4050+
}
4051+
if (n == curitem && group_start_userhl == group_end_userhl)
40414052
{
40424053
p = t;
40434054
l = 0;

src/ex_getln.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ trigger_cmd_autocmd(int typechar, int evt)
158158
}
159159
#endif
160160

161+
/*
162+
* Abandon the command line.
163+
*/
164+
static void
165+
abandon_cmdline(void)
166+
{
167+
vim_free(ccline.cmdbuff);
168+
ccline.cmdbuff = NULL;
169+
if (msg_scrolled == 0)
170+
compute_cmdrow();
171+
MSG("");
172+
redraw_cmdline = TRUE;
173+
}
174+
161175
/*
162176
* getcmdline() - accept a command line starting with firstc.
163177
*
@@ -1710,11 +1724,8 @@ getcmdline(
17101724
if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
17111725
{
17121726
pos_T t;
1713-
int search_flags = SEARCH_KEEP + SEARCH_NOOF
1714-
+ SEARCH_PEEK;
1727+
int search_flags = SEARCH_KEEP + SEARCH_NOOF;
17151728

1716-
if (char_avail())
1717-
continue;
17181729
cursor_off();
17191730
out_flush();
17201731
if (c == Ctrl_G)
@@ -2091,15 +2102,8 @@ getcmdline(
20912102
}
20922103
#endif
20932104

2094-
if (gotesc) /* abandon command line */
2095-
{
2096-
vim_free(ccline.cmdbuff);
2097-
ccline.cmdbuff = NULL;
2098-
if (msg_scrolled == 0)
2099-
compute_cmdrow();
2100-
MSG("");
2101-
redraw_cmdline = TRUE;
2102-
}
2105+
if (gotesc)
2106+
abandon_cmdline();
21032107
}
21042108

21052109
/*

src/gui_gtk_x11.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3567,8 +3567,29 @@ on_select_tab(
35673567
gpointer data UNUSED)
35683568
{
35693569
if (!ignore_tabline_evt)
3570-
{
35713570
send_tabline_event(idx + 1);
3571+
}
3572+
3573+
/*
3574+
* Handle reordering the tabs (using D&D).
3575+
*/
3576+
static void
3577+
on_tab_reordered(
3578+
GtkNotebook *notebook UNUSED,
3579+
# if GTK_CHECK_VERSION(3,0,0)
3580+
gpointer *page UNUSED,
3581+
# else
3582+
GtkNotebookPage *page UNUSED,
3583+
# endif
3584+
gint idx,
3585+
gpointer data UNUSED)
3586+
{
3587+
if (!ignore_tabline_evt)
3588+
{
3589+
if ((tabpage_index(curtab) - 1) < idx)
3590+
tabpage_move(idx + 1);
3591+
else
3592+
tabpage_move(idx);
35723593
}
35733594
}
35743595

@@ -3658,6 +3679,9 @@ gui_mch_update_tabline(void)
36583679
page,
36593680
event_box,
36603681
nr++);
3682+
gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(gui.tabline),
3683+
page,
3684+
TRUE);
36613685
}
36623686

36633687
event_box = gtk_notebook_get_tab_label(GTK_NOTEBOOK(gui.tabline), page);
@@ -4093,14 +4117,19 @@ gui_mch_init(void)
40934117
# endif
40944118
gtk_container_add(GTK_CONTAINER(event_box), label);
40954119
gtk_notebook_set_tab_label(GTK_NOTEBOOK(gui.tabline), page, event_box);
4120+
gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(gui.tabline), page, TRUE);
40964121
}
40974122

40984123
# if GTK_CHECK_VERSION(3,0,0)
40994124
g_signal_connect(G_OBJECT(gui.tabline), "switch-page",
41004125
G_CALLBACK(on_select_tab), NULL);
4126+
g_signal_connect(G_OBJECT(gui.tabline), "page-reordered",
4127+
G_CALLBACK(on_tab_reordered), NULL);
41014128
# else
41024129
gtk_signal_connect(GTK_OBJECT(gui.tabline), "switch_page",
41034130
GTK_SIGNAL_FUNC(on_select_tab), NULL);
4131+
gtk_signal_connect(GTK_OBJECT(gui.tabline), "page-reordered",
4132+
GTK_SIGNAL_FUNC(on_tab_reordered), NULL);
41044133
# endif
41054134

41064135
/* Create a popup menu for the tab line and connect it. */

src/gui_w32.c

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7567,6 +7567,26 @@ nCopyAnsiToWideChar(
75677567

75687568

75697569
#ifdef FEAT_TEAROFF
7570+
/*
7571+
* Lookup menu handle from "menu_id".
7572+
*/
7573+
static HMENU
7574+
tearoff_lookup_menuhandle(
7575+
vimmenu_T *menu,
7576+
WORD menu_id)
7577+
{
7578+
for ( ; menu != NULL; menu = menu->next)
7579+
{
7580+
if (menu->modes == 0) /* this menu has just been deleted */
7581+
continue;
7582+
if (menu_is_separator(menu->dname))
7583+
continue;
7584+
if ((WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000) == menu_id)
7585+
return menu->submenu_id;
7586+
}
7587+
return NULL;
7588+
}
7589+
75707590
/*
75717591
* The callback function for all the modeless dialogs that make up the
75727592
* "tearoff menus" Very simple - forward button presses (to fool Vim into
@@ -7580,7 +7600,10 @@ tearoff_callback(
75807600
LPARAM lParam)
75817601
{
75827602
if (message == WM_INITDIALOG)
7603+
{
7604+
SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
75837605
return (TRUE);
7606+
}
75847607

75857608
/* May show the mouse pointer again. */
75867609
HandleMouseHide(message, lParam);
@@ -7594,8 +7617,11 @@ tearoff_callback(
75947617

75957618
if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
75967619
{
7620+
vimmenu_T *menu;
7621+
7622+
menu = (vimmenu_T*)GetWindowLongPtr(hwnd, DWLP_USER);
75977623
(void)TrackPopupMenu(
7598-
(HMENU)(long_u)(LOWORD(wParam) ^ 0x8000),
7624+
tearoff_lookup_menuhandle(menu, LOWORD(wParam)),
75997625
TPM_LEFTALIGN | TPM_LEFTBUTTON,
76007626
(int)rect.right - 8,
76017627
(int)mp.y,
@@ -7707,6 +7733,7 @@ gui_mch_tearoff(
77077733
WORD dlgwidth;
77087734
WORD menuID;
77097735
vimmenu_T *pmenu;
7736+
vimmenu_T *top_menu;
77107737
vimmenu_T *the_menu = menu;
77117738
HWND hwnd;
77127739
HDC hdc;
@@ -7885,6 +7912,7 @@ gui_mch_tearoff(
78857912
menu = menu->children->next;
78867913
else
78877914
menu = menu->children;
7915+
top_menu = menu;
78887916
for ( ; menu != NULL; menu = menu->next)
78897917
{
78907918
if (menu->modes == 0) /* this menu has just been deleted */
@@ -7995,11 +8023,12 @@ gui_mch_tearoff(
79958023

79968024

79978025
/* show modelessly */
7998-
the_menu->tearoff_handle = CreateDialogIndirect(
8026+
the_menu->tearoff_handle = CreateDialogIndirectParam(
79998027
s_hinst,
80008028
(LPDLGTEMPLATE)pdlgtemplate,
80018029
s_hwnd,
8002-
(DLGPROC)tearoff_callback);
8030+
(DLGPROC)tearoff_callback,
8031+
(LPARAM)top_menu);
80038032

80048033
LocalFree(LocalHandle(pdlgtemplate));
80058034
SelectFont(hdc, oldFont);
@@ -8151,14 +8180,108 @@ initialise_tabline(void)
81518180
# endif
81528181
}
81538182

8183+
/*
8184+
* Get tabpage_T from POINT.
8185+
*/
8186+
static tabpage_T *
8187+
GetTabFromPoint(
8188+
HWND hWnd,
8189+
POINT pt)
8190+
{
8191+
tabpage_T *ptp = NULL;
8192+
8193+
if (gui_mch_showing_tabline())
8194+
{
8195+
TCHITTESTINFO htinfo;
8196+
htinfo.pt = pt;
8197+
/* ignore if a window under cusor is not tabcontrol. */
8198+
if (s_tabhwnd == hWnd)
8199+
{
8200+
int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
8201+
if (idx != -1)
8202+
ptp = find_tabpage(idx + 1);
8203+
}
8204+
}
8205+
return ptp;
8206+
}
8207+
8208+
static POINT s_pt = {0, 0};
8209+
static HCURSOR s_hCursor = NULL;
8210+
81548211
static LRESULT CALLBACK
81558212
tabline_wndproc(
81568213
HWND hwnd,
81578214
UINT uMsg,
81588215
WPARAM wParam,
81598216
LPARAM lParam)
81608217
{
8218+
POINT pt;
8219+
tabpage_T *tp;
8220+
RECT rect;
8221+
int nCenter;
8222+
int idx0;
8223+
int idx1;
8224+
81618225
HandleMouseHide(uMsg, lParam);
8226+
8227+
switch (uMsg)
8228+
{
8229+
case WM_LBUTTONDOWN:
8230+
{
8231+
s_pt.x = GET_X_LPARAM(lParam);
8232+
s_pt.y = GET_Y_LPARAM(lParam);
8233+
SetCapture(hwnd);
8234+
s_hCursor = GetCursor(); /* backup default cursor */
8235+
break;
8236+
}
8237+
case WM_MOUSEMOVE:
8238+
if (GetCapture() == hwnd
8239+
&& ((wParam & MK_LBUTTON)) != 0)
8240+
{
8241+
pt.x = GET_X_LPARAM(lParam);
8242+
pt.y = s_pt.y;
8243+
if (abs(pt.x - s_pt.x) > GetSystemMetrics(SM_CXDRAG))
8244+
{
8245+
SetCursor(LoadCursor(NULL, IDC_SIZEWE));
8246+
8247+
tp = GetTabFromPoint(hwnd, pt);
8248+
if (tp != NULL)
8249+
{
8250+
idx0 = tabpage_index(curtab) - 1;
8251+
idx1 = tabpage_index(tp) - 1;
8252+
8253+
TabCtrl_GetItemRect(hwnd, idx1, &rect);
8254+
nCenter = rect.left + (rect.right - rect.left) / 2;
8255+
8256+
/* Check if the mouse cursor goes over the center of
8257+
* the next tab to prevent "flickering". */
8258+
if ((idx0 < idx1) && (nCenter < pt.x))
8259+
{
8260+
tabpage_move(idx1 + 1);
8261+
update_screen(0);
8262+
}
8263+
else if ((idx1 < idx0) && (pt.x < nCenter))
8264+
{
8265+
tabpage_move(idx1);
8266+
update_screen(0);
8267+
}
8268+
}
8269+
}
8270+
}
8271+
break;
8272+
case WM_LBUTTONUP:
8273+
{
8274+
if (GetCapture() == hwnd)
8275+
{
8276+
SetCursor(s_hCursor);
8277+
ReleaseCapture();
8278+
}
8279+
break;
8280+
}
8281+
default:
8282+
break;
8283+
}
8284+
81628285
return CallWindowProc(s_tabline_wndproc, hwnd, uMsg, wParam, lParam);
81638286
}
81648287
#endif

0 commit comments

Comments
 (0)