[svn] Revamped MS console logic. Submitted by David Fritz.

This commit is contained in:
hniksic 2004-02-25 15:45:24 -08:00
parent 6b955d9fe7
commit a0642cc62e
6 changed files with 46 additions and 28 deletions

View File

@ -1,3 +1,17 @@
2004-02-23 David Fritz <zeroxdf@att.net>
* http.c (http_loop): Ditto.
* ftp.c (ftp_loop_internal): Update call to ws_changetitle().
* main.c (main): Don't bother calling ws_changetitle().
* mswindows.h (ws_changetitle): Update prototype.
* mswindows.c (ws_changetitle): Remove second argument. Use
xfree_null().
(ws_percenttitle): Only update title when percentage has changed.
2004-02-23 David Fritz <zeroxdf@att.net>
* mswindows.h: Ditto.

View File

@ -1203,7 +1203,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con)
logprintf (LOG_VERBOSE, "--%s-- %s\n %s => `%s'\n",
tms, hurl, tmp, locf);
#ifdef WINDOWS
ws_changetitle (hurl, 1);
ws_changetitle (hurl);
#endif
xfree (hurl);
}

View File

@ -1912,7 +1912,7 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
logprintf (LOG_VERBOSE, "--%s-- %s\n %s => `%s'\n",
tms, hurl, tmp, locf);
#ifdef WINDOWS
ws_changetitle (hurl, 1);
ws_changetitle (hurl);
#endif
xfree (hurl);
}

View File

@ -852,12 +852,6 @@ Can't timestamp and not clobber old files at the same time.\n"));
}
url[i] = NULL;
/* Change the title of console window on Windows. #### I think this
statement should belong to retrieve_url(). --hniksic. */
#ifdef WINDOWS
ws_changetitle (*url, nurl);
#endif
/* Initialize logging. */
log_init (opt.lfilename, append_to_log);

View File

@ -165,33 +165,43 @@ ws_handler (DWORD dwEvent)
static char *title_buf = NULL;
static char *curr_url = NULL;
static int num_urls = 0;
static int old_percentage = -1;
/* Updates the console title with the URL of the current file being
transferred. */
void
ws_changetitle (const char *url, int nurl)
ws_changetitle (const char *url)
{
if (!nurl)
return;
num_urls = nurl;
if (title_buf)
xfree(title_buf);
if (curr_url)
xfree(curr_url);
xfree_null (title_buf);
xfree_null (curr_url);
title_buf = (char *)xmalloc (strlen (url) + 20);
curr_url = xstrdup(url);
sprintf(title_buf, "Wget %s%s", url, nurl == 1 ? "" : " ...");
SetConsoleTitle(title_buf);
curr_url = xstrdup (url);
old_percentage = -1;
sprintf (title_buf, "Wget %s", curr_url);
SetConsoleTitle (title_buf);
}
/* Updates the console title with the percentage of the current file
transferred. */
void
ws_percenttitle (double percent)
ws_percenttitle (double percentage_float)
{
if (num_urls == 1 && title_buf && curr_url && fabs(percent) <= 100.0)
{
sprintf (title_buf, "Wget [%.0f%%] %s", percent, curr_url);
SetConsoleTitle (title_buf);
}
int percentage = (int) percentage_float;
/* Only update the title when the percentage has changed. */
if (percentage == old_percentage)
return;
old_percentage = percentage;
if (percentage > 100)
return;
assert (title_buf != NULL);
assert (curr_url != NULL);
sprintf (title_buf, "Wget [%d%%] %s", percentage, curr_url);
SetConsoleTitle (title_buf);
}
/* Returns a pointer to the fully qualified name of the directory that

View File

@ -157,7 +157,7 @@ int usleep (unsigned long);
#endif
void ws_startup (void);
void ws_changetitle (const char*, int);
void ws_changetitle (const char *);
void ws_percenttitle (double);
char *ws_mypath (void);
void windows_main_junk (int *, char **, char **);