-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetsurf.diff
150 lines (145 loc) · 4.46 KB
/
netsurf.diff
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
--- /mnt/git/object/c6e8947629338beb12f1875540d4bf17900fb5cf/tree/frontends/plan9/drawui/entry.c
+++ frontends/plan9/drawui/entry.c
@@ -124,10 +124,11 @@
if (entry->pos != entry->pos2) {
sels = min(entry->pos, entry->pos2);
sele = max(entry->pos, entry->pos2);
- p.x += stringnwidth(font, entry->text, sels);
- stringnbg(screen, p, fg_color, ZP, font, entry->text+sels, sele-sels, sel_color, ZP);
+ p.x += stringnwidth(font, entry->text, utfnlen(entry->text, sels));
+ stringnbg(screen, p, fg_color, ZP, font, entry->text+sels,
+ utfnlen(entry->text + sels, sele-sels), sel_color, ZP);
} else if (entry->state & STATE_FOCUSED) {
- entry->tick_x = stringnwidth(font, entry->text, entry->pos);
+ entry->tick_x = stringnwidth(font, entry->text, utfnlen(entry->text, entry->pos));
p.x += entry->tick_x;
r = Rect(p.x, p.y, p.x + Dx(tick->r), p.y + Dy(tick->r));
draw(screen, r, tick, nil, ZP);
@@ -140,10 +141,10 @@
x = m.xy.x - entry->r.min.x - PADDING;
prev = 0;
- for (i = 0; i < entry->len; i++) {
- cur = stringnwidth(font, entry->text, i);
+ for (i = 0; i < entry->len; i = utf8_next(entry->text, entry->len, i)) {
+ cur = stringnwidth(font, entry->text, utfnlen(entry->text, i));
if ((prev+cur)/2 >= x) {
- i--;
+ i = utf8_prev(entry->text, i);
break;
} else if (prev <= x && cur >= x) {
break;
@@ -282,10 +283,11 @@
entry->text[entry->len] = 0;
break;
case Kleft:
- entry->pos = max(0, sels-1);
+ entry->pos = max(0, utf8_prev(entry->text, sels));
break;
case Kright:
- entry->pos = min(entry->len, sele+1);
+ if (sele < entry->len)
+ entry->pos = utf8_next(entry->text, entry->len, sele);
break;
case Ksoh: /* ^A: start of line */
case Khome:
@@ -371,6 +373,8 @@
sele = max(entry->pos, entry->pos2);
if(sels == sele && sels == 0)
return;
+ if (bs)
+ bs = sels - utf8_prev(entry->text, sels);
memmove(entry->text + sels - bs, entry->text + sele, entry->len - sele);
entry->pos = sels - bs;
entry->len -= sele - sels + bs;
--- /mnt/git/object/c6e8947629338beb12f1875540d4bf17900fb5cf/tree/frontends/plan9/layout.c
+++ frontends/plan9/layout.c
@@ -13,25 +13,25 @@
char *name;
Font *font;
} fontlist[4][4] = {
- "lucidasans/unicode.7", 0,
- "lucidasans/unicode.8", 0,
- "lucidasans/unicode.10", 0,
- "lucidasans/unicode.13", 0,
+ "Go-Regular/Go-Regular.14", 0,
+ "Go-Regular/Go-Regular.16", 0,
+ "Go-Regular/Go-Regular.18", 0,
+ "Go-Regular/Go-Regular.20", 0,
+
+ "Go-Italic/Go-Italic.14", 0,
+ "Go-Italic/Go-Italic.16", 0,
+ "Go-Italic/Go-Italic.18", 0,
+ "Go-Italic/Go-Italic.20", 0,
+
+ "Go-Bold/Go-Bold.14", 0,
+ "Go-Bold/Go-Bold.16", 0,
+ "Go-Bold/Go-Bold.18", 0,
+ "Go-Bold/Go-Bold.20", 0,
- "lucidasans/italicunicode.7", 0,
- "lucidasans/italicunicode.8", 0,
- "lucidasans/italicunicode.10", 0,
- "lucidasans/italicunicode.13", 0,
-
- "lucidasans/boldunicode.7", 0,
- "lucidasans/boldunicode.8", 0,
- "lucidasans/boldunicode.10", 0,
- "lucidasans/boldunicode.13", 0,
-
- "lucidasans/typeunicode.7", 0,
- "pelm/unicode.8", 0,
- "lucidasans/typeunicode.12", 0,
- "lucidasans/typeunicode.16", 0,
+ "Go-Mono/Go-Mono.14", 0,
+ "Go-Mono/Go-Mono.16", 0,
+ "Go-Mono/Go-Mono.18", 0,
+ "Go-Mono/Go-Mono.20", 0,
};
enum
@@ -136,26 +136,32 @@
uint32_t ucs4;
size_t nxtchr = 0;
int prev_x = 0;
-
+ if (length == 0 || x < 1) {
+ *char_offset = 0;
+ *actual_x = 0;
+ return NSERROR_OK;
+ }
f = getfont(fstyle);
- *actual_x = 0;
- while (nxtchr < length) {
- ucs4 = utf8_to_ucs4(s + nxtchr, length - nxtchr);
-
- *actual_x += runestringnwidth(f, &ucs4, 1);
- if (*actual_x > x)
- break;
-
- prev_x = *actual_x;
- nxtchr = utf8_next(s, length, nxtchr);
+ *actual_x = 0;
+ while (nxtchr < length) {
+ ucs4 = utf8_to_ucs4(s + nxtchr, length - nxtchr);
+ prev_x = *actual_x;
+ *actual_x += runestringnwidth(f, &ucs4, 1);
+ if (x >= prev_x && x < *actual_x) {
+ *actual_x = prev_x + 1;
+ *char_offset = nxtchr;
+ return NSERROR_OK;
}
-
+ nxtchr = utf8_next(s, length, nxtchr);
+ }
+ *char_offset = length;
+
/* choose nearest of previous and last x */
- if (abs(*actual_x - x) > abs(prev_x - x))
- *actual_x = prev_x;
-
- *char_offset = nxtchr;
- return NSERROR_OK;}
+ // if (abs(*actual_x - x) > abs(prev_x - x))
+ // *actual_x = prev_x;
+ // *char_offset = nxtchr;
+ return NSERROR_UNKNOWN;//OK;
+}
/**