-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmt-screen.c
44 lines (37 loc) · 983 Bytes
/
mt-screen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: LGPL-2.1-or-later
/*
* Copyright (C) 2019-2022 Cyril Hrubis <[email protected]>
*/
#include "mt-screen.h"
void mt_damage_merge(struct mt_damage *self,
mt_coord s_col, mt_coord s_row,
mt_coord e_col, mt_coord e_row)
{
if (self->s_col < 0) {
self->s_col = s_col;
self->s_row = s_row;
self->e_col = e_col;
self->e_row = e_row;
return;
}
//printf("Merging damage %ix%i-%ix%i %ix%i-%ix%i\n",
// self->s_col, self->s_row, self->e_col, self->e_row,
// s_col, s_row, e_col, e_row);
self->s_col = MT_MIN(self->s_col, s_col);
self->s_row = MT_MIN(self->s_row, s_row);
self->e_col = MT_MAX(self->e_col, e_col);
self->e_row = MT_MAX(self->e_row, e_row);
}
void mt_damage_scroll(struct mt_damage *self, int lines)
{
self->scroll += lines;
if (self->e_row <= lines) {
self->s_col = -1;
return;
}
if (self->s_row <= lines)
self->s_row = 0;
else
self->s_row -= lines;
self->e_row -= lines;
}