MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / X11Textbox_Measure

Function X11Textbox_Measure

src/Window_X11.c:945–959  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

943};
944
945static void X11Textbox_Measure(struct X11Textbox* t, XFontStruct* font) {
946 cc_string str = String_FromReadonly(t->text), line;
947 XCharStruct overall;
948 int direction, ascent, descent, lines = 0;
949
950 for (; str.length; lines++) {
951 String_UNSAFE_SplitBy(&str, '\n', &line);
952 XTextExtents(font, line.buffer, line.length, &direction, &ascent, &descent, &overall);
953 t->width = max(overall.width, t->width);
954 }
955
956 t->lineHeight = ascent + descent;
957 t->descent = descent;
958 t->height = t->lineHeight * lines;
959}
960
961static void X11Textbox_Draw(struct X11Textbox* t, struct X11MessageBox* m) {
962 cc_string str = String_FromReadonly(t->text), line;

Callers 1

X11_MessageBoxFunction · 0.85

Calls 2

String_FromReadonlyFunction · 0.85
String_UNSAFE_SplitByFunction · 0.85

Tested by

no test coverage detected