Cleanup: spelling
[blender.git] / release / scripts / startup / bl_ui / space_console.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu
22
23
24 class CONSOLE_HT_header(Header):
25     bl_space_type = 'CONSOLE'
26
27     def draw(self, context):
28         layout = self.layout.row()
29
30         layout.template_header()
31
32         CONSOLE_MT_editor_menus.draw_collapsible(context, layout)
33
34
35 class CONSOLE_MT_editor_menus(Menu):
36     bl_idname = "CONSOLE_MT_editor_menus"
37     bl_label = ""
38
39     def draw(self, _context):
40         layout = self.layout
41         layout.menu("CONSOLE_MT_view")
42         layout.menu("CONSOLE_MT_console")
43
44
45 class CONSOLE_MT_view(Menu):
46     bl_label = "View"
47
48     def draw(self, _context):
49         layout = self.layout
50
51         props = layout.operator("wm.context_cycle_int", text="Zoom In")
52         props.data_path = 'space_data.font_size'
53         props.reverse = False
54         props = layout.operator("wm.context_cycle_int", text="Zoom Out")
55         props.data_path = 'space_data.font_size'
56         props.reverse = True
57
58         layout.separator()
59
60         layout.operator("console.move", text="Move to Previous Word").type = 'PREVIOUS_WORD'
61         layout.operator("console.move", text="Move to Next Word").type = 'NEXT_WORD'
62         layout.operator("console.move", text="Move to Line Begin").type = 'LINE_BEGIN'
63         layout.operator("console.move", text="Move to Line End").type = 'LINE_END'
64
65         layout.separator()
66
67         layout.menu("CONSOLE_MT_language")
68
69         layout.separator()
70
71         layout.menu("INFO_MT_area")
72
73
74 class CONSOLE_MT_language(Menu):
75     bl_label = "Languages..."
76
77     def draw(self, _context):
78         import sys
79
80         layout = self.layout
81         layout.column()
82
83         # Collect modules with 'console_*.execute'
84         languages = []
85         for modname, mod in sys.modules.items():
86             if modname.startswith("console_") and hasattr(mod, "execute"):
87                 languages.append(modname.split("_", 1)[-1])
88
89         languages.sort()
90
91         for language in languages:
92             layout.operator("console.language",
93                             text=language.title(),
94                             translate=False).language = language
95
96
97 class CONSOLE_MT_console(Menu):
98     bl_label = "Console"
99
100     def draw(self, _context):
101         layout = self.layout
102
103         layout.operator("console.clear")
104         layout.operator("console.clear_line")
105         layout.operator("console.delete", text="Delete Previous Word").type = 'PREVIOUS_WORD'
106         layout.operator("console.delete", text="Delete Next Word").type = 'NEXT_WORD'
107
108         layout.separator()
109
110         layout.operator("console.copy_as_script", text="Copy as Script")
111         layout.operator("console.copy", text="Copy")
112         layout.operator("console.paste", text="Paste")
113
114         layout.separator()
115
116         layout.operator("console.indent")
117         layout.operator("console.unindent")
118
119         layout.separator()
120
121         layout.operator("console.history_cycle", text="Backward in History").reverse = True
122         layout.operator("console.history_cycle", text="Forward in History").reverse = False
123
124         layout.separator()
125
126         layout.operator("console.autocomplete", text="Autocomplete")
127
128
129 class CONSOLE_MT_context_menu(Menu):
130     bl_label = "Console Context Menu"
131
132     def draw(self, _context):
133         layout = self.layout
134
135         layout.operator("console.clear")
136         layout.operator("console.clear_line")
137         layout.operator("console.delete", text="Delete Previous Word").type = 'PREVIOUS_WORD'
138         layout.operator("console.delete", text="Delete Next Word").type = 'NEXT_WORD'
139
140         layout.separator()
141
142         layout.operator("console.copy_as_script", text="Copy as Script")
143         layout.operator("console.copy", text="Copy")
144         layout.operator("console.paste", text="Paste")
145
146         layout.separator()
147
148         layout.operator("console.indent")
149         layout.operator("console.unindent")
150
151         layout.separator()
152
153         layout.operator("console.history_cycle", text="Backward in History").reverse = True
154         layout.operator("console.history_cycle", text="Forward in History").reverse = False
155
156         layout.separator()
157
158         layout.operator("console.autocomplete", text="Autocomplete")
159
160
161 def add_scrollback(text, text_type):
162     for l in text.split("\n"):
163         bpy.ops.console.scrollback_append(text=l.expandtabs(4), type=text_type)
164
165
166 classes = (
167     CONSOLE_HT_header,
168     CONSOLE_MT_editor_menus,
169     CONSOLE_MT_view,
170     CONSOLE_MT_language,
171     CONSOLE_MT_console,
172     CONSOLE_MT_context_menu,
173 )
174
175 if __name__ == "__main__":  # only for live edit.
176     from bpy.utils import register_class
177     for cls in classes:
178         register_class(cls)