├── .github ├── dependabot.yml └── workflows │ └── CI_build.yml ├── .gitignore ├── DockingFeature ├── ContextMenu.cpp ├── ContextMenu.h ├── Docking.h ├── DockingDlgInterface.h ├── GitPanelDlg.cpp ├── GitPanelDlg.h ├── Process.cpp ├── Process.h ├── SettingsDlg.cpp ├── SettingsDlg.h ├── StaticDialog.cpp ├── StaticDialog.h ├── Window.h ├── dockingResource.h ├── gitPanel.rc ├── res │ ├── Git.bmp │ ├── Toolbar1.bmp │ └── Toolbar2.bmp └── resource.h ├── GitSCM.cpp ├── GitSCM.ico ├── GitSCM.rc ├── GitSCM.sln ├── GitSCM.vcxproj ├── GitSCM.vcxproj.user ├── Notepad_plus_msgs.h ├── PluginDefinition.cpp ├── PluginDefinition.h ├── PluginInterface.h ├── README.md ├── Sci_Position.h ├── Scintilla.h ├── license.txt ├── menuCmdID.h ├── resource.h ├── stdafx.h └── targetver.h /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | 9 | # Maintain dependencies for GitHub Actions 10 | - package-ecosystem: "github-actions" 11 | directory: "/" 12 | schedule: 13 | interval: "weekly" 14 | -------------------------------------------------------------------------------- /.github/workflows/CI_build.yml: -------------------------------------------------------------------------------- 1 | name: CI_build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: windows-latest 9 | strategy: 10 | max-parallel: 6 11 | matrix: 12 | build_configuration: [Release, Debug] 13 | build_platform: [x64, Win32, ARM64] 14 | 15 | steps: 16 | - name: Checkout repo 17 | uses: actions/checkout@v4 18 | 19 | - name: Add msbuild to PATH 20 | uses: microsoft/setup-msbuild@v1 21 | 22 | - name: MSBuild of plugin dll 23 | working-directory: .\ 24 | run: msbuild GitSCM.vcxproj /m /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /p:PlatformToolset="v142" /target:zip 25 | env: 26 | ZIPCMD: 7z a -tzip 27 | 28 | - name: Archive 29 | uses: actions/upload-artifact@v3 30 | with: 31 | name: GitSCM-${{ matrix.build_configuration }}-${{ matrix.build_platform }} 32 | path: ${{ matrix.build_configuration }}\${{ matrix.build_platform }}\GitSCM.dll 33 | 34 | - name: Release 35 | uses: softprops/action-gh-release@v1 36 | if: startsWith(github.ref, 'refs/tags/') && matrix.build_configuration == 'Release' 37 | with: 38 | body: ${{ github.event.commits[0].message }} 39 | files: ${{ matrix.build_configuration }}/${{ matrix.build_platform }}/GitSCM-v${{ github.ref_name }}-${{ matrix.build_platform }}.zip 40 | 41 | - name: SHA256 42 | if: startsWith(github.ref, 'refs/tags/') && matrix.build_configuration == 'Release' 43 | run: sha256sum.exe ${{ matrix.build_configuration }}\${{ matrix.build_platform }}\GitSCM-v${{ github.ref_name }}-${{ matrix.build_platform }}.zip 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Debug 2 | Release 3 | .vs 4 | *.suo 5 | *.exp 6 | *.lib 7 | *.iobj 8 | *.ipdb 9 | *.zip 10 | tags 11 | Win32/* 12 | x64/* 13 | arm64/* 14 | -------------------------------------------------------------------------------- /DockingFeature/ContextMenu.cpp: -------------------------------------------------------------------------------- 1 | /***********************************************************\ 2 | * Original in MFC by Roman Engels Copyright 2003 * 3 | * * 4 | * http://www.codeproject.com/shell/shellcontextmenu.asp * 5 | \***********************************************************/ 6 | 7 | /* 8 | This file is part of Explorer Plugin for Notepad++ 9 | Copyright (C)2006 Jens Lorenz 10 | 11 | This program is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU General Public License 13 | as published by the Free Software Foundation; either version 2 14 | of the License, or (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 | */ 25 | 26 | 27 | // #include "stdafx.h" 28 | #include "ContextMenu.h" 29 | #include "../Notepad_plus_msgs.h" 30 | #include "../PluginDefinition.h" 31 | 32 | #include 33 | 34 | IContextMenu2 * g_IContext2 = NULL; 35 | IContextMenu3 * g_IContext3 = NULL; 36 | 37 | WNDPROC g_OldWndProc = NULL; 38 | 39 | 40 | ContextMenu::ContextMenu() : 41 | _hInst(nullptr), 42 | _hWndNpp(nullptr), 43 | _hWndParent(nullptr), 44 | _nItems(0), 45 | _bDelete(FALSE), 46 | _hMenu(nullptr), 47 | _psfFolder(nullptr), 48 | _pidlArray(nullptr) 49 | { 50 | } 51 | 52 | ContextMenu::~ContextMenu() 53 | { 54 | /* free all allocated datas */ 55 | if (_psfFolder && _bDelete) 56 | _psfFolder->Release (); 57 | _psfFolder = NULL; 58 | FreePIDLArray(_pidlArray); 59 | _pidlArray = NULL; 60 | 61 | ::DestroyMenu(_hMenu); 62 | } 63 | 64 | 65 | // this functions determines which version of IContextMenu is avaibale for those objects (always the highest one) 66 | // and returns that interface 67 | BOOL ContextMenu::GetContextMenu (void ** ppContextMenu, int & iMenuType) 68 | { 69 | *ppContextMenu = NULL; 70 | LPCONTEXTMENU icm1 = NULL; 71 | 72 | // first we retrieve the normal IContextMenu interface (every object should have it) 73 | _psfFolder->GetUIObjectOf (NULL, (UINT)_nItems, (LPCITEMIDLIST *) _pidlArray, IID_IContextMenu, NULL, (void**) &icm1); 74 | 75 | if (icm1) 76 | { // since we got an IContextMenu interface we can now obtain the higher version interfaces via that 77 | if (icm1->QueryInterface (IID_IContextMenu3, ppContextMenu) == NOERROR) 78 | iMenuType = 3; 79 | else if (icm1->QueryInterface (IID_IContextMenu2, ppContextMenu) == NOERROR) 80 | iMenuType = 2; 81 | 82 | if (*ppContextMenu) 83 | icm1->Release(); // we can now release version 1 interface, cause we got a higher one 84 | else 85 | { 86 | iMenuType = 1; 87 | *ppContextMenu = icm1; // since no higher versions were found 88 | } // redirect ppContextMenu to version 1 interface 89 | } 90 | else 91 | return (FALSE); // something went wrong 92 | 93 | return (TRUE); // success 94 | } 95 | 96 | 97 | LRESULT CALLBACK ContextMenu::HookWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 98 | { 99 | switch (message) 100 | { 101 | case WM_MENUCHAR: // only supported by IContextMenu3 102 | { 103 | if (g_IContext3) 104 | { 105 | LRESULT lResult = 0; 106 | g_IContext3->HandleMenuMsg2 (message, wParam, lParam, &lResult); 107 | return (lResult); 108 | } 109 | break; 110 | } 111 | case WM_DRAWITEM: 112 | case WM_MEASUREITEM: 113 | { 114 | if (wParam) 115 | break; // if wParam != 0 then the message is not menu-related 116 | } 117 | case WM_INITMENUPOPUP: 118 | { 119 | if (g_IContext2) 120 | g_IContext2->HandleMenuMsg (message, wParam, lParam); 121 | else // version 3 122 | g_IContext3->HandleMenuMsg (message, wParam, lParam); 123 | return (message == WM_INITMENUPOPUP ? 0 : TRUE); // inform caller that we handled WM_INITPOPUPMENU by ourself 124 | break; 125 | } 126 | default: 127 | break; 128 | } 129 | 130 | // call original WndProc of window to prevent undefined bevhaviour of window 131 | return ::CallWindowProc (g_OldWndProc, hWnd, message, wParam, lParam); 132 | } 133 | 134 | 135 | UINT ContextMenu::ShowContextMenu(HINSTANCE hInst, HWND hWndNpp, HWND hWndParent, POINT pt, bool normal) 136 | { 137 | TCHAR szText[64] = {0}; 138 | 139 | /* store notepad handle */ 140 | _hInst = hInst; 141 | _hWndNpp = hWndNpp; 142 | _hWndParent = hWndParent; 143 | 144 | // to know which version of IContextMenu is supported 145 | int iMenuType = 0; 146 | 147 | // common pointer to IContextMenu and higher version interface 148 | LPCONTEXTMENU pContextMenu = NULL; 149 | 150 | if (_pidlArray != NULL) 151 | { 152 | if (!_hMenu) 153 | { 154 | _hMenu = NULL; 155 | _hMenu = ::CreateMenu(); 156 | } 157 | 158 | if (!GetContextMenu((void**) &pContextMenu, iMenuType)) 159 | return (0); // something went wrong 160 | 161 | // lets fill out our popupmenu 162 | pContextMenu->QueryContextMenu( _hMenu, 163 | ::GetMenuItemCount(_hMenu), 164 | CTX_MIN, 165 | CTX_MAX, 166 | CMF_EXPLORE | ((_strFirstElement.size() > 4)?CMF_CANRENAME:0)); 167 | 168 | // subclass window to handle menurelated messages in ContextMenu 169 | g_OldWndProc = NULL; 170 | if (iMenuType > 1) // only subclass if its version 2 or 3 171 | { 172 | g_OldWndProc = (WNDPROC)::SetWindowLongPtr (hWndParent, GWLP_WNDPROC, (LONG_PTR) HookWndProc); 173 | if (iMenuType == 2) 174 | g_IContext2 = (LPCONTEXTMENU2) pContextMenu; 175 | else // version 3 176 | g_IContext3 = (LPCONTEXTMENU3) pContextMenu; 177 | } 178 | } 179 | 180 | /************************************* modification for notepad ***********************************/ 181 | HMENU hMainMenu = ::CreatePopupMenu(); 182 | // bool isFolder = (_strFirstElement[_strFirstElement.size()-1] == '\\'); 183 | 184 | /* Add notepad menu items */ 185 | // if (! isFolder) 186 | ::AppendMenu(hMainMenu, MF_STRING, CTX_OPEN, TEXT("Open")); 187 | ::InsertMenu(hMainMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, 0); 188 | ::AppendMenu(hMainMenu, MF_STRING, CTX_DIFF, TEXT("Diff")); 189 | ::AppendMenu(hMainMenu, MF_STRING, CTX_ADD, TEXT("Add")); 190 | ::AppendMenu(hMainMenu, MF_STRING, CTX_UNSTAGE, TEXT("Unstage")); 191 | ::AppendMenu(hMainMenu, MF_STRING, CTX_RESTORE, TEXT("Restore")); 192 | ::InsertMenu(hMainMenu, 6, MF_BYPOSITION | MF_SEPARATOR, 0, 0); 193 | 194 | if (_pidlArray != NULL) 195 | { 196 | int copyAt = -1; 197 | int items = ::GetMenuItemCount(_hMenu); 198 | MENUITEMINFO info = {0}; 199 | 200 | info.cbSize = sizeof(MENUITEMINFO); 201 | info.fMask = MIIM_TYPE | MIIM_ID | MIIM_SUBMENU; 202 | 203 | ::AppendMenu(hMainMenu, MF_SEPARATOR, 0, 0); 204 | 205 | if (normal) 206 | { 207 | /* store all items in an seperate sub menu until "cut" (25) or "copy" (26) */ 208 | for (int i = 0; i < items; i++) 209 | { 210 | info.cch = 256; 211 | info.dwTypeData = szText; 212 | if (copyAt == -1) 213 | { 214 | ::GetMenuItemInfo(_hMenu, i, TRUE, &info); 215 | if ((info.wID == CTX_CUT) || (info.wID == CTX_COPY) || (info.wID == CTX_PASTE)) 216 | { 217 | copyAt = i - 1; 218 | ::AppendMenu(hMainMenu, info.fType, info.wID, info.dwTypeData); 219 | ::DeleteMenu(_hMenu, i , MF_BYPOSITION); 220 | ::DeleteMenu(_hMenu, i-1, MF_BYPOSITION); 221 | } 222 | } 223 | else 224 | { 225 | ::GetMenuItemInfo(_hMenu, copyAt, TRUE, &info); 226 | if ((MFT_STRING == info.fType) || (MFT_SEPARATOR == info.fType)) { 227 | ::AppendMenu(hMainMenu, info.fType, info.wID, info.dwTypeData); 228 | } 229 | ::DeleteMenu(_hMenu, copyAt, MF_BYPOSITION); 230 | } 231 | } 232 | 233 | TCHAR szMenuName[MAX_PATH]; 234 | wcscpy(szMenuName, TEXT("Standard Menu")); 235 | ::InsertMenu(hMainMenu, 7, MF_BYPOSITION | MF_STRING | MF_POPUP, (UINT_PTR)_hMenu, szMenuName); 236 | } 237 | else 238 | { 239 | /* ignore all items until "cut" (25) or "copy" (26) */ 240 | for (int i = 0; i < items; i++) 241 | { 242 | info.cch = 256; 243 | info.dwTypeData = szText; 244 | ::GetMenuItemInfo(_hMenu, i, TRUE, &info); 245 | if ((copyAt == -1) && ((info.wID == CTX_CUT) || (info.wID == CTX_COPY) || (info.wID == CTX_PASTE))) 246 | { 247 | copyAt = 0; 248 | } 249 | else if ((info.wID == 20) || (info.wID == 27)) 250 | { 251 | ::AppendMenu(hMainMenu, info.fType, info.wID, info.dwTypeData); 252 | ::AppendMenu(hMainMenu, MF_SEPARATOR, 0, 0); 253 | } 254 | } 255 | ::DeleteMenu(hMainMenu, ::GetMenuItemCount(hMainMenu) - 1, MF_BYPOSITION); 256 | } 257 | } 258 | 259 | /*****************************************************************************************************/ 260 | 261 | UINT idCommand = ::TrackPopupMenu(hMainMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hWndParent, NULL); 262 | 263 | /* free resources */ 264 | ::DestroyMenu(hMainMenu); 265 | 266 | if ((_pidlArray != NULL) && (g_OldWndProc != NULL)) // unsubclass 267 | { 268 | ::SetWindowLongPtr(hWndParent, GWLP_WNDPROC, (LONG_PTR) g_OldWndProc); 269 | } 270 | 271 | // see if returned idCommand belongs to shell menu entries but not for renaming (19) 272 | if ((idCommand >= CTX_MIN) && (idCommand < CTX_MAX) && (idCommand != CTX_RENAME)) 273 | { 274 | InvokeCommand (pContextMenu, idCommand - CTX_MIN); // execute related command 275 | } 276 | else 277 | { 278 | 279 | /************************************* modification for notepad ***********************************/ 280 | 281 | switch (idCommand) 282 | { 283 | case CTX_OPEN: 284 | { 285 | openFile(); 286 | break; 287 | } 288 | case CTX_DIFF: 289 | { 290 | diffFileFiles( _strArray ); 291 | break; 292 | } 293 | case CTX_ADD: 294 | { 295 | addFileFiles( _strArray ); 296 | break; 297 | } 298 | case CTX_UNSTAGE: 299 | { 300 | unstageFileFiles( _strArray ); 301 | break; 302 | } 303 | case CTX_RESTORE: 304 | { 305 | restoreFileFiles( _strArray ); 306 | break; 307 | } 308 | default: /* and greater */ 309 | { 310 | break; 311 | } 312 | } 313 | 314 | /*****************************************************************************************************/ 315 | 316 | } 317 | 318 | if (pContextMenu != NULL) 319 | pContextMenu->Release(); 320 | g_IContext2 = NULL; 321 | g_IContext3 = NULL; 322 | 323 | return (idCommand); 324 | } 325 | 326 | 327 | void ContextMenu::InvokeCommand (LPCONTEXTMENU pContextMenu, UINT idCommand) 328 | { 329 | CMINVOKECOMMANDINFO cmi = {0}; 330 | cmi.cbSize = sizeof (CMINVOKECOMMANDINFO); 331 | cmi.lpVerb = (LPSTR) MAKEINTRESOURCE (idCommand); 332 | cmi.nShow = SW_SHOWNORMAL; 333 | 334 | pContextMenu->InvokeCommand (&cmi); 335 | } 336 | 337 | 338 | 339 | void ContextMenu::SetObjects(std::wstring strObject) 340 | { 341 | // only one object is passed 342 | std::vector strArray; 343 | strArray.push_back(strObject); // create a CStringArray with one element 344 | 345 | SetObjects (strArray); // and pass it to SetObjects (vector strArray) 346 | // for further processing 347 | } 348 | 349 | 350 | void ContextMenu::SetObjects(std::vector strArray) 351 | { 352 | // store also the string for later menu use 353 | _strFirstElement = strArray[0]; 354 | _strArray = strArray; 355 | 356 | // free all allocated datas 357 | if (_psfFolder && _bDelete) 358 | _psfFolder->Release (); 359 | _psfFolder = NULL; 360 | FreePIDLArray (_pidlArray); 361 | _pidlArray = NULL; 362 | 363 | // get IShellFolder interface of Desktop (root of shell namespace) 364 | IShellFolder * psfDesktop = NULL; 365 | SHGetDesktopFolder (&psfDesktop); // needed to obtain full qualified pidl 366 | 367 | // ParseDisplayName creates a PIDL from a file system path relative to the IShellFolder interface 368 | // but since we use the Desktop as our interface and the Desktop is the namespace root 369 | // that means that it's a fully qualified PIDL, which is what we need 370 | LPITEMIDLIST pidl = NULL; 371 | 372 | #ifndef _UNICODE 373 | OLECHAR * olePath = NULL; 374 | olePath = (OLECHAR *) calloc (strArray[0].size() + 1, sizeof (OLECHAR)); 375 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strArray[0].c_str(), -1, olePath, strArray[0].size() + 1); 376 | psfDesktop->ParseDisplayName (NULL, 0, olePath, NULL, &pidl, NULL); 377 | free (olePath); 378 | #else 379 | psfDesktop->ParseDisplayName (NULL, 0, (LPOLESTR)strArray[0].c_str(), NULL, &pidl, NULL); 380 | #endif 381 | 382 | if (pidl != NULL) { 383 | // now we need the parent IShellFolder interface of pidl, and the relative PIDL to that interface 384 | LPITEMIDLIST pidlItem = NULL; // relative pidl 385 | SHBindToParentEx (pidl, IID_IShellFolder, (void **) &_psfFolder, NULL); 386 | free (pidlItem); 387 | // get interface to IMalloc (need to free the PIDLs allocated by the shell functions) 388 | LPMALLOC lpMalloc = NULL; 389 | SHGetMalloc (&lpMalloc); 390 | if (lpMalloc != NULL) lpMalloc->Free (pidl); 391 | 392 | // now we have the IShellFolder interface to the parent folder specified in the first element in strArray 393 | // since we assume that all objects are in the same folder (as it's stated in the MSDN) 394 | // we now have the IShellFolder interface to every objects parent folder 395 | 396 | IShellFolder * psfFolder = NULL; 397 | _nItems = strArray.size(); 398 | for (SIZE_T i = 0; i < _nItems; i++) { 399 | #ifndef _UNICODE 400 | olePath = (OLECHAR *) calloc (strArray[i].size() + 1, sizeof (OLECHAR)); 401 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strArray[i].c_str(), -1, olePath, strArray[i].size() + 1); 402 | psfDesktop->ParseDisplayName (NULL, 0, olePath, NULL, &pidl, NULL); 403 | free (olePath); 404 | #else 405 | psfDesktop->ParseDisplayName (NULL, 0, (LPOLESTR)strArray[i].c_str(), NULL, &pidl, NULL); 406 | #endif 407 | _pidlArray = (LPITEMIDLIST *) realloc (_pidlArray, (i + 1) * sizeof (LPITEMIDLIST)); 408 | // get relative pidl via SHBindToParent 409 | SHBindToParentEx (pidl, IID_IShellFolder, (void **) &psfFolder, (LPCITEMIDLIST *) &pidlItem); 410 | _pidlArray[i] = CopyPIDL (pidlItem); // copy relative pidl to pidlArray 411 | free (pidlItem); 412 | // free pidl allocated by ParseDisplayName 413 | if (lpMalloc != NULL) lpMalloc->Free (pidl); 414 | if (psfFolder != NULL) psfFolder->Release (); 415 | } 416 | 417 | if (lpMalloc != NULL) lpMalloc->Release (); 418 | } 419 | if (psfDesktop != NULL) psfDesktop->Release (); 420 | 421 | _bDelete = TRUE; // indicates that _psfFolder should be deleted by ContextMenu 422 | } 423 | 424 | 425 | void ContextMenu::FreePIDLArray(LPITEMIDLIST *pidlArray) 426 | { 427 | if (!pidlArray) { 428 | return; 429 | } 430 | 431 | SIZE_T iSize = _msize (pidlArray) / sizeof (LPITEMIDLIST); 432 | 433 | for (SIZE_T i = 0; i < iSize; i++) { 434 | free(pidlArray[i]); 435 | } 436 | free (pidlArray); 437 | } 438 | 439 | 440 | LPITEMIDLIST ContextMenu::CopyPIDL (LPCITEMIDLIST pidl, int cb) 441 | { 442 | if (cb == -1) { 443 | cb = GetPIDLSize (pidl); // Calculate size of list. 444 | } 445 | 446 | LPITEMIDLIST pidlRet = (LPITEMIDLIST) calloc (cb + sizeof (USHORT), sizeof (BYTE)); 447 | if (pidlRet) { 448 | CopyMemory(pidlRet, pidl, cb); 449 | } 450 | 451 | return (pidlRet); 452 | } 453 | 454 | 455 | UINT ContextMenu::GetPIDLSize (LPCITEMIDLIST pidl) 456 | { 457 | if (!pidl) { 458 | return 0; 459 | } 460 | int nSize = 0; 461 | LPITEMIDLIST pidlTemp = (LPITEMIDLIST) pidl; 462 | while (pidlTemp->mkid.cb) { 463 | nSize += pidlTemp->mkid.cb; 464 | pidlTemp = (LPITEMIDLIST) (((LPBYTE) pidlTemp) + pidlTemp->mkid.cb); 465 | } 466 | return nSize; 467 | } 468 | 469 | HMENU ContextMenu::GetMenu() 470 | { 471 | if (!_hMenu) { 472 | _hMenu = ::CreatePopupMenu(); // create the popupmenu (its empty) 473 | } 474 | return (_hMenu); 475 | } 476 | 477 | 478 | // this is workaround function for the Shell API Function SHBindToParent 479 | // SHBindToParent is not available under Win95/98 480 | HRESULT ContextMenu::SHBindToParentEx (LPCITEMIDLIST pidl, REFIID riid, VOID **ppv, LPCITEMIDLIST *ppidlLast) 481 | { 482 | HRESULT hr = 0; 483 | if (!pidl || !ppv) { 484 | return E_POINTER; 485 | } 486 | 487 | int nCount = GetPIDLCount (pidl); 488 | if (nCount == 0) { // desktop pidl of invalid pidl 489 | return E_POINTER; 490 | } 491 | 492 | IShellFolder * psfDesktop = NULL; 493 | SHGetDesktopFolder (&psfDesktop); 494 | if (nCount == 1) { // desktop pidl 495 | if ((hr = psfDesktop->QueryInterface(riid, ppv)) == S_OK) { 496 | if (ppidlLast) { 497 | *ppidlLast = CopyPIDL (pidl); 498 | } 499 | } 500 | psfDesktop->Release (); 501 | return hr; 502 | } 503 | 504 | LPBYTE pRel = GetPIDLPos (pidl, nCount - 1); 505 | LPITEMIDLIST pidlParent = NULL; 506 | pidlParent = CopyPIDL (pidl, (int)(pRel - (LPBYTE) pidl)); 507 | IShellFolder * psfFolder = NULL; 508 | 509 | if ((hr = psfDesktop->BindToObject (pidlParent, NULL, __uuidof (psfFolder), (void **) &psfFolder)) != S_OK) { 510 | free (pidlParent); 511 | psfDesktop->Release (); 512 | return hr; 513 | } 514 | if ((hr = psfFolder->QueryInterface (riid, ppv)) == S_OK) { 515 | if (ppidlLast) { 516 | *ppidlLast = CopyPIDL ((LPCITEMIDLIST) pRel); 517 | } 518 | } 519 | free (pidlParent); 520 | psfFolder->Release (); 521 | psfDesktop->Release (); 522 | return hr; 523 | } 524 | 525 | 526 | LPBYTE ContextMenu::GetPIDLPos (LPCITEMIDLIST pidl, int nPos) 527 | { 528 | if (!pidl) 529 | return 0; 530 | int nCount = 0; 531 | 532 | BYTE * pCur = (BYTE *) pidl; 533 | while (((LPCITEMIDLIST) pCur)->mkid.cb) { 534 | if (nCount == nPos) { 535 | return pCur; 536 | } 537 | nCount++; 538 | pCur += ((LPCITEMIDLIST) pCur)->mkid.cb; // + sizeof(pidl->mkid.cb); 539 | } 540 | if (nCount == nPos) { 541 | return pCur; 542 | } 543 | return NULL; 544 | } 545 | 546 | 547 | int ContextMenu::GetPIDLCount (LPCITEMIDLIST pidl) 548 | { 549 | if (!pidl) 550 | return 0; 551 | 552 | int nCount = 0; 553 | BYTE* pCur = (BYTE *) pidl; 554 | while (((LPCITEMIDLIST) pCur)->mkid.cb) 555 | { 556 | nCount++; 557 | pCur += ((LPCITEMIDLIST) pCur)->mkid.cb; 558 | } 559 | return nCount; 560 | } 561 | 562 | 563 | /********************************************************************************************* 564 | * Notepad specific functions 565 | */ 566 | void ContextMenu::openFile(void) 567 | { 568 | for (const auto &path : _strArray) { 569 | ::SendMessage(_hWndNpp, NPPM_DOOPEN, 0, (LPARAM)path.c_str()); 570 | } 571 | } 572 | -------------------------------------------------------------------------------- /DockingFeature/ContextMenu.h: -------------------------------------------------------------------------------- 1 | /***********************************************************\ 2 | * Original in MFC by Roman Engels Copyright 2003 * 3 | * * 4 | * http://www.codeproject.com/shell/shellcontextmenu.asp * 5 | \***********************************************************/ 6 | 7 | /* 8 | This file is part of Explorer Plugin for Notepad++ 9 | Copyright (C)2006 Jens Lorenz 10 | 11 | This program is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU General Public License 13 | as published by the Free Software Foundation; either version 2 14 | of the License, or (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program; if not, write to the Free Software 23 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 | */ 25 | 26 | 27 | 28 | #ifndef CONTEXTMENU_DEFINE_H 29 | #define CONTEXTMENU_DEFINE_H 30 | 31 | #include "window.h" 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | struct __declspec(uuid("000214e6-0000-0000-c000-000000000046")) IShellFolder; 40 | 41 | struct OBJECT_DATA { 42 | TCHAR * pszFullPath; 43 | TCHAR szFileName[MAX_PATH]; 44 | TCHAR szTypeName[MAX_PATH]; 45 | UINT64 u64FileSize; 46 | DWORD dwFileAttributes; 47 | int iIcon; 48 | FILETIME ftLastModified; 49 | } ; 50 | 51 | #define CTX_MIN 1 52 | #define CTX_MAX 10000 53 | 54 | enum eContextMenuID { 55 | CTX_DELETE = 18, 56 | CTX_RENAME = 19, 57 | CTX_CUT = 25, 58 | CTX_COPY = 26, 59 | CTX_PASTE = 27, 60 | CTX_OPEN = CTX_MAX, 61 | CTX_DIFF, 62 | CTX_ADD, 63 | CTX_UNSTAGE, 64 | CTX_RESTORE 65 | } ; 66 | 67 | class ContextMenu 68 | { 69 | public: 70 | ContextMenu(); 71 | ~ContextMenu(); 72 | 73 | /* get menu */ 74 | HMENU GetMenu (void); 75 | 76 | void SetObjects(std::wstring strObject); 77 | void SetObjects(std::vector strArray); 78 | UINT ShowContextMenu(HINSTANCE hInst, HWND hWndNpp, HWND hWndParent, POINT pt, bool normal = true); 79 | 80 | private: 81 | static LRESULT CALLBACK HookWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 82 | 83 | HRESULT SHBindToParentEx (LPCITEMIDLIST pidl, REFIID riid, VOID **ppv, LPCITEMIDLIST *ppidlLast); 84 | 85 | void InvokeCommand(LPCONTEXTMENU pContextMenu, UINT idCommand); 86 | BOOL GetContextMenu(void ** ppContextMenu, int & iMenuType); 87 | void FreePIDLArray(LPITEMIDLIST * pidlArray); 88 | UINT GetPIDLSize(LPCITEMIDLIST pidl); 89 | LPBYTE GetPIDLPos(LPCITEMIDLIST pidl, int nPos); 90 | int GetPIDLCount(LPCITEMIDLIST pidl); 91 | LPITEMIDLIST CopyPIDL(LPCITEMIDLIST pidl, int cb = -1); 92 | 93 | /* notepad functions */ 94 | void openFile(void); 95 | 96 | private: 97 | HINSTANCE _hInst; 98 | HWND _hWndNpp; 99 | HWND _hWndParent; 100 | 101 | SIZE_T _nItems; 102 | BOOL _bDelete; 103 | HMENU _hMenu; 104 | IShellFolder* _psfFolder; 105 | LPITEMIDLIST* _pidlArray; 106 | 107 | std::wstring _strFirstElement; 108 | std::vector _strArray; 109 | }; 110 | 111 | #endif // CONTEXTMENU_DEFINE_H 112 | -------------------------------------------------------------------------------- /DockingFeature/Docking.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2021 Don HO 3 | 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // at your option any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | // ATTENTION : It's a part of interface header, so don't include the others header here 23 | 24 | // styles for containers 25 | #define CAPTION_TOP TRUE 26 | #define CAPTION_BOTTOM FALSE 27 | 28 | // defines for docking manager 29 | #define CONT_LEFT 0 30 | #define CONT_RIGHT 1 31 | #define CONT_TOP 2 32 | #define CONT_BOTTOM 3 33 | #define DOCKCONT_MAX 4 34 | 35 | // mask params for plugins of internal dialogs 36 | #define DWS_ICONTAB 0x00000001 // Icon for tabs are available 37 | #define DWS_ICONBAR 0x00000002 // Icon for icon bar are available (currently not supported) 38 | #define DWS_ADDINFO 0x00000004 // Additional information are in use 39 | #define DWS_PARAMSALL (DWS_ICONTAB|DWS_ICONBAR|DWS_ADDINFO) 40 | 41 | // default docking values for first call of plugin 42 | #define DWS_DF_CONT_LEFT (CONT_LEFT << 28) // default docking on left 43 | #define DWS_DF_CONT_RIGHT (CONT_RIGHT << 28) // default docking on right 44 | #define DWS_DF_CONT_TOP (CONT_TOP << 28) // default docking on top 45 | #define DWS_DF_CONT_BOTTOM (CONT_BOTTOM << 28) // default docking on bottom 46 | #define DWS_DF_FLOATING 0x80000000 // default state is floating 47 | 48 | 49 | typedef struct { 50 | HWND hClient; // client Window Handle 51 | const TCHAR *pszName; // name of plugin (shown in window) 52 | int dlgID; // a funcItem provides the function pointer to start a dialog. Please parse here these ID 53 | 54 | // user modifications 55 | UINT uMask; // mask params: look to above defines 56 | HICON hIconTab; // icon for tabs 57 | const TCHAR *pszAddInfo; // for plugin to display additional informations 58 | 59 | // internal data, do not use !!! 60 | RECT rcFloat; // floating position 61 | int iPrevCont; // stores the privious container (toggling between float and dock) 62 | const TCHAR* pszModuleName; // it's the plugin file name. It's used to identify the plugin 63 | } tTbData; 64 | 65 | 66 | typedef struct { 67 | HWND hWnd; // the docking manager wnd 68 | RECT rcRegion[DOCKCONT_MAX]; // position of docked dialogs 69 | } tDockMgr; 70 | 71 | 72 | #define HIT_TEST_THICKNESS 20 73 | #define SPLITTER_WIDTH 4 74 | 75 | -------------------------------------------------------------------------------- /DockingFeature/DockingDlgInterface.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2006 Jens Lorenz 3 | 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // at your option any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | 18 | #pragma once 19 | 20 | #include "dockingResource.h" 21 | #include "Docking.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include "StaticDialog.h" 27 | 28 | 29 | 30 | class DockingDlgInterface : public StaticDialog 31 | { 32 | public: 33 | DockingDlgInterface() = default; 34 | explicit DockingDlgInterface(int dlgID): _dlgID(dlgID) {} 35 | 36 | virtual void init(HINSTANCE hInst, HWND parent) { 37 | StaticDialog::init(hInst, parent); 38 | TCHAR temp[MAX_PATH]; 39 | ::GetModuleFileName(reinterpret_cast(hInst), temp, MAX_PATH); 40 | _moduleName = ::PathFindFileName(temp); 41 | } 42 | 43 | void create(tTbData* data, bool isRTL = false) { 44 | assert(data != nullptr); 45 | StaticDialog::create(_dlgID, isRTL); 46 | TCHAR temp[MAX_PATH]; 47 | ::GetWindowText(_hSelf, temp, MAX_PATH); 48 | _pluginName = temp; 49 | 50 | // user information 51 | data->hClient = _hSelf; 52 | data->pszName = _pluginName.c_str(); 53 | 54 | // supported features by plugin 55 | data->uMask = 0; 56 | 57 | // additional info 58 | data->pszAddInfo = NULL; 59 | } 60 | 61 | virtual void updateDockingDlg() { 62 | ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, reinterpret_cast(_hSelf)); 63 | } 64 | 65 | virtual void destroy() {} 66 | 67 | virtual void setBackgroundColor(COLORREF) {} 68 | virtual void setForegroundColor(COLORREF) {} 69 | 70 | virtual void display(bool toShow = true) const { 71 | ::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, reinterpret_cast(_hSelf)); 72 | } 73 | 74 | bool isClosed() const { 75 | return _isClosed; 76 | } 77 | 78 | void setClosed(bool toClose) { 79 | _isClosed = toClose; 80 | } 81 | 82 | const TCHAR * getPluginFileName() const { 83 | return _moduleName.c_str(); 84 | } 85 | 86 | protected : 87 | int _dlgID = -1; 88 | bool _isFloating = true; 89 | int _iDockedPos = 0; 90 | std::wstring _moduleName; 91 | std::wstring _pluginName; 92 | bool _isClosed = false; 93 | 94 | virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) { 95 | switch (message) 96 | { 97 | case WM_NOTIFY: 98 | { 99 | LPNMHDR pnmh = reinterpret_cast(lParam); 100 | 101 | if (pnmh->hwndFrom == _hParent) 102 | { 103 | switch (LOWORD(pnmh->code)) 104 | { 105 | case DMN_CLOSE: 106 | { 107 | break; 108 | } 109 | case DMN_FLOAT: 110 | { 111 | _isFloating = true; 112 | break; 113 | } 114 | case DMN_DOCK: 115 | { 116 | _iDockedPos = HIWORD(pnmh->code); 117 | _isFloating = false; 118 | break; 119 | } 120 | default: 121 | break; 122 | } 123 | } 124 | break; 125 | } 126 | default: 127 | break; 128 | } 129 | return FALSE; 130 | }; 131 | }; 132 | -------------------------------------------------------------------------------- /DockingFeature/GitPanelDlg.cpp: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO ( donho@altern.org ) 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #include "../PluginDefinition.h" 19 | #include "ContextMenu.h" 20 | #include "GitPanelDlg.h" 21 | #include "Process.h" 22 | #include "SettingsDlg.h" 23 | #include "resource.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | extern DemoDlg _gitPanel; 35 | extern TCHAR g_GitPath[MAX_PATH]; 36 | extern TCHAR g_GitPrompt[MAX_PATH]; 37 | extern bool g_useTortoise; 38 | extern bool g_NppReady; 39 | extern bool g_useNppColors; 40 | extern bool g_RaisePanel; 41 | extern bool g_Debug; 42 | extern int g_LVDelay; 43 | 44 | LVITEM LvItem; 45 | LVCOLUMN LvCol; 46 | COLORREF colorBg; 47 | COLORREF colorFg; 48 | 49 | // #define COL_CHK 0 50 | #define COL_I 0 51 | #define COL_W 1 52 | #define COL_FILE 2 53 | #define TIMER_ID 1 54 | 55 | const int WS_TOOLBARSTYLE = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER; 56 | /* WS_CHILD | WS_VISIBLE | CCS_NORESIZE | CCS_ADJUSTABLE */ 57 | 58 | TBBUTTON tbButtonsAdd1[] = 59 | { 60 | {MAKELONG( 0, 0 ), IDC_BTN_GITGUI, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 61 | {MAKELONG( 1, 0 ), IDC_BTN_GITK, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 62 | {MAKELONG( 2, 0 ), IDC_BTN_PROMPT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 63 | {0, 0, 0, BTNS_SEP, {0}, 0, 0}, 64 | {MAKELONG( 3, 0 ), IDC_BTN_PULL, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 65 | {MAKELONG( 4, 0 ), IDC_BTN_STATUS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 66 | {0, 0, 0, BTNS_SEP, {0}, 0, 0}, 67 | {MAKELONG( 5, 0 ), IDC_BTN_COMMIT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 68 | {MAKELONG( 6, 0 ), IDC_BTN_PUSH, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0} 69 | }; 70 | const int sizeButtonArray1 = sizeof( tbButtonsAdd1 ) / sizeof( TBBUTTON ); 71 | const int numButtons1 = sizeButtonArray1 - 2 /* separators */; 72 | 73 | TBBUTTON tbButtonsAdd2[] = 74 | { 75 | {MAKELONG( 0, 0 ), IDC_BTN_ADD, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 76 | {MAKELONG( 1, 0 ), IDC_BTN_UNSTAGE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 77 | {MAKELONG( 2, 0 ), IDC_BTN_RESTORE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 78 | {MAKELONG( 3, 0 ), IDC_BTN_DIFF, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 79 | {0, 0, 0, BTNS_SEP, {0}, 0, 0}, 80 | {MAKELONG( 4, 0 ), IDC_BTN_LOG, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 81 | {MAKELONG( 5, 0 ), IDC_BTN_BLAME, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, 82 | {0, 0, 0, BTNS_SEP, {0}, 0, 0}, 83 | {MAKELONG( 6, 0 ), IDC_BTN_SETTINGS, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0} 84 | }; 85 | const int sizeButtonArray2 = sizeof( tbButtonsAdd2 ) / sizeof( TBBUTTON ); 86 | const int numButtons2 = sizeButtonArray2 - 2 /* separators */; 87 | 88 | static LPCTSTR szToolTip[16] = { 89 | TEXT("Git GUI"), 90 | TEXT("GiTk"), 91 | TEXT("Git Prompt"), 92 | TEXT("Pull"), 93 | TEXT("Status"), 94 | TEXT("Commit"), 95 | TEXT("Push"), 96 | TEXT("Add"), 97 | TEXT("Unstage"), 98 | TEXT("Restore"), 99 | TEXT("Diff"), 100 | TEXT("Log"), 101 | TEXT("Blame"), 102 | TEXT("Settings") 103 | }; 104 | 105 | LPCTSTR GetNameStrFromCmd( UINT_PTR resID ) 106 | { 107 | if ((IDC_BTN_GITGUI <= resID) && (resID <= IDC_BTN_SETTINGS)) 108 | { 109 | return szToolTip[resID - IDC_BTN_GITGUI]; 110 | } 111 | return NULL; 112 | } 113 | 114 | void imageToolbar( HINSTANCE hInst, HWND hWndToolbar, UINT ToolbarID, const int numButtons ) 115 | { 116 | HBITMAP hbm = LoadBitmap( hInst, MAKEINTRESOURCE( ToolbarID ) ); 117 | BITMAP bm = {0}; 118 | GetObject( hbm, sizeof( BITMAP ), &bm ); 119 | int iImageWidth = bm.bmWidth / numButtons; 120 | int iImageHeight = bm.bmHeight; 121 | HIMAGELIST himlToolBar1 = ( HIMAGELIST )SendMessage( hWndToolbar, TB_GETIMAGELIST, 0, 0 ); 122 | ImageList_Destroy( himlToolBar1 ); 123 | himlToolBar1 = ImageList_Create( iImageWidth, iImageHeight, ILC_COLOR32 | ILC_MASK, numButtons, 0 ); 124 | ImageList_AddMasked( himlToolBar1, hbm, RGB( 192, 192, 192 ) ); 125 | SendMessage( hWndToolbar, TB_SETIMAGELIST, 0, ( LPARAM )himlToolBar1 ); 126 | } 127 | 128 | std::vector DemoDlg::split( std::wstring stringToBeSplitted, std::wstring delimeter ) 129 | { 130 | std::vector splittedString; 131 | size_t startIndex = 0; 132 | size_t endIndex = 0; 133 | 134 | while ( ( endIndex = stringToBeSplitted.find( delimeter, startIndex ) ) < stringToBeSplitted.size() ) 135 | { 136 | std::wstring val = stringToBeSplitted.substr( startIndex, endIndex - startIndex ); 137 | splittedString.push_back( val ); 138 | startIndex = endIndex + delimeter.size(); 139 | } 140 | 141 | if ( startIndex < stringToBeSplitted.size() ) 142 | { 143 | std::wstring val = stringToBeSplitted.substr( startIndex ); 144 | splittedString.push_back( val ); 145 | } 146 | 147 | return splittedString; 148 | } 149 | 150 | bool DemoDlg::updateLoc( std::wstring &loc ) 151 | { 152 | TCHAR pathName[MAX_PATH] = {0}; 153 | SendMessage( _hParent, NPPM_GETCURRENTDIRECTORY, MAX_PATH, ( LPARAM )pathName ); 154 | SendMessage( GetDlgItem( _hSelf, IDC_EDT_DIR ), WM_SETTEXT, 0, ( LPARAM )pathName ); 155 | 156 | loc = pathName; 157 | return true; 158 | } 159 | 160 | void DemoDlg::setListColumns( unsigned int uItem, std::wstring strI, std::wstring strW, std::wstring strFile ) 161 | { 162 | // https://www.codeproject.com/Articles/2890/Using-ListView-control-under-Win32-API 163 | memset( &LvItem, 0, sizeof( LvItem ) ); // Zero struct's Members 164 | LvItem.mask = LVIF_TEXT; // Text Style 165 | LvItem.cchTextMax = MAX_PATH; // Max size of text 166 | LvItem.iItem = uItem; // choose item 167 | 168 | // LvItem.iSubItem = COL_CHK; // Put in first coluom 169 | // LvItem.pszText = TEXT( "" ); 170 | // SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_INSERTITEM, 0, ( LPARAM )&LvItem ); 171 | 172 | LvItem.iSubItem = COL_I; // Put in second coluom 173 | LvItem.pszText = const_cast( strI.c_str() ); 174 | SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_INSERTITEM, 0, ( LPARAM )&LvItem ); 175 | 176 | LvItem.iSubItem = COL_W; // Put in third coluom 177 | LvItem.pszText = const_cast( strW.c_str() ); 178 | SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_SETITEM, 0, ( LPARAM )&LvItem ); 179 | 180 | LvItem.iSubItem = COL_FILE; // Put in fourth coluom 181 | LvItem.pszText = const_cast( strFile.c_str() ); 182 | SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_SETITEM, 0, ( LPARAM )&LvItem ); 183 | } 184 | 185 | std::vector DemoDlg::getListSelected(void) 186 | { 187 | std::vector selectedItems; 188 | int itemInt = -1; 189 | itemInt = ( int )::SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_GETNEXTITEM, itemInt, LVNI_SELECTED ); 190 | if ( itemInt == -1 ) 191 | return selectedItems; 192 | 193 | std::wstring wide = TEXT( "" ); 194 | if ( execCommand( TEXT( "git.exe rev-parse --show-toplevel" ), wide ) ) 195 | { 196 | wide.erase(std::remove(wide.begin(), wide.end(), '\n'), wide.end()); 197 | 198 | for (itemInt = -1; ( itemInt = ( int )::SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_GETNEXTITEM, itemInt, LVNI_SELECTED ) ) != -1; ) 199 | { 200 | TCHAR file[MAX_PATH] = {0}; 201 | 202 | memset( &LvItem, 0, sizeof(LvItem) ); 203 | LvItem.mask = LVIF_TEXT; 204 | LvItem.iSubItem = COL_FILE; 205 | LvItem.pszText = file; 206 | LvItem.cchTextMax = MAX_PATH; 207 | LvItem.iItem = itemInt; 208 | 209 | SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_GETITEMTEXT, itemInt, (LPARAM)&LvItem ); 210 | 211 | std::wstring tempPath = wide; 212 | tempPath += TEXT( "\\" ); 213 | tempPath += file; 214 | 215 | DWORD fileOrDir = GetFileAttributes( tempPath.c_str() ); 216 | if ( fileOrDir == INVALID_FILE_ATTRIBUTES ) 217 | { 218 | selectedItems = {}; 219 | return selectedItems; 220 | } 221 | 222 | for (unsigned int j = 0; j < tempPath.size(); j++) 223 | { 224 | if (tempPath[j] == '/') 225 | { 226 | tempPath[j] = '\\'; 227 | } 228 | } 229 | 230 | selectedItems.push_back( tempPath ); 231 | } 232 | } 233 | return selectedItems; 234 | } 235 | 236 | bool DemoDlg::execCommand( std::wstring command, std::wstring &wide ) 237 | { 238 | wide = TEXT( "" ); 239 | 240 | std::wstring pathName = TEXT( "" ); 241 | updateLoc( pathName ); 242 | if ( pathName.empty() ) 243 | return false; 244 | 245 | const TCHAR *programPath = TEXT( "\0" ); // Overridden as NULL in Process.cpp 246 | const TCHAR *pProgramDir = pathName.c_str(); 247 | const TCHAR *progInput = TEXT( "" ); 248 | const TCHAR *progOutput = TEXT( "" ); 249 | 250 | generic_string progInputStr = progInput ? progInput : TEXT( "" ); 251 | generic_string progOutputStr = progOutput ? progOutput : TEXT( "" ); 252 | generic_string paramInput = getGitLocation(); 253 | paramInput += command; 254 | 255 | if ( g_Debug ) 256 | OutputDebugString( paramInput.c_str() ); 257 | 258 | Process program( programPath, paramInput.c_str(), pProgramDir, CONSOLE_PROG ); 259 | program.run(); 260 | 261 | if ( !program.hasStderr() ) 262 | { 263 | const char *pOutput = NULL; 264 | size_t pOutputLen = 0; 265 | 266 | // If progOutput is defined, then we search the file to read 267 | if ( progOutputStr != TEXT( "" ) ) 268 | { 269 | if ( ::PathFileExists( progOutputStr.c_str() ) ) 270 | { 271 | // open the file for binary reading 272 | std::ifstream file; 273 | file.open( progOutputStr.c_str(), std::ios_base::binary ); 274 | std::vector fileContent; 275 | 276 | if ( file.is_open() ) 277 | { 278 | // get the length of the file 279 | file.seekg( 0, std::ios::end ); 280 | pOutputLen = static_cast( file.tellg() ); 281 | file.seekg( 0, std::ios::beg ); 282 | 283 | // create a vector to hold all the bytes in the file 284 | fileContent.resize( pOutputLen, 0 ); 285 | 286 | // read the file 287 | file.read( reinterpret_cast( &fileContent[0] ), ( std::streamsize )pOutputLen ); 288 | 289 | // close the file 290 | file.close(); 291 | 292 | pOutput = reinterpret_cast( &fileContent[0] ); 293 | } 294 | 295 | const char errMsg[] = "ERROR: NO FILE CONTENT"; 296 | 297 | if ( !pOutput || !( pOutput[0] ) ) 298 | { 299 | pOutput = errMsg; 300 | pOutputLen = strlen( errMsg ); 301 | } 302 | } 303 | else 304 | { 305 | ::MessageBox( NULL, TEXT( "The file is invalid" ), progOutputStr.c_str(), MB_OK ); 306 | wide = progOutputStr.c_str(); 307 | return false; 308 | } 309 | } 310 | // otherwise, we look in stdout 311 | else if ( program.hasStdout() ) 312 | { 313 | wide = program.getStdout(); 314 | return true; 315 | } 316 | } 317 | else 318 | { 319 | wide = program.getStderr(); 320 | return false; 321 | } 322 | return false; 323 | } 324 | 325 | void DemoDlg::updateListWithDelay() 326 | { 327 | if ( ! g_NppReady ) 328 | return; 329 | 330 | KillTimer( _hSelf, TIMER_ID ); 331 | SetTimer( _hSelf, TIMER_ID, g_LVDelay, NULL ); 332 | } 333 | 334 | void DemoDlg::updateList() 335 | { 336 | KillTimer( _hSelf, TIMER_ID ); 337 | 338 | if ( ! g_NppReady ) 339 | return; 340 | 341 | // HANDLE hThread = CreateThread(NULL, 0, _static_updateList, (void*) this, 0, NULL); 342 | // CloseHandle(hThread); 343 | _updateList(); 344 | } 345 | 346 | DWORD DemoDlg::_updateList() 347 | { 348 | // clear list 349 | SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_DELETEALLITEMS, 0, 0 ); 350 | 351 | std::wstring wide = TEXT( "" ); 352 | if ( execCommand( TEXT( "git.exe status --porcelain --branch" ), wide ) ) 353 | { 354 | std::vector splittedStrings = split( wide, TEXT( "\n" ) ); 355 | 356 | std::wstring strBranch = splittedStrings[0].erase(0, 3); 357 | SendMessage( GetDlgItem( _hSelf, IDC_EDT_BRANCH ), WM_SETTEXT, 0, ( LPARAM )strBranch.c_str() ); 358 | for ( unsigned int i = 1; i < splittedStrings.size() ; i++ ) 359 | { 360 | std::wstring strI = splittedStrings[i].substr(0, 1); 361 | std::wstring strW = splittedStrings[i].substr(1, 1); 362 | std::wstring strFile = splittedStrings[i].erase(0, 3); 363 | setListColumns( i-1, strI, strW, strFile ); 364 | } 365 | } 366 | else 367 | { 368 | SendMessage( GetDlgItem( _hSelf, IDC_EDT_BRANCH ), WM_SETTEXT, 0, ( LPARAM )wide.c_str() ); 369 | setListColumns( 0, TEXT( "" ), TEXT( "" ), TEXT( "" ) ); 370 | } 371 | 372 | return 0; 373 | } 374 | 375 | void DemoDlg::SetNppColors() 376 | { 377 | colorBg = ( COLORREF )::SendMessage( getCurScintilla(), SCI_STYLEGETBACK, 0, 0 ); 378 | colorFg = ( COLORREF )::SendMessage( getCurScintilla(), SCI_STYLEGETFORE, 0, 0 ); 379 | } 380 | 381 | void DemoDlg::SetSysColors() 382 | { 383 | colorBg = GetSysColor( COLOR_WINDOW ); 384 | colorFg = GetSysColor( COLOR_WINDOWTEXT ); 385 | } 386 | 387 | void DemoDlg::ChangeColors() 388 | { 389 | HWND hList = GetDlgItem( _hSelf, IDC_LSV1 ); 390 | 391 | ::SendMessage(hList, WM_SETREDRAW, FALSE, 0); 392 | 393 | ListView_SetBkColor( hList, colorBg ); 394 | ListView_SetTextBkColor( hList, colorBg); 395 | ListView_SetTextColor( hList, colorFg); 396 | 397 | ::SendMessage(hList, WM_SETREDRAW, TRUE, 0); 398 | ::RedrawWindow(hList, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN); 399 | } 400 | 401 | void DemoDlg::refreshDialog() 402 | { 403 | SendMessage( GetDlgItem( _hSelf, IDC_CHK_TORTOISE ), BM_SETCHECK, ( WPARAM )( g_useTortoise ? 1 : 0 ), 0 ); 404 | SendMessage( GetDlgItem( _hSelf, IDC_CHK_NPPCOLOR ), BM_SETCHECK, ( WPARAM )( g_useNppColors ? 1 : 0 ), 0 ); 405 | SendMessage( GetDlgItem( _hSelf, IDC_CHK_PANELTOGGLE ), BM_SETCHECK, ( WPARAM )( g_RaisePanel ? 1 : 0 ), 0 ); 406 | } 407 | 408 | void DemoDlg::initDialog() 409 | { 410 | INITCOMMONCONTROLSEX ic; 411 | 412 | ic.dwSize = sizeof( INITCOMMONCONTROLSEX ); 413 | ic.dwICC = ICC_BAR_CLASSES | ICC_PAGESCROLLER_CLASS; 414 | InitCommonControlsEx( &ic ); 415 | 416 | HWND hWndToolbar1, hWndToolbar2, hWndPager1, hWndPager2; 417 | HMODULE module_name = GetModuleHandle( _moduleName.c_str() ); 418 | 419 | // TOOLBAR1 420 | // Create pager. The parent window is the parent. 421 | hWndPager1 = CreateWindow( WC_PAGESCROLLER, NULL, WS_VISIBLE | WS_CHILD | PGS_HORZ, 422 | 0, 0, 200, 32, _hSelf, (HMENU) IDB_PAGER1, module_name, NULL ); 423 | // Create Toolbar. The parent window is the Pager. 424 | hWndToolbar1 = CreateWindowEx( 0, TOOLBARCLASSNAME, NULL, WS_TOOLBARSTYLE, 425 | 0, 0, 200, 32, hWndPager1, ( HMENU ) IDB_TOOLBAR1, module_name, NULL ); 426 | 427 | SendMessage( hWndToolbar1, TB_BUTTONSTRUCTSIZE, sizeof( TBBUTTON ), 0 ); 428 | SendMessage( hWndToolbar1, TB_SETEXTENDEDSTYLE, 0, ( LPARAM ) TBSTYLE_EX_HIDECLIPPEDBUTTONS | TBSTYLE_EX_DRAWDDARROWS ); 429 | SendMessage( hWndToolbar1, TB_ADDBUTTONS, sizeButtonArray1, ( LPARAM )tbButtonsAdd1 ); 430 | SendMessage( hWndToolbar1, TB_AUTOSIZE, 0, 0 ); 431 | // Notify the pager that it contains the toolbar 432 | SendMessage( hWndPager1, PGM_SETCHILD, 0, (LPARAM) hWndToolbar1 ); 433 | imageToolbar( module_name, hWndToolbar1, IDB_TOOLBAR1, numButtons1 ); 434 | 435 | // TOOLBAR2 436 | // Create pager. The parent window is the parent. 437 | hWndPager2 = CreateWindow( WC_PAGESCROLLER, NULL, WS_VISIBLE | WS_CHILD | PGS_HORZ, 438 | 0, 32, 200, 32, _hSelf, (HMENU) IDB_PAGER2, module_name, NULL ); 439 | // Create Toolbar. The parent window is the Pager. 440 | hWndToolbar2 = CreateWindowEx( 0, TOOLBARCLASSNAME, NULL, WS_TOOLBARSTYLE, 441 | 0, 0, 200, 32, hWndPager2, ( HMENU ) IDB_TOOLBAR2, module_name, NULL ); 442 | 443 | SendMessage( hWndToolbar2, TB_BUTTONSTRUCTSIZE, sizeof( TBBUTTON ), 0 ); 444 | SendMessage( hWndToolbar1, TB_SETEXTENDEDSTYLE, 0, ( LPARAM ) TBSTYLE_EX_HIDECLIPPEDBUTTONS | TBSTYLE_EX_DRAWDDARROWS ); 445 | SendMessage( hWndToolbar2, TB_ADDBUTTONS, sizeButtonArray2, ( LPARAM )tbButtonsAdd2 ); 446 | SendMessage( hWndToolbar2, TB_AUTOSIZE, 0, 0 ); 447 | // in CreateWindowEx() 448 | SendMessage( hWndPager2, PGM_SETCHILD, 0, (LPARAM) hWndToolbar2 ); 449 | imageToolbar( module_name, hWndToolbar2, IDB_TOOLBAR2, numButtons2 ); 450 | 451 | // Edit and List controls 452 | if ( g_useNppColors ) 453 | SetNppColors(); 454 | else 455 | SetSysColors(); 456 | ChangeColors(); 457 | refreshDialog(); 458 | 459 | HWND hList = GetDlgItem( _hSelf, IDC_LSV1 ); 460 | 461 | // https://www.codeproject.com/Articles/2890/Using-ListView-control-under-Win32-API 462 | SendMessage( hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ( LVS_EX_FULLROWSELECT /*| LVS_EX_CHECKBOXES*/ ) ); 463 | 464 | memset( &LvCol, 0, sizeof( LvCol ) ); // Zero Members 465 | LvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; // Type of mask 466 | 467 | // Column I and W are Index and Working from: 468 | // https://git-scm.com/docs/git-status 469 | // LvCol.cx = 25; // width between each coloum 470 | // LvCol.pszText = TEXT( "" ); // First Header Text 471 | // SendMessage( hList, LVM_INSERTCOLUMN, COL_CHK, ( LPARAM )&LvCol ); 472 | 473 | LvCol.cx = 25; // width between each coloum 474 | LvCol.pszText = TEXT( "I" ); // Second Header Text 475 | SendMessage( hList, LVM_INSERTCOLUMN, COL_I, ( LPARAM )&LvCol ); 476 | 477 | LvCol.cx = 25; // width between each coloum 478 | LvCol.pszText = TEXT( "W" ); // Third Header Text 479 | SendMessage( hList, LVM_INSERTCOLUMN, COL_W, ( LPARAM )&LvCol ); 480 | 481 | LvCol.cx = 25; // width of column 482 | LvCol.pszText = TEXT( "File" ); // Fourth Header Text 483 | SendMessage( hList, LVM_INSERTCOLUMN, COL_FILE, ( LPARAM )&LvCol ); 484 | 485 | SendMessage( hList, LVM_SETCOLUMNWIDTH, COL_FILE, LVSCW_AUTOSIZE_USEHEADER ); 486 | 487 | updateList(); 488 | } 489 | 490 | void DemoDlg::gotoFile() 491 | { 492 | std::vector files = getListSelected(); 493 | if ( files.size() == 0 ) 494 | return; 495 | 496 | for ( unsigned int i = 0; i < files.size(); i++ ) 497 | { 498 | DWORD fileOrDir = GetFileAttributes( files[i].c_str() ); 499 | if ( fileOrDir == INVALID_FILE_ATTRIBUTES ) 500 | return; 501 | else if ( fileOrDir & FILE_ATTRIBUTE_DIRECTORY ) 502 | { 503 | std::wstring err = TEXT( "" ); 504 | err += files[i]; 505 | err += TEXT( "\n\nIs a directory. Continue to open all files?" ); 506 | int ret = ( int )::MessageBox( _hSelf, err.c_str(), TEXT( "Continue?" ), ( MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2 | MB_APPLMODAL ) ); 507 | if ( ret == IDYES ) 508 | SendMessage( _hParent, NPPM_DOOPEN, 0, ( LPARAM )files[i].c_str() ); 509 | } 510 | else 511 | SendMessage( _hParent, NPPM_DOOPEN, 0, ( LPARAM )files[i].c_str() ); 512 | } 513 | } 514 | 515 | INT_PTR CALLBACK DemoDlg::run_dlgProc( UINT message, WPARAM wParam, LPARAM lParam ) 516 | { 517 | switch ( message ) 518 | { 519 | case WM_INITDIALOG : 520 | { 521 | initDialog(); 522 | break; 523 | } 524 | 525 | case WM_COMMAND : 526 | { 527 | switch ( wParam ) 528 | { 529 | case IDC_BTN_GITGUI : 530 | { 531 | gitGui(); 532 | return TRUE; 533 | } 534 | 535 | case IDC_BTN_GITK : 536 | { 537 | giTk(); 538 | return TRUE; 539 | } 540 | 541 | case IDC_BTN_PROMPT : 542 | { 543 | std::wstring pathName = TEXT( "" ); 544 | updateLoc( pathName ); 545 | ShellExecute( _hParent, TEXT("open"), g_GitPrompt, NULL, pathName.c_str(), SW_SHOW ); 546 | return TRUE; 547 | } 548 | 549 | case IDC_BTN_PULL : 550 | { 551 | pullFile(); 552 | return TRUE; 553 | } 554 | 555 | case IDC_BTN_STATUS : 556 | { 557 | statusAll(); 558 | return TRUE; 559 | } 560 | 561 | case IDC_BTN_COMMIT : 562 | { 563 | commitAll(); 564 | return TRUE; 565 | } 566 | 567 | case IDC_BTN_PUSH : 568 | { 569 | pushFile(); 570 | return TRUE; 571 | } 572 | 573 | case IDC_BTN_ADD : 574 | { 575 | std::vector files = getListSelected(); 576 | if ( files.size() == 0 ) 577 | addFile(); 578 | else 579 | addFileFiles( files ); 580 | updateListWithDelay(); 581 | return TRUE; 582 | } 583 | 584 | case IDC_BTN_UNSTAGE : 585 | { 586 | std::vector files = getListSelected(); 587 | if ( files.size() == 0 ) 588 | unstageFile(); 589 | else 590 | unstageFileFiles( files ); 591 | updateListWithDelay(); 592 | return TRUE; 593 | } 594 | 595 | case IDC_BTN_RESTORE : 596 | { 597 | std::vector files = getListSelected(); 598 | if ( files.size() == 0 ) 599 | restoreFile(); 600 | else 601 | restoreFileFiles( files ); 602 | updateListWithDelay(); 603 | return TRUE; 604 | } 605 | 606 | case IDC_BTN_DIFF : 607 | { 608 | std::vector files = getListSelected(); 609 | if ( files.size() == 0 ) 610 | diffFile(); 611 | else 612 | diffFileFiles( files ); 613 | return TRUE; 614 | } 615 | 616 | case IDC_BTN_LOG : 617 | { 618 | logFile(); 619 | return TRUE; 620 | } 621 | 622 | case IDC_BTN_BLAME : 623 | { 624 | blameFile(); 625 | return TRUE; 626 | } 627 | 628 | case IDB_BTN_BRANCH : 629 | { 630 | branchFile(); 631 | updateListWithDelay(); 632 | return TRUE; 633 | } 634 | 635 | case IDC_BTN_SETTINGS : 636 | { 637 | doSettings(); 638 | return TRUE; 639 | } 640 | 641 | case IDC_CHK_TORTOISE : 642 | { 643 | doTortoise(); 644 | return TRUE; 645 | } 646 | 647 | case IDC_CHK_NPPCOLOR: 648 | { 649 | int check = ( int )::SendMessage( GetDlgItem( _hSelf, IDC_CHK_NPPCOLOR ), BM_GETCHECK, 0, 0 ); 650 | 651 | if ( check & BST_CHECKED ) 652 | { 653 | SetNppColors(); 654 | g_useNppColors = true; 655 | } 656 | else 657 | { 658 | SetSysColors(); 659 | g_useNppColors = false; 660 | } 661 | 662 | ChangeColors(); 663 | refreshDialog(); 664 | return TRUE; 665 | } 666 | 667 | case IDC_CHK_PANELTOGGLE: 668 | { 669 | int check = ( int )::SendMessage( GetDlgItem( _hSelf, IDC_CHK_PANELTOGGLE ), BM_GETCHECK, 0, 0 ); 670 | 671 | if ( check & BST_CHECKED ) 672 | g_RaisePanel = true; 673 | else 674 | g_RaisePanel = false; 675 | return TRUE; 676 | } 677 | 678 | case IDB_BTN_GOTOREMOTE: 679 | { 680 | std::wstring wide = TEXT( "" ); 681 | if ( execCommand( TEXT( "git config --get remote.origin.url" ), wide ) ) 682 | { 683 | ShellExecute(_hSelf, TEXT("open"), wide.c_str(), NULL, NULL, SW_SHOWNORMAL); 684 | } 685 | return TRUE; 686 | } 687 | 688 | case MAKELONG( IDC_EDT_BRANCH, EN_SETFOCUS ) : 689 | case MAKELONG( IDC_EDT_DIR, EN_SETFOCUS ) : 690 | { 691 | updateListWithDelay(); 692 | return TRUE; 693 | } 694 | 695 | // Trap VK_ENTER in the LISTVIEW 696 | case IDOK : 697 | { 698 | HWND hWndCtrl = GetFocus(); 699 | if ( hWndCtrl == GetDlgItem( _hSelf, IDC_LSV1 ) ) 700 | gotoFile(); 701 | return TRUE; 702 | } 703 | // Trap VK_ESCAPE 704 | case IDCANCEL : 705 | { 706 | if ( _gitPanel.isFloating() ) 707 | { 708 | EndDialog(_hSelf, 0); 709 | _gitPanel.display(false); 710 | } 711 | else 712 | ::SetFocus( getCurScintilla() ); 713 | 714 | return TRUE; 715 | } 716 | } 717 | break; 718 | } 719 | 720 | case WM_TIMER: 721 | { 722 | KillTimer( _hSelf, TIMER_ID ); 723 | updateList(); 724 | return FALSE; 725 | } 726 | 727 | case WM_NOTIFY: 728 | { 729 | LPNMHDR nmhdr = (LPNMHDR)lParam; 730 | 731 | switch ( nmhdr->code ) 732 | { 733 | case NM_DBLCLK: 734 | { 735 | if ( nmhdr->hwndFrom == GetDlgItem( _hSelf, IDC_LSV1 ) ) 736 | { 737 | POINT pt = {0}; 738 | LVHITTESTINFO ht = {0}; 739 | DWORD dwpos = ::GetMessagePos(); 740 | 741 | pt.x = GET_X_LPARAM(dwpos); 742 | pt.y = GET_Y_LPARAM(dwpos); 743 | 744 | ht.pt = pt; 745 | ::ScreenToClient( GetDlgItem( _hSelf, IDC_LSV1 ), &ht.pt); 746 | 747 | ListView_SubItemHitTest( GetDlgItem( _hSelf, IDC_LSV1 ), &ht); 748 | if ( ht.iItem == -1 ) 749 | break; 750 | 751 | std::vector files = getListSelected(); 752 | if ( files.size() == 0 ) 753 | break; 754 | 755 | if ( ht.iSubItem == COL_I ) 756 | { 757 | unstageFileFiles( files ); 758 | updateListWithDelay(); 759 | } 760 | else if ( ht.iSubItem == COL_W ) 761 | { 762 | addFileFiles( files ); 763 | updateListWithDelay(); 764 | } 765 | else if ( ht.iSubItem == COL_FILE ) 766 | { 767 | for ( unsigned int i = 0; i < files.size(); i++ ) 768 | { 769 | DWORD fileOrDir = GetFileAttributes( files[i].c_str() ); 770 | if ( fileOrDir == INVALID_FILE_ATTRIBUTES ) 771 | break; 772 | else if ( fileOrDir & FILE_ATTRIBUTE_DIRECTORY ) 773 | { 774 | std::wstring err = TEXT( "" ); 775 | err += files[i]; 776 | err += TEXT( "\n\nIs a directory. Continue to open all files?" ); 777 | int ret = ( int )::MessageBox( _hSelf, err.c_str(), TEXT( "Continue?" ), ( MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2 | MB_APPLMODAL ) ); 778 | if ( ret == IDYES ) 779 | SendMessage( _hParent, NPPM_DOOPEN, 0, ( LPARAM )files[i].c_str() ); 780 | } 781 | else 782 | SendMessage( _hParent, NPPM_DOOPEN, 0, ( LPARAM )files[i].c_str() ); 783 | } 784 | } 785 | return TRUE; 786 | } 787 | break; 788 | } 789 | 790 | case NM_RCLICK: 791 | { 792 | if ( nmhdr->hwndFrom == GetDlgItem( _hSelf, IDC_LSV1 ) ) 793 | { 794 | POINT pt = {0}; 795 | LVHITTESTINFO ht = {0}; 796 | DWORD dwpos = ::GetMessagePos(); 797 | 798 | pt.x = GET_X_LPARAM(dwpos); 799 | pt.y = GET_Y_LPARAM(dwpos); 800 | 801 | ContextMenu cm; 802 | std::vector files = getListSelected(); 803 | if ( files.size() == 0 ) 804 | break; 805 | 806 | cm.SetObjects( files ); 807 | cm.ShowContextMenu( _hInst, _hParent, _hSelf, pt ); 808 | return TRUE; 809 | } 810 | break; 811 | } 812 | 813 | case TTN_GETDISPINFO: /* TTN_NEEDTEXT */ 814 | { 815 | UINT_PTR idButton; 816 | LPTOOLTIPTEXT lpttt; 817 | 818 | lpttt = (LPTOOLTIPTEXT) lParam; 819 | lpttt->hinst = NULL; 820 | idButton = lpttt->hdr.idFrom; 821 | lpttt->lpszText = const_cast( GetNameStrFromCmd( idButton ) ); 822 | return TRUE; 823 | } 824 | case LVN_KEYDOWN: 825 | { 826 | LPNMLVKEYDOWN pnkd = (LPNMLVKEYDOWN) lParam; 827 | if ( ( nmhdr->hwndFrom == GetDlgItem( _hSelf, IDC_LSV1 ) ) && 828 | ( ( pnkd->wVKey == VK_RETURN ) 829 | || ( pnkd->wVKey == VK_SPACE ) 830 | ) ) 831 | { 832 | gotoFile(); 833 | return TRUE; 834 | } 835 | break; 836 | } 837 | 838 | default : 839 | break; 840 | } 841 | 842 | DockingDlgInterface::run_dlgProc( message, wParam, lParam ); 843 | return FALSE; 844 | } 845 | 846 | case WM_SIZE: 847 | case WM_MOVE: 848 | { 849 | RECT rc = {0}; 850 | getClientRect( rc ); 851 | 852 | ::SetWindowPos( GetDlgItem( _hSelf, IDC_EDT_BRANCH ), NULL, 853 | rc.left + 5, rc.top + 120, rc.right - 75, 20, 854 | SWP_NOZORDER | SWP_SHOWWINDOW ); 855 | ::SetWindowPos( GetDlgItem( _hSelf, IDB_BTN_BRANCH ), NULL, 856 | rc.right - 65, rc.top + 120, 60, 20, 857 | SWP_NOZORDER | SWP_SHOWWINDOW ); 858 | ::SetWindowPos( GetDlgItem( _hSelf, IDC_EDT_DIR ), NULL, 859 | rc.left + 5, rc.top + 150, rc.right - 10, 20, 860 | SWP_NOZORDER | SWP_SHOWWINDOW ); 861 | ::SetWindowPos( GetDlgItem( _hSelf, IDC_LSV1 ), NULL, 862 | rc.left + 5, rc.top + 180, rc.right - 10, rc.bottom - 185, 863 | SWP_NOZORDER | SWP_SHOWWINDOW ); 864 | 865 | SendMessage( GetDlgItem( _hSelf, IDC_LSV1 ), LVM_SETCOLUMNWIDTH, COL_FILE, LVSCW_AUTOSIZE_USEHEADER ); 866 | 867 | // redraw(); 868 | break; 869 | } 870 | 871 | case WM_PAINT: 872 | { 873 | ::RedrawWindow( _hSelf, NULL, NULL, TRUE ); 874 | break; 875 | } 876 | 877 | default : 878 | return DockingDlgInterface::run_dlgProc( message, wParam, lParam ); 879 | } 880 | 881 | return FALSE; 882 | } 883 | -------------------------------------------------------------------------------- /DockingFeature/GitPanelDlg.h: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO ( donho@altern.org ) 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #ifndef GITPANEL_DLG_H 19 | #define GITPANEL_DLG_H 20 | 21 | #include 22 | #include 23 | 24 | #include "DockingDlgInterface.h" 25 | #include "..\PluginDefinition.h" 26 | #include "resource.h" 27 | 28 | typedef std::basic_string generic_string; 29 | 30 | class DemoDlg : public DockingDlgInterface 31 | { 32 | public : 33 | DemoDlg() : DockingDlgInterface( IDD_PLUGINGITPANEL ) {}; 34 | 35 | virtual void display(bool toShow = true) const { 36 | DockingDlgInterface::display(toShow); 37 | }; 38 | 39 | void setParent(HWND parent2set){ 40 | _hParent = parent2set; 41 | }; 42 | 43 | bool updateLoc( std::wstring &loc ); 44 | void updateListWithDelay(); 45 | void updateList(); 46 | 47 | bool isFloating() const { 48 | return _isFloating; 49 | }; 50 | 51 | protected : 52 | virtual INT_PTR CALLBACK run_dlgProc( UINT message, WPARAM wParam, LPARAM lParam ); 53 | 54 | private : 55 | static DWORD WINAPI _static_updateList(void* Param) 56 | { 57 | DemoDlg* This = (DemoDlg*) Param; 58 | return This->_updateList(); 59 | } 60 | DWORD _updateList(); 61 | 62 | std::vector split( std::wstring stringToBeSplitted, std::wstring delimeter ); 63 | void setListColumns( unsigned int uItem, std::wstring strI, std::wstring strW, std::wstring strFile ); 64 | std::vector getListSelected(); 65 | bool execCommand( std::wstring, std::wstring &wide ); 66 | void SetNppColors(); 67 | void SetSysColors(); 68 | void ChangeColors(); 69 | void refreshDialog(); 70 | void initDialog(); 71 | void gotoFile(); 72 | }; 73 | 74 | #endif //GITPANEL_DLG_H 75 | -------------------------------------------------------------------------------- /DockingFeature/Process.cpp: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #include "../PluginInterface.h" 19 | #include "Process.h" 20 | #include 21 | 22 | extern NppData nppData; 23 | 24 | void systemMessage(const TCHAR *title) { 25 | LPVOID lpMsgBuf; 26 | FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 27 | NULL, 28 | ::GetLastError(), 29 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 30 | (LPTSTR) &lpMsgBuf, 31 | 0, 32 | NULL );// Process any inserts in lpMsgBuf. 33 | MessageBox( nppData._nppHandle, (LPTSTR)lpMsgBuf, title, MB_OK | MB_ICONSTOP); 34 | ::LocalFree(lpMsgBuf); 35 | }; 36 | 37 | BOOL Process::run() 38 | { 39 | BOOL result = TRUE; 40 | 41 | // stdout & stderr pipes for process to write 42 | HANDLE hPipeOutW = NULL; 43 | HANDLE hPipeErrW = NULL; 44 | 45 | HANDLE hListenerStdOutThread = NULL; 46 | HANDLE hListenerStdErrThread = NULL; 47 | 48 | HANDLE hWaitForProcessEndThread = NULL; 49 | 50 | HANDLE hListenerEvent[2]; 51 | hListenerEvent[0] = NULL; 52 | hListenerEvent[1] = NULL; 53 | 54 | SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; // inheritable handle 55 | 56 | try { 57 | // Create stdout pipe 58 | if (!::CreatePipe(&_hPipeOutR, &hPipeOutW, &sa, 0)) 59 | error(TEXT("CreatePipe"), result, 1000); 60 | 61 | // Create stderr pipe 62 | if (!::CreatePipe(&_hPipeErrR, &hPipeErrW, &sa, 0)) 63 | error(TEXT("CreatePipe"), result, 1001); 64 | 65 | STARTUPINFO startup; 66 | PROCESS_INFORMATION procinfo; 67 | ::ZeroMemory(&startup, sizeof(startup)); 68 | startup.cb = sizeof(startup); 69 | startup.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; 70 | startup.wShowWindow = (_type == WIN32_PROG)?SW_SHOW:SW_HIDE; // hidden console window 71 | startup.hStdInput = NULL; // not used 72 | startup.hStdOutput = hPipeOutW; 73 | startup.hStdError = hPipeErrW; 74 | 75 | //generic_string cmd = TEXT("\""); 76 | //cmd += _command; 77 | //cmd += TEXT("\""); 78 | /* 79 | generic_string cmdArg = cmd; 80 | if (_args[0]) 81 | { 82 | cmdArg += TEXT(" "); 83 | cmdArg += _args; 84 | } 85 | */ 86 | //TCHAR *args = TEXT("java -classpath C:/Users/Don/source/nppRelated/mime/zip.base64;C:/Users/Don/source/nppRelated/mime/zip.base64/commons-codec-1.4.jar zipB64 -zip"); 87 | //TCHAR *pArgs = new TCHAR[_args.length()+1]; 88 | //lstrcpy(pArgs, _args.c_str()); 89 | //::MessageBox(NULL, cmd.c_str(), TEXT("cmd"), MB_OK); 90 | //::MessageBox(NULL, _args.c_str(), TEXT("_args"), MB_OK); 91 | BOOL started = ::CreateProcess( 92 | // _command.c_str(), //TEXT("C:\\Program Files\\Mozilla Firefox\\firefox.exe"), // command is part of input string 93 | NULL, 94 | (TCHAR *)_args.c_str(), // (writeable) command string 95 | NULL, // process security 96 | NULL, // thread security 97 | TRUE, // inherit handles flag 98 | (_type == WIN32_PROG)?NULL:CREATE_SUSPENDED, // flags 99 | NULL, // inherit environment 100 | _curDir.c_str(), // inherit directory 101 | &startup, // STARTUPINFO 102 | &procinfo); // PROCESS_INFORMATION 103 | 104 | _hProcess = procinfo.hProcess; 105 | _hProcessThread = procinfo.hThread; 106 | 107 | if(!started) 108 | error(TEXT("CreateProcess"), result, 1002); 109 | 110 | if (_type == CONSOLE_PROG) 111 | { 112 | hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerEvent")); 113 | if(!hListenerEvent[0]) 114 | error(TEXT("CreateEvent"), result, 1003); 115 | 116 | hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerStdErrEvent")); 117 | if(!hListenerEvent[1]) 118 | error(TEXT("CreateEvent"), result, 1004); 119 | 120 | 121 | // The process is running so we set this to FALSE 122 | _bProcessEnd = FALSE; 123 | 124 | hWaitForProcessEndThread = ::CreateThread(NULL, 0, staticWaitForProcessEnd, this, 0, NULL); 125 | if (!hWaitForProcessEndThread) 126 | error(TEXT("CreateThread"), result, 1005); 127 | 128 | hListenerStdOutThread = ::CreateThread(NULL, 0, staticListenerStdOut, this, 0, NULL); 129 | if (!hListenerStdOutThread) 130 | error(TEXT("CreateThread"), result, 1006); 131 | 132 | hListenerStdErrThread = ::CreateThread(NULL, 0, staticListenerStdErr, this, 0, NULL); 133 | if (!hListenerStdErrThread) 134 | error(TEXT("CreateThread"), result, 1007); 135 | 136 | // We wait until the process is over 137 | // TO DO: This should be a bit secured in case something happen and the 138 | // _bProcessEnd variable never gets set to TRUE... (by checking process 139 | // state as well for instance to see if it is still running...) 140 | while (!_bProcessEnd) 141 | { 142 | MSG msg; 143 | while( ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE)) 144 | { 145 | if( msg.message == WM_QUIT) 146 | { 147 | ::PostQuitMessage(0); 148 | // We do not exit but simply break in order to close 149 | // handles properly 150 | _bProcessEnd = TRUE; 151 | break; 152 | } 153 | else 154 | { 155 | ::TranslateMessage( &msg); 156 | ::DispatchMessage( &msg); 157 | } 158 | } 159 | } 160 | } 161 | } catch (int coderr){ 162 | TCHAR str[10]; 163 | wsprintf(str, TEXT("%d"), coderr); 164 | ::MessageBox(nppData._nppHandle, str, TEXT("Exception :"), MB_OK); 165 | } 166 | 167 | // on va fermer toutes les handles 168 | if (hPipeOutW) 169 | ::CloseHandle(hPipeOutW); 170 | if (hPipeErrW) 171 | ::CloseHandle(hPipeErrW); 172 | if (_hPipeOutR) 173 | ::CloseHandle(_hPipeOutR); 174 | if (_hPipeErrR) 175 | ::CloseHandle(_hPipeErrR); 176 | if (hListenerStdOutThread) 177 | ::CloseHandle(hListenerStdOutThread); 178 | if (hListenerStdErrThread) 179 | ::CloseHandle(hListenerStdErrThread); 180 | if (hWaitForProcessEndThread) 181 | ::CloseHandle(hWaitForProcessEndThread); 182 | if (hListenerEvent[0]) 183 | ::CloseHandle(hListenerEvent[0]); 184 | if (hListenerEvent[1]) 185 | ::CloseHandle(hListenerEvent[1]); 186 | 187 | return result; 188 | } 189 | 190 | 191 | #define MAX_LINE_LENGTH 1024 192 | 193 | void Process::listenerStdOut() 194 | { 195 | //BOOL Result = 0; 196 | //DWORD size = 0; 197 | DWORD bytesAvail = 0; 198 | BOOL result = 0; 199 | HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerEvent")); 200 | //FILE *fp = NULL; 201 | 202 | int taille = 0; 203 | char bufferOut[MAX_LINE_LENGTH + 1]; 204 | //TCHAR bufferErr[MAX_LINE_LENGTH + 1]; 205 | 206 | int nExitCode = STILL_ACTIVE; 207 | 208 | DWORD outbytesRead; 209 | 210 | ::ResumeThread(_hProcessThread); 211 | 212 | for(;;) 213 | { // got data 214 | memset(bufferOut, 0x00, MAX_LINE_LENGTH + 1); 215 | //memset(bufferErr,0x00,MAX_LINE_LENGTH + 1); 216 | taille = sizeof(bufferOut) - sizeof(char); 217 | 218 | Sleep(50); 219 | 220 | if (!::PeekNamedPipe(_hPipeOutR, bufferOut, taille, &outbytesRead, &bytesAvail, NULL)) 221 | { 222 | bytesAvail = 0; 223 | break; 224 | } 225 | 226 | if(outbytesRead) 227 | { 228 | result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL); 229 | if ((!result) && (outbytesRead == 0)) 230 | break; 231 | } 232 | //outbytesRead = lstrlen(bufferOut); 233 | bufferOut[outbytesRead] = '\0'; 234 | #ifdef UNICODE 235 | std::string inputA = bufferOut; 236 | std::wstring s(inputA.begin(), inputA.end()); 237 | s.assign(inputA.begin(), inputA.end()); 238 | 239 | #else 240 | std::string s = bufferOut; 241 | #endif 242 | _stdoutStr += s; 243 | 244 | if (::GetExitCodeProcess(_hProcess, (unsigned long*)&nExitCode)) 245 | { 246 | if (nExitCode != STILL_ACTIVE) 247 | break; // EOF condition 248 | } 249 | //else 250 | //break; 251 | } 252 | _exitCode = nExitCode; 253 | 254 | if(!::SetEvent(hListenerEvent)) 255 | { 256 | systemMessage(TEXT("Thread listenerStdOut")); 257 | } 258 | } 259 | 260 | void Process::listenerStdErr() 261 | { 262 | DWORD bytesAvail = 0; 263 | BOOL result = 0; 264 | HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent")); 265 | 266 | int taille = 0; 267 | char bufferErr[MAX_LINE_LENGTH + 1]; 268 | //TCHAR bufferErr[MAX_LINE_LENGTH + 1]; 269 | 270 | int nExitCode = STILL_ACTIVE; 271 | 272 | DWORD errbytesRead; 273 | 274 | ::ResumeThread(_hProcessThread); 275 | 276 | for(;;) 277 | { // got data 278 | memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1); 279 | taille = sizeof(bufferErr) - sizeof(TCHAR); 280 | 281 | Sleep(50); 282 | 283 | if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL)) 284 | { 285 | bytesAvail = 0; 286 | break; 287 | } 288 | 289 | if(errbytesRead) 290 | { 291 | result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL); 292 | if ((!result) && (errbytesRead == 0)) 293 | break; 294 | } 295 | bufferErr[errbytesRead] = '\0'; 296 | // generic_string s; 297 | // s.assign(bufferErr); 298 | #ifdef UNICODE 299 | std::string inputA = bufferErr; 300 | std::wstring s(inputA.begin(), inputA.end()); 301 | s.assign(inputA.begin(), inputA.end()); 302 | #else 303 | std::string s = bufferOut; 304 | #endif 305 | _stderrStr += s; 306 | 307 | if (::GetExitCodeProcess(_hProcess, (unsigned long*)&nExitCode)) 308 | { 309 | if (nExitCode != STILL_ACTIVE) 310 | break; // EOF condition 311 | } 312 | } 313 | 314 | if(!::SetEvent(hListenerEvent)) 315 | { 316 | systemMessage(TEXT("Thread stdout listener")); 317 | } 318 | } 319 | 320 | void Process::waitForProcessEnd() 321 | { 322 | HANDLE hListenerEvent[2]; 323 | hListenerEvent[0] = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerEvent")); 324 | hListenerEvent[1] = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent")); 325 | 326 | ::WaitForSingleObject(_hProcess, INFINITE); 327 | ::WaitForMultipleObjects(2, hListenerEvent, TRUE, INFINITE); 328 | 329 | _bProcessEnd = TRUE; 330 | } 331 | 332 | void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode) 333 | { 334 | systemMessage(txt2display); 335 | returnCode = FALSE; 336 | throw int(errCode); 337 | } 338 | -------------------------------------------------------------------------------- /DockingFeature/Process.h: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO ( donho@altern.org ) 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #ifndef PROCESSUS_H 19 | #define PROCESSUS_H 20 | 21 | #include 22 | #include 23 | 24 | typedef std::basic_string generic_string; 25 | 26 | enum progType {WIN32_PROG, CONSOLE_PROG}; 27 | 28 | 29 | class Process 30 | { 31 | public: 32 | Process(progType pt = WIN32_PROG) : _type(pt) {}; 33 | Process(const TCHAR *cmd, const TCHAR *args, const TCHAR *cDir, progType pt = WIN32_PROG) 34 | : _type(pt), _stdoutStr(TEXT("")), _stderrStr(TEXT("")), _hPipeOutR(NULL), 35 | _hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL), 36 | _command(cmd), _args(args), _curDir(cDir), _bProcessEnd(TRUE) 37 | {}; 38 | 39 | BOOL run(); 40 | 41 | const TCHAR * getStdout() const { 42 | return _stdoutStr.c_str(); 43 | }; 44 | 45 | const TCHAR * getStderr() const { 46 | return _stderrStr.c_str(); 47 | }; 48 | 49 | int getExitCode() const { 50 | return _exitCode; 51 | }; 52 | 53 | bool hasStdout() { 54 | return (_stdoutStr.compare(TEXT("")) != 0); 55 | }; 56 | 57 | bool hasStderr() { 58 | return (_stderrStr.compare(TEXT("")) != 0); 59 | }; 60 | 61 | protected: 62 | progType _type; 63 | 64 | // LES ENTREES 65 | generic_string _command; 66 | generic_string _args; 67 | generic_string _curDir; 68 | 69 | // LES SORTIES 70 | generic_string _stdoutStr; 71 | generic_string _stderrStr; 72 | int _exitCode; 73 | 74 | // LES HANDLES 75 | HANDLE _hPipeOutR; 76 | HANDLE _hPipeErrR; 77 | HANDLE _hProcess; 78 | HANDLE _hProcessThread; 79 | 80 | BOOL _bProcessEnd; 81 | 82 | //UINT _pid; // process ID assigned by caller 83 | 84 | static DWORD WINAPI staticListenerStdOut(void * myself){ 85 | ((Process *)myself)->listenerStdOut(); 86 | return 0; 87 | }; 88 | static DWORD WINAPI staticListenerStdErr(void * myself) { 89 | ((Process *)myself)->listenerStdErr(); 90 | return 0; 91 | }; 92 | static DWORD WINAPI staticWaitForProcessEnd(void * myself) { 93 | ((Process *)myself)->waitForProcessEnd(); 94 | return 0; 95 | }; 96 | 97 | void listenerStdOut(); 98 | void listenerStdErr(); 99 | void waitForProcessEnd(); 100 | 101 | void error(const TCHAR *txt2display, BOOL & returnCode, int errCode); 102 | }; 103 | 104 | #endif //PROCESSUS_H 105 | -------------------------------------------------------------------------------- /DockingFeature/SettingsDlg.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "..\PluginInterface.h" 6 | #include "GitPanelDlg.h" 7 | #include "SettingsDlg.h" 8 | #include "resource.h" 9 | #include "..\resource.h" 10 | 11 | extern HINSTANCE g_hInst; 12 | extern NppData nppData; 13 | extern TCHAR g_GitPath[MAX_PATH]; 14 | extern TCHAR g_GitPrompt[MAX_PATH]; 15 | extern bool g_RefScnFocus; 16 | extern bool g_DiffWordDiff; 17 | extern bool g_gitGuiBlame; 18 | 19 | static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData) 20 | { 21 | if (uMsg == BFFM_INITIALIZED) 22 | ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData); 23 | return 0; 24 | }; 25 | 26 | INT_PTR CALLBACK SettingsDlg( HWND hWndDlg, UINT msg, WPARAM wParam, 27 | LPARAM lParam ) 28 | { 29 | 30 | switch(msg) 31 | { 32 | case WM_INITDIALOG: 33 | { 34 | SendMessage( GetDlgItem( hWndDlg, IDC_EDT_GITPATH ), WM_SETTEXT, 0, ( LPARAM )g_GitPath ); 35 | SendMessage( GetDlgItem( hWndDlg, IDC_EDT_GITPROMPT ), WM_SETTEXT, 0, ( LPARAM )g_GitPrompt ); 36 | SendMessage( GetDlgItem( hWndDlg, IDC_CHK_SCNFOCUS ), BM_SETCHECK, ( LPARAM )( g_RefScnFocus ? 1 : 0 ), 0 ); 37 | SendMessage( GetDlgItem( hWndDlg, IDC_CHK_WORDDIFF ), BM_SETCHECK, ( LPARAM )( g_DiffWordDiff ? 1 : 0 ), 0 ); 38 | SendMessage( GetDlgItem( hWndDlg, IDC_CHK_GITGUIBLAME), BM_SETCHECK, ( LPARAM )( g_gitGuiBlame ? 1 : 0), 0); 39 | 40 | std::string version; 41 | version = ""; 42 | version += VER_STRING; 43 | version += ""; 44 | SetDlgItemTextA(hWndDlg, IDC_STC_VER, version.c_str()); 45 | 46 | return TRUE; 47 | } 48 | 49 | case WM_CLOSE: 50 | { 51 | PostMessage(hWndDlg, WM_DESTROY, 0, 0); 52 | return TRUE; 53 | } 54 | 55 | case WM_DESTROY: 56 | { 57 | EndDialog(hWndDlg, 0); 58 | return TRUE; 59 | } 60 | 61 | case WM_NOTIFY: 62 | { 63 | switch (((LPNMHDR)lParam)->code) 64 | { 65 | case NM_CLICK: 66 | case NM_RETURN: 67 | { 68 | PNMLINK pNMLink = (PNMLINK)lParam; 69 | LITEM item = pNMLink->item; 70 | HWND ver = GetDlgItem( hWndDlg, IDC_STC_VER ); 71 | 72 | if ((((LPNMHDR)lParam)->hwndFrom == ver) && (item.iLink == 0)) 73 | ShellExecute(hWndDlg, TEXT("open"), TEXT("https://github.com/VinsWorldcom/nppGitSCM"), NULL, NULL, SW_SHOWNORMAL); 74 | 75 | return TRUE; 76 | } 77 | } 78 | break; 79 | } 80 | 81 | case WM_COMMAND: 82 | { 83 | switch (LOWORD(wParam)) 84 | { 85 | case IDB_OK: 86 | SendMessage( GetDlgItem( hWndDlg, IDC_EDT_GITPATH ), WM_GETTEXT, ( MAX_PATH - 1 ), ( LPARAM ) g_GitPath ); 87 | SendMessage( GetDlgItem( hWndDlg, IDC_EDT_GITPROMPT ), WM_GETTEXT, ( MAX_PATH - 1 ), ( LPARAM ) g_GitPrompt ); 88 | PostMessage(hWndDlg, WM_CLOSE, 0, 0); 89 | return TRUE; 90 | 91 | case IDC_BTN_GITPATH : 92 | { 93 | // From: 94 | // npp-explorer-plugin\Explorer\src\OptionDlg\OptionDialog.cpp 95 | LPMALLOC pShellMalloc = 0; 96 | if (::SHGetMalloc(&pShellMalloc) == NO_ERROR) 97 | { 98 | // If we were able to get the shell malloc object, 99 | // then proceed by initializing the BROWSEINFO stuct 100 | BROWSEINFO info; 101 | ZeroMemory(&info, sizeof(info)); 102 | info.hwndOwner = nppData._nppHandle; 103 | info.pidlRoot = NULL; 104 | info.pszDisplayName = (LPTSTR)new TCHAR[MAX_PATH]; 105 | info.lpszTitle = TEXT( "Folder where git.exe is installed" ); 106 | info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON; 107 | info.lpfn = BrowseCallbackProc; 108 | info.lParam = (LPARAM)g_GitPath; 109 | 110 | // Execute the browsing dialog. 111 | LPITEMIDLIST pidl = ::SHBrowseForFolder(&info); 112 | 113 | // pidl will be null if they cancel the browse dialog. 114 | // pidl will be not null when they select a folder. 115 | if (pidl) 116 | { 117 | // Try to convert the pidl to a display string. 118 | // Return is true if success. 119 | // if ( 120 | ::SHGetPathFromIDList( pidl, g_GitPath ); 121 | SendMessage( GetDlgItem( hWndDlg, IDC_EDT_GITPATH ), WM_SETTEXT, 0, ( LPARAM )g_GitPath ); 122 | // ) 123 | // { 124 | // Set edit control to the directory path. 125 | // ::SetWindowText(::GetDlgItem(hDialog, IDC_EDT_DIR), g_GitPath); 126 | // } 127 | pShellMalloc->Free(pidl); 128 | } 129 | pShellMalloc->Release(); 130 | delete [] info.pszDisplayName; 131 | } 132 | return TRUE; 133 | } 134 | 135 | case IDC_CHK_SCNFOCUS: 136 | { 137 | int check = ( int )::SendMessage( GetDlgItem( hWndDlg, IDC_CHK_SCNFOCUS ), 138 | BM_GETCHECK, 0, 0 ); 139 | 140 | if ( check & BST_CHECKED ) 141 | g_RefScnFocus = true; 142 | else 143 | g_RefScnFocus = false; 144 | return TRUE; 145 | } 146 | 147 | case IDC_CHK_WORDDIFF: 148 | { 149 | int check = ( int )::SendMessage( GetDlgItem( hWndDlg, IDC_CHK_WORDDIFF ), 150 | BM_GETCHECK, 0, 0 ); 151 | 152 | if ( check & BST_CHECKED ) 153 | g_DiffWordDiff = true; 154 | else 155 | g_DiffWordDiff = false; 156 | return TRUE; 157 | } 158 | 159 | case IDC_CHK_GITGUIBLAME: 160 | { 161 | int check = (int)::SendMessage(GetDlgItem(hWndDlg, IDC_CHK_GITGUIBLAME), 162 | BM_GETCHECK, 0, 0); 163 | 164 | if (check & BST_CHECKED) 165 | g_gitGuiBlame = true; 166 | else 167 | g_gitGuiBlame = false; 168 | return TRUE; 169 | } 170 | 171 | case IDCANCEL : 172 | { 173 | EndDialog(hWndDlg, 0); 174 | return TRUE; 175 | } 176 | } 177 | } 178 | } 179 | return FALSE; 180 | } 181 | 182 | void doSettings() 183 | { 184 | DialogBoxParam( g_hInst, MAKEINTRESOURCE( IDD_SETTINGS ), nppData._nppHandle, SettingsDlg, 0 ); 185 | } 186 | -------------------------------------------------------------------------------- /DockingFeature/SettingsDlg.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTINGSDLG_H_ 2 | #define SETTINGSDLG_H 3 | 4 | void doSettings(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /DockingFeature/StaticDialog.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2021 Don HO 3 | 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // at your option any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | #include 18 | #include 19 | #include 20 | #include "StaticDialog.h" 21 | 22 | StaticDialog::~StaticDialog() 23 | { 24 | if (isCreated()) 25 | { 26 | // Prevent run_dlgProc from doing anything, since its virtual 27 | ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, NULL); 28 | destroy(); 29 | } 30 | } 31 | 32 | void StaticDialog::destroy() 33 | { 34 | ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast(_hSelf)); 35 | ::DestroyWindow(_hSelf); 36 | } 37 | 38 | POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const 39 | { 40 | RECT rc; 41 | ::GetWindowRect(hwnd, &rc); 42 | 43 | POINT p; 44 | if (isLeft) 45 | p.x = rc.left; 46 | else 47 | p.x = rc.right; 48 | 49 | p.y = rc.top; 50 | ::ScreenToClient(_hSelf, &p); 51 | return p; 52 | } 53 | 54 | void StaticDialog::goToCenter() 55 | { 56 | RECT rc; 57 | ::GetClientRect(_hParent, &rc); 58 | POINT center; 59 | center.x = rc.left + (rc.right - rc.left)/2; 60 | center.y = rc.top + (rc.bottom - rc.top)/2; 61 | ::ClientToScreen(_hParent, ¢er); 62 | 63 | int x = center.x - (_rc.right - _rc.left)/2; 64 | int y = center.y - (_rc.bottom - _rc.top)/2; 65 | 66 | ::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW); 67 | } 68 | 69 | void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing) const 70 | { 71 | if (toShow) 72 | { 73 | if (enhancedPositioningCheckWhenShowing) 74 | { 75 | RECT testPositionRc, candidateRc; 76 | 77 | getWindowRect(testPositionRc); 78 | 79 | candidateRc = getViewablePositionRect(testPositionRc); 80 | 81 | if ((testPositionRc.left != candidateRc.left) || (testPositionRc.top != candidateRc.top)) 82 | { 83 | ::MoveWindow(_hSelf, candidateRc.left, candidateRc.top, 84 | candidateRc.right - candidateRc.left, candidateRc.bottom - candidateRc.top, TRUE); 85 | } 86 | } 87 | else 88 | { 89 | // If the user has switched from a dual monitor to a single monitor since we last 90 | // displayed the dialog, then ensure that it's still visible on the single monitor. 91 | RECT workAreaRect = { 0 }; 92 | RECT rc = { 0 }; 93 | ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0); 94 | ::GetWindowRect(_hSelf, &rc); 95 | int newLeft = rc.left; 96 | int newTop = rc.top; 97 | int margin = ::GetSystemMetrics(SM_CYSMCAPTION); 98 | 99 | if (newLeft > ::GetSystemMetrics(SM_CXVIRTUALSCREEN) - margin) 100 | newLeft -= rc.right - workAreaRect.right; 101 | if (newLeft + (rc.right - rc.left) < ::GetSystemMetrics(SM_XVIRTUALSCREEN) + margin) 102 | newLeft = workAreaRect.left; 103 | if (newTop > ::GetSystemMetrics(SM_CYVIRTUALSCREEN) - margin) 104 | newTop -= rc.bottom - workAreaRect.bottom; 105 | if (newTop + (rc.bottom - rc.top) < ::GetSystemMetrics(SM_YVIRTUALSCREEN) + margin) 106 | newTop = workAreaRect.top; 107 | 108 | if ((newLeft != rc.left) || (newTop != rc.top)) // then the virtual screen size has shrunk 109 | // Remember that MoveWindow wants width/height. 110 | ::MoveWindow(_hSelf, newLeft, newTop, rc.right - rc.left, rc.bottom - rc.top, TRUE); 111 | } 112 | } 113 | 114 | Window::display(toShow); 115 | } 116 | 117 | RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const 118 | { 119 | HMONITOR hMon = ::MonitorFromRect(&testPositionRc, MONITOR_DEFAULTTONULL); 120 | 121 | MONITORINFO mi; 122 | mi.cbSize = sizeof(MONITORINFO); 123 | 124 | bool rectPosViewableWithoutChange = false; 125 | 126 | if (hMon != NULL) 127 | { 128 | // rect would be at least partially visible on a monitor 129 | 130 | ::GetMonitorInfo(hMon, &mi); 131 | 132 | int margin = ::GetSystemMetrics(SM_CYBORDER) + ::GetSystemMetrics(SM_CYSIZEFRAME) + ::GetSystemMetrics(SM_CYCAPTION); 133 | 134 | // require that the title bar of the window be in a viewable place so the user can see it to grab it with the mouse 135 | if ((testPositionRc.top >= mi.rcWork.top) && (testPositionRc.top + margin <= mi.rcWork.bottom) && 136 | // require that some reasonable amount of width of the title bar be in the viewable area: 137 | (testPositionRc.right - (margin * 2) > mi.rcWork.left) && (testPositionRc.left + (margin * 2) < mi.rcWork.right)) 138 | { 139 | rectPosViewableWithoutChange = true; 140 | } 141 | } 142 | else 143 | { 144 | // rect would not have been visible on a monitor; get info about the nearest monitor to it 145 | 146 | hMon = ::MonitorFromRect(&testPositionRc, MONITOR_DEFAULTTONEAREST); 147 | 148 | ::GetMonitorInfo(hMon, &mi); 149 | } 150 | 151 | RECT returnRc = testPositionRc; 152 | 153 | if (!rectPosViewableWithoutChange) 154 | { 155 | // reposition rect so that it would be viewable on current/nearest monitor, centering if reasonable 156 | 157 | LONG testRectWidth = testPositionRc.right - testPositionRc.left; 158 | LONG testRectHeight = testPositionRc.bottom - testPositionRc.top; 159 | LONG monWidth = mi.rcWork.right - mi.rcWork.left; 160 | LONG monHeight = mi.rcWork.bottom - mi.rcWork.top; 161 | 162 | returnRc.left = mi.rcWork.left; 163 | if (testRectWidth < monWidth) returnRc.left += (monWidth - testRectWidth) / 2; 164 | returnRc.right = returnRc.left + testRectWidth; 165 | 166 | returnRc.top = mi.rcWork.top; 167 | if (testRectHeight < monHeight) returnRc.top += (monHeight - testRectHeight) / 2; 168 | returnRc.bottom = returnRc.top + testRectHeight; 169 | } 170 | 171 | return returnRc; 172 | } 173 | 174 | HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate) 175 | { 176 | // Get Dlg Template resource 177 | HRSRC hDialogRC = ::FindResource(_hInst, MAKEINTRESOURCE(dialogID), RT_DIALOG); 178 | if (!hDialogRC) 179 | return NULL; 180 | 181 | HGLOBAL hDlgTemplate = ::LoadResource(_hInst, hDialogRC); 182 | if (!hDlgTemplate) 183 | return NULL; 184 | 185 | DLGTEMPLATE *pDlgTemplate = static_cast(::LockResource(hDlgTemplate)); 186 | if (!pDlgTemplate) 187 | return NULL; 188 | 189 | // Duplicate Dlg Template resource 190 | unsigned long sizeDlg = ::SizeofResource(_hInst, hDialogRC); 191 | HGLOBAL hMyDlgTemplate = ::GlobalAlloc(GPTR, sizeDlg); 192 | *ppMyDlgTemplate = static_cast(::GlobalLock(hMyDlgTemplate)); 193 | 194 | ::memcpy(*ppMyDlgTemplate, pDlgTemplate, sizeDlg); 195 | 196 | DLGTEMPLATEEX *pMyDlgTemplateEx = reinterpret_cast(*ppMyDlgTemplate); 197 | if (pMyDlgTemplateEx->signature == 0xFFFF) 198 | pMyDlgTemplateEx->exStyle |= WS_EX_LAYOUTRTL; 199 | else 200 | (*ppMyDlgTemplate)->dwExtendedStyle |= WS_EX_LAYOUTRTL; 201 | 202 | return hMyDlgTemplate; 203 | } 204 | 205 | std::wstring GetLastErrorAsString(DWORD errorCode) 206 | { 207 | std::wstring errorMsg(_T("")); 208 | // Get the error message, if any. 209 | // If both error codes (passed error n GetLastError) are 0, then return empty 210 | if (errorCode == 0) 211 | errorCode = GetLastError(); 212 | if (errorCode == 0) 213 | return errorMsg; //No error message has been recorded 214 | 215 | LPWSTR messageBuffer = nullptr; 216 | FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 217 | nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr); 218 | 219 | errorMsg += messageBuffer; 220 | 221 | //Free the buffer. 222 | LocalFree(messageBuffer); 223 | 224 | return errorMsg; 225 | } 226 | 227 | void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent) 228 | { 229 | if (isRTL) 230 | { 231 | DLGTEMPLATE *pMyDlgTemplate = NULL; 232 | HGLOBAL hMyDlgTemplate = makeRTLResource(dialogID, &pMyDlgTemplate); 233 | _hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast(this)); 234 | ::GlobalFree(hMyDlgTemplate); 235 | } 236 | else 237 | _hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, dlgProc, reinterpret_cast(this)); 238 | 239 | if (!_hSelf) 240 | { 241 | std::wstring errMsg = TEXT("CreateDialogParam() return NULL.\rGetLastError(): "); 242 | errMsg += GetLastErrorAsString(0); 243 | ::MessageBox(NULL, errMsg.c_str(), TEXT("In StaticDialog::create()"), MB_OK); 244 | return; 245 | } 246 | 247 | // if the destination of message NPPM_MODELESSDIALOG is not its parent, then it's the grand-parent 248 | ::SendMessage(msgDestParent ? _hParent : (::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, reinterpret_cast(_hSelf)); 249 | } 250 | 251 | INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 252 | { 253 | switch (message) 254 | { 255 | case WM_INITDIALOG: 256 | { 257 | StaticDialog *pStaticDlg = reinterpret_cast(lParam); 258 | pStaticDlg->_hSelf = hwnd; 259 | ::SetWindowLongPtr(hwnd, GWLP_USERDATA, static_cast(lParam)); 260 | ::GetWindowRect(hwnd, &(pStaticDlg->_rc)); 261 | pStaticDlg->run_dlgProc(message, wParam, lParam); 262 | 263 | return TRUE; 264 | } 265 | 266 | default: 267 | { 268 | StaticDialog *pStaticDlg = reinterpret_cast(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); 269 | if (!pStaticDlg) 270 | return FALSE; 271 | return pStaticDlg->run_dlgProc(message, wParam, lParam); 272 | } 273 | } 274 | } 275 | 276 | void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point) 277 | { 278 | RECT rc, rc2; 279 | ::GetWindowRect(handle, &rc); 280 | 281 | point.x = rc.left; 282 | point.y = rc.top; 283 | 284 | switch (pos) 285 | { 286 | case PosAlign::left: 287 | { 288 | ::GetWindowRect(handle2Align, &rc2); 289 | point.x -= rc2.right - rc2.left; 290 | break; 291 | } 292 | case PosAlign::right: 293 | { 294 | ::GetWindowRect(handle, &rc2); 295 | point.x += rc2.right - rc2.left; 296 | break; 297 | } 298 | case PosAlign::top: 299 | { 300 | ::GetWindowRect(handle2Align, &rc2); 301 | point.y -= rc2.bottom - rc2.top; 302 | break; 303 | } 304 | case PosAlign::bottom: 305 | { 306 | ::GetWindowRect(handle, &rc2); 307 | point.y += rc2.bottom - rc2.top; 308 | break; 309 | } 310 | } 311 | 312 | ::ScreenToClient(_hSelf, &point); 313 | } 314 | -------------------------------------------------------------------------------- /DockingFeature/StaticDialog.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2021 Don HO 3 | 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // at your option any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | #pragma once 17 | #include "..\Notepad_plus_msgs.h" 18 | #include "Window.h" 19 | 20 | typedef HRESULT (WINAPI * ETDTProc) (HWND, DWORD); 21 | 22 | enum class PosAlign { left, right, top, bottom }; 23 | 24 | struct DLGTEMPLATEEX 25 | { 26 | WORD dlgVer; 27 | WORD signature; 28 | DWORD helpID; 29 | DWORD exStyle; 30 | DWORD style; 31 | WORD cDlgItems; 32 | short x; 33 | short y; 34 | short cx; 35 | short cy; 36 | // The structure has more fields but are variable length 37 | }; 38 | 39 | class StaticDialog : public Window 40 | { 41 | public : 42 | virtual ~StaticDialog(); 43 | 44 | virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true); 45 | 46 | virtual bool isCreated() const { 47 | return (_hSelf != NULL); 48 | } 49 | 50 | void goToCenter(); 51 | 52 | void display(bool toShow = true, bool enhancedPositioningCheckWhenShowing = false) const; 53 | 54 | RECT getViewablePositionRect(RECT testRc) const; 55 | 56 | POINT getTopPoint(HWND hwnd, bool isLeft = true) const; 57 | 58 | bool isCheckedOrNot(int checkControlID) const 59 | { 60 | return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0)); 61 | } 62 | 63 | void setChecked(int checkControlID, bool checkOrNot = true) const 64 | { 65 | ::SendDlgItemMessage(_hSelf, checkControlID, BM_SETCHECK, checkOrNot ? BST_CHECKED : BST_UNCHECKED, 0); 66 | } 67 | 68 | virtual void destroy() override; 69 | 70 | protected: 71 | RECT _rc; 72 | static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 73 | virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0; 74 | 75 | void alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point); 76 | HGLOBAL makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate); 77 | }; 78 | -------------------------------------------------------------------------------- /DockingFeature/Window.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2021 Don HO 3 | 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // at your option any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | 18 | #pragma once 19 | #include 20 | 21 | class Window 22 | { 23 | public: 24 | //! \name Constructors & Destructor 25 | //@{ 26 | Window() = default; 27 | Window(const Window&) = delete; 28 | virtual ~Window() = default; 29 | //@} 30 | 31 | 32 | virtual void init(HINSTANCE hInst, HWND parent) 33 | { 34 | _hInst = hInst; 35 | _hParent = parent; 36 | } 37 | 38 | virtual void destroy() = 0; 39 | 40 | virtual void display(bool toShow = true) const 41 | { 42 | ::ShowWindow(_hSelf, toShow ? SW_SHOW : SW_HIDE); 43 | } 44 | 45 | 46 | virtual void reSizeTo(RECT & rc) // should NEVER be const !!! 47 | { 48 | ::MoveWindow(_hSelf, rc.left, rc.top, rc.right, rc.bottom, TRUE); 49 | redraw(); 50 | } 51 | 52 | 53 | virtual void reSizeToWH(RECT& rc) // should NEVER be const !!! 54 | { 55 | ::MoveWindow(_hSelf, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); 56 | redraw(); 57 | } 58 | 59 | 60 | virtual void redraw(bool forceUpdate = false) const 61 | { 62 | ::InvalidateRect(_hSelf, nullptr, TRUE); 63 | if (forceUpdate) 64 | ::UpdateWindow(_hSelf); 65 | } 66 | 67 | 68 | virtual void getClientRect(RECT & rc) const 69 | { 70 | ::GetClientRect(_hSelf, &rc); 71 | } 72 | 73 | virtual void getWindowRect(RECT & rc) const 74 | { 75 | ::GetWindowRect(_hSelf, &rc); 76 | } 77 | 78 | virtual int getWidth() const 79 | { 80 | RECT rc; 81 | ::GetClientRect(_hSelf, &rc); 82 | return (rc.right - rc.left); 83 | } 84 | 85 | virtual int getHeight() const 86 | { 87 | RECT rc; 88 | ::GetClientRect(_hSelf, &rc); 89 | if (::IsWindowVisible(_hSelf) == TRUE) 90 | return (rc.bottom - rc.top); 91 | return 0; 92 | } 93 | 94 | virtual bool isVisible() const 95 | { 96 | return (::IsWindowVisible(_hSelf)?true:false); 97 | } 98 | 99 | HWND getHSelf() const 100 | { 101 | return _hSelf; 102 | } 103 | 104 | HWND getHParent() const { 105 | return _hParent; 106 | } 107 | 108 | void getFocus() const { 109 | ::SetFocus(_hSelf); 110 | } 111 | 112 | HINSTANCE getHinst() const 113 | { 114 | //assert(_hInst != 0); 115 | return _hInst; 116 | } 117 | 118 | 119 | Window& operator = (const Window&) = delete; 120 | 121 | 122 | protected: 123 | HINSTANCE _hInst = NULL; 124 | HWND _hParent = NULL; 125 | HWND _hSelf = NULL; 126 | }; -------------------------------------------------------------------------------- /DockingFeature/dockingResource.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2006 Jens Lorenz 3 | 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // at your option any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | 18 | #pragma once 19 | 20 | #define DM_NOFOCUSWHILECLICKINGCAPTION TEXT("NOFOCUSWHILECLICKINGCAPTION") 21 | 22 | #define IDD_PLUGIN_DLG 103 23 | #define IDC_EDIT1 1000 24 | 25 | 26 | #define IDB_CLOSE_DOWN 137 27 | #define IDB_CLOSE_UP 138 28 | #define IDD_CONTAINER_DLG 139 29 | 30 | #define IDC_TAB_CONT 1027 31 | #define IDC_CLIENT_TAB 1028 32 | #define IDC_BTN_CAPTION 1050 33 | 34 | #define DMM_MSG 0x5000 35 | #define DMM_CLOSE (DMM_MSG + 1) 36 | #define DMM_DOCK (DMM_MSG + 2) 37 | #define DMM_FLOAT (DMM_MSG + 3) 38 | #define DMM_DOCKALL (DMM_MSG + 4) 39 | #define DMM_FLOATALL (DMM_MSG + 5) 40 | #define DMM_MOVE (DMM_MSG + 6) 41 | #define DMM_UPDATEDISPINFO (DMM_MSG + 7) 42 | #define DMM_GETIMAGELIST (DMM_MSG + 8) 43 | #define DMM_GETICONPOS (DMM_MSG + 9) 44 | #define DMM_DROPDATA (DMM_MSG + 10) 45 | #define DMM_MOVE_SPLITTER (DMM_MSG + 11) 46 | #define DMM_CANCEL_MOVE (DMM_MSG + 12) 47 | #define DMM_LBUTTONUP (DMM_MSG + 13) 48 | 49 | #define DMN_FIRST 1050 50 | #define DMN_CLOSE (DMN_FIRST + 1) 51 | //nmhdr.code = DWORD(DMN_CLOSE, 0)); 52 | //nmhdr.hwndFrom = hwndNpp; 53 | //nmhdr.idFrom = ctrlIdNpp; 54 | 55 | #define DMN_DOCK (DMN_FIRST + 2) 56 | #define DMN_FLOAT (DMN_FIRST + 3) 57 | //nmhdr.code = DWORD(DMN_XXX, int newContainer); 58 | //nmhdr.hwndFrom = hwndNpp; 59 | //nmhdr.idFrom = ctrlIdNpp; 60 | 61 | #define DMN_SWITCHIN (DMN_FIRST + 4) 62 | #define DMN_SWITCHOFF (DMN_FIRST + 5) 63 | #define DMN_FLOATDROPPED (DMN_FIRST + 6) 64 | //nmhdr.code = DWORD(DMN_XXX, 0); 65 | //nmhdr.hwndFrom = DockingCont::_hself; 66 | //nmhdr.idFrom = 0; 67 | 68 | -------------------------------------------------------------------------------- /DockingFeature/gitPanel.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "resource.h" 3 | 4 | IDD_PLUGINGITPANEL DIALOGEX 26,41,190,330 5 | CAPTION "Git Panel" 6 | FONT 8,"MS Shell Dlg",0,0,0 7 | STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_SHELLFONT 8 | EXSTYLE WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW 9 | BEGIN 10 | CONTROL "",IDC_EDT_BRANCH,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,2,180,135,15,WS_EX_CLIENTEDGE 11 | CONTROL "Branch",IDB_BTN_BRANCH,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,140,180,40,15 12 | CONTROL "",IDC_EDT_DIR,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_READONLY|ES_AUTOHSCROLL,2,200,185,15,WS_EX_CLIENTEDGE 13 | CONTROL "",IDC_LSV1,"SysListView32",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|LVS_SHOWSELALWAYS|LVS_REPORT,2,220,185,100,WS_EX_CLIENTEDGE 14 | CONTROL "Use TortoiseGit",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_GROUP,24,43,55,9 15 | CONTROL "",IDC_CHK_TORTOISE,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,10,43,10,9 16 | CONTROL "Use N++ Colors",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_GROUP,104,43,55,9 17 | CONTROL "",IDC_CHK_NPPCOLOR,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,90,43,10,9 18 | CONTROL "Panel Raise (or Toggle)",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_GROUP,104,58,80,8 19 | CONTROL "",IDC_CHK_PANELTOGGLE,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,90,58,10,9 20 | CONTROL "Go to remote",IDB_BTN_GOTOREMOTE,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,9,56,70,13 21 | END 22 | 23 | IDD_SETTINGS DIALOGEX 26,41,291,170 24 | CAPTION "Git SCM Settings" 25 | FONT 8,"MS Shell Dlg",0,0,0 26 | STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_SHELLFONT 27 | BEGIN 28 | CONTROL "&OK",IDB_OK,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_DEFPUSHBUTTON,120,146,50,14 29 | CONTROL "Git Directory Path",IDC_GRP1,"Button",WS_CHILDWINDOW|WS_VISIBLE|BS_GROUPBOX,9,15,270,63 30 | CONTROL "Git directory path is only needed if `git` cannot be found in your %PATH% environment variable.",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,18,27,204,18 31 | CONTROL "&git ...",IDC_BTN_GITPATH,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,15,54,40,14 32 | CONTROL "",IDC_EDT_GITPATH,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,70,54,200,15,WS_EX_CLIENTEDGE 33 | CONTROL "Git &Prompt EXE",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,9,90,55,9 34 | CONTROL "",IDC_EDT_GITPROMPT,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,70,87,200,15,WS_EX_CLIENTEDGE 35 | CONTROL "&Refresh Git Panel on Scintilla focus",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,25,110,120,9 36 | CONTROL "",IDC_CHK_SCNFOCUS,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,10,111,10,9 37 | CONTROL "--word-&diff (non-TortoiseGit)",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,170,110,105,9 38 | CONTROL "",IDC_CHK_WORDDIFF,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,155,111,10,9 39 | CONTROL "Blame with Git GUI", IDC_STATIC, "Static", WS_CHILDWINDOW | WS_VISIBLE, 25, 126, 120, 9 40 | CONTROL "", IDC_CHK_GITGUIBLAME, "Button", WS_CHILDWINDOW | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, 10, 127, 10, 9 41 | CONTROL "Version",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_DISABLED|WS_GROUP,10,146,30,11 42 | CONTROL "",IDC_STC_VER,"SysLink",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|LWS_TRANSPARENT,40,146,40,11 43 | END 44 | 45 | IDI_PLUGINGITPANEL ICON DISCARDABLE "GitSCM.ico" 46 | IDB_TOOLBAR1 BITMAP DISCARDABLE "DockingFeature/res/Toolbar1.bmp" 47 | IDB_TOOLBAR2 BITMAP DISCARDABLE "DockingFeature/res/Toolbar2.bmp" 48 | -------------------------------------------------------------------------------- /DockingFeature/res/Git.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsworldcom/nppGitSCM/5210b315d0cdad7de18fb3ec855dfd39dc604489/DockingFeature/res/Git.bmp -------------------------------------------------------------------------------- /DockingFeature/res/Toolbar1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsworldcom/nppGitSCM/5210b315d0cdad7de18fb3ec855dfd39dc604489/DockingFeature/res/Toolbar1.bmp -------------------------------------------------------------------------------- /DockingFeature/res/Toolbar2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsworldcom/nppGitSCM/5210b315d0cdad7de18fb3ec855dfd39dc604489/DockingFeature/res/Toolbar2.bmp -------------------------------------------------------------------------------- /DockingFeature/resource.h: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #ifndef DOCKINGFEATURE_RESOURCE_H 19 | #define DOCKINGFEATURE_RESOURCE_H 20 | 21 | 22 | #ifndef IDC_STATIC 23 | #define IDC_STATIC -1 24 | #endif 25 | 26 | // Docking 27 | #define IDD_PLUGINGITPANEL 2500 28 | 29 | #define IDI_PLUGINGITPANEL 2501 30 | 31 | #define IDB_TOOLBAR1 1601 32 | #define IDB_TOOLBAR2 1600 33 | 34 | #define IDB_PAGER1 1701 35 | #define IDB_PAGER2 1702 36 | 37 | // The following MUST stay in order so GetNameStrFromCmd() 38 | // tooltip lookups from szToolTip will work 39 | 40 | #define IDC_BTN_GITGUI (IDB_TOOLBAR1 + 1) 41 | #define IDC_BTN_GITK (IDB_TOOLBAR1 + 2) 42 | #define IDC_BTN_PROMPT (IDB_TOOLBAR1 + 3) 43 | #define IDC_BTN_PULL (IDB_TOOLBAR1 + 4) 44 | #define IDC_BTN_STATUS (IDB_TOOLBAR1 + 5) 45 | #define IDC_BTN_COMMIT (IDB_TOOLBAR1 + 6) 46 | #define IDC_BTN_PUSH (IDB_TOOLBAR1 + 7) 47 | #define IDC_BTN_ADD (IDB_TOOLBAR1 + 8) 48 | #define IDC_BTN_UNSTAGE (IDB_TOOLBAR1 + 9) 49 | #define IDC_BTN_RESTORE (IDB_TOOLBAR1 + 10) 50 | #define IDC_BTN_DIFF (IDB_TOOLBAR1 + 11) 51 | #define IDC_BTN_LOG (IDB_TOOLBAR1 + 12) 52 | #define IDC_BTN_BLAME (IDB_TOOLBAR1 + 13) 53 | #define IDC_BTN_SETTINGS (IDB_TOOLBAR1 + 14) 54 | 55 | // END order "MUST stay in order" 56 | 57 | #define IDC_CHK_TORTOISE (IDD_PLUGINGITPANEL + 11) 58 | #define IDC_CHK_NPPCOLOR (IDD_PLUGINGITPANEL + 12) 59 | #define IDC_CHK_PANELTOGGLE (IDD_PLUGINGITPANEL + 13) 60 | #define IDC_EDT_DIR (IDD_PLUGINGITPANEL + 14) 61 | #define IDC_EDT_BRANCH (IDD_PLUGINGITPANEL + 15) 62 | #define IDB_BTN_BRANCH (IDD_PLUGINGITPANEL + 16) 63 | #define IDB_BTN_GOTOREMOTE (IDD_PLUGINGITPANEL + 17) 64 | #define IDC_LSV1 (IDD_PLUGINGITPANEL + 18) 65 | 66 | // Settings 67 | #define IDD_SETTINGS 2600 68 | 69 | #define IDB_OK (IDD_SETTINGS + 1) 70 | #define IDC_GRP1 (IDD_SETTINGS + 2) 71 | #define IDC_BTN_GITPATH (IDD_SETTINGS + 3) 72 | #define IDC_EDT_GITPATH (IDD_SETTINGS + 4) 73 | #define IDC_EDT_GITPROMPT (IDD_SETTINGS + 5) 74 | #define IDC_CHK_SCNFOCUS (IDD_SETTINGS + 6) 75 | #define IDC_CHK_WORDDIFF (IDD_SETTINGS + 7) 76 | #define IDC_CHK_GITGUIBLAME (IDD_SETTINGS + 8) 77 | 78 | #define IDC_STC_VER (IDD_SETTINGS + 9) 79 | 80 | #endif // DOCKINGFEATURE_RESOURCE_H 81 | -------------------------------------------------------------------------------- /GitSCM.cpp: -------------------------------------------------------------------------------- 1 | ///---------------------------------------------------------------------------- 2 | /// Copyright (c) 2008-2010 3 | /// Brandon Cannaday 4 | /// Paranoid Ferret Productions (support@paranoidferret.com) 5 | /// 6 | /// This program is free software; you can redistribute it and/or 7 | /// modify it under the terms of the GNU General Public License 8 | /// as published by the Free Software Foundation; either 9 | /// version 2 of the License, or (at your option) any later version. 10 | /// 11 | /// This program is distributed in the hope that it will be useful, 12 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | /// GNU General Public License for more details. 15 | /// 16 | /// You should have received a copy of the GNU General Public License 17 | /// along with this program; if not, write to the Free Software 18 | /// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | ///---------------------------------------------------------------------------- 20 | 21 | #include "PluginDefinition.h" 22 | #include "resource.h" 23 | 24 | extern FuncItem funcItem[nbFunc]; 25 | extern HINSTANCE g_hInst; 26 | extern NppData nppData; 27 | extern bool g_NppReady; 28 | extern bool g_RefScnFocus; 29 | extern toolbarIcons g_TBGit; 30 | 31 | BOOL APIENTRY DllMain( HMODULE hModule, DWORD reasonForCall, LPVOID /*lpReserved*/ ) 32 | { 33 | switch ( reasonForCall ) 34 | { 35 | case DLL_PROCESS_ATTACH: 36 | g_hInst = ( HINSTANCE )hModule; 37 | pluginInit( hModule ); 38 | break; 39 | 40 | case DLL_PROCESS_DETACH: 41 | pluginCleanUp(); 42 | break; 43 | 44 | case DLL_THREAD_ATTACH: 45 | break; 46 | 47 | case DLL_THREAD_DETACH: 48 | break; 49 | } 50 | return TRUE; 51 | } 52 | 53 | 54 | extern "C" __declspec( dllexport ) void setInfo( NppData notpadPlusData ) 55 | { 56 | nppData = notpadPlusData; 57 | commandMenuInit(); 58 | } 59 | 60 | extern "C" __declspec( dllexport ) const TCHAR *getName() 61 | { 62 | return NPP_PLUGIN_NAME; 63 | } 64 | 65 | extern "C" __declspec( dllexport ) FuncItem *getFuncsArray( int *nbF ) 66 | { 67 | *nbF = nbFunc; 68 | return funcItem; 69 | } 70 | 71 | extern "C" __declspec( dllexport ) void beNotified( SCNotification *notifyCode ) 72 | { 73 | switch (notifyCode->nmhdr.code) 74 | { 75 | case NPPN_TBMODIFICATION: 76 | g_TBGit.hToolbarBmp = (HBITMAP)::LoadImage((HINSTANCE)g_hInst, MAKEINTRESOURCE(IDB_TB_GIT), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE); 77 | ::SendMessage(nppData._nppHandle, NPPM_ADDTOOLBARICON_DEPRECATED, (WPARAM)funcItem[DOCKABLE_INDEX]._cmdID, (LPARAM)&g_TBGit); 78 | break; 79 | 80 | case NPPN_READY: 81 | g_NppReady = true; 82 | updatePanelLoc(); 83 | break; 84 | 85 | // TODO:2019-12-25:MVINCENT: if updatePanel() is used, Causes very slow tab switching 86 | // Convert Process.cpp CreateProcess to CreateThread 87 | case NPPN_BUFFERACTIVATED: 88 | { 89 | if ( g_NppReady ) 90 | updatePanelLoc(); 91 | } 92 | break; 93 | case SCN_FOCUSIN: 94 | { 95 | if ( g_NppReady && g_RefScnFocus ) 96 | updatePanelLoc(); 97 | } 98 | break; 99 | 100 | case NPPN_FILESAVED: 101 | updatePanel(); 102 | break; 103 | 104 | case NPPN_FILEOPENED: 105 | { 106 | if ( g_NppReady ) 107 | updatePanel(); 108 | } 109 | break; 110 | 111 | case NPPN_SHUTDOWN: 112 | commandMenuCleanUp(); 113 | break; 114 | 115 | default: 116 | return; 117 | } 118 | } 119 | 120 | // Here you can process the Npp Messages 121 | // I will make the messages accessible little by little, according to the need of plugin development. 122 | // Please let me know if you need to access to some messages : 123 | // http://sourceforge.net/forum/forum.php?forum_id=482781 124 | // 125 | extern "C" __declspec(dllexport) LRESULT messageProc(UINT /*Message*/, WPARAM /*wParam*/, LPARAM /*lParam*/) 126 | { 127 | return TRUE; 128 | } 129 | 130 | #ifdef UNICODE 131 | extern "C" __declspec( dllexport ) BOOL isUnicode() 132 | { 133 | return TRUE; 134 | } 135 | #endif //UNICODE 136 | -------------------------------------------------------------------------------- /GitSCM.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinsworldcom/nppGitSCM/5210b315d0cdad7de18fb3ec855dfd39dc604489/GitSCM.ico -------------------------------------------------------------------------------- /GitSCM.rc: -------------------------------------------------------------------------------- 1 | #include // include for version info constants 2 | #include 3 | 4 | // 5 | // TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS... 6 | // 7 | 1 VERSIONINFO 8 | FILEVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD 9 | PRODUCTVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD 10 | FILETYPE VFT_DLL 11 | { 12 | BLOCK "StringFileInfo" 13 | { 14 | BLOCK "040904E4" 15 | { 16 | VALUE "FileDescription", FILE_DESCRIPTION 17 | VALUE "InternalName", INTERNAL_NAME 18 | 19 | VALUE "CompanyName", COMPANY_NAME 20 | VALUE "FileVersion", VER_STRING 21 | VALUE "LegalCopyright", LEGAL_COPYRIGHT 22 | VALUE "LegalTrademarks", LEGAL_TRADEMARKS 23 | VALUE "OriginalFilename", ORIGINAL_FILENAME 24 | VALUE "ProductName", PRODUCT_NAME 25 | VALUE "ProductVersion", VER_STRING 26 | } 27 | } 28 | BLOCK "VarFileInfo" 29 | { 30 | VALUE "Translation", 0x0409, 1252 31 | } 32 | } 33 | 34 | IDB_TB_GIT BITMAP "DockingFeature\\res\\Git.bmp" 35 | 36 | -------------------------------------------------------------------------------- /GitSCM.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.32228.343 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GitSCM", "GitSCM.vcxproj", "{9D04DBD5-E12E-44E0-A683-6F43F21D533B}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|ARM64 = Debug|ARM64 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|ARM64 = Release|ARM64 13 | Release|x64 = Release|x64 14 | Release|x86 = Release|x86 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Debug|ARM64.ActiveCfg = Debug|ARM64 18 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Debug|ARM64.Build.0 = Debug|ARM64 19 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Debug|x64.ActiveCfg = Debug|x64 20 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Debug|x64.Build.0 = Debug|x64 21 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Debug|x86.ActiveCfg = Debug|Win32 22 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Debug|x86.Build.0 = Debug|Win32 23 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Release|ARM64.ActiveCfg = Release|ARM64 24 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Release|ARM64.Build.0 = Release|ARM64 25 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Release|x64.ActiveCfg = Release|x64 26 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Release|x64.Build.0 = Release|x64 27 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Release|x86.ActiveCfg = Release|Win32 28 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B}.Release|x86.Build.0 = Release|Win32 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {D0A99902-D6DF-4A05-9320-B158BD9E7F22} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /GitSCM.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | ARM64 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | ARM64 19 | 20 | 21 | Release 22 | Win32 23 | 24 | 25 | Release 26 | x64 27 | 28 | 29 | 30 | {9D04DBD5-E12E-44E0-A683-6F43F21D533B} 31 | Win32Proj 32 | GitSCM 33 | 10.0 34 | 35 | 36 | 37 | DynamicLibrary 38 | true 39 | v142 40 | Unicode 41 | 42 | 43 | DynamicLibrary 44 | true 45 | v142 46 | Unicode 47 | 48 | 49 | DynamicLibrary 50 | true 51 | v142 52 | Unicode 53 | 54 | 55 | DynamicLibrary 56 | false 57 | v142 58 | true 59 | Unicode 60 | 61 | 62 | DynamicLibrary 63 | false 64 | v142 65 | true 66 | Unicode 67 | 68 | 69 | DynamicLibrary 70 | false 71 | v142 72 | true 73 | Unicode 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | true 99 | $(Configuration)\$(Platform)\ 100 | 101 | 102 | true 103 | $(Configuration)\$(Platform)\ 104 | 105 | 106 | true 107 | $(Configuration)\$(Platform)\ 108 | 109 | 110 | false 111 | $(Configuration)\$(Platform)\ 112 | 113 | 114 | false 115 | $(Configuration)\$(Platform)\ 116 | 117 | 118 | false 119 | $(Configuration)\$(Platform)\ 120 | 121 | 122 | 123 | Level4 124 | Disabled 125 | WIN32;_DEBUG;_WINDOWS;_USRDLL;GitSCM_EXPORTS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1;%(PreprocessorDefinitions) 126 | true 127 | Speed 128 | MultiThreadedDebug 129 | 130 | 131 | Windows 132 | true 133 | comctl32.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 134 | 135 | 136 | 137 | 138 | Level4 139 | Disabled 140 | WIN32;_DEBUG;_WINDOWS;_USRDLL;GitSCM_EXPORTS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1;%(PreprocessorDefinitions) 141 | true 142 | Speed 143 | MultiThreadedDebug 144 | 145 | 146 | Windows 147 | true 148 | comctl32.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 149 | 150 | 151 | 152 | 153 | Level4 154 | Disabled 155 | WIN32;_DEBUG;_WINDOWS;_USRDLL;GitSCM_EXPORTS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1;%(PreprocessorDefinitions) 156 | true 157 | Speed 158 | MultiThreadedDebug 159 | 160 | 161 | Windows 162 | true 163 | comctl32.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 164 | 165 | 166 | 167 | 168 | Level4 169 | Full 170 | true 171 | false 172 | Speed 173 | WIN32;NDEBUG;_WINDOWS;_USRDLL;GitSCM_EXPORTS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1;%(PreprocessorDefinitions) 174 | MultiThreaded 175 | 176 | 177 | Windows 178 | false 179 | true 180 | true 181 | comctl32.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 182 | $(TargetName).lib 183 | 184 | 185 | 186 | 187 | Level4 188 | Full 189 | true 190 | false 191 | Speed 192 | WIN32;NDEBUG;_WINDOWS;_USRDLL;GitSCM_EXPORTS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1;%(PreprocessorDefinitions) 193 | MultiThreaded 194 | 195 | 196 | Windows 197 | false 198 | true 199 | true 200 | comctl32.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 201 | $(TargetName).lib 202 | 203 | 204 | 205 | 206 | Level4 207 | Full 208 | true 209 | false 210 | Speed 211 | WIN32;NDEBUG;_WINDOWS;_USRDLL;GitSCM_EXPORTS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS=1;%(PreprocessorDefinitions) 212 | MultiThreaded 213 | 214 | 215 | Windows 216 | false 217 | true 218 | true 219 | comctl32.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 220 | $(TargetName).lib 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | -------------------------------------------------------------------------------- /GitSCM.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 20 | 21 | 22 | zip 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Notepad_plus_msgs.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2021 Don HO 3 | 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // at your option any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\ 24 | L_HTML, L_XML, L_MAKEFILE, L_PASCAL, L_BATCH, L_INI, L_ASCII, L_USER,\ 25 | L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA, \ 26 | L_TEX, L_FORTRAN, L_BASH, L_FLASH, L_NSIS, L_TCL, L_LISP, L_SCHEME,\ 27 | L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3,\ 28 | L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT,\ 29 | L_CMAKE, L_YAML, L_COBOL, L_GUI4CLI, L_D, L_POWERSHELL, L_R, L_JSP,\ 30 | L_COFFEESCRIPT, L_JSON, L_JAVASCRIPT, L_FORTRAN_77, L_BAANC, L_SREC,\ 31 | L_IHEX, L_TEHEX, L_SWIFT,\ 32 | L_ASN1, L_AVS, L_BLITZBASIC, L_PUREBASIC, L_FREEBASIC, \ 33 | L_CSOUND, L_ERLANG, L_ESCRIPT, L_FORTH, L_LATEX, \ 34 | L_MMIXAL, L_NIM, L_NNCRONTAB, L_OSCRIPT, L_REBOL, \ 35 | L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG, L_TYPESCRIPT,\ 36 | // Don't use L_JS, use L_JAVASCRIPT instead 37 | // The end of enumated language type, so it should be always at the end 38 | L_EXTERNAL}; 39 | 40 | enum winVer{ WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81, WV_WIN10 }; 41 | enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; 42 | 43 | 44 | 45 | #define NPPMSG (WM_USER + 1000) 46 | 47 | #define NPPM_GETCURRENTSCINTILLA (NPPMSG + 4) 48 | #define NPPM_GETCURRENTLANGTYPE (NPPMSG + 5) 49 | #define NPPM_SETCURRENTLANGTYPE (NPPMSG + 6) 50 | 51 | #define NPPM_GETNBOPENFILES (NPPMSG + 7) 52 | #define ALL_OPEN_FILES 0 53 | #define PRIMARY_VIEW 1 54 | #define SECOND_VIEW 2 55 | 56 | #define NPPM_GETOPENFILENAMES (NPPMSG + 8) 57 | 58 | 59 | #define NPPM_MODELESSDIALOG (NPPMSG + 12) 60 | #define MODELESSDIALOGADD 0 61 | #define MODELESSDIALOGREMOVE 1 62 | 63 | #define NPPM_GETNBSESSIONFILES (NPPMSG + 13) 64 | #define NPPM_GETSESSIONFILES (NPPMSG + 14) 65 | #define NPPM_SAVESESSION (NPPMSG + 15) 66 | #define NPPM_SAVECURRENTSESSION (NPPMSG + 16) 67 | 68 | struct sessionInfo { 69 | TCHAR* sessionFilePathName; 70 | int nbFile; 71 | TCHAR** files; 72 | }; 73 | 74 | #define NPPM_GETOPENFILENAMESPRIMARY (NPPMSG + 17) 75 | #define NPPM_GETOPENFILENAMESSECOND (NPPMSG + 18) 76 | 77 | #define NPPM_CREATESCINTILLAHANDLE (NPPMSG + 20) 78 | #define NPPM_DESTROYSCINTILLAHANDLE (NPPMSG + 21) 79 | #define NPPM_GETNBUSERLANG (NPPMSG + 22) 80 | 81 | #define NPPM_GETCURRENTDOCINDEX (NPPMSG + 23) 82 | #define MAIN_VIEW 0 83 | #define SUB_VIEW 1 84 | 85 | #define NPPM_SETSTATUSBAR (NPPMSG + 24) 86 | #define STATUSBAR_DOC_TYPE 0 87 | #define STATUSBAR_DOC_SIZE 1 88 | #define STATUSBAR_CUR_POS 2 89 | #define STATUSBAR_EOF_FORMAT 3 90 | #define STATUSBAR_UNICODE_TYPE 4 91 | #define STATUSBAR_TYPING_MODE 5 92 | 93 | #define NPPM_GETMENUHANDLE (NPPMSG + 25) 94 | #define NPPPLUGINMENU 0 95 | #define NPPMAINMENU 1 96 | // INT NPPM_GETMENUHANDLE(INT menuChoice, 0) 97 | // Return: menu handle (HMENU) of choice (plugin menu handle or Notepad++ main menu handle) 98 | 99 | #define NPPM_ENCODESCI (NPPMSG + 26) 100 | //ascii file to unicode 101 | //int NPPM_ENCODESCI(MAIN_VIEW/SUB_VIEW, 0) 102 | //return new unicodeMode 103 | 104 | #define NPPM_DECODESCI (NPPMSG + 27) 105 | //unicode file to ascii 106 | //int NPPM_DECODESCI(MAIN_VIEW/SUB_VIEW, 0) 107 | //return old unicodeMode 108 | 109 | #define NPPM_ACTIVATEDOC (NPPMSG + 28) 110 | //void NPPM_ACTIVATEDOC(int view, int index2Activate) 111 | 112 | #define NPPM_LAUNCHFINDINFILESDLG (NPPMSG + 29) 113 | //void NPPM_LAUNCHFINDINFILESDLG(TCHAR * dir2Search, TCHAR * filtre) 114 | 115 | #define NPPM_DMMSHOW (NPPMSG + 30) 116 | //void NPPM_DMMSHOW(0, tTbData->hClient) 117 | 118 | #define NPPM_DMMHIDE (NPPMSG + 31) 119 | //void NPPM_DMMHIDE(0, tTbData->hClient) 120 | 121 | #define NPPM_DMMUPDATEDISPINFO (NPPMSG + 32) 122 | //void NPPM_DMMUPDATEDISPINFO(0, tTbData->hClient) 123 | 124 | #define NPPM_DMMREGASDCKDLG (NPPMSG + 33) 125 | //void NPPM_DMMREGASDCKDLG(0, &tTbData) 126 | 127 | #define NPPM_LOADSESSION (NPPMSG + 34) 128 | //void NPPM_LOADSESSION(0, const TCHAR* file name) 129 | 130 | #define NPPM_DMMVIEWOTHERTAB (NPPMSG + 35) 131 | //void WM_DMM_VIEWOTHERTAB(0, tTbData->pszName) 132 | 133 | #define NPPM_RELOADFILE (NPPMSG + 36) 134 | //BOOL NPPM_RELOADFILE(BOOL withAlert, TCHAR *filePathName2Reload) 135 | 136 | #define NPPM_SWITCHTOFILE (NPPMSG + 37) 137 | //BOOL NPPM_SWITCHTOFILE(0, TCHAR *filePathName2switch) 138 | 139 | #define NPPM_SAVECURRENTFILE (NPPMSG + 38) 140 | //BOOL NPPM_SAVECURRENTFILE(0, 0) 141 | 142 | #define NPPM_SAVEALLFILES (NPPMSG + 39) 143 | //BOOL NPPM_SAVEALLFILES(0, 0) 144 | 145 | #define NPPM_SETMENUITEMCHECK (NPPMSG + 40) 146 | //void WM_PIMENU_CHECK(UINT funcItem[X]._cmdID, TRUE/FALSE) 147 | 148 | #define NPPM_ADDTOOLBARICON_DEPRECATED (NPPMSG + 41) 149 | //void NPPM_ADDTOOLBARICON(UINT funcItem[X]._cmdID, toolbarIcons iconHandles) -- DEPRECATED : use NPPM_ADDTOOLBARICON_FORDARKMODE instead 150 | //2 formats of icon are needed: .ico & .bmp 151 | //Both handles below should be set so the icon will be displayed correctly if toolbar icon sets are changed by users 152 | struct toolbarIcons { 153 | HBITMAP hToolbarBmp; 154 | HICON hToolbarIcon; 155 | }; 156 | 157 | #define NPPM_GETWINDOWSVERSION (NPPMSG + 42) 158 | //winVer NPPM_GETWINDOWSVERSION(0, 0) 159 | 160 | #define NPPM_DMMGETPLUGINHWNDBYNAME (NPPMSG + 43) 161 | //HWND WM_DMM_GETPLUGINHWNDBYNAME(const TCHAR *windowName, const TCHAR *moduleName) 162 | // if moduleName is NULL, then return value is NULL 163 | // if windowName is NULL, then the first found window handle which matches with the moduleName will be returned 164 | 165 | #define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44) 166 | //BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0) 167 | 168 | #define NPPM_GETENABLETHEMETEXTUREFUNC (NPPMSG + 45) 169 | //BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) 170 | 171 | #define NPPM_GETPLUGINSCONFIGDIR (NPPMSG + 46) 172 | //INT NPPM_GETPLUGINSCONFIGDIR(int strLen, TCHAR *str) 173 | // Get user's plugin config directory path. It's useful if plugins want to save/load parameters for the current user 174 | // Returns the number of TCHAR copied/to copy. 175 | // Users should call it with "str" be NULL to get the required number of TCHAR (not including the terminating nul character), 176 | // allocate "str" buffer with the return value + 1, then call it again to get the path. 177 | 178 | #define NPPM_MSGTOPLUGIN (NPPMSG + 47) 179 | //BOOL NPPM_MSGTOPLUGIN(TCHAR *destModuleName, CommunicationInfo *info) 180 | // return value is TRUE when the message arrive to the destination plugins. 181 | // if destModule or info is NULL, then return value is FALSE 182 | struct CommunicationInfo { 183 | long internalMsg; 184 | const TCHAR * srcModuleName; 185 | void * info; // defined by plugin 186 | }; 187 | 188 | #define NPPM_MENUCOMMAND (NPPMSG + 48) 189 | //void NPPM_MENUCOMMAND(0, int cmdID) 190 | // uncomment //#include "menuCmdID.h" 191 | // in the beginning of this file then use the command symbols defined in "menuCmdID.h" file 192 | // to access all the Notepad++ menu command items 193 | 194 | #define NPPM_TRIGGERTABBARCONTEXTMENU (NPPMSG + 49) 195 | //void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate) 196 | 197 | #define NPPM_GETNPPVERSION (NPPMSG + 50) 198 | // int NPPM_GETNPPVERSION(0, 0) 199 | // return version 200 | // ex : v4.6 201 | // HIWORD(version) == 4 202 | // LOWORD(version) == 6 203 | 204 | #define NPPM_HIDETABBAR (NPPMSG + 51) 205 | // BOOL NPPM_HIDETABBAR(0, BOOL hideOrNot) 206 | // if hideOrNot is set as TRUE then tab bar will be hidden 207 | // otherwise it'll be shown. 208 | // return value : the old status value 209 | 210 | #define NPPM_ISTABBARHIDDEN (NPPMSG + 52) 211 | // BOOL NPPM_ISTABBARHIDDEN(0, 0) 212 | // returned value : TRUE if tab bar is hidden, otherwise FALSE 213 | 214 | #define NPPM_GETPOSFROMBUFFERID (NPPMSG + 57) 215 | // INT NPPM_GETPOSFROMBUFFERID(UINT_PTR bufferID, INT priorityView) 216 | // Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing 217 | // if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly 218 | // 219 | // VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits) 220 | // Here's the values for the view : 221 | // MAIN_VIEW 0 222 | // SUB_VIEW 1 223 | 224 | #define NPPM_GETFULLPATHFROMBUFFERID (NPPMSG + 58) 225 | // INT NPPM_GETFULLPATHFROMBUFFERID(UINT_PTR bufferID, TCHAR *fullFilePath) 226 | // Get full path file name from a bufferID. 227 | // Return -1 if the bufferID non existing, otherwise the number of TCHAR copied/to copy 228 | // User should call it with fullFilePath be NULL to get the number of TCHAR (not including the nul character), 229 | // allocate fullFilePath with the return values + 1, then call it again to get full path file name 230 | 231 | #define NPPM_GETBUFFERIDFROMPOS (NPPMSG + 59) 232 | // LRESULT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView) 233 | // wParam: Position of document 234 | // lParam: View to use, 0 = Main, 1 = Secondary 235 | // Returns 0 if invalid 236 | 237 | #define NPPM_GETCURRENTBUFFERID (NPPMSG + 60) 238 | // LRESULT NPPM_GETCURRENTBUFFERID(0, 0) 239 | // Returns active Buffer 240 | 241 | #define NPPM_RELOADBUFFERID (NPPMSG + 61) 242 | // VOID NPPM_RELOADBUFFERID(UINT_PTR bufferID, BOOL alert) 243 | // Reloads Buffer 244 | // wParam: Buffer to reload 245 | // lParam: 0 if no alert, else alert 246 | 247 | #define NPPM_GETBUFFERLANGTYPE (NPPMSG + 64) 248 | // INT NPPM_GETBUFFERLANGTYPE(UINT_PTR bufferID, 0) 249 | // wParam: BufferID to get LangType from 250 | // lParam: 0 251 | // Returns as int, see LangType. -1 on error 252 | 253 | #define NPPM_SETBUFFERLANGTYPE (NPPMSG + 65) 254 | // BOOL NPPM_SETBUFFERLANGTYPE(UINT_PTR bufferID, INT langType) 255 | // wParam: BufferID to set LangType of 256 | // lParam: LangType 257 | // Returns TRUE on success, FALSE otherwise 258 | // use int, see LangType for possible values 259 | // L_USER and L_EXTERNAL are not supported 260 | 261 | #define NPPM_GETBUFFERENCODING (NPPMSG + 66) 262 | // INT NPPM_GETBUFFERENCODING(UINT_PTR bufferID, 0) 263 | // wParam: BufferID to get encoding from 264 | // lParam: 0 265 | // returns as int, see UniMode. -1 on error 266 | 267 | #define NPPM_SETBUFFERENCODING (NPPMSG + 67) 268 | // BOOL NPPM_SETBUFFERENCODING(UINT_PTR bufferID, INT encoding) 269 | // wParam: BufferID to set encoding of 270 | // lParam: encoding 271 | // Returns TRUE on success, FALSE otherwise 272 | // use int, see UniMode 273 | // Can only be done on new, unedited files 274 | 275 | #define NPPM_GETBUFFERFORMAT (NPPMSG + 68) 276 | // INT NPPM_GETBUFFERFORMAT(UINT_PTR bufferID, 0) 277 | // wParam: BufferID to get EolType format from 278 | // lParam: 0 279 | // returns as int, see EolType format. -1 on error 280 | 281 | #define NPPM_SETBUFFERFORMAT (NPPMSG + 69) 282 | // BOOL NPPM_SETBUFFERFORMAT(UINT_PTR bufferID, INT format) 283 | // wParam: BufferID to set EolType format of 284 | // lParam: format 285 | // Returns TRUE on success, FALSE otherwise 286 | // use int, see EolType format 287 | 288 | 289 | #define NPPM_HIDETOOLBAR (NPPMSG + 70) 290 | // BOOL NPPM_HIDETOOLBAR(0, BOOL hideOrNot) 291 | // if hideOrNot is set as TRUE then tool bar will be hidden 292 | // otherwise it'll be shown. 293 | // return value : the old status value 294 | 295 | #define NPPM_ISTOOLBARHIDDEN (NPPMSG + 71) 296 | // BOOL NPPM_ISTOOLBARHIDDEN(0, 0) 297 | // returned value : TRUE if tool bar is hidden, otherwise FALSE 298 | 299 | #define NPPM_HIDEMENU (NPPMSG + 72) 300 | // BOOL NPPM_HIDEMENU(0, BOOL hideOrNot) 301 | // if hideOrNot is set as TRUE then menu will be hidden 302 | // otherwise it'll be shown. 303 | // return value : the old status value 304 | 305 | #define NPPM_ISMENUHIDDEN (NPPMSG + 73) 306 | // BOOL NPPM_ISMENUHIDDEN(0, 0) 307 | // returned value : TRUE if menu is hidden, otherwise FALSE 308 | 309 | #define NPPM_HIDESTATUSBAR (NPPMSG + 74) 310 | // BOOL NPPM_HIDESTATUSBAR(0, BOOL hideOrNot) 311 | // if hideOrNot is set as TRUE then STATUSBAR will be hidden 312 | // otherwise it'll be shown. 313 | // return value : the old status value 314 | 315 | #define NPPM_ISSTATUSBARHIDDEN (NPPMSG + 75) 316 | // BOOL NPPM_ISSTATUSBARHIDDEN(0, 0) 317 | // returned value : TRUE if STATUSBAR is hidden, otherwise FALSE 318 | 319 | #define NPPM_GETSHORTCUTBYCMDID (NPPMSG + 76) 320 | // BOOL NPPM_GETSHORTCUTBYCMDID(int cmdID, ShortcutKey *sk) 321 | // get your plugin command current mapped shortcut into sk via cmdID 322 | // You may need it after getting NPPN_READY notification 323 | // returned value : TRUE if this function call is successful and shortcut is enable, otherwise FALSE 324 | 325 | #define NPPM_DOOPEN (NPPMSG + 77) 326 | // BOOL NPPM_DOOPEN(0, const TCHAR *fullPathName2Open) 327 | // fullPathName2Open indicates the full file path name to be opened. 328 | // The return value is TRUE (1) if the operation is successful, otherwise FALSE (0). 329 | 330 | #define NPPM_SAVECURRENTFILEAS (NPPMSG + 78) 331 | // BOOL NPPM_SAVECURRENTFILEAS (BOOL asCopy, const TCHAR* filename) 332 | 333 | #define NPPM_GETCURRENTNATIVELANGENCODING (NPPMSG + 79) 334 | // INT NPPM_GETCURRENTNATIVELANGENCODING(0, 0) 335 | // returned value : the current native language encoding 336 | 337 | #define NPPM_ALLOCATESUPPORTED (NPPMSG + 80) 338 | // returns TRUE if NPPM_ALLOCATECMDID is supported 339 | // Use to identify if subclassing is necessary 340 | 341 | #define NPPM_ALLOCATECMDID (NPPMSG + 81) 342 | // BOOL NPPM_ALLOCATECMDID(int numberRequested, int* startNumber) 343 | // sets startNumber to the initial command ID if successful 344 | // Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful 345 | 346 | #define NPPM_ALLOCATEMARKER (NPPMSG + 82) 347 | // BOOL NPPM_ALLOCATEMARKER(int numberRequested, int* startNumber) 348 | // sets startNumber to the initial command ID if successful 349 | // Allocates a marker number to a plugin: if a plugin need to add a marker on Notepad++'s Scintilla marker margin, 350 | // it has to use this message to get marker number, in order to prevent from the conflict with the other plugins. 351 | // Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful 352 | 353 | #define NPPM_GETLANGUAGENAME (NPPMSG + 83) 354 | // INT NPPM_GETLANGUAGENAME(int langType, TCHAR *langName) 355 | // Get programming language name from the given language type (LangType) 356 | // Return value is the number of copied character / number of character to copy (\0 is not included) 357 | // You should call this function 2 times - the first time you pass langName as NULL to get the number of characters to copy. 358 | // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGENAME function the 2nd time 359 | // by passing allocated buffer as argument langName 360 | 361 | #define NPPM_GETLANGUAGEDESC (NPPMSG + 84) 362 | // INT NPPM_GETLANGUAGEDESC(int langType, TCHAR *langDesc) 363 | // Get programming language short description from the given language type (LangType) 364 | // Return value is the number of copied character / number of character to copy (\0 is not included) 365 | // You should call this function 2 times - the first time you pass langDesc as NULL to get the number of characters to copy. 366 | // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGEDESC function the 2nd time 367 | // by passing allocated buffer as argument langDesc 368 | 369 | #define NPPM_SHOWDOCLIST (NPPMSG + 85) 370 | // VOID NPPM_SHOWDOCLIST(0, BOOL toShowOrNot) 371 | // Send this message to show or hide Document List. 372 | // if toShowOrNot is TRUE then show Document List, otherwise hide it. 373 | 374 | #define NPPM_ISDOCLISTSHOWN (NPPMSG + 86) 375 | // BOOL NPPM_ISDOCLISTSHOWN(0, 0) 376 | // Check to see if Document List is shown. 377 | 378 | #define NPPM_GETAPPDATAPLUGINSALLOWED (NPPMSG + 87) 379 | // BOOL NPPM_GETAPPDATAPLUGINSALLOWED(0, 0) 380 | // Check to see if loading plugins from "%APPDATA%\..\Local\Notepad++\plugins" is allowed. 381 | 382 | #define NPPM_GETCURRENTVIEW (NPPMSG + 88) 383 | // INT NPPM_GETCURRENTVIEW(0, 0) 384 | // Return: current edit view of Notepad++. Only 2 possible values: 0 = Main, 1 = Secondary 385 | 386 | #define NPPM_DOCLISTDISABLEEXTCOLUMN (NPPMSG + 89) 387 | // VOID NPPM_DOCLISTDISABLEEXTCOLUMN(0, BOOL disableOrNot) 388 | // Disable or enable extension column of Document List 389 | 390 | #define NPPM_DOCLISTDISABLEPATHCOLUMN (NPPMSG + 102) 391 | // VOID NPPM_DOCLISTDISABLEPATHCOLUMN(0, BOOL disableOrNot) 392 | // Disable or enable path column of Document List 393 | 394 | #define NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR (NPPMSG + 90) 395 | // INT NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR(0, 0) 396 | // Return: current editor default foreground color. You should convert the returned value in COLORREF 397 | 398 | #define NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR (NPPMSG + 91) 399 | // INT NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR(0, 0) 400 | // Return: current editor default background color. You should convert the returned value in COLORREF 401 | 402 | #define NPPM_SETSMOOTHFONT (NPPMSG + 92) 403 | // VOID NPPM_SETSMOOTHFONT(0, BOOL setSmoothFontOrNot) 404 | 405 | #define NPPM_SETEDITORBORDEREDGE (NPPMSG + 93) 406 | // VOID NPPM_SETEDITORBORDEREDGE(0, BOOL withEditorBorderEdgeOrNot) 407 | 408 | #define NPPM_SAVEFILE (NPPMSG + 94) 409 | // VOID NPPM_SAVEFILE(0, const TCHAR *fileNameToSave) 410 | 411 | #define NPPM_DISABLEAUTOUPDATE (NPPMSG + 95) // 2119 in decimal 412 | // VOID NPPM_DISABLEAUTOUPDATE(0, 0) 413 | 414 | #define NPPM_REMOVESHORTCUTBYCMDID (NPPMSG + 96) // 2120 in decimal 415 | // BOOL NPPM_REMOVESHORTCUTASSIGNMENT(int cmdID) 416 | // removes the assigned shortcut mapped to cmdID 417 | // returned value : TRUE if function call is successful, otherwise FALSE 418 | 419 | #define NPPM_GETPLUGINHOMEPATH (NPPMSG + 97) 420 | // INT NPPM_GETPLUGINHOMEPATH(size_t strLen, TCHAR *pluginRootPath) 421 | // Get plugin home root path. It's useful if plugins want to get its own path 422 | // by appending which is the name of plugin without extension part. 423 | // Returns the number of TCHAR copied/to copy. 424 | // Users should call it with pluginRootPath be NULL to get the required number of TCHAR (not including the terminating nul character), 425 | // allocate pluginRootPath buffer with the return value + 1, then call it again to get the path. 426 | 427 | #define NPPM_GETSETTINGSONCLOUDPATH (NPPMSG + 98) 428 | // INT NPPM_GETSETTINGSCLOUDPATH(size_t strLen, TCHAR *settingsOnCloudPath) 429 | // Get settings on cloud path. It's useful if plugins want to store its settings on Cloud, if this path is set. 430 | // Returns the number of TCHAR copied/to copy. If the return value is 0, then this path is not set, or the "strLen" is not enough to copy the path. 431 | // Users should call it with settingsCloudPath be NULL to get the required number of TCHAR (not including the terminating nul character), 432 | // allocate settingsCloudPath buffer with the return value + 1, then call it again to get the path. 433 | 434 | #define NPPM_SETLINENUMBERWIDTHMODE (NPPMSG + 99) 435 | #define LINENUMWIDTH_DYNAMIC 0 436 | #define LINENUMWIDTH_CONSTANT 1 437 | // BOOL NPPM_SETLINENUMBERWIDTHMODE(0, INT widthMode) 438 | // Set line number margin width in dynamic width mode (LINENUMWIDTH_DYNAMIC) or constant width mode (LINENUMWIDTH_CONSTANT) 439 | // It may help some plugins to disable non-dynamic line number margins width to have a smoothly visual effect while vertical scrolling the content in Notepad++ 440 | // If calling is successful return TRUE, otherwise return FALSE. 441 | 442 | #define NPPM_GETLINENUMBERWIDTHMODE (NPPMSG + 100) 443 | // INT NPPM_GETLINENUMBERWIDTHMODE(0, 0) 444 | // Get line number margin width in dynamic width mode (LINENUMWIDTH_DYNAMIC) or constant width mode (LINENUMWIDTH_CONSTANT) 445 | 446 | #define NPPM_ADDTOOLBARICON_FORDARKMODE (NPPMSG + 101) 447 | // VOID NPPM_ADDTOOLBARICON_FORDARKMODE(UINT funcItem[X]._cmdID, toolbarIconsWithDarkMode iconHandles) 448 | // Use NPPM_ADDTOOLBARICON_FORDARKMODE instead obsolete NPPM_ADDTOOLBARICON which doesn't support the dark mode 449 | // 2 formats / 3 icons are needed: 1 * BMP + 2 * ICO 450 | // All 3 handles below should be set so the icon will be displayed correctly if toolbar icon sets are changed by users, also in dark mode 451 | struct toolbarIconsWithDarkMode { 452 | HBITMAP hToolbarBmp; 453 | HICON hToolbarIcon; 454 | HICON hToolbarIconDarkMode; 455 | }; 456 | 457 | #define VAR_NOT_RECOGNIZED 0 458 | #define FULL_CURRENT_PATH 1 459 | #define CURRENT_DIRECTORY 2 460 | #define FILE_NAME 3 461 | #define NAME_PART 4 462 | #define EXT_PART 5 463 | #define CURRENT_WORD 6 464 | #define NPP_DIRECTORY 7 465 | #define CURRENT_LINE 8 466 | #define CURRENT_COLUMN 9 467 | #define NPP_FULL_FILE_PATH 10 468 | #define GETFILENAMEATCURSOR 11 469 | 470 | #define RUNCOMMAND_USER (WM_USER + 3000) 471 | #define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH) 472 | #define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY) 473 | #define NPPM_GETFILENAME (RUNCOMMAND_USER + FILE_NAME) 474 | #define NPPM_GETNAMEPART (RUNCOMMAND_USER + NAME_PART) 475 | #define NPPM_GETEXTPART (RUNCOMMAND_USER + EXT_PART) 476 | #define NPPM_GETCURRENTWORD (RUNCOMMAND_USER + CURRENT_WORD) 477 | #define NPPM_GETNPPDIRECTORY (RUNCOMMAND_USER + NPP_DIRECTORY) 478 | #define NPPM_GETFILENAMEATCURSOR (RUNCOMMAND_USER + GETFILENAMEATCURSOR) 479 | // BOOL NPPM_GETXXXXXXXXXXXXXXXX(size_t strLen, TCHAR *str) 480 | // where str is the allocated TCHAR array, 481 | // strLen is the allocated array size 482 | // The return value is TRUE when get generic_string operation success 483 | // Otherwise (allocated array size is too small) FALSE 484 | 485 | #define NPPM_GETCURRENTLINE (RUNCOMMAND_USER + CURRENT_LINE) 486 | // INT NPPM_GETCURRENTLINE(0, 0) 487 | // return the caret current position line 488 | #define NPPM_GETCURRENTCOLUMN (RUNCOMMAND_USER + CURRENT_COLUMN) 489 | // INT NPPM_GETCURRENTCOLUMN(0, 0) 490 | // return the caret current position column 491 | 492 | #define NPPM_GETNPPFULLFILEPATH (RUNCOMMAND_USER + NPP_FULL_FILE_PATH) 493 | 494 | 495 | 496 | // Notification code 497 | #define NPPN_FIRST 1000 498 | #define NPPN_READY (NPPN_FIRST + 1) // To notify plugins that all the procedures of launchment of notepad++ are done. 499 | //scnNotification->nmhdr.code = NPPN_READY; 500 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 501 | //scnNotification->nmhdr.idFrom = 0; 502 | 503 | #define NPPN_TBMODIFICATION (NPPN_FIRST + 2) // To notify plugins that toolbar icons can be registered 504 | //scnNotification->nmhdr.code = NPPN_TBMODIFICATION; 505 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 506 | //scnNotification->nmhdr.idFrom = 0; 507 | 508 | #define NPPN_FILEBEFORECLOSE (NPPN_FIRST + 3) // To notify plugins that the current file is about to be closed 509 | //scnNotification->nmhdr.code = NPPN_FILEBEFORECLOSE; 510 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 511 | //scnNotification->nmhdr.idFrom = BufferID; 512 | 513 | #define NPPN_FILEOPENED (NPPN_FIRST + 4) // To notify plugins that the current file is just opened 514 | //scnNotification->nmhdr.code = NPPN_FILEOPENED; 515 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 516 | //scnNotification->nmhdr.idFrom = BufferID; 517 | 518 | #define NPPN_FILECLOSED (NPPN_FIRST + 5) // To notify plugins that the current file is just closed 519 | //scnNotification->nmhdr.code = NPPN_FILECLOSED; 520 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 521 | //scnNotification->nmhdr.idFrom = BufferID; 522 | 523 | #define NPPN_FILEBEFOREOPEN (NPPN_FIRST + 6) // To notify plugins that the current file is about to be opened 524 | //scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN; 525 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 526 | //scnNotification->nmhdr.idFrom = BufferID; 527 | 528 | #define NPPN_FILEBEFORESAVE (NPPN_FIRST + 7) // To notify plugins that the current file is about to be saved 529 | //scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN; 530 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 531 | //scnNotification->nmhdr.idFrom = BufferID; 532 | 533 | #define NPPN_FILESAVED (NPPN_FIRST + 8) // To notify plugins that the current file is just saved 534 | //scnNotification->nmhdr.code = NPPN_FILESAVED; 535 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 536 | //scnNotification->nmhdr.idFrom = BufferID; 537 | 538 | #define NPPN_SHUTDOWN (NPPN_FIRST + 9) // To notify plugins that Notepad++ is about to be shutdowned. 539 | //scnNotification->nmhdr.code = NPPN_SHUTDOWN; 540 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 541 | //scnNotification->nmhdr.idFrom = 0; 542 | 543 | #define NPPN_BUFFERACTIVATED (NPPN_FIRST + 10) // To notify plugins that a buffer was activated (put to foreground). 544 | //scnNotification->nmhdr.code = NPPN_BUFFERACTIVATED; 545 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 546 | //scnNotification->nmhdr.idFrom = activatedBufferID; 547 | 548 | #define NPPN_LANGCHANGED (NPPN_FIRST + 11) // To notify plugins that the language in the current doc is just changed. 549 | //scnNotification->nmhdr.code = NPPN_LANGCHANGED; 550 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 551 | //scnNotification->nmhdr.idFrom = currentBufferID; 552 | 553 | #define NPPN_WORDSTYLESUPDATED (NPPN_FIRST + 12) // To notify plugins that user initiated a WordStyleDlg change. 554 | //scnNotification->nmhdr.code = NPPN_WORDSTYLESUPDATED; 555 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 556 | //scnNotification->nmhdr.idFrom = currentBufferID; 557 | 558 | #define NPPN_SHORTCUTREMAPPED (NPPN_FIRST + 13) // To notify plugins that plugin command shortcut is remapped. 559 | //scnNotification->nmhdr.code = NPPN_SHORTCUTSREMAPPED; 560 | //scnNotification->nmhdr.hwndFrom = ShortcutKeyStructurePointer; 561 | //scnNotification->nmhdr.idFrom = cmdID; 562 | //where ShortcutKeyStructurePointer is pointer of struct ShortcutKey: 563 | //struct ShortcutKey { 564 | // bool _isCtrl; 565 | // bool _isAlt; 566 | // bool _isShift; 567 | // UCHAR _key; 568 | //}; 569 | 570 | #define NPPN_FILEBEFORELOAD (NPPN_FIRST + 14) // To notify plugins that the current file is about to be loaded 571 | //scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN; 572 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 573 | //scnNotification->nmhdr.idFrom = NULL; 574 | 575 | #define NPPN_FILELOADFAILED (NPPN_FIRST + 15) // To notify plugins that file open operation failed 576 | //scnNotification->nmhdr.code = NPPN_FILEOPENFAILED; 577 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 578 | //scnNotification->nmhdr.idFrom = BufferID; 579 | 580 | #define NPPN_READONLYCHANGED (NPPN_FIRST + 16) // To notify plugins that current document change the readonly status, 581 | //scnNotification->nmhdr.code = NPPN_READONLYCHANGED; 582 | //scnNotification->nmhdr.hwndFrom = bufferID; 583 | //scnNotification->nmhdr.idFrom = docStatus; 584 | // where bufferID is BufferID 585 | // docStatus can be combined by DOCSTATUS_READONLY and DOCSTATUS_BUFFERDIRTY 586 | 587 | #define DOCSTATUS_READONLY 1 588 | #define DOCSTATUS_BUFFERDIRTY 2 589 | 590 | #define NPPN_DOCORDERCHANGED (NPPN_FIRST + 17) // To notify plugins that document order is changed 591 | //scnNotification->nmhdr.code = NPPN_DOCORDERCHANGED; 592 | //scnNotification->nmhdr.hwndFrom = newIndex; 593 | //scnNotification->nmhdr.idFrom = BufferID; 594 | 595 | #define NPPN_SNAPSHOTDIRTYFILELOADED (NPPN_FIRST + 18) // To notify plugins that a snapshot dirty file is loaded on startup 596 | //scnNotification->nmhdr.code = NPPN_SNAPSHOTDIRTYFILELOADED; 597 | //scnNotification->nmhdr.hwndFrom = NULL; 598 | //scnNotification->nmhdr.idFrom = BufferID; 599 | 600 | #define NPPN_BEFORESHUTDOWN (NPPN_FIRST + 19) // To notify plugins that Npp shutdown has been triggered, files have not been closed yet 601 | //scnNotification->nmhdr.code = NPPN_BEFORESHUTDOWN; 602 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 603 | //scnNotification->nmhdr.idFrom = 0; 604 | 605 | #define NPPN_CANCELSHUTDOWN (NPPN_FIRST + 20) // To notify plugins that Npp shutdown has been cancelled 606 | //scnNotification->nmhdr.code = NPPN_CANCELSHUTDOWN; 607 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 608 | //scnNotification->nmhdr.idFrom = 0; 609 | 610 | #define NPPN_FILEBEFORERENAME (NPPN_FIRST + 21) // To notify plugins that file is to be renamed 611 | //scnNotification->nmhdr.code = NPPN_FILEBEFORERENAME; 612 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 613 | //scnNotification->nmhdr.idFrom = BufferID; 614 | 615 | #define NPPN_FILERENAMECANCEL (NPPN_FIRST + 22) // To notify plugins that file rename has been cancelled 616 | //scnNotification->nmhdr.code = NPPN_FILERENAMECANCEL; 617 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 618 | //scnNotification->nmhdr.idFrom = BufferID; 619 | 620 | #define NPPN_FILERENAMED (NPPN_FIRST + 23) // To notify plugins that file has been renamed 621 | //scnNotification->nmhdr.code = NPPN_FILERENAMED; 622 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 623 | //scnNotification->nmhdr.idFrom = BufferID; 624 | 625 | #define NPPN_FILEBEFOREDELETE (NPPN_FIRST + 24) // To notify plugins that file is to be deleted 626 | //scnNotification->nmhdr.code = NPPN_FILEBEFOREDELETE; 627 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 628 | //scnNotification->nmhdr.idFrom = BufferID; 629 | 630 | #define NPPN_FILEDELETEFAILED (NPPN_FIRST + 25) // To notify plugins that file deletion has failed 631 | //scnNotification->nmhdr.code = NPPN_FILEDELETEFAILED; 632 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 633 | //scnNotification->nmhdr.idFrom = BufferID; 634 | 635 | #define NPPN_FILEDELETED (NPPN_FIRST + 26) // To notify plugins that file has been deleted 636 | //scnNotification->nmhdr.code = NPPN_FILEDELETED; 637 | //scnNotification->nmhdr.hwndFrom = hwndNpp; 638 | //scnNotification->nmhdr.idFrom = BufferID; 639 | -------------------------------------------------------------------------------- /PluginDefinition.cpp: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #include "DockingFeature/SettingsDlg.h" 19 | #include "PluginDefinition.h" 20 | #include "resource.h" 21 | #include "DockingFeature/GitPanelDlg.h" 22 | #include "menuCmdID.h" 23 | #include "stdafx.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | const TCHAR configFileName[] = TEXT( "GitSCM.ini" ); 30 | const TCHAR sectionName[] = TEXT( "Git" ); 31 | const TCHAR iniKeyTortoise[] = TEXT( "Tortoise" ); 32 | const TCHAR iniKeyGitPath[] = TEXT( "GitPath" ); 33 | const TCHAR iniKeyGitPrompt[] = TEXT( "GitPrompt" ); 34 | const TCHAR iniKeyUseNppColors[] = TEXT( "UseNppColors" ); 35 | const TCHAR iniKeyRaisePanel[] = TEXT( "RaisePanelorToggle" ); 36 | const TCHAR iniKeyRefScnFocus[] = TEXT( "RefreshScnFocus" ); 37 | const TCHAR iniKeyDiffWordDiff[] = TEXT( "DiffWordDiff" ); 38 | const TCHAR iniKeyDebug[] = TEXT( "Debug" ); 39 | const TCHAR iniKeyLVDelay[] = TEXT( "LVDelay" ); 40 | const TCHAR iniKeyGitGuiBlame[] = TEXT( "GitGuiBlame" ); 41 | 42 | DemoDlg _gitPanel; 43 | 44 | toolbarIcons g_TBGit; 45 | 46 | // 47 | // The plugin data that Notepad++ needs 48 | // 49 | FuncItem funcItem[nbFunc]; 50 | 51 | // 52 | // The data of Notepad++ that you can use in your plugin commands 53 | // 54 | NppData nppData; 55 | HINSTANCE g_hInst; 56 | 57 | TCHAR iniFilePath[MAX_PATH]; 58 | TCHAR g_GitPath[MAX_PATH]; 59 | TCHAR g_GitPrompt[MAX_PATH]; 60 | bool g_useTortoise = false; 61 | bool g_NppReady = false; 62 | bool g_useNppColors = false; 63 | bool g_RaisePanel = false; 64 | bool g_RefScnFocus = false; 65 | bool g_DiffWordDiff = false; 66 | bool g_gitGuiBlame = false; 67 | 68 | // g_Debug and g_LVDelay must be set manually in config file ($NPP_DIR\plugins\config\GitSCM.ini) 69 | // ON => Debug=1 70 | // OFF => Debug=0 71 | // LVDelay=<# milliseconds> 72 | // It is read at startup, it is NOT written back to the config file! 73 | // When set ON, use DebugView (DbgView.exe) https://www.sysinternals.com 74 | bool g_Debug = false; 75 | int g_LVDelay = LSV1_REFRESH_DELAY; 76 | 77 | std::wstring g_tortoiseLoc; 78 | 79 | // 80 | // Initialize your plugin data here 81 | // It will be called while plugin loading 82 | void pluginInit( HANDLE hModule ) 83 | { 84 | // Initialize dockable dialog 85 | _gitPanel.init( ( HINSTANCE )hModule, NULL ); 86 | } 87 | 88 | // 89 | // Here you can do the clean up, save the parameters (if any) for the next session 90 | // 91 | void pluginCleanUp() 92 | { 93 | ::WritePrivateProfileString( sectionName, iniKeyTortoise, 94 | g_useTortoise ? TEXT( "1" ) : TEXT( "0" ), iniFilePath ); 95 | ::WritePrivateProfileString( sectionName, iniKeyGitPath, 96 | g_GitPath, iniFilePath); 97 | ::WritePrivateProfileString( sectionName, iniKeyGitPrompt, 98 | g_GitPrompt, iniFilePath); 99 | ::WritePrivateProfileString( sectionName, iniKeyUseNppColors, 100 | g_useNppColors ? TEXT( "1" ) : TEXT( "0" ), iniFilePath ); 101 | ::WritePrivateProfileString( sectionName, iniKeyRaisePanel, 102 | g_RaisePanel ? TEXT( "1" ) : TEXT( "0" ), iniFilePath ); 103 | ::WritePrivateProfileString( sectionName, iniKeyRefScnFocus, 104 | g_RefScnFocus ? TEXT( "1" ) : TEXT( "0" ), iniFilePath ); 105 | ::WritePrivateProfileString( sectionName, iniKeyDiffWordDiff, 106 | g_DiffWordDiff ? TEXT( "1" ) : TEXT( "0" ), iniFilePath ); 107 | ::WritePrivateProfileString( sectionName, iniKeyGitGuiBlame, 108 | g_gitGuiBlame ? TEXT( "1" ) : TEXT( "0" ), iniFilePath); 109 | 110 | if (g_TBGit.hToolbarBmp) { 111 | ::DeleteObject(g_TBGit.hToolbarBmp); 112 | g_TBGit.hToolbarBmp = nullptr; 113 | } 114 | if (g_TBGit.hToolbarIcon) { 115 | ::DestroyIcon(g_TBGit.hToolbarIcon); 116 | g_TBGit.hToolbarIcon = nullptr; 117 | } 118 | } 119 | 120 | // 121 | // Initialization of your plugin commands 122 | // You should fill your plugins commands here 123 | void commandMenuInit() 124 | { 125 | // 126 | // Firstly we get the parameters from your plugin config file (if any) 127 | // 128 | 129 | // get path of plugin configuration 130 | ::SendMessage( nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, 131 | ( LPARAM )iniFilePath ); 132 | 133 | // if config path doesn't exist, we create it 134 | if ( PathFileExists( iniFilePath ) == FALSE ) 135 | ::CreateDirectory( iniFilePath, NULL ); 136 | 137 | // make your plugin config file full file path name 138 | PathAppend( iniFilePath, configFileName ); 139 | 140 | // get the parameter value from plugin config 141 | g_useTortoise = ::GetPrivateProfileInt( sectionName, iniKeyTortoise, 142 | 0, iniFilePath ); 143 | ::GetPrivateProfileString( sectionName, iniKeyGitPath, TEXT(""), 144 | g_GitPath, MAX_PATH, iniFilePath ); 145 | ::GetPrivateProfileString( sectionName, iniKeyGitPrompt, TEXT("powershell.exe"), 146 | g_GitPrompt, MAX_PATH, iniFilePath ); 147 | g_useNppColors = ::GetPrivateProfileInt( sectionName, iniKeyUseNppColors, 148 | 0, iniFilePath ); 149 | g_RaisePanel = ::GetPrivateProfileInt( sectionName, iniKeyRaisePanel, 150 | 0, iniFilePath ); 151 | g_RefScnFocus = ::GetPrivateProfileInt( sectionName, iniKeyRefScnFocus, 152 | 0, iniFilePath ); 153 | g_DiffWordDiff = ::GetPrivateProfileInt( sectionName, iniKeyDiffWordDiff, 154 | 0, iniFilePath ); 155 | g_gitGuiBlame = ::GetPrivateProfileInt(sectionName, iniKeyGitGuiBlame, 156 | 0, iniFilePath); 157 | 158 | g_Debug = ::GetPrivateProfileInt( sectionName, iniKeyDebug, 159 | 0, iniFilePath ); 160 | g_LVDelay = ::GetPrivateProfileInt( sectionName, iniKeyLVDelay, 161 | 0, iniFilePath ); 162 | 163 | if ( g_useTortoise ) 164 | { 165 | if ( ! getTortoiseLocation( g_tortoiseLoc ) ) 166 | g_useTortoise = false; 167 | } 168 | 169 | //--------------------------------------------// 170 | //-- STEP 3. CUSTOMIZE YOUR PLUGIN COMMANDS --// 171 | //--------------------------------------------// 172 | // with function : 173 | // setCommand(int index, // zero based number to indicate the order of command 174 | // TCHAR *commandName, // the command name that you want to see in plugin menu 175 | // PFUNCPLUGINCMD functionPointer, // the symbol of function (function pointer) associated with this command. The body should be defined below. See Step 4. 176 | // ShortcutKey *shortcut, // optional. Define a shortcut to trigger this command 177 | // bool check0nInit // optional. Make this menu item be checked visually 178 | // ); 179 | 180 | setCommand( 0, TEXT( "Git &GUI" ), gitGui, NULL, false ); 181 | setCommand( 1, TEXT( "GiT&k" ), giTk, NULL, false ); 182 | setCommand( 2, TEXT( "Git Pro&mpt" ), gitPrompt, NULL, false ); 183 | setCommand( 3, TEXT( "-SEPARATOR-" ), NULL, NULL, false ); 184 | setCommand( DOCKABLE_INDEX, TEXT( "Git Docking Panel" ), DockableDlg, NULL, _gitPanel.isVisible() ? true : false ); 185 | setCommand( 5, TEXT( "-SEPARATOR-" ), NULL, NULL, false ); 186 | setCommand( 6, TEXT( "&Add File" ), addFile, NULL, false ); 187 | setCommand( 7, TEXT( "&Unstage File" ), unstageFile, NULL, false ); 188 | setCommand( 8, TEXT( "&Restore File" ), restoreFile, NULL, false ); 189 | setCommand( 9, TEXT( "&Diff File" ), diffFile, NULL, false ); 190 | setCommand( 10, TEXT( "&Log File" ), logFile, NULL, false ); 191 | setCommand( 11, TEXT( "&Blame File" ), blameFile, NULL, false ); 192 | setCommand( 12, TEXT( "-SEPARATOR-" ), NULL, NULL, false ); 193 | setCommand( 13, TEXT( "&Pull" ), pullFile, NULL, false ); 194 | setCommand( 14, TEXT( "&Status" ), statusAll, NULL, false ); 195 | setCommand( 15, TEXT( "Bra&nch/Checkout" ), branchFile, NULL, false ); 196 | setCommand( 16, TEXT( "&Commit" ), commitAll, NULL, false ); 197 | setCommand( 17, TEXT( "Pus&h" ), pushFile, NULL, false ); 198 | setCommand( 18, TEXT( "-SEPARATOR-" ), NULL, NULL, false ); 199 | setCommand( TORTOISE_INDEX, TEXT( "Use &TortoiseGit" ), doTortoise, NULL, g_useTortoise ? true : false ); 200 | setCommand( 20, TEXT( "S&ettings" ), doSettings, NULL, false ); 201 | } 202 | 203 | // 204 | // Here you can do the clean up (especially for the shortcut) 205 | // 206 | void commandMenuCleanUp() 207 | { 208 | // Don't forget to deallocate your shortcut here 209 | } 210 | 211 | // 212 | // This function help you to initialize your plugin commands 213 | // 214 | bool setCommand( size_t index, TCHAR *cmdName, PFUNCPLUGINCMD pFunc, 215 | ShortcutKey *sk, bool check0nInit ) 216 | { 217 | if ( index >= nbFunc ) 218 | return false; 219 | 220 | if ( !pFunc ) 221 | return false; 222 | 223 | lstrcpy( funcItem[index]._itemName, cmdName ); 224 | funcItem[index]._pFunc = pFunc; 225 | funcItem[index]._init2Check = check0nInit; 226 | funcItem[index]._pShKey = sk; 227 | 228 | return true; 229 | } 230 | 231 | //----------------------------------------------// 232 | //-- STEP 4. DEFINE YOUR ASSOCIATED FUNCTIONS --// 233 | //----------------------------------------------// 234 | 235 | /// 236 | /// Gets the path to the current file. 237 | /// 238 | /// @return Current file path. 239 | /// 240 | HWND getCurScintilla() 241 | { 242 | int which = -1; 243 | ::SendMessage( nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, 244 | ( LPARAM )&which ); 245 | return ( which == 0 ) ? nppData._scintillaMainHandle : 246 | nppData._scintillaSecondHandle; 247 | } 248 | 249 | std::wstring getCurrentFile() 250 | { 251 | TCHAR path[MAX_PATH]; 252 | ::SendMessage( nppData._nppHandle, NPPM_GETFULLCURRENTPATH, MAX_PATH, 253 | ( LPARAM )path ); 254 | 255 | return std::wstring( path ); 256 | } 257 | 258 | /// 259 | /// Gets the path to the current file's directory. 260 | /// 261 | /// @return Current file's directory path. 262 | /// 263 | std::wstring getCurrentFileDirectory() 264 | { 265 | TCHAR path[MAX_PATH]; 266 | ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTDIRECTORY, MAX_PATH, 267 | (LPARAM)path); 268 | 269 | return std::wstring( path ); 270 | } 271 | 272 | std::wstring GetLastErrorString(DWORD errorCode) 273 | { 274 | std::wstring errorMsg(_T("")); 275 | // Get the error message, if any. 276 | // If both error codes (passed error n GetLastError) are 0, then return empty 277 | if (errorCode == 0) 278 | errorCode = GetLastError(); 279 | if (errorCode == 0) 280 | return errorMsg; //No error message has been recorded 281 | 282 | LPWSTR messageBuffer = nullptr; 283 | FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 284 | nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr); 285 | 286 | errorMsg += messageBuffer; 287 | 288 | //Free the buffer. 289 | LocalFree(messageBuffer); 290 | 291 | return errorMsg; 292 | } 293 | 294 | /// 295 | /// Gets the path to the TortioseGit executable from the registry. 296 | /// 297 | /// @param loc [out] Location of Tortoise executable 298 | /// 299 | /// @return Whether or not the path was successfully retrieved. 300 | /// If false, Tortoise is most likely not installed. 301 | bool getTortoiseLocation( std::wstring &loc ) 302 | { 303 | HKEY hKey; 304 | 305 | if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT( "Software\\TortoiseGit" ), 0, 306 | KEY_READ | KEY_WOW64_64KEY, &hKey ) != ERROR_SUCCESS ) 307 | return false; 308 | 309 | TCHAR procPath[MAX_PATH]; 310 | DWORD length = MAX_PATH; 311 | 312 | // Modified Douglas Phillips 2008-12-29 to 313 | // support 32-bit and Non-Vista operating Systems. 314 | if ( RegQueryValueEx( 315 | hKey, 316 | TEXT( "ProcPath" ), 317 | NULL, 318 | NULL, 319 | ( LPBYTE )procPath, 320 | &length ) != ERROR_SUCCESS ) 321 | return false; 322 | 323 | loc = procPath; 324 | return true; 325 | } 326 | 327 | std::wstring getGitLocation() 328 | { 329 | std::wstring gp = g_GitPath; 330 | if ( gp.size() == 0 ) 331 | return TEXT(""); 332 | else 333 | { 334 | gp += TEXT("\\"); 335 | return gp; 336 | } 337 | } 338 | 339 | /// 340 | /// Launches Git using the supplied command 341 | /// 342 | /// @param Command line string to execute. 343 | /// 344 | /// @return Whether or not Git could be launched. 345 | /// 346 | int launchGit( std::wstring &command, bool b_notGui = true ) 347 | { 348 | STARTUPINFOW si; 349 | PROCESS_INFORMATION pi; 350 | memset( &si, 0, sizeof( si ) ); 351 | memset( &pi, 0, sizeof( pi ) ); 352 | si.cb = sizeof( si ); 353 | 354 | if ( g_Debug ) 355 | OutputDebugString( command.c_str() ); 356 | 357 | int ret = 0; 358 | std::wstring path = getCurrentFileDirectory().c_str(); 359 | if ( path.length() > 0 || b_notGui ) 360 | ret = CreateProcess( 361 | NULL, 362 | const_cast( command.c_str() ), 363 | NULL, 364 | NULL, 365 | FALSE, 366 | CREATE_DEFAULT_ERROR_MODE, 367 | NULL, 368 | const_cast( getCurrentFileDirectory().c_str() ), 369 | &si, 370 | &pi 371 | ); 372 | else 373 | ret = CreateProcess( 374 | NULL, 375 | const_cast( command.c_str() ), 376 | NULL, 377 | NULL, 378 | FALSE, 379 | CREATE_DEFAULT_ERROR_MODE, 380 | NULL, 381 | NULL, 382 | &si, 383 | &pi 384 | ); 385 | 386 | if ( (ret == 0) && (path.length() == 0) ) 387 | ret = -1; 388 | return ret; 389 | } 390 | 391 | /// 392 | /// Builds and executes command line string to send to CreateProcess 393 | /// 394 | /// @param cmd Command name to execute. 395 | /// @param all Execute command on all files, or just the current file. 396 | /// @param ignoreFiles No files 397 | /// @param pause Pause after command. 398 | /// 399 | void ExecGitCommand( 400 | const std::wstring &cmd, 401 | std::vector files, 402 | bool ignoreFiles = false, 403 | bool pause = true ) 404 | { 405 | std::wstring command = TEXT( "cmd /d/c \"\"" ); 406 | command += getGitLocation(); 407 | command += TEXT( "git" ); 408 | command += cmd + TEXT( " " ); 409 | 410 | if ( !ignoreFiles ) 411 | { 412 | for ( std::vector::iterator itr = files.begin(); 413 | itr != files.end(); itr++ ) 414 | { 415 | command += TEXT( "\"" ); 416 | command += ( *itr ); 417 | command += TEXT( "\"" ); 418 | 419 | if ( itr != files.end() - 1 ) 420 | command += TEXT( " " ); 421 | } 422 | } 423 | 424 | if ( pause ) 425 | command += TEXT( " & pause" ); 426 | 427 | command += TEXT( "\"" ); 428 | 429 | bool b_notGui = true; 430 | if ( ignoreFiles && !pause ) 431 | b_notGui = false; 432 | 433 | int ret = launchGit( command, b_notGui ); 434 | if ( ret <= 0 ) 435 | { 436 | std::wstring err = TEXT( "Could not launch Git.\n\n" ); 437 | err += GetLastErrorString(GetLastError()); 438 | if ( ret == -1 ) 439 | err += TEXT( "\nCurrent directory is empty.\n Is this a \"new-1\" file or have you saved it?\n Is the file in a current git repo directory?" ); 440 | MessageBox( nppData._nppHandle, err.c_str(), 441 | TEXT( "Failed" ), ( MB_OK | MB_ICONWARNING | MB_APPLMODAL ) ); 442 | } 443 | 444 | updatePanel(); 445 | } 446 | 447 | /// 448 | /// Builds and executes command line string to send to CreateProcess 449 | /// See http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-automation.html 450 | /// for TortoiseSVN command line parameters. 451 | /// 452 | /// @param cmd Command name to execute. 453 | /// @param all Execute command on all files, or just the current file. 454 | /// 455 | void ExecTortoiseCommand( 456 | const std::wstring &cmd, 457 | std::vector files, 458 | bool ignoreFiles = false, 459 | bool pause = true ) 460 | { 461 | std::wstring command = g_tortoiseLoc; 462 | command += TEXT( " /command:" ) + cmd + TEXT( " /path:\"" ); 463 | 464 | if ( !ignoreFiles ) 465 | { 466 | for ( std::vector::iterator itr = files.begin(); 467 | itr != files.end(); itr++ ) 468 | { 469 | command += ( *itr ); 470 | 471 | if ( itr != files.end() - 1 ) 472 | command += TEXT( "*" ); 473 | } 474 | } 475 | else 476 | command += TEXT( "*" ); 477 | 478 | if ( pause ) 479 | command += TEXT( "\" /closeonend:0" ); 480 | else 481 | command += TEXT( "\" /closeonend:2" ); 482 | 483 | int ret = launchGit( command ); 484 | if ( ret <= 0 ) 485 | { 486 | std::wstring err = TEXT( "Could not launch TortoiseGit.\n\n" ); 487 | err += GetLastErrorString(GetLastError()); 488 | if ( ret == -1 ) 489 | err += TEXT( "\nCurrent directory is empty.\n Is this a \"new-1\" file or have you saved it?\n Is the file in a current git repo directory?" ); 490 | MessageBox( nppData._nppHandle, err.c_str(), 491 | TEXT( "Failed" ), ( MB_OK | MB_ICONWARNING | MB_APPLMODAL ) ); 492 | } 493 | 494 | updatePanel(); 495 | } 496 | 497 | //////////////////////////////////////////////////////////////////////////// 498 | /// 499 | /// Execution commands: 500 | /// 501 | void updatePanelLoc() 502 | { 503 | if ( _gitPanel.isVisible() ) 504 | { 505 | std::wstring temp; 506 | _gitPanel.updateLoc( temp ); 507 | _gitPanel.updateListWithDelay(); 508 | } 509 | } 510 | 511 | void updatePanel() 512 | { 513 | if ( _gitPanel.isVisible() ) 514 | _gitPanel.updateList(); 515 | } 516 | 517 | void gitPrompt() 518 | { 519 | std::wstring pathName; 520 | if ( _gitPanel.isVisible() ) 521 | _gitPanel.updateLoc( pathName ); 522 | else 523 | pathName = getCurrentFileDirectory(); 524 | 525 | ShellExecute( nppData._nppHandle, TEXT("open"), g_GitPrompt, NULL, pathName.c_str(), SW_SHOW ); 526 | } 527 | 528 | void gitGui() 529 | { 530 | std::vector files = {}; 531 | gitGuiFiles( files ); 532 | } 533 | void gitGuiFiles( std::vector files ) 534 | { 535 | ExecGitCommand( TEXT( "-gui\"" ), files, true, false ); 536 | } 537 | 538 | void giTk() 539 | { 540 | std::vector files = {}; 541 | giTkFiles( files ); 542 | } 543 | void giTkFiles( std::vector files = {} ) 544 | { 545 | ExecGitCommand( TEXT( "k\" --all" ), files, true, false ); 546 | } 547 | 548 | void statusAll() 549 | { 550 | std::vector files = {}; 551 | statusAllFiles( files ); 552 | } 553 | void statusAllFiles( std::vector files = {} ) 554 | { 555 | if ( g_useTortoise ) 556 | ExecTortoiseCommand( TEXT( "repostatus" ), files, true , true); 557 | else 558 | ExecGitCommand( TEXT( "\" status" ), files, true, true); 559 | } 560 | 561 | void commitAll() 562 | { 563 | std::vector files = {}; 564 | commitAllFiles( files ); 565 | } 566 | void commitAllFiles( std::vector files = {} ) 567 | { 568 | if ( g_useTortoise ) 569 | ExecTortoiseCommand( TEXT( "commit" ), files, true, true ); 570 | else 571 | ExecGitCommand( TEXT( "\" commit" ), files, true, true ); 572 | } 573 | 574 | void addFile() 575 | { 576 | std::vector files = {}; 577 | addFileFiles( files ); 578 | } 579 | void addFileFiles( std::vector files = {} ) 580 | { 581 | if ( files.size() == 0 ) 582 | files.push_back( getCurrentFile() ); 583 | 584 | if ( g_useTortoise ) 585 | ExecTortoiseCommand( TEXT( "add" ), files, false, false ); 586 | else 587 | ExecGitCommand( TEXT( "\" add" ), files, false, false ); 588 | } 589 | 590 | void diffFile() 591 | { 592 | std::vector files = {}; 593 | diffFileFiles( files ); 594 | } 595 | void diffFileFiles( std::vector files = {} ) 596 | { 597 | if ( files.size() == 0 ) 598 | files.push_back( getCurrentFile() ); 599 | 600 | if ( g_useTortoise ) 601 | ExecTortoiseCommand( TEXT( "diff" ), files, false, true ); 602 | else 603 | { 604 | if ( g_DiffWordDiff ) 605 | ExecGitCommand( TEXT( "\" diff --word-diff" ), files, false, true ); 606 | else 607 | ExecGitCommand( TEXT( "\" diff" ), files, false, true ); 608 | } 609 | } 610 | 611 | void unstageFile() 612 | { 613 | std::vector files = {}; 614 | unstageFileFiles( files ); 615 | } 616 | void unstageFileFiles( std::vector files = {} ) 617 | { 618 | if ( files.size() == 0 ) 619 | files.push_back( getCurrentFile() ); 620 | 621 | ExecGitCommand( TEXT( "\" reset HEAD" ), files, false, false ); 622 | } 623 | 624 | void restoreFile() 625 | { 626 | std::vector files = {}; 627 | restoreFileFiles( files ); 628 | } 629 | void restoreFileFiles( std::vector files = {} ) 630 | { 631 | if ( files.size() == 0 ) 632 | files.push_back( getCurrentFile() ); 633 | 634 | if ( g_useTortoise ) 635 | ExecTortoiseCommand( TEXT( "revert" ), files, false, false ); 636 | else 637 | ExecGitCommand( TEXT( "\" checkout --" ), files, false, false ); 638 | } 639 | 640 | void logFile() 641 | { 642 | std::vector files = {}; 643 | logFileFiles( files ); 644 | } 645 | void logFileFiles( std::vector files = {} ) 646 | { 647 | if ( files.size() == 0 ) 648 | files.push_back( getCurrentFile() ); 649 | 650 | if ( g_useTortoise ) 651 | ExecTortoiseCommand( TEXT( "log" ), files, false, true ); 652 | else 653 | ExecGitCommand( TEXT( "\" log" ), files, false, true ); 654 | } 655 | 656 | void blameFile() 657 | { 658 | std::vector files = {}; 659 | blameFileFiles( files ); 660 | } 661 | void blameFileFiles( std::vector files = {} ) 662 | { 663 | if ( files.size() == 0 ) 664 | files.push_back( getCurrentFile() ); 665 | 666 | Sci_Position pos = (Sci_Position)::SendMessage( getCurScintilla(), SCI_GETCURRENTPOS, 0, 0 ); 667 | Sci_Position line = (Sci_Position)::SendMessage( getCurScintilla(), SCI_LINEFROMPOSITION, pos, 0 ); 668 | if ( g_useTortoise ) 669 | { 670 | std::wstring blame = TEXT( "blame /line:" ); 671 | blame += std::to_wstring( line + 1 ); 672 | ExecTortoiseCommand( blame, files, false, true ); 673 | } 674 | else 675 | { 676 | if (g_gitGuiBlame) 677 | { 678 | std::wstring blame = TEXT( "-gui\" blame --line=" ); 679 | blame += std::to_wstring( line + 1 ); 680 | ExecGitCommand( blame, files, false, false ); 681 | } 682 | else 683 | ExecGitCommand( TEXT( "\" blame" ), files, false, true ); 684 | } 685 | } 686 | 687 | void branchFile() 688 | { 689 | std::vector files = {}; 690 | 691 | if ( g_useTortoise ) 692 | ExecTortoiseCommand( TEXT( "switch" ), files, true, true ); 693 | else 694 | { 695 | MessageBox( nppData._nppHandle, TEXT("Only supported with TortioseGit"), TEXT("Not Implemented"), MB_OK ); 696 | // files.push_back( getBranchDlg() ); 697 | // branchFileFiles( files ); 698 | } 699 | } 700 | void branchFileFiles( std::vector files = {} ) 701 | { 702 | ExecGitCommand( TEXT( "\" branch" ), files, false, false ); 703 | ExecGitCommand( TEXT( "\" checkout" ), files, false, true ); 704 | } 705 | 706 | void pullFile() 707 | { 708 | std::vector files = {}; 709 | pullFileFiles( files ); 710 | } 711 | void pullFileFiles( std::vector files = {} ) 712 | { 713 | if ( g_useTortoise ) 714 | ExecTortoiseCommand( TEXT( "pull" ), files, true, true ); 715 | else 716 | ExecGitCommand( TEXT( "\" pull" ), files, true, true ); 717 | } 718 | 719 | void pushFile() 720 | { 721 | std::vector files = {}; 722 | pushFileFiles( files ); 723 | } 724 | void pushFileFiles( std::vector files = {} ) 725 | { 726 | if ( g_useTortoise ) 727 | ExecTortoiseCommand( TEXT( "push" ), files, true, true ); 728 | else 729 | ExecGitCommand( TEXT( "\" push" ), files, true, true ); 730 | } 731 | 732 | void doTortoise() 733 | { 734 | // UINT state = ::GetMenuState( ::GetMenu( nppData._nppHandle ), 735 | // funcItem[TORTOISE_INDEX]._cmdID, 736 | // MF_BYCOMMAND ); 737 | 738 | if ( g_useTortoise ) 739 | { 740 | g_useTortoise = false; 741 | ::SendMessage( nppData._nppHandle, NPPM_SETMENUITEMCHECK, 742 | funcItem[TORTOISE_INDEX]._cmdID, MF_UNCHECKED ); 743 | } 744 | else 745 | { 746 | if ( ! getTortoiseLocation( g_tortoiseLoc ) ) 747 | { 748 | MessageBox( nppData._nppHandle, TEXT( "Could not locate TortoiseGit" ), 749 | TEXT( "Not Found" ), ( MB_OK | MB_ICONWARNING | MB_APPLMODAL ) ); 750 | g_useTortoise = false; 751 | return; 752 | } 753 | else 754 | { 755 | g_useTortoise = true; 756 | ::SendMessage( nppData._nppHandle, NPPM_SETMENUITEMCHECK, 757 | funcItem[TORTOISE_INDEX]._cmdID, MF_CHECKED ); 758 | } 759 | } 760 | } 761 | 762 | //////////////////////////////////////////////////////////////////////////// 763 | /// 764 | /// Dockable dialog: 765 | /// 766 | void DockableDlg() 767 | { 768 | _gitPanel.setParent( nppData._nppHandle ); 769 | tTbData data = {0}; 770 | 771 | if ( !_gitPanel.isCreated() ) 772 | { 773 | _gitPanel.create( &data ); 774 | 775 | // define the default docking behaviour 776 | data.uMask = DWS_DF_CONT_LEFT | DWS_ICONTAB; 777 | 778 | data.hIconTab = ( HICON )::LoadImage( _gitPanel.getHinst(), 779 | MAKEINTRESOURCE( IDI_PLUGINGITPANEL ), IMAGE_ICON, 0, 0, 780 | LR_LOADTRANSPARENT ); 781 | data.pszModuleName = _gitPanel.getPluginFileName(); 782 | 783 | // the dlgDlg should be the index of funcItem where the current function pointer is 784 | // in this case is DOCKABLE_INDEX 785 | data.dlgID = DOCKABLE_INDEX; 786 | ::SendMessage( nppData._nppHandle, NPPM_DMMREGASDCKDLG, 0, 787 | ( LPARAM )&data ); 788 | 789 | _gitPanel.setClosed(true); 790 | } 791 | 792 | if ( _gitPanel.isClosed() || g_RaisePanel ) 793 | { 794 | _gitPanel.display(); 795 | _gitPanel.setClosed(false); 796 | ::SendMessage( nppData._nppHandle, NPPM_SETMENUITEMCHECK, 797 | funcItem[DOCKABLE_INDEX]._cmdID, MF_CHECKED ); 798 | } 799 | else 800 | { 801 | _gitPanel.display( false ); 802 | _gitPanel.setClosed(true); 803 | ::SendMessage( nppData._nppHandle, NPPM_SETMENUITEMCHECK, 804 | funcItem[DOCKABLE_INDEX]._cmdID, MF_UNCHECKED ); 805 | } 806 | } 807 | -------------------------------------------------------------------------------- /PluginDefinition.h: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #ifndef PLUGINDEFINITION_H 19 | #define PLUGINDEFINITION_H 20 | 21 | // 22 | // All difinitions of plugin interface 23 | // 24 | #include "PluginInterface.h" 25 | 26 | #include 27 | #include 28 | 29 | //-------------------------------------// 30 | //-- STEP 1. DEFINE YOUR PLUGIN NAME --// 31 | //-------------------------------------// 32 | // Here define your plugin name 33 | // 34 | const TCHAR NPP_PLUGIN_NAME[] = TEXT( "&Git SCM" ); 35 | 36 | //-----------------------------------------------// 37 | //-- STEP 2. DEFINE YOUR PLUGIN COMMAND NUMBER --// 38 | //-----------------------------------------------// 39 | // 40 | // Here define the number of your plugin commands 41 | // 42 | const int nbFunc = 21; 43 | 44 | 45 | // 46 | // Initialization of your plugin data 47 | // It will be called while plugin loading 48 | // 49 | void pluginInit( HANDLE hModule ); 50 | 51 | // 52 | // Cleaning of your plugin 53 | // It will be called while plugin unloading 54 | // 55 | void pluginCleanUp(); 56 | 57 | // 58 | //Initialization of your plugin commands 59 | // 60 | void commandMenuInit(); 61 | 62 | // 63 | //Clean up your plugin commands allocation (if any) 64 | // 65 | void commandMenuCleanUp(); 66 | 67 | // 68 | // Function which sets your command 69 | // 70 | bool setCommand( size_t index, TCHAR *cmdName, PFUNCPLUGINCMD pFunc, 71 | ShortcutKey *sk = NULL, bool check0nInit = false ); 72 | 73 | 74 | // 75 | // Your plugin command functions 76 | // 77 | #define LSV1_REFRESH_DELAY 500 78 | 79 | HWND getCurScintilla(); 80 | bool getTortoiseLocation( std::wstring & ); 81 | std::wstring getGitLocation(); 82 | void updatePanelLoc(); 83 | void updatePanel(); 84 | void gitPrompt(); 85 | void gitGui(); 86 | void gitGuiFiles( std::vector ); 87 | void giTk(); 88 | void giTkFiles( std::vector ); 89 | void statusAll(); 90 | void statusAllFiles( std::vector ); 91 | void commitAll(); 92 | void commitAllFiles( std::vector ); 93 | void addFile(); 94 | void addFileFiles( std::vector ); 95 | void diffFile(); 96 | void diffFileFiles( std::vector ); 97 | void unstageFile(); 98 | void unstageFileFiles( std::vector ); 99 | void restoreFile(); 100 | void restoreFileFiles( std::vector ); 101 | void logFile(); 102 | void logFileFiles( std::vector ); 103 | void blameFile(); 104 | void blameFileFiles( std::vector ); 105 | void branchFile(); 106 | void branchFileFiles( std::vector ); 107 | void pushFile(); 108 | void pushFileFiles( std::vector ); 109 | void pullFile(); 110 | void pullFileFiles( std::vector ); 111 | void doTortoise(); 112 | void DockableDlg(); 113 | 114 | #endif //PLUGINDEFINITION_H 115 | -------------------------------------------------------------------------------- /PluginInterface.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2021 Don HO 3 | 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // at your option any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | 18 | #pragma once 19 | 20 | #include "Scintilla.h" 21 | #include "Notepad_plus_msgs.h" 22 | 23 | const int nbChar = 64; 24 | 25 | typedef const TCHAR * (__cdecl * PFUNCGETNAME)(); 26 | 27 | struct NppData 28 | { 29 | HWND _nppHandle = nullptr; 30 | HWND _scintillaMainHandle = nullptr; 31 | HWND _scintillaSecondHandle = nullptr; 32 | }; 33 | 34 | typedef void (__cdecl * PFUNCSETINFO)(NppData); 35 | typedef void (__cdecl * PFUNCPLUGINCMD)(); 36 | typedef void (__cdecl * PBENOTIFIED)(SCNotification *); 37 | typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam); 38 | 39 | 40 | struct ShortcutKey 41 | { 42 | bool _isCtrl = false; 43 | bool _isAlt = false; 44 | bool _isShift = false; 45 | UCHAR _key = 0; 46 | }; 47 | 48 | struct FuncItem 49 | { 50 | TCHAR _itemName[nbChar] = { '\0' }; 51 | PFUNCPLUGINCMD _pFunc = nullptr; 52 | int _cmdID = 0; 53 | bool _init2Check = false; 54 | ShortcutKey *_pShKey = nullptr; 55 | }; 56 | 57 | typedef FuncItem * (__cdecl * PFUNCGETFUNCSARRAY)(int *); 58 | 59 | // You should implement (or define an empty function body) those functions which are called by Notepad++ plugin manager 60 | extern "C" __declspec(dllexport) void setInfo(NppData); 61 | extern "C" __declspec(dllexport) const TCHAR * getName(); 62 | extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *); 63 | extern "C" __declspec(dllexport) void beNotified(SCNotification *); 64 | extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam); 65 | 66 | // This API return always true now, since Notepad++ isn't compiled in ANSI mode anymore 67 | extern "C" __declspec(dllexport) BOOL isUnicode(); 68 | 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Notepad++ Git 2 | 3 | Author: Michael J. Vincent 4 | 5 | 6 | ## Description 7 | 8 | The original plugin was posted here: https://forum.lowyat.net/topic/1358320/all 9 | 10 | I modified the code found here: https://github.com/alansbraga/NPPGit 11 | 12 | ... to use [Git SCM for Windows](https://git-scm.com/), not 13 | [TortoiseGit](https://tortoisegit.org/). And then after seeing 14 | what TortoiseGit could do while using underlying Git for Windows, I 15 | added the TortoiseGit functionality back in. 16 | 17 | You need to have [Git SCM for Windows](https://git-scm.com/) installed and in your 18 | `PATH` environment variable. Usually `C:\Program Files\git\cmd`. 19 | 20 | 21 | ## Compiling 22 | 23 | There was a Makefile written for gmake.exe from the MinGW distribution. 24 | 25 | I've compiled it fine, but needed to statically include glibc so I could 26 | change my C compiler in my path. This led to a much larger DLL. Also, 27 | I couldn't get the docking interface to work when compiling with MinGW. 28 | 29 | I compiled with MS Visual Studio Community 2017 and this seems to work 30 | OK. 31 | 32 | For 32-bit: 33 | ``` 34 | [x86 Native Tools Command Prompt for VS 2017] 35 | C:\> set Configuration=Release 36 | C:\> set Platform=x86 37 | C:\> msbuild 38 | ``` 39 | 40 | For 64-bit: 41 | ``` 42 | [x64 Native Tools Command Prompt for VS 2017] 43 | C:\> set Configuration=Release 44 | C:\> set Platform=x64 45 | C:\> msbuild 46 | ``` 47 | 48 | 49 | ## Installation 50 | 51 | First you need to install [Git SCM for Windows](https://git-scm.com/), because 52 | this plugin simply uses the command line features of it. 53 | 54 | It needs to be in your `PATH` environment variable. 55 | 56 | PATH=[..];\git\cmd; 57 | 58 | Optionally install [TortoiseGit](https://tortoisegit.org/) 59 | 60 | After that, copy the: 61 | 62 | + 32-bit: ./bin/GitSCM.dll 63 | + 64-bit: ./bin64/GitSCM.dll 64 | 65 | to the Notepad++ plugins folder: 66 | + In N++ <7.6, directly in the plugins/ folder 67 | + In N++ >=7.6, in a directory called GitSCM in the plugins/ folder (plugins/GitSCM/) 68 | 69 | Next time you open Notepad++ you can access through menu Plugins->Git. 70 | 71 | 72 | ## Usage 73 | 74 | This plugin relies on [Git SCM for Windows](https://git-scm.com/) and 75 | optionally [TortoiseGit](https://tortoisegit.org/) for a nicer GUI 76 | experience. 77 | 78 | The plugin relies on Notepad++ feature of "Follow current directory". This 79 | can be set from Settings => Preferences => Default Directory => 80 | Follow current directory. 81 | 82 | All Plugin => Git SCM menu options operate on the current Notepad++ file in 83 | the edit view. 84 | 85 | All Plugins => Git SCM => Git Docking Panel => Toolbar buttons operate on 86 | the current Notepad++ file in the edit view ***UNLESS*** a file or files are 87 | selected in the List View of the Git Docking Panel in which case those files 88 | are operated on. 89 | 90 | The Git Docking Panel Toolbar buttons have tool tips if hovered over. 91 | 92 | 93 | ### Panel 94 | In the Panel: 95 | 96 | --- 97 | 98 | Branch [Branch] 99 | 100 | Directory 101 | 102 | I | W | File 103 | --|---|------ 104 | Status | Status | File_name 105 | 106 | --- 107 | 108 | Branch shows the current branch for the current repo. 109 | 110 | [Branch] button allows one to create a new branch. **NOTE:** this is only 111 | supported with TortoiseGit. 112 | 113 | The list view shows the parsed output of `git status --porcelain --branch`. 114 | See https://git-scm.com/docs/git-status for more information. 115 | 116 | + Right-clicking any item in the List View will bring up a context menu. 117 | 118 | + Multiple items in the List View can be selected by holding CTRL or Shift. 119 | 120 | + Double-clicking any filename in the "File" column will open the file in 121 | Notepad++; as will pressing "Enter" or "Spacebar". 122 | 123 | + Double-clicking any "M" in the "W" (working) column will `git add` the file 124 | to the index, moving the "M" to the "I" (index) column. 125 | 126 | + Double-clicking any "M" in the "I" (index) column will `git reset HEAD` 127 | the file out of the index, moving the "M" to the "W" (working) column. 128 | 129 | **Use N++ Colors** simply changes the colors of the List View background and 130 | foreground text in the Git Docking Panel to match that of the current 131 | Notepad++ theme. 132 | 133 | **Panel Raise (or Toggle)** sets the panel action on the "Git Docking Panel" 134 | menu option. Check just raises the panel into view; uncheck shows / hides 135 | the panel. 136 | 137 | ### Settings 138 | 139 | **Git Directory Path** is only required if `git` is not found in your system 140 | PATH environment variable or if you want to use a different Git. Only the 141 | directory to the Git executable is required - use the "git..." button to 142 | help locate and enter the directory only if required. 143 | 144 | **Git Prompt** is to launch a terminal prompt in the current repo directory. 145 | The default shell is PowerShell. 146 | 147 | **Refresh on Scintilla focus** will refresh the Panel (if shown) anytime the 148 | Scintilla editing component of Notepad++ gets the focus. 149 | -------------------------------------------------------------------------------- /Sci_Position.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file Sci_Position.h 3 | ** Define the Sci_Position type used in Scintilla's external interfaces. 4 | ** These need to be available to clients written in C so are not in a C++ namespace. 5 | **/ 6 | // Copyright 2015 by Neil Hodgson 7 | // The License.txt file describes the conditions under which this software may be distributed. 8 | 9 | #ifndef SCI_POSITION_H 10 | #define SCI_POSITION_H 11 | 12 | #include 13 | 14 | // Basic signed type used throughout interface 15 | typedef ptrdiff_t Sci_Position; 16 | 17 | // Unsigned variant used for ILexer::Lex and ILexer::Fold 18 | // Definitions of common types 19 | typedef size_t Sci_PositionU; 20 | 21 | 22 | // For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE 23 | typedef intptr_t Sci_PositionCR; 24 | 25 | #ifdef _WIN32 26 | #define SCI_METHOD __stdcall 27 | #else 28 | #define SCI_METHOD 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 6 | 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | Preamble 11 | The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. 12 | 13 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. 14 | 15 | To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. 16 | 17 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. 18 | 19 | We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. 20 | 21 | Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. 22 | 23 | Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. 24 | 25 | The precise terms and conditions for copying, distribution and modification follow. 26 | 27 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 28 | 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". 29 | 30 | Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 31 | 32 | 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. 33 | 34 | You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 35 | 36 | 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: 37 | 38 | 39 | a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. 40 | 41 | b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. 42 | 43 | c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) 44 | These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. 45 | Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. 46 | 47 | In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 48 | 49 | 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: 50 | 51 | a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 52 | 53 | b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 54 | 55 | c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) 56 | The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. 57 | If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 58 | 59 | 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 60 | 61 | 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 62 | 63 | 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 64 | 65 | 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. 66 | 67 | If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. 68 | 69 | It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. 70 | 71 | This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 72 | 73 | 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 74 | 75 | 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 76 | 77 | Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 78 | 79 | 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 80 | 81 | NO WARRANTY 82 | 83 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 84 | 85 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 86 | 87 | 88 | END OF TERMS AND CONDITIONS 89 | -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | #ifndef RESOURCE_H 2 | #define RESOURCE_H 3 | 4 | #define STR_HELPER(x) #x 5 | #define STR(x) STR_HELPER(x) 6 | 7 | /* VERSION DEFINITIONS */ 8 | #define VER_MAJOR 1 9 | #define VER_MINOR 4 10 | #define VER_RELEASE 10 11 | #define VER_BUILD 1 12 | #define VER_STRING STR(VER_MAJOR) "." STR(VER_MINOR) "." STR(VER_RELEASE) "." STR(VER_BUILD) 13 | 14 | #define FILE_DESCRIPTION "Notepad++ Plugin for Git SCM." 15 | #define INTERNAL_NAME "Notepad++ Git SCM" 16 | 17 | #define COMPANY_NAME "Vin's World" 18 | #define FILE_VERSION VER_STRING 19 | #define LEGAL_COPYRIGHT "Copyright (C) VinsWorld. All Rights Reserved." 20 | #define LEGAL_TRADEMARKS "" 21 | #define ORIGINAL_FILENAME "GitSCM" 22 | #define PRODUCT_NAME "GITSCM" 23 | #define PRODUCT_VERSION VER_STRING 24 | 25 | /* ADDITIONAL DEFINITIONS */ 26 | 27 | #define DOCKABLE_INDEX 4 28 | #define TORTOISE_INDEX 19 29 | 30 | #define IDB_TB_GIT 1001 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef WINVER // Specifies that the minimum required platform is Windows Vista. 11 | #define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 15 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 16 | #endif 17 | 18 | #ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. 19 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 20 | #endif 21 | 22 | #ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. 23 | #define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. 24 | #endif 25 | --------------------------------------------------------------------------------