diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-02-14 08:11:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-02-14 08:14:02 +0300 |
commit | f621f03e4b252d5ef1d86b9306a22628da3160ce (patch) | |
tree | 21f4630ba495ca2eaa6ea1e7accf6be1bfd762d3 /source/blender/editors/space_console | |
parent | bbe6b661df08bbd0c73a2b89bffe4525667aab9b (diff) |
Fix console cursor offset
Also remove hard coded offsets.
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r-- | source/blender/editors/space_console/console_draw.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index af01ec72ec2..3ba355b3730 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -144,34 +144,37 @@ static void console_cursor_wrap_offset( return; } -static void console_textview_draw_cursor(struct TextViewContext *tvc) +static void console_textview_draw_cursor(struct TextViewContext *tvc, + int cwidth, + int columns, + int descender) { - const SpaceConsole *sc = (SpaceConsole *)tvc->arg1; - const ConsoleLine *cl = (ConsoleLine *)sc->history.last; - int offl = 0, offc = 0; - int xy[2] = {tvc->draw_rect.xmin, tvc->draw_rect.ymin}; int pen[2]; - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - xy[1] += tvc->lheight * 0.35f; + { + const SpaceConsole *sc = (SpaceConsole *)tvc->arg1; + const ConsoleLine *cl = (ConsoleLine *)sc->history.last; + int offl = 0, offc = 0; + + console_cursor_wrap_offset(sc->prompt, columns, &offl, &offc, NULL); + console_cursor_wrap_offset(cl->line, columns, &offl, &offc, cl->line + cl->cursor); + pen[0] = cwidth * offc; + pen[1] = -2 - (tvc->lheight + descender) * offl; - console_cursor_wrap_offset(sc->prompt, tvc->columns, &offl, &offc, NULL); - console_cursor_wrap_offset(cl->line, tvc->columns, &offl, &offc, cl->line + cl->cursor); - pen[0] = tvc->cwidth * offc; - pen[1] = -2 - tvc->lheight * offl; + console_cursor_wrap_offset(cl->line + cl->cursor, columns, &offl, &offc, NULL); + pen[1] += (tvc->lheight + descender) * offl; - console_cursor_wrap_offset(cl->line + cl->cursor, tvc->columns, &offl, &offc, NULL); - pen[1] += tvc->lheight * offl; + pen[0] += tvc->draw_rect.xmin; + pen[1] += tvc->draw_rect.ymin; + } /* cursor */ + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_CONSOLE_CURSOR); - immRectf(pos, - (xy[0] + pen[0]) - U.pixelsize, - (xy[1] + pen[1]), - (xy[0] + pen[0]) + U.pixelsize, - (xy[1] + pen[1] + tvc->lheight)); + immRectf( + pos, pen[0] - U.pixelsize, pen[1], pen[0] + U.pixelsize, pen[1] + tvc->lheight + descender); immUnbindProgram(); } |