]> 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>
Tue, 1 Sep 2015 17:35:38 +0000 (18:35 +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.

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

index f5320c9f3620f4c4b0c7bc1274afbdeb3037ad2a..3d7486c434a8c26540c771075767934d382d380b 100644 (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);
index 271d3aa4099f3235178f6dd16c93fe12f666d207..6f97901af82228a80d4e6dd657a4032edefacdd3 100644 (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 */
index 33cc2c1e702d4e87574f917a75500bfe19d117ae..8c4688875efdcc04c5e385e97450d75c9d50973c 100644 (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);
     }