diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-03-10 16:04:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-03-10 16:06:09 +0300 |
commit | 033b0789c8fb17f0a9e6f66ff0a6fb9df53af236 (patch) | |
tree | 07f3fd247c87bdd19e11a056732b130d05cd7cca /source/blender/editors/space_text/text_ops.c | |
parent | de7a8af79380ba9c77bedb068b72f3d7e05bc98e (diff) |
Text Editor: Auto indent for backspace/delete
Editing with spaces + auto-indent didn't delete indentation as expected.
Diffstat (limited to 'source/blender/editors/space_text/text_ops.c')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 26 |
1 files changed, 26 insertions, 0 deletions
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); } |