[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36236] trunk/blender/source/blender/ blenkernel: Fix #27014: ctrl-A, ctrl-C, ctrl-V breaks formatting of script
Sergey Sharybin
g.ulairi at gmail.com
Wed Apr 20 09:44:42 CEST 2011
Revision: 36236
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36236
Author: nazgul
Date: 2011-04-20 07:44:42 +0000 (Wed, 20 Apr 2011)
Log Message:
-----------
Fix #27014: ctrl-A, ctrl-C, ctrl-V breaks formatting of script
This bug was caused by tabs->spaces conversion. Change pate-ing logic to
paste buffer AS-IS (without any conversions).
This commit also fixes undo-ing block deletion which contains tabs when
"Tabs as spaces" is toggled on. Also, markes shouldn't be moved after
pasteing new buffer.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_text.h
trunk/blender/source/blender/blenkernel/intern/text.c
Modified: trunk/blender/source/blender/blenkernel/BKE_text.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_text.h 2011-04-20 06:47:16 UTC (rev 36235)
+++ trunk/blender/source/blender/blenkernel/BKE_text.h 2011-04-20 07:44:42 UTC (rev 36236)
@@ -89,6 +89,7 @@
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);
Modified: trunk/blender/source/blender/blenkernel/intern/text.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/text.c 2011-04-20 06:47:16 UTC (rev 36235)
+++ trunk/blender/source/blender/blenkernel/intern/text.c 2011-04-20 07:44:42 UTC (rev 36236)
@@ -1348,9 +1348,19 @@
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 @@
/* 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 @@
/* 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 @@
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 @@
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 @@
}
/* 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 @@
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);
More information about the Bf-blender-cvs
mailing list