diff options
Diffstat (limited to 'source/blender/editors/space_text/text_draw.c')
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 625e5561389..066404f23ba 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -907,9 +907,12 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar) void text_drawcache_tag_update(SpaceText *st, int full) { - DrawCache *drawcache= (DrawCache *)st->drawcache; - - if(drawcache) { + /* this happens if text editor ops are caled from python */ + if (st == NULL) + return; + + if(st->drawcache) { + DrawCache *drawcache= (DrawCache *)st->drawcache; Text *txt= st->text; if(drawcache->update_flag) { @@ -1818,12 +1821,10 @@ void text_update_character_width(SpaceText *st) /* Moves the view to the cursor location, also used to make sure the view isnt outside the file */ -void text_update_cursor_moved(bContext *C) +void text_scroll_to_cursor(SpaceText *st, ScrArea *sa) { - ScrArea *sa= CTX_wm_area(C); - SpaceText *st= CTX_wm_space_text(C); Text *text; - ARegion *ar; + ARegion *ar= NULL; int i, x, winx= 0; if(ELEM3(NULL, st, st->text, st->text->curl)) return; @@ -1831,8 +1832,10 @@ void text_update_cursor_moved(bContext *C) text= st->text; for(ar=sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_WINDOW) + if(ar->regiontype==RGN_TYPE_WINDOW) { winx= ar->winx; + break; + } winx -= TXT_SCROLL_WIDTH; @@ -1841,7 +1844,7 @@ void text_update_cursor_moved(bContext *C) i= txt_get_span(text->lines.first, text->sell); if(st->wordwrap) { int offl, offc; - wrap_offset(st, CTX_wm_region(C), text->sell, text->selc, &offl, &offc); + wrap_offset(st, ar, text->sell, text->selc, &offl, &offc); i+= offl; } @@ -1862,3 +1865,10 @@ void text_update_cursor_moved(bContext *C) if(st->left <0) st->left= 0; } +void text_update_cursor_moved(bContext *C) +{ + ScrArea *sa= CTX_wm_area(C); + SpaceText *st= CTX_wm_space_text(C); + + text_scroll_to_cursor(st, sa); +} |