diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_text.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 44 |
2 files changed, 39 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index a6b98b8ea88..136ce416037 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -89,6 +89,7 @@ void txt_split_curline (struct Text *text); void txt_backspace_char (struct Text *text); void txt_backspace_word (struct Text *text); int txt_add_char (struct Text *text, char add); +int txt_add_raw_char (struct Text *text, char add); int txt_replace_char (struct Text *text, char add); void txt_export_to_object (struct Text *text); void txt_export_to_objects(struct Text *text); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index e7b85ec9b17..5a8106b23e3 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1348,9 +1348,19 @@ char *txt_sel_to_buf (Text *text) return buf; } +static void txt_shift_markers(Text *text, int lineno, int count) +{ + TextMarker *marker; + + for (marker=text->markers.first; marker; marker= marker->next) + if (marker->lineno>=lineno) { + marker->lineno+= count; + } +} + void txt_insert_buf(Text *text, const char *in_buffer) { - int i=0, l=0, j, u, len; + int i=0, l=0, j, u, len, lineno= -1, count= 0; TextLine *add; if (!text) return; @@ -1365,7 +1375,7 @@ void txt_insert_buf(Text *text, const char *in_buffer) /* Read the first line (or as close as possible */ while (in_buffer[i] && in_buffer[i]!='\n') { - txt_add_char(text, in_buffer[i]); + txt_add_raw_char(text, in_buffer[i]); i++; } @@ -1375,6 +1385,7 @@ void txt_insert_buf(Text *text, const char *in_buffer) /* Read as many full lines as we can */ len= strlen(in_buffer); + lineno= txt_get_span(text->lines.first, text->curl); while (i<len) { l=0; @@ -1387,14 +1398,25 @@ void txt_insert_buf(Text *text, const char *in_buffer) add= txt_new_linen(in_buffer +(i-l), l); BLI_insertlinkbefore(&text->lines, text->curl, add); i++; + count++; } else { + if(count) { + txt_shift_markers(text, lineno, count); + count= 0; + } + for (j= i-l; j<i && j<(int)strlen(in_buffer); j++) { - txt_add_char(text, in_buffer[j]); + txt_add_raw_char(text, in_buffer[j]); } break; } } - + + if(count) { + txt_shift_markers(text, lineno, count); + count= 0; + } + undoing= u; } @@ -2375,7 +2397,7 @@ static void txt_convert_tab_to_spaces (Text *text) txt_insert_buf(text, sb); } -int txt_add_char (Text *text, char add) +static int txt_add_char_intern (Text *text, char add, int replace_tabs) { int len, lineno; char *tmp; @@ -2390,7 +2412,7 @@ int txt_add_char (Text *text, char add) } /* insert spaces rather then tabs */ - if (add == '\t' && text->flags & TXT_TABSTOSPACES) { + if (add == '\t' && replace_tabs) { txt_convert_tab_to_spaces(text); return 1; } @@ -2428,6 +2450,16 @@ int txt_add_char (Text *text, char add) return 1; } +int txt_add_char (Text *text, char add) +{ + return txt_add_char_intern(text, add, text->flags & TXT_TABSTOSPACES); +} + +int txt_add_raw_char (Text *text, char add) +{ + return txt_add_char_intern(text, add, 0); +} + void txt_delete_selected(Text *text) { txt_delete_sel(text); |