diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-27 18:01:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-27 18:01:16 +0400 |
commit | 28a2eedce6ba454021d4caaddccb16424d4774d3 (patch) | |
tree | 3b167e59b2ce654bc6952e4df5dae970ba5d7abc /source/blender/editors/space_console | |
parent | 8bc0cfc1ca988749365009eb01ac90dfec2baa50 (diff) |
console now stores selection internally with 0 index starting at the end of the line. makes internal logic much less confusing. no functional changes.
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r-- | source/blender/editors/space_console/console_draw.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_console/console_ops.c | 24 |
2 files changed, 9 insertions, 26 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 74d47ad675d..9c18eeee1e9 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -126,7 +126,7 @@ typedef struct ConsoleDrawContext { int ymin, ymax; int *xy; // [2] int *sel; // [2] - int *pos_pick; + int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start. int *mval; // [2] int draw; } ConsoleDrawContext; @@ -138,6 +138,7 @@ static void console_draw_sel(int sel[2], int xy[2], int str_len, int cwidth, int int end = MIN2(sel[1], str_len); /* highly confusing but draws correctly */ +#if 0 if(sel[0] < 0 || sel[1] > str_len) { if(sel[0] > 0) { end= sta; @@ -148,6 +149,7 @@ static void console_draw_sel(int sel[2], int xy[2], int str_len, int cwidth, int end= str_len; } } +#endif /* end confusement */ { @@ -157,7 +159,7 @@ static void console_draw_sel(int sel[2], int xy[2], int str_len, int cwidth, int glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ub(255, 255, 255, 96); } - glRecti(xy[0]+(cwidth*sta), xy[1]-2 + lheight, xy[0]+(cwidth*end), xy[1]-2); + glRecti(xy[0]+(cwidth*(str_len - sta)), xy[1]-2 + lheight, xy[0]+(cwidth*(str_len - end)), xy[1]-2); { glDisable(GL_POLYGON_STIPPLE); glDisable( GL_BLEND ); @@ -184,7 +186,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len, if((cdc->mval[1] != INT_MAX) && cdc->xy[1] <= cdc->mval[1]) { if((cdc->xy[1]+cdc->lheight >= cdc->mval[1])) { int ofs = (int)floor(((float)cdc->mval[0] / (float)cdc->cwidth)); - *cdc->pos_pick += MIN2(ofs, str_len); + CLAMP(ofs, 0, str_len); + *cdc->pos_pick += str_len - ofs; } else *cdc->pos_pick += str_len + 1; } @@ -324,7 +327,7 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion * if(sc->type==CONSOLE_TYPE_PYTHON) { int prompt_len; - + if(sc->sel_start != sc->sel_end) { sel[0]= sc->sel_start; sel[1]= sc->sel_end; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 9a53531ba73..802e3a75929 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -695,29 +695,9 @@ static int copy_exec(bContext *C, wmOperator *op) sel[1]= offset - sc->sel_start; for(cl= sc->scrollback.first; cl; cl= cl->next) { - - int sta= MAX2(0, sel[0]); - int end= MIN2(cl->len, sel[1]); - if(sel[0] <= cl->len && sel[1] >= 0) { - int str_len= cl->len; - - /* highly confusing but draws correctly */ - if(sel[0] < 0 || sel[1] > str_len) { - if(sel[0] > 0) { - end= sta; - sta= 0; - } - if (sel[1] <= str_len) { - sta= end; - end= str_len; - } - } - /* end confusement */ - - SWAP(int, sta, end); - end= cl->len - end; - sta= cl->len - sta; + int sta= MAX2(sel[0], 0); + int end= MIN2(sel[1], cl->len); if(BLI_dynstr_get_len(buf_dyn)) BLI_dynstr_append(buf_dyn, "\n"); |