diff --git a/source/textbox.c b/source/textbox.c index dbde7bc7..a7599475 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -236,10 +236,19 @@ void textbox_draw ( textbox *tb ) int cursor_offset = 0; cursor_offset = MIN ( tb->cursor, text_len ); + // Trailing spaces still go wrong.... + // The replace by _ is needed, one way or the other. + // Make a copy, and replace all trailing spaces. + char *test = strdup(text); + for(int iter = strlen(text)-1; iter >= 0 && test[iter] == ' '; iter--) + { + test[iter] = '_'; + } // calc cursor position - XftTextExtentsUtf8 ( display, tb->font, ( unsigned char * ) text, cursor_offset, &extents ); + XftTextExtentsUtf8 ( display, tb->font, ( unsigned char * ) test, cursor_offset, &extents ); // Add a small 4px offset between cursor and last glyph. cursor_x = extents.width + ( ( extents.width > 0 ) ? 2 : 0 ); + free(test); } // calc full input text width