summarylogtreecommitdiffstats
path: root/fullwidth-backspace.patch
blob: f519417ce3849e0d291a444cbc86dc682047e230 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--- a/tmux-2.1/screen-write.c	2016-03-22 01:39:12.909169226 +0800
+++ b/tmux-2.1/screen-write.c	2016-03-22 01:39:57.147655122 +0800
@@ -18,8 +18,11 @@
 
 #include <sys/types.h>
 
+#include <assert.h>
+#include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "tmux.h"
 
@@ -488,8 +491,20 @@
 			s->cy--;
 			s->cx = screen_size_x(s) - 1;
 		}
-	} else
-		s->cx--;
+	} else {
+		struct termios tio;
+		int fd = open(ctx->wp->tty, O_RDONLY);
+		assert(tcgetattr(fd, &tio) == 0);
+		close(fd);
+		if (tio.c_lflag & ICANON && tio.c_iflag & IUTF8) {
+			gl = &s->grid->linedata[s->grid->hsize + s->cy];
+			if (s->cx >= 2 && s->cx-2 < gl->cellsize && grid_cell_width(&gl->celldata[s->cx-2]) == 2)
+				s->cx -= 2;
+			else
+				s->cx--;
+		} else
+				s->cx--;
+	}
 }
 
 /* VT100 alignment test. */
--- a/tmux-2.1/utf8.c	2016-03-24 00:05:38.096784610 +0800
+++ b/tmux-2.1/utf8.c	2016-03-24 00:07:48.045489630 +0800
@@ -193,6 +193,10 @@
 	{ 0x02060, 0x02063, 0, NULL, NULL },
 	{ 0x00c3e, 0x00c40, 0, NULL, NULL },
 	{ 0x10a05, 0x10a06, 0, NULL, NULL },
+
+	{ 0x025a0, 0x027c0, 2, NULL, NULL },
+	{ 0x02b00, 0x02c00, 2, NULL, NULL },
+	{ 0x1f300, 0x1f700, 2, NULL, NULL },
 };
 
 struct utf8_width_entry	*utf8_width_root = NULL;