How many times will I break/fix trailing spaces, only buddah knows

This commit is contained in:
QC 2014-06-02 13:23:36 +02:00
parent 477b10fb2f
commit 92db68b36d
1 changed files with 10 additions and 1 deletions

View File

@ -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