From 033b0789c8fb17f0a9e6f66ff0a6fb9df53af236 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 11 Mar 2016 00:04:13 +1100 Subject: Text Editor: Auto indent for backspace/delete Editing with spaces + auto-indent didn't delete indentation as expected. --- source/blender/editors/space_text/text_ops.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/blender/editors/space_text/text_ops.c') diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 5c17ebc37c6..d404e7aaf15 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1951,6 +1951,19 @@ static int text_delete_exec(bContext *C, wmOperator *op) txt_backspace_word(text); } else if (type == DEL_PREV_CHAR) { + + if (text->flags & TXT_TABSTOSPACES) { + if (!txt_has_sel(text) && !txt_cursor_is_line_start(text)) { + int tabsize = 0; + tabsize = txt_calc_tab_left(text->curl, text->curc); + if (tabsize) { + text->sell = text->curl; + text->selc = text->curc - tabsize; + txt_order_cursors(text, false); + } + } + } + txt_backspace_char(text); } else if (type == DEL_NEXT_WORD) { @@ -1960,6 +1973,19 @@ static int text_delete_exec(bContext *C, wmOperator *op) txt_delete_word(text); } else if (type == DEL_NEXT_CHAR) { + + if (text->flags & TXT_TABSTOSPACES) { + if (!txt_has_sel(text) && !txt_cursor_is_line_end(text)) { + int tabsize = 0; + tabsize = txt_calc_tab_right(text->curl, text->curc); + if (tabsize) { + text->sell = text->curl; + text->selc = text->curc + tabsize; + txt_order_cursors(text, true); + } + } + } + txt_delete_char(text); } -- cgit v1.2.3