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
This commit is contained in:
kichik 2007-09-08 17:20:11 +00:00
parent ffe4cefdd9
commit b0978fc844
6 changed files with 43 additions and 42 deletions

View file

@ -262,6 +262,9 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
mystrcat(state_language, g_tmp); mystrcat(state_language, g_tmp);
} }
// initialize status update (SetDetailsPrint) flag
g_exec_flags.status_update = 6;
// set default language // set default language
set_language(); set_language();
@ -1450,15 +1453,13 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
#endif//NSIS_CONFIG_VISIBLE_SUPPORT #endif//NSIS_CONFIG_VISIBLE_SUPPORT
int ui_st_updateflag=0x6;
void NSISCALL update_status_text(int strtab, const char *text) { void NSISCALL update_status_text(int strtab, const char *text) {
static char tmp[NSIS_MAX_STRLEN*2]; static char tmp[NSIS_MAX_STRLEN*2];
LVITEM new_item; LVITEM new_item;
HWND linsthwnd = insthwnd; HWND linsthwnd = insthwnd;
if (linsthwnd) if (linsthwnd)
{ {
int updateflag = ui_st_updateflag; int updateflag = g_exec_flags.status_update;
int tmplen; int tmplen;
if (!(updateflag & 1)) if (!(updateflag & 1))

View file

@ -42,6 +42,7 @@ static stack_t *g_st;
#endif #endif
exec_flags g_exec_flags; exec_flags g_exec_flags;
exec_flags g_exec_flags_last_used;
struct { struct {
exec_flags *flags; exec_flags *flags;
@ -258,23 +259,8 @@ static int NSISCALL ExecuteEntry(entry *entry_)
return ExecuteCodeSegment(v,NULL); return ExecuteCodeSegment(v,NULL);
} }
case EW_UPDATETEXT: case EW_UPDATETEXT:
{ log_printf2("detailprint: %s",GetStringFromParm(0x00));
static int old_st_updateflag=6; update_status_text(parm0,0);
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);
}
}
break; break;
case EW_SLEEP: case EW_SLEEP:
{ {
@ -290,7 +276,15 @@ static int NSISCALL ExecuteEntry(entry *entry_)
break; break;
#endif//NSIS_CONFIG_VISIBLE_SUPPORT #endif//NSIS_CONFIG_VISIBLE_SUPPORT
case EW_SETFLAG: 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; break;
case EW_IFFLAG: case EW_IFFLAG:
{ {
@ -513,9 +507,9 @@ static int NSISCALL ExecuteEntry(entry *entry_)
update_status_text(LANG_EXTRACT,buf3); update_status_text(LANG_EXTRACT,buf3);
{ {
ui_st_updateflag++; g_exec_flags.status_update++;
ret=GetCompressedDataFromDataBlock(parm2,hOut); ret=GetCompressedDataFromDataBlock(parm2,hOut);
ui_st_updateflag--; g_exec_flags.status_update--;
} }
log_printf3("File: wrote %d to \"%s\"",ret,buf0); log_printf3("File: wrote %d to \"%s\"",ret,buf0);

View file

@ -96,7 +96,7 @@ BOOL CALLBACK verProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
#ifdef NSIS_COMPRESS_WHOLE #ifdef NSIS_COMPRESS_WHOLE
if (ui_st_updateflag & 1) if (g_exec_flags.status_update & 1)
{ {
wsprintf(bt, "... %d%%", percent); wsprintf(bt, "... %d%%", percent);
update_status_text(0, bt); 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; u=(char*)g_inflate_stream.next_out - outbuffer;
tc = GetTickCount(); 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)); wsprintf(progress, "... %d%%", MulDiv(input_len_total - input_len, 100, input_len_total));
update_status_text(0, progress); update_status_text(0, progress);

View file

@ -510,6 +510,7 @@ typedef struct
int rtl; int rtl;
int errlvl; int errlvl;
int alter_reg_view; int alter_reg_view;
int status_update;
} exec_flags; } exec_flags;
#define FIELDN(x, y) (((int *)&x)[y]) #define FIELDN(x, y) (((int *)&x)[y])

View file

@ -22,7 +22,6 @@ extern int *cur_langtable;
extern int NSISCALL ui_doinstall(void); extern int NSISCALL ui_doinstall(void);
void NSISCALL update_status_text(int strtab, const char *text2); void NSISCALL update_status_text(int strtab, const char *text2);
extern int ui_st_updateflag;
extern int ui_dlg_visible; extern int ui_dlg_visible;
extern HWND m_curwnd; extern HWND m_curwnd;

View file

@ -4554,24 +4554,30 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
} }
return add_entry(&ent); return add_entry(&ent);
case TOK_SETDETAILSPRINT: case TOK_SETDETAILSPRINT:
ent.which=EW_UPDATETEXT; {
ent.offsets[0] = 0; ent.which=EW_SETFLAG;
ent.offsets[1] = line.gettoken_enum(1,"lastused\0listonly\0textonly\0both\0none\0"); ent.offsets[0]=FLAG_OFFSET(status_update);
if (ent.offsets[1] < 0) PRINTHELP(); int k=line.gettoken_enum(1,"lastused\0listonly\0textonly\0both\0none\0");
switch (ent.offsets[1]) { if (k<0) PRINTHELP()
case 0: if (k == 0)
ent.offsets[2]=1; {
break; ent.offsets[2]=1;
case 1: }
case 2: else
case 3: {
ent.offsets[1]<<=1; if (k == 4)
break; {
case 4: k = 16;
ent.offsets[1]=16; }
break; else
{
k <<= 1;
}
ent.offsets[1]=add_intstring(k);
} }
SCRIPT_MSG("SetDetailsPrint: %s\n",line.gettoken_str(1)); SCRIPT_MSG("SetDetailsPrint: %s\n",line.gettoken_str(1));
}
return add_entry(&ent); return add_entry(&ent);
case TOK_SETAUTOCLOSE: case TOK_SETAUTOCLOSE:
{ {