2019-06-17 19:33:10 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-07-01 12:23:38 +02:00
|
|
|
#include <stddef.h>
|
2019-06-17 19:33:10 +02:00
|
|
|
#include "terminal.h"
|
2019-07-01 12:23:38 +02:00
|
|
|
|
2019-07-08 13:57:31 +02:00
|
|
|
static inline struct row *
|
|
|
|
|
grid_row(struct grid *grid, int row)
|
|
|
|
|
{
|
|
|
|
|
assert(grid->offset >= 0);
|
|
|
|
|
return grid->rows[(grid->offset + row + grid->num_rows) % grid->num_rows];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
grid_swap_row(struct grid *grid, int row_a, int row_b)
|
|
|
|
|
{
|
|
|
|
|
assert(grid->offset >= 0);
|
|
|
|
|
assert(row_a != row_b);
|
|
|
|
|
assert(row_a >= 0);
|
|
|
|
|
assert(row_b >= 0);
|
|
|
|
|
|
|
|
|
|
int real_a = (grid->offset + row_a + grid->num_rows) % grid->num_rows;
|
|
|
|
|
int real_b = (grid->offset + row_b + grid->num_rows) % grid->num_rows;
|
|
|
|
|
|
|
|
|
|
struct row *tmp = grid->rows[real_a];
|
|
|
|
|
grid->rows[real_a] = grid->rows[real_b];
|
|
|
|
|
grid->rows[real_b] = tmp;
|
|
|
|
|
|
|
|
|
|
grid->rows[real_a]->dirty = true;
|
|
|
|
|
grid->rows[real_b]->dirty = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
2019-07-03 10:45:49 +02:00
|
|
|
struct cell *grid_get_range(struct grid *grid, int start, int *length);
|
2019-07-07 17:10:15 +02:00
|
|
|
void grid_memclear(struct grid *grid, int start, int length);
|
2019-07-03 10:45:49 +02:00
|
|
|
void grid_memmove(struct grid *grid, int dst, int src, int length);
|
2019-07-08 13:57:31 +02:00
|
|
|
#endif
|