1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Remove TermWin's is_utf8 method.

All implementations of it work by checking the line_codepage field in
the ucsdata structure that the terminal itself already has a pointer
to. Therefore, it's a totally unnecessary query function: the terminal
can check the same thing directly by inspecting that structure!

(In fact, it already _does_ do that, for the purpose of actually
deciding how to decode terminal output data. It only uses this query
function at all for the auxiliary purpose of inventing useful tty
modes to pass to the backend.)
This commit is contained in:
Simon Tatham 2021-02-07 19:59:20 +00:00
parent b63a66cd2c
commit 45b03419fd
5 changed files with 2 additions and 21 deletions

View File

@ -99,7 +99,6 @@ static void fuzz_palette_reset(TermWin *tw) {}
static void fuzz_get_pos(TermWin *tw, int *x, int *y) { *x = *y = 0; }
static void fuzz_get_pixels(TermWin *tw, int *x, int *y) { *x = *y = 0; }
static const char *fuzz_get_title(TermWin *tw, bool icon) { return "moo"; }
static bool fuzz_is_utf8(TermWin *tw) { return true; }
static const TermWinVtable fuzz_termwin_vt = {
.setup_draw_ctx = fuzz_setup_draw_ctx,
@ -129,7 +128,6 @@ static const TermWinVtable fuzz_termwin_vt = {
.get_pos = fuzz_get_pos,
.get_pixels = fuzz_get_pixels,
.get_title = fuzz_get_title,
.is_utf8 = fuzz_is_utf8,
};
void ldisc_send(Ldisc *ldisc, const void *buf, int len, bool interactive) {}

View File

@ -1150,7 +1150,6 @@ struct TermWinVtable {
void (*get_pos)(TermWin *, int *x, int *y);
void (*get_pixels)(TermWin *, int *x, int *y);
const char *(*get_title)(TermWin *, bool icon);
bool (*is_utf8)(TermWin *);
};
static inline bool win_setup_draw_ctx(TermWin *win)
@ -1213,8 +1212,6 @@ static inline void win_get_pixels(TermWin *win, int *x, int *y)
{ win->vt->get_pixels(win, x, y); }
static inline const char *win_get_title(TermWin *win, bool icon)
{ return win->vt->get_title(win, icon); }
static inline bool win_is_utf8(TermWin *win)
{ return win->vt->is_utf8(win); }
/*
* Global functions not specific to a connection instance.

View File

@ -7138,7 +7138,7 @@ char *term_get_ttymode(Terminal *term, const char *mode)
if (strcmp(mode, "ERASE") == 0) {
val = term->bksp_is_delete ? "^?" : "^H";
} else if (strcmp(mode, "IUTF8") == 0) {
val = win_is_utf8(term->win) ? "yes" : "no";
val = (term->ucsdata->line_codepage == CP_UTF8) ? "yes" : "no";
}
/* FIXME: perhaps we should set ONLCR based on lfhascr as well? */
/* FIXME: or ECHO and friends based on local echo state? */

View File

@ -348,7 +348,7 @@ static int gtk_seat_get_userpass_input(Seat *seat, prompts_t *p,
static bool gtk_seat_is_utf8(Seat *seat)
{
GtkFrontend *inst = container_of(seat, GtkFrontend, seat);
return win_is_utf8(&inst->termwin);
return inst->ucsdata.line_codepage == CS_UTF8;
}
static bool gtk_seat_get_window_pixel_size(Seat *seat, int *w, int *h)
@ -4251,12 +4251,6 @@ static bool gtk_seat_get_windowid(Seat *seat, long *id)
}
#endif
static bool gtkwin_is_utf8(TermWin *tw)
{
GtkFrontend *inst = container_of(tw, GtkFrontend, termwin);
return inst->ucsdata.line_codepage == CS_UTF8;
}
char *setup_fonts_ucs(GtkFrontend *inst)
{
bool shadowbold = conf_get_bool(inst->conf, CONF_shadowbold);
@ -5197,7 +5191,6 @@ static const TermWinVtable gtk_termwin_vt = {
.get_pos = gtkwin_get_pos,
.get_pixels = gtkwin_get_pixels,
.get_title = gtkwin_get_title,
.is_utf8 = gtkwin_is_utf8,
};
void new_session_window(Conf *conf, const char *geometry_string)

View File

@ -254,7 +254,6 @@ static void wintw_palette_reset(TermWin *);
static void wintw_get_pos(TermWin *, int *x, int *y);
static void wintw_get_pixels(TermWin *, int *x, int *y);
static const char *wintw_get_title(TermWin *, bool icon);
static bool wintw_is_utf8(TermWin *);
static const TermWinVtable windows_termwin_vt = {
.setup_draw_ctx = wintw_setup_draw_ctx,
@ -284,7 +283,6 @@ static const TermWinVtable windows_termwin_vt = {
.get_pos = wintw_get_pos,
.get_pixels = wintw_get_pixels,
.get_title = wintw_get_title,
.is_utf8 = wintw_is_utf8,
};
static TermWin wintw[1];
@ -300,11 +298,6 @@ static bool is_utf8(void)
return ucsdata.line_codepage == CP_UTF8;
}
static bool wintw_is_utf8(TermWin *tw)
{
return is_utf8();
}
static bool win_seat_is_utf8(Seat *seat)
{
return is_utf8();