Don't make too big windows, count actually text width/height
This commit is contained in:
parent
df59073be8
commit
f195e2e513
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: utils.c,v 1.12 1994/10/26 02:53:15 phk Exp $
|
||||
* $Id: utils.c,v 1.13 1994/10/29 10:01:40 phk Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -28,6 +28,42 @@
|
||||
|
||||
#include "sysinstall.h"
|
||||
|
||||
void
|
||||
strip_trailing_newlines(char *p)
|
||||
{
|
||||
int len = strlen(p);
|
||||
while (len > 0 && p[len-1] == '\n')
|
||||
p[--len] = '\0';
|
||||
}
|
||||
|
||||
int strwidth(char *p)
|
||||
{
|
||||
int i = 0, len;
|
||||
char *start, *s;
|
||||
|
||||
for (start = s = p; (s = strchr(s, '\n')) != NULL; start = ++s) {
|
||||
*s = '\0';
|
||||
len = strlen(start);
|
||||
*s = '\n';
|
||||
if (len > i)
|
||||
i = len;
|
||||
}
|
||||
len = strlen(start);
|
||||
if (len > i)
|
||||
i = len;
|
||||
return i;
|
||||
}
|
||||
|
||||
int strheight(char *p)
|
||||
{
|
||||
int i = 1;
|
||||
char *s;
|
||||
|
||||
for (s = p; (s = strchr(s, '\n')) != NULL; s++)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
Debug(char *fmt, ...)
|
||||
{
|
||||
@ -48,14 +84,19 @@ TellEm(char *fmt, ...)
|
||||
{
|
||||
char *p;
|
||||
va_list ap;
|
||||
int width, height;
|
||||
|
||||
p = Malloc(2048);
|
||||
va_start(ap,fmt);
|
||||
vsnprintf(p, 2048, fmt, ap);
|
||||
va_end(ap);
|
||||
strip_trailing_newlines(p);
|
||||
write(debug_fd,"Progress <",10);
|
||||
write(debug_fd,p,strlen(p));
|
||||
write(debug_fd,">\n\r",3);
|
||||
dialog_msgbox("Progress", p, 3, 75, 0);
|
||||
width = strwidth(p);
|
||||
height = strheight(p);
|
||||
dialog_msgbox("Progress", p, height+2, width+4, 0);
|
||||
free(p);
|
||||
}
|
||||
|
||||
@ -64,14 +105,19 @@ Fatal(char *fmt, ...)
|
||||
{
|
||||
char *p;
|
||||
va_list ap;
|
||||
int width, height;
|
||||
|
||||
p = Malloc(2048);
|
||||
va_start(ap,fmt);
|
||||
vsnprintf(p, 2048, fmt, ap);
|
||||
va_end(ap);
|
||||
strip_trailing_newlines(p);
|
||||
width = strwidth(p);
|
||||
height = strheight(p);
|
||||
if (dialog_active)
|
||||
dialog_msgbox("Fatal", p, 12, 75, 1);
|
||||
dialog_msgbox("Fatal", p, height+4, width+4, 1);
|
||||
else
|
||||
fprintf(stderr, "Fatal -- %s", p);
|
||||
fprintf(stderr, "Fatal -- %s\n", p);
|
||||
free(p);
|
||||
ExitSysinstall();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user