mirror of
https://github.com/LukeSmithxyz/st.git
synced 2024-11-21 23:05:59 +01:00
Simplify a bit more tdeletechar and tinsertblank
The large and repeated expression used in memmove to indirect the line can be simplified using a pointer, that makes more clear where begins and where ends the movement.
This commit is contained in:
parent
80b32af794
commit
6b7f63bac5
1 changed files with 6 additions and 4 deletions
10
st.c
10
st.c
|
@ -1587,30 +1587,32 @@ tclearregion(int x1, int y1, int x2, int y2) {
|
||||||
void
|
void
|
||||||
tdeletechar(int n) {
|
tdeletechar(int n) {
|
||||||
int dst, src, size;
|
int dst, src, size;
|
||||||
|
Glyph *line;
|
||||||
|
|
||||||
LIMIT(n, 0, term.col - term.c.x);
|
LIMIT(n, 0, term.col - term.c.x);
|
||||||
|
|
||||||
dst = term.c.x;
|
dst = term.c.x;
|
||||||
src = term.c.x + n;
|
src = term.c.x + n;
|
||||||
size = term.col - src;
|
size = term.col - src;
|
||||||
|
line = term.line[term.c.y];
|
||||||
|
|
||||||
memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src],
|
memmove(&line[dst], &line[src], size * sizeof(Glyph));
|
||||||
size * sizeof(Glyph));
|
|
||||||
tclearregion(term.col-n, term.c.y, term.col-1, term.c.y);
|
tclearregion(term.col-n, term.c.y, term.col-1, term.c.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tinsertblank(int n) {
|
tinsertblank(int n) {
|
||||||
int dst, src, size;
|
int dst, src, size;
|
||||||
|
Glyph *line;
|
||||||
|
|
||||||
LIMIT(n, 0, term.col - term.c.x);
|
LIMIT(n, 0, term.col - term.c.x);
|
||||||
|
|
||||||
dst = term.c.x + n;
|
dst = term.c.x + n;
|
||||||
src = term.c.x;
|
src = term.c.x;
|
||||||
size = term.col - dst;
|
size = term.col - dst;
|
||||||
|
line = term.line[term.c.y];
|
||||||
|
|
||||||
memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src],
|
memmove(&line[dst], &line[src], size * sizeof(Glyph));
|
||||||
size * sizeof(Glyph));
|
|
||||||
tclearregion(src, term.c.y, dst - 1, term.c.y);
|
tclearregion(src, term.c.y, dst - 1, term.c.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue