From e8c8f37f9b8bba1c9570a983f69439a61cd18cbf Mon Sep 17 00:00:00 2001 From: rainwater Date: Mon, 9 Sep 2002 23:02:48 +0000 Subject: [PATCH] Added Load Script option on File menu and fixed save output string filter git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@967 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/Makensisw/Readme.txt | 1 + Contrib/Makensisw/makensisw.cpp | 28 ++++++++++++- Contrib/Makensisw/resource.h | 3 +- Contrib/Makensisw/resource.rc | 2 + Contrib/Makensisw/utils.cpp | 74 +++++++++++++++++---------------- 5 files changed, 69 insertions(+), 39 deletions(-) diff --git a/Contrib/Makensisw/Readme.txt b/Contrib/Makensisw/Readme.txt index 1695ff72..babac6a2 100644 --- a/Contrib/Makensisw/Readme.txt +++ b/Contrib/Makensisw/Readme.txt @@ -146,6 +146,7 @@ Version History - Fixed some random crashes - Drag and Drop Support into the Makensisw window - Updated icon to Trace's modern NSIS icon + - Added Load Script option on File menu Copyright Information diff --git a/Contrib/Makensisw/makensisw.cpp b/Contrib/Makensisw/makensisw.cpp index 82691e09..c6205b20 100644 --- a/Contrib/Makensisw/makensisw.cpp +++ b/Contrib/Makensisw/makensisw.cpp @@ -186,6 +186,30 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { ShellExecute(g_hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL); return TRUE; } + case IDM_LOADSCRIPT: + { + if (!g_hThread) { + OPENFILENAME l={sizeof(l),}; + char buf[MAX_STRING]; + l.hwndOwner = hwndDlg; + l.lpstrFilter = "NSIS Script (*.nsi)\0*.nsi\0All Files (*.*)\0*.*\0"; + l.lpstrFile = buf; + l.nMaxFile = MAX_STRING-1; + l.lpstrTitle = "Load Script"; + l.lpstrDefExt = "log"; + l.lpstrFileTitle = NULL; + l.lpstrInitialDir = NULL; + l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST; + lstrcpy(buf,""); + if (GetOpenFileName(&l)) { + g_script = (char *)GlobalAlloc(GPTR,sizeof(buf)+7); + wsprintf(g_script,"/CD \"%s\"",buf); + ResetObjects(); + CompileNSISScript(); + } + } + return TRUE; + } case IDM_RECOMPILE: { CompileNSISScript(); @@ -235,14 +259,14 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { OPENFILENAME l={sizeof(l),}; char buf[MAX_STRING]; l.hwndOwner = hwndDlg; - l.lpstrFilter = "Log Files (*.log)\0Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; + l.lpstrFilter = "Log Files (*.log)\0*.log\0Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; l.lpstrFile = buf; l.nMaxFile = MAX_STRING-1; l.lpstrTitle = "Save Output"; l.lpstrDefExt = "log"; l.lpstrInitialDir = NULL; l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST; - lstrcpy(buf,"output.log"); + lstrcpy(buf,"output"); if (GetSaveFileName(&l)) { HANDLE hFile = CreateFile(buf,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0); if (hFile) { diff --git a/Contrib/Makensisw/resource.h b/Contrib/Makensisw/resource.h index a1a94417..ff312796 100644 --- a/Contrib/Makensisw/resource.h +++ b/Contrib/Makensisw/resource.h @@ -26,13 +26,14 @@ #define IDM_TEST 40002 #define IDM_EDITSCRIPT 40003 #define IDM_DOCS 40004 +#define IDM_LOADSCRIPT 40005 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 111 -#define _APS_NEXT_COMMAND_VALUE 40005 +#define _APS_NEXT_COMMAND_VALUE 40006 #define _APS_NEXT_CONTROL_VALUE 1009 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/Contrib/Makensisw/resource.rc b/Contrib/Makensisw/resource.rc index 6744b463..9c632612 100644 --- a/Contrib/Makensisw/resource.rc +++ b/Contrib/Makensisw/resource.rc @@ -69,6 +69,8 @@ BEGIN MENUITEM "&Test\tCtrl+T", IDM_TEST MENUITEM "&Save Output...", IDM_SAVE MENUITEM SEPARATOR + MENUITEM "&Load Script...", IDM_LOADSCRIPT + MENUITEM SEPARATOR MENUITEM "E&xit\tCtrl+X", IDM_EXIT END POPUP "&Edit" diff --git a/Contrib/Makensisw/utils.cpp b/Contrib/Makensisw/utils.cpp index f6476b38..444014d8 100644 --- a/Contrib/Makensisw/utils.cpp +++ b/Contrib/Makensisw/utils.cpp @@ -77,6 +77,7 @@ void DisableItems(HWND hwnd) { EnableMenuItem(m,IDM_SAVE,MF_GRAYED); EnableMenuItem(m,IDM_TEST,MF_GRAYED); EnableMenuItem(m,IDM_EXIT,MF_GRAYED); + EnableMenuItem(m,IDM_LOADSCRIPT,MF_GRAYED); EnableMenuItem(m,IDM_RECOMPILE,MF_GRAYED); EnableMenuItem(m,IDM_COPY,MF_GRAYED); EnableMenuItem(m,IDM_COPYSELECTED,MF_GRAYED); @@ -84,48 +85,48 @@ void DisableItems(HWND hwnd) { } void EnableItems(HWND hwnd) { - #define MSG(a) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,0,0) - #define MSG1(a,b) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,0) - #define MSG2(a,b,c) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,c) + #define MSG(a) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,0,0) + #define MSG1(a,b) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,0) + #define MSG2(a,b,c) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,c) - if (g_input_script) { - GlobalFree(g_input_script); - g_input_script = 0; - } - if (g_output_exe) { - GlobalFree(g_output_exe); - g_output_exe = 0; - } + if (g_input_script) { + GlobalFree(g_input_script); + g_input_script = 0; + } + if (g_output_exe) { + GlobalFree(g_output_exe); + g_output_exe = 0; + } - TEXTRANGE tr; - FINDTEXT ft; + TEXTRANGE tr; + FINDTEXT ft; - // find input script - ft.chrg.cpMin = 0; - ft.chrg.cpMax = MSG(WM_GETTEXTLENGTH); - ft.lpstrText = "Processing script file: \""; - ft.chrg.cpMin = tr.chrg.cpMin = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) + lstrlen("Processing script file: \""); - ft.lpstrText = "\""; - tr.chrg.cpMax = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft); - tr.lpstrText = g_input_script = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1); - MSG2(EM_GETTEXTRANGE, 0, (WPARAM)&tr); + // find input script + ft.chrg.cpMin = 0; + ft.chrg.cpMax = MSG(WM_GETTEXTLENGTH); + ft.lpstrText = "Processing script file: \""; + ft.chrg.cpMin = tr.chrg.cpMin = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) + lstrlen("Processing script file: \""); + ft.lpstrText = "\""; + tr.chrg.cpMax = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft); + tr.lpstrText = g_input_script = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1); + MSG2(EM_GETTEXTRANGE, 0, (WPARAM)&tr); - // find output exe - ft.chrg.cpMin = 0; - ft.chrg.cpMax = MSG(WM_GETTEXTLENGTH); - ft.lpstrText = "Output: \""; - ft.chrg.cpMin = tr.chrg.cpMin = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) + lstrlen("Output: \""); - ft.lpstrText = "\""; - tr.chrg.cpMax = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft); - tr.lpstrText = g_output_exe = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1); - MSG2(EM_GETTEXTRANGE, 0, (WPARAM)&tr); + // find output exe + ft.chrg.cpMin = 0; + ft.chrg.cpMax = MSG(WM_GETTEXTLENGTH); + ft.lpstrText = "Output: \""; + ft.chrg.cpMin = tr.chrg.cpMin = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) + lstrlen("Output: \""); + ft.lpstrText = "\""; + tr.chrg.cpMax = MSG2(EM_FINDTEXT, 0, (LPARAM)&ft); + tr.lpstrText = g_output_exe = (char *)GlobalAlloc(GPTR, tr.chrg.cpMax-tr.chrg.cpMin+1); + MSG2(EM_GETTEXTRANGE, 0, (WPARAM)&tr); - g_warnings = FALSE; + g_warnings = FALSE; - ft.lpstrText = "warning:"; - if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_warnings++; - ft.lpstrText = "warnings:"; - if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_warnings++; + ft.lpstrText = "warning:"; + if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_warnings++; + ft.lpstrText = "warnings:"; + if (MSG2(EM_FINDTEXT, 0, (LPARAM)&ft) != -1) g_warnings++; HMENU m = GetMenu(hwnd); if (g_output_exe && !g_retcode) { @@ -135,6 +136,7 @@ void EnableItems(HWND hwnd) { EnableWindow(GetDlgItem(hwnd,IDC_CLOSE),1); EnableMenuItem(m,IDM_SAVE,MF_ENABLED); EnableMenuItem(m,IDM_EXIT,MF_ENABLED); + EnableMenuItem(m,IDM_LOADSCRIPT,MF_ENABLED); EnableMenuItem(m,IDM_RECOMPILE,MF_ENABLED); EnableMenuItem(m,IDM_COPY,MF_ENABLED); EnableMenuItem(m,IDM_COPYSELECTED,MF_ENABLED);