diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-12 11:37:25 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-12 11:37:25 +0400 |
commit | ba1082444efae1085bd01f240958bc9fceb826a5 (patch) | |
tree | 5f7b24edea0ded09a341e51ee7458f48422bb158 /source/blender | |
parent | 345be5cbbc8c78228b2ded7c2dcb7278c38631b1 (diff) |
made text editor margin work with different font sizes.
also made it draw the width needed, was fixed at 4.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_intern.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 2 |
3 files changed, 17 insertions, 18 deletions
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index adba7ef100a..9f8cedd569f 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1300,15 +1300,23 @@ void draw_text_main(SpaceText *st, ARegion *ar) linecount++; } + text_font_begin(st); + st->cwidth= BLF_fixed_width(); + st->cwidth= MAX2(st->cwidth, 1); + /* draw line numbers background */ if(st->showlinenrs) { + st->linenrs_tot = (int)floor(log10((float)(linecount + st->viewlines))) + 1; + x= TXT_OFFSET + TEXTXLOC; + UI_ThemeColor(TH_GRID); - glRecti(23, 0, (st->lheight==15)? 63: 59, ar->winy - 2); + glRecti((TXT_OFFSET-12), 0, (TXT_OFFSET-5) + TEXTXLOC, ar->winy - 2); } - - text_font_begin(st); - st->cwidth= BLF_fixed_width(); - st->cwidth= MAX2(st->cwidth, 1); + else { + st->linenrs_tot= 0; /* not used */ + x= TXT_OFFSET; + } + y= ar->winy-st->lheight; /* draw cursor */ draw_cursor(st, ar); @@ -1316,9 +1324,6 @@ void draw_text_main(SpaceText *st, ARegion *ar) /* draw the text */ UI_ThemeColor(TH_TEXT); - y= ar->winy-st->lheight; - x= (st->showlinenrs)? TXT_OFFSET + TEXTXLOC: TXT_OFFSET; - for(i=0; y>0 && i<st->viewlines && tmp; i++, tmp= tmp->next) { if(st->showsyntax && !tmp->format) txt_format_line(st, tmp, 0); @@ -1330,14 +1335,8 @@ void draw_text_main(SpaceText *st, ARegion *ar) else UI_ThemeColor(TH_TEXT); - if(((float)(i + linecount + 1)/10000.0) < 1.0) { - sprintf(linenr, "%4d", i + linecount + 1); - text_font_draw(st, TXT_OFFSET - 7, y, linenr); - } - else { - sprintf(linenr, "%5d", i + linecount + 1); - text_font_draw(st, TXT_OFFSET - 11, y, linenr); - } + sprintf(linenr, "%d", i + linecount + 1); + text_font_draw(st, TXT_OFFSET - 7, y, linenr); UI_ThemeColor(TH_TEXT); } diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index 5ea33e1660d..cb425274fc0 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -58,7 +58,7 @@ void text_update_edited(struct Text *text); void text_update_character_width(struct SpaceText *st); void text_update_cursor_moved(struct SpaceText *st, struct ARegion *ar); -#define TEXTXLOC 38 +#define TEXTXLOC (st->cwidth * st->linenrs_tot) #define SUGG_LIST_SIZE 7 #define SUGG_LIST_WIDTH 20 diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 951b12b82fe..cc6987084d0 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -294,7 +294,7 @@ typedef struct SpaceText { short flags, menunr; short lheight; /* user preference */ - short cwidth; /* runtime computed */ + char cwidth, linenrs_tot; /* runtime computed, character width and the number of chars to use when showing line numbers */ int left; int showlinenrs; int tabnumber; |