summaryrefslogtreecommitdiffstats
path: root/chinese/irssi/files/patch-src_fe-text_window.c
blob: 5e4ec9c6bc975e499a214ca50a36b58c61784000 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--- src/fe-text/gui-windows.c.orig	Sat Mar 17 07:55:50 2001
+++ src/fe-text/gui-windows.c	Sat Jan 26 19:40:34 2002
@@ -289,6 +289,7 @@
         unsigned char cmd;
 	char *ptr, *last_space_ptr;
 	int xpos, pos, indent_pos, last_space, last_color, color;
+	int w = 0;
 
 	g_return_val_if_fail(line->text != NULL, NULL);
 
@@ -343,14 +344,14 @@
 			continue;
 		}
 
-		if (xpos == COLS && sub != NULL &&
+		if (xpos >= COLS && sub != NULL &&
 		    (last_space <= indent_pos || last_space <= 10)) {
                         /* long word, remove the indentation from this line */
 			xpos -= sub->indent;
                         sub->indent = 0;
 		}
 
-		if (xpos == COLS) {
+		if (xpos >= COLS) {
 			xpos = indent_pos;
 
 			sub = g_new(LINE_CACHE_SUB_REC, 1);
@@ -376,8 +377,25 @@
 			continue;
 		}
 
-		xpos++;
-		if (*ptr++ == ' ') {
+		if(ptr[1] != '\0' && is_big5(ptr[0], ptr[1]))
+			w = 2;
+		else
+			w = 1;
+		
+		xpos+=w;
+		if (*ptr == ' ' ||
+		    (xpos <= COLS && w > 1)) {
+			last_space = xpos-1;
+			last_space_ptr = ptr + w;
+			last_color = color;
+		}
+		if(xpos <= COLS)
+			ptr += w;
+		
+		if(w == 1 && xpos <= COLS &&
+			(ptr[0] == ' ' ||
+			 (ptr[0] != '\0' && ptr[1] != '\0' && is_big5(ptr[0], ptr[1]))))
+		{
 			last_space = xpos-1;
 			last_space_ptr = ptr;
 			last_color = color;
@@ -525,6 +543,9 @@
 		next_pos = (n+1 < cache->count) ?
 			cache->lines[n].start : NULL;
 
+		if(next_pos != NULL && next_pos > pos && *(next_pos - 1) == ' ')
+			while(next_pos > pos && *(next_pos - 1) == ' ')
+				next_pos --;
 		single_line_draw(gui, ypos, sub, pos, next_pos);
 	}
 
OpenPOWER on IntegriCloud