How many times will I break/fix trailing spaces, only buddah knows
This commit is contained in:
@@ -236,10 +236,19 @@ void textbox_draw ( textbox *tb )
|
|||||||
int cursor_offset = 0;
|
int cursor_offset = 0;
|
||||||
cursor_offset = MIN ( tb->cursor, text_len );
|
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
|
// 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.
|
// Add a small 4px offset between cursor and last glyph.
|
||||||
cursor_x = extents.width + ( ( extents.width > 0 ) ? 2 : 0 );
|
cursor_x = extents.width + ( ( extents.width > 0 ) ? 2 : 0 );
|
||||||
|
free(test);
|
||||||
}
|
}
|
||||||
|
|
||||||
// calc full input text width
|
// calc full input text width
|
||||||
|
Reference in New Issue
Block a user