1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# SPDX-License-Identifier: GPL-2.0-or-later
# <pep8 compliant>
import bpy
from bpy.types import Header, Menu
class CONSOLE_HT_header(Header):
bl_space_type = 'CONSOLE'
def draw(self, context):
layout = self.layout.row()
layout.template_header()
CONSOLE_MT_editor_menus.draw_collapsible(context, layout)
class CONSOLE_MT_editor_menus(Menu):
bl_idname = "CONSOLE_MT_editor_menus"
bl_label = ""
def draw(self, _context):
layout = self.layout
layout.menu("CONSOLE_MT_view")
layout.menu("CONSOLE_MT_console")
class CONSOLE_MT_view(Menu):
bl_label = "View"
def draw(self, _context):
layout = self.layout
props = layout.operator("wm.context_cycle_int", text="Zoom In")
props.data_path = 'space_data.font_size'
props.reverse = False
props = layout.operator("wm.context_cycle_int", text="Zoom Out")
props.data_path = 'space_data.font_size'
props.reverse = True
layout.separator()
layout.operator("console.move", text="Move to Previous Word").type = 'PREVIOUS_WORD'
layout.operator("console.move", text="Move to Next Word").type = 'NEXT_WORD'
layout.operator("console.move", text="Move to Line Begin").type = 'LINE_BEGIN'
layout.operator("console.move", text="Move to Line End").type = 'LINE_END'
layout.separator()
layout.menu("CONSOLE_MT_language")
layout.separator()
layout.menu("INFO_MT_area")
class CONSOLE_MT_language(Menu):
bl_label = "Languages..."
def draw(self, _context):
import sys
layout = self.layout
layout.column()
# Collect modules with 'console_*.execute'
languages = []
for modname, mod in sys.modules.items():
if modname.startswith("console_") and hasattr(mod, "execute"):
languages.append(modname.split("_", 1)[-1])
languages.sort()
for language in languages:
layout.operator("console.language",
text=language.title(),
translate=False).language = language
class CONSOLE_MT_console(Menu):
bl_label = "Console"
def draw(self, _context):
layout = self.layout
layout.operator("console.clear")
layout.operator("console.clear_line")
layout.operator("console.delete", text="Delete Previous Word").type = 'PREVIOUS_WORD'
layout.operator("console.delete", text="Delete Next Word").type = 'NEXT_WORD'
layout.separator()
layout.operator("console.copy_as_script", text="Copy as Script")
layout.operator("console.copy", text="Copy")
layout.operator("console.paste", text="Paste")
layout.separator()
layout.operator("console.indent")
layout.operator("console.unindent")
layout.separator()
layout.operator("console.history_cycle", text="Backward in History").reverse = True
layout.operator("console.history_cycle", text="Forward in History").reverse = False
layout.separator()
layout.operator("console.autocomplete", text="Autocomplete")
class CONSOLE_MT_context_menu(Menu):
bl_label = "Console Context Menu"
def draw(self, _context):
layout = self.layout
layout.operator("console.clear")
layout.operator("console.clear_line")
layout.operator("console.delete", text="Delete Previous Word").type = 'PREVIOUS_WORD'
layout.operator("console.delete", text="Delete Next Word").type = 'NEXT_WORD'
layout.separator()
layout.operator("console.copy_as_script", text="Copy as Script")
layout.operator("console.copy", text="Copy")
layout.operator("console.paste", text="Paste")
layout.separator()
layout.operator("console.indent")
layout.operator("console.unindent")
layout.separator()
layout.operator("console.history_cycle", text="Backward in History").reverse = True
layout.operator("console.history_cycle", text="Forward in History").reverse = False
layout.separator()
layout.operator("console.autocomplete", text="Autocomplete")
def add_scrollback(text, text_type):
for l in text.split("\n"):
bpy.ops.console.scrollback_append(text=l.expandtabs(4), type=text_type)
classes = (
CONSOLE_HT_header,
CONSOLE_MT_editor_menus,
CONSOLE_MT_view,
CONSOLE_MT_language,
CONSOLE_MT_console,
CONSOLE_MT_context_menu,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)
|