[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26734] trunk/blender/source/blender: Bugfix #21041: pressing tab, adds spaces depending on the end of the line

Joshua Leung aligorith at gmail.com
Tue Feb 9 12:18:17 CET 2010


Revision: 26734
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26734
Author:   aligorith
Date:     2010-02-09 12:18:17 +0100 (Tue, 09 Feb 2010)

Log Message:
-----------
Bugfix #21041: pressing tab, adds spaces depending on the end of the line

The code used to calculate the number of spaces to insert for a tab (so that indention widths were aligned to multiples of the number of spaces to use) was incorrectly assuming that the line that this was to occur on was blank, using text->curl->len (i.e. the length of the current line). 

The code now uses the position of the cursor to determine how many spaces need to be added to it to move it to the next multiple of the tab width.

---

Also, added numpad enter to text-editor keymap for creating new lines for more consistency with user expectations.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/text.c
    trunk/blender/source/blender/editors/space_text/space_text.c

Modified: trunk/blender/source/blender/blenkernel/intern/text.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/text.c	2010-02-09 11:01:31 UTC (rev 26733)
+++ trunk/blender/source/blender/blenkernel/intern/text.c	2010-02-09 11:18:17 UTC (rev 26734)
@@ -2370,7 +2370,11 @@
 
 static void txt_convert_tab_to_spaces (Text *text)
 {
-	char *sb = &tab_to_spaces[text->curl->len % TXT_TABSIZE];
+	/* sb aims to pad adjust the tab-width needed so that the right number of spaces
+	 * is added so that the indention of the line is the right width (i.e. aligned
+	 * to multiples of TXT_TABSIZE)
+	 */
+	char *sb = &tab_to_spaces[text->curc % TXT_TABSIZE];
 	txt_insert_buf(text, sb);
 }
 

Modified: trunk/blender/source/blender/editors/space_text/space_text.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/space_text.c	2010-02-09 11:01:31 UTC (rev 26733)
+++ trunk/blender/source/blender/editors/space_text/space_text.c	2010-02-09 11:18:17 UTC (rev 26734)
@@ -311,6 +311,7 @@
 	RNA_int_set(WM_keymap_add_item(keymap, "TEXT_OT_scroll", WHEELDOWNMOUSE, KM_PRESS, 0, 0)->ptr, "lines", 1);
 
 	WM_keymap_add_item(keymap, "TEXT_OT_line_break", RETKEY, KM_PRESS, 0, 0);
+	WM_keymap_add_item(keymap, "TEXT_OT_line_break", PADENTER, KM_PRESS, 0, 0);
 
 	WM_keymap_add_item(keymap, "TEXT_OT_line_number", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
 	WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last!





More information about the Bf-blender-cvs mailing list