summaryrefslogtreecommitdiff
path: root/layer.c
diff options
context:
space:
mode:
Diffstat (limited to 'layer.c')
-rw-r--r--layer.c227
1 files changed, 184 insertions, 43 deletions
diff --git a/layer.c b/layer.c
index dfd40a8..5bd37aa 100644
--- a/layer.c
+++ b/layer.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1993
+/* Copyright (c) 1993-2002
* Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
* Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
* Copyright (c) 1987 Oliver Laumann
@@ -34,10 +34,8 @@ RCS_ID("$Id: search.c,v 1.2 1994/05/31 12:32:57 mlschroe Exp $ FAU")
extern struct display *display, *displays;
-extern struct mline mline_blank;
-extern struct mline mline_null;
-extern struct mchar mchar_null;
-extern struct mchar mchar_blank;
+extern struct mline mline_blank, mline_null;
+extern struct mchar mchar_blank, mchar_null;
extern struct layer *flayer; /* sigh */
extern struct LayFuncs WinLf;
@@ -71,10 +69,22 @@ int off;
#endif
#ifdef COLOR
mml.color = ml->color + off;
+# ifdef COLORS256
+ mml.colorx = ml->colorx + off;
+# endif
#endif
return &mml;
}
+#ifdef UTF8
+# define RECODE_MCHAR(mc) ((l->l_encoding == UTF8) != (D_encoding == UTF8) ? recode_mchar(mc, l->l_encoding, D_encoding) : (mc))
+# define RECODE_MLINE(ml) ((l->l_encoding == UTF8) != (D_encoding == UTF8) ? recode_mline(ml, l->l_width, l->l_encoding, D_encoding) : (ml))
+#else
+# define RECODE_MCHAR(mc) (mc)
+# define RECODE_MLINE(ml) (ml)
+#endif
+
+
void
LGotoPos(l, x, y)
struct layer *l;
@@ -117,9 +127,10 @@ int x, y;
}
void
-LScrollH(l, n, y, xs, xe, ol)
+LScrollH(l, n, y, xs, xe, bce, ol)
struct layer *l;
int n, y, xs, xe;
+int bce;
struct mline *ol;
{
struct canvas *cv;
@@ -143,7 +154,7 @@ struct mline *ol;
if (xs2 > xe2)
continue;
display = cv->c_display;
- ScrollH(y2, xs2, xe2, n, ol ? mloff(ol, -vp->v_xoff) : 0);
+ ScrollH(y2, xs2, xe2, n, bce, ol ? mloff(ol, -vp->v_xoff) : 0);
if (xe2 - xs2 == xe - xs)
continue;
if (n > 0)
@@ -166,10 +177,11 @@ struct mline *ol;
}
void
-LScrollV(l, n, ys, ye)
+LScrollV(l, n, ys, ye, bce)
struct layer *l;
int n;
int ys, ye;
+int bce;
{
struct canvas *cv;
struct viewport *vp;
@@ -195,9 +207,9 @@ int ys, ye;
continue;
display = cv->c_display;
#if 0
- ScrollV(xs2, ys2, xe2, ye2, n);
+ ScrollV(xs2, ys2, xe2, ye2, n, bce);
#else
- ScrollV(vp->v_xs, ys2, vp->v_xe, ye2, n);
+ ScrollV(vp->v_xs, ys2, vp->v_xe, ye2, n, bce);
#endif
debug2("LScrollV: %d %d", ys, ye);
debug2(" -> %d %d\n", ys2, ye2);
@@ -235,6 +247,7 @@ struct mline *ol;
struct viewport *vp;
int xs2, xe2, y2, f;
struct mchar *c2, cc;
+ struct mline *rol;
for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
for (vp = cv->c_vplist; vp; vp = vp->v_next)
@@ -268,7 +281,8 @@ struct mline *ol;
if (xs2 > xe2)
continue;
display = cv->c_display;
- InsChar(c2, xs2, xe2, y2, mloff(ol, -vp->v_xoff));
+ rol = RECODE_MLINE(ol);
+ InsChar(RECODE_MCHAR(c2), xs2, xe2, y2, mloff(rol, -vp->v_xoff));
if (f)
RefreshArea(xs2, y2, xs2, y2, 1);
}
@@ -291,25 +305,82 @@ int x, y;
}
#endif
for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
+ {
+ display = cv->c_display;
+ 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;
+{
+ struct canvas *cv;
+ struct viewport *vp;
+ char *s2;
+ int xs2, xe2, y2;
+
+ 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;
+ }
+#endif
+ for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
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)
+ 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;
- GotoPos(x2, y2);
- SetRendition(c);
- PUTCHARLP(c->image);
- if (D_AM && !D_CLP && x2 == D_width - 1)
- GotoPos(x2, y2);
+ GotoPos(xs2, y2);
+ SetRendition(r);
+ s2 = s + xs2 - x - vp->v_xoff;
+#ifdef UTF8
+ if (D_encoding == UTF8 && l->l_encoding != UTF8 && (r->font || 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
-LPutStr(l, s, n, r, x, y)
+LPutWinMsg(l, s, n, r, x, y)
struct layer *l;
char *s;
int n;
@@ -319,7 +390,8 @@ int x, y;
struct canvas *cv;
struct viewport *vp;
char *s2;
- int xs2, xe2, y2;
+ int xs2, xe2, y2, len, len2;
+ struct mchar or;
if (x + n > l->l_width)
n = l->l_width - x;
@@ -330,6 +402,9 @@ int x, y;
return;
}
#endif
+ len = strlen(s);
+ if (len > n)
+ len = n;
for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
for (vp = cv->c_vplist; vp; vp = vp->v_next)
{
@@ -347,16 +422,34 @@ int x, y;
display = cv->c_display;
GotoPos(xs2, y2);
SetRendition(r);
- s2 = s + xs2 - x - vp->v_xoff;
+ len2 = xe2 - (x + vp->v_xoff) + 1;
+ if (len2 > len)
+ len2 = len;
+ if (!PutWinMsg(s, xs2 - x - vp->v_xoff, len2))
+ {
+ s2 = s + xs2 - x - vp->v_xoff;
+ while (len2-- > 0)
+ {
+ PUTCHARLP(*s2++);
+ xs2++;
+ }
+ }
+ else
+ 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(*s2++);
+ PUTCHARLP(' ');
}
}
void
-LClearLine(l, y, xs, xe, ol)
+LClearLine(l, y, xs, xe, bce, ol)
struct layer *l;
-int xs, xe;
+int xs, xe, bce;
struct mline *ol;
{
struct canvas *cv;
@@ -383,14 +476,15 @@ struct mline *ol;
if (xs2 > xe2)
continue;
display = cv->c_display;
- DisplayLine(ol ? mloff(ol, -vp->v_xoff) : &mline_null, &mline_blank, y2, xs2, xe2);
+ ClearLine(ol ? mloff(RECODE_MLINE(ol), -vp->v_xoff) : (struct mline *)0, y2, xs2, xe2, bce);
}
}
void
-LClear(l, xs, ys, xe, ye, uself)
+LClearArea(l, xs, ys, xe, ye, bce, uself)
struct layer *l;
int xs, ys, xe, ye;
+int bce;
int uself;
{
struct canvas *cv;
@@ -440,14 +534,14 @@ int uself;
if (ye2 != ye + vp->v_yoff)
xe2 = xce;
display = cv->c_display;
- Clear(xs2, ys2, xcs, xce, xe2, ye2, uself);
+ 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;
- Clear(xs2, ys2, vp->v_xs, vp->v_xe, xe2, ye2, uself);
+ ClearArea(xs2, ys2, vp->v_xs, vp->v_xe, xe2, ye2, bce, uself);
#endif
}
}
@@ -486,11 +580,33 @@ int isblank;
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(ml, -vp->v_xoff), y2, xs2, xe2);
+ 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;
+{
+ 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++;
+ }
+#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;
@@ -516,7 +632,13 @@ int ins;
struct canvas *cv, *cvlist, *cvlnext;
struct viewport *vp, *evp, **vpp;
int yy, y2, yy2, top2, bot2;
+ int bce;
+#ifdef COLOR
+ bce = rend_getbg(c);
+#else
+ bce = 0;
+#endif
if (y != bot)
{
/* simple case: no scrolling */
@@ -526,6 +648,7 @@ int ins;
for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
{
+ y2 = 0; /* gcc -Wall */
display = cv->c_display;
/* find the viewport of the wrapped character */
for (vp = cv->c_vplist; vp; vp = vp->v_next)
@@ -557,7 +680,9 @@ int ins;
cv->c_lnext = cvlnext;
}
else
- WrapChar(c, vp->v_xoff + l->l_width, y2, vp->v_xoff, -1, vp->v_xoff + l->l_width - 1, -1, ins);
+ {
+ 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
@@ -588,7 +713,7 @@ int ins;
cvlnext = cv->c_lnext;
l->l_cvlist = cv;
cv->c_lnext = 0;
- LScrollV(l, 1, top, bot);
+ LScrollV(l, 1, top, bot, bce);
if (!vp)
{
if (ins)
@@ -607,7 +732,7 @@ int ins;
bot2 = bot + vp->v_yoff;
if (top2 < vp->v_ys)
top2 = vp->v_ys;
- WrapChar(c, vp->v_xoff + l->l_width, bot2, vp->v_xoff, top2, vp->v_xoff + l->l_width - 1, bot2, ins);
+ WrapChar(RECODE_MCHAR(c), vp->v_xoff + l->l_width, bot2, vp->v_xoff, top2, vp->v_xoff + l->l_width - 1, bot2, ins);
}
}
}
@@ -674,34 +799,49 @@ int on;
}
}
+void
+LMouseMode(l, on)
+struct layer *l;
+int on;
+{
+ struct canvas *cv;
+ for (cv = l->l_cvlist; cv; cv = cv->c_lnext)
+ {
+ display = cv->c_display;
+ if (cv != D_forecv)
+ continue;
+ MouseMode(on);
+ }
+}
+
/*******************************************************************/
void
-ClearLayer(l, uself)
+LClearAll(l, uself)
struct layer *l;
int uself;
{
- LClear(l, 0, 0, l->l_width - 1, l->l_height - 1, uself);
+ LClearArea(l, 0, 0, l->l_width - 1, l->l_height - 1, 0, uself);
}
void
-RedisplayLayer(l, isblank)
+LRefreshAll(l, isblank)
struct layer *l;
int isblank;
{
struct layer *oldflayer;
int y;
- debug1("RedisplayLayer isblank=%d\n", isblank);
+ debug1("LRefreshAll isblank=%d\n", isblank);
oldflayer = flayer;
flayer = l;
if (!isblank)
- LClear(l, 0, 0, l->l_width - 1, l->l_height - 1, 0);
+ LClearArea(l, 0, 0, l->l_width - 1, l->l_height - 1, 0, 0);
/* signal full refresh */
- RedisplayLine(-1, -1, -1, 1);
+ LayRedisplayLine(-1, -1, -1, 1);
for (y = 0; y < l->l_height; y++)
- RedisplayLine(y, 0, l->l_width - 1, 1);
+ LayRedisplayLine(y, 0, l->l_width - 1, 1);
flayer = oldflayer;
}
@@ -824,12 +964,13 @@ int block;
}
newlay->l_width = flayer->l_width;
newlay->l_height = flayer->l_height;
+ newlay->l_encoding = 0;
newlay->l_layfn = lf;
newlay->l_data = data;
newlay->l_next = flayer;
newlay->l_bottom = flayer->l_bottom;
flayer = newlay;
- Restore();
+ LayRestore();
return 0;
}
@@ -887,13 +1028,13 @@ ExitOverlayPage()
flayer->l_cvlist = oldlay->l_cvlist;
/* redisplay only the warped cvs */
if (doredisplay)
- RedisplayLayer(flayer, 0);
+ LRefreshAll(flayer, 0);
ocv->c_lnext = cv;
}
oldlay->l_cvlist = 0;
free((char *)oldlay);
- Restore();
- SetCursor();
+ LayRestore();
+ LaySetCursor();
}
void