summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-07-06 07:15:05 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-07-06 07:15:05 +0300
commitcfc05e4c4fdcbe35e15111ce52f5d73541533859 (patch)
tree9feec0acf311935bff00cd09552e317e2efffec7 /src/ui/inputwidget.c
parente1ff98965a4aec72418165424a0183e596df1ecb (diff)
InputWidget: Fixed cursor positioning
Use advance and not bounds.
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index e65af417..b51b3985 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -1448,10 +1448,10 @@ static void draw_InputWidget_(const iInputWidget *d) {
1448 const iString * text = &curLine->text; 1448 const iString * text = &curLine->text;
1449 /* The `gap_UI` offsets below are a hack. They are used because for some reason the 1449 /* The `gap_UI` offsets below are a hack. They are used because for some reason the
1450 cursor rect and the glyph inside don't quite position like during `run_Text_()`. */ 1450 cursor rect and the glyph inside don't quite position like during `run_Text_()`. */
1451 const iInt2 prefixSize = measureN_Text(d->font, cstr_String(text), d->cursor - curLine->offset).bounds.size; 1451 const int prefixSize = measureN_Text(d->font, cstr_String(text), d->cursor - curLine->offset).advance.x;
1452 const iInt2 curPos = addX_I2(addY_I2(contentBounds.pos, lineHeight_Text(d->font) * d->cursorLine), 1452 const iInt2 curPos = addX_I2(addY_I2(contentBounds.pos, lineHeight_Text(d->font) * d->cursorLine),
1453 prefixSize.x + 1453 prefixSize +
1454 (d->mode == insert_InputMode ? -curSize.x / 2 : 0)); 1454 (d->mode == insert_InputMode ? -curSize.x / 2 : 0));
1455 const iRect curRect = { curPos, curSize }; 1455 const iRect curRect = { curPos, curSize };
1456 fillRect_Paint(&p, curRect, uiInputCursor_ColorId); 1456 fillRect_Paint(&p, curRect, uiInputCursor_ColorId);
1457 if (d->mode == overwrite_InputMode) { 1457 if (d->mode == overwrite_InputMode) {