1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-30 01:55:30 +00:00

Enhance version and features display. Wrap on spaces when features

are sent to console using -version, and let Info dialog do the job in
interactive mode.
This commit is contained in:
Laurent MONIN 2007-04-26 15:00:04 +02:00 committed by Witold Filipczyk
parent 9a1ba01947
commit c496a7eaf6

View File

@ -48,22 +48,42 @@ static void
add_modules_to_string(struct string *string, struct terminal *term)
{
struct module *module;
int i, last_split = 0;
unsigned char *last_newline = strrchr(string->source, '\n');
if (last_newline)
last_split = last_newline - string->source;
int i;
foreach_module (module, builtin_modules, i) {
if (i > 0) add_to_string(string, ", ");
if (string->length - last_split > 70) {
add_char_to_string(string, '\n');
last_split = string->length;
}
add_module_to_string(string, module, term);
}
}
/* Wrap string on spaces starting at position @start_at, trying
* to keep lines undex @maxlen length */
static void
wrap_string(struct string *string, int start_at, int maxlen)
{
unsigned char *pos, *start_pos;
unsigned char *last_pos = NULL;
assert(string && string->source && start_at < string->length);
if_assert_failed return;
if (maxlen <= 0) return;
pos = start_pos = &string->source[start_at];
while ((pos = strchr(pos, ' '))) {
int len = pos - start_pos;
if (len < maxlen) {
last_pos = pos;
pos++;
} else {
if (last_pos) *last_pos = '\n';
pos = start_pos = last_pos + 1;
}
if (!*pos) break;
}
}
/* @more will add more information especially for info box. */
unsigned char *
get_dyn_full_version(struct terminal *term, int more)
@ -74,17 +94,19 @@ get_dyn_full_version(struct terminal *term, int more)
if (!init_string(&string)) return NULL;
add_format_to_string(&string, "ELinks %s", VERSION_STRING);
if (*build_id)
if (*build_id) {
if (more) add_to_string(&string, "\n");
add_format_to_string(&string, " (%s)", build_id);
}
if (more) add_to_string(&string, "\n");
add_format_to_string(&string, _(" (built on %s %s)", term),
build_date, build_time);
if (more) {
add_to_string(&string, "\n");
add_format_to_string(&string, _("Built on %s %s", term),
build_date, build_time);
add_to_string(&string, "\n\n");
add_to_string(&string, _("Text WWW browser", term));
} else {
add_format_to_string(&string, _(" (built on %s %s)", term),
build_date, build_time);
}
string_concat(&string,
@ -128,6 +150,17 @@ get_dyn_full_version(struct terminal *term, int more)
add_modules_to_string(&string, term);
if (!more) {
int start_at = 0;
unsigned char *last_newline = strrchr(string.source, '\n');
if (last_newline) {
start_at = last_newline - string.source + 1;
}
wrap_string(&string, start_at, 72);
}
return string.source;
}