- Timestamp:
- Sep 30, 2010, 8:07:17 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- 385cce2
- Parents:
- 9c3f334
- git-author:
- David Benjamin <davidben@mit.edu> (09/29/10 15:41:28)
- git-committer:
- David Benjamin <davidben@mit.edu> (09/30/10 20:07:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
editwin.c
r9c3f334 rac6d4e4 27 27 int goal_column; 28 28 int topindex; 29 int column; 29 30 int winlines, wincols, fillcol, wrapcol; 30 31 owl_window *win; … … 50 51 static void oe_restore_mark_only(owl_editwin *e, oe_excursion *x); 51 52 static int oe_char_width(gunichar c, int column); 52 static int oe_region_width(owl_editwin *e, int start, int end, int width); 53 static int oe_region_column(owl_editwin *e, int start, int end, int offset); 54 static int oe_region_width(owl_editwin *e, int start, int end, int offset); 53 55 static int oe_find_display_line(owl_editwin *e, int *x, int index, int *hard); 54 56 static void oe_insert_char(owl_editwin *e, gunichar c); … … 100 102 if (index != e->index) { 101 103 e->goal_column = -1; 104 e->column = -1; 102 105 } 103 106 e->index = index; … … 133 136 e->killbuf = NULL; 134 137 e->goal_column = -1; 138 e->column = -1; 135 139 e->topindex = 0; 136 140 e->excursions = NULL; … … 646 650 static int owl_editwin_replace_internal(owl_editwin *e, int replace, const char *s) 647 651 { 648 int start, end, free, need, size, change ;652 int start, end, free, need, size, change, oldindex; 649 653 oe_excursion *x; 650 654 … … 665 669 change = start - end + strlen(s); 666 670 e->bufflen += change; 671 oldindex = e->index; 667 672 e->index += strlen(s); 673 if (e->column != -1) 674 e->column = oe_region_column(e, oldindex, e->index, e->column); 668 675 669 676 /* fix up the mark */ … … 1146 1153 int owl_editwin_current_column(owl_editwin *e) 1147 1154 { 1148 oe_excursion x; 1149 int lineindex; 1150 1151 oe_save_excursion(e, &x); 1152 owl_editwin_move_to_beginning_of_line(e); 1153 lineindex = e->index; 1154 oe_restore_excursion(e, &x); 1155 return oe_region_width(e, lineindex, e->index, 0); 1155 if (e->column == -1) { 1156 oe_excursion x; 1157 int lineindex; 1158 1159 oe_save_excursion(e, &x); 1160 owl_editwin_move_to_beginning_of_line(e); 1161 lineindex = e->index; 1162 oe_restore_excursion(e, &x); 1163 e->column = oe_region_width(e, lineindex, e->index, 0); 1164 } 1165 return e->column; 1156 1166 } 1157 1167 … … 1272 1282 return; 1273 1283 } 1284 } 1285 1286 static int oe_region_column(owl_editwin *e, int start, int end, int offset) 1287 { 1288 const char *p; 1289 int column = offset; 1290 1291 for(p = e->buff + start; 1292 p < e->buff + end; 1293 p = g_utf8_find_next_char(p, NULL)) { 1294 gunichar c = g_utf8_get_char(p); 1295 if (c == '\n') 1296 column = 0; 1297 else 1298 column += oe_char_width(c, column); 1299 } 1300 return column; 1274 1301 } 1275 1302
Note: See TracChangeset
for help on using the changeset viewer.