1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Convert link titles to correct codepage before displaying it on screen.

Don't replace UTF-8 bytes with '*'. Probably there is need to do better
check what will be displayed.

Also get_current_link_title is no longer pretty and trivial. (o:
This commit is contained in:
Pavol Babincak 2006-03-13 01:54:34 +01:00 committed by Pavol Babincak
parent 7d4dedcb8d
commit 8b9d06c977
10 changed files with 87 additions and 19 deletions

View File

@ -145,6 +145,11 @@ download_dialog_layouter(struct dialog_data *dlg_data)
mem_free(msg);
return;
}
#ifdef CONFIG_UTF_8
if (term->utf8)
decode_uri(url);
else
#endif /* CONFIG_UTF_8 */
decode_uri_for_display(url);
url_len = strlen(url);
@ -296,7 +301,14 @@ get_file_download_text(struct listbox_item *item, struct terminal *term)
unsigned char *uristring;
uristring = get_uri_string(file_download->uri, URI_PUBLIC);
if (uristring) decode_uri_for_display(uristring);
if (uristring) {
#ifdef CONFIG_UTF_8
if (term->utf8)
decode_uri(uristring);
else
#endif /* CONFIG_UTF_8 */
decode_uri_for_display(uristring);
}
return uristring;
}

View File

@ -578,6 +578,11 @@ query_file(struct session *ses, struct uri *uri, void *data,
add_mime_filename_to_string(&def, uri);
/* Remove the %-ugliness for display */
#ifdef CONFIG_UTF_8
if (ses->tab->term->utf8)
decode_uri_string(&def);
else
#endif /* CONFIG_UTF_8 */
decode_uri_string_for_display(&def);
if (interactive) {

View File

@ -142,15 +142,8 @@ get_current_link_info_and_title(struct session *ses,
link_title = get_current_link_title(doc_view);
if (link_title) {
unsigned char *src;
assert(*link_title);
/* Remove illicit chars. */
for (src = link_title; *src; src++)
if (!isprint(*src) || iscntrl(*src))
*src = '*';
ret = straconcat(link_info, " - ", link_title, NULL);
mem_free(link_info);
mem_free(link_title);

View File

@ -345,9 +345,15 @@ render_document(struct view_state *vs, struct document_view *doc_view,
}
document->title = get_uri_string(document->uri, components);
if (document->title)
if (document->title) {
#ifdef CONFIG_UTF_8
if (doc_view->document->options.utf8)
decode_uri(document->title);
else
#endif /* CONFIG_UTF_8 */
decode_uri_for_display(document->title);
}
}
#ifdef CONFIG_CSS
document->css_magic = get_document_css_magic(document);

View File

@ -574,6 +574,11 @@ bittorrent_message_dialog(struct session *ses, void *data)
uristring = get_uri_string(message->uri, URI_PUBLIC);
if (uristring) {
#ifdef CONFIG_UTF_8
if (ses->tab->term->utf8)
decode_uri(uristring);
else
#endif /* CONFIG_UTF_8 */
decode_uri_for_display(uristring);
add_format_to_string(&string,
_("Unable to retrieve %s", ses->tab->term),
@ -719,6 +724,11 @@ bittorrent_query_callback(void *data, enum connection_state state,
/* Let's make the filename pretty for display & save */
/* TODO: The filename can be the empty string here. See bug 396. */
#ifdef CONFIG_UTF_8
if (term->utf8)
decode_uri_string(&filename);
else
#endif /* CONFIG_UTF_8 */
decode_uri_string_for_display(&filename);
}

View File

@ -649,6 +649,10 @@ init_gopher_index_cache_entry(struct connection *conn)
return S_OUT_OF_MEM;
where = get_uri_string(conn->uri, URI_PUBLIC);
/* TODO: Use different function when using UTF-8
* in terminal (decode_uri_for_display replaces
* bytes of UTF-8 characters width '*'). */
if (where) decode_uri_for_display(where);
add_format_to_string(&buffer,

View File

@ -1048,6 +1048,11 @@ do_type_query(struct type_query *type_query, unsigned char *ct, struct mime_hand
/* Let's make the filename pretty for display & save */
/* TODO: The filename can be the empty string here. See bug 396. */
#ifdef CONFIG_UTF_8
if (term->utf8)
decode_uri_string(&filename);
else
#endif /* CONFIG_UTF_8 */
decode_uri_string_for_display(&filename);
}

View File

@ -268,6 +268,11 @@ print_error_dialog(struct session *ses, enum connection_state state,
uristring = uri ? get_uri_string(uri, URI_PUBLIC) : NULL;
if (uristring) {
#ifdef CONFIG_UTF_8
if (ses->tab->term->utf8)
decode_uri(uristring);
else
#endif /* CONFIG_UTF_8 */
decode_uri_for_display(uristring);
add_format_to_string(&msg,
_("Unable to retrieve %s", ses->tab->term),

View File

@ -1347,7 +1347,7 @@ end:
do_menu(term, mi, ses, 1);
}
/* Return current link's title. Pretty trivial. */
/* Return current link's title. */
unsigned char *
get_current_link_title(struct document_view *doc_view)
{
@ -1361,7 +1361,29 @@ get_current_link_title(struct document_view *doc_view)
link = get_current_link(doc_view);
return (link && link->title && *link->title) ? stracpy(link->title) : NULL;
if (link && link->title && *link->title) {
unsigned char *link_title, *src;
struct conv_table *convert_table;
convert_table = get_translation_table(doc_view->document->cp,
doc_view->document->options.cp);
link_title = convert_string(convert_table, link->title,
strlen(link->title),
doc_view->document->options.cp,
CSM_DEFAULT, NULL, NULL, NULL);
/* Remove illicit chars. */
#ifdef CONFIG_UTF_8
if (link_title && !doc_view->document->options.utf8)
#endif /* CONFIG_UTF_8 */
for (src = link_title; *src; src++)
if (!isprint(*src) || iscntrl(*src))
*src = '*';
return link_title;
}
return NULL;
}
unsigned char *
@ -1406,6 +1428,11 @@ get_current_link_info(struct session *ses, struct document_view *doc_view)
add_char_to_string(&str, ')');
}
#ifdef CONFIG_UTF_8
if (term->utf8)
decode_uri_string(&str);
else
#endif /* CONFIG_UTF_8 */
decode_uri_string_for_display(&str);
return str.source;
}

View File

@ -11,6 +11,7 @@ struct session;
struct term_event;
struct terminal;
struct uri;
struct conv_table;
void set_link(struct document_view *doc_view);
void free_link(struct document_view *doc_view);