Lines Matching refs:t
67 Table *t = xmalloc (sizeof(*t)); in table_new() local
69 t->ncols = ncols; in table_new()
70 t->nrows = 0; in table_new()
71 t->rows = (wchar_t***)NULL; in table_new()
72 t->widths = NULL; in table_new()
74 return t; in table_new()
78 void table_destroy (Table* t) in table_destroy() argument
82 assert (t); in table_destroy()
83 assert (t->ncols > 0); in table_destroy()
85 for (r = 0; r < t->nrows; ++r) in table_destroy()
87 for (c = 0; c < t->ncols; ++c) in table_destroy()
88 free (t->rows[r][c]); in table_destroy()
89 free (t->rows[r]); in table_destroy()
92 if (t->rows) in table_destroy()
93 free (t->rows); in table_destroy()
95 if (t->widths) in table_destroy()
96 free (t->widths); in table_destroy()
98 free (t); in table_destroy()
108 static void table_calc_column_widths (Table* t) in table_calc_column_widths() argument
112 assert(t); in table_calc_column_widths()
113 assert(t->ncols > 0); in table_calc_column_widths()
115 if (!t->widths) in table_calc_column_widths()
116 t->widths = xmalloc (t->ncols * sizeof(t->widths[0])); in table_calc_column_widths()
118 for (c = 0; c < t->ncols; ++c) in table_calc_column_widths()
119 t->widths[c] = 0; in table_calc_column_widths()
121 for (r = 0; r < t->nrows; ++r) in table_calc_column_widths()
122 for (c = 0; c < t->ncols; ++c) in table_calc_column_widths()
124 t->widths[c] = max ( t->widths[c], in table_calc_column_widths()
125 wcswidth(t->rows[r][c], in table_calc_column_widths()
136 void table_add_row (Table* t, wchar_t** row) in table_add_row() argument
138 assert(t); in table_add_row()
146 t->rows = xrealloc (t->rows, (t->nrows + 1) * sizeof(wchar_t***)); in table_add_row()
148 t->rows[t->nrows] = row; in table_add_row()
150 ++t->nrows; in table_add_row()
152 table_calc_column_widths (t); in table_add_row()
156 void table_add_row_from_strlist (Table* t, StrList* list) in table_add_row_from_strlist() argument
172 table_add_row (t, row); in table_add_row_from_strlist()
177 static void table_render_row (Table* t, int rownum, int ncols, wchar_t** s) in table_render_row() argument
179 wchar_t** row = t->rows[rownum]; in table_render_row()
183 assert(t); in table_render_row()
187 len += t->widths[i] + wcslen(DELIMITER); in table_render_row()
197 int nspaces = max(t->widths[i] - wcswidth(row[i], MAX_WIDTH), in table_render_row()
223 static void table_render_rows (Table* t, wchar_t** s) in table_render_rows() argument
228 for (i = 0; i < t->nrows; ++i) in table_render_rows()
229 table_render_row (t, i, t->ncols, s); in table_render_rows()
236 wchar_t* table_render(Table* t) in table_render() argument
241 table_render_rows (t, &s); in table_render()