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:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-09-02 13:39:21 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-09-02 13:39:21 +0400
commit7a496bfbcf3c5a25d4101cf427ca980327ed3e8a (patch)
tree25c248a5e62b4472734d9e119c3ae689bb8ac292 /source/blender/editors/space_text
parent612e2d4dbe0e8dfe5b4d4fee49040ec38107ada3 (diff)
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.
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r--source/blender/editors/space_text/space_text.c5
-rw-r--r--source/blender/editors/space_text/text_draw.c19
-rw-r--r--source/blender/editors/space_text/text_intern.h1
3 files changed, 19 insertions, 6 deletions
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index c7d4d78422e..47f051e1ec4 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -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;
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 28230b7a48b..066404f23ba 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -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);
+}
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index cb55f41acb5..b34c7815f35 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -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... */