mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
* util.h (msglen): Converted from a function to a procedure.
* util.c (msglen): Changed variable names and did a speedup. * hotlist.c (add_new_entry_input): Using new msglen function. * hotlist.c (add_new_group_input): Likewise. * wtools.c (query_dialog): Likewise. * wtools.c (fg_input_dialog_help): Likewise.
This commit is contained in:
parent
711f268786
commit
3a40734373
@ -1,3 +1,12 @@
|
||||
2005-02-05 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* util.h (msglen): Converted from a function to a procedure.
|
||||
* util.c (msglen): Changed variable names and did a speedup.
|
||||
* hotlist.c (add_new_entry_input): Using new msglen function.
|
||||
* hotlist.c (add_new_group_input): Likewise.
|
||||
* wtools.c (query_dialog): Likewise.
|
||||
* wtools.c (fg_input_dialog_help): Likewise.
|
||||
|
||||
2005-02-02 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||
|
||||
* find.c: Implement non-recursive 'Find file' feature.
|
||||
|
@ -852,16 +852,19 @@ add_new_entry_input (const char *header, const char *text1, const char *text2,
|
||||
0, 0, "label-lbl" },
|
||||
NULL_QuickWidget };
|
||||
|
||||
size_t len;
|
||||
int len;
|
||||
int i;
|
||||
int lines1, lines2;
|
||||
int cols1, cols2;
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
static int i18n_flag = 0;
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
len = max (strlen (header), (size_t) msglen (text1, &lines1));
|
||||
len = max (len, (size_t) msglen (text2, &lines2)) + 4;
|
||||
msglen(text1, &lines1, &cols1);
|
||||
msglen(text2, &lines2, &cols2);
|
||||
len = max ((int) strlen (header), cols1);
|
||||
len = max (len, cols2) + 4;
|
||||
len = max (len, 64);
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
@ -949,13 +952,14 @@ add_new_group_input (const char *header, const char *label, char **result)
|
||||
quick_widgets variable above */
|
||||
int len;
|
||||
int i;
|
||||
int lines;
|
||||
int lines, cols;
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
static int i18n_flag = 0;
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
len = max (strlen (header), (size_t) msglen (label, &lines)) + 4;
|
||||
msglen (label, &lines, &cols);
|
||||
len = max ((int) strlen (header), cols) + 4;
|
||||
len = max (len, 64);
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
|
25
src/util.c
25
src/util.c
@ -97,23 +97,26 @@ is_printable (int c)
|
||||
#endif /* !HAVE_CHARSET */
|
||||
}
|
||||
|
||||
/* Returns the message dimensions (lines and columns) */
|
||||
int msglen (const char *text, int *lines)
|
||||
/* Calculates the message dimensions (lines and columns) */
|
||||
void msglen (const char *text, int *lines, int *columns)
|
||||
{
|
||||
int max = 0;
|
||||
int line_len = 0;
|
||||
int nlines = 1; /* even the empty string takes one line */
|
||||
int ncolumns = 0;
|
||||
int colindex = 0;
|
||||
|
||||
for (*lines = 1;*text; text++){
|
||||
for (; *text != '\0'; text++) {
|
||||
if (*text == '\n') {
|
||||
line_len = 0;
|
||||
(*lines)++;
|
||||
nlines++;
|
||||
colindex = 0;
|
||||
} else {
|
||||
line_len++;
|
||||
if (line_len > max)
|
||||
max = line_len;
|
||||
colindex++;
|
||||
if (colindex > ncolumns)
|
||||
ncolumns = colindex;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
|
||||
*lines = nlines;
|
||||
*columns = ncolumns;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -9,7 +9,7 @@ extern const char *cstrcasestr (const char *haystack, const char *needle);
|
||||
|
||||
void str_replace(char *s, char from, char to);
|
||||
int is_printable (int c);
|
||||
int msglen (const char *text, int *lines);
|
||||
void msglen (const char *text, /*@out@*/ int *lines, /*@out@*/ int *columns);
|
||||
|
||||
/* Copy from s to d, and trim the beginning if necessary, and prepend
|
||||
* "..." in this case. The destination string can have at most len
|
||||
|
@ -131,7 +131,8 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
||||
}
|
||||
|
||||
/* count coordinates */
|
||||
cols = 6 + max (win_len, max ((int) strlen (header), msglen (text, &lines)));
|
||||
msglen (text, &lines, &cols);
|
||||
cols = 6 + max (win_len, max ((int) strlen (header), cols));
|
||||
lines += 4 + (count > 0 ? 2 : 0);
|
||||
xpos = COLS / 2 - cols / 2;
|
||||
ypos = LINES / 3 - (lines - 3) / 2;
|
||||
@ -446,7 +447,7 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
|
||||
|
||||
int len;
|
||||
int i;
|
||||
int lines;
|
||||
int lines, cols;
|
||||
int ret;
|
||||
char *my_str;
|
||||
char histname[64] = "inp|";
|
||||
@ -457,7 +458,8 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
|
||||
g_strlcpy (histname + 3, header, 61);
|
||||
quick_widgets[2].histname = histname;
|
||||
|
||||
len = max ((int) strlen (header), msglen (text, &lines)) + 4;
|
||||
msglen (text, &lines, &cols);
|
||||
len = max ((int) strlen (header), cols) + 4;
|
||||
len = max (len, 64);
|
||||
|
||||
/* The special value of def_text is used to identify password boxes
|
||||
|
Loading…
Reference in New Issue
Block a user