Changeset 16cfd12a
- Timestamp:
- Jul 11, 2009, 1:14:35 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 7f0c26f
- Parents:
- 8321cb7
- git-author:
- Karl Ramm <kcr@1ts.org> (06/13/09 16:27:21)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (07/11/09 13:14:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
editwin.c
r8321cb7 r16cfd12a 12 12 int valid; 13 13 int index; 14 int mark; 14 15 int goal_column; 15 16 int lock; … … 23 24 int allocated; 24 25 int index; 26 int mark; 25 27 int goal_column; 26 28 int topindex; … … 46 48 static int oe_count_glyphs(char *s); 47 49 static int oe_char_width(gunichar c, int column); 50 static int oe_region_width(owl_editwin *e, int start, int end, int width); 48 51 static int oe_find_display_line(owl_editwin *e, int *x, int index); 49 52 static void oe_insert_char(owl_editwin *e, gunichar c); … … 98 101 e->allocated=INCR; 99 102 oe_set_index(e, 0); 103 e->mark = 0; 100 104 e->goal_column = -1; 101 105 e->cursorx = -1; … … 1046 1050 } 1047 1051 1052 static int oe_region_width(owl_editwin *e, int start, int end, int width) 1053 { 1054 char *p; 1055 for(p = e->buff + start; 1056 p < e->buff + end; 1057 p = g_utf8_find_next_char(p, NULL)) 1058 width += oe_char_width(g_utf8_get_char(p), width); 1059 1060 return width; 1061 } 1062 1048 1063 static void oe_insert_char(owl_editwin *e, gunichar c) 1049 1064 { 1065 oe_excursion x; 1050 1066 char tmp[7]; 1067 int replaced = -1; 1051 1068 1052 1069 if (c == '\r') /* translate CRs to NLs */ 1053 1070 c = '\n'; 1054 1071 1055 if (!g_unichar_iscntrl(c) || c == '\n' || c== '\ n' ) {1072 if (!g_unichar_iscntrl(c) || c == '\n' || c== '\t' ) { 1056 1073 memset(tmp, 0, 7); 1057 1074 … … 1059 1076 return; 1060 1077 } 1078 1079 if (e->cursorx != -1 && e->cursorx + oe_char_width(c, e->cursorx) > e->wrapcol) { 1080 /* XXX this is actually wrong: 1081 * + If the line has been been wrapped, we can be past the wrap column but 1082 * e->cursorx be much smaller. 1083 * + If the user went back and inserted a bunch of stuff in the middle of 1084 * the line, there may be more than one word past the wrap column. 1085 */ 1086 oe_save_excursion(e, &x); 1087 1088 if (c == ' ' || c == '\t') { 1089 owl_editwin_point_move(e, -1); 1090 replaced = -owl_editwin_move_if_in(e, -1, " \t"); 1091 if (!replaced) { 1092 c = '\n'; 1093 replaced = -1; 1094 } 1095 } else { 1096 while(!owl_editwin_at_beginning_of_line(e)) { 1097 owl_editwin_point_move(e, -1); 1098 if (owl_util_can_break_after(owl_editwin_get_char_at_point(e))) { 1099 replaced = -owl_editwin_move_if_in(e, -1, " \t"); 1100 break; 1101 } 1102 } 1103 if (owl_editwin_at_beginning_of_line(e)) 1104 replaced = -1; 1105 } 1106 if (replaced && !owl_editwin_at_beginning_of_line(e)) 1107 owl_editwin_point_move(e, 1); 1108 if (replaced >= 0) { 1109 owl_editwin_replace(e, replaced, "\n"); 1110 } 1111 1112 oe_restore_excursion(e, &x); 1113 } 1114 1115 if (replaced >= 0 && (c == ' ' || c == '\t')) 1116 return; /* our work here is done */ 1061 1117 1062 1118 g_unichar_to_utf8(c, tmp);
Note: See TracChangeset
for help on using the changeset viewer.