From fdd5119f7591cf2240626dbad39307677b256e03 Mon Sep 17 00:00:00 2001 From: kichik Date: Mon, 11 Nov 2002 15:11:49 +0000 Subject: [PATCH] Caption parameter for custom pages git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1662 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/build.cpp | 6 ++++-- Source/exehead/Ui.c | 11 +++++++++++ Source/exehead/fileform.h | 8 +++++++- Source/script.cpp | 33 ++++++++++++++++++--------------- Source/tokens.cpp | 4 ++-- 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/Source/build.cpp b/Source/build.cpp index e5e64d96..17b938a6 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -1058,7 +1058,8 @@ int CEXEBuild::resolve_coderefs(const char *str) int i = 0; while (i < build_uninst.common.num_pages) { if (resolve_call_int("uninstall pages","pre-page function",p->prefunc,&p->prefunc)) return 1; - if (resolve_call_int("uninstall pages","post-page function",p->postfunc,&p->postfunc)) return 1; + if (p->id != NSIS_PAGE_CUSTOM) + if (resolve_call_int("uninstall pages","post-page function",p->postfunc,&p->postfunc)) return 1; p++; i++; } @@ -1089,7 +1090,8 @@ int CEXEBuild::resolve_coderefs(const char *str) int i = 0; while (i < build_header.common.num_pages) { if (resolve_call_int("pages","pre-page function",p->prefunc,&p->prefunc)) return 1; - if (resolve_call_int("pages","post-page function",p->postfunc,&p->postfunc)) return 1; + if (p->id != NSIS_PAGE_CUSTOM) + if (resolve_call_int("pages","post-page function",p->postfunc,&p->postfunc)) return 1; p++; i++; } diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 004bbd49..86534392 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -518,6 +518,17 @@ nextPage: if (this_page->id!=NSIS_PAGE_COMPLETED) DestroyWindow(m_curwnd); else if (g_autoclose) goto nextPage; + if (this_page->id==NSIS_PAGE_CUSTOM) // custom page + { + mystrcpy(g_tmp,g_caption); + process_string_fromtab( + g_tmp+mystrlen(g_tmp), + this_page->caption // post_func contains the caption for custom functions + ); + + SetWindowText(hwndDlg,g_tmp); + } + #ifdef NSIS_SUPPORT_CODECALLBACKS if (ExecuteCodeSegment(this_page->prefunc,NULL) || this_page->id<0) goto nextPage; diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index 986ed799..7b8a34e5 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -460,7 +460,13 @@ typedef struct int id; // index in the pages array #ifdef NSIS_SUPPORT_CODECALLBACKS int prefunc; // function to use Abort in, or show the custom page if id == NSIS_PAGE_CUSTOM - int postfunc; // function to do stuff after the page is shown + union + { + int postfunc; // function to do stuff after the page is shown +#endif //NSIS_SUPPORT_CODECALLBACKS + int caption; // caption for custom pages +#ifdef NSIS_SUPPORT_CODECALLBACKS + }; #endif //NSIS_SUPPORT_CODECALLBACKS int next; int back; diff --git a/Source/script.cpp b/Source/script.cpp index 0aa847b3..b3436d94 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -534,11 +534,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char if (*line.gettoken_str(2)) p.prefunc = ns_func.add(line.gettoken_str(2),0); if (line.getnumtokens()>3) { - if (k==0) { - ERROR_MSG("\nError: custom page don't need post creation functions!\n"); - PRINTHELP(); - } - p.postfunc = ns_func.add(line.gettoken_str(3),0); + if (k) + p.postfunc = ns_func.add(line.gettoken_str(3),0); + else + p.caption = add_string_main(line.gettoken_str(3),0); } #else ERROR_MSG("Error: Page callback specified, NSIS_CONFIG_LICENSEPAGE not defined.\n"); @@ -584,8 +583,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char #ifdef NSIS_SUPPORT_CODECALLBACKS if (p.prefunc>=0) SCRIPT_MSG(" (%s:%s)", k?"pre":"creator", line.gettoken_str(2)); - if (p.postfunc>=0) + if (p.postfunc>=0 && k) SCRIPT_MSG(" (post:%s)", line.gettoken_str(3)); + else if (p.caption && !k) + SCRIPT_MSG(" (caption:%s)", line.gettoken_str(3)); #endif SCRIPT_MSG("\n"); @@ -626,15 +627,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char p.prefunc = ns_func.add(line.gettoken_str(2),0); } if (line.getnumtokens()>3) { - if (k==0) { - ERROR_MSG("\nError: custom page don't need post creation functions!\n"); - PRINTHELP(); + if (k) { + if (strnicmp(line.gettoken_str(3),"un.",3)) { + ERROR_MSG("\nError: function must have a un. prefix!\n"); + return PS_ERROR; + } + p.postfunc = ns_func.add(line.gettoken_str(3),0); } - if (strnicmp(line.gettoken_str(3),"un.",3)) { - ERROR_MSG("\nError: function must have a un. prefix!\n"); - return PS_ERROR; - } - p.postfunc = ns_func.add(line.gettoken_str(3),0); + else + p.caption = add_string_uninst(line.gettoken_str(3),0); } #else ERROR_MSG("Error: UninstPage callback specified, NSIS_CONFIG_LICENSEPAGE not defined.\n"); @@ -664,8 +665,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char #ifdef NSIS_SUPPORT_CODECALLBACKS if (p.prefunc>=0) SCRIPT_MSG(" (%s:%s)", k?"pre":"creator", line.gettoken_str(2)); - if (p.postfunc>=0) + if (p.postfunc>=0 && k) SCRIPT_MSG(" (post:%s)", line.gettoken_str(3)); + else if (p.caption && !k) + SCRIPT_MSG(" (caption:%s)", line.gettoken_str(3)); #endif SCRIPT_MSG("\n"); diff --git a/Source/tokens.cpp b/Source/tokens.cpp index 3b6b3a17..e03d991f 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -105,7 +105,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_NOP,"Nop",0,0,""}, {TOK_NAME,"Name",1,1,"[/LANG=lang_id] installer_name"}, {TOK_OUTFILE,"OutFile",1,0,"install_output.exe"}, -{TOK_PAGE,"Page",1,2,"(custom function) | ((license|components|directory|instfiles) [pre_function] [post_function])"}, +{TOK_PAGE,"Page",1,2,"(custom function [caption]) | ((license|components|directory|instfiles) [pre_function] [post_function])"}, {TOK_POP,"Pop",1,0,"$(user_var: output)"}, {TOK_PUSH,"Push",1,0,"string"}, {TOK_QUIT,"Quit",0,0,""}, @@ -157,7 +157,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_UNINSTALLEXENAME,"UninstallExeName",0,0,"no longer supported, use WriteUninstaller from section."}, {TOK_UNINSTCAPTION,"UninstallCaption",1,1,"[/LANG=lang_id] uninstaller_caption"}, {TOK_UNINSTICON,"UninstallIcon",1,0,"icon_on_local_system.ico"}, -{TOK_UNINSTPAGE,"UninstPage",1,2,"(custom function) | ((uninstConfirm|instfiles) [pre_function] [post_function])"}, +{TOK_UNINSTPAGE,"UninstPage",1,2,"(custom function [caption]) | ((uninstConfirm|instfiles) [pre_function] [post_function])"}, {TOK_UNINSTTEXT,"UninstallText",1,2,"[/LANG=lang_id] Text_to_go_on_uninstall page [subtext]"}, {TOK_UNINSTSUBCAPTION,"UninstallSubCaption",2,1,"[/LANG=lang_id] page_number(0-2) new_subcaption"}, {TOK_UNREGDLL,"UnRegDLL",1,0,"dll_path_on_target.dll"},