[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56558] trunk/blender/release/scripts/ modules/console_python.py: auto indent for multi-line python statements.

Campbell Barton ideasman42 at gmail.com
Wed May 8 14:57:00 CEST 2013


Revision: 56558
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56558
Author:   campbellbarton
Date:     2013-05-08 12:57:00 +0000 (Wed, 08 May 2013)
Log Message:
-----------
auto indent for multi-line python statements.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/console_python.py

Modified: trunk/blender/release/scripts/modules/console_python.py
===================================================================
--- trunk/blender/release/scripts/modules/console_python.py	2013-05-08 12:56:51 UTC (rev 56557)
+++ trunk/blender/release/scripts/modules/console_python.py	2013-05-08 12:57:00 UTC (rev 56558)
@@ -190,12 +190,17 @@
 
     if is_multiline:
         sc.prompt = PROMPT_MULTI
+        indent = line[:len(line) - len(line.lstrip())]
+        if line.rstrip().endswith(":"):
+            indent += "    "
     else:
         sc.prompt = PROMPT
+        indent = ""
 
     # insert a new blank line
-    bpy.ops.console.history_append(text="", current_character=0,
+    bpy.ops.console.history_append(text=indent, current_character=0,
                                    remove_duplicates=True)
+    sc.history[-1].current_character = len(indent)
 
     # Insert the output into the editor
     # not quite correct because the order might have changed,




More information about the Bf-blender-cvs mailing list