forked from bartvdbraak/blender
disable auto indent when pasting text into the python console.
This commit is contained in:
parent
ebe86abb46
commit
8e6ce736c4
@ -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 = ""
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user