Skip to content

Commit aa29cfa

Browse files
committed
first line cursor sel
1 parent f3f61cf commit aa29cfa

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

lib/libgui/edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ void render_cursor(edit_t *self) {
922922
sth_vmetrics(buffer->font->stash, buffer->font->id, buffer->font->size,
923923
&ascender, &descender, &lineh);
924924

925-
float x1 = buffer->cursor_x + sx-1;
925+
float x1 = buffer->cursor_x + sx - 1;
926926
float y1 = buffer->cursor_y + sy + 8.0;
927927
float x2 = x1 + 3;
928928
float y2 = y1 + (ascender - descender * 2) * self->scale / 2;

lib/libgui/fontstash.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,21 +633,21 @@ int sth_pos(struct sth_stash* stash, int idx, float size, float width, char* s,
633633
while (fnt != NULL && fnt->idx != idx) fnt = fnt->next;
634634
if (fnt == NULL) return -1;
635635
if (fnt->type != BMFONT && !fnt->data) return -1;
636-
637-
for (int i = 0; *s && i < count; ++s) {
636+
int i=0;
637+
for (i = 0; *s && i < count; ++s) {
638638
if (decutf8(&state, &codepoint, *(unsigned char*)s)) {
639639
continue;
640640
}
641-
i++;
642641
glyph = get_glyph(stash, fnt, codepoint, isize);
643642
if (!glyph) continue;
644-
if ((width + glyph->xoff - glyph->xadv * 2) <= sx) {
643+
if ((width + glyph->xoff - glyph->xadv ) <= sx) {
645644
return i;
646645
}
646+
i++;
647647
if (!get_quad(stash, fnt, glyph, isize, &x, &y, &q)) continue;
648648
sx = x;
649649
}
650-
return -1;
650+
return i;
651651
}
652652

653653
void sth_measure(struct sth_stash* stash, int idx, float size, float width,

0 commit comments

Comments
 (0)