diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_console/console_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_console/console_ops.c | 37 | ||||
-rw-r--r-- | source/blender/editors/space_console/space_console.c | 7 |
3 files changed, 41 insertions, 4 deletions
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h index 33588cc0923..c0abd094e62 100644 --- a/source/blender/editors/space_console/console_intern.h +++ b/source/blender/editors/space_console/console_intern.h @@ -58,6 +58,7 @@ void CONSOLE_OT_history_append(struct wmOperatorType *ot); void CONSOLE_OT_scrollback_append(struct wmOperatorType *ot); void CONSOLE_OT_clear(struct wmOperatorType *ot); +void CONSOLE_OT_clear_line(struct wmOperatorType *ot); void CONSOLE_OT_history_cycle(struct wmOperatorType *ot); void CONSOLE_OT_copy(struct wmOperatorType *ot); void CONSOLE_OT_paste(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index ef036b071be..5d63a223c08 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -519,6 +519,39 @@ void CONSOLE_OT_delete(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", console_delete_type_items, DEL_NEXT_CHAR, "Type", "Which part of the text to delete"); } +static int console_clear_line_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); + ConsoleLine *ci = console_history_verify(C); + + if (ci->len == 0) { + return OPERATOR_CANCELLED; + } + + console_history_add(C, ci); + console_history_add(C, NULL); + + console_textview_update_rect(sc, ar); + + ED_area_tag_redraw(CTX_wm_area(C)); + + console_scroll_bottom(ar); + + return OPERATOR_FINISHED; +} + +void CONSOLE_OT_clear_line(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Clear Line"; + ot->description = "Clear the line and store in history"; + ot->idname = "CONSOLE_OT_clear_line"; + + /* api callbacks */ + ot->exec = console_clear_line_exec; + ot->poll = ED_operator_console_active; +} /* the python exec operator uses this */ static int console_clear_exec(bContext *C, wmOperator *op) @@ -571,7 +604,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) SpaceConsole *sc = CTX_wm_space_console(C); ARegion *ar = CTX_wm_region(C); - ConsoleLine *ci = console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */ + ConsoleLine *ci = console_history_verify(C); /* TODO - stupid, just prevents crashes when no command line */ short reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */ int prev_len = ci->len; @@ -584,7 +617,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) console_history_free(sc, ci_prev); } - if (reverse) { /* last item in mistory */ + if (reverse) { /* last item in history */ ci = sc->history.last; BLI_remlink(&sc->history, ci); BLI_addhead(&sc->history, ci); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 39757aa393a..a25606db2b3 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -250,8 +250,9 @@ static void console_operatortypes(void) /* for use by python only */ WM_operatortype_append(CONSOLE_OT_history_append); WM_operatortype_append(CONSOLE_OT_scrollback_append); - - WM_operatortype_append(CONSOLE_OT_clear); + + WM_operatortype_append(CONSOLE_OT_clear); + WM_operatortype_append(CONSOLE_OT_clear_line); WM_operatortype_append(CONSOLE_OT_history_cycle); WM_operatortype_append(CONSOLE_OT_copy); WM_operatortype_append(CONSOLE_OT_paste); @@ -312,6 +313,8 @@ static void console_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD); + WM_keymap_add_item(keymap, "CONSOLE_OT_clear_line", RETKEY, KM_PRESS, KM_SHIFT, 0); + #ifdef WITH_PYTHON WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */ WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0); |