UI: Add initial context menus for Info and Console editors

Both keymaps are also updated
This commit is contained in:
William Reynish 2019-08-10 11:35:16 +02:00
parent 77516c25e4
commit 41f8f08e51
4 changed files with 47 additions and 1 deletions

View File

@ -1736,6 +1736,7 @@ def km_info(params):
("info.report_delete", {"type": 'X', "value": 'PRESS'}, None),
("info.report_delete", {"type": 'DEL', "value": 'PRESS'}, None),
("info.report_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
op_menu("INFO_MT_context_menu", params.context_menu_event),
])
return keymap
@ -2449,7 +2450,7 @@ def km_sequencerpreview(params):
return keymap
def km_console(_params):
def km_console(params):
items = []
keymap = (
"Console",
@ -2509,6 +2510,7 @@ def km_console(_params):
("console.indent", {"type": 'TAB', "value": 'PRESS'}, None),
("console.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None),
("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
op_menu("CONSOLE_MT_context_menu", params.context_menu_event),
])
return keymap

View File

@ -1136,6 +1136,7 @@ def km_info(params):
("info.report_delete", {"type": 'BACK_SPACE', "value": 'PRESS'}, None),
("info.report_delete", {"type": 'DEL', "value": 'PRESS'}, None),
("info.report_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
op_menu("INFO_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
])
return keymap
@ -1859,6 +1860,7 @@ def km_console(params):
("console.indent", {"type": 'TAB', "value": 'PRESS'}, None),
("console.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None),
("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
op_menu("CONSOLE_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
])
return keymap

View File

@ -125,6 +125,37 @@ class CONSOLE_MT_console(Menu):
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"):
@ -137,6 +168,7 @@ classes = (
CONSOLE_MT_view,
CONSOLE_MT_language,
CONSOLE_MT_console,
CONSOLE_MT_context_menu,
)
if __name__ == "__main__": # only for live edit.

View File

@ -104,12 +104,22 @@ class INFO_MT_area(Menu):
).use_hide_panels = True
class INFO_MT_context_menu(Menu):
bl_label = "Info Context Menu"
def draw(self, context):
layout = self.layout
layout.operator("info.report_copy", text="Copy")
layout.operator("info.report_delete", text="Delete")
classes = (
INFO_HT_header,
INFO_MT_editor_menus,
INFO_MT_area,
INFO_MT_view,
INFO_MT_info,
INFO_MT_context_menu,
)
if __name__ == "__main__": # only for live edit.