]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
pterm: set IUTF8 on pty devices depending on charset.
authorSimon Tatham <anakin@pobox.com>
Tue, 1 Sep 2015 17:35:38 +0000 (18:35 +0100)
committerSimon Tatham <anakin@pobox.com>
Sat, 17 Oct 2015 16:30:17 +0000 (17:30 +0100)
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.

(cherry picked from commit 1840103c05d10ba1c45353282b4ad7f742a75b92)

unix/gtkwin.c
unix/unix.h
unix/uxpty.c

index 4cce11e6e52b9431fab0df0423ced7c835a81605..1c29b41eab2d6dc6371a465d82abcf8e82f69a19 100644 (file)
@@ -2914,6 +2914,12 @@ void uxsel_input_remove(int id) {
     gdk_input_remove(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);
index 917976d699d704f128a15d65cf4b40f390676ac5..e78800b5a2d93f02ff53fe83ff85473a594f2701 100644 (file)
@@ -77,6 +77,7 @@ unsigned long getticks(void);        /* based on gettimeofday(2) */
 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 */
index 307690d64ea441a6d60e31f653726fcf3bc1231f..e504b7050a8d28f9adc1aedba0421c18b62fb05a 100644 (file)
@@ -738,14 +738,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);
     }