Created
November 20, 2013 16:13
-
-
Save nocd5/7565874 to your computer and use it in GitHub Desktop.
gVimのタブの機能追加
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** src/gui_w32.c Sun Aug 4 23:15:37 2013 | |
--- src/gui_w32.c.mod Thu Nov 21 01:06:34 2013 | |
*************** | |
*** 4223,4228 **** | |
--- 4223,4328 ---- | |
#endif | |
#if defined(FEAT_GUI_TABLINE) || defined(PROTO) | |
+ static tabpage_T* s_tp = NULL; | |
+ static LONG DefTabControlProc; | |
+ static HCURSOR s_hCursor = NULL; | |
+ static POINT s_pt = {0, 0}; | |
+ static tabpage_T* GetTabFromPoint(HWND hWnd, POINT pt){ | |
+ tabpage_T* ptp; | |
+ ptp = NULL; | |
+ if (gui_mch_showing_tabline()){ | |
+ TCHITTESTINFO htinfo; | |
+ htinfo.pt = pt; | |
+ /* ignore if a window under cusor is not tabcontrol. */ | |
+ if (s_tabhwnd == hWnd){ | |
+ int idx; | |
+ idx = TabCtrl_HitTest(s_tabhwnd, &htinfo); | |
+ if (idx != -1){ | |
+ ptp = find_tabpage(idx + 1); | |
+ } | |
+ } | |
+ } | |
+ return ptp; | |
+ } | |
+ static LRESULT CALLBACK MyTabControlProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ | |
+ POINT pt; | |
+ switch (uMsg){ | |
+ case WM_LBUTTONDOWN: | |
+ { | |
+ s_pt.x = LOWORD(lParam); | |
+ s_pt.y = HIWORD(lParam); | |
+ s_tp = GetTabFromPoint(hWnd, s_pt); | |
+ SetCapture(hWnd); | |
+ break; | |
+ } | |
+ case WM_MOUSEMOVE: | |
+ if (GetCapture() == hWnd){ | |
+ if (wParam & MK_LBUTTON){ | |
+ pt.x = LOWORD(lParam); | |
+ pt.y = HIWORD(lParam); | |
+ if ( ( (s_pt.x-pt.x)*(s_pt.x-pt.x) + (s_pt.y-pt.y)*(s_pt.y-pt.y) ) > 0xff ){ | |
+ s_hCursor = GetCursor(); | |
+ SetCursor(LoadCursor(0, IDC_SIZEWE)); | |
+ } | |
+ } | |
+ } | |
+ break; | |
+ case WM_LBUTTONUP: | |
+ { | |
+ SetCursor(s_hCursor); | |
+ ReleaseCapture(); | |
+ pt.x = LOWORD(lParam); | |
+ pt.y = HIWORD(lParam); | |
+ tabpage_T* tp = GetTabFromPoint(hWnd, pt); | |
+ if (s_tp != NULL && tp != NULL){ | |
+ if (tp != s_tp){ | |
+ goto_tabpage_tp(s_tp, TRUE, TRUE); | |
+ tabpage_move(tabpage_index(tp)-1); | |
+ update_screen(0); | |
+ } | |
+ s_tp = NULL; | |
+ } | |
+ break; | |
+ } | |
+ case WM_MBUTTONDOWN: | |
+ { | |
+ pt.x = LOWORD(lParam); | |
+ pt.y = HIWORD(lParam); | |
+ s_tp = GetTabFromPoint(hWnd, pt); | |
+ SetCapture(hWnd); | |
+ break; | |
+ } | |
+ case WM_MBUTTONUP: | |
+ { | |
+ ReleaseCapture(); | |
+ /* when the mouse events was executed on the same tab */ | |
+ pt.x = LOWORD(lParam); | |
+ pt.y = HIWORD(lParam); | |
+ if (GetTabFromPoint(hWnd, pt) == s_tp){ | |
+ BOOL bResult; | |
+ bResult = FALSE; | |
+ if (s_tp == curtab){ | |
+ if (first_tabpage->tp_next != NULL){ | |
+ tabpage_close(FALSE); | |
+ bResult = TRUE; | |
+ } | |
+ } | |
+ else if (s_tp != NULL){ | |
+ tabpage_close_other(s_tp, FALSE); | |
+ bResult = TRUE; | |
+ } | |
+ | |
+ if (bResult == TRUE) update_screen(0); | |
+ } | |
+ s_tp = NULL; | |
+ break; | |
+ } | |
+ default: | |
+ break; | |
+ } | |
+ /* call default TabControl proc */ | |
+ return CallWindowProc(DefTabControlProc, hWnd, uMsg, wParam, lParam); | |
+ } | |
static void | |
initialise_tabline(void) | |
{ | |
*************** | |
*** 4234,4239 **** | |
--- 4334,4341 ---- | |
CW_USEDEFAULT, s_hwnd, NULL, s_hinst, NULL); | |
s_tabline_wndproc = SubclassWindow(s_tabhwnd, tabline_wndproc); | |
+ DefTabControlProc = SetWindowLong(s_tabhwnd, GWL_WNDPROC, (LONG)MyTabControlProc); | |
+ | |
gui.tabline_height = TABLINE_HEIGHT; | |
# ifdef USE_SYSMENU_FONT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment