void init_table();
void expand_table_rows(Workspace *workspace);
void expand_table_cols(Workspace *workspace);
+void expand_table_cols_at_head(Workspace *workspace);
bool cell_exists(int col, int row);
void cleanup_table(xcb_connection_t *conn, Workspace *workspace);
void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace);
void dump_table(xcb_connection_t *conn, Workspace *workspace);
-
#endif
switch (direction) {
case D_LEFT:
- /* TODO: If we’re at the left-most position, move the rest of the table right */
- if (current_col == 0)
- return;
+ /* If we’re at the left-most position, move the rest of the table right */
+ if (current_col == 0) {
+ expand_table_cols_at_head(c_ws);
+ new = CUR_TABLE[current_col][current_row];
+ } else
+ new = CUR_TABLE[--current_col][current_row];
- new = CUR_TABLE[--current_col][current_row];
break;
case D_RIGHT:
if (current_col == (c_ws->cols-1))
new_container(workspace, &(workspace->table[workspace->cols-1][c]), workspace->cols-1, c);
}
+/*
+ * Inserts one column at the table’s head
+ *
+ */
+void expand_table_cols_at_head(Workspace *workspace) {
+ workspace->cols++;
+
+ workspace->table = realloc(workspace->table, sizeof(Container**) * workspace->cols);
+ workspace->table[workspace->cols-1] = calloc(sizeof(Container*) * workspace->rows, 1);
+
+ /* Move the other columns */
+ for (int rows = 0; rows < workspace->rows; rows++)
+ for (int cols = workspace->cols - 1; cols > 0; cols--) {
+ LOG("Moving col %d to %d\n", cols-1, cols);
+ workspace->table[cols][rows] = workspace->table[cols-1][rows];
+ workspace->table[cols][rows]->col = cols;
+ }
+
+ for (int rows = 0; rows < workspace->rows; rows++)
+ new_container(workspace, &(workspace->table[0][rows]), 0, rows);
+}
+
/*
* Shrinks the table by one column.
*