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:
-rw-r--r--source/blender/blenkernel/BKE_text.h2
-rw-r--r--source/blender/blenkernel/intern/text.c10
-rw-r--r--source/blender/editors/space_text/text_ops.c24
3 files changed, 32 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h
index 5e81fb85d76..8fd712bde72 100644
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@ -101,6 +101,8 @@ void txt_uncomment (struct Text *text);
void txt_move_lines (struct Text *text, const int direction);
void txt_duplicate_line (struct Text *text);
int txt_setcurr_tab_spaces(struct Text *text, int space);
+bool txt_cursor_is_line_start(struct Text *text);
+bool txt_cursor_is_line_end(struct Text *text);
/* utility functions, could be moved somewhere more generic but are python/text related */
int text_check_bracket(const char ch);
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 9b019776508..c5a509162ff 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -780,6 +780,16 @@ static void txt_curs_sel(Text *text, TextLine ***linep, int **charp)
*linep = &text->sell; *charp = &text->selc;
}
+bool txt_cursor_is_line_start(Text *text)
+{
+ return (text->selc == 0);
+}
+
+bool txt_cursor_is_line_end(Text *text)
+{
+ return (text->selc == text->sell->len);
+}
+
/*****************************/
/* Cursor movement functions */
/*****************************/
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index fec6847bb79..30f3c1623c9 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -1855,10 +1855,16 @@ static int text_move_cursor(bContext *C, int type, int select)
break;
case PREV_WORD:
+ if (txt_cursor_is_line_start(text)) {
+ txt_move_left(text, select);
+ }
txt_jump_left(text, select, true);
break;
case NEXT_WORD:
+ if (txt_cursor_is_line_end(text)) {
+ txt_move_right(text, select);
+ }
txt_jump_right(text, select, true);
break;
@@ -2005,14 +2011,24 @@ static int text_delete_exec(bContext *C, wmOperator *op)
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
- if (type == DEL_PREV_WORD)
+ if (type == DEL_PREV_WORD) {
+ if (txt_cursor_is_line_start(text)) {
+ txt_backspace_char(text);
+ }
txt_backspace_word(text);
- else if (type == DEL_PREV_CHAR)
+ }
+ else if (type == DEL_PREV_CHAR) {
txt_backspace_char(text);
- else if (type == DEL_NEXT_WORD)
+ }
+ else if (type == DEL_NEXT_WORD) {
+ if (txt_cursor_is_line_end(text)) {
+ txt_delete_char(text);
+ }
txt_delete_word(text);
- else if (type == DEL_NEXT_CHAR)
+ }
+ else if (type == DEL_NEXT_CHAR) {
txt_delete_char(text);
+ }
text_update_line_edited(text->curl);