summaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorjnweiger <jnweiger>2005-12-16 16:24:30 +0000
committerjnweiger <jnweiger>2005-12-16 16:24:30 +0000
commit32462f2e30134ec5b785571151e848ab4c2824ee (patch)
tree23919ad44df8d2c39324eefc444d2bc7bce6aead /src/window.c
parenta1df972a70120e12d419eec7c2e53efb532db545 (diff)
downloadscreen-32462f2e30134ec5b785571151e848ab4c2824ee.tar.gz
historic version screen-3.2
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c564
1 files changed, 283 insertions, 281 deletions
diff --git a/src/window.c b/src/window.c
index bf6f30e..81aad6d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -22,7 +22,7 @@
* Patrick Wolfe (pat@kai.com, kailand!pat)
* Bart Schaefer (schaefer@cse.ogi.edu)
* Nathan Glasser (nathan@brokaw.lcs.mit.edu)
- * Larry W. Virden (lwv27%cas.BITNET@CUNYVM.CUNY.Edu)
+ * Larry W. Virden (lvirden@cas.org)
* Howard Chu (hyc@hanauma.jpl.nasa.gov)
* Tim MacKenzie (tym@dibbler.cs.monash.edu.au)
* Markku Jarvinen (mta@{cc,cs,ee}.tut.fi)
@@ -31,9 +31,8 @@
****************************************************************
*/
-#ifndef lint
- static char rcs_id[] = "$Id$ FAU";
-#endif
+#include "rcs.h"
+RCS_ID("$Id$ FAU")
#include <stdio.h>
#include <sys/types.h>
@@ -42,8 +41,10 @@
#include <sys/ioctl.h>
#endif
-#ifdef MIPS
-extern int errno;
+#ifdef ISC
+# include <sys/tty.h>
+# include <sys/sioctl.h>
+# include <sys/pty.h>
#endif
#include "config.h"
@@ -51,30 +52,30 @@ extern int errno;
#include "extern.h"
static void FreeScrollback __P((struct win *));
+static void CheckMaxSize __P((int));
static int ResizeHistArray __P((struct win *, char ***, int, int, int));
static int ResizeScreenArray __P((struct win *, char ***, int, int, int));
static void FreeArray __P((char ***, int));
-extern TermcapCOLS, TermcapROWS;
extern int maxwidth;
-extern int default_width, default_height, screenwidth, screenheight;
+extern struct display *display, *displays;
extern char *blank, *null, *OldImage, *OldAttr;
-extern char *OldFont, *LastMsg;
-extern struct win *wtab[], *fore;
-extern int WinList, ForeNum;
-extern char *Z0, *Z1, *WS;
+extern char *OldFont;
+extern struct win *windows;
extern int Z0width, Z1width;
-extern int Detached;
+#ifdef NETHACK
+extern int nethackflag;
+#endif
-#ifdef TIOCSWINSZ
+#if defined(TIOCGWINSZ) || defined(TIOCSWINSZ)
struct winsize glwz;
#endif
/*
* ChangeFlag: 0: try to modify no window
- * 1: modify fore (and try to modify no other)
+ * 1: modify fore (and try to modify no d_other) + redisplay
* 2: modify all windows
*
* Note: Activate() is only called if change_flag == 1
@@ -85,115 +86,146 @@ void
CheckScreenSize(change_flag)
int change_flag;
{
- int width, height, n;
+ int wi, he;
struct win *p;
+ struct layer *oldlay;
- if (Detached)
+ if (display == 0)
{
- debug("CheckScreenSize: Detached -> No check.\n");
+ debug("CheckScreenSize: No display -> no check.\n");
return;
}
-#ifdef TIOCSWINSZ
- if (ioctl(0, TIOCGWINSZ, &glwz) != 0)
+ oldlay = d_lay;
+#ifdef TIOCGWINSZ
+ if (ioctl(d_userfd, TIOCGWINSZ, &glwz) != 0)
{
- debug1("CheckScreenSize: ioctl(0, TIOCGWINSZ) errno %d\n", errno);
- width = TermcapCOLS;
- height = TermcapROWS;
+ debug2("CheckScreenSize: ioctl(%d, TIOCGWINSZ) errno %d\n", d_userfd, errno);
+ wi = CO;
+ he = LI;
}
else
{
- width = glwz.ws_col;
- height = glwz.ws_row;
- if (width == 0)
- width = TermcapCOLS;
- if (height == 0)
- height = TermcapROWS;
+ wi = glwz.ws_col;
+ he = glwz.ws_row;
+ if (wi == 0)
+ wi = CO;
+ if (he == 0)
+ he = LI;
}
#else
- width = TermcapCOLS;
- height = TermcapROWS;
+ wi = CO;
+ he = LI;
#endif
- debug2("CheckScreenSize: screen is (%d,%d)\n", width, height);
+ debug2("CheckScreenSize: screen is (%d,%d)\n", wi, he);
if (change_flag == 2)
{
- for (n = WinList; n != -1; n = p->WinLink)
- {
- p = wtab[n];
- ChangeWindowSize(p, width, height);
- }
+ debug("Trying to adapt all windows (-A)\n");
+ for (p = windows; p; p = p->w_next)
+ if (p->w_display == 0 || p->w_display == display)
+ ChangeWindowSize(p, wi, he);
}
- if (screenwidth == width && screenheight == height)
+ if (d_width == wi && d_height == he)
{
debug("CheckScreenSize: No change -> return.\n");
return;
}
- ChangeScreenSize(width, height, change_flag);
- if (change_flag == 1 && WinList != -1) /* was HasWindow */
- Activate ();
+ ChangeScreenSize(wi, he, change_flag);
+ if (change_flag == 1)
+ Activate(d_fore ? d_fore->w_norefresh : 0);
+ if (d_lay != oldlay)
+ {
+#ifdef NETHACK
+ if (nethackflag)
+ Msg(0, "KAABLAMM!!! You triggered a land mine!");
+ else
+#endif
+ Msg(0, "Aborted because of window size change.");
+ }
}
void
-ChangeScreenSize(width, height, change_fore)
-int width, height;
+ChangeScreenSize(wi, he, change_fore)
+int wi, he;
int change_fore;
{
struct win *p;
- int n, wwi;
+ int wwi;
- if (screenwidth == width && screenheight == height)
+ if (d_width == wi && d_height == he)
{
debug("ChangeScreenSize: no change\n");
return;
}
- debug3("ChangeScreenSize to (%d,%d) (change_fore: %d)\n",width, height, change_fore);
- screenwidth = width;
- screenheight = height;
+ debug2("ChangeScreenSize from (%d,%d) ", d_width, d_height);
+ debug3("to (%d,%d) (change_fore: %d)\n",wi, he, change_fore);
+ d_width = wi;
+ d_height = he;
- if (WS)
+ CheckMaxSize(wi);
+ if (CWS)
{
- default_width = TermcapCOLS;
- default_height = TermcapROWS;
+ d_defwidth = CO;
+ d_defheight = LI;
}
else
{
- if (Z0 && (width == Z0width || width == Z1width) &&
- (TermcapCOLS == Z0width || TermcapCOLS == Z1width))
- default_width = TermcapCOLS;
+ if (CZ0 && (wi == Z0width || wi == Z1width) &&
+ (CO == Z0width || CO == Z1width))
+ d_defwidth = CO;
else
- default_width = width;
- default_height = height;
+ d_defwidth = wi;
+ d_defheight = he;
}
- debug2("Default size: (%d,%d)\n",default_width, default_height);
+ debug2("Default size: (%d,%d)\n", d_defwidth, d_defheight);
if (change_fore)
+ DoResize(wi, he);
+ if (CWS == NULL && displays->_d_next == 0)
{
- if (WinList != -1 && change_fore) /* was HasWindow */
+ /* adapt all windows - to be removed ? */
+ for (p = windows; p; p = p->w_next)
{
- debug("Trying to change fore.\n");
- ChangeWindowSize(fore, width, height);
- }
- }
- if (WS == NULL)
- {
- /* We have to adapt all windows */
- for (n = WinList; n != -1; n = p->WinLink)
- {
- p = wtab[n];
- debug1("Trying to change window %d.\n",n);
- wwi = width;
- if (Z0 && (width==Z0width || width==Z1width))
+ debug1("Trying to change window %d.\n", p->w_number);
+ wwi = wi;
+ if (CZ0 && (wi == Z0width || wi == Z1width))
{
- if (p->width > (Z0width + Z1width) / 2)
+ if (p->w_width > (Z0width + Z1width) / 2)
wwi = Z0width;
else
wwi = Z1width;
}
- ChangeWindowSize(p, wwi, height);
+ ChangeWindowSize(p, wwi, he);
}
}
}
+void
+DoResize(wi, he)
+int wi, he;
+{
+ struct layer *oldlay;
+ int q = 0;
+
+ for(;;)
+ {
+ oldlay = d_lay;
+ for (; d_lay; d_lay = d_lay->l_next)
+ {
+ d_layfn = d_lay->l_layfn;
+ if ((q = Resize(wi, he)))
+ break;
+ }
+ d_lay = oldlay;
+ d_layfn = d_lay->l_layfn;
+ if (q == 0)
+ break;
+ ExitOverlayPage();
+ }
+}
+
+#ifdef COPY_PASTE
+
int
ChangeScrollback(p, histheight, histwidth)
struct win *p;
@@ -202,7 +234,7 @@ int histheight, histwidth;
if (histheight > MAXHISTHEIGHT)
histheight = MAXHISTHEIGHT;
debug2("ChangeScrollback(..., %d, %d)\n", histheight, histwidth);
- debug2(" was %d, %d\n", p->histheight, p->width);
+ debug2(" was %d, %d\n", p->w_histheight, p->w_width);
if (histheight == 0)
{
@@ -210,29 +242,30 @@ int histheight, histwidth;
return 0;
}
- if (ResizeHistArray(p, &p->ihist, histwidth, histheight, 1)
- || ResizeHistArray(p, &p->ahist, histwidth, histheight, 0)
- || ResizeHistArray(p, &p->fhist, histwidth, histheight, 0))
+ if (ResizeHistArray(p, &p->w_ihist, histwidth, histheight, 1)
+ || ResizeHistArray(p, &p->w_ahist, histwidth, histheight, 0)
+ || ResizeHistArray(p, &p->w_fhist, histwidth, histheight, 0))
{
debug(" failed, removing all histbuf\n");
FreeScrollback(p);
- Msg_nomem;
- return (-1);
+ Msg(0, strnomem);
+ return -1;
}
- if (p->histheight != histheight)
- p->histidx = 0;
- p->histheight = histheight;
+ if (p->w_histheight != histheight)
+ p->w_histidx = 0;
+ p->w_histheight = histheight;
- return(0);
+ return 0;
}
-static void FreeScrollback(p)
+static void
+FreeScrollback(p)
struct win *p;
{
- FreeArray(&p->ihist, p->histheight);
- FreeArray(&p->ahist, p->histheight);
- FreeArray(&p->fhist, p->histheight);
- p->histheight = 0;
+ FreeArray(&p->w_ihist, p->w_histheight);
+ FreeArray(&p->w_ahist, p->w_histheight);
+ FreeArray(&p->w_fhist, p->w_histheight);
+ p->w_histheight = 0;
}
static int
@@ -244,64 +277,66 @@ int wi, hi, fillblank;
char **narr, **np, **onp, **onpe;
int t, x, first;
- if (p->width == wi && p->histheight == hi)
+ if (p->w_width == wi && p->w_histheight == hi)
return(0);
- if (p->histheight != hi)
+ if (p->w_histheight != hi)
{
if ((narr = (char **)calloc(sizeof(char *), hi)) == NULL)
{
- FreeArray(arr, p->histheight);
+ FreeArray(arr, p->w_histheight);
return(-1);
}
np = narr;
- onp = (*arr) + p->histidx;
- onpe = (*arr) + p->histheight;
- first = p->histheight - hi;
- if (first<0)
- np-=first;
- for(t=0; t<p->histheight; t++)
+ onp = (*arr) + p->w_histidx;
+ onpe = (*arr) + p->w_histheight;
+ first = p->w_histheight - hi;
+ if (first < 0)
+ np -= first;
+ for(t = 0; t < p->w_histheight; t++)
{
- if (t-first >=0 && t-first < hi)
+ ASSERT(*onp);
+ if (t - first >= 0 && t - first < hi)
*np++ = *onp;
else
- Free(*onp);
+ free(*onp);
if (++onp == onpe)
onp = *arr;
}
if (*arr)
- Free(*arr);
+ free(*arr);
}
else
narr = *arr;
- for (t=0, np=narr; t<hi; t++, np++)
+ for (t=0, np=narr; t < hi; t++, np++)
{
- x = p->width;
+ x = p->w_width;
if (*np == 0)
{
- *np = (char *)malloc(wi);
+ *np = (char *)malloc(wi + 1);
x = 0;
}
- else if (p->width != wi)
+ else if (p->w_width != wi)
{
- *np = (char *)xrealloc(*np, wi);
+ *np = (char *)xrealloc(*np, wi + 1);
}
if (*np == 0)
{
FreeArray(&narr, hi);
- return(-1);
+ return -1;
}
- if (x<wi)
+ if (x < wi)
{
if (fillblank)
- bclear(*np+x, wi-x);
+ bclear(*np + x, wi + 1 - x);
else
- bzero(*np+x, wi-x);
+ bzero(*np + x, wi + 1 - x);
}
}
*arr = narr;
- return(0);
+ return 0;
}
+#endif /* COPY_PASTE */
static int
@@ -313,58 +348,59 @@ int wi, hi, fillblank;
int minr;
char **cp;
- if (p->width == wi && p->height == hi)
+ if (p->w_width == wi && p->w_height == hi)
return(0);
- if (hi > p->height)
- minr = p->height;
+ if (hi > p->w_height)
+ minr = p->w_height;
else
minr = hi;
- if (p->height > hi)
+ if (p->w_height > hi)
{
- for (cp = *arr; cp < *arr + (p->height - hi); cp++)
- Free(*cp);
- bcopy((char *)(*arr + (p->height - hi)), (char *)(*arr),
+ for (cp = *arr; cp < *arr + (p->w_height - hi); cp++)
+ free(*cp);
+ bcopy((char *)(*arr + (p->w_height - hi)), (char *)(*arr),
hi * sizeof(char *));
}
- if (*arr && p->width != wi)
+ if (*arr && p->w_width != wi)
for (cp = *arr; cp < *arr + minr; cp++)
{
- if ((*cp = (char *)xrealloc(*cp, (unsigned) wi)) == 0)
+ if ((*cp = (char *)xrealloc(*cp, (unsigned) wi + 1)) == 0)
{
- FreeArray(arr, p->height);
+ FreeArray(arr, p->w_height);
return(-1);
}
- if (wi > p->width)
+ if (wi > p->w_width)
{
if (fillblank)
- bclear(*cp + p->width, wi - p->width);
+ bclear(*cp + p->w_width, wi + 1 - p->w_width);
else
- bzero(*cp + p->width, wi - p->width);
+ bzero(*cp + p->w_width, wi + 1 - p->w_width);
}
}
if (*arr)
*arr = (char **) xrealloc((char *) *arr, (unsigned) hi * sizeof(char *));
else
*arr = (char **) malloc((unsigned) hi * sizeof(char *));
- if (*arr == 0)
- return(-1);
- for (cp = *arr + p->height; cp < *arr + hi; cp++)
+ if (*arr == NULL)
+ return -1;
+ for (cp = *arr + p->w_height; cp < *arr + hi; cp++)
{
- if ((*cp = malloc((unsigned) wi)) == 0)
+ if ((*cp = malloc((unsigned) wi + 1)) == 0)
{
while (--cp >= *arr)
- Free(*cp);
- Free(*arr);
- return(-1);
+ free(*cp);
+ free(*arr);
+ *arr = NULL;
+ return -1;
}
if (fillblank)
- bclear(*cp, wi);
+ bclear(*cp, wi + 1);
else
- bzero(*cp, wi);
+ bzero(*cp, wi + 1);
}
- return(0);
+ return 0;
}
static void
@@ -379,147 +415,156 @@ int hi;
return;
for (t = hi, p = *arr; t--; p++)
if (*p)
- Free(*p);
- Free(*arr);
+ free(*p);
+ free(*arr);
+ *arr = 0;
+}
+
+
+static void
+CheckMaxSize(wi)
+int wi;
+{
+ if (wi + 1 <= maxwidth)
+ return;
+ maxwidth = wi + 1;
+ debug1("New maxwidth: %d\n", maxwidth);
+ if (blank == 0)
+ blank = malloc((unsigned) maxwidth);
+ else
+ blank = xrealloc(blank, (unsigned) maxwidth);
+ if (null == 0)
+ null = malloc((unsigned) maxwidth);
+ else
+ null = xrealloc(null, (unsigned) maxwidth);
+ if (OldImage == 0)
+ OldImage = malloc((unsigned) maxwidth);
+ else
+ OldImage = xrealloc(OldImage, (unsigned) maxwidth);
+ if (OldAttr == 0)
+ OldAttr = malloc((unsigned) maxwidth);
+ else
+ OldAttr = xrealloc(OldAttr, (unsigned) maxwidth);
+ if (OldFont == 0)
+ OldFont = malloc((unsigned) maxwidth);
+ else
+ OldFont = xrealloc(OldFont, (unsigned) maxwidth);
+ if (!(blank && null && OldImage && OldAttr && OldFont))
+ {
+ Panic(0, "Out of memory -> Game over!!");
+ /*NOTREACHED*/
+ }
+ MakeBlankLine(blank, maxwidth);
+ bzero(null, maxwidth);
}
int
-ChangeWindowSize(p, width, height)
+ChangeWindowSize(p, wi, he)
struct win *p;
-int width, height;
+int wi, he;
{
int t, scr;
- if (width > maxwidth)
- {
- maxwidth = width;
- debug1("New maxwidth: %d\n", maxwidth);
- if (blank == 0)
- blank = malloc((unsigned) maxwidth);
- else
- blank = xrealloc(blank, (unsigned) maxwidth);
- if (null == 0)
- null = malloc((unsigned) maxwidth);
- else
- null = xrealloc(null, (unsigned) maxwidth);
- if (OldImage == 0)
- OldImage = malloc((unsigned) maxwidth);
- else
- OldImage = xrealloc(OldImage, (unsigned) maxwidth);
- if (OldAttr == 0)
- OldAttr = malloc((unsigned) maxwidth);
- else
- OldAttr = xrealloc(OldAttr, (unsigned) maxwidth);
- if (OldFont == 0)
- OldFont = malloc((unsigned) maxwidth);
- else
- OldFont = xrealloc(OldFont, (unsigned) maxwidth);
- if (LastMsg == 0)
- {
- LastMsg = malloc((unsigned) maxwidth + 1);
- *LastMsg = 0;
- }
- else
- LastMsg = xrealloc(LastMsg, (unsigned) maxwidth + 1);
- LastMsg[maxwidth]=0;
- if (!(blank && null && OldImage && OldAttr && OldFont && LastMsg))
- {
-nomem: for (t = WinList; t != -1 && wtab[t] != p; t = p->WinLink)
- ;
- if (t >= 0)
- KillWindow(t);
- Msg(0, "Out of memory -> Window destroyed !!");
- return(-1);
- }
- MakeBlankLine(blank, maxwidth);
- bzero(null, maxwidth);
- }
+ CheckMaxSize(wi);
- if (width == p->width && height == p->height)
+ if (wi == p->w_width && he == p->w_height)
{
debug("ChangeWindowSize: No change.\n");
- return(0);
+ return 0;
}
- debug2("ChangeWindowSize from (%d,%d) to ", p->width, p->height);
- debug2("(%d,%d)\n", width, height);
-
- if (width == 0 && height == 0)
+ debug2("ChangeWindowSize from (%d,%d) to ", p->w_width, p->w_height);
+ debug2("(%d,%d)\n", wi, he);
+ if (p->w_lay != &p->w_winlay)
+ {
+ debug("ChangeWindowSize: No resize because of overlay.\n");
+ return -1;
+ }
+ if (wi == 0 && he == 0)
{
- FreeArray(&p->image, p->height);
- FreeArray(&p->attr, p->height);
- FreeArray(&p->font, p->height);
- if (p->tabs)
- Free(p->tabs);
- p->width = 0;
- p->height = 0;
+ FreeArray(&p->w_image, p->w_height);
+ FreeArray(&p->w_attr, p->w_height);
+ FreeArray(&p->w_font, p->w_height);
+ if (p->w_tabs)
+ free(p->w_tabs);
+ p->w_tabs = NULL;
+ p->w_width = 0;
+ p->w_height = 0;
+#ifdef COPY_PASTE
FreeScrollback(p);
- return(0);
+#endif
+ return 0;
}
/* when window gets smaller, scr is the no. of lines we scroll up */
- scr = p->height - height;
+ scr = p->w_height - he;
if (scr < 0)
scr = 0;
+#ifdef COPY_PASTE
for (t = 0; t < scr; t++)
- AddLineToHist(p, p->image+t, p->attr+t, p->font+t);
- if (ResizeScreenArray(p, &p->image, width, height, 1)
- || ResizeScreenArray(p, &p->attr, width, height, 0)
- || ResizeScreenArray(p, &p->font, width, height, 0))
+ AddLineToHist(p, p->w_image+t, p->w_attr+t, p->w_font+t);
+#endif
+ if (ResizeScreenArray(p, &p->w_image, wi, he, 1)
+ || ResizeScreenArray(p, &p->w_attr, wi, he, 0)
+ || ResizeScreenArray(p, &p->w_font, wi, he, 0))
{
- goto nomem;
+nomem: KillWindow(p);
+ Msg(0, "Out of memory -> Window destroyed !!");
+ return -1;
}
- /* this won't change the height of the scrollback history buffer, but
- * it will check the width of the lines.
+ /* this won't change the d_height of the scrollback history buffer, but
+ * it will check the d_width of the lines.
*/
- ChangeScrollback(p, p->histheight, width);
+#ifdef COPY_PASTE
+ ChangeScrollback(p, p->w_histheight, wi);
+#endif
- if (p->tabs == 0)
+ if (p->w_tabs == 0)
{
- /* tabs get width+1 because 0 <= x <= width */
- if ((p->tabs = malloc((unsigned) width + 1)) == 0)
+ /* tabs get d_width+1 because 0 <= x <= wi */
+ if ((p->w_tabs = malloc((unsigned) wi + 1)) == 0)
goto nomem;
t = 8;
}
else
{
- if ((p->tabs = xrealloc(p->tabs, (unsigned) width + 1)) == 0)
+ if ((p->w_tabs = xrealloc(p->w_tabs, (unsigned) wi + 1)) == 0)
goto nomem;
- t = p->width;
+ t = p->w_width;
}
- for (t = (t + 7) & 8; t < width; t += 8)
- p->tabs[t] = 1;
- p->height = height;
- p->width = width;
- if (p->x >= width)
- p->x = width - 1;
- if ((p->y -= scr) < 0)
- p->y = 0;
- if (p->Saved_x >= width)
- p->Saved_x = width - 1;
- if ((p->Saved_y -= scr) < 0)
- p->Saved_y = 0;
- if (p->autoaka > 0)
- if ((p->autoaka -= scr) < 1)
- p->autoaka = 1;
- p->top = 0;
- p->bot = height - 1;
+ for (t = (t + 7) & 8; t < wi; t += 8)
+ p->w_tabs[t] = 1;
+ p->w_height = he;
+ p->w_width = wi;
+ if (p->w_x >= wi)
+ p->w_x = wi - 1;
+ if ((p->w_y -= scr) < 0)
+ p->w_y = 0;
+ if (p->w_Saved_x >= wi)
+ p->w_Saved_x = wi - 1;
+ if ((p->w_Saved_y -= scr) < 0)
+ p->w_Saved_y = 0;
+ if (p->w_autoaka > 0)
+ if ((p->w_autoaka -= scr) < 1)
+ p->w_autoaka = 1;
+ p->w_top = 0;
+ p->w_bot = he - 1;
#ifdef TIOCSWINSZ
- if (p->ptyfd && p->wpid)
+ if (p->w_ptyfd && p->w_pid)
{
- glwz.ws_col = width;
- glwz.ws_row = height;
+ glwz.ws_col = wi;
+ glwz.ws_row = he;
debug("Setting pty winsize.\n");
- if (ioctl(p->ptyfd, TIOCSWINSZ, &glwz))
- debug2("SetPtySize: errno %d (fd:%d)\n", errno, p->ptyfd);
+ if (ioctl(p->w_ptyfd, TIOCSWINSZ, &glwz))
+ debug2("SetPtySize: errno %d (fd:%d)\n", errno, p->w_ptyfd);
# if defined(STUPIDTIOCSWINSZ) && defined(SIGWINCH)
# ifdef POSIX
- pgrp = tcgetpgrp(p->ptyfd);
-# else
- if (ioctl(p->ptyfd, TIOCGPGRP, &pgrp))
+ pgrp = tcgetpgrp(p->w_ptyfd);
+# else /* POSIX */
+ if (ioctl(p->w_ptyfd, TIOCGPGRP, &pgrp))
pgrp = 0;
-# endif
+# endif /* POSIX */
if (pgrp)
{
debug1("Sending SIGWINCH to pgrp %d.\n", pgrp);
@@ -530,54 +575,11 @@ nomem: for (t = WinList; t != -1 && wtab[t] != p; t = p->WinLink)
debug1("Could not get pgrp: errno %d\n", errno);
# endif /* STUPIDTIOCSWINSZ */
}
-#endif
- return(0);
+#endif /* TIOCSWINSZ */
+ return 0;
}
-void
-ResizeScreen(wi)
-struct win *wi;
-{
- int width, height;
-
- if (wi)
- {
- width = wi->width;
- height = wi->height;
- }
- else
- {
- width = default_width;
- height = default_height;
- }
- if (screenwidth == width && screenheight == height)
- {
- debug("ResizeScreen: No change\n");
- return;
- }
- debug2("ResizeScreen: to (%d,%d).\n", width, height);
- if (WS)
- {
- debug("ResizeScreen: using WS\n");
- WSresize(width, height);
- ChangeScreenSize(width, height, 0);
- }
- else if (Z0 && (width == Z0width || width == Z1width))
- {
- debug("ResizeScreen: using Z0/Z1\n");
- PutStr(width == Z0width ? Z0 : Z1);
- ChangeScreenSize(width, screenheight, 0);
- }
- if (screenwidth != width || screenheight != height)
- {
- debug2("BUG: Cannot resize from (%d,%d)",screenwidth, screenheight);
- debug2(" to (%d,%d) !!\n", width, height);
- if (wi)
- ChangeWindowSize(wi, screenwidth, screenheight);
- }
-}
-
char *
xrealloc(mem, len)
char *mem;
@@ -585,7 +587,7 @@ int len;
{
register char *nmem;
- if (nmem = realloc(mem, len))
+ if ((nmem = realloc(mem, len)))
return(nmem);
free(mem);
return((char *)0);