disable auto indent when pasting text into the python console.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 24 May 2013 01:04:37 +0000 (01:04 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 24 May 2013 01:04:37 +0000 (01:04 +0000)
release/scripts/modules/console_python.py
release/scripts/startup/bl_operators/console.py
source/blender/editors/space_console/space_console.c

index 54782aa941902d968a142f272ce279cf07a2b48b..66956899076e36dc7e5c07ef2afe62a327a2f9b7 100644 (file)
@@ -126,7 +126,7 @@ PROMPT = '>>> '
 PROMPT_MULTI = '... '
 
 
-def execute(context):
+def execute(context, is_interactive):
     sc = context.space_data
 
     try:
@@ -190,9 +190,12 @@ def execute(context):
 
     if is_multiline:
         sc.prompt = PROMPT_MULTI
-        indent = line[:len(line) - len(line.lstrip())]
-        if line.rstrip().endswith(":"):
-            indent += "    "
+        if is_interactive:
+            indent = line[:len(line) - len(line.lstrip())]
+            if line.rstrip().endswith(":"):
+                indent += "    "
+        else:
+            indent = ""
     else:
         sc.prompt = PROMPT
         indent = ""
index 2670a762cb530f9244a265375f76ced54eb1c985..4e99acd4f36b29578916a991c89303cd6c6c05f5 100644 (file)
@@ -20,7 +20,9 @@
 
 import bpy
 from bpy.types import Operator
-from bpy.props import StringProperty
+from bpy.props import (BoolProperty,
+                       StringProperty,
+                       )
 
 
 def _lang_module_get(sc):
@@ -34,6 +36,10 @@ class ConsoleExec(Operator):
     bl_idname = "console.execute"
     bl_label = "Console Execute"
 
+    interactive = BoolProperty(
+            options={'SKIP_SAVE'},
+            )
+
     @classmethod
     def poll(cls, context):
         return (context.area and context.area.type == 'CONSOLE')
@@ -44,8 +50,8 @@ class ConsoleExec(Operator):
         module = _lang_module_get(sc)
         execute = getattr(module, "execute", None)
 
-        if execute:
-            return execute(context)
+        if execute is not None:
+            return execute(context, self.interactive)
         else:
             print("Error: bpy.ops.console.execute_%s - not found" %
                   sc.language)
index ace39f8d669d341c663118c063b13fe5bca3150f..81211e7bfefbc26628ae517742936695cead9d69 100644 (file)
@@ -319,8 +319,10 @@ static void console_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "CONSOLE_OT_clear_line", RETKEY, KM_PRESS, KM_SHIFT, 0);
 
 #ifdef WITH_PYTHON
-       WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */
-       WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0);
+       RNA_boolean_set(kmi->ptr, "interactive", true);
+       kmi = WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0);
+       RNA_boolean_set(kmi->ptr, "interactive", true);
        
        //WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", TABKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */
        WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */