Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-11-22 12:50:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-11-22 12:53:40 +0300
commite98d27fd8d432650489f973abcdfad4163e87f42 (patch)
tree16c4515cc74341d2c409d2c997a58fbba4cf2f9d
parente93aa9c0fc669d0b09a1159e8ef1e2b9dfcc7320 (diff)
Keymap: use tab key for indent or auto-complete
Only indent when there aren't characters before the cursor. This resolves the conflict with Ctrl-Space for view maximize. D6239 by @wbrbr for text editor, based console support on this.
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/blender_default.py6
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py8
-rw-r--r--source/blender/editors/space_console/console_intern.h1
-rw-r--r--source/blender/editors/space_console/console_ops.c40
-rw-r--r--source/blender/editors/space_console/space_console.c1
-rw-r--r--source/blender/editors/space_text/space_text.c1
-rw-r--r--source/blender/editors/space_text/text_intern.h1
-rw-r--r--source/blender/editors/space_text/text_ops.c35
8 files changed, 84 insertions, 9 deletions
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 82ec7040564..abbc8ad103e 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -2225,7 +2225,7 @@ def km_text(params):
{"properties": [("direction", 'UP')]}),
("text.move_lines", {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("direction", 'DOWN')]}),
- ("text.indent", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("text.indent_or_autocomplete", {"type": 'TAB', "value": 'PRESS'}, None),
("text.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None),
("text.comment_toggle", {"type": 'SLASH', "value": 'PRESS', "ctrl": True}, None),
("text.move", {"type": 'HOME', "value": 'PRESS'},
@@ -2305,7 +2305,6 @@ def km_text(params):
{"properties": [("lines", 1)]}),
("text.line_break", {"type": 'RET', "value": 'PRESS'}, None),
("text.line_break", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None),
- ("text.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None),
("text.line_number", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
op_menu("TEXT_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
("text.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
@@ -2535,7 +2534,6 @@ def km_console(params):
{"properties": [("interactive", True)]}),
("console.execute", {"type": 'NUMPAD_ENTER', "value": 'PRESS'},
{"properties": [("interactive", True)]}),
- ("console.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None),
("console.copy_as_script", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None),
("console.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
("console.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
@@ -2543,7 +2541,7 @@ def km_console(params):
("console.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("console.insert", {"type": 'TAB', "value": 'PRESS', "ctrl": True},
{"properties": [("text", '\t')]}),
- ("console.indent", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("console.indent_or_autocomplete", {"type": 'TAB', "value": 'PRESS'}, None),
("console.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None),
op_menu("CONSOLE_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index 49a394b478d..2fa747b98ab 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -1587,7 +1587,7 @@ def km_text(params):
{"properties": [("direction", 'UP')]}),
("text.move_lines", {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("direction", 'DOWN')]}),
- ("text.indent", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("text.indent_or_autocomplete", {"type": 'TAB', "value": 'PRESS'}, None),
("text.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None),
("text.uncomment", {"type": 'D', "value": 'PRESS', "shift": True, "ctrl": True}, None),
("text.move", {"type": 'HOME', "value": 'PRESS'},
@@ -1668,7 +1668,6 @@ def km_text(params):
("text.line_break", {"type": 'RET', "value": 'PRESS'}, None),
("text.line_break", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None),
op_menu("TEXT_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}),
- ("text.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None),
("text.line_number", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
("text.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
])
@@ -1878,7 +1877,6 @@ def km_console(params):
{"properties": [("interactive", True)]}),
("console.execute", {"type": 'NUMPAD_ENTER', "value": 'PRESS'},
{"properties": [("interactive", True)]}),
- ("console.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None),
("console.copy_as_script", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None),
("console.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
("console.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None),
@@ -1886,10 +1884,10 @@ def km_console(params):
("console.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
("console.insert", {"type": 'TAB', "value": 'PRESS', "ctrl": True},
{"properties": [("text", '\t')]}),
- ("console.indent", {"type": 'TAB', "value": 'PRESS'}, None),
+ ("console.indent_or_autocomplete", {"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'}),
+ ("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None),
])
return keymap
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index 30f7894ea33..2a5675b9c3b 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -51,6 +51,7 @@ void CONSOLE_OT_delete(struct wmOperatorType *ot);
void CONSOLE_OT_insert(struct wmOperatorType *ot);
void CONSOLE_OT_indent(struct wmOperatorType *ot);
+void CONSOLE_OT_indent_or_autocomplete(struct wmOperatorType *ot);
void CONSOLE_OT_unindent(struct wmOperatorType *ot);
void CONSOLE_OT_history_append(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index bc18a6cfb56..591c3cc62f2 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -473,6 +473,44 @@ void CONSOLE_OT_insert(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
+/* -------------------------------------------------------------------- */
+/** \name Indent or Autocomplete Operator
+ * \{ */
+
+static int console_indent_or_autocomplete_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ ConsoleLine *ci = console_history_verify(C);
+ bool text_before_cursor = ci->cursor != 0 && !ELEM(ci->line[ci->cursor - 1], ' ', '\t');
+ if (text_before_cursor) {
+ WM_operator_name_call(C, "CONSOLE_OT_autocomplete", WM_OP_INVOKE_DEFAULT, NULL);
+ }
+ else {
+ WM_operator_name_call(C, "CONSOLE_OT_indent", WM_OP_EXEC_DEFAULT, NULL);
+ }
+ return OPERATOR_FINISHED;
+}
+
+void CONSOLE_OT_indent_or_autocomplete(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Indent or Autocomplete";
+ ot->idname = "CONSOLE_OT_indent_or_autocomplete";
+ ot->description = "Indent selected text or autocomplete";
+
+ /* api callbacks */
+ ot->exec = console_indent_or_autocomplete_exec;
+ ot->poll = ED_operator_console_active;
+
+ /* flags */
+ ot->flag = 0;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Indent Operator
+ * \{ */
+
static int console_indent_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceConsole *sc = CTX_wm_space_console(C);
@@ -518,6 +556,8 @@ void CONSOLE_OT_indent(wmOperatorType *ot)
ot->poll = ED_operator_console_active;
}
+/** \} */
+
static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceConsole *sc = CTX_wm_space_console(C);
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 5cc2f00413a..65a23531963 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -245,6 +245,7 @@ static void console_operatortypes(void)
WM_operatortype_append(CONSOLE_OT_insert);
WM_operatortype_append(CONSOLE_OT_indent);
+ WM_operatortype_append(CONSOLE_OT_indent_or_autocomplete);
WM_operatortype_append(CONSOLE_OT_unindent);
/* for use by python only */
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 088f06e9da8..ae7c3b001e7 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -203,6 +203,7 @@ static void text_operatortypes(void)
WM_operatortype_append(TEXT_OT_comment_toggle);
WM_operatortype_append(TEXT_OT_unindent);
WM_operatortype_append(TEXT_OT_indent);
+ WM_operatortype_append(TEXT_OT_indent_or_autocomplete);
WM_operatortype_append(TEXT_OT_select_line);
WM_operatortype_append(TEXT_OT_select_all);
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index ca37e9dcd3f..349682bb131 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -137,6 +137,7 @@ void TEXT_OT_convert_whitespace(struct wmOperatorType *ot);
void TEXT_OT_comment_toggle(struct wmOperatorType *ot);
void TEXT_OT_unindent(struct wmOperatorType *ot);
void TEXT_OT_indent(struct wmOperatorType *ot);
+void TEXT_OT_indent_or_autocomplete(struct wmOperatorType *ot);
void TEXT_OT_line_break(struct wmOperatorType *ot);
void TEXT_OT_insert(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index a4608123f19..71e24090aa1 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -1069,6 +1069,41 @@ void TEXT_OT_cut(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Indent or Autocomplete Operator
+ * \{ */
+
+static int text_indent_or_autocomplete_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Text *text = CTX_data_edit_text(C);
+ TextLine *line = text->curl;
+ bool text_before_cursor = text->curc != 0 && !ELEM(line->line[text->curc - 1], ' ', '\t');
+ if (text_before_cursor && (txt_has_sel(text) == false)) {
+ WM_operator_name_call(C, "TEXT_OT_autocomplete", WM_OP_INVOKE_DEFAULT, NULL);
+ }
+ else {
+ WM_operator_name_call(C, "TEXT_OT_indent", WM_OP_EXEC_DEFAULT, NULL);
+ }
+ return OPERATOR_FINISHED;
+}
+
+void TEXT_OT_indent_or_autocomplete(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Indent or Autocomplete";
+ ot->idname = "TEXT_OT_indent_or_autocomplete";
+ ot->description = "Indent selected text or autocomplete";
+
+ /* api callbacks */
+ ot->exec = text_indent_or_autocomplete_exec;
+ ot->poll = text_edit_poll;
+
+ /* flags */
+ ot->flag = 0;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Indent Operator
* \{ */