From b0978fc84405992ee7c587bf320a26495b079af4 Mon Sep 17 00:00:00 2001 From: kichik Date: Sat, 8 Sep 2007 17:20:11 +0000 Subject: [PATCH] move SetDetailsPrint flag to g_exec_flag and added a lastused capability to EW_SETFLAG git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5268 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/exehead/Ui.c | 7 ++++--- Source/exehead/exec.c | 34 ++++++++++++++-------------------- Source/exehead/fileform.c | 4 ++-- Source/exehead/fileform.h | 1 + Source/exehead/ui.h | 1 - Source/script.cpp | 38 ++++++++++++++++++++++---------------- 6 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 42be1b3b..7214e920 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -262,6 +262,9 @@ FORCE_INLINE int NSISCALL ui_doinstall(void) mystrcat(state_language, g_tmp); } + // initialize status update (SetDetailsPrint) flag + g_exec_flags.status_update = 6; + // set default language set_language(); @@ -1450,15 +1453,13 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar #endif//NSIS_CONFIG_VISIBLE_SUPPORT -int ui_st_updateflag=0x6; - void NSISCALL update_status_text(int strtab, const char *text) { static char tmp[NSIS_MAX_STRLEN*2]; LVITEM new_item; HWND linsthwnd = insthwnd; if (linsthwnd) { - int updateflag = ui_st_updateflag; + int updateflag = g_exec_flags.status_update; int tmplen; if (!(updateflag & 1)) diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index e9b636f3..1566ffcb 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -42,6 +42,7 @@ static stack_t *g_st; #endif exec_flags g_exec_flags; +exec_flags g_exec_flags_last_used; struct { exec_flags *flags; @@ -258,23 +259,8 @@ static int NSISCALL ExecuteEntry(entry *entry_) return ExecuteCodeSegment(v,NULL); } case EW_UPDATETEXT: - { - static int old_st_updateflag=6; - if (parm2) - { - ui_st_updateflag=old_st_updateflag; - } - else if (parm1) - { - old_st_updateflag=ui_st_updateflag; - ui_st_updateflag=parm1; - } - else - { - log_printf2("detailprint: %s",GetStringFromParm(0x00)); - update_status_text(parm0,0); - } - } + log_printf2("detailprint: %s",GetStringFromParm(0x00)); + update_status_text(parm0,0); break; case EW_SLEEP: { @@ -290,7 +276,15 @@ static int NSISCALL ExecuteEntry(entry *entry_) break; #endif//NSIS_CONFIG_VISIBLE_SUPPORT case EW_SETFLAG: - FIELDN(g_exec_flags,parm0)=GetIntFromParm(1); + if (!parm2) + { + FIELDN(g_exec_flags_last_used,parm0)=FIELDN(g_exec_flags,parm0); + FIELDN(g_exec_flags,parm0)=GetIntFromParm(1); + } + else + { + FIELDN(g_exec_flags,parm0)=FIELDN(g_exec_flags_last_used,parm0); + } break; case EW_IFFLAG: { @@ -513,9 +507,9 @@ static int NSISCALL ExecuteEntry(entry *entry_) update_status_text(LANG_EXTRACT,buf3); { - ui_st_updateflag++; + g_exec_flags.status_update++; ret=GetCompressedDataFromDataBlock(parm2,hOut); - ui_st_updateflag--; + g_exec_flags.status_update--; } log_printf3("File: wrote %d to \"%s\"",ret,buf0); diff --git a/Source/exehead/fileform.c b/Source/exehead/fileform.c index e38584b3..e1cbabcb 100644 --- a/Source/exehead/fileform.c +++ b/Source/exehead/fileform.c @@ -96,7 +96,7 @@ BOOL CALLBACK verProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) } #ifdef NSIS_COMPRESS_WHOLE - if (ui_st_updateflag & 1) + if (g_exec_flags.status_update & 1) { wsprintf(bt, "... %d%%", percent); update_status_text(0, bt); @@ -367,7 +367,7 @@ int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen) u=(char*)g_inflate_stream.next_out - outbuffer; tc = GetTickCount(); - if (ui_st_updateflag & 1 && (tc - ltc > 200 || !input_len)) + if (g_exec_flags.status_update & 1 && (tc - ltc > 200 || !input_len)) { wsprintf(progress, "... %d%%", MulDiv(input_len_total - input_len, 100, input_len_total)); update_status_text(0, progress); diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index 3a143f23..66391f9c 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -510,6 +510,7 @@ typedef struct int rtl; int errlvl; int alter_reg_view; + int status_update; } exec_flags; #define FIELDN(x, y) (((int *)&x)[y]) diff --git a/Source/exehead/ui.h b/Source/exehead/ui.h index b4066b01..ae85609e 100644 --- a/Source/exehead/ui.h +++ b/Source/exehead/ui.h @@ -22,7 +22,6 @@ extern int *cur_langtable; extern int NSISCALL ui_doinstall(void); void NSISCALL update_status_text(int strtab, const char *text2); -extern int ui_st_updateflag; extern int ui_dlg_visible; extern HWND m_curwnd; diff --git a/Source/script.cpp b/Source/script.cpp index 302d6853..3ef4c774 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -4554,24 +4554,30 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) } return add_entry(&ent); case TOK_SETDETAILSPRINT: - ent.which=EW_UPDATETEXT; - ent.offsets[0] = 0; - ent.offsets[1] = line.gettoken_enum(1,"lastused\0listonly\0textonly\0both\0none\0"); - if (ent.offsets[1] < 0) PRINTHELP(); - switch (ent.offsets[1]) { - case 0: - ent.offsets[2]=1; - break; - case 1: - case 2: - case 3: - ent.offsets[1]<<=1; - break; - case 4: - ent.offsets[1]=16; - break; + { + ent.which=EW_SETFLAG; + ent.offsets[0]=FLAG_OFFSET(status_update); + int k=line.gettoken_enum(1,"lastused\0listonly\0textonly\0both\0none\0"); + if (k<0) PRINTHELP() + if (k == 0) + { + ent.offsets[2]=1; + } + else + { + if (k == 4) + { + k = 16; + } + else + { + k <<= 1; + } + + ent.offsets[1]=add_intstring(k); } SCRIPT_MSG("SetDetailsPrint: %s\n",line.gettoken_str(1)); + } return add_entry(&ent); case TOK_SETAUTOCLOSE: {