char *substrcpy(char *destination, Substr range) { uint32_t length = substrlen(range); destination[length] = 0; return strncpy(destination, range.start, length); }
int GUIAPI TabbedTextOutEx (HDC hdc, int x, int y, const char* spText, int nCount, int nTabs, int *pTabPos, int nTabOrig) { PDC pdc; int line_len, sub_len; int nr_tab = 0, tab_pos, def_tab; int x_orig = x, max_x = x; int line_height; int nr_delim_newline, nr_delim_tab; if (nCount == 0) return 0; if (nCount < 0) nCount = strlen (spText); pdc = dc_HDC2PDC(hdc); line_height = pdc->pLogFont->size + pdc->alExtra + pdc->blExtra; y += pdc->alExtra; if (nTabs == 0 || pTabPos == NULL) { int ave_width = (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width) (pdc->pLogFont, pdc->pLogFont->sbc_devfont); def_tab = ave_width * pdc->tabstop; } else def_tab = pTabPos [nTabs - 1]; while (nCount) { line_len = substrlen (spText, nCount, '\n', &nr_delim_newline); nCount -= line_len + nr_delim_newline; nr_tab = 0; x = x_orig; tab_pos = nTabOrig; while (line_len) { int i, width; sub_len = substrlen (spText, line_len, '\t', &nr_delim_tab); width = TextOutLen (hdc, x, y, spText, sub_len); x += width; if (x >= tab_pos) { while (x >= tab_pos) tab_pos += (nr_tab >= nTabs) ? def_tab : pTabPos [nr_tab++]; for (i = 0; i < nr_delim_tab - 1; i ++) tab_pos += (nr_tab >= nTabs) ? def_tab : pTabPos [nr_tab++]; } else { for (i = 0; i < nr_delim_tab; i ++) tab_pos += (nr_tab >= nTabs) ? def_tab : pTabPos [nr_tab++]; } x = tab_pos; line_len -= sub_len + nr_delim_tab; spText += sub_len + nr_delim_tab; } if (max_x < x) max_x = x; spText += nr_delim_newline; y += line_height * nr_delim_newline; } return max_x - x_orig; }