X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=e468d73cf522853325cc0c26921e91d0cf3bad05;hb=6b7f63bac597ca03e18fe63ad522b4d1bded08d1;hp=d188b355cc2f512dd17c72fda746da9dd8b6181e;hpb=3afdb4ff04b45a5e4209a56d5073341c9d506b38;p=st.git diff --git a/st.c b/st.c index d188b35..e468d73 100644 --- a/st.c +++ b/st.c @@ -1398,9 +1398,8 @@ tscrolldown(int orig, int n) { LIMIT(n, 0, term.bot-orig+1); - tclearregion(0, term.bot-n+1, term.col-1, term.bot); tsetdirt(orig, term.bot-n); - tsetdirt(orig+n, term.bot); + tclearregion(0, term.bot-n+1, term.col-1, term.bot); for(i = term.bot; i >= orig+n; i--) { temp = term.line[i]; @@ -1415,16 +1414,16 @@ void tscrollup(int orig, int n) { int i; Line temp; + LIMIT(n, 0, term.bot-orig+1); tclearregion(0, orig, term.col-1, orig+n-1); - tsetdirt(orig, term.bot-n); tsetdirt(orig+n, term.bot); for(i = orig; i <= term.bot-n; i++) { - temp = term.line[i]; - term.line[i] = term.line[i+n]; - term.line[i+n] = temp; + temp = term.line[i]; + term.line[i] = term.line[i+n]; + term.line[i+n] = temp; } selscroll(orig, -n); @@ -1587,37 +1586,33 @@ tclearregion(int x1, int y1, int x2, int y2) { void tdeletechar(int n) { - int src = term.c.x + n; - int dst = term.c.x; - int size = term.col - src; + int dst, src, size; + Glyph *line; - term.dirty[term.c.y] = 1; + LIMIT(n, 0, term.col - term.c.x); - if(src >= term.col) { - tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); - return; - } + dst = term.c.x; + src = term.c.x + n; + size = term.col - src; + line = term.line[term.c.y]; - memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], - size * sizeof(Glyph)); + memmove(&line[dst], &line[src], size * sizeof(Glyph)); tclearregion(term.col-n, term.c.y, term.col-1, term.c.y); } void tinsertblank(int n) { - int src = term.c.x; - int dst = src + n; - int size = term.col - dst; + int dst, src, size; + Glyph *line; - term.dirty[term.c.y] = 1; + LIMIT(n, 0, term.col - term.c.x); - if(dst >= term.col) { - tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); - return; - } + dst = term.c.x + n; + src = term.c.x; + size = term.col - dst; + line = term.line[term.c.y]; - memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], - size * sizeof(Glyph)); + memmove(&line[dst], &line[src], size * sizeof(Glyph)); tclearregion(src, term.c.y, dst - 1, term.c.y); }