void stopwin(struct ww *w) { if (w->ww_pty >= 0 && w->ww_type == WWT_PTY && wwstoptty(w->ww_pty) < 0) error("Can't stop output: %s.", wwerror()); else SET(w->ww_pflags, WWP_STOPPED); }
/* * Open a user window. */ struct ww * openwin(int id, int row, int col, int nrow, int ncol, int nline, char *label, int type, int uflags, char *shf, char **sh) { struct ww *w; if (id < 0 && (id = findid()) < 0) return 0; if (row + nrow <= 0 || row > wwnrow - 1 || col + ncol <= 0 || col > wwncol - 1) { error("Illegal window position."); return 0; } w = wwopen(type, 0, nrow, ncol, row, col, nline); if (w == 0) { error("Can't open window: %s.", wwerror()); return 0; } w->ww_id = id; window[id] = w; CLR(w->ww_uflags, WWU_ALLFLAGS); SET(w->ww_uflags, uflags); w->ww_alt = w->ww_w; if (label != 0 && setlabel(w, label) < 0) error("No memory for label."); wwcursor(w, 1); /* * We have to do this little maneuver to make sure * addwin() puts w at the top, so we don't waste an * insert and delete operation. */ setselwin((struct ww *)0); addwin(w, 0); setselwin(w); if (wwspawn(w, shf, sh) < 0) { error("Can't execute %s: %s.", shf, wwerror()); closewin(w); return 0; } return w; }
void sizewin(struct ww *w, int nrow, int ncol) { struct ww *back = w->ww_back; w->ww_alt.nr = w->ww_w.nr; w->ww_alt.nc = w->ww_w.nc; wwdelete(w); if (wwsize(w, nrow, ncol) < 0) error("Can't resize window: %s.", wwerror()); wwadd(w, back); reframe(); }
c_help() { register struct ww *w; if ((w = openiwin(wwnrow - 3, "Help")) == 0) { error("Can't open help window: %s.", wwerror()); return; } wwprintf(w, "The escape character is %c.\n", escapec); wwprintf(w, "(# represents one of the digits from 1 to 9.)\n\n"); if (help_print(w, "Short commands", help_shortcmd) >= 0) (void) help_print(w, "Long commands", help_longcmd); closeiwin(w); }
debug_str() { register struct ww *w; struct string *s; if ((w = openiwin(wwnrow - 3, "Allocated Strings")) == 0) { error("Can't open string window: %s.", wwerror()); return; } for (s = str_head.s_forw; s != &str_head; s = s->s_forw) { if (more(w, 0) == 2) goto out; wwprintf(w, "(0x%x)\t\"%s\"\n", s->s_data, s->s_data); } waitnl(w); out: closeiwin(w); }