+ /*
+ * Construct a modified version of state->sequence which takes
+ * into account an unfinished drag operation.
+ */
+ if (ui->drag) {
+ x = ui->dragnum;
+ y = ui->dragpos;
+ } else {
+ x = y = -1;
+ }
+ for (i = j = 0; i < w; i++) {
+ if (i == y) {
+ ds->sequence[i] = x;
+ } else {
+ if (state->sequence[j] == x)
+ j++;
+ ds->sequence[i] = state->sequence[j++];
+ }
+ }
+
+ /*
+ * Draw the table legend.
+ */
+ for (x = 0; x < w; x++) {
+ int sx = ds->sequence[x];
+ long tile = (sx+1) | DF_LEGEND;
+ if (ds->legend[x] != tile) {
+ ds->legend[x] = tile;
+ draw_tile(dr, ds, -1, x, tile, 0, 0);
+ draw_tile(dr, ds, x, -1, tile, 0, 0);
+ }
+ }
+