• R/O
  • SSH
  • HTTPS

bchan: 提交


Commit MetaInfo

修訂582 (tree)
時間2013-11-17 21:38:44
作者ornse01

Log Message

add charactor position caluculate.

Change Summary

差異

--- bchank/trunk/src/bchank_lines.c (revision 581)
+++ bchank/trunk/src/bchank_lines.c (revision 582)
@@ -161,6 +161,30 @@
161161 return list->len;
162162 }
163163
164+LOCAL W bchank_linelist_calclinewidth_stw(bchank_line_t *line, GID target, W prev_x, TC *str, W str_len)
165+{
166+ W *new_pos;
167+ W i, err;
168+
169+ new_pos = realloc(line->pos, (line->pos_len + str_len)*sizeof(W));
170+ if (new_pos == NULL) {
171+ return -1;
172+ }
173+ line->pos = new_pos;
174+
175+ err = gget_stw(target, str, str_len, NULL, new_pos + line->pos_len);
176+ if (err < 0) {
177+ return -1;
178+ }
179+
180+ for (i = 0; i < str_len; i++) {
181+ new_pos[line->pos_len + i] += prev_x;
182+ }
183+ line->pos_len += str_len;
184+
185+ return err;
186+}
187+
164188 EXPORT W bchank_linelist_calclinewidth(bchank_linelist_t *list, bchank_line_t *line, GID target)
165189 {
166190 taditerator_t iterator;
@@ -180,7 +204,7 @@
180204 taditerator_next2(&iterator, &result);
181205 if (result.type == TADITERATOR_RESULTTYPE_END) {
182206 if (start != NULL) {
183- w += gget_stw(target, start, len, NULL, NULL);
207+ w += bchank_linelist_calclinewidth_stw(line, target, w, start, len);
184208 start = NULL;
185209 len = 0;
186210 }
@@ -192,7 +216,7 @@
192216 len++;
193217 } else if (result.type == TADITERATOR_RESULTTYPE_SEGMENT) {
194218 if (start != NULL) {
195- w += gget_stw(target, start, len, NULL, NULL);
219+ w += bchank_linelist_calclinewidth_stw(line, target, w, start, len);
196220 start = NULL;
197221 len = 0;
198222 }
Show on old repository browser