2023-08-16 00:20:26 +10:00
|
|
|
# SPDX-FileCopyrightText: 2009-2023 Blender Authors
|
2023-06-15 13:09:04 +10:00
|
|
|
#
|
2022-02-11 09:07:11 +11:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2023-06-15 13:09:04 +10:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
import bpy
|
2011-09-22 19:50:41 +00:00
|
|
|
from bpy.types import Header, Menu
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2009-10-29 20:55:45 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class CONSOLE_HT_header(Header):
|
2009-10-31 13:31:23 +00:00
|
|
|
bl_space_type = 'CONSOLE'
|
2009-10-29 20:55:45 +00:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
2023-04-13 18:06:12 +02:00
|
|
|
layout = self.layout
|
2011-08-13 17:52:13 +00:00
|
|
|
layout.template_header()
|
2009-10-29 20:55:45 +00:00
|
|
|
|
2014-01-27 18:38:53 +11:00
|
|
|
CONSOLE_MT_editor_menus.draw_collapsible(context, layout)
|
2009-10-29 20:55:45 +00:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2014-01-27 18:38:53 +11:00
|
|
|
class CONSOLE_MT_editor_menus(Menu):
|
|
|
|
|
bl_idname = "CONSOLE_MT_editor_menus"
|
|
|
|
|
bl_label = ""
|
|
|
|
|
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw(self, _context):
|
2018-12-20 12:02:21 +11:00
|
|
|
layout = self.layout
|
2019-08-09 19:05:15 +10:00
|
|
|
layout.menu("CONSOLE_MT_view")
|
2014-01-27 18:38:53 +11:00
|
|
|
layout.menu("CONSOLE_MT_console")
|
|
|
|
|
|
|
|
|
|
|
2019-08-09 19:05:15 +10:00
|
|
|
class CONSOLE_MT_view(Menu):
|
|
|
|
|
bl_label = "View"
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw(self, _context):
|
2009-10-29 20:55:45 +00:00
|
|
|
layout = self.layout
|
2011-08-22 09:01:49 +00:00
|
|
|
|
2019-08-09 19:05:15 +10:00
|
|
|
props = layout.operator("wm.context_cycle_int", text="Zoom In")
|
2023-01-06 13:52:57 +11:00
|
|
|
props.data_path = "space_data.font_size"
|
2019-08-09 19:05:15 +10:00
|
|
|
props.reverse = False
|
|
|
|
|
props = layout.operator("wm.context_cycle_int", text="Zoom Out")
|
2023-01-06 13:52:57 +11:00
|
|
|
props.data_path = "space_data.font_size"
|
2019-08-09 19:05:15 +10:00
|
|
|
props.reverse = True
|
2012-06-04 07:24:19 +00:00
|
|
|
|
|
|
|
|
layout.separator()
|
|
|
|
|
|
2019-08-09 19:05:15 +10:00
|
|
|
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'
|
2012-06-04 07:24:19 +00:00
|
|
|
|
|
|
|
|
layout.separator()
|
|
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.menu("CONSOLE_MT_language")
|
2009-12-04 17:54:48 +00:00
|
|
|
|
2009-12-03 16:28:50 +00:00
|
|
|
layout.separator()
|
2009-12-04 17:54:48 +00:00
|
|
|
|
2018-05-24 18:35:19 +02:00
|
|
|
layout.menu("INFO_MT_area")
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2009-12-04 17:54:48 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class CONSOLE_MT_language(Menu):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Languages..."
|
2009-11-06 23:53:40 +00:00
|
|
|
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw(self, _context):
|
2009-11-17 12:21:41 +00:00
|
|
|
import sys
|
2009-11-21 00:05:43 +00:00
|
|
|
|
2009-11-06 23:53:40 +00:00
|
|
|
layout = self.layout
|
|
|
|
|
layout.column()
|
2009-11-07 22:07:46 +00:00
|
|
|
|
2023-01-06 13:52:57 +11:00
|
|
|
# Collect modules with `console_*.execute`.
|
2009-11-06 23:53:40 +00:00
|
|
|
languages = []
|
2009-11-17 12:21:41 +00:00
|
|
|
for modname, mod in sys.modules.items():
|
|
|
|
|
if modname.startswith("console_") and hasattr(mod, "execute"):
|
2012-07-04 21:41:05 +00:00
|
|
|
languages.append(modname.split("_", 1)[-1])
|
2009-11-07 22:07:46 +00:00
|
|
|
|
2009-11-06 23:53:40 +00:00
|
|
|
languages.sort()
|
2009-11-07 22:07:46 +00:00
|
|
|
|
2009-11-06 23:53:40 +00:00
|
|
|
for language in languages:
|
2024-03-15 10:04:03 +11:00
|
|
|
layout.operator("console.language", text=language.title(), translate=False).language = language
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2009-11-14 13:35:44 +00:00
|
|
|
|
2019-08-09 19:05:15 +10:00
|
|
|
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")
|
2023-09-22 13:29:17 +10:00
|
|
|
layout.operator("console.copy", text="Cut").delete = True
|
2019-08-09 19:05:15 +10:00
|
|
|
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")
|
|
|
|
|
|
2019-09-10 06:11:52 +10:00
|
|
|
|
2019-08-10 11:35:16 +02:00
|
|
|
class CONSOLE_MT_context_menu(Menu):
|
2023-09-25 16:25:55 +02:00
|
|
|
bl_label = "Console"
|
2019-08-10 11:35:16 +02:00
|
|
|
|
2019-09-15 05:26:15 +10:00
|
|
|
def draw(self, _context):
|
2019-08-10 11:35:16 +02:00
|
|
|
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")
|
2023-09-22 13:29:17 +10:00
|
|
|
layout.operator("console.copy", text="Cut").delete = True
|
2019-08-10 11:35:16 +02:00
|
|
|
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")
|
|
|
|
|
|
2019-08-09 19:05:15 +10:00
|
|
|
|
2017-03-18 20:03:24 +11:00
|
|
|
classes = (
|
|
|
|
|
CONSOLE_HT_header,
|
|
|
|
|
CONSOLE_MT_editor_menus,
|
2019-08-09 19:05:15 +10:00
|
|
|
CONSOLE_MT_view,
|
2017-03-18 20:03:24 +11:00
|
|
|
CONSOLE_MT_language,
|
2019-08-09 19:05:15 +10:00
|
|
|
CONSOLE_MT_console,
|
2019-08-10 11:35:16 +02:00
|
|
|
CONSOLE_MT_context_menu,
|
2017-03-18 20:03:24 +11:00
|
|
|
)
|
|
|
|
|
|
2011-04-04 10:13:04 +00:00
|
|
|
if __name__ == "__main__": # only for live edit.
|
2017-03-18 20:03:24 +11:00
|
|
|
from bpy.utils import register_class
|
|
|
|
|
for cls in classes:
|
|
|
|
|
register_class(cls)
|