void LoadLayout(struct layout *lay) { AutosaveLayout(D_layout); if (!lay) { while (D_canvas.c_slperp) FreeCanvas(D_canvas.c_slperp); MakeDefaultCanvas(); SetCanvasWindow(D_forecv, 0); D_layout = 0; return; } while (D_canvas.c_slperp) FreeCanvas(D_canvas.c_slperp); D_cvlist = 0; if (!D_forecv) MakeDefaultCanvas(); D_forecv = lay->lay_forecv; if (!D_forecv) MakeDefaultCanvas(); DupLayoutCv(&lay->lay_canvas, &D_canvas, 0); D_canvas.c_ys = (D_has_hstatus == HSTATUS_FIRSTLINE); D_canvas.c_ye = D_height - 1 - ((D_canvas.c_slperp && D_canvas.c_slperp->c_slnext) || captionalways) - (D_has_hstatus == HSTATUS_LASTLINE); ResizeCanvas(&D_canvas); RecreateCanvasChain(); RethinkDisplayViewports(); PutWindowCv(&D_canvas); ResizeLayersToCanvases(); D_layout = lay; }
void OneCanvas() { struct canvas *cv = D_forecv, *ocv = 0; if (cv->c_slprev) { ocv = cv->c_slprev; cv->c_slprev->c_slnext = cv->c_slnext; } if (cv->c_slnext) { ocv = cv->c_slnext; cv->c_slnext->c_slprev = cv->c_slprev; } if (!ocv) return; if (cv->c_slback && cv->c_slback->c_slperp == cv) cv->c_slback->c_slperp = ocv; cv->c_slorient = SLICE_UNKN; while (D_canvas.c_slperp) FreeCanvas(D_canvas.c_slperp); cv = D_forecv; D_canvas.c_slperp = cv; cv->c_slback = &D_canvas; cv->c_slnext = 0; cv->c_slprev = 0; ASSERT(!cv->c_slperp); if (!captionalways) D_canvas.c_ye++; /* caption line no longer needed */ ResizeCanvas(&D_canvas); RecreateCanvasChain(); RethinkDisplayViewports(); ResizeLayersToCanvases(); }
void ChangeScreenSize(int wi, int he, int change_fore) { struct win *p; struct canvas *cv; int wwi; debug2("ChangeScreenSize from (%d,%d) ", D_width, D_height); debug3("to (%d,%d) (change_fore: %d)\n",wi, he, change_fore); cv = &D_canvas; cv->c_xe = wi - 1; cv->c_ys = (D_has_hstatus == HSTATUS_FIRSTLINE); cv->c_ye = he - 1 - ((cv->c_slperp && cv->c_slperp->c_slnext) || captionalways) - (D_has_hstatus == HSTATUS_LASTLINE); cv->c_blank.l_height = cv->c_ye - cv->c_ys + 1; if (cv->c_slperp) { ResizeCanvas(cv); RecreateCanvasChain(); RethinkDisplayViewports(); } if (D_forecv == 0) D_forecv = D_cvlist; if (D_forecv) D_fore = Layer2Window(D_forecv->c_layer); D_width = wi; D_height = he; CheckMaxSize(wi); if (D_CWS) { D_defwidth = D_CO; D_defheight = D_LI; } else { if (D_CZ0 && (wi == Z0width || wi == Z1width) && (D_CO == Z0width || D_CO == Z1width)) D_defwidth = D_CO; else D_defwidth = wi; D_defheight = he; } debug2("Default size: (%d,%d)\n", D_defwidth, D_defheight); if (change_fore) ResizeLayersToCanvases(); if (change_fore == 2 && D_CWS == NULL && displays->d_next == 0) { /* adapt all windows - to be removed ? */ for (p = windows; p; p = p->w_next) { debug1("Trying to change window %d.\n", p->w_number); wwi = wi; if (p->w_savelayer && p->w_savelayer->l_cvlist == 0) ResizeLayer(p->w_savelayer, wwi, he, 0); } } }
void RemCanvas() { int ye; struct canvas *cv; debug("RemCanvas\n"); cv = D_forecv; if (cv->c_slorient == SLICE_UNKN) return; while (cv->c_slprev) cv = cv->c_slprev; if (!cv->c_slnext) return; if (!cv->c_slnext->c_slnext && cv->c_slback->c_slback) { /* two canvases in slice, kill perp node */ cv = D_forecv; debug("deleting perp node\n"); FreePerp(cv->c_slprev ? cv->c_slprev : cv->c_slnext); FreePerp(cv->c_slback); } ye = cv->c_slback->c_ye; /* free canvas */ cv = D_forecv; D_forecv = cv->c_slprev; if (!D_forecv) D_forecv = cv->c_slnext; FreeCanvas(cv); cv = D_forecv; while (D_forecv->c_slperp) D_forecv = D_forecv->c_slperp; /* if only one canvas left, set orient back to unknown */ if (!cv->c_slnext && !cv->c_slprev && !cv->c_slback->c_slback && !cv->c_slperp) { cv->c_slorient = SLICE_UNKN; if (!captionalways) cv->c_slback->c_ye = ++ye; /* caption line no longer needed */ } cv = cv->c_slback; EqualizeCanvas(cv->c_slperp, 0); ResizeCanvas(cv); D_fore = Layer2Window(D_forecv->c_layer); flayer = D_forecv->c_layer; RecreateCanvasChain(); RethinkDisplayViewports(); ResizeLayersToCanvases(); }
void ChangeScreenSize(int wi, int he, int change_fore) { Window *p; Canvas *cv; int wwi; cv = &D_canvas; cv->c_xe = wi - 1; cv->c_ys = ((cv->c_slperp && cv->c_slperp->c_slnext) || captionalways) * captiontop + (D_has_hstatus == HSTATUS_FIRSTLINE); cv->c_ye = he - 1 - ((cv->c_slperp && cv->c_slperp->c_slnext) || captionalways) * !captiontop - (D_has_hstatus == HSTATUS_LASTLINE); cv->c_blank.l_height = cv->c_ye - cv->c_ys + 1; if (cv->c_slperp) { ResizeCanvas(cv); RecreateCanvasChain(); RethinkDisplayViewports(); } if (D_forecv == 0) D_forecv = D_cvlist; if (D_forecv) D_fore = Layer2Window(D_forecv->c_layer); D_width = wi; D_height = he; CheckMaxSize(wi); if (D_CWS) { D_defwidth = D_CO; D_defheight = D_LI; } else { if (D_CZ0 && (wi == Z0width || wi == Z1width) && (D_CO == Z0width || D_CO == Z1width)) D_defwidth = D_CO; else D_defwidth = wi; D_defheight = he; } if (change_fore) ResizeLayersToCanvases(); if (change_fore == 2 && D_CWS == NULL && displays->d_next == 0) { /* adapt all windows - to be removed ? */ for (p = windows; p; p = p->w_next) { wwi = wi; if (p->w_savelayer && p->w_savelayer->l_cvlist == 0) ResizeLayer(p->w_savelayer, wwi, he, 0); } } }
int AddCanvas(int orient) { struct canvas *cv; int xs, xe, ys, ye; int h, num; cv = D_forecv; debug("AddCanvas orient %d, forecv is %d\n", orient, cv->c_slorient); if (cv->c_slorient != SLICE_UNKN && cv->c_slorient != orient) if (!AddPerp(cv)) return -1; cv = D_forecv; xs = cv->c_slback->c_xs; xe = cv->c_slback->c_xe; ys = cv->c_slback->c_ys; ye = cv->c_slback->c_ye; if (!captionalways && cv == D_canvas.c_slperp && !cv->c_slnext) ye--; /* need space for caption */ debug("Adding Canvas to slice %d,%d ", xs, ys); debug("%d,%d\n", xe, ye); num = CountCanvas(cv->c_slback->c_slperp) + 1; debug("Num = %d\n", num); if (orient == SLICE_VERT) h = ye - ys + 1; else h = xe - xs + 1; h -= 2 * num - 1; if (h < 0) return -1; /* can't fit in */ if ((cv = calloc(1, sizeof *cv)) == 0) return -1; D_forecv->c_slback->c_ye = ye; /* in case we modified it above */ D_forecv->c_slorient = orient; /* in case it was UNKN */ cv->c_slnext = D_forecv->c_slnext; cv->c_slprev = D_forecv; D_forecv->c_slnext = cv; if (cv->c_slnext) cv->c_slnext->c_slprev = cv; cv->c_slorient = orient; cv->c_slback = D_forecv->c_slback; cv->c_xs = xs; cv->c_xe = xe; cv->c_ys = ys; cv->c_ye = ye; cv->c_xoff = 0; cv->c_yoff = 0; cv->c_display = display; cv->c_vplist = 0; cv->c_captev.type = EV_TIMEOUT; cv->c_captev.data = (char *)cv; cv->c_captev.handler = NULL; CanvasInitBlank(cv); cv->c_lnext = 0; cv->c_next = 0; cv = cv->c_slback; EqualizeCanvas(cv->c_slperp, 0); ResizeCanvas(cv); RecreateCanvasChain(); RethinkDisplayViewports(); ResizeLayersToCanvases(); return 0; }