| 198 | } |
| 199 | |
| 200 | func (m *TuiModel) SwapTableValues(f, t *TableState) { |
| 201 | from := &f.Data |
| 202 | to := &t.Data |
| 203 | for k, v := range *from { |
| 204 | if copyValues, ok := v.(map[string][]interface{}); ok { |
| 205 | columnNames := m.Data().TableHeaders[k] |
| 206 | columnValues := make(map[string][]interface{}) |
| 207 | // golang wizardry |
| 208 | columns := make([]interface{}, len(columnNames)) |
| 209 | |
| 210 | for i := range columns { |
| 211 | columns[i] = copyValues[columnNames[i]][0] |
| 212 | } |
| 213 | |
| 214 | for i, colName := range columnNames { |
| 215 | columnValues[colName] = columns[i].([]interface{}) |
| 216 | } |
| 217 | |
| 218 | (*to)[k] = columnValues // data for schema, organized by column |
| 219 | } |
| 220 | } |
| 221 | } |