Partial fix for #28441: Tab width in texteditor ignored if used tabs as spaces
Scroll to cursor when displaying text datablock was changed. This behavior was lost in 2.5x.
This commit is contained in:
@@ -154,6 +154,11 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
case NA_REMOVED:
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
case NA_SELECTED:
|
||||
if(st->text && st->text == wmn->reference)
|
||||
text_scroll_to_cursor(st, sa);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -1821,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;
|
||||
@@ -1834,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;
|
||||
|
||||
@@ -1844,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;
|
||||
}
|
||||
|
||||
@@ -1865,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);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ int text_font_width(struct SpaceText *st, const char *str);
|
||||
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 ScrArea *sa);
|
||||
void text_update_cursor_moved(struct bContext *C);
|
||||
|
||||
/* TXT_OFFSET used to be 35 when the scrollbar was on the left... */
|
||||
|
||||
@@ -591,7 +591,8 @@ static void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value)
|
||||
SpaceText *st= (SpaceText*)(ptr->data);
|
||||
|
||||
st->text= value.data;
|
||||
st->top= 0;
|
||||
|
||||
WM_main_add_notifier(NC_TEXT|NA_SELECTED, st->text);
|
||||
}
|
||||
|
||||
static void rna_SpaceTextEditor_updateEdited(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
||||
|
||||
Reference in New Issue
Block a user