[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26007] trunk/blender: Text Editor: Add an option "Tabs as Spaces".

Dalai Felinto dfelinto at gmail.com
Thu Jan 14 22:30:51 CET 2010


Revision: 26007
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26007
Author:   dfelinto
Date:     2010-01-14 22:30:51 +0100 (Thu, 14 Jan 2010)

Log Message:
-----------
Text Editor: Add an option "Tabs as Spaces".
So now tab is not ALWAYS converted to spaces.
This is stored by text datablock (what allows to do nice things in the future, as automatic check for the indentation type of the file).

Ideally we should redraw the other Text Editor windows after changing that (in case the same file is opened and the Property panel is also open). Not sure how to do that though.

I'm using TABSTOSPACES as the DEFINE flag because TABSASSPACES sounds too ugly.

(also fix for interface divisor bug)

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_text.py
    trunk/blender/source/blender/blenkernel/intern/text.c
    trunk/blender/source/blender/editors/interface/interface_widgets.c
    trunk/blender/source/blender/makesdna/DNA_text_types.h
    trunk/blender/source/blender/makesrna/intern/rna_text.c

Modified: trunk/blender/release/scripts/ui/space_text.py
===================================================================
--- trunk/blender/release/scripts/ui/space_text.py	2010-01-14 20:48:25 UTC (rev 26006)
+++ trunk/blender/release/scripts/ui/space_text.py	2010-01-14 21:30:51 UTC (rev 26007)
@@ -78,6 +78,7 @@
         layout = self.layout
 
         st = context.space_data
+        text = st.text
 
         flow = layout.column_flow()
         flow.prop(st, "line_numbers")
@@ -88,6 +89,7 @@
         flow = layout.column_flow()
         flow.prop(st, "font_size")
         flow.prop(st, "tab_width")
+        flow.prop(text, "tabs_as_spaces")
 
 
 class TEXT_PT_find(bpy.types.Panel):

Modified: trunk/blender/source/blender/blenkernel/intern/text.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/text.c	2010-01-14 20:48:25 UTC (rev 26006)
+++ trunk/blender/source/blender/blenkernel/intern/text.c	2010-01-14 21:30:51 UTC (rev 26007)
@@ -2380,7 +2380,7 @@
 	}
 	
 	/* insert spaces rather then tabs */
-	if (add == '\t') {
+	if (add == '\t' && text->flags & TXT_TABSTOSPACES) {
 		txt_convert_tab_to_spaces(text);
 		return 1;
 	}

Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c	2010-01-14 20:48:25 UTC (rev 26006)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c	2010-01-14 21:30:51 UTC (rev 26007)
@@ -1800,7 +1800,7 @@
 static void ui_draw_separator(uiBut *but, rcti *rect,  uiWidgetColors *wcol)
 {
 	int y = rect->ymin + (rect->ymax - rect->ymin)/2 - 1;
-	unsigned char col[3];
+	unsigned char col[4];
 	
 	col[0] = wcol->text[0];
 	col[1] = wcol->text[1];

Modified: trunk/blender/source/blender/makesdna/DNA_text_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_text_types.h	2010-01-14 20:48:25 UTC (rev 26006)
+++ trunk/blender/source/blender/makesdna/DNA_text_types.h	2010-01-14 21:30:51 UTC (rev 26007)
@@ -84,6 +84,7 @@
 #define TXT_ISSCRIPT            0x0010 /* used by space handler scriptlinks */
 #define TXT_READONLY            0x0100
 #define TXT_FOLLOW              0x0200 /* always follow cursor (console) */
+#define TXT_TABSTOSPACES        0x0400 /* use space instead of tabs */
 
 /* format continuation flags */
 #define TXT_NOCONT				0x00 /* no continuation */

Modified: trunk/blender/source/blender/makesrna/intern/rna_text.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_text.c	2010-01-14 20:48:25 UTC (rev 26006)
+++ trunk/blender/source/blender/makesrna/intern/rna_text.c	2010-01-14 21:30:51 UTC (rev 26007)
@@ -198,6 +198,10 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_ISSCRIPT);
 	RNA_def_property_ui_text(prop, "Register", "Register this text as a module on loading.");
 
+	prop= RNA_def_property(srna, "tabs_as_spaces", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flags", TXT_TABSTOSPACES);
+	RNA_def_property_ui_text(prop, "Tabs as Spaces", "Automatically converts all new tabs into spaces.");
+
 	prop= RNA_def_property(srna, "lines", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_struct_type(prop, "TextLine");
 	RNA_def_property_ui_text(prop, "Lines", "Lines of text.");





More information about the Bf-blender-cvs mailing list