aboutsummaryrefslogtreecommitdiff
path: root/grid.h
blob: ba31fe4e111cc24eaa6aa3758957e324805e370f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once

#include <stddef.h>
#include "terminal.h"

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 struct row *
grid_row_in_view(struct grid *grid, int row)
{
    assert(grid->view >= 0);
    return grid->rows[(grid->view + row + grid->num_rows) % grid->num_rows];
}

void grid_swap_row(struct grid *grid, int row_a, int row_b);