mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Add get_terminal_codepage().
This simplifies the callers a little and may help implement simultaneous support for different charsets on different terminals of the same type (bug 1064).
This commit is contained in:
parent
25da8085b3
commit
ad45176dde
@ -297,7 +297,7 @@ select_button_by_key(struct dialog_data *dlg_data)
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
key = unicode_fold_label_case(get_kbd_key(ev));
|
||||
codepage = get_opt_codepage_tree(dlg_data->win->term->spec, "charset");
|
||||
codepage = get_terminal_codepage(dlg_data->win->term);
|
||||
#else
|
||||
key = toupper(get_kbd_key(ev));
|
||||
#endif
|
||||
|
@ -127,7 +127,7 @@ check_hotkeys_common(struct menu *menu, term_event_char_T hotkey, struct termina
|
||||
{
|
||||
#ifdef CONFIG_UTF8
|
||||
unicode_val_T key = unicode_fold_label_case(hotkey);
|
||||
int codepage = get_opt_codepage_tree(term->spec, "charset");
|
||||
int codepage = get_terminal_codepage(term);
|
||||
#else
|
||||
unsigned char key = toupper(hotkey);
|
||||
#endif
|
||||
|
@ -691,8 +691,7 @@ kbd_field(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
/* get_kbd_key(ev) is UCS-4, and @text
|
||||
* is in the terminal's charset. */
|
||||
ins = u2cp_no_nbsp(get_kbd_key(ev),
|
||||
get_opt_codepage_tree(term->spec,
|
||||
"charset"));
|
||||
get_terminal_codepage(term));
|
||||
inslen = strlen(ins);
|
||||
#endif /* CONFIG_UTF8 */
|
||||
|
||||
|
@ -50,7 +50,7 @@ charset_list(struct terminal *term, void *xxx, void *ses_)
|
||||
int i, items;
|
||||
int sel = 0;
|
||||
const unsigned char *const sel_mime = get_cp_mime_name(
|
||||
get_opt_codepage_tree(term->spec, "charset"));
|
||||
get_terminal_codepage(term));
|
||||
struct menu_item *mi = new_menu(FREE_LIST);
|
||||
|
||||
if (!mi) return;
|
||||
|
@ -455,7 +455,7 @@ render_document_frames(struct session *ses, int no_cache)
|
||||
if (!get_opt_bool_tree(ses->tab->term->spec, "underline"))
|
||||
doc_opts.color_flags |= COLOR_ENHANCE_UNDERLINE;
|
||||
|
||||
doc_opts.cp = get_opt_codepage_tree(ses->tab->term->spec, "charset");
|
||||
doc_opts.cp = get_terminal_codepage(ses->tab->term);
|
||||
doc_opts.no_cache = no_cache & 1;
|
||||
doc_opts.gradual_rerendering = !!(no_cache & 2);
|
||||
|
||||
|
@ -61,7 +61,7 @@ extern int current_charset;
|
||||
static inline void
|
||||
intl_set_charset(struct terminal *term)
|
||||
{
|
||||
int new_charset = get_opt_codepage_tree(term->spec, "charset");
|
||||
int new_charset = get_terminal_codepage(term);
|
||||
|
||||
/* Prevent useless switching. */
|
||||
if (current_charset != new_charset) {
|
||||
|
@ -171,8 +171,7 @@ show_http_error_document(struct session *ses, void *data)
|
||||
if (str) {
|
||||
/* The codepage that _("foo", term) used when it was
|
||||
* called by get_http_error_document. */
|
||||
const int gettext_codepage
|
||||
= get_opt_codepage_tree(term->spec, "charset");
|
||||
const int gettext_codepage = get_terminal_codepage(term);
|
||||
|
||||
if (cached) delete_entry_content(cache);
|
||||
|
||||
|
@ -388,7 +388,7 @@ ses_imgmap(struct session *ses)
|
||||
&menu, &ml, ses->loading_uri,
|
||||
&doc_view->document->options,
|
||||
ses->task.target.frame,
|
||||
get_opt_codepage_tree(ses->tab->term->spec, "charset"),
|
||||
get_terminal_codepage(ses->tab->term),
|
||||
get_opt_codepage("document.codepage.assume"),
|
||||
get_opt_bool("document.codepage.force_assumed")))
|
||||
return;
|
||||
|
@ -148,7 +148,7 @@ term_send_ucs(struct terminal *term, unicode_val_T u,
|
||||
const unsigned char *recoded;
|
||||
|
||||
set_kbd_term_event(&ev, KBD_UNDEF, modifier);
|
||||
recoded = u2cp_no_nbsp(u, get_opt_codepage_tree(term->spec, "charset"));
|
||||
recoded = u2cp_no_nbsp(u, get_terminal_codepage(term));
|
||||
if (!recoded) recoded = "*";
|
||||
while (*recoded) {
|
||||
ev.info.keyboard.key = *recoded;
|
||||
@ -184,8 +184,7 @@ check_terminal_name(struct terminal *term, struct terminal_info *info)
|
||||
/* Probably not best place for set this. But now we finally have
|
||||
* term->spec and term->utf8 should be set before decode session info.
|
||||
* --Scrool */
|
||||
term->utf8_cp = is_cp_utf8(get_opt_codepage_tree(term->spec,
|
||||
"charset"));
|
||||
term->utf8_cp = is_cp_utf8(get_terminal_codepage(term));
|
||||
/* Force UTF-8 I/O if the UTF-8 charset is selected. Various
|
||||
* places assume that the terminal's charset is unibyte if
|
||||
* UTF-8 I/O is disabled. (bug 827) */
|
||||
|
@ -103,6 +103,24 @@ init_term(int fdin, int fdout)
|
||||
return term;
|
||||
}
|
||||
|
||||
/** Get the codepage of a terminal. The UTF-8 I/O option does not
|
||||
* affect this.
|
||||
*
|
||||
* @todo Perhaps cache the value in struct terminal?
|
||||
*
|
||||
* @bug Bug 1064: If the charset has been set as "System", this should
|
||||
* apply the locale environment variables of the slave ELinks process,
|
||||
* not those of the master ELinks process that parsed the configuration
|
||||
* file. That is why the parameter points to struct terminal and not
|
||||
* merely to its option tree (term->spec).
|
||||
*
|
||||
* @see get_translation_table(), get_cp_mime_name() */
|
||||
int
|
||||
get_terminal_codepage(const struct terminal *term)
|
||||
{
|
||||
return get_opt_codepage_tree(term->spec, "charset");
|
||||
}
|
||||
|
||||
void
|
||||
redraw_all_terminals(void)
|
||||
{
|
||||
|
@ -172,6 +172,7 @@ void destroy_terminal(struct terminal *);
|
||||
void redraw_terminal(struct terminal *term);
|
||||
void redraw_terminal_cls(struct terminal *term);
|
||||
void cls_redraw_all_terminals(void);
|
||||
int get_terminal_codepage(const struct terminal *);
|
||||
|
||||
void redraw_all_terminals(void);
|
||||
void destroy_all_terminals(void);
|
||||
|
@ -165,7 +165,7 @@ init_form_state(struct document_view *doc_view,
|
||||
|
||||
doc_cp = doc_view->document->cp;
|
||||
term = doc_view->session->tab->term;
|
||||
viewer_cp = get_opt_codepage_tree(term->spec, "charset");
|
||||
viewer_cp = get_terminal_codepage(term);
|
||||
|
||||
mem_free_set(&fs->value, NULL);
|
||||
|
||||
@ -1248,7 +1248,7 @@ get_form_uri(struct session *ses, struct document_view *doc_view,
|
||||
|
||||
get_successful_controls(doc_view, fc, &submit);
|
||||
|
||||
cp_from = get_opt_codepage_tree(ses->tab->term->spec, "charset");
|
||||
cp_from = get_terminal_codepage(ses->tab->term);
|
||||
cp_to = doc_view->document->cp;
|
||||
switch (form->method) {
|
||||
case FORM_METHOD_GET:
|
||||
@ -1846,8 +1846,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
||||
#ifdef CONFIG_UTF8
|
||||
/* fs->value is in the charset of the terminal. */
|
||||
ctext = u2cp_no_nbsp(get_kbd_key(ev),
|
||||
get_opt_codepage_tree(ses->tab->term->spec,
|
||||
"charset"));
|
||||
get_terminal_codepage(ses->tab->term));
|
||||
length = strlen(ctext);
|
||||
|
||||
if (strlen(fs->value) + length > fc->maxlength
|
||||
|
@ -1216,8 +1216,7 @@ try_document_key(struct session *ses, struct document_view *doc_view,
|
||||
#ifdef CONFIG_UTF8
|
||||
key = get_kbd_key(ev);
|
||||
#else /* !CONFIG_UTF8 */
|
||||
key = cp2u(get_opt_codepage_tree(ses->tab->term->spec,
|
||||
"charset"),
|
||||
key = cp2u(get_terminal_codepage(ses->tab->term),
|
||||
get_kbd_key(ev));
|
||||
#endif /* !CONFIG_UTF8 */
|
||||
/* If @key now is 0 (which is used in link.accesskey if there
|
||||
|
Loading…
Reference in New Issue
Block a user