summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Naumov <alexander_naumov@opensuse.org>2017-01-19 13:10:46 +0100
committerAlexander Naumov <alexander_naumov@opensuse.org>2017-01-19 13:10:46 +0100
commit6a5f8ac1cf2edc952ba298a900b4744d46317327 (patch)
treeb164507409bb93e41f97058925d93cc0b090e0ff
parent0b7bcd4302ffcbbe14b493f84476e4baa5e08904 (diff)
downloadscreen-6a5f8ac1cf2edc952ba298a900b4744d46317327.tar.gz
Refactoring + 'olddisplay' is never read (LayPause)
-rw-r--r--src/layer.c1508
1 files changed, 693 insertions, 815 deletions
diff --git a/src/layer.c b/src/layer.c
index 0afe013..fc8d03b 100644
--- a/src/layer.c
+++ b/src/layer.c
@@ -1,11 +1,13 @@
-/* Copyright (c) 2008, 2009
- * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
- * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
- * Micah Cowan (micah@cowan.name)
- * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
+/* Copyright (c) 2008-2017
+ * Juergen Weigert <jnweiger@immd4.informatik.uni-erlangen.de>
+ * Michael Schroeder <mlschroe@immd4.informatik.uni-erlangen.de>
+ * Micah Cowan <micah@cowan.name>
+ * Sadrul Habib Chowdhury <sadrul@users.sourceforge.net>
+ *
* Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
- * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
- * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
+ * Juergen Weigert <jnweiger@immd4.informatik.uni-erlangen.de>
+ * Michael Schroeder <mlschroe@immd4.informatik.uni-erlangen.de>
+ *
* Copyright (c) 1987 Oliver Laumann
*
* This program is free software; you can redistribute it and/or modify
@@ -55,27 +57,26 @@ static struct mline *mloff __P((struct mline *, int));
*
*/
-static struct mline *
-mloff(ml, off)
-struct mline *ml;
-int off;
+static struct mline *mloff(struct mline *ml, int off)
{
static struct mline mml;
-
if (ml == 0)
return 0;
+
mml.image = ml->image + off;
mml.attr = ml->attr + off;
#ifdef FONT
mml.font = ml->font + off;
mml.fontx = ml->fontx + off;
#endif
+
#ifdef COLOR
mml.color = ml->color + off;
# ifdef COLORS256
mml.colorx = ml->colorx + off;
# endif
#endif
+
return &mml;
}
@@ -94,10 +95,7 @@ int off;
fn \
}
-void
-LGotoPos(l, x, y)
-struct layer *l;
-int x, y;
+void LGotoPos(struct layer *l, int x, int y)
{
struct canvas *cv;
struct viewport *vp;
@@ -114,39 +112,33 @@ int x, y;
{
display = cv->c_display;
if (D_blocked)
- continue;
+ continue;
if (cv != D_forecv)
- continue;
+ continue;
x2 = x + cv->c_xoff;
y2 = y + cv->c_yoff;
debug2("---LGotoPos %d %d\n", x2, y2);
if (x2 < cv->c_xs)
- x2 = cv->c_xs;
+ x2 = cv->c_xs;
if (y2 < cv->c_ys)
- y2 = cv->c_ys;
+ y2 = cv->c_ys;
if (x2 > cv->c_xe)
- x2 = cv->c_xe;
+ x2 = cv->c_xe;
if (y2 > cv->c_ye)
- y2 = cv->c_ye;
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- if (x2 < vp->v_xs || x2 > vp->v_xe)
- continue;
- if (y2 < vp->v_ys || y2 > vp->v_ye)
- continue;
- GotoPos(x2, y2);
- break;
- }
+ y2 = cv->c_ye;
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ if (x2 < vp->v_xs || x2 > vp->v_xe)
+ continue;
+ if (y2 < vp->v_ys || y2 > vp->v_ye)
+ continue;
+ GotoPos(x2, y2);
+ break;
+ }
}
);
}
-void
-LScrollH(l, n, y, xs, xe, bce, ol)
-struct layer *l;
-int n, y, xs, xe;
-int bce;
-struct mline *ol;
+void LScrollH(struct layer *l, int n, int y, int xs, int xe, int bce, struct mline *ol)
{
struct canvas *cv;
struct viewport *vp;
@@ -156,52 +148,46 @@ struct mline *ol;
return;
if (l->l_pause.d)
LayPauseUpdateRegion(l, xs, xe, y, y);
+
FOR_EACH_UNPAUSED_CANVAS(l,
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- y2 = y + vp->v_yoff;
- if (y2 < vp->v_ys || y2 > vp->v_ye)
- continue;
- xs2 = xs + vp->v_xoff;
- xe2 = xe + vp->v_xoff;
- if (xs2 < vp->v_xs)
- xs2 = vp->v_xs;
- if (xe2 > vp->v_xe)
- xe2 = vp->v_xe;
- if (xs2 > xe2)
- continue;
- display = cv->c_display;
- if (D_blocked)
- continue;
- ScrollH(y2, xs2, xe2, n, bce, ol ? mloff(ol, -vp->v_xoff) : 0);
- if (xe2 - xs2 == xe - xs)
- continue;
- if (n > 0)
- {
- xs2 = xe2 + 1 - n;
- xe2 = xe + vp->v_xoff - n;
- }
- else
- {
- xe2 = xs2 - 1 - n;
- xs2 = xs + vp->v_xoff - n;
- }
- if (xs2 < vp->v_xs)
- xs2 = vp->v_xs;
- if (xe2 > vp->v_xe)
- xe2 = vp->v_xe;
- if (xs2 <= xe2)
- RefreshArea(xs2, y2, xe2, y2, 1);
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ y2 = y + vp->v_yoff;
+ if (y2 < vp->v_ys || y2 > vp->v_ye)
+ continue;
+ xs2 = xs + vp->v_xoff;
+ xe2 = xe + vp->v_xoff;
+ if (xs2 < vp->v_xs)
+ xs2 = vp->v_xs;
+ if (xe2 > vp->v_xe)
+ xe2 = vp->v_xe;
+ if (xs2 > xe2)
+ continue;
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ ScrollH(y2, xs2, xe2, n, bce, ol ? mloff(ol, -vp->v_xoff) : 0);
+ if (xe2 - xs2 == xe - xs)
+ continue;
+ if (n > 0) {
+ xs2 = xe2 + 1 - n;
+ xe2 = xe + vp->v_xoff - n;
}
+ else {
+ xe2 = xs2 - 1 - n;
+ xs2 = xs + vp->v_xoff - n;
+ }
+
+ if (xs2 < vp->v_xs)
+ xs2 = vp->v_xs;
+ if (xe2 > vp->v_xe)
+ xe2 = vp->v_xe;
+ if (xs2 <= xe2)
+ RefreshArea(xs2, y2, xe2, y2, 1);
+ }
);
}
-void
-LScrollV(l, n, ys, ye, bce)
-struct layer *l;
-int n;
-int ys, ye;
-int bce;
+void LScrollV(struct layer *l, int n, int ys, int ye, int bce)
{
struct canvas *cv;
struct viewport *vp;
@@ -211,62 +197,57 @@ int bce;
if (l->l_pause.d)
LayPauseUpdateRegion(l, 0, l->l_width - 1, ys, ye);
FOR_EACH_UNPAUSED_CANVAS(l,
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- xs2 = vp->v_xoff;
- xe2 = l->l_width - 1 + vp->v_xoff;
- ys2 = ys + vp->v_yoff;
- ye2 = ye + vp->v_yoff;
- if (xs2 < vp->v_xs)
- xs2 = vp->v_xs;
- if (xe2 > vp->v_xe)
- xe2 = vp->v_xe;
- if (ys2 < vp->v_ys)
- ys2 = vp->v_ys;
- if (ye2 > vp->v_ye)
- ye2 = vp->v_ye;
- if (ys2 > ye2 || xs2 > xe2)
- continue;
- display = cv->c_display;
- if (D_blocked)
- continue;
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ xs2 = vp->v_xoff;
+ xe2 = l->l_width - 1 + vp->v_xoff;
+ ys2 = ys + vp->v_yoff;
+ ye2 = ye + vp->v_yoff;
+
+ if (xs2 < vp->v_xs)
+ xs2 = vp->v_xs;
+ if (xe2 > vp->v_xe)
+ xe2 = vp->v_xe;
+ if (ys2 < vp->v_ys)
+ ys2 = vp->v_ys;
+ if (ye2 > vp->v_ye)
+ ye2 = vp->v_ye;
+ if (ys2 > ye2 || xs2 > xe2)
+ continue;
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
#if 0
- ScrollV(xs2, ys2, xe2, ye2, n, bce);
+ ScrollV(xs2, ys2, xe2, ye2, n, bce);
#else
- ScrollV(vp->v_xs, ys2, vp->v_xe, ye2, n, bce);
+ ScrollV(vp->v_xs, ys2, vp->v_xe, ye2, n, bce);
#endif
- debug2("LScrollV: %d %d", ys, ye);
- debug2(" -> %d %d\n", ys2, ye2);
- if (ye2 - ys2 == ye - ys)
- continue;
- if (n > 0)
- {
- ys2 = ye2 + 1 - n;
- ye2 = ye + vp->v_yoff - n;
- }
- else
- {
- ye2 = ys2 - 1 - n;
- ys2 = ys + vp->v_yoff - n;
- }
- debug2("LScrollV: - %d %d\n", ys2, ye2);
- if (ys2 < vp->v_ys)
- ys2 = vp->v_ys;
- if (ye2 > vp->v_ye)
- ye2 = vp->v_ye;
- debug2("LScrollV: - %d %d\n", ys2, ye2);
- if (ys2 <= ye2)
- RefreshArea(xs2, ys2, xe2, ye2, 1);
+
+ debug2("LScrollV: %d %d", ys, ye);
+ debug2(" -> %d %d\n", ys2, ye2);
+ if (ye2 - ys2 == ye - ys)
+ continue;
+ if (n > 0) {
+ ys2 = ye2 + 1 - n;
+ ye2 = ye + vp->v_yoff - n;
+ }
+ else {
+ ye2 = ys2 - 1 - n;
+ ys2 = ys + vp->v_yoff - n;
}
+
+ debug2("LScrollV: - %d %d\n", ys2, ye2);
+ if (ys2 < vp->v_ys)
+ ys2 = vp->v_ys;
+ if (ye2 > vp->v_ye)
+ ye2 = vp->v_ye;
+ debug2("LScrollV: - %d %d\n", ys2, ye2);
+ if (ys2 <= ye2)
+ RefreshArea(xs2, ys2, xe2, ye2, 1);
+ }
);
}
-void
-LInsChar(l, c, x, y, ol)
-struct layer *l;
-struct mchar *c;
-int x, y;
-struct mline *ol;
+void LInsChar(struct layer *l, struct mchar *c, int x, int y, struct mline *ol)
{
struct canvas *cv;
struct viewport *vp;
@@ -277,100 +258,89 @@ struct mline *ol;
if (l->l_pause.d)
LayPauseUpdateRegion(l, x, l->l_width - 1, y, y);
FOR_EACH_UNPAUSED_CANVAS(l,
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- y2 = y + vp->v_yoff;
- if (y2 < vp->v_ys || y2 > vp->v_ye)
- continue;
- xs2 = x + vp->v_xoff;
- xe2 = l->l_width - 1 + vp->v_xoff;
- c2 = c;
- f = 0;
- if (xs2 < vp->v_xs)
- {
- xs2 = vp->v_xs;
- c2 = &mchar_blank;
- if (ol)
- {
- int i;
- i = xs2 - vp->v_xoff - 1;
- if (i >= 0 && i < l->l_width)
- {
- copy_mline2mchar(&cc, ol, i);
- c2 = &cc;
- }
- }
- else
- f = 1;
- }
- if (xe2 > vp->v_xe)
- xe2 = vp->v_xe;
- if (xs2 > xe2)
- continue;
- display = cv->c_display;
- if (D_blocked)
- continue;
- rol = RECODE_MLINE(ol);
- InsChar(RECODE_MCHAR(c2), xs2, xe2, y2, mloff(rol, -vp->v_xoff));
- if (f)
- RefreshArea(xs2, y2, xs2, y2, 1);
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ y2 = y + vp->v_yoff;
+ if (y2 < vp->v_ys || y2 > vp->v_ye)
+ continue;
+ xs2 = x + vp->v_xoff;
+ xe2 = l->l_width - 1 + vp->v_xoff;
+ c2 = c;
+ f = 0;
+ if (xs2 < vp->v_xs) {
+ xs2 = vp->v_xs;
+ c2 = &mchar_blank;
+ if (ol) {
+ int i = xs2 - vp->v_xoff - 1;
+ if (i >= 0 && i < l->l_width) {
+ copy_mline2mchar(&cc, ol, i);
+ c2 = &cc;
+ }
+ }
+ else
+ f = 1;
}
+
+ if (xe2 > vp->v_xe)
+ xe2 = vp->v_xe;
+ if (xs2 > xe2)
+ continue;
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ rol = RECODE_MLINE(ol);
+ InsChar(RECODE_MCHAR(c2), xs2, xe2, y2, mloff(rol, -vp->v_xoff));
+ if (f)
+ RefreshArea(xs2, y2, xs2, y2, 1);
+ }
);
}
-void
-LPutChar(l, c, x, y)
-struct layer *l;
-struct mchar *c;
-int x, y;
+
+void LPutChar(struct layer *l, struct mchar *c, int x, int y)
{
struct canvas *cv;
struct viewport *vp;
int x2, y2;
+
#ifdef HAVE_BRAILLE
- if (bd.bd_refreshing)
- {
- BPutChar(l, c, x, y);
- return;
- }
+ if (bd.bd_refreshing) {
+ BPutChar(l, c, x, y);
+ return;
+ }
#endif
if (l->l_pause.d)
LayPauseUpdateRegion(l, x,
+
#ifdef DW_CHARS
- x + (c->mbcs ? 1 : 0)
+ x + (c->mbcs ? 1 : 0)
#else
- x
+ x
#endif
- , y, y);
+ , y, y);
+
FOR_EACH_UNPAUSED_CANVAS(l,
{
display = cv->c_display;
if (D_blocked)
- continue;
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- y2 = y + vp->v_yoff;
- if (y2 < vp->v_ys || y2 > vp->v_ye)
- continue;
- x2 = x + vp->v_xoff;
- if (x2 < vp->v_xs || x2 > vp->v_xe)
- continue;
- PutChar(RECODE_MCHAR(c), x2, y2);
- break;
- }
+ continue;
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ y2 = y + vp->v_yoff;
+ if (y2 < vp->v_ys || y2 > vp->v_ye)
+ continue;
+ x2 = x + vp->v_xoff;
+ if (x2 < vp->v_xs || x2 > vp->v_xe)
+ continue;
+ PutChar(RECODE_MCHAR(c), x2, y2);
+ break;
+ }
}
);
}
-void
-LPutStr(l, s, n, r, x, y)
-struct layer *l;
-char *s;
-int n;
-struct mchar *r;
-int x, y;
+
+void LPutStr(struct layer *l, char *s, int n, struct mchar *r, int x, int y)
{
struct canvas *cv;
struct viewport *vp;
@@ -379,62 +349,57 @@ int x, y;
if (x + n > l->l_width)
n = l->l_width - x;
+
#ifdef HAVE_BRAILLE
- if (bd.bd_refreshing)
- {
- BPutStr(l, s, n, r, x, y);
- return;
- }
+ if (bd.bd_refreshing) {
+ BPutStr(l, s, n, r, x, y);
+ return;
+ }
#endif
+
if (l->l_pause.d)
LayPauseUpdateRegion(l, x, x + n - 1, y, y);
FOR_EACH_UNPAUSED_CANVAS(l,
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- y2 = y + vp->v_yoff;
- if (y2 < vp->v_ys || y2 > vp->v_ye)
- continue;
- xs2 = x + vp->v_xoff;
- xe2 = xs2 + n - 1;
- if (xs2 < vp->v_xs)
- xs2 = vp->v_xs;
- if (xe2 > vp->v_xe)
- xe2 = vp->v_xe;
- if (xs2 > xe2)
- continue;
- display = cv->c_display;
- if (D_blocked)
- continue;
- GotoPos(xs2, y2);
- SetRendition(r);
- s2 = s + xs2 - x - vp->v_xoff;
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ y2 = y + vp->v_yoff;
+ if (y2 < vp->v_ys || y2 > vp->v_ye)
+ continue;
+ xs2 = x + vp->v_xoff;
+ xe2 = xs2 + n - 1;
+ if (xs2 < vp->v_xs)
+ xs2 = vp->v_xs;
+ if (xe2 > vp->v_xe)
+ xe2 = vp->v_xe;
+ if (xs2 > xe2)
+ continue;
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ GotoPos(xs2, y2);
+ SetRendition(r);
+ s2 = s + xs2 - x - vp->v_xoff;
+
#ifdef UTF8
- if (D_encoding == UTF8 && l->l_encoding != UTF8 && (r->font || r->fontx || l->l_encoding))
- {
- struct mchar mc;
- mc = *r;
- while (xs2 <= xe2)
- {
- mc.image = *s2++;
- PutChar(RECODE_MCHAR(&mc), xs2++, y2);
- }
- continue;
- }
-#endif
- while (xs2++ <= xe2)
- PUTCHARLP(*s2++);
+ if (D_encoding == UTF8 && l->l_encoding != UTF8 && (r->font || r->fontx || l->l_encoding)) {
+ struct mchar mc;
+ mc = *r;
+ while (xs2 <= xe2) {
+ mc.image = *s2++;
+ PutChar(RECODE_MCHAR(&mc), xs2++, y2);
+ }
+ continue;
}
+#endif
+
+ while (xs2++ <= xe2)
+ PUTCHARLP(*s2++);
+ }
);
}
-void
-LPutWinMsg(l, s, n, r, x, y)
-struct layer *l;
-char *s;
-int n;
-struct mchar *r;
-int x, y;
+
+void LPutWinMsg(struct layer *l, char *s, int n, struct mchar *r, int x, int y)
{
struct canvas *cv;
struct viewport *vp;
@@ -443,58 +408,57 @@ int x, y;
if (x + n > l->l_width)
n = l->l_width - x;
+
#ifdef HAVE_BRAILLE
- if (bd.bd_refreshing)
- {
- BPutStr(l, s, n, r, x, y);
- return;
- }
+ if (bd.bd_refreshing) {
+ BPutStr(l, s, n, r, x, y);
+ return;
+ }
#endif
+
if (l->l_pause.d)
LayPauseUpdateRegion(l, x, x + n - 1, y, y);
+
len = strlen(s);
if (len > n)
len = n;
+
FOR_EACH_UNPAUSED_CANVAS(l,
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- y2 = y + vp->v_yoff;
- if (y2 < vp->v_ys || y2 > vp->v_ye)
- continue;
- xs2 = x + vp->v_xoff;
- xe2 = xs2 + n - 1;
- if (xs2 < vp->v_xs)
- xs2 = vp->v_xs;
- if (xe2 > vp->v_xe)
- xe2 = vp->v_xe;
- if (xs2 > xe2)
- continue;
- display = cv->c_display;
- if (D_blocked)
- continue;
- GotoPos(xs2, y2);
- SetRendition(r);
- len2 = xe2 - (x + vp->v_xoff) + 1;
- if (len2 > len)
- len2 = len;
- PutWinMsg(s, xs2 - x - vp->v_xoff, len2);
- xs2 = x + vp->v_xoff + len2;
- if (xs2 < vp->v_xs)
- xs2 = vp->v_xs;
- or = D_rend;
- GotoPos(xs2, y2);
- SetRendition(&or);
- while (xs2++ <= xe2)
- PUTCHARLP(' ');
- }
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ y2 = y + vp->v_yoff;
+ if (y2 < vp->v_ys || y2 > vp->v_ye)
+ continue;
+ xs2 = x + vp->v_xoff;
+ xe2 = xs2 + n - 1;
+ if (xs2 < vp->v_xs)
+ xs2 = vp->v_xs;
+ if (xe2 > vp->v_xe)
+ xe2 = vp->v_xe;
+ if (xs2 > xe2)
+ continue;
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ GotoPos(xs2, y2);
+ SetRendition(r);
+ len2 = xe2 - (x + vp->v_xoff) + 1;
+ if (len2 > len)
+ len2 = len;
+ PutWinMsg(s, xs2 - x - vp->v_xoff, len2);
+ xs2 = x + vp->v_xoff + len2;
+ if (xs2 < vp->v_xs)
+ xs2 = vp->v_xs;
+ or = D_rend;
+ GotoPos(xs2, y2);
+ SetRendition(&or);
+ while (xs2++ <= xe2)
+ PUTCHARLP(' ');
+ }
);
}
-void
-LClearLine(l, y, xs, xe, bce, ol)
-struct layer *l;
-int y, xs, xe, bce;
-struct mline *ol;
+
+void LClearLine(struct layer *l, int y, int xs, int xe, int bce, struct mline *ol)
{
struct canvas *cv;
struct viewport *vp;
@@ -507,42 +471,39 @@ struct mline *ol;
xe = l->l_width - 1;
if (l->l_pause.d)
LayPauseUpdateRegion(l, xs, xe, y, y);
+
FOR_EACH_UNPAUSED_CANVAS(l,
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- xs2 = xs + vp->v_xoff;
- xe2 = xe + vp->v_xoff;
- y2 = y + vp->v_yoff;
- if (y2 < vp->v_ys || y2 > vp->v_ye)
- continue;
- if (xs2 < vp->v_xs)
- xs2 = vp->v_xs;
- if (xe2 > vp->v_xe)
- xe2 = vp->v_xe;
- if (xs2 > xe2)
- continue;
- display = cv->c_display;
- if (D_blocked)
- continue;
- ClearLine(ol ? mloff(RECODE_MLINE(ol), -vp->v_xoff) : (struct mline *)0, y2, xs2, xe2, bce);
- }
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ xs2 = xs + vp->v_xoff;
+ xe2 = xe + vp->v_xoff;
+ y2 = y + vp->v_yoff;
+ if (y2 < vp->v_ys || y2 > vp->v_ye)
+ continue;
+ if (xs2 < vp->v_xs)
+ xs2 = vp->v_xs;
+ if (xe2 > vp->v_xe)
+ xe2 = vp->v_xe;
+ if (xs2 > xe2)
+ continue;
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ ClearLine(ol ? mloff(RECODE_MLINE(ol), -vp->v_xoff) : (struct mline *)0, y2, xs2, xe2, bce);
+ }
);
}
-void
-LClearArea(l, xs, ys, xe, ye, bce, uself)
-struct layer *l;
-int xs, ys, xe, ye;
-int bce;
-int uself;
+void LClearArea(struct layer *l, int xs, int ys, int xe, int ye, int bce, int uself)
{
struct canvas *cv;
struct viewport *vp;
int xs2, ys2, xe2, ye2;
+
#ifdef HAVE_BRAILLE
if (bd.bd_refreshing)
return;
#endif
+
/* Check for zero-height window */
if (ys < 0 || ye < ys)
return;
@@ -554,159 +515,147 @@ int uself;
xe = l->l_width - 1;
if (l->l_pause.d)
LayPauseUpdateRegion(l, xs, xe, ys, ye);
+
FOR_EACH_UNPAUSED_CANVAS(l,
{
display = cv->c_display;
if (D_blocked)
- continue;
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- xs2 = xs + vp->v_xoff;
- xe2 = xe + vp->v_xoff;
- ys2 = ys + vp->v_yoff;
- ye2 = ye + vp->v_yoff;
- if (xs2 < vp->v_xs)
- xs2 = vp->v_xs;
- if (xe2 > vp->v_xe)
- xe2 = vp->v_xe;
- if (xs2 > vp->v_xe)
- ys2++;
- if (xe2 < vp->v_xs)
- ye2--;
- if (ys2 < vp->v_ys)
- ys2 = vp->v_ys;
- if (ye2 > vp->v_ye)
- ye2 = vp->v_ye;
- if (ys2 > ye2)
- continue;
+ continue;
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ xs2 = xs + vp->v_xoff;
+ xe2 = xe + vp->v_xoff;
+ ys2 = ys + vp->v_yoff;
+ ye2 = ye + vp->v_yoff;
+
+ if (xs2 < vp->v_xs)
+ xs2 = vp->v_xs;
+ if (xe2 > vp->v_xe)
+ xe2 = vp->v_xe;
+ if (xs2 > vp->v_xe)
+ ys2++;
+ if (xe2 < vp->v_xs)
+ ye2--;
+ if (ys2 < vp->v_ys)
+ ys2 = vp->v_ys;
+ if (ye2 > vp->v_ye)
+ ye2 = vp->v_ye;
+ if (ys2 > ye2)
+ continue;
#if 0
- xcs = vp->v_xoff;
- xce = l->l_width - 1 + vp->v_xoff;
- if (xcs < vp->v_xs)
- xcs = vp->v_xs;
- if (xce > vp->v_xe)
- xce = vp->v_xe;
- if (xcs > xce)
- continue;
- if (ys2 != ys + vp->v_yoff)
- xs2 = xcs;
- if (ye2 != ye + vp->v_yoff)
- xe2 = xce;
- display = cv->c_display;
- ClearArea(xs2, ys2, xcs, xce, xe2, ye2, bce, uself);
+ xcs = vp->v_xoff;
+ xce = l->l_width - 1 + vp->v_xoff;
+ if (xcs < vp->v_xs)
+ xcs = vp->v_xs;
+ if (xce > vp->v_xe)
+ xce = vp->v_xe;
+ if (xcs > xce)
+ continue;
+ if (ys2 != ys + vp->v_yoff)
+ xs2 = xcs;
+ if (ye2 != ye + vp->v_yoff)
+ xe2 = xce;
+ display = cv->c_display;
+ ClearArea(xs2, ys2, xcs, xce, xe2, ye2, bce, uself);
#else
- if (xs == 0 || ys2 != ys + vp->v_yoff)
- xs2 = vp->v_xs;
- if (xe == l->l_width - 1 || ye2 != ye + vp->v_yoff)
- xe2 = vp->v_xe;
- display = cv->c_display;
- ClearArea(xs2, ys2, vp->v_xs, vp->v_xe, xe2, ye2, bce, uself);
- if (xe == l->l_width - 1 && xe2 > vp->v_xoff + xe)
- {
- int y;
- SetRendition(&mchar_blank);
- for (y = ys2; y <= ye2; y++)
- {
- GotoPos(xe + vp->v_xoff + 1, y);
- PUTCHARLP('|');
- }
- }
+
+ if (xs == 0 || ys2 != ys + vp->v_yoff)
+ xs2 = vp->v_xs;
+ if (xe == l->l_width - 1 || ye2 != ye + vp->v_yoff)
+ xe2 = vp->v_xe;
+ display = cv->c_display;
+ ClearArea(xs2, ys2, vp->v_xs, vp->v_xe, xe2, ye2, bce, uself);
+
+ if (xe == l->l_width - 1 && xe2 > vp->v_xoff + xe) {
+ int y;
+ SetRendition(&mchar_blank);
+ for (y = ys2; y <= ye2; y++) {
+ GotoPos(xe + vp->v_xoff + 1, y);
+ PUTCHARLP('|');
+ }
+ }
#endif
- }
+ }
}
);
}
-void
-LCDisplayLine(l, ml, y, xs, xe, isblank)
-struct layer *l;
-struct mline *ml;
-int y, xs, xe;
-int isblank;
+
+void LCDisplayLine(struct layer *l, struct mline *ml, int y, int xs, int xe, int isblank)
{
struct canvas *cv;
struct viewport *vp;
int xs2, xe2, y2;
+
#ifdef HAVE_BRAILLE
- if (bd.bd_refreshing)
- {
- BCDisplayLine(l, ml, y, xs, xe, isblank);
- return;
- }
+ if (bd.bd_refreshing) {
+ BCDisplayLine(l, ml, y, xs, xe, isblank);
+ return;
+ }
#endif
+
if (l->l_pause.d)
LayPauseUpdateRegion(l, xs, xe, y, y);
+
FOR_EACH_UNPAUSED_CANVAS(l,
{
display = cv->c_display;
if (D_blocked)
- continue;
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- xs2 = xs + vp->v_xoff;
- xe2 = xe + vp->v_xoff;
- y2 = y + vp->v_yoff;
- if (y2 < vp->v_ys || y2 > vp->v_ye)
- continue;
- if (xs2 < vp->v_xs)
- xs2 = vp->v_xs;
- if (xe2 > vp->v_xe)
- xe2 = vp->v_xe;
- if (xs2 > xe2)
- continue;
- display = cv->c_display;
- debug3("LCDisplayLine: DisplayLine %d, %d-%d", y2, xs2, xe2);
- debug1(" mloff = %d\n", -vp->v_xoff);
- DisplayLine(isblank ? &mline_blank : &mline_null, mloff(RECODE_MLINE(ml), -vp->v_xoff), y2, xs2, xe2);
- }
+ continue;
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ xs2 = xs + vp->v_xoff;
+ xe2 = xe + vp->v_xoff;
+ y2 = y + vp->v_yoff;
+ if (y2 < vp->v_ys || y2 > vp->v_ye)
+ continue;
+ if (xs2 < vp->v_xs)
+ xs2 = vp->v_xs;
+ if (xe2 > vp->v_xe)
+ xe2 = vp->v_xe;
+ if (xs2 > xe2)
+ continue;
+ display = cv->c_display;
+ debug3("LCDisplayLine: DisplayLine %d, %d-%d", y2, xs2, xe2);
+ debug1(" mloff = %d\n", -vp->v_xoff);
+ DisplayLine(isblank ? &mline_blank : &mline_null, mloff(RECODE_MLINE(ml), -vp->v_xoff), y2, xs2, xe2);
+ }
}
);
}
-void
-LCDisplayLineWrap(l, ml, y, from, to, isblank)
-struct layer *l;
-struct mline *ml;
-int y, from, to;
-int isblank;
+
+void LCDisplayLineWrap(struct layer *l, struct mline *ml, int y, int from, int to, int isblank)
{
struct mchar nc;
copy_mline2mchar(&nc, ml, 0);
+
#ifdef DW_CHARS
- if (dw_left(ml, 0, l->l_encoding))
- {
- nc.mbcs = ml->image[1];
- from++;
- }
+ if (dw_left(ml, 0, l->l_encoding)) {
+ nc.mbcs = ml->image[1];
+ from++;
+ }
#endif
+
LWrapChar(l, &nc, y - 1, -1, -1, 0);
from++;
if (from <= to)
LCDisplayLine(l, ml, y, from, to, isblank);
}
-void
-LSetRendition(l, r)
-struct layer *l;
-struct mchar *r;
+
+void LSetRendition(struct layer *l, struct mchar *r)
{
struct canvas *cv;
- for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
- {
- display = cv->c_display;
- if (D_blocked)
- continue;
- SetRendition(r);
- }
+ for (cv = l->l_cvlist; cv; cv = cv->c_lnext) {
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ SetRendition(r);
+ }
}
-void
-LWrapChar(l, c, y, top, bot, ins)
-struct layer *l;
-struct mchar *c;
-int y, top, bot;
-int ins;
+
+void LWrapChar(struct layer *l, struct mchar *c, int y, int top, int bot, int ins)
{
struct canvas *cv, *cvlist, *cvlnext;
struct viewport *vp, *evp, **vpp;
@@ -722,207 +671,182 @@ int ins;
#else
bce = 0;
#endif
- if (y != bot)
+
+ if (y != bot) {
+ /* simple case: no scrolling */
+ /* cursor after wrapping */
+ yy = y == l->l_height - 1 ? y : y + 1;
+
+ FOR_EACH_UNPAUSED_CANVAS(l,
{
- /* simple case: no scrolling */
-
- /* cursor after wrapping */
- yy = y == l->l_height - 1 ? y : y + 1;
-
- FOR_EACH_UNPAUSED_CANVAS(l,
- {
- y2 = 0; /* gcc -Wall */
- display = cv->c_display;
- if (D_blocked)
- continue;
- /* find the viewport of the wrapped character */
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- y2 = y + vp->v_yoff;
- yy2 = yy + vp->v_yoff;
- if (yy2 >= vp->v_ys && yy2 <= vp->v_ye && vp->v_xoff >= vp->v_xs && vp->v_xoff <= vp->v_xe)
- break;
- }
- if (vp == 0)
- continue; /* nothing to do, character not visible */
- /* find the viewport of the character at the end of the line*/
- for (evp = cv->c_vplist; evp; evp = evp->v_next)
- if (y2 >= evp->v_ys && y2 <= evp->v_ye && evp->v_xoff + l->l_width - 1 >= evp->v_xs && evp->v_xoff + l->l_width - 1 <= evp->v_xe)
- break; /* gotcha! */
- if (evp == 0 || (ins && vp->v_xoff + l->l_width - 1 > vp->v_ye))
- {
- /* no wrapping possible */
- debug("LWrap: can't wrap!\n");
- cvlist = l->l_cvlist;
- cvlnext = cv->c_lnext;
- l->l_cvlist = cv;
- cv->c_lnext = 0;
- if (ins)
- LInsChar(l, c, 0, yy, 0);
- else
- LPutChar(l, c, 0, yy);
- l->l_cvlist = cvlist;
- cv->c_lnext = cvlnext;
- }
- else
- {
- WrapChar(RECODE_MCHAR(c), vp->v_xoff + l->l_width, y2, vp->v_xoff, -1, vp->v_xoff + l->l_width - 1, -1, ins);
- }
- }
- );
- }
+ y2 = 0; /* gcc -Wall */
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+
+ /* find the viewport of the wrapped character */
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ y2 = y + vp->v_yoff;
+ yy2 = yy + vp->v_yoff;
+ if (yy2 >= vp->v_ys && yy2 <= vp->v_ye && vp->v_xoff >= vp->v_xs && vp->v_xoff <= vp->v_xe)
+ break;
+ }
+
+ if (vp == 0)
+ continue; /* nothing to do, character not visible */
+
+ /* find the viewport of the character at the end of the line*/
+ for (evp = cv->c_vplist; evp; evp = evp->v_next)
+ if (y2 >= evp->v_ys && y2 <= evp->v_ye && evp->v_xoff + l->l_width - 1 >= evp->v_xs && evp->v_xoff + l->l_width - 1 <= evp->v_xe)
+ break; /* gotcha! */
+
+ if (evp == 0 || (ins && vp->v_xoff + l->l_width - 1 > vp->v_ye)) {
+ /* no wrapping possible */
+ debug("LWrap: can't wrap!\n");
+ cvlist = l->l_cvlist;
+ cvlnext = cv->c_lnext;
+ l->l_cvlist = cv;
+ cv->c_lnext = 0;
+
+ if (ins)
+ LInsChar(l, c, 0, yy, 0);
+ else
+ LPutChar(l, c, 0, yy);
+
+ l->l_cvlist = cvlist;
+ cv->c_lnext = cvlnext;
+ }
+ else
+ WrapChar(RECODE_MCHAR(c), vp->v_xoff + l->l_width, y2, vp->v_xoff, -1, vp->v_xoff + l->l_width - 1, -1, ins);
+ });
+ }
else
+ {
+ /* hard case: scroll up*/
+ FOR_EACH_UNPAUSED_CANVAS(l,
{
- /* hard case: scroll up*/
-
- FOR_EACH_UNPAUSED_CANVAS(l,
- {
- display = cv->c_display;
- if (D_blocked)
- continue;
- /* search for wrap viewport */
- for (vpp = &cv->c_vplist; (vp = *vpp); vpp = &vp->v_next)
- {
- yy2 = bot + vp->v_yoff;
- if (yy2 >= vp->v_ys && yy2 <= vp->v_ye && vp->v_xoff >= vp->v_xs && vp->v_xoff + l->l_width - 1 <= vp->v_xe)
- break;
- }
-
- if (vp)
- {
- /* great, can use Wrap on the vp */
- /* temporarily remove vp from cvlist */
- *vpp = vp->v_next;
- }
- if (cv->c_vplist)
- {
- /* scroll all viewports != vp */
- cvlist = l->l_cvlist;
- cvlnext = cv->c_lnext;
- l->l_cvlist = cv;
- cv->c_lnext = 0;
- LScrollV(l, 1, top, bot, bce);
- if (!vp)
- {
- if (ins)
- LInsChar(l, c, 0, bot, 0);
- else
- LPutChar(l, c, 0, bot);
- }
- l->l_cvlist = cvlist;
- cv->c_lnext = cvlnext;
- }
- if (vp)
- {
- /* add vp back to cvlist */
- *vpp = vp;
- top2 = top + vp->v_yoff;
- bot2 = bot + vp->v_yoff;
- if (top2 < vp->v_ys)
- top2 = vp->v_ys;
- WrapChar(RECODE_MCHAR(c), vp->v_xoff + l->l_width, bot2, vp->v_xoff, top2, vp->v_xoff + l->l_width - 1, bot2, ins);
- }
- }
- );
- }
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+
+ /* search for wrap viewport */
+ for (vpp = &cv->c_vplist; (vp = *vpp); vpp = &vp->v_next) {
+ yy2 = bot + vp->v_yoff;
+ if (yy2 >= vp->v_ys && yy2 <= vp->v_ye && vp->v_xoff >= vp->v_xs && vp->v_xoff + l->l_width - 1 <= vp->v_xe)
+ break;
+ }
+
+ if (vp) {
+ /* great, can use Wrap on the vp */
+ /* temporarily remove vp from cvlist */
+ *vpp = vp->v_next;
+ }
+
+ if (cv->c_vplist) {
+ /* scroll all viewports != vp */
+ cvlist = l->l_cvlist;
+ cvlnext = cv->c_lnext;
+ l->l_cvlist = cv;
+ cv->c_lnext = 0;
+ LScrollV(l, 1, top, bot, bce);
+ if (!vp) {
+ if (ins)
+ LInsChar(l, c, 0, bot, 0);
+ else
+ LPutChar(l, c, 0, bot);
+ }
+
+ l->l_cvlist = cvlist;
+ cv->c_lnext = cvlnext;
+ }
+ if (vp) {
+ /* add vp back to cvlist */
+ *vpp = vp;
+ top2 = top + vp->v_yoff;
+ bot2 = bot + vp->v_yoff;
+ if (top2 < vp->v_ys)
+ top2 = vp->v_ys;
+ WrapChar(RECODE_MCHAR(c), vp->v_xoff + l->l_width, bot2, vp->v_xoff, top2, vp->v_xoff + l->l_width - 1, bot2, ins);
+ }
+ });
+ }
}
-void
-LCursorVisibility(l, vis)
-struct layer *l;
-int vis;
+void LCursorVisibility(struct layer *l, int vis)
{
struct canvas *cv;
- for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
- {
- display = cv->c_display;
- if (D_blocked)
- continue;
- if (cv != D_forecv)
- continue;
- CursorVisibility(vis);
- }
+ for (cv = l->l_cvlist; cv; cv = cv->c_lnext) {
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ if (cv != D_forecv)
+ continue;
+ CursorVisibility(vis);
+ }
}
-void
-LSetFlow(l, flow)
-struct layer *l;
-int flow;
+
+void LSetFlow(struct layer *l, int flow)
{
struct canvas *cv;
- for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
- {
- display = cv->c_display;
- if (cv != D_forecv)
- continue;
- SetFlow(flow);
- }
+ for (cv = l->l_cvlist; cv; cv = cv->c_lnext) {
+ display = cv->c_display;
+ if (cv != D_forecv)
+ continue;
+ SetFlow(flow);
+ }
}
-void
-LKeypadMode(l, on)
-struct layer *l;
-int on;
+
+void LKeypadMode(struct layer *l, int on)
{
struct canvas *cv;
- for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
- {
- display = cv->c_display;
- if (D_blocked)
- continue;
- if (cv != D_forecv)
- continue;
- KeypadMode(on);
- }
+ for (cv = l->l_cvlist; cv; cv = cv->c_lnext) {
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ if (cv != D_forecv)
+ continue;
+ KeypadMode(on);
+ }
}
-void
-LCursorkeysMode(l, on)
-struct layer *l;
-int on;
+
+void LCursorkeysMode(struct layer *l, int on)
{
struct canvas *cv;
- for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
- {
- display = cv->c_display;
- if (D_blocked)
- continue;
- if (cv != D_forecv)
- continue;
- CursorkeysMode(on);
- }
+ for (cv = l->l_cvlist; cv; cv = cv->c_lnext) {
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ if (cv != D_forecv)
+ continue;
+ CursorkeysMode(on);
+ }
}
-void
-LMouseMode(l, on)
-struct layer *l;
-int on;
+
+void LMouseMode(struct layer *l, int on)
{
struct canvas *cv;
- for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
- {
- display = cv->c_display;
- if (D_blocked)
- continue;
- if (cv != D_forecv)
- continue;
- MouseMode(on);
- }
+ for (cv = l->l_cvlist; cv; cv = cv->c_lnext) {
+ display = cv->c_display;
+ if (D_blocked)
+ continue;
+ if (cv != D_forecv)
+ continue;
+ MouseMode(on);
+ }
}
-void
-LClearAll(l, uself)
-struct layer *l;
-int uself;
+void LClearAll(struct layer *l, int uself)
{
LClearArea(l, 0, 0, l->l_width - 1, l->l_height - 1, 0, uself);
}
-void
-LRefreshAll(l, isblank)
-struct layer *l;
-int isblank;
+
+void LRefreshAll(struct layer *l, int isblank)
{
struct layer *oldflayer;
int y;
@@ -959,24 +883,25 @@ VA_DECL
fmt = DoNLS(fmt);
(void)vsnprintf(p, sizeof(buf) - 100, fmt, VA_ARGS(ap));
VA_END(ap);
- if (err)
- {
- p += strlen(p);
- *p++ = ':';
- *p++ = ' ';
- strncpy(p, strerror(err), buf + sizeof(buf) - p - 1);
- buf[sizeof(buf) - 1] = 0;
- }
+
+ if (err) {
+ p += strlen(p);
+ *p++ = ':';
+ *p++ = ' ';
+ strncpy(p, strerror(err), buf + sizeof(buf) - p - 1);
+ buf[sizeof(buf) - 1] = 0;
+ }
+
debug2("LMsg('%s') (%#x);\n", buf, (unsigned int)flayer);
- for (display = displays; display; display = display->d_next)
- {
- for (cv = D_cvlist; cv; cv = cv->c_next)
- if (cv->c_layer == flayer)
- break;
- if (cv == 0)
- continue;
- MakeStatus(buf);
- }
+ for (display = displays; display; display = display->d_next) {
+ for (cv = D_cvlist; cv; cv = cv->c_next)
+ if (cv->c_layer == flayer)
+ break;
+
+ if (cv == 0)
+ continue;
+ MakeStatus(buf);
+ }
}
@@ -987,29 +912,25 @@ VA_DECL
* Layer creation / removal
*/
-void
-KillLayerChain(lay)
-struct layer *lay;
+void KillLayerChain(struct layer *lay)
{
struct canvas *cv, *ncv;
struct layer *l, *oldflayer;
oldflayer = flayer;
debug1("KillLayerChain %#x\n", lay);
- for (l = lay; l; l = l->l_next)
- {
- if (l->l_layfn == &WinLf || l->l_layfn == &BlankLf)
- break;
- debug1("- killing %#x\n", l);
- if (oldflayer == l)
- oldflayer = 0;
- for (cv = l->l_cvlist; cv; cv = ncv)
- {
- ncv = cv->c_lnext;
- cv->c_layer = 0;
- cv->c_lnext = 0;
- }
+ for (l = lay; l; l = l->l_next) {
+ if (l->l_layfn == &WinLf || l->l_layfn == &BlankLf)
+ break;
+ debug1("- killing %#x\n", l);
+ if (oldflayer == l)
+ oldflayer = 0;
+ for (cv = l->l_cvlist; cv; cv = ncv) {
+ ncv = cv->c_lnext;
+ cv->c_layer = 0;
+ cv->c_lnext = 0;
}
+ }
flayer = lay;
while (flayer != l)
ExitOverlayPage();
@@ -1018,11 +939,7 @@ struct layer *lay;
-int
-InitOverlayPage(datasize, lf, block)
-int datasize;
-struct LayFuncs *lf;
-int block;
+int InitOverlayPage(int datasize, struct LayFuncs *lf, int block)
{
char *data;
struct layer *newlay;
@@ -1035,67 +952,62 @@ int block;
if (display && D_forecv->c_layer == flayer)
cv = D_forecv; /* work only on this cv! */
- if ((newlay = (struct layer *)calloc(1, sizeof(struct layer))) == 0)
- {
- Msg(0, "No memory for layer struct");
+ if ((newlay = (struct layer *)calloc(1, sizeof(struct layer))) == 0) {
+ Msg(0, "No memory for layer struct");
return -1;
- }
+ }
debug2("Entering new layer on top of %#x: %#x\n", (unsigned int)flayer, newlay);
data = 0;
- if (datasize)
- {
- if ((data = calloc(1, datasize)) == 0)
- {
- free((char *)newlay);
- Msg(0, "No memory for layer data");
- return -1;
- }
+ if (datasize) {
+ if ((data = calloc(1, datasize)) == 0) {
+ free((char *)newlay);
+ Msg(0, "No memory for layer data");
+ return -1;
}
-
+ }
p = Layer2Window(flayer);
- if (p && (p->w_savelayer == flayer || (block && flayer->l_next == 0)))
- {
- if (p->w_savelayer && p->w_savelayer != flayer && p->w_savelayer->l_cvlist == 0)
- KillLayerChain(p->w_savelayer);
- p->w_savelayer = newlay;
- }
+ if (p && (p->w_savelayer == flayer || (block && flayer->l_next == 0))) {
+ if (p->w_savelayer && p->w_savelayer != flayer && p->w_savelayer->l_cvlist == 0)
+ KillLayerChain(p->w_savelayer);
+ p->w_savelayer = newlay;
+ }
- if (cv && flayer->l_next == 0 && !block)
- {
- struct display *olddisplay = display;
- display = cv->c_display;
- RemoveStatus();
- display = olddisplay;
-
- /* new branch -> just get canvas vps */
- for (cvpp = &flayer->l_cvlist; (cvp = *cvpp); cvpp = &cvp->c_lnext)
- if (cvp == cv)
- break;
- ASSERT(cvp);
- *cvpp = cv->c_lnext;
- newlay->l_cvlist = cv;
- cv->c_lnext = 0;
- cv->c_layer = newlay;
- }
- else
- {
- LAY_DISPLAYS(flayer, RemoveStatus());
- if (block)
- debug("layer is blocking\n");
- if (block && flayer->l_layfn == &WinLf)
- {
- debug("...and is first, so window gets blocked\n");
- ASSERT(p->w_blocked == 0);
- p->w_blocked++;
- newlay->l_blocking = 1;
- }
- /* change all canvases */
- newlay->l_cvlist = flayer->l_cvlist;
- for (cvp = newlay->l_cvlist; cvp; cvp = cvp->c_lnext)
- cvp->c_layer = newlay;
- flayer->l_cvlist = 0;
+ if (cv && flayer->l_next == 0 && !block) {
+ struct display *olddisplay = display;
+ display = cv->c_display;
+ RemoveStatus();
+ display = olddisplay;
+
+ /* new branch -> just get canvas vps */
+ for (cvpp = &flayer->l_cvlist; (cvp = *cvpp); cvpp = &cvp->c_lnext)
+ if (cvp == cv)
+ break;
+
+ ASSERT(cvp);
+ *cvpp = cv->c_lnext;
+ newlay->l_cvlist = cv;
+ cv->c_lnext = 0;
+ cv->c_layer = newlay;
+ }
+ else {
+ LAY_DISPLAYS(flayer, RemoveStatus());
+ if (block)
+ debug("layer is blocking\n");
+ if (block && flayer->l_layfn == &WinLf) {
+ debug("...and is first, so window gets blocked\n");
+ ASSERT(p->w_blocked == 0);
+ p->w_blocked++;
+ newlay->l_blocking = 1;
}
+
+ /* change all canvases */
+ newlay->l_cvlist = flayer->l_cvlist;
+
+ for (cvp = newlay->l_cvlist; cvp; cvp = cvp->c_lnext)
+ cvp->c_layer = newlay;
+ flayer->l_cvlist = 0;
+ }
newlay->l_width = flayer->l_width;
newlay->l_height = flayer->l_height;
newlay->l_encoding = 0;
@@ -1108,10 +1020,10 @@ int block;
return 0;
}
+
extern struct layout *layouts;
-void
-ExitOverlayPage()
+void ExitOverlayPage()
{
struct layer *oldlay;
struct win *p;
@@ -1122,33 +1034,30 @@ ExitOverlayPage()
ASSERT(flayer);
debug1("Exiting layer %#x\n", (unsigned int)flayer);
oldlay = flayer;
- if (oldlay->l_data)
- {
- if (oldlay->l_layfn->lf_LayFree)
- LayFree(oldlay->l_data);
- free(oldlay->l_data);
- }
-
+ if (oldlay->l_data) {
+ if (oldlay->l_layfn->lf_LayFree)
+ LayFree(oldlay->l_data);
+ free(oldlay->l_data);
+ }
p = Layer2Window(flayer);
flayer = oldlay->l_next;
- if (flayer->l_layfn == &WinLf)
- {
- if (oldlay->l_blocking)
- {
- ASSERT(p->w_blocked > 0);
- p->w_blocked--;
- debug1("layer was blocking, -> w_blocked now %d\n", p->w_blocked);
- }
- /* don't warp dead layers: check cvlist */
- if (p->w_blocked && p->w_savelayer && p->w_savelayer != flayer && oldlay->l_cvlist)
- {
- debug("warping to top of blocking chain!\n");
- /* warp ourself into savelayer */
- flayer = p->w_savelayer;
- doredisplay = 1;
- }
+ if (flayer->l_layfn == &WinLf) {
+ if (oldlay->l_blocking) {
+ ASSERT(p->w_blocked > 0);
+ p->w_blocked--;
+ debug1("layer was blocking, -> w_blocked now %d\n", p->w_blocked);
+ }
+
+ /* don't warp dead layers: check cvlist */
+ if (p->w_blocked && p->w_savelayer && p->w_savelayer != flayer && oldlay->l_cvlist) {
+ debug("warping to top of blocking chain!\n");
+ /* warp ourself into savelayer */
+ flayer = p->w_savelayer;
+ doredisplay = 1;
}
+ }
+
if (p && p->w_savelayer == oldlay)
p->w_savelayer = flayer;
#ifdef COPY_PASTE
@@ -1159,24 +1068,23 @@ ExitOverlayPage()
for (lay = layouts; lay; lay = lay->lay_next)
for (cv = lay->lay_cvlist; cv; cv = cv->c_next)
if (cv->c_layer == oldlay)
- cv->c_layer = flayer;
+ cv->c_layer = flayer;
/* add all canvases back into next layer's canvas list */
- for (ocv = 0, cv = oldlay->l_cvlist; cv; cv = cv->c_lnext)
- {
- cv->c_layer = flayer;
- ocv = cv;
- }
- if (ocv)
- {
- cv = flayer->l_cvlist;
- ocv->c_lnext = 0;
- flayer->l_cvlist = oldlay->l_cvlist;
- /* redisplay only the warped cvs */
- if (doredisplay)
- LRefreshAll(flayer, 0);
- ocv->c_lnext = cv;
- }
+ for (ocv = 0, cv = oldlay->l_cvlist; cv; cv = cv->c_lnext) {
+ cv->c_layer = flayer;
+ ocv = cv;
+ }
+ if (ocv) {
+ cv = flayer->l_cvlist;
+ ocv->c_lnext = 0;
+ flayer->l_cvlist = oldlay->l_cvlist;
+
+ /* redisplay only the warped cvs */
+ if (doredisplay)
+ LRefreshAll(flayer, 0);
+ ocv->c_lnext = cv;
+ }
oldlay->l_cvlist = 0;
LayerCleanupMemory(oldlay);
free((char *)oldlay);
@@ -1184,12 +1092,10 @@ ExitOverlayPage()
LaySetCursor();
}
-int
-LayProcessMouse(struct layer *l, unsigned char ch)
+int LayProcessMouse(struct layer *l, unsigned char ch)
{
/* XXX: Make sure the layer accepts mouse events */
int len;
-
if (l->l_mouseevent.len >= sizeof(l->l_mouseevent.buffer))
return -1;
@@ -1198,110 +1104,88 @@ LayProcessMouse(struct layer *l, unsigned char ch)
return (l->l_mouseevent.len == sizeof(l->l_mouseevent.buffer));
}
-void
-LayProcessMouseSwitch(struct layer *l, int s)
+void LayProcessMouseSwitch(struct layer *l, int s)
{
if ((l->l_mouseevent.start = s))
- {
- l->l_mouseevent.len = 0;
- }
+ l->l_mouseevent.len = 0;
}
-void LayPause(layer, pause)
-struct layer *layer;
-int pause;
+
+void LayPause(struct layer *layer, int pause)
{
struct canvas *cv;
- struct display *olddisplay = display;
int line;
struct win *win;
-
pause = !!pause;
if (layer->l_pause.d == pause)
return;
- if ((layer->l_pause.d = pause))
- {
- /* Start pausing */
- layer->l_pause.top = layer->l_pause.bottom = -1;
- return;
- }
+ if ((layer->l_pause.d = pause)) {
+ /* Start pausing */
+ layer->l_pause.top = layer->l_pause.bottom = -1;
+ return;
+ }
/* Unpause. So refresh the regions in the displays! */
- if (layer->l_pause.top == -1 &&
- layer->l_pause.bottom == -1)
+ if (layer->l_pause.top == -1 && layer->l_pause.bottom == -1)
return;
- if (layer->l_layfn == &WinLf) /* Currently, this will always be the case! */
+ if (layer->l_layfn == &WinLf) /* Currently, this will always be the case! */
win = layer->l_data;
else
win = NULL;
- for (cv = layer->l_cvlist; cv; cv = cv->c_lnext)
- {
- struct viewport *vp;
+ for (cv = layer->l_cvlist; cv; cv = cv->c_lnext) {
+ struct viewport *vp;
- if (!cv->c_slorient)
- continue; /* Wasn't split, so already updated. */
+ if (!cv->c_slorient)
+ continue; /* Wasn't split, so already updated. */
+ display = cv->c_display;
+ for (vp = cv->c_vplist; vp; vp = vp->v_next) {
+ for (line = layer->l_pause.top; line <= layer->l_pause.bottom; line++) {
+ int xs, xe;
+ if (line + vp->v_yoff >= vp->v_ys && line + vp->v_yoff <= vp->v_ye &&
+ ((xs = layer->l_pause.left[line]) >= 0) &&
+ ((xe = layer->l_pause.right[line]) >= 0)) {
+ xs += vp->v_xoff;
+ xe += vp->v_xoff;
- display = cv->c_display;
-
- for (vp = cv->c_vplist; vp; vp = vp->v_next)
- {
- for (line = layer->l_pause.top; line <= layer->l_pause.bottom; line++)
- {
- int xs, xe;
-
- if (line + vp->v_yoff >= vp->v_ys && line + vp->v_yoff <= vp->v_ye &&
- ((xs = layer->l_pause.left[line]) >= 0) &&
- ((xe = layer->l_pause.right[line]) >= 0))
- {
- xs += vp->v_xoff;
- xe += vp->v_xoff;
-
- if (xs < vp->v_xs) xs = vp->v_xs;
- if (xe > vp->v_xe) xe = vp->v_xe;
+ if (xs < vp->v_xs) xs = vp->v_xs;
+ if (xe > vp->v_xe) xe = vp->v_xe;
#if defined(DW_CHARS) && defined(UTF8)
- if (layer->l_encoding == UTF8 && xe < vp->v_xe && win)
- {
- struct mline *ml = win->w_mlines + line;
- if (dw_left(ml, xe, UTF8))
- xe++;
- }
+ if (layer->l_encoding == UTF8 && xe < vp->v_xe && win) {
+ struct mline *ml = win->w_mlines + line;
+ if (dw_left(ml, xe, UTF8))
+ xe++;
+ }
#endif
- if (xs <= xe)
- RefreshLine(line + vp->v_yoff, xs, xe, 0);
- }
- }
- }
+ if (xs <= xe)
+ RefreshLine(line + vp->v_yoff, xs, xe, 0);
+ }
+ }
+ }
- if (cv == D_forecv)
- {
- int cx = layer->l_x + cv->c_xoff;
- int cy = layer->l_y + cv->c_yoff;
+ if (cv == D_forecv) {
+ int cx = layer->l_x + cv->c_xoff;
+ int cy = layer->l_y + cv->c_yoff;
- if (cx < cv->c_xs) cx = cv->c_xs;
- if (cy < cv->c_ys) cy = cv->c_ys;
- if (cx > cv->c_xe) cx = cv->c_xe;
- if (cy > cv->c_ye) cy = cv->c_ye;
+ if (cx < cv->c_xs) cx = cv->c_xs;
+ if (cy < cv->c_ys) cy = cv->c_ys;
+ if (cx > cv->c_xe) cx = cv->c_xe;
+ if (cy > cv->c_ye) cy = cv->c_ye;
- GotoPos(cx, cy);
- }
+ GotoPos(cx, cy);
}
+ }
for (line = layer->l_pause.top; line <= layer->l_pause.bottom; line++)
layer->l_pause.left[line] = layer->l_pause.right[line] = -1;
- olddisplay = display;
}
-void
-LayPauseUpdateRegion(layer, xs, xe, ys, ye)
-struct layer *layer;
-int xs, xe;
-int ys, ye;
+void LayPauseUpdateRegion(struct layer *layer, int xs, int xe, int ys, int ye)
{
if (!layer->l_pause.d)
return;
@@ -1314,36 +1198,30 @@ int ys, ye;
if (layer->l_pause.top == -1 || layer->l_pause.top > ys)
layer->l_pause.top = ys;
- if (layer->l_pause.bottom < ye)
- {
- layer->l_pause.bottom = ye;
- if (layer->l_pause.lines <= ye)
- {
- int o = layer->l_pause.lines;
- layer->l_pause.lines = ye + 32;
- layer->l_pause.left = realloc(layer->l_pause.left, sizeof(int) * layer->l_pause.lines);
- layer->l_pause.right = realloc(layer->l_pause.right, sizeof(int) * layer->l_pause.lines);
- while (o < layer->l_pause.lines)
- {
- layer->l_pause.left[o] = layer->l_pause.right[o] = -1;
- o++;
- }
- }
+ if (layer->l_pause.bottom < ye) {
+ layer->l_pause.bottom = ye;
+
+ if (layer->l_pause.lines <= ye) {
+ int o = layer->l_pause.lines;
+ layer->l_pause.lines = ye + 32;
+ layer->l_pause.left = realloc(layer->l_pause.left, sizeof(int) * layer->l_pause.lines);
+ layer->l_pause.right = realloc(layer->l_pause.right, sizeof(int) * layer->l_pause.lines);
+ while (o < layer->l_pause.lines) {
+ layer->l_pause.left[o] = layer->l_pause.right[o] = -1;
+ o++;
+ }
}
-
- while (ys <= ye)
- {
- if (layer->l_pause.left[ys] == -1 || layer->l_pause.left[ys] > xs)
- layer->l_pause.left[ys] = xs;
+ }
+ while (ys <= ye) {
+ if (layer->l_pause.left[ys] == -1 || layer->l_pause.left[ys] > xs)
+ layer->l_pause.left[ys] = xs;
if (layer->l_pause.right[ys] < xe)
- layer->l_pause.right[ys] = xe;
+ layer->l_pause.right[ys] = xe;
ys++;
- }
+ }
}
-void
-LayerCleanupMemory(layer)
-struct layer *layer;
+void LayerCleanupMemory(struct layer *layer)
{
if (layer->l_pause.left)
free(layer->l_pause.left);