1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-10 07:38:06 -05:00

pterm: set IUTF8 on pty devices depending on charset.

In a UTF-8 pterm, it makes sense to set the IUTF8 flag (on systems
that have one) on the pty device, so that line editing will take
account of UTF-8 multibyte characters.
This commit is contained in:
Simon Tatham 2015-09-01 18:35:38 +01:00
parent ad994bab57
commit 1840103c05
3 changed files with 24 additions and 2 deletions

View File

@ -3540,6 +3540,12 @@ void uxsel_input_remove(uxsel_id *id) {
sfree(id);
}
int frontend_is_utf8(void *frontend)
{
struct gui_data *inst = (struct gui_data *)frontend;
return inst->ucsdata.line_codepage == CS_UTF8;
}
char *setup_fonts_ucs(struct gui_data *inst)
{
int shadowbold = conf_get_int(inst->conf, CONF_shadowbold);

View File

@ -91,6 +91,7 @@ unsigned long getticks(void); /* based on gettimeofday(2) */
const char *get_x_display(void *frontend);
int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
long get_windowid(void *frontend);
int frontend_is_utf8(void *frontend);
/* Things gtkdlg.c needs from pterm.c */
void *get_window(void *frontend); /* void * to avoid depending on gtk.h */

View File

@ -764,14 +764,29 @@ static const char *pty_init(void *frontend, void **backend_handle, Conf *conf,
pty_open_master(pty);
/*
* Set the backspace character to be whichever of ^H and ^? is
* specified by bksp_is_delete.
* Set up configuration-dependent termios settings on the new pty.
*/
{
struct termios attrs;
tcgetattr(pty->master_fd, &attrs);
/*
* Set the backspace character to be whichever of ^H and ^? is
* specified by bksp_is_delete.
*/
attrs.c_cc[VERASE] = conf_get_int(conf, CONF_bksp_is_delete)
? '\177' : '\010';
/*
* Set the IUTF8 bit iff the character set is UTF-8.
*/
#ifdef IUTF8
if (frontend_is_utf8(frontend))
attrs.c_iflag |= IUTF8;
else
attrs.c_iflag &= ~IUTF8;
#endif
tcsetattr(pty->master_fd, TCSANOW, &attrs);
}