X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=inject_csi.h;h=b350a12177a94f87afe328609cc8cb98400dc8ff;hb=8e5831e371def4903b232c4e91962d2053cc6ce1;hp=a372bcdc80d77e9c0eaef92f55befbc395bf9a6d;hpb=1d26603be3c785ed147834cb7c750454a5866599;p=apps%2Fmadtty.git diff --git a/inject_csi.h b/inject_csi.h index a372bcd..b350a12 100644 --- a/inject_csi.h +++ b/inject_csi.h @@ -30,5 +30,15 @@ Copyright (c) 2004 Bruno T. C. de Oliveira * related fields in it */ void rote_es_interpret_csi(RoteTerm *rt); +static inline void clamp_cursor_to_bounds(RoteTerm *rt) { + if (rt->crow < 0) rt->curpos_dirty = true, rt->crow = 0; + if (rt->ccol < 0) rt->curpos_dirty = true, rt->ccol = 0; + + if (rt->crow >= rt->rows) + rt->curpos_dirty = true, rt->crow = rt->rows - 1; + + if (rt->ccol >= rt->cols) + rt->curpos_dirty = true, rt->ccol = rt->cols - 1; +} #endif