From e4e465b0929637a431f41aae80e5853114004438 Mon Sep 17 00:00:00 2001 From: donho Date: Thu, 6 Dec 2007 00:03:41 +0000 Subject: [PATCH] [UPDATE] Integrate the newest GUP into Notepad++. Add "Update Notepad++" menu item. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@79 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 20 +++++- PowerEditor/src/Notepad_plus.h | 1 + PowerEditor/src/Notepad_plus.rc | 2 + PowerEditor/src/menuCmdID.h | 1 + PowerEditor/src/resource.h | 6 +- PowerEditor/src/winmain.cpp | 85 +++++------------------ PowerEditor/visual.net/notepadPlus.vcproj | 4 +- 7 files changed, 46 insertions(+), 73 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 1345a912..a809d508 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -244,7 +244,6 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLi if (PathFileExists(cmdLine)) { - doOpen(cmdLine, cmdLineParams->_isReadOnly); if (lt != L_TXT) @@ -3392,6 +3391,18 @@ void Notepad_plus::command(int id) break; } + case IDM_UPDATE_NPP : + { + string updaterDir = pNppParam->getNppPath(); + updaterDir += "\\updater\\"; + string updaterFullPath = updaterDir + "gup.exe"; + string param = "-verbose -v"; + param += VERSION_VALUE; + Process updater(updaterFullPath.c_str(), param.c_str(), updaterDir.c_str()); + updater.run(); + break; + } + case IDM_EDIT_AUTOCOMPLETE : showAutoComp(); break; @@ -5811,6 +5822,13 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _scintillaCtrls4Plugins.init(_hInst, hwnd); + // Updater menu item + if (!nppGUI._doesExistUpdater) + { + //::MessageBox(NULL, "pas de updater", "", MB_OK); + ::DeleteMenu(::GetMenu(_hSelf), IDM_UPDATE_NPP, MF_BYCOMMAND); + ::DrawMenuBar(hwnd); + } // Plugin Manager NppData nppData; nppData._nppHandle = _hSelf; diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index e781b2ba..ae02f23c 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -45,6 +45,7 @@ #include "WindowsDlg.h" #include "RunMacroDlg.h" #include "DockingManager.h" +#include "Process.h" #define NOTEPAD_PP_CLASS_NAME "Notepad++" diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 8d459ed8..a425e100 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -476,6 +476,8 @@ BEGIN MENUITEM "Online help", IDM_ONLINEHELP MENUITEM "Forum", IDM_FORUM MENUITEM "Get more plugins", IDM_PLUGINSHOME + MENUITEM SEPARATOR + MENUITEM "Update Notepad++", IDM_UPDATE_NPP MENUITEM "About Notepad++\tF1", IDM_ABOUT END diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 5ac7b687..35eb3325 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -237,6 +237,7 @@ #define IDM_ONLINEHELP (IDM_ABOUT + 3) #define IDM_FORUM (IDM_ABOUT + 4) #define IDM_PLUGINSHOME (IDM_ABOUT + 5) + #define IDM_UPDATE_NPP (IDM_ABOUT + 6) diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index fd7a7556..06f74a5c 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -18,9 +18,9 @@ #ifndef RESOURCE_H #define RESOURCE_H -#define NOTEPAD_PLUS_VERSION "Notepad++ v4.6" -#define VERSION_VALUE "4.6\0" -#define VERSION_DIGITALVALUE 4, 6, 0, 0 +#define NOTEPAD_PLUS_VERSION "Notepad++ v4.7" +#define VERSION_VALUE "4.7\0" +#define VERSION_DIGITALVALUE 4, 7, 0, 0 #ifndef IDC_STATIC #define IDC_STATIC -1 diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index a22dc548..8cea6d59 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -63,11 +63,10 @@ static bool isInList(const char *token2Find, char *list2Clean) { return false; }; - -static LangType getLangTypeFromParam(char *list2Clean) { +static string getParamVal(char c, char *list2Clean) { char word[1024]; bool checkDash = true; - bool checkL = false; + bool checkCh = false; bool action = false; bool isFileNamePart = false; int pos2Erase = 0; @@ -87,7 +86,7 @@ static LangType getLangTypeFromParam(char *list2Clean) { list2Clean[pos2Erase] = '\0'; - return NppParameters::getLangIDFromStr(word); + return word; } checkDash = true; } @@ -105,83 +104,34 @@ static LangType getLangTypeFromParam(char *list2Clean) { else if (checkDash) { if (list2Clean[i] == '-') - checkL = true; + checkCh = true; if (list2Clean[i] != ' ') checkDash = false; } - else if (checkL) + else if (checkCh) { - if (list2Clean[i] == 'l') + if (list2Clean[i] == c) { action = true; pos2Erase = i-1; } - checkL = false; + checkCh = false; } } } - return L_TXT; + return ""; +}; + +static LangType getLangTypeFromParam(char *list2Clean) { + string langStr = getParamVal('l', list2Clean); + return NppParameters::getLangIDFromStr(langStr.c_str()); }; static int getLn2GoFromParam(char *list2Clean) { - char word[16]; - bool checkDash = true; - bool checkN = false; - bool action = false; - bool isFileNamePart = false; - int pos2Erase = 0; - - for (int i = 0, j = 0 ; i <= int(strlen(list2Clean)) ; i++) - { - if ((list2Clean[i] == ' ') || (list2Clean[i] == '\0')) - { - if (action) - { - word[j] = '\0'; - j = 0; - action = false; - - for (i = i + 1 ; i <= int(strlen(list2Clean)) ; i++, pos2Erase++) - list2Clean[pos2Erase] = list2Clean[i]; - - list2Clean[pos2Erase] = '\0'; - return atoi(word); - } - checkDash = true; - } - else if (list2Clean[i] == '"') - { - isFileNamePart = !isFileNamePart; - } - - if (!isFileNamePart) - { - if (action) - { - word[j++] = list2Clean[i]; - } - else if (checkDash) - { - if (list2Clean[i] == '-') - checkN = true; - - if (list2Clean[i] != ' ') - checkDash = false; - } - else if (checkN) - { - if (list2Clean[i] == 'n') - { - action = true; - pos2Erase = i-1; - } - checkN = false; - } - } - } - return -1; -}; + string lineNumStr = getParamVal('n', list2Clean); + return atoi(lineNumStr.c_str()); +}; const char FLAG_MULTI_INSTANCE[] = "-multiInst"; const char FLAG_NO_PLUGIN[] = "-noPlugin"; @@ -274,7 +224,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh string updaterFullPath = updaterDir + "gup.exe"; - string version = VERSION_VALUE; + string version = "-v"; + version += VERSION_VALUE; bool isUpExist = nppGui._doesExistUpdater = (::PathFileExists(updaterFullPath.c_str()) == TRUE); bool doUpdate = !nppGui._neverUpdate; diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index 908a590b..c9284364 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -573,11 +573,11 @@ >