diff options
-rw-r--r-- | release/scripts/modules/console_python.py | 11 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/console.py | 12 | ||||
-rw-r--r-- | source/blender/editors/space_console/space_console.c | 6 |
3 files changed, 20 insertions, 9 deletions
diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py index 54782aa9419..66956899076 100644 --- a/release/scripts/modules/console_python.py +++ b/release/scripts/modules/console_python.py @@ -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 = "" diff --git a/release/scripts/startup/bl_operators/console.py b/release/scripts/startup/bl_operators/console.py index 2670a762cb5..4e99acd4f36 100644 --- a/release/scripts/startup/bl_operators/console.py +++ b/release/scripts/startup/bl_operators/console.py @@ -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) diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index ace39f8d669..81211e7bfef 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -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 */ |