diff options
-rw-r--r-- | source/blender/editors/include/ED_text.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_text/space_text.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 8 |
7 files changed, 22 insertions, 22 deletions
diff --git a/source/blender/editors/include/ED_text.h b/source/blender/editors/include/ED_text.h index 6742561735e..2284c82b3d5 100644 --- a/source/blender/editors/include/ED_text.h +++ b/source/blender/editors/include/ED_text.h @@ -34,6 +34,8 @@ struct UndoStep; struct UndoType; struct bContext; +void ED_text_scroll_to_cursor(struct SpaceText *st, struct ARegion *region, bool center); + bool ED_text_region_location_from_cursor(struct SpaceText *st, struct ARegion *region, const int cursor_co[2], diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 540e98f542e..62be13c11c9 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -72,6 +72,7 @@ #include "BKE_main.h" #include "BLI_ghash.h" #include "ED_screen.h" +#include "ED_text.h" /* -------------------------------------------------------------------- */ /** \name Copy Data Path Operator @@ -1336,18 +1337,23 @@ static int editsource_text_edit(bContext *C, return OPERATOR_CANCELLED; } + txt_move_toline(text, line - 1, false); + /* naughty!, find text area to set, not good behavior * but since this is a dev tool lets allow it - campbell */ ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0); if (area) { SpaceText *st = area->spacedata.first; + ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); st->text = text; + if (region) { + ED_text_scroll_to_cursor(st, region, true); + } } else { BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2); } - txt_move_toline(text, line - 1, false); WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 98faf89f8ae..af783051661 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -138,13 +138,7 @@ static void text_listener(const wmSpaceTypeListenerParams *params) switch (wmn->data) { case ND_DISPLAY: - ED_area_tag_redraw(area); - break; case ND_CURSOR: - if (st->text && st->text == wmn->reference) { - text_scroll_to_cursor__area(st, area, true); - } - ED_area_tag_redraw(area); break; } @@ -160,13 +154,8 @@ static void text_listener(const wmSpaceTypeListenerParams *params) ATTR_FALLTHROUGH; /* fall down to tag redraw */ case NA_ADDED: case NA_REMOVED: - ED_area_tag_redraw(area); - break; case NA_SELECTED: - if (st->text && st->text == wmn->reference) { - text_scroll_to_cursor__area(st, area, true); - } - + ED_area_tag_redraw(area); break; } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 8b8034124d9..17831c95575 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1739,7 +1739,7 @@ void text_update_character_width(SpaceText *st) /* Moves the view to the cursor location, * also used to make sure the view isn't outside the file */ -void text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center) +void ED_text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center) { Text *text; int i, x, winx = region->winx; @@ -1818,7 +1818,7 @@ void text_scroll_to_cursor__area(SpaceText *st, ScrArea *area, const bool center region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region) { - text_scroll_to_cursor(st, region, center); + ED_text_scroll_to_cursor(st, region, center); } } diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index a33af56e11a..241e0133a8a 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -39,7 +39,6 @@ void draw_text_main(struct SpaceText *st, struct ARegion *region); void text_update_line_edited(struct TextLine *line); void text_update_edited(struct Text *text); void text_update_character_width(struct SpaceText *st); -void text_scroll_to_cursor(struct SpaceText *st, struct ARegion *region, const bool center); void text_scroll_to_cursor__area(struct SpaceText *st, struct ScrArea *area, const bool center); void text_update_cursor_moved(struct bContext *C); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 526285c076a..e6803d12a42 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -506,12 +506,10 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op)) if (text->id.prev) { st->text = text->id.prev; text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text); } else if (text->id.next) { st->text = text->id.next; text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text); } } @@ -3200,7 +3198,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev if (event->type == TIMER) { text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], 1); - text_scroll_to_cursor(st, region, false); + ED_text_scroll_to_cursor(st, region, false); WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text); } } @@ -3210,7 +3208,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev if (event->type == TIMER) { text_cursor_set_to_pos( st, region, CLAMPIS(event->mval[0], 0, region->winx), event->mval[1], 1); - text_scroll_to_cursor(st, region, false); + ED_text_scroll_to_cursor(st, region, false); WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text); } } @@ -3219,7 +3217,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev if (event->type != TIMER) { text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], 1); - text_scroll_to_cursor(st, region, false); + ED_text_scroll_to_cursor(st, region, false); WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text); ssel->mval_prev[0] = event->mval[0]; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 361c0e82b3b..b6c0bce4342 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1793,7 +1793,13 @@ static void rna_SpaceTextEditor_text_set(PointerRNA *ptr, st->text = value.data; - WM_main_add_notifier(NC_TEXT | NA_SELECTED, st->text); + ScrArea *area = rna_area_from_space(ptr); + if (area) { + ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); + if (region) { + ED_text_scroll_to_cursor(st, region, true); + } + } } static bool rna_SpaceTextEditor_text_is_syntax_highlight_supported(struct SpaceText *space) |