//this file is part of notepad++ //Copyright (C)2003 Don HO <donho@altern.org> // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "PluginDefinition.h" #include "menuCmdID.h" #include "winuser.h" #include <clientapi.h> #include <strtable.h> #include <enviro.h> #include "PerforceClient.h" // // The plugin data that Notepad++ needs // FuncItem funcItem[nbFunc]; // // The data of Notepad++ that you can use in your plugin commands // NppData nppData; // // Initialize your plugin data here // It will be called while plugin loading void pluginInit(HANDLE hModule) { } // // Here you can do the clean up, save the parameters (if any) for the next session // void pluginCleanUp() { } // // Initialization of your plugin commands // You should fill your plugins commands here void commandMenuInit() { //--------------------------------------------// //-- STEP 3. CUSTOMIZE YOUR PLUGIN COMMANDS --// //--------------------------------------------// // with function : // setCommand(int index, // zero based number to indicate the order of command // TCHAR *commandName, // the command name that you want to see in plugin menu // PFUNCPLUGINCMD functionPointer, // the symbol of function (function pointer) associated with this command. The body should be defined below. See Step 4. // ShortcutKey *shortcut, // optional. Define a shortcut to trigger this command // bool check0nInit // optional. Make this menu item be checked visually // ); ShortcutKey *pAddKey = new ShortcutKey; pAddKey->_isAlt = true; pAddKey->_isCtrl = false; pAddKey->_isShift = true; pAddKey->_key = 'A'; //VK_A setCommand(0, TEXT("Add File"), addFile, pAddKey, false); ShortcutKey *pEditKey = new ShortcutKey; pEditKey->_isAlt = true; pEditKey->_isCtrl = false; pEditKey->_isShift = true; pEditKey->_key = 'E'; //VK_E setCommand(1, TEXT("Edit File"), editFile, pEditKey, false); ShortcutKey *pRevertKey = new ShortcutKey; pRevertKey->_isAlt = true; pRevertKey->_isCtrl = false; pRevertKey->_isShift = true; pRevertKey->_key = 'R'; //VK_R setCommand(2, TEXT("Revert File"), revertFile, pRevertKey, false); ShortcutKey *pDeleteKey = new ShortcutKey; pDeleteKey->_isAlt = true; pDeleteKey->_isCtrl = false; pDeleteKey->_isShift = true; pDeleteKey->_key = 'D'; //VK_S setCommand(3, TEXT("Delete File"), deleteFile, pDeleteKey, false); ShortcutKey *pSyncKey = new ShortcutKey; pSyncKey->_isAlt = true; pSyncKey->_isCtrl = false; pSyncKey->_isShift = true; pSyncKey->_key = 'X'; //VK_X -- ALT+SHIFT+S is taken already setCommand(4, TEXT("Sync File"), syncFile, pSyncKey, false); setCommand(5, TEXT("--------------------"), NULL, NULL, false); ShortcutKey *pFileKey = new ShortcutKey; pFileKey->_isAlt = true; pFileKey->_isCtrl = false; pFileKey->_isShift = true; pFileKey->_key = 'F'; //VK_F setCommand(6, TEXT("Show file info"), showFileInfo, pFileKey, false); ShortcutKey *pConnectionKey = new ShortcutKey; pConnectionKey->_isAlt = true; pConnectionKey->_isCtrl = false; pConnectionKey->_isShift = true; pConnectionKey->_key = 'I'; //VK_I setCommand(7, TEXT("Show connection info"), showConnectionInfo, pConnectionKey, false); } // // Here you can do the clean up (especially for the shortcut) // void commandMenuCleanUp() { // Don't forget to deallocate your shortcut here delete funcItem[0]._pShKey; delete funcItem[1]._pShKey; delete funcItem[2]._pShKey; delete funcItem[3]._pShKey; delete funcItem[4]._pShKey; delete funcItem[6]._pShKey; delete funcItem[7]._pShKey; } // // This function help you to initialize your plugin commands // bool setCommand(size_t index, TCHAR *cmdName, PFUNCPLUGINCMD pFunc, ShortcutKey *sk, bool check0nInit) { if (index >= nbFunc) return false; if (!pFunc) return false; lstrcpy(funcItem[index]._itemName, cmdName); funcItem[index]._pFunc = pFunc; funcItem[index]._init2Check = check0nInit; funcItem[index]._pShKey = sk; return true; } //----------------------------------------------// //-- STEP 4. DEFINE YOUR ASSOCIATED FUNCTIONS --// //----------------------------------------------// void addFile() { PerforceClient client; client.addFile(); } void editFile() { PerforceClient client; client.editFile(); } void revertFile() { PerforceClient client; client.revertFile( ); } void deleteFile() { PerforceClient client; client.deleteFile(); } void syncFile() { PerforceClient client; client.syncFile(); } void showConnectionInfo() { PerforceClient client; client.showInfo(); } void showFileInfo() { PerforceClient client; client.showFileInfo(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 11396 | Sven Erik Knop |
Fixed login issue from file command (endless loop). Bumped version to 1.0.7 Final version in this iteration (I hope). |
||
#8 | 11391 | Sven Erik Knop | Added login status to connection info output. | ||
#7 | 11384 | Sven Erik Knop | Added logout menu item (more for testing than practical use) | ||
#6 | 11381 | Sven Erik Knop |
Added login dialog (after many years of waiting) Currently needs to log on in a separate step, next change should prompt for password if ticket expired in any case. Also fixed a bug with showing file information for freshly added files. |
||
#5 | 11340 | Sven Erik Knop | Added an about box and menu item. | ||
#4 | 10986 | Sven Erik Knop |
Updated for new-style P4V. Now using P4VC (there is no more P4V -cmd). Currently only Revgraph, Timelapse View and Submit are supported. |
||
#3 | 7817 | Sven Erik Knop |
Updated NppPerforcePlugin: prevent crash for some people using newer versions of Notepad++. It seems that the existing sample code are wrong: adding a separator to the menu list does require a new entry in the function list. I also re-added my Visual Studio solution and project and added a compiled release version of the DLL. Let me know if there are any problems. |
||
#2 | 7482 | Sven Erik Knop |
Added P4V support to the plugin. If p4v.exe is in the path, additional menu items become available. |
||
#1 | 7440 | Sven Erik Knop |
Notepad++ Perforce Plugin. The provided DLL will only work for the Unicode version of Notepad++. The code currently contains no provision for ASCII builds. The plugin can : Add Edit Delete Revert Sync (to head) --- Show file info Show connection info |