screen-4.8.0/0000755000175000017500000000000013616622371011711 5ustar amadeamadescreen-4.8.0/screen.h0000644000175000017500000002034713616620402013340 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** * $Id$ GNU */ #include "os.h" #if defined(__STDC__) # ifndef __P # define __P(a) a # endif #else # ifndef __P # define __P(a) () # endif # define const #endif #include "osdef.h" #include "ansi.h" #include "sched.h" #include "acls.h" #include "comm.h" #include "layer.h" #include "term.h" #ifdef DEBUG # define STATIC /* a function that the debugger should see */ #else # define STATIC static #endif #ifdef DEBUG # define DEBUGDIR "/tmp/debug" # define debugf(a) do {if(dfp){fprintf a;fflush(dfp);}} while (0) # define debug(x) debugf((dfp,x)) # define debug1(x,a) debugf((dfp,x,a)) # define debug2(x,a,b) debugf((dfp,x,a,b)) # define debug3(x,a,b,c) debugf((dfp,x,a,b,c)) extern FILE *dfp; #else # define debugf(a) do {} while (0) # define debug(x) debugf(x) # define debug1(x,a) debugf(x) # define debug2(x,a,b) debugf(x) # define debug3(x,a,b,c) debugf(x) #endif #ifndef DEBUG # define NOASSERT #endif #ifndef NOASSERT # if defined(__STDC__) # define ASSERT(lousy_cpp) do {if (!(lousy_cpp)) {if (!dfp) opendebug(0, 1);debug2("ASSERT("#lousy_cpp") failed file %s line %d\n", __FILE__, __LINE__);abort();}} while (0) # else # define ASSERT(lousy_cpp) do {if (!(lousy_cpp)) {if (!dfp) opendebug(0, 1);debug2("ASSERT(lousy_cpp) failed file %s line %d\n", __FILE__, __LINE__);abort();}} while (0) # endif #else # define ASSERT(lousy_cpp) do {} while (0) #endif /* here comes my own Free: jw. */ #define Free(a) {if ((a) == 0) abort(); else free((void *)(a)); (a)=0;} #define Ctrl(c) ((c)&037) #define MAXSTR 768 #define MAXARGS 64 #define MSGWAIT 5 #define MSGMINWAIT 1 #define SILENCEWAIT 30 /* * if a nasty user really wants to try a history of 3000 lines on all 10 * windows, he will allocate 8 MegaBytes of memory, which is quite enough. */ #define MAXHISTHEIGHT 3000 #define DEFAULTHISTHEIGHT 100 #if defined(NAME_MAX) && NAME_MAX < 16 # define DEFAULT_BUFFERFILE "/tmp/screen-xchg" #else # define DEFAULT_BUFFERFILE "/tmp/screen-exchange" #endif #if defined(hpux) && !(defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT)) # define HPUX_LTCHARS_HACK #endif struct mode { #ifdef POSIX struct termios tio; # ifdef HPUX_LTCHARS_HACK struct ltchars m_ltchars; # endif /* HPUX_LTCHARS_HACK */ #else /* POSIX */ # ifdef TERMIO struct termio tio; # ifdef CYTERMIO int m_mapkey; int m_mapscreen; int m_backspace; # endif # else /* TERMIO */ struct sgttyb m_ttyb; struct tchars m_tchars; struct ltchars m_ltchars; int m_ldisc; int m_lmode; # endif /* TERMIO */ #endif /* POSIX */ #if defined(KANJI) && defined(TIOCKSET) struct jtchars m_jtchars; int m_knjmode; #endif }; /* #include "logfile.h" */ /* (requires stat.h) struct logfile */ #include "image.h" #include "canvas.h" #include "display.h" #include "window.h" /* * Parameters for the Detach() routine */ #define D_DETACH 0 #define D_STOP 1 #define D_REMOTE 2 #define D_POWER 3 #define D_REMOTE_POWER 4 #define D_LOCK 5 #define D_HANGUP 6 /* * Here are the messages the attacher sends to the backend */ #define MSG_CREATE 0 #define MSG_ERROR 1 #define MSG_ATTACH 2 #define MSG_CONT 3 #define MSG_DETACH 4 #define MSG_POW_DETACH 5 #define MSG_WINCH 6 #define MSG_HANGUP 7 #define MSG_COMMAND 8 #define MSG_QUERY 9 /* * versions of struct msg: * 0: screen version 3.6.6 (version count introduced) * 1: screen version 4.1.0devel (revisions e3fc19a upto 8147d08) * A few revisions after 8147d08 incorrectly * carried version 1, but should have carried 2. * 2: screen version 4.1.0devel (revisions 8b46d8a upto YYYYYYY) * 3: screen version 4.2.0 (was incorrectly originally. Patched here) * 4: screen version 4.2.1 (bumped once again due to changed terminal and login length) * 5: screen version 4.4.0 (fix screenterm size) */ #define MSG_VERSION 5 #define MSG_REVISION (('m'<<24) | ('s'<<16) | ('g'<<8) | MSG_VERSION) struct msg { int protocol_revision; /* reduce harm done by incompatible messages */ int type; char m_tty[MAXPATHLEN]; /* ttyname */ union { struct { int lflag; int aflag; int flowflag; int hheight; /* size of scrollback buffer */ int nargs; char line[MAXPATHLEN]; char dir[MAXPATHLEN]; char screenterm[MAXTERMLEN + 1]; /* is screen really "screen" ? */ } create; struct { char auser[MAXLOGINLEN + 1]; /* username */ int apid; /* pid of frontend */ int adaptflag; /* adapt window size? */ int lines, columns; /* display size */ char preselect[20]; int esc; /* his new escape character unless -1 */ int meta_esc; /* his new meta esc character unless -1 */ char envterm[MAXTERMLEN + 1]; /* terminal type */ int encoding; /* encoding of display */ int detachfirst; /* whether to detach remote sessions first */ } attach; struct { char duser[MAXLOGINLEN + 1]; /* username */ int dpid; /* pid of frontend */ } detach; struct { char auser[MAXLOGINLEN + 1]; /* username */ int nargs; char cmd[MAXPATHLEN]; /* command */ int apid; /* pid of frontend */ char preselect[20]; char writeback[MAXPATHLEN]; /* The socket to write the result. Only used for MSG_QUERY */ } command; char message[MAXPATHLEN * 2]; } m; }; /* * And the signals the attacher receives from the backend */ #define SIG_BYE SIGHUP #define SIG_POWER_BYE SIGUSR1 #define SIG_LOCK SIGUSR2 #define SIG_STOP SIGTSTP #ifdef SIGIO #define SIG_NODEBUG SIGIO /* triggerd by command 'debug off' */ #endif #define BELL (Ctrl('g')) #define VBELLWAIT 1 /* No. of seconds a vbell will be displayed */ #define BELL_ON 0 /* No bell has occurred in the window */ #define BELL_FOUND 1 /* A bell has occurred, but user not yet notified */ #define BELL_DONE 2 /* A bell has occured, user has been notified */ #define BELL_VISUAL 3 /* A bell has occured in fore win, notify him visually */ #define MON_OFF 0 /* Monitoring is off in the window */ #define MON_ON 1 /* No activity has occurred in the window */ #define MON_FOUND 2 /* Activity has occured, but user not yet notified */ #define MON_DONE 3 /* Activity has occured, user has been notified */ #define DUMP_TERMCAP 0 /* WriteFile() options */ #define DUMP_HARDCOPY 1 #define DUMP_EXCHANGE 2 #define DUMP_SCROLLBACK 3 #define SILENCE_OFF 0 /* Not checking for silence */ #define SILENCE_ON 1 /* Window being monitored for silence */ #define SILENCE_FOUND 2 /* Window is silent */ #define SILENCE_DONE 3 /* Window is silent and user is notified */ extern char strnomem[]; /* * line modes used by Input() */ #define INP_COOKED 0 #define INP_NOECHO 1 #define INP_RAW 2 #define INP_EVERY 4 #ifdef MULTIUSER struct acl { struct acl *next; char *name; }; #endif /* register list */ #define MAX_PLOP_DEFS 256 struct baud_values { int idx; /* the index in the bsd-is padding lookup table */ int bps; /* bits per seconds */ int sym; /* symbol defined in ttydev.h */ }; /* * windowlist orders */ #define WLIST_NUM 0 #define WLIST_MRU 1 #define WLIST_NESTED 2 screen-4.8.0/NEWS.3.90000644000175000017500000001512313607701732012721 0ustar amadeamade ------------------------------- What's new in screen-3.9.15 ? ------------------------------- * unicode combining character support * new encoding: chinese GBK * new 'backtick' command and string escape to embed command output into e.g. the hardstatus line ------------------------------- What's new in screen-3.9.13 ? ------------------------------- * altscreen support from Gurusamy Sarathy * new command "maxwin" to set a limit on the number of windows * new keys in copy&paste mode: 'B' and 'E' ------------------------------- What's new in screen-3.9.11 ? ------------------------------- * windowlist, bound to ^A" * support for other encodings, e.g. big5, koi8r, cp1251 new commands 'encoding', 'defencoding' 'register', 'readreg', 'readbuf', 'writebuf' now understand an extra encoding parameter * support for double utf-8 characters * lots of new string escapes and extensions to existsing ones: %LD, %LM, %Lw, %W, %-w, %+w, %H, %f, %F, %l, %=, %<, %> * new commands: 'source', 'eval', 'deflog', 'ignorecase', 'setsid' * command key classes: 'bind', 'command' and 'help' understand a '-c ' parameter. See the man page for examples * new login state: always - don't remove slot even if screen gets detached * 256 color support (experimental) * configurable time format string (for ^At) * config option to use localized month/week names * new option '-h' for hardcopy: also dump the scrollback buffer ------------------------------ What's new in screen-3.9.9 ? ------------------------------ * new '-X' option to send commands to screen sessions. screen -X echo Hi... * added a possibility to change the attributes/color in caption or hardstatus strings: caption always "%3n %{r}%t%{-}%? @%u%?%? %{g}[%h]%{-}%?" * new 'dinfo' command to show what screen thinks about your terminal. * new 'attrcolor' command to map attributes to color codes: attrcolor u "-u b" attrcolor b "r" * support for UTF-8: new commands 'utf8', 'defutf8' to change the encoding of a window, plus a '-U' option to tell screen that your terminal sends/receives UTF-8 codes. * support for 16 colors. ------------------------------ What's new in screen-3.9.8 ? ------------------------------ * new command 'resize' to resize regions (aka split windows), try: bind = resize = bind + resize +1 bind - resize -1 bind _ resize max * new argument for 'focus': up, down, top, bottom * X11 mouse tracking support * Support for the "new color model", aka "background color erase": the bce/defbce commands change the color model of the current window/new windows. * experimental rxvt OSC sequence support (used to set a background picture or to change the default colors), disabled by default. ---------------------------- What's new in screen-3.9 ? ---------------------------- * real multiuser support A window can now be displayed on more than one attached displays. Screen does all the necessary clipping if the window size doesn't fit the display. New command: ^AF - fit the window size into the display size. * split screen support A display may now host multiple windows. New commands: ^AS - split horizontally. This add another region to the display ^A - move the focus to the next region ^AX - kill the current region ^AQ - kill all other regions * hardstatus emulation support The last line of the display may now be used as a hardstatus line if the terminal doesn't have the 'hs' capability. New commands: hardstatus [always]lastline hardstatus [always]message hardstatus [always]ignore * configurable window seperator and hardstatus strings The window (region) seperator and the hardstatus can be set to an arbitrary string containing screen's % escape sequences. The window's hardstatus is just another escape sequence, '%h'. New commands: hardstatus string [string] caption string [string] The default strings are "%h" (hardstatus) and "%3n %t" (caption). * permanent window seperator The window seperator can be set to stay on screen even if the display contains only one region New commands: caption always caption splitonly * many new escapes %c - current time HH:MM (*CHANGE*: this was %w in screen-3.7) %C - current time HH:MM in 24h format %l - the load of the system %h - hardstatus of the window %w - all window names %W - all window names except the current window %u - all other users on this window %? - the part to the next %? is displayed only if an escape expands to an nonempty string. %: - "else" part of %? Some escapes like %c may be qualified with a '0' (like %0c) to make screen use '0' instead of space as a filler. Others understand a length qualifier, like %3n. If escapes like the current time are used as hardstatus/caption string screen will update them so that you can always have the current time onscreen. *CHANGE* ~ is no longer used as bell character, use ^G instead! * logfile timestamps and flush timeout New commands: logfile flush logtstamp [on|off] logtstamp string [string] logtstamp after [secs] * configurable breaktype You can now choose one of TIOCSBRK, TCSBRK, tcsendbreak. New commands: breaktype defbreaktype * other new commands: hstatus - set the window's hardstatus defslowpaste defsilence * optional builtin telnet. This is useful if screen is used as frontend to a terminal multiplexor. Use //telnet to access the builtin telnet program, as in: 'screen //telnet host [port]' * remote detach and reattach change: '-d' is now ignored if the screen is already detached and you want to reattach. You can also use '-RR' to make screen use the first session found if more than one session is available. Thus '-d -RR' or '-x -RR' always gets you a screen. * support for history compaction You can tell screen to suppress trailing blank lines when scolling up text into the history buffer. (Wayne Davison) New command: compacthist * optional Braille support. If you can read Braille and have one of the devices listed in README.DOTSCREEN, please compile with -DHAVE_BRAILLE and let us know if this feature is useful. screen-4.8.0/canvas.c0000644000175000017500000005124113616620402013324 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include "config.h" #include "screen.h" #include "extern.h" #include "canvas.h" #include "list_generic.h" extern struct display *display; extern struct win *fore, *windows; extern struct layer *flayer; extern int captionalways; extern struct LayFuncs BlankLf; extern int focusminwidth, focusminheight; static void CanvasInitBlank(cv) struct canvas *cv; { cv->c_blank.l_cvlist = cv; cv->c_blank.l_width = cv->c_xe - cv->c_xs + 1; cv->c_blank.l_height = cv->c_ye - cv->c_ys + 1; cv->c_blank.l_x = cv->c_blank.l_y = 0; cv->c_blank.l_layfn = &BlankLf; cv->c_blank.l_data = 0; cv->c_blank.l_next = 0; cv->c_blank.l_bottom = &cv->c_blank; cv->c_blank.l_blocking = 0; cv->c_layer = &cv->c_blank; } static void FreePerp(pcv) struct canvas *pcv; { struct canvas *cv; if (!pcv->c_slperp) return; cv = pcv->c_slperp; cv->c_slprev = pcv->c_slprev; if (cv->c_slprev) cv->c_slprev->c_slnext = cv; cv->c_slback = pcv->c_slback; if (cv->c_slback && cv->c_slback->c_slperp == pcv) cv->c_slback->c_slperp = cv; cv->c_slorient = pcv->c_slorient; cv->c_slweight = pcv->c_slweight; while (cv->c_slnext) { cv = cv->c_slnext; cv->c_slorient = pcv->c_slorient; cv->c_slback = pcv->c_slback; cv->c_slweight = pcv->c_slweight; } cv->c_slnext = pcv->c_slnext; if (cv->c_slnext) cv->c_slnext->c_slprev = cv; LayerCleanupMemory(&pcv->c_blank); free(pcv); } void FreeCanvas(cv) struct canvas *cv; { struct viewport *vp, *nvp; struct canvas **cvp; struct win *p; if (cv->c_slprev) cv->c_slprev->c_slnext = cv->c_slnext; if (cv->c_slnext) cv->c_slnext->c_slprev = cv->c_slprev; if (cv->c_slback && cv->c_slback->c_slperp == cv) cv->c_slback->c_slperp = cv->c_slnext ? cv->c_slnext : cv->c_slprev; if (cv->c_slperp) { while (cv->c_slperp) FreeCanvas(cv->c_slperp); LayerCleanupMemory(&cv->c_blank); free(cv); return; } if (display) { if (D_forecv == cv) D_forecv = 0; /* remove from canvas chain as SetCanvasWindow might call * some layer function */ for (cvp = &D_cvlist; *cvp ; cvp = &(*cvp)->c_next) if (*cvp == cv) { *cvp = cv->c_next; break; } } p = cv->c_layer ? Layer2Window(cv->c_layer) : 0; SetCanvasWindow(cv, 0); if (p) WindowChanged(p, 'u'); if (flayer == cv->c_layer) flayer = 0; for (vp = cv->c_vplist; vp; vp = nvp) { vp->v_canvas = 0; nvp = vp->v_next; vp->v_next = 0; free(vp); } evdeq(&cv->c_captev); LayerCleanupMemory(&cv->c_blank); free(cv); } int CountCanvas(cv) struct canvas *cv; { int num = 0; for (; cv; cv = cv->c_slnext) { if (cv->c_slperp) { struct canvas *cvp; int nump = 1, n; for (cvp = cv->c_slperp; cvp; cvp = cvp->c_slnext) if (cvp->c_slperp) { n = CountCanvas(cvp->c_slperp); if (n > nump) nump = n; } num += nump; } else num++; } return num; } int CountCanvasPerp(cv) struct canvas *cv; { struct canvas *cvp; int num = 1, n; for (cvp = cv->c_slperp; cvp; cvp = cvp->c_slnext) if (cvp->c_slperp) { n = CountCanvas(cvp->c_slperp); if (n > num) num = n; } return num; } struct canvas * FindCanvas(x, y) int x, y; { struct canvas *cv, *mcv = 0; int m, mm = 0; for (cv = D_cvlist; cv; cv = cv->c_next) { /* ye + 1 because of caption line */ if (x >= cv->c_xs && x <= cv->c_xe && y >= cv->c_ys && y <= cv->c_ye + 1) return cv; if (cv == D_forecv) continue; m = 0; if (x >= D_forecv->c_xs && x <= D_forecv->c_xe) { if (x < cv->c_xs || x > cv->c_xe) continue; if (y < D_forecv->c_ys && y < cv->c_ys) continue; if (y > D_forecv->c_ye + 1 && y > cv->c_ye + 1) continue; if (y < cv->c_ys) m = cv->c_ys - y; if (y > cv->c_ye + 1) m = y - (cv->c_ye + 1); } if (y >= D_forecv->c_ys && y <= D_forecv->c_ye + 1) { if (y < cv->c_ys || y > cv->c_ye + 1) continue; if (x < D_forecv->c_xs && x < cv->c_xs) continue; if (x > D_forecv->c_xe && x > cv->c_xe) continue; if (x < cv->c_xs) m = cv->c_xs - x; if (x > cv->c_xe) m = x - cv->c_xe; } if (m && (!mm || m < mm)) { mcv = cv; mm = m; } } return mcv ? mcv : D_forecv; } void SetCanvasWindow(cv, wi) struct canvas *cv; struct win *wi; { struct win *p = 0, **pp; struct layer *l; struct canvas *cvp, **cvpp; l = cv->c_layer; display = cv->c_display; if (l) { /* remove old layer */ for (cvpp = &l->l_cvlist; (cvp = *cvpp); cvpp = &cvp->c_lnext) if (cvp == cv) break; ASSERT(cvp); *cvpp = cvp->c_lnext; p = Layer2Window(l); l = cv->c_layer; cv->c_layer = 0; if (p && cv == D_forecv) { #ifdef MULTIUSER ReleaseAutoWritelock(display, p); #endif if (p->w_silence) { SetTimeout(&p->w_silenceev, p->w_silencewait * 1000); evenq(&p->w_silenceev); } D_other = fore; D_fore = 0; } if (l->l_cvlist == 0 && (p == 0 || l != p->w_savelayer)) KillLayerChain(l); } /* find right layer to display on canvas */ if (wi && wi->w_type != W_TYPE_GROUP) { l = &wi->w_layer; if (wi->w_savelayer && (wi->w_blocked || wi->w_savelayer->l_cvlist == 0)) l = wi->w_savelayer; } else { l = &cv->c_blank; if (wi) l->l_data = (char *)wi; else l->l_data = 0; } /* add our canvas to the layer's canvaslist */ ASSERT(l->l_cvlist != cv); cv->c_lnext = l->l_cvlist; l->l_cvlist = cv; cv->c_layer = l; cv->c_xoff = cv->c_xs; cv->c_yoff = cv->c_ys; RethinkViewportOffsets(cv); if (flayer == 0) flayer = l; if (wi && wi->w_type == W_TYPE_GROUP) { /* auto-start windowlist on groups */ struct display *d = display; struct layer *oldflayer = flayer; flayer = l; display_windows(0, 0, wi); flayer = oldflayer; display = d; } if (wi && D_other == wi) D_other = wi->w_next; /* Might be 0, but that's OK. */ if (cv == D_forecv) { D_fore = wi; fore = D_fore; /* XXX ? */ if (wi) { #ifdef MULTIUSER ObtainAutoWritelock(display, wi); #endif /* * Place the window at the head of the most-recently-used list */ if (windows != wi) { for (pp = &windows; (p = *pp); pp = &p->w_next) if (p == wi) break; ASSERT(p); *pp = p->w_next; p->w_next = windows; windows = p; WListLinkChanged(); } } } } static void cv_winid_fn(ev, data) struct event *ev; char *data; { int ox, oy; struct canvas *cv = (struct canvas *)data; display = cv->c_display; if (D_status == STATUS_ON_WIN) { SetTimeout(ev, 1); evenq(ev); return; } ox = D_x; oy = D_y; if (cv->c_ye + 1 < D_height) RefreshLine(cv->c_ye + 1, 0, D_width - 1, 0); if (ox != -1 && oy != -1) GotoPos(ox, oy); } int MakeDefaultCanvas() { struct canvas *cv; ASSERT(display); if ((cv = (struct canvas *)calloc(1, sizeof *cv)) == 0) return -1; cv->c_xs = 0; cv->c_xe = D_width - 1; cv->c_ys = (D_has_hstatus == HSTATUS_FIRSTLINE); cv->c_ye = D_height - 1 - (D_has_hstatus == HSTATUS_LASTLINE) - captionalways; debug2("MakeDefaultCanvas 0,0 %d,%d\n", cv->c_xe, cv->c_ye); cv->c_xoff = 0; cv->c_yoff = 0; cv->c_next = 0; cv->c_display = display; cv->c_vplist = 0; cv->c_slnext = 0; cv->c_slprev = 0; cv->c_slperp = 0; cv->c_slweight = 1; cv->c_slback = &D_canvas; D_canvas.c_slperp = cv; D_canvas.c_xs = cv->c_xs; D_canvas.c_xe = cv->c_xe; D_canvas.c_ys = cv->c_ys; D_canvas.c_ye = cv->c_ye; cv->c_slorient = SLICE_UNKN; cv->c_captev.type = EV_TIMEOUT; cv->c_captev.data = (char *)cv; cv->c_captev.handler = cv_winid_fn; CanvasInitBlank(cv); cv->c_lnext = 0; D_cvlist = cv; RethinkDisplayViewports(); D_forecv = cv; /* default input focus */ return 0; } static struct canvas ** CreateCanvasChainRec(cv, cvp) struct canvas *cv; struct canvas **cvp; { for (; cv; cv = cv->c_slnext) { if (cv->c_slperp) cvp = CreateCanvasChainRec(cv->c_slperp, cvp); else { *cvp = cv; cvp = &cv->c_next; } } return cvp; } void RecreateCanvasChain() { struct canvas **cvp; cvp = CreateCanvasChainRec(D_canvas.c_slperp, &D_cvlist); *cvp = 0; } void EqualizeCanvas(cv, gflag) struct canvas *cv; int gflag; { struct canvas *cv2; for (; cv; cv = cv->c_slnext) { if (cv->c_slperp && gflag) { cv->c_slweight = CountCanvasPerp(cv); for (cv2 = cv->c_slperp; cv2; cv2 = cv2->c_slnext) if (cv2->c_slperp) EqualizeCanvas(cv2->c_slperp, gflag); } else cv->c_slweight = 1; } } void ResizeCanvas(cv) struct canvas *cv; { struct canvas *cv2, *cvn, *fcv; int nh, i, maxi, hh, m, w, wsum; int need, got; int xs, ys, xe, ye; int focusmin = 0; xs = cv->c_xs; ys = cv->c_ys; xe = cv->c_xe; ye = cv->c_ye; cv = cv->c_slperp; debug2("ResizeCanvas: %d,%d", xs, ys); debug2(" %d,%d\n", xe, ye); if (cv == 0) return; if (cv->c_slorient == SLICE_UNKN) { ASSERT(!cv->c_slnext && !cv->c_slperp); cv->c_xs = xs; cv->c_xe = xe; cv->c_ys = ys; cv->c_ye = ye; cv->c_xoff = cv->c_xs; cv->c_yoff = cv->c_ys; cv->c_blank.l_width = cv->c_xe - cv->c_xs + 1; cv->c_blank.l_height = cv->c_ye - cv->c_ys + 1; return; } fcv = 0; if (focusminwidth || focusminheight) { debug("searching for focus canvas\n"); cv2 = D_forecv; while (cv2->c_slback) { if (cv2->c_slback == cv->c_slback) { fcv = cv2; focusmin = cv->c_slorient == SLICE_VERT ? focusminheight : focusminwidth; if (focusmin > 0) focusmin--; else if (focusmin < 0) focusmin = cv->c_slorient == SLICE_VERT ? ye - ys + 2 : xe - xs + 2; debug1("found, focusmin=%d\n", focusmin); } cv2 = cv2->c_slback; } } if (focusmin) { m = CountCanvas(cv) * 2; nh = cv->c_slorient == SLICE_VERT ? ye - ys + 2 : xe - xs + 2; nh -= m; if (nh < 0) nh = 0; if (focusmin > nh) focusmin = nh; debug1("corrected to %d\n", focusmin); } /* pass 1: calculate weight sum */ for (cv2 = cv, wsum = 0; cv2; cv2 = cv2->c_slnext) { debug1(" weight %d\n", cv2->c_slweight); wsum += cv2->c_slweight; } debug1("wsum = %d\n", wsum); if (wsum == 0) wsum = 1; w = wsum; /* pass 2: calculate need/excess space */ nh = cv->c_slorient == SLICE_VERT ? ye - ys + 2 : xe - xs + 2; for (cv2 = cv, need = got = 0; cv2; cv2 = cv2->c_slnext) { m = cv2->c_slperp ? CountCanvasPerp(cv2) * 2 - 1 : 1; if (cv2 == fcv) m += focusmin; hh = cv2->c_slweight ? nh * cv2->c_slweight / w : 0; w -= cv2->c_slweight; nh -= hh; debug2(" should %d min %d\n", hh, m); if (hh <= m + 1) need += m + 1 - hh; else got += hh - m - 1; } debug2("need: %d, got %d\n", need, got); if (need > got) need = got; /* pass 3: distribute space */ nh = cv->c_slorient == SLICE_VERT ? ye - ys + 2 : xe - xs + 2; i = cv->c_slorient == SLICE_VERT ? ys : xs; maxi = cv->c_slorient == SLICE_VERT ? ye : xe; w = wsum; for (; cv; cv = cvn) { cvn = cv->c_slnext; if (i > maxi) { if (cv->c_slprev && !cv->c_slback->c_slback && !cv->c_slprev->c_slperp && !cv->c_slprev->c_slprev) { cv->c_slprev->c_slorient = SLICE_UNKN; if (!captionalways) { cv->c_slback->c_ye++; cv->c_slprev->c_ye++; } } SetCanvasWindow(cv, 0); FreeCanvas(cv); continue; } m = cv->c_slperp ? CountCanvasPerp(cv) * 2 - 1 : 1; if (cv == fcv) m += focusmin; hh = cv->c_slweight ? nh * cv->c_slweight / w : 0; w -= cv->c_slweight; nh -= hh; debug2(" should %d min %d\n", hh, m); if (hh <= m + 1) { hh = m + 1; debug1(" -> %d\n", hh); } else { int hx = 1; //FIXME Division by zero (got) is posible. "hx = 1" is random number here!!! if (got != 0) hx = need * (hh - m - 1) / got; else debug(" got = 0\n"); debug3(" -> %d - %d = %d\n", hh, hx, hh - hx); got -= (hh - m - 1); hh -= hx; need -= hx; debug2(" now need=%d got=%d\n", need, got); } ASSERT(hh >= m + 1); /* hh is window size plus pation line */ if (i + hh > maxi + 2) { hh = maxi + 2 - i; debug1(" not enough space, reducing to %d\n", hh); } if (i + hh == maxi + 1) { hh++; debug(" incrementing as no other canvas will fit\n"); } if (cv->c_slorient == SLICE_VERT) { cv->c_xs = xs; cv->c_xe = xe; cv->c_ys = i; cv->c_ye = i + hh - 2; cv->c_xoff = xs; cv->c_yoff = i; } else { cv->c_xs = i; cv->c_xe = i + hh - 2; cv->c_ys = ys; cv->c_ye = ye; cv->c_xoff = i; cv->c_yoff = ys; } cv->c_xoff = cv->c_xs; cv->c_yoff = cv->c_ys; cv->c_blank.l_width = cv->c_xe - cv->c_xs + 1; cv->c_blank.l_height = cv->c_ye - cv->c_ys + 1; if (cv->c_slperp) { ResizeCanvas(cv); if (!cv->c_slperp->c_slnext) { debug("deleting perp node\n"); FreePerp(cv->c_slperp); FreePerp(cv); } } i += hh; } } static struct canvas * AddPerp(cv) struct canvas *cv; { struct canvas *pcv; debug("Creating new perp node\n"); if ((pcv = (struct canvas *)calloc(1, sizeof *cv)) == 0) return 0; pcv->c_next = 0; pcv->c_display = cv->c_display; pcv->c_slnext = cv->c_slnext; pcv->c_slprev = cv->c_slprev; pcv->c_slperp = cv; pcv->c_slback = cv->c_slback; if (cv->c_slback && cv->c_slback->c_slperp == cv) cv->c_slback->c_slperp = pcv; pcv->c_slorient = cv->c_slorient; pcv->c_xoff = 0; pcv->c_yoff = 0; pcv->c_xs = cv->c_xs; pcv->c_xe = cv->c_xe; pcv->c_ys = cv->c_ys; pcv->c_ye = cv->c_ye; if (pcv->c_slnext) pcv->c_slnext->c_slprev = pcv; if (pcv->c_slprev) pcv->c_slprev->c_slnext = pcv; pcv->c_slweight = cv->c_slweight; CanvasInitBlank(pcv); cv->c_slweight = 1; cv->c_slnext = 0; cv->c_slprev = 0; cv->c_slperp = 0; cv->c_slback = pcv; cv->c_slorient = SLICE_UNKN; return pcv; } int AddCanvas(orient) int orient; { struct canvas *cv; int xs, xe, ys, ye; int h, num; cv = D_forecv; debug2("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 */ debug2("Adding Canvas to slice %d,%d ", xs, ys); debug2("%d,%d\n", xe, ye); num = CountCanvas(cv->c_slback->c_slperp) + 1; debug1("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 = (struct canvas *)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 = cv_winid_fn; 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; } void RemCanvas() { int ye; struct canvas *cv; debug("RemCanvas\n"); cv = D_forecv; ye = cv->c_slback->c_ye; 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); } /* 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 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 DupLayoutCv(cvf, cvt, save) struct canvas *cvf, *cvt; int save; { while(cvf) { cvt->c_slorient = cvf->c_slorient; cvt->c_slweight = cvf->c_slweight; if (cvf == D_forecv) D_forecv = cvt; if (!save) { cvt->c_display = display; if (!cvf->c_slperp) { cvt->c_captev.type = EV_TIMEOUT; cvt->c_captev.data = (char *)cvt; cvt->c_captev.handler = cv_winid_fn; cvt->c_blank.l_cvlist = 0; cvt->c_blank.l_layfn = &BlankLf; cvt->c_blank.l_bottom = &cvt->c_blank; } cvt->c_layer = cvf->c_layer; } else { struct win *p = cvf->c_layer ? Layer2Window(cvf->c_layer) : 0; cvt->c_layer = p ? &p->w_layer : 0; } if (cvf->c_slperp) { cvt->c_slperp = (struct canvas *)calloc(1, sizeof(struct canvas)); cvt->c_slperp->c_slback = cvt; CanvasInitBlank(cvt->c_slperp); DupLayoutCv(cvf->c_slperp, cvt->c_slperp, save); } if (cvf->c_slnext) { cvt->c_slnext = (struct canvas *)calloc(1, sizeof(struct canvas)); cvt->c_slnext->c_slprev = cvt; cvt->c_slnext->c_slback = cvt->c_slback; CanvasInitBlank(cvt->c_slnext); } cvf = cvf->c_slnext; cvt = cvt->c_slnext; } } void PutWindowCv(cv) struct canvas *cv; { struct win *p; for (; cv; cv = cv->c_slnext) { if (cv->c_slperp) { PutWindowCv(cv->c_slperp); continue; } p = cv->c_layer ? (struct win *)cv->c_layer->l_data : 0; cv->c_layer = 0; SetCanvasWindow(cv, p); } } screen-4.8.0/mark.c0000644000175000017500000010510413616620402013001 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include #include #include "config.h" #include "screen.h" #include "mark.h" #include "extern.h" #ifdef COPY_PASTE /* * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * * WARNING: these routines use the global variables "fore" and * "flayer" to make things easier. * * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ static int is_letter __P((int)); static void nextword __P((int *, int *, int, int)); static int linestart __P((int)); static int lineend __P((int)); static int rem __P((int, int , int , int , int , char *, int)); static int eq __P((int, int )); static int MarkScrollDownDisplay __P((int)); static int MarkScrollUpDisplay __P((int)); static void MarkProcess __P((char **, int *)); static void MarkAbort __P((void)); static void MarkRedisplayLine __P((int, int, int, int)); static int MarkRewrite __P((int, int, int, struct mchar *, int)); extern struct layer *flayer; extern struct display *display, *displays; extern struct win *fore; extern struct mline mline_blank, mline_null; extern struct mchar mchar_so; #ifdef FONT int pastefont = 1; #endif struct LayFuncs MarkLf = { MarkProcess, MarkAbort, MarkRedisplayLine, DefClearLine, MarkRewrite, DefResize, DefRestore, 0 }; int join_with_cr = 0; int compacthist = 0; unsigned char mark_key_tab[256]; /* this array must be initialised first! */ static struct markdata *markdata; /* * VI like is_letter: 0 - whitespace * 1 - letter * 2 - other */ static int is_letter(c) char c; { if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || c == '.' || c == '@' || c == ':' || c == '%' || c == '!' || c == '-' || c == '+') /* thus we can catch email-addresses as a word :-) */ return 1; else if (c != ' ') return 2; return 0; } static int linestart(y) int y; { register int x; register unsigned char *i; for (x = markdata->left_mar, i = WIN(y)->image + x; x < fore->w_width - 1; x++) if (*i++ != ' ') break; if (x == fore->w_width - 1) x = markdata->left_mar; return x; } static int lineend(y) int y; { register int x; register unsigned char *i; for (x = markdata->right_mar, i = WIN(y)->image + x; x >= 0; x--) if (*i-- != ' ') break; if (x < 0) x = markdata->left_mar; return x; } /* * nextchar sets *xp to the num-th occurrence of the target in the line. * * Returns -1 if the target doesn't appear num times, 0 otherwise. */ static int nextchar(int *xp, int *yp, int direction, char target, int num) { int width; /* width of the current window. */ int x; /* x coordinate of the current cursor position. */ int step; /* amount to increment x (+1 or -1) */ int adjust; /* Final adjustment of cursor position. */ char *displayed_line; /* Line in which search takes place. */ debug("nextchar\n"); x = *xp; step = 1; adjust = 0; width = fore->w_width; displayed_line = (char *)WIN(*yp) -> image; switch(direction) { case 't': adjust = -1; /* fall through */ case 'f': step = 1; break; case 'T': adjust = 1; /* fall through */ case 'F': step = -1; break; default: ASSERT(0); } x += step; debug1("ml->image = %s\n", displayed_line); debug2("num = %d, width = %d\n",num, width); debug2("x = %d target = %c\n", x, target ); for ( ;x>=0 && x <= width; x += step) { if (displayed_line[x] == target) { if (--num == 0) { *xp = x + adjust; return 0; } } } return -1; } /* * nextword calculates the cursor position of the num'th word. * If the cursor is on a word, it counts as the first. * NW_BACK: search backward * NW_ENDOFWORD: find the end of the word * NW_MUSTMOVE: move at least one char * NW_BIG: match WORDs not words */ #define NW_BACK (1<<0) #define NW_ENDOFWORD (1<<1) #define NW_MUSTMOVE (1<<2) #define NW_BIG (1<<3) static void nextword(xp, yp, flags, num) int *xp, *yp, flags, num; { int xx = fore->w_width, yy = fore->w_histheight + fore->w_height; register int sx, oq, q, x, y; struct mline *ml; x = *xp; y = *yp; sx = (flags & NW_BACK) ? -1 : 1; if ((flags & NW_ENDOFWORD) && (flags & NW_MUSTMOVE)) x += sx; ml = WIN(y); for (oq = -1; ; x += sx, oq = q) { if (x >= xx || x < 0) q = 0; else if (flags & NW_BIG) q = ml->image[x] == ' '; else q = is_letter(ml->image[x]); if (oq >= 0 && oq != q) { if (oq == 0 || !(flags & NW_ENDOFWORD)) *xp = x; else *xp = x-sx; *yp = y; if ((!(flags & NW_ENDOFWORD) && q) || ((flags & NW_ENDOFWORD) && oq)) { if (--num <= 0) return; } } if (x == xx) { x = -1; if (++y >= yy) return; ml = WIN(y); } else if (x < 0) { x = xx; if (--y < 0) return; ml = WIN(y); } } } /* * y1, y2 are WIN coordinates * * redisplay: 0 - just copy * 1 - redisplay + copy * 2 - count + copy, don't redisplay */ static int rem(x1, y1, x2, y2, redisplay, pt, yend) int x1, y1, x2, y2, redisplay, yend; char *pt; { int i, j, from, to, ry, c; int l = 0; unsigned char *im; struct mline *ml; #ifdef FONT int cf, cfx, font; unsigned char *fo, *fox; #endif markdata->second = 0; if (y2 < y1 || ((y2 == y1) && (x2 < x1))) { i = y2; y2 = y1; y1 = i; i = x2; x2 = x1; x1 = i; } ry = y1 - markdata->hist_offset; i = y1; if (redisplay != 2 && pt == 0 && ry <0) { i -= ry; ry = 0; } for (; i <= y2; i++, ry++) { if (redisplay != 2 && pt == 0 && ry > yend) break; ml = WIN(i); from = (i == y1) ? x1 : 0; if (from < markdata->left_mar) from = markdata->left_mar; for (to = fore->w_width, im = ml->image + to; to >= 0; to--) if (*im-- != ' ') break; if (i == y2 && x2 < to) to = x2; if (to > markdata->right_mar) to = markdata->right_mar; if (redisplay == 1 && from <= to && ry >=0 && ry <= yend) MarkRedisplayLine(ry, from, to, 0); if (redisplay != 2 && pt == 0) /* don't count/copy */ continue; j = from; #ifdef DW_CHARS if (dw_right(ml, j, fore->w_encoding)) j--; #endif im = ml->image + j; #ifdef FONT fo = ml->font + j; fox = ml->fontx + j; font = ASCII; #endif for (; j <= to; j++) { c = (unsigned char)*im++; #ifdef FONT cf = (unsigned char)*fo++; cfx = (unsigned char)*fox++; # ifdef UTF8 if (fore->w_encoding == UTF8) { c |= cf << 8 | cfx << 16; if (c == UCS_HIDDEN) continue; c = ToUtf8_comb(pt, c); l += c; if (pt) pt += c; continue; } # endif # ifdef DW_CHARS if (is_dw_font(cf)) { c = c << 8 | (unsigned char)*im++; fo++; j++; } # endif if (pastefont) { c = EncodeChar(pt, c | cf << 16, fore->w_encoding, &font); l += c; if (pt) pt += c; continue; } #endif /* FONT */ if (pt) *pt++ = c; l++; } #ifdef FONT if (pastefont && font != ASCII) { if (pt) { strcpy(pt, "\033(B"); pt += 3; } l += 3; } #endif if (i != y2 && (to != fore->w_width - 1 || ml->image[to + 1] == ' ')) { /* * this code defines, what glues lines together */ switch (markdata->nonl) { case 0: /* lines separated by newlines */ if (pt) *pt++ = '\r'; l++; if (join_with_cr) { if (pt) *pt++ = '\n'; l++; } break; case 1: /* nothing to separate lines */ break; case 2: /* lines separated by blanks */ if (pt) *pt++ = ' '; l++; break; case 3: /* seperate by comma, for csh junkies */ if (pt) *pt++ = ','; l++; break; } } } return l; } /* Check if two chars are identical. All digits are treated * as same. Used for GetHistory() */ static int eq(a, b) int a, b; { if (a == b) return 1; if (a == 0 || b == 0) return 1; if (a <= '9' && a >= '0' && b <= '9' && b >= '0') return 1; return 0; } /**********************************************************************/ int GetHistory() /* return value 1 if copybuffer changed */ { int i = 0, q = 0, xx, yy, x, y; unsigned char *linep; struct mline *ml; ASSERT(display && fore); x = fore->w_x; if (x >= fore->w_width) x = fore->w_width - 1; y = fore->w_y + fore->w_histheight; debug2("cursor is at x=%d, y=%d\n", x, y); ml = WIN(y); for (xx = x - 1, linep = ml->image + xx; xx >= 0; xx--) if ((q = *linep--) != ' ' ) break; debug3("%c at (%d,%d)\n", q, xx, y); for (yy = y - 1; yy >= 0; yy--) { ml = WIN(yy); linep = ml->image; if (xx < 0 || eq(linep[xx], q)) { /* line is matching... */ for (i = fore->w_width - 1, linep += i; i >= x; i--) if (*linep-- != ' ') break; if (i >= x) break; } } if (yy < 0) return 0; if (D_user->u_plop.buf) UserFreeCopyBuffer(D_user); if ((D_user->u_plop.buf = (char *)malloc((unsigned) (i - x + 2))) == NULL) { LMsg(0, "Not enough memory... Sorry."); return 0; } bcopy((char *)linep - i + x + 1, D_user->u_plop.buf, i - x + 1); D_user->u_plop.len = i - x + 1; #ifdef ENCODINGS D_user->u_plop.enc = fore->w_encoding; #endif return 1; } /**********************************************************************/ void MarkRoutine() { int x, y; ASSERT(fore && display && D_user); debug2("MarkRoutine called: fore nr %d, display %s\n", fore->w_number, D_usertty); if (InitOverlayPage(sizeof(*markdata), &MarkLf, 1)) return; flayer->l_encoding = fore->w_encoding; flayer->l_mode = 1; markdata = (struct markdata *)flayer->l_data; markdata->md_user = D_user; /* XXX: Correct? */ markdata->md_window = fore; markdata->second = 0; markdata->rep_cnt = 0; markdata->append_mode = 0; markdata->write_buffer = 0; markdata->nonl = 0; markdata->left_mar = 0; markdata->right_mar = fore->w_width - 1; markdata->hist_offset = fore->w_histheight; x = fore->w_x; y = D2W(fore->w_y); if (x >= fore->w_width) x = fore->w_width - 1; LGotoPos(flayer, x, W2D(y)); LMsg(0, "Copy mode - Column %d Line %d(+%d) (%d,%d)", x + 1, W2D(y + 1), fore->w_histheight, fore->w_width, fore->w_height); markdata->cx = markdata->x1 = x; markdata->cy = markdata->y1 = y; flayer->l_x = x; flayer->l_y = W2D(y); } static void MarkProcess(inbufp,inlenp) char **inbufp; int *inlenp; { char *inbuf, *pt; int inlen; int cx, cy, x2, y2, j, yend; int newcopylen = 0, od; int in_mark; int rep_cnt; struct acluser *md_user; /* char *extrap = 0, extrabuf[100]; */ markdata = (struct markdata *)flayer->l_data; fore = markdata->md_window; md_user = markdata->md_user; if (inbufp == 0) { MarkAbort(); return; } LGotoPos(flayer, markdata->cx, W2D(markdata->cy)); inbuf= *inbufp; inlen= *inlenp; pt = inbuf; in_mark = 1; while (in_mark && (inlen /* || extrap */)) { unsigned char ch = (unsigned char )*pt++; inlen--; if (flayer->l_mouseevent.start) { int r = LayProcessMouse(flayer, ch); if (r == -1) LayProcessMouseSwitch(flayer, 0); else { if (r) ch = 0222; else continue; } } od = mark_key_tab[(int)ch]; rep_cnt = markdata->rep_cnt; if (od >= '0' && od <= '9' && !markdata->f_cmd.flag) { if (rep_cnt < 1001 && (od != '0' || rep_cnt != 0)) { markdata->rep_cnt = 10 * rep_cnt + od - '0'; continue; /* * Now what is that 1001 here? Well, we have a screen with * 25 * 80 = 2000 characters. Movement is at most across the full * screen. This we do with word by word movement, as character by * character movement never steps over line boundaries. The most words * we can place on the screen are 1000 single letter words. Thus 1001 * is sufficient. Users with bigger screens never write in single letter * words, as they should be more advanced. jw. * Oh, wrong. We still give even the experienced user a factor of ten. */ } } cx = markdata->cx; cy = markdata->cy; if (markdata -> f_cmd.flag) { debug2("searching for %c:%d\n",od,rep_cnt); markdata->f_cmd.flag = 0; markdata->rep_cnt = 0; if (isgraph (od)) { markdata->f_cmd.target = od; rep_cnt = (rep_cnt) ? rep_cnt : 1; nextchar(&cx, &cy, markdata->f_cmd.direction, od, rep_cnt ); revto(cx, cy); continue; } } processchar: switch (od) { case 'f': /* fall through */ case 'F': /* fall through */ case 't': /* fall through */ case 'T': /* fall through */ /* * Set f_cmd to do a search on the next key stroke. * If we break, rep_cnt will be reset, so we * continue instead. It might be cleaner to * store the rep_count in f_cmd and * break here so later followon code will be * hit. */ markdata->f_cmd.flag = 1; markdata->f_cmd.direction = od; debug("entering char search\n"); continue; case ';': case ',': if (!markdata->f_cmd.target) break; if (!rep_cnt) rep_cnt = 1; nextchar(&cx, &cy, od == ';' ? markdata->f_cmd.direction : (markdata->f_cmd.direction ^ 0x20), markdata->f_cmd.target, rep_cnt ); revto(cx, cy); break; case 'o': case 'x': if (!markdata->second) break; markdata->cx = markdata->x1; markdata->cy = markdata->y1; markdata->x1 = cx; markdata->y1 = cy; revto(markdata->cx, markdata->cy); break; case '\014': /* CTRL-L Redisplay */ Redisplay(0); LGotoPos(flayer, cx, W2D(cy)); break; case 0202: /* M-C-b */ case '\010': /* CTRL-H Backspace */ case 'h': if (rep_cnt == 0) rep_cnt = 1; revto(cx - rep_cnt, cy); break; case 0216: /* M-C-p */ case '\016': /* CTRL-N */ case 'j': if (rep_cnt == 0) rep_cnt = 1; revto(cx, cy + rep_cnt); break; case '+': if (rep_cnt == 0) rep_cnt = 1; j = cy + rep_cnt; if (j > fore->w_histheight + fore->w_height - 1) j = fore->w_histheight + fore->w_height - 1; revto(linestart(j), j); break; case '-': if (rep_cnt == 0) rep_cnt = 1; cy -= rep_cnt; if (cy < 0) cy = 0; revto(linestart(cy), cy); break; case '^': revto(linestart(cy), cy); break; case '\n': revto(markdata->left_mar, cy + 1); break; case 0220: /* M-C-p */ case '\020': /* CTRL-P */ case 'k': if (rep_cnt == 0) rep_cnt = 1; revto(cx, cy - rep_cnt); break; case 0206: /* M-C-f */ case 'l': if (rep_cnt == 0) rep_cnt = 1; revto(cx + rep_cnt, cy); break; case '\001': /* CTRL-A from tcsh/emacs */ case '0': revto(markdata->left_mar, cy); break; case '\004': /* CTRL-D down half screen */ if (rep_cnt == 0) rep_cnt = (fore->w_height + 1) >> 1; revto_line(cx, cy + rep_cnt, W2D(cy)); break; case '$': revto(lineend(cy), cy); break; case '\022': /* CTRL-R emacs style backwards search */ ISearch(-1); in_mark = 0; break; case '\023': /* CTRL-S emacs style search */ ISearch(1); in_mark = 0; break; case '\025': /* CTRL-U up half screen */ if (rep_cnt == 0) rep_cnt = (fore->w_height + 1) >> 1; revto_line(cx, cy - rep_cnt, W2D(cy)); break; case '\007': /* CTRL-G show cursorpos */ if (markdata->left_mar == 0 && markdata->right_mar == fore->w_width - 1) LMsg(0, "Column %d Line %d(+%d)", cx+1, W2D(cy)+1, markdata->hist_offset); else LMsg(0, "Column %d(%d..%d) Line %d(+%d)", cx+1, markdata->left_mar+1, markdata->right_mar+1, W2D(cy)+1, markdata->hist_offset); break; case '\002': /* CTRL-B back one page */ if (rep_cnt == 0) rep_cnt = 1; rep_cnt *= fore->w_height; revto(cx, cy - rep_cnt); break; case '\006': /* CTRL-F forward one page */ if (rep_cnt == 0) rep_cnt = 1; rep_cnt *= fore->w_height; revto(cx, cy + rep_cnt); break; case '\005': /* CTRL-E scroll up */ if (rep_cnt == 0) rep_cnt = 1; rep_cnt = MarkScrollUpDisplay(rep_cnt); if (cy < D2W(0)) revto(cx, D2W(0)); else LGotoPos(flayer, cx, W2D(cy)); break; case '\031': /* CTRL-Y scroll down */ if (rep_cnt == 0) rep_cnt = 1; rep_cnt = MarkScrollDownDisplay(rep_cnt); if (cy > D2W(fore->w_height-1)) revto(cx, D2W(fore->w_height-1)); else LGotoPos(flayer, cx, W2D(cy)); break; case '@': /* it may be useful to have a key that does nothing */ break; case '%': /* rep_cnt is a percentage for the history buffer */ if (rep_cnt < 0) rep_cnt = 0; if (rep_cnt > 100) rep_cnt = 100; revto_line(markdata->left_mar, fore->w_histheight - fore->w_scrollback_height + (int)(rep_cnt * (fore->w_scrollback_height + fore->w_height) / 100.0), (fore->w_height - 1) / 2); break; case 0201: case 'g': rep_cnt = 1; /* FALLTHROUGH */ case 0205: case 'G': /* rep_cnt is here the WIN line number */ if (rep_cnt == 0) rep_cnt = fore->w_histheight + fore->w_height; revto_line(markdata->left_mar, --rep_cnt, (fore->w_height - 1) / 2); break; case 'H': revto(markdata->left_mar, D2W(0)); break; case 'M': revto(markdata->left_mar, D2W((fore->w_height - 1) / 2)); break; case 'L': revto(markdata->left_mar, D2W(fore->w_height - 1)); break; case '|': revto(--rep_cnt, cy); break; case 'w': if (rep_cnt == 0) rep_cnt = 1; nextword(&cx, &cy, NW_MUSTMOVE, rep_cnt); revto(cx, cy); break; case 'e': case 'E': if (rep_cnt == 0) rep_cnt = 1; nextword(&cx, &cy, NW_ENDOFWORD|NW_MUSTMOVE | (od == 'E' ? NW_BIG : 0), rep_cnt); revto(cx, cy); break; case 'b': case 'B': if (rep_cnt == 0) rep_cnt = 1; nextword(&cx, &cy, NW_BACK|NW_ENDOFWORD|NW_MUSTMOVE | (od == 'B' ? NW_BIG : 0), rep_cnt); revto(cx, cy); break; case 'a': markdata->append_mode = 1 - markdata->append_mode; debug1("append mode %d--\n", markdata->append_mode); LMsg(0, (markdata->append_mode) ? ":set append" : ":set noappend"); break; case 'v': case 'V': /* this sets start column to column 9 for VI :set nu users */ if (markdata->left_mar == 8) rep_cnt = 1; else rep_cnt = 9; /* FALLTHROUGH */ case 'c': case 'C': /* set start column (c) and end column (C) */ if (markdata->second) { rem(markdata->x1, markdata->y1, cx, cy, 1, (char *)0, fore->w_height-1); /* Hack */ markdata->second = 1; /* rem turns off second */ } rep_cnt--; if (rep_cnt < 0) rep_cnt = cx; if (od != 'C') { markdata->left_mar = rep_cnt; if (markdata->left_mar > markdata->right_mar) markdata->left_mar = markdata->right_mar; } else { markdata->right_mar = rep_cnt; if (markdata->left_mar > markdata->right_mar) markdata->right_mar = markdata->left_mar; } if (markdata->second) { markdata->cx = markdata->x1; markdata->cy = markdata->y1; revto(cx, cy); } if (od == 'v' || od == 'V') LMsg(0, (markdata->left_mar != 8) ? ":set nonu" : ":set nu"); break; case 'J': /* how do you join lines in VI ? */ markdata->nonl = (markdata->nonl + 1) % 4; switch (markdata->nonl) { case 0: if (join_with_cr) LMsg(0, "Multiple lines (CR/LF)"); else LMsg(0, "Multiple lines (LF)"); break; case 1: LMsg(0, "Lines joined"); break; case 2: LMsg(0, "Lines joined with blanks"); break; case 3: LMsg(0, "Lines joined with comma"); break; } break; case '/': Search(1); in_mark = 0; break; case '?': Search(-1); in_mark = 0; break; case 'n': Search(0); break; case 'N': markdata->isdir = -markdata->isdir; Search(0); markdata->isdir = -markdata->isdir; break; case 'y': case 'Y': if (markdata->second == 0) { revto(linestart(cy), cy); markdata->second++; cx = markdata->x1 = markdata->cx; cy = markdata->y1 = markdata->cy; } if (--rep_cnt > 0) revto(cx, cy + rep_cnt); revto(lineend(markdata->cy), markdata->cy); if (od == 'y') break; /* FALLTHROUGH */ case 'W': if (od == 'W') { if (rep_cnt == 0) rep_cnt = 1; if (!markdata->second) { nextword(&cx, &cy, NW_BACK|NW_ENDOFWORD, 1); revto(cx, cy); markdata->second++; cx = markdata->x1 = markdata->cx; cy = markdata->y1 = markdata->cy; } nextword(&cx, &cy, NW_ENDOFWORD, rep_cnt); revto(cx, cy); } cx = markdata->cx; cy = markdata->cy; /* FALLTHROUGH */ case 'A': if (od == 'A') markdata->append_mode = 1; /* FALLTHROUGH */ case '>': if (od == '>') markdata->write_buffer = 1; /* FALLTHROUGH */ case ' ': case '\r': if (!markdata->second) { markdata->second++; markdata->x1 = cx; markdata->y1 = cy; revto(cx, cy); LMsg(0, "First mark set - Column %d Line %d", cx+1, W2D(cy)+1); break; } else { int append_mode = markdata->append_mode; int write_buffer = markdata->write_buffer; x2 = cx; y2 = cy; newcopylen = rem(markdata->x1, markdata->y1, x2, y2, 2, (char *)0, 0); /* count */ if (md_user->u_plop.buf && !append_mode) UserFreeCopyBuffer(md_user); yend = fore->w_height - 1; if (fore->w_histheight - markdata->hist_offset < fore->w_height) { markdata->second = 0; yend -= MarkScrollUpDisplay(fore->w_histheight - markdata->hist_offset); } if (newcopylen > 0) { /* the +3 below is for : cr + lf + \0 */ if (md_user->u_plop.buf) md_user->u_plop.buf = realloc(md_user->u_plop.buf, (unsigned) (md_user->u_plop.len + newcopylen + 3)); else { md_user->u_plop.len = 0; md_user->u_plop.buf = malloc((unsigned) (newcopylen + 3)); } if (!md_user->u_plop.buf) { MarkAbort(); in_mark = 0; LMsg(0, "Not enough memory... Sorry."); md_user->u_plop.len = 0; md_user->u_plop.buf = 0; break; } if (append_mode) { switch (markdata->nonl) { /* * this code defines, what glues lines together */ case 0: if (join_with_cr) { md_user->u_plop.buf[md_user->u_plop.len] = '\r'; md_user->u_plop.len++; } md_user->u_plop.buf[md_user->u_plop.len] = '\n'; md_user->u_plop.len++; break; case 1: break; case 2: md_user->u_plop.buf[md_user->u_plop.len] = ' '; md_user->u_plop.len++; break; case 3: md_user->u_plop.buf[md_user->u_plop.len] = ','; md_user->u_plop.len++; break; } } md_user->u_plop.len += rem(markdata->x1, markdata->y1, x2, y2, markdata->hist_offset == fore->w_histheight, md_user->u_plop.buf + md_user->u_plop.len, yend); #ifdef ENCODINGS md_user->u_plop.enc = fore->w_encoding; #endif } if (markdata->hist_offset != fore->w_histheight) { LAY_CALL_UP(LRefreshAll(flayer, 0)); } ExitOverlayPage(); WindowChanged(fore, 'P'); if (append_mode) LMsg(0, "Appended %d characters to buffer", newcopylen); else LMsg(0, "Copied %d characters into buffer", md_user->u_plop.len); if (write_buffer) WriteFile(md_user, (char *)0, DUMP_EXCHANGE); in_mark = 0; break; } case 0222: if (flayer->l_mouseevent.start) { int button = flayer->l_mouseevent.buffer[0]; if (button == 'a') { /* Scroll down */ od = 'j'; } else if (button == '`') { /* Scroll up */ od = 'k'; } else if (button == ' ') { /* Left click */ cx = flayer->l_mouseevent.buffer[1]; cy = D2W(flayer->l_mouseevent.buffer[2]); revto(cx, cy); od = ' '; } else od = 0; LayProcessMouseSwitch(flayer, 0); if (od) goto processchar; } else LayProcessMouseSwitch(flayer, 1); break; default: MarkAbort(); LMsg(0, "Copy mode aborted"); in_mark = 0; break; } if (in_mark) /* markdata may be freed */ markdata->rep_cnt = 0; } if (in_mark) { flayer->l_x = markdata->cx; flayer->l_y = W2D(markdata->cy); } *inbufp = pt; *inlenp = inlen; } void revto(tx, ty) int tx, ty; { revto_line(tx, ty, -1); } /* tx, ty: WINDOW, line: DISPLAY */ void revto_line(tx, ty, line) int tx, ty, line; { int fx, fy; int x, y, t, revst, reven, qq, ff, tt, st, en, ce = 0; int ystart = 0, yend = fore->w_height-1; int i, ry; unsigned char *wi; struct mline *ml; struct mchar mc; if (tx < 0) tx = 0; else if (tx > fore->w_width - 1) tx = fore->w_width -1; if (ty < fore->w_histheight - fore->w_scrollback_height) ty = fore->w_histheight - fore->w_scrollback_height; else if (ty > fore->w_histheight + fore->w_height - 1) ty = fore->w_histheight + fore->w_height - 1; fx = markdata->cx; fy = markdata->cy; #ifdef DW_CHARS /* don't just move inside of a kanji, the user wants to see something */ ml = WIN(ty); if (ty == fy && fx + 1 == tx && dw_right(ml, tx, fore->w_encoding) && tx < D_width - 1) tx++; if (ty == fy && fx - 1 == tx && dw_right(ml, fx, fore->w_encoding) && tx) tx--; #endif markdata->cx = tx; markdata->cy = ty; /* * if we go to a position that is currently offscreen * then scroll the screen */ i = 0; if (line >= 0 && line < fore->w_height) i = W2D(ty) - line; else if (ty < markdata->hist_offset) i = ty - markdata->hist_offset; else if (ty > markdata->hist_offset + (fore->w_height - 1)) i = ty - markdata->hist_offset - (fore->w_height - 1); if (i > 0) yend -= MarkScrollUpDisplay(i); else if (i < 0) ystart += MarkScrollDownDisplay(-i); if (markdata->second == 0) { flayer->l_x = tx; flayer->l_y = W2D(ty); LGotoPos(flayer, tx, W2D(ty)); return; } qq = markdata->x1 + markdata->y1 * fore->w_width; ff = fx + fy * fore->w_width; /* "from" offset in WIN coords */ tt = tx + ty * fore->w_width; /* "to" offset in WIN coords*/ if (ff > tt) { st = tt; en = ff; x = tx; y = ty; } else { st = ff; en = tt; x = fx; y = fy; } if (st > qq) { st++; x++; } if (en < qq) en--; if (tt > qq) { revst = qq; reven = tt; } else { revst = tt; reven = qq; } ry = y - markdata->hist_offset; if (ry < ystart) { y += (ystart - ry); x = 0; st = y * fore->w_width; ry = ystart; } ml = WIN(y); for (t = st; t <= en; t++, x++) { if (x >= fore->w_width) { x = 0; y++, ry++; ml = WIN(y); } if (ry > yend) break; if (t == st || x == 0) { wi = ml->image + fore->w_width; for (ce = fore->w_width; ce >= 0; ce--, wi--) if (*wi != ' ') break; } if (x <= ce && x >= markdata->left_mar && x <= markdata->right_mar) { #ifdef DW_CHARS if (dw_right(ml, x, fore->w_encoding)) { if (t == revst) revst--; t--; x--; } #endif if (t >= revst && t <= reven) { mc = mchar_so; #ifdef FONT if (pastefont) { mc.font = ml->font[x]; mc.fontx = ml->fontx[x]; } #endif mc.image = ml->image[x]; } else copy_mline2mchar(&mc, ml, x); #ifdef DW_CHARS if (dw_left(ml, x, fore->w_encoding)) { mc.mbcs = ml->image[x + 1]; LPutChar(flayer, &mc, x, W2D(y)); t++; } #endif LPutChar(flayer, &mc, x, W2D(y)); #ifdef DW_CHARS if (dw_left(ml, x, fore->w_encoding)) x++; #endif } } flayer->l_x = tx; flayer->l_y = W2D(ty); LGotoPos(flayer, tx, W2D(ty)); } static void MarkAbort() { int yend, redisp; debug("MarkAbort\n"); markdata = (struct markdata *)flayer->l_data; fore = markdata->md_window; yend = fore->w_height - 1; redisp = markdata->second; if (fore->w_histheight - markdata->hist_offset < fore->w_height) { markdata->second = 0; yend -= MarkScrollUpDisplay(fore->w_histheight - markdata->hist_offset); } if (markdata->hist_offset != fore->w_histheight) { LAY_CALL_UP(LRefreshAll(flayer, 0)); } else { rem(markdata->x1, markdata->y1, markdata->cx, markdata->cy, redisp, (char *)0, yend); } ExitOverlayPage(); WindowChanged(fore, 'P'); } static void MarkRedisplayLine(y, xs, xe, isblank) int y; /* NOTE: y is in DISPLAY coords system! */ int xs, xe; int isblank; { int wy, x, i, rm; int sta, sto, cp; /* NOTE: these 3 are in WINDOW coords system */ unsigned char *wi; struct mline *ml; struct mchar mchar_marked; if (y < 0) /* No special full page handling */ return; markdata = (struct markdata *)flayer->l_data; fore = markdata->md_window; mchar_marked = mchar_so; wy = D2W(y); ml = WIN(wy); if (markdata->second == 0) { if (dw_right(ml, xs, fore->w_encoding) && xs > 0) xs--; if (dw_left(ml, xe, fore->w_encoding) && xe < fore->w_width - 1) xe++; if (xs == 0 && y > 0 && wy > 0 && WIN(wy - 1)->image[flayer->l_width] == 0) LCDisplayLineWrap(flayer, ml, y, xs, xe, isblank); else LCDisplayLine(flayer, ml, y, xs, xe, isblank); return; } sta = markdata->y1 * fore->w_width + markdata->x1; sto = markdata->cy * fore->w_width + markdata->cx; if (sta > sto) { i=sta; sta=sto; sto=i; } cp = wy * fore->w_width + xs; rm = markdata->right_mar; for (x = fore->w_width, wi = ml->image + fore->w_width; x >= 0; x--, wi--) if (*wi != ' ') break; if (x < rm) rm = x; for (x = xs; x <= xe; x++, cp++) if (cp >= sta && x >= markdata->left_mar) break; #ifdef DW_CHARS if (dw_right(ml, x, fore->w_encoding)) x--; #endif if (x > xs) LCDisplayLine(flayer, ml, y, xs, x - 1, isblank); for (; x <= xe; x++, cp++) { if (cp > sto || x > rm) break; #ifdef FONT if (pastefont) { mchar_marked.font = ml->font[x]; mchar_marked.fontx = ml->fontx[x]; } #endif mchar_marked.image = ml->image[x]; #ifdef DW_CHARS mchar_marked.mbcs = 0; if (dw_left(ml, x, fore->w_encoding)) { mchar_marked.mbcs = ml->image[x + 1]; cp++; } #endif LPutChar(flayer, &mchar_marked, x, y); #ifdef DW_CHARS if (dw_left(ml, x, fore->w_encoding)) x++; #endif } if (x <= xe) LCDisplayLine(flayer, ml, y, x, xe, isblank); } /* * This ugly routine is to speed up GotoPos() */ static int MarkRewrite(ry, xs, xe, rend, doit) int ry, xs, xe, doit; struct mchar *rend; { int dx, x, y, st, en, t, rm; unsigned char *i; struct mline *ml; struct mchar mchar_marked; mchar_marked = mchar_so; debug3("MarkRewrite %d, %d-%d\n", ry, xs, xe); markdata = (struct markdata *)flayer->l_data; fore = markdata->md_window; y = D2W(ry); ml = WIN(y); #ifdef UTF8 if (fore->w_encoding && fore->w_encoding != UTF8 && D_encoding == UTF8 && ContainsSpecialDeffont(ml, xs, xe, fore->w_encoding)) return EXPENSIVE; #endif dx = xe - xs + 1; if (doit) { i = ml->image + xs; while (dx--) PUTCHAR(*i++); return 0; } if (markdata->second == 0) st = en = -1; else { st = markdata->y1 * fore->w_width + markdata->x1; en = markdata->cy * fore->w_width + markdata->cx; if (st > en) { t = st; st = en; en = t; } } t = y * fore->w_width + xs; for (rm = fore->w_width, i = ml->image + fore->w_width; rm >= 0; rm--) if (*i-- != ' ') break; if (rm > markdata->right_mar) rm = markdata->right_mar; x = xs; while (dx--) { if (t >= st && t <= en && x >= markdata->left_mar && x <= rm) { #ifdef FONT if (pastefont) { mchar_marked.font = ml->font[x]; mchar_marked.fontx = ml->fontx[x]; } #endif rend->image = mchar_marked.image; if (!cmp_mchar(rend, &mchar_marked)) return EXPENSIVE; } else { rend->image = ml->image[x]; if (!cmp_mchar_mline(rend, ml, x)) return EXPENSIVE; } x++; } return xe - xs + 1; } /* * scroll the screen contents up/down. */ static int MarkScrollUpDisplay(n) int n; { int i; debug1("MarkScrollUpDisplay(%d)\n", n); if (n <= 0) return 0; if (n > fore->w_histheight - markdata->hist_offset) n = fore->w_histheight - markdata->hist_offset; markdata->hist_offset += n; i = (n < flayer->l_height) ? n : (flayer->l_height); LScrollV(flayer, i, 0, flayer->l_height - 1, 0); while (i-- > 0) MarkRedisplayLine(flayer->l_height - i - 1, 0, flayer->l_width - 1, 1); return n; } static int MarkScrollDownDisplay(n) int n; { int i; debug1("MarkScrollDownDisplay(%d)\n", n); if (n <= 0) return 0; if (n > markdata->hist_offset) n = markdata->hist_offset; markdata->hist_offset -= n; i = (n < flayer->l_height) ? n : (flayer->l_height); LScrollV(flayer, -i, 0, fore->w_height - 1, 0); while (i-- > 0) MarkRedisplayLine(i, 0, flayer->l_width - 1, 1); return n; } void MakePaster(pa, buf, len, bufiscopy) struct paster *pa; char *buf; int len; int bufiscopy; { FreePaster(pa); pa->pa_pasteptr = buf; pa->pa_pastelen = len; if (bufiscopy) pa->pa_pastebuf = buf; pa->pa_pastelayer = flayer; DoProcess(Layer2Window(flayer), &pa->pa_pasteptr, &pa->pa_pastelen, pa); } void FreePaster(pa) struct paster *pa; { if (pa->pa_pastebuf) free(pa->pa_pastebuf); pa->pa_pastebuf = 0; pa->pa_pasteptr = 0; pa->pa_pastelen = 0; pa->pa_pastelayer = 0; evdeq(&pa->pa_slowev); } #endif /* COPY_PASTE */ screen-4.8.0/display.c0000644000175000017500000025351713616620402013530 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include #include #include #ifndef sun # include #endif #include "config.h" #include "screen.h" #include "extern.h" #include "braille.h" #include "canvas.h" /* CSI parsing status */ enum { CSI_PB=0, CSI_PX=1, CSI_PY=2, CSI_DONE=3, CSI_ESC_SEEN, CSI_BEGIN, CSI_INACTIVE, CSI_INVALID }; static int CountChars __P((int)); static int DoAddChar __P((int)); static int BlankResize __P((int, int)); static int CallRewrite __P((int, int, int, int)); static void disp_readev_fn __P((struct event *, char *)); static void disp_processinput __P((struct display *, unsigned char *, int)); static void disp_writeev_fn __P((struct event *, char *)); #ifdef linux static void disp_writeev_eagain __P((struct event *, char *)); #endif static void disp_status_fn __P((struct event *, char *)); static void disp_hstatus_fn __P((struct event *, char *)); static void disp_blocked_fn __P((struct event *, char *)); #ifdef MAPKEYS static void disp_map_fn __P((struct event *, char *)); #endif static void disp_idle_fn __P((struct event *, char *)); #ifdef BLANKER_PRG static void disp_blanker_fn __P((struct event *, char *)); #endif static void WriteLP __P((int, int)); static void INSERTCHAR __P((int)); static void RAW_PUTCHAR __P((int)); #ifdef COLOR static void SetBackColor __P((int)); #endif static void RemoveStatusMinWait __P((void)); extern struct layer *flayer; extern struct win *windows, *fore; extern struct LayFuncs WinLf; extern int use_hardstatus; extern int MsgWait, MsgMinWait; extern const int Z0width, Z1width; extern unsigned char *blank, *null; extern struct mline mline_blank, mline_null, mline_old; extern struct mchar mchar_null, mchar_blank, mchar_so; extern struct NewWindow nwin_default; extern struct action idleaction; /* XXX shouldn't be here */ extern char *hstatusstring; extern char *captionstring; extern int pastefont; extern int idletimo; #ifdef BLANKER_PRG extern int pty_preopen; #if defined(TIOCSWINSZ) || defined(TIOCGWINSZ) extern struct winsize glwz; #endif extern char **NewEnv; extern int real_uid, real_gid; extern int ServerSocket, eff_uid, eff_gid; #endif /* * tputs needs this to calculate the padding */ #ifndef NEED_OSPEED extern #endif /* NEED_OSPEED */ short ospeed; struct display *display, *displays; #ifdef COLOR int attr2color[8][4]; int nattr2color; #endif #ifndef MULTI struct display TheDisplay; #endif /* * The default values */ int defobuflimit = OBUF_MAX; int defnonblock = -1; int defmousetrack = 0; #ifdef AUTO_NUKE int defautonuke = 0; #endif int captionalways; int hardstatusemu = HSTATUS_IGNORE; int focusminwidth, focusminheight; /* * Default layer management */ void DefProcess(bufp, lenp) char **bufp; int *lenp; { *bufp += *lenp; *lenp = 0; } void DefRedisplayLine(y, xs, xe, isblank) int y, xs, xe, isblank; { if (isblank == 0 && y >= 0) DefClearLine(y, xs, xe, 0); } void DefClearLine(y, xs, xe, bce) int y, xs, xe, bce; { LClearLine(flayer, y, xs, xe, bce, (struct mline *)0); } /*ARGSUSED*/ int DefRewrite(y, xs, xe, rend, doit) int y, xs, xe, doit; struct mchar *rend; { return EXPENSIVE; } /*ARGSUSED*/ int DefResize(wi, he) int wi, he; { return -1; } void DefRestore() { LAY_DISPLAYS(flayer, InsertMode(0)); /* ChangeScrollRegion(0, D_height - 1); */ LKeypadMode(flayer, 0); LCursorkeysMode(flayer, 0); LCursorVisibility(flayer, 0); LMouseMode(flayer, 0); LSetRendition(flayer, &mchar_null); LSetFlow(flayer, nwin_default.flowflag & FLOW_NOW); } /* * Blank layer management */ struct LayFuncs BlankLf = { DefProcess, 0, DefRedisplayLine, DefClearLine, DefRewrite, BlankResize, DefRestore, 0 }; /*ARGSUSED*/ static int BlankResize(wi, he) int wi, he; { flayer->l_width = wi; flayer->l_height = he; return 0; } /* * Generate new display, start with a blank layer. * The termcap arrays are not initialised here. * The new display is placed in the displays list. */ struct display * MakeDisplay(uname, utty, term, fd, pid, Mode) char *uname, *utty, *term; int fd, pid; struct mode *Mode; { struct acluser **u; struct baud_values *b; if (!*(u = FindUserPtr(uname)) && UserAdd(uname, (char *)0, u)) return 0; /* could not find or add user */ #ifdef MULTI if ((display = (struct display *)calloc(1, sizeof(*display))) == 0) return 0; #else if (displays) return 0; bzero((char *)&TheDisplay, sizeof(TheDisplay)); display = &TheDisplay; #endif display->d_next = displays; displays = display; D_flow = 1; D_nonblock = defnonblock; D_userfd = fd; D_readev.fd = D_writeev.fd = fd; D_readev.type = EV_READ; D_writeev.type = EV_WRITE; D_readev.data = D_writeev.data = (char *)display; D_readev.handler = disp_readev_fn; D_writeev.handler = disp_writeev_fn; evenq(&D_readev); D_writeev.condpos = &D_obuflen; D_writeev.condneg = &D_obuffree; evenq(&D_writeev); D_statusev.type = EV_TIMEOUT; D_statusev.data = (char *)display; D_statusev.handler = disp_status_fn; D_hstatusev.type = EV_TIMEOUT; D_hstatusev.data = (char *)display; D_hstatusev.handler = disp_hstatus_fn; D_blockedev.type = EV_TIMEOUT; D_blockedev.data = (char *)display; D_blockedev.handler = disp_blocked_fn; D_blockedev.condpos = &D_obuffree; D_blockedev.condneg = &D_obuflenmax; D_hstatusev.handler = disp_hstatus_fn; #ifdef MAPKEYS D_mapev.type = EV_TIMEOUT; D_mapev.data = (char *)display; D_mapev.handler = disp_map_fn; #endif D_idleev.type = EV_TIMEOUT; D_idleev.data = (char *)display; D_idleev.handler = disp_idle_fn; #ifdef BLANKER_PRG D_blankerev.type = EV_READ; D_blankerev.data = (char *)display; D_blankerev.handler = disp_blanker_fn; D_blankerev.fd = -1; #endif D_OldMode = *Mode; D_status_obuffree = -1; Resize_obuf(); /* Allocate memory for buffer */ D_obufmax = defobuflimit; D_obuflenmax = D_obuflen - D_obufmax; #ifdef AUTO_NUKE D_auto_nuke = defautonuke; #endif D_obufp = D_obuf; D_printfd = -1; D_userpid = pid; #ifdef POSIX if ((b = lookup_baud((int)cfgetospeed(&D_OldMode.tio)))) D_dospeed = b->idx; #else # ifdef TERMIO if ((b = lookup_baud(D_OldMode.tio.c_cflag & CBAUD))) D_dospeed = b->idx; # else D_dospeed = (short)D_OldMode.m_ttyb.sg_ospeed; # endif #endif debug1("New displays ospeed = %d\n", D_dospeed); strncpy(D_usertty, utty, sizeof(D_usertty) - 1); D_usertty[sizeof(D_usertty) - 1] = 0; strncpy(D_termname, term, MAXTERMLEN); D_termname[MAXTERMLEN] = 0; D_user = *u; D_processinput = ProcessInput; D_mousetrack = defmousetrack; return display; } void FreeDisplay() { struct win *p; #ifdef MULTI struct display *d, **dp; #endif #ifdef FONT FreeTransTable(); #endif #ifdef BLANKER_PRG KillBlanker(); #endif if (D_userfd >= 0) { Flush(3); if (!display) return; SetTTY(D_userfd, &D_OldMode); fcntl(D_userfd, F_SETFL, 0); } freetty(); if (D_tentry) free(D_tentry); D_tentry = 0; if (D_processinputdata) free(D_processinputdata); D_processinputdata = 0; D_tcinited = 0; evdeq(&D_hstatusev); evdeq(&D_statusev); evdeq(&D_readev); evdeq(&D_writeev); evdeq(&D_blockedev); #ifdef MAPKEYS evdeq(&D_mapev); if (D_kmaps) { free(D_kmaps); D_kmaps = 0; D_aseqs = 0; D_nseqs = 0; D_seqp = 0; D_seql = 0; D_seqh = 0; } #endif evdeq(&D_idleev); #ifdef BLANKER_PRG evdeq(&D_blankerev); #endif #ifdef HAVE_BRAILLE if (bd.bd_dpy == display) { bd.bd_start_braille = 0; StartBraille(); } #endif #ifdef MULTI for (dp = &displays; (d = *dp) ; dp = &d->d_next) if (d == display) break; ASSERT(d); if (D_status_lastmsg) free(D_status_lastmsg); if (D_obuf) free(D_obuf); *dp = display->d_next; #else /* MULTI */ ASSERT(display == displays); ASSERT(display == &TheDisplay); displays = 0; #endif /* MULTI */ while (D_canvas.c_slperp) FreeCanvas(D_canvas.c_slperp); D_cvlist = 0; for (p = windows; p; p = p->w_next) { if (p->w_pdisplay == display) p->w_pdisplay = 0; if (p->w_lastdisp == display) p->w_lastdisp = 0; if (p->w_readev.condneg == &D_status || p->w_readev.condneg == &D_obuflenmax) p->w_readev.condpos = p->w_readev.condneg = 0; } #ifdef ZMODEM for (p = windows; p; p = p->w_next) if (p->w_zdisplay == display) zmodem_abort(p, 0); #endif if (D_mousetrack) { D_mousetrack = 0; MouseMode(0); } #ifdef MULTI free((char *)display); #endif display = 0; } /* * if the adaptflag is on, we keep the size of this display, else * we may try to restore our old window sizes. */ void InitTerm(adapt) int adapt; { ASSERT(display); ASSERT(D_tcinited); D_top = D_bot = -1; AddCStr(D_IS); AddCStr(D_TI); /* Check for toggle */ if (D_IM && strcmp(D_IM, D_EI)) AddCStr(D_EI); D_insert = 0; #ifdef MAPKEYS AddCStr(D_KS); AddCStr(D_CCS); #else /* Check for toggle */ if (D_KS && strcmp(D_KS, D_KE)) AddCStr(D_KE); if (D_CCS && strcmp(D_CCS, D_CCE)) AddCStr(D_CCE); #endif D_keypad = 0; D_cursorkeys = 0; AddCStr(D_ME); AddCStr(D_EA); AddCStr(D_CE0); D_rend = mchar_null; D_atyp = 0; if (adapt == 0) ResizeDisplay(D_defwidth, D_defheight); ChangeScrollRegion(0, D_height - 1); D_x = D_y = 0; Flush(3); ClearAll(); debug1("we %swant to adapt all our windows to the display\n", (adapt) ? "" : "don't "); /* In case the size was changed by a init sequence */ CheckScreenSize((adapt) ? 2 : 0); } void FinitTerm() { ASSERT(display); #ifdef BLANKER_PRG KillBlanker(); #endif if (D_tcinited) { ResizeDisplay(D_defwidth, D_defheight); InsertMode(0); ChangeScrollRegion(0, D_height - 1); KeypadMode(0); CursorkeysMode(0); CursorVisibility(0); if (D_mousetrack) D_mousetrack = 0; MouseMode(0); ExtMouseMode(0); SetRendition(&mchar_null); SetFlow(FLOW_NOW); #ifdef MAPKEYS AddCStr(D_KE); AddCStr(D_CCE); #endif if (D_hstatus) ShowHStatus((char *)0); #ifdef RXVT_OSC ClearAllXtermOSC(); #endif D_x = D_y = -1; GotoPos(0, D_height - 1); AddChar('\r'); AddChar('\n'); AddCStr(D_TE); } Flush(3); } static void INSERTCHAR(c) int c; { ASSERT(display); if (!D_insert && D_x < D_width - 1) { if (D_IC || D_CIC) { if (D_IC) AddCStr(D_IC); else AddCStr2(D_CIC, 1); RAW_PUTCHAR(c); return; } InsertMode(1); if (!D_insert) { RefreshLine(D_y, D_x, D_width-1, 0); return; } } RAW_PUTCHAR(c); } void PUTCHAR(c) int c; { ASSERT(display); if (D_insert && D_x < D_width - 1) InsertMode(0); RAW_PUTCHAR(c); } void PUTCHARLP(c) int c; { if (D_x < D_width - 1) { if (D_insert) InsertMode(0); RAW_PUTCHAR(c); return; } if (D_CLP || D_y != D_bot) { int y = D_y; RAW_PUTCHAR(c); if (D_AM && !D_CLP) GotoPos(D_width - 1, y); return; } debug("PUTCHARLP: lp_missing!\n"); D_lp_missing = 1; D_rend.image = c; D_lpchar = D_rend; #ifdef DW_CHARS /* XXX -> PutChar ? */ if (D_mbcs) { D_lpchar.mbcs = c; D_lpchar.image = D_mbcs; D_mbcs = 0; D_x--; } #endif } /* * RAW_PUTCHAR() is for all text that will be displayed. * NOTE: charset Nr. 0 has a conversion table, but c1, c2, ... don't. */ STATIC void RAW_PUTCHAR(c) int c; { ASSERT(display); #ifdef FONT # ifdef UTF8 if (D_encoding == UTF8) { c = (c & 255) | (unsigned char)D_rend.font << 8 | (unsigned char)D_rend.fontx << 16; # ifdef DW_CHARS if (D_mbcs) { c = D_mbcs; if (D_x == D_width) D_x += D_AM ? 1 : -1; D_mbcs = 0; } else if (utf8_isdouble(c)) { D_mbcs = c; D_x++; return; } # endif if (c < 32) { AddCStr2(D_CS0, '0'); AddChar(c + 0x5f); AddCStr(D_CE0); goto addedutf8; } if (c < 0x80) { if (D_xtable && D_xtable[(int)(unsigned char)D_rend.font] && D_xtable[(int)(unsigned char)D_rend.font][(int)(unsigned char)c]) AddStr(D_xtable[(int)(unsigned char)D_rend.font][(int)(unsigned char)c]); else AddChar(c); } else AddUtf8(c); goto addedutf8; } # endif # ifdef DW_CHARS if (is_dw_font(D_rend.font)) { int t = c; if (D_mbcs == 0) { D_mbcs = c; D_x++; return; } D_x--; if (D_x == D_width - 1) D_x += D_AM ? 1 : -1; c = D_mbcs; D_mbcs = t; } # endif # if defined(ENCODINGS) && defined(DW_CHARS) if (D_encoding) c = PrepareEncodedChar(c); # endif # ifdef DW_CHARS kanjiloop: # endif if (D_xtable && D_xtable[(int)(unsigned char)D_rend.font] && D_xtable[(int)(unsigned char)D_rend.font][(int)(unsigned char)c]) AddStr(D_xtable[(int)(unsigned char)D_rend.font][(int)(unsigned char)c]); else AddChar(D_rend.font != '0' ? c : D_c0_tab[(int)(unsigned char)c]); #else /* FONT */ AddChar(c); #endif /* FONT */ #ifdef UTF8 addedutf8: #endif if (++D_x >= D_width) { if (D_AM == 0) D_x = D_width - 1; else if (!D_CLP || D_x > D_width) { D_x -= D_width; if (D_y < D_height-1 && D_y != D_bot) D_y++; } } #ifdef DW_CHARS if (D_mbcs) { c = D_mbcs; D_mbcs = 0; goto kanjiloop; } #endif } static int DoAddChar(c) int c; { /* this is for ESC-sequences only (AddChar is a macro) */ AddChar(c); return c; } void AddCStr(s) char *s; { if (display && s && *s) { ospeed = D_dospeed; tputs(s, 1, DoAddChar); } } void AddCStr2(s, c) char *s; int c; { if (display && s && *s) { ospeed = D_dospeed; tputs(tgoto(s, 0, c), 1, DoAddChar); } } /* Insert mode is a toggle on some terminals, so we need this hack: */ void InsertMode(on) int on; { if (display && on != D_insert && D_IM) { D_insert = on; if (on) AddCStr(D_IM); else AddCStr(D_EI); } } /* ...and maybe keypad application mode is a toggle, too: */ void KeypadMode(on) int on; { #ifdef MAPKEYS if (display) D_keypad = on; #else if (display && D_keypad != on && D_KS) { D_keypad = on; if (on) AddCStr(D_KS); else AddCStr(D_KE); } #endif } void CursorkeysMode(on) int on; { #ifdef MAPKEYS if (display) D_cursorkeys = on; #else if (display && D_cursorkeys != on && D_CCS) { D_cursorkeys = on; if (on) AddCStr(D_CCS); else AddCStr(D_CCE); } #endif } void ReverseVideo(on) int on; { if (display && D_revvid != on && D_CVR) { D_revvid = on; if (D_revvid) AddCStr(D_CVR); else AddCStr(D_CVN); } } void CursorVisibility(v) int v; { if (display && D_curvis != v) { if (D_curvis) AddCStr(D_VE); /* do this always, just to be safe */ D_curvis = 0; if (v == -1 && D_VI) AddCStr(D_VI); else if (v == 1 && D_VS) AddCStr(D_VS); else return; D_curvis = v; } } void MouseMode(mode) int mode; { if (!display) return; if (mode < D_mousetrack) mode = D_mousetrack; if (D_mouse != mode) { char mousebuf[20]; if (!D_CXT) return; if (D_mouse) { sprintf(mousebuf, "\033[?%dl", D_mouse); AddStr(mousebuf); } if (mode) { sprintf(mousebuf, "\033[?%dh", mode); AddStr(mousebuf); } D_mouse = mode; D_mouse_parse.state = CSI_INACTIVE; } } void ExtMouseMode(mode) int mode; { if (display && D_extmouse != mode) { char mousebuf[20]; if (!D_CXT) return; if (D_extmouse) { sprintf(mousebuf, "\033[?%dl", D_extmouse); AddStr(mousebuf); } if (mode) { sprintf(mousebuf, "\033[?%dh", mode); AddStr(mousebuf); } D_extmouse = mode; D_mouse_parse.state = CSI_INACTIVE; } } static int StrCost; /* ARGSUSED */ static int CountChars(c) int c; { StrCost++; return c; } int CalcCost(s) register char *s; { ASSERT(display); if (s) { StrCost = 0; ospeed = D_dospeed; tputs(s, 1, CountChars); return StrCost; } else return EXPENSIVE; } static int CallRewrite(y, xs, xe, doit) int y, xs, xe, doit; { struct canvas *cv, *cvlist, *cvlnext; struct viewport *vp; struct layer *oldflayer; int cost; debug3("CallRewrite %d %d %d\n", y, xs, xe); ASSERT(display); ASSERT(xe >= xs); vp = 0; for (cv = D_cvlist; cv; cv = cv->c_next) { if (y < cv->c_ys || y > cv->c_ye || xe < cv->c_xs || xs > cv->c_xe) continue; for (vp = cv->c_vplist; vp; vp = vp->v_next) if (y >= vp->v_ys && y <= vp->v_ye && xe >= vp->v_xs && xs <= vp->v_xe) break; if (vp) break; } if (doit) { oldflayer = flayer; flayer = cv->c_layer; cvlist = flayer->l_cvlist; cvlnext = cv->c_lnext; flayer->l_cvlist = cv; cv->c_lnext = 0; LayRewrite(y - vp->v_yoff, xs - vp->v_xoff, xe - vp->v_xoff, &D_rend, 1); flayer->l_cvlist = cvlist; cv->c_lnext = cvlnext; flayer = oldflayer; return 0; } if (cv == 0 || cv->c_layer == 0) return EXPENSIVE; /* not found or nothing on it */ if (xs < vp->v_xs || xe > vp->v_xe) return EXPENSIVE; /* crosses viewport boundaries */ if (y - vp->v_yoff < 0 || y - vp->v_yoff >= cv->c_layer->l_height) return EXPENSIVE; /* line not on layer */ if (xs - vp->v_xoff < 0 || xe - vp->v_xoff >= cv->c_layer->l_width) return EXPENSIVE; /* line not on layer */ #ifdef UTF8 if (D_encoding == UTF8) D_rend.font = 0; #endif oldflayer = flayer; flayer = cv->c_layer; debug3("Calling Rewrite %d %d %d\n", y - vp->v_yoff, xs - vp->v_xoff, xe - vp->v_xoff); cost = LayRewrite(y - vp->v_yoff, xs - vp->v_xoff, xe - vp->v_xoff, &D_rend, 0); flayer = oldflayer; if (D_insert) cost += D_EIcost + D_IMcost; return cost; } void GotoPos(x2, y2) int x2, y2; { register int dy, dx, x1, y1; register int costx, costy; register int m; register char *s; int CMcost; enum move_t xm = M_NONE, ym = M_NONE; if (!display) return; x1 = D_x; y1 = D_y; if (x1 == D_width) { if (D_CLP && D_AM) x1 = -1; /* don't know how the terminal treats this */ else x1--; } if (x2 == D_width) x2--; dx = x2 - x1; dy = y2 - y1; if (dy == 0 && dx == 0) return; debug2("GotoPos (%d,%d)", x1, y1); debug2(" -> (%d,%d)\n", x2, y2); if (!D_MS) /* Safe to move ? */ SetRendition(&mchar_null); if (y1 < 0 /* don't know the y position */ || (y2 > D_bot && y1 <= D_bot) /* have to cross border */ || (y2 < D_top && y1 >= D_top)) /* of scrollregion ? */ { DoCM: if (D_HO && !x2 && !y2) AddCStr(D_HO); else AddCStr(tgoto(D_CM, x2, y2)); D_x = x2; D_y = y2; return; } /* some scrollregion implementations don't allow movements * away from the region. sigh. */ if ((y1 > D_bot && y2 > y1) || (y1 < D_top && y2 < y1)) goto DoCM; /* Calculate CMcost */ if (D_HO && !x2 && !y2) s = D_HO; else s = tgoto(D_CM, x2, y2); CMcost = CalcCost(s); /* Calculate the cost to move the cursor to the right x position */ costx = EXPENSIVE; if (x1 >= 0) /* relativ x positioning only if we know where we are */ { if (dx > 0) { if (D_CRI && (dx > 1 || !D_ND)) { costx = CalcCost(tgoto(D_CRI, 0, dx)); xm = M_CRI; } if ((m = D_NDcost * dx) < costx) { costx = m; xm = M_RI; } /* Speedup: dx <= LayRewrite() */ if (dx < costx && (m = CallRewrite(y1, x1, x2 - 1, 0)) < costx) { costx = m; xm = M_RW; } } else if (dx < 0) { if (D_CLE && (dx < -1 || !D_BC)) { costx = CalcCost(tgoto(D_CLE, 0, -dx)); xm = M_CLE; } if ((m = -dx * D_LEcost) < costx) { costx = m; xm = M_LE; } } else costx = 0; } /* Speedup: LayRewrite() >= x2 */ if (x2 + D_CRcost < costx && (m = (x2 ? CallRewrite(y1, 0, x2 - 1, 0) : 0) + D_CRcost) < costx) { costx = m; xm = M_CR; } /* Check if it is already cheaper to do CM */ if (costx >= CMcost) goto DoCM; /* Calculate the cost to move the cursor to the right y position */ costy = EXPENSIVE; if (dy > 0) { if (D_CDO && dy > 1) /* DO & NL are always != 0 */ { costy = CalcCost(tgoto(D_CDO, 0, dy)); ym = M_CDO; } if ((m = dy * ((x2 == 0) ? D_NLcost : D_DOcost)) < costy) { costy = m; ym = M_DO; } } else if (dy < 0) { if (D_CUP && (dy < -1 || !D_UP)) { costy = CalcCost(tgoto(D_CUP, 0, -dy)); ym = M_CUP; } if ((m = -dy * D_UPcost) < costy) { costy = m; ym = M_UP; } } else costy = 0; /* Finally check if it is cheaper to do CM */ if (costx + costy >= CMcost) goto DoCM; switch (xm) { case M_LE: while (dx++ < 0) AddCStr(D_BC); break; case M_CLE: AddCStr2(D_CLE, -dx); break; case M_RI: while (dx-- > 0) AddCStr(D_ND); break; case M_CRI: AddCStr2(D_CRI, dx); break; case M_CR: AddCStr(D_CR); D_x = 0; x1 = 0; /* FALLTHROUGH */ case M_RW: if (x1 < x2) (void) CallRewrite(y1, x1, x2 - 1, 1); break; default: break; } switch (ym) { case M_UP: while (dy++ < 0) AddCStr(D_UP); break; case M_CUP: AddCStr2(D_CUP, -dy); break; case M_DO: s = (x2 == 0) ? D_NL : D_DO; while (dy-- > 0) AddCStr(s); break; case M_CDO: AddCStr2(D_CDO, dy); break; default: break; } D_x = x2; D_y = y2; } void ClearAll() { ASSERT(display); ClearArea(0, 0, 0, D_width - 1, D_width - 1, D_height - 1, 0, 0); } void ClearArea(x1, y1, xs, xe, x2, y2, bce, uselayfn) int x1, y1, xs, xe, x2, y2, bce, uselayfn; { int y, xxe; struct canvas *cv; struct viewport *vp; debug2("Clear %d,%d", x1, y1); debug2(" %d-%d", xs, xe); debug2(" %d,%d", x2, y2); debug2(" uselayfn=%d bce=%d\n", uselayfn, bce); ASSERT(display); if (x1 == D_width) x1--; if (x2 == D_width) x2--; if (xs == -1) xs = x1; if (xe == -1) xe = x2; if (D_UT) /* Safe to erase ? */ SetRendition(&mchar_null); #ifdef COLOR if (D_BE) SetBackColor(bce); #endif if (D_lp_missing && y1 <= D_bot && xe >= D_width - 1) { if (y2 > D_bot || (y2 == D_bot && x2 >= D_width - 1)) D_lp_missing = 0; } if (x2 == D_width - 1 && (xs == 0 || y1 == y2) && xe == D_width - 1 && y2 == D_height - 1 && (!bce || D_BE)) { #ifdef AUTO_NUKE if (x1 == 0 && y1 == 0 && D_auto_nuke) NukePending(); #endif if (x1 == 0 && y1 == 0 && D_CL) { AddCStr(D_CL); D_y = D_x = 0; return; } /* * Workaround a hp700/22 terminal bug. Do not use CD where CE * is also appropriate. */ if (D_CD && (y1 < y2 || !D_CE)) { GotoPos(x1, y1); AddCStr(D_CD); return; } } if (x1 == 0 && xs == 0 && (xe == D_width - 1 || y1 == y2) && y1 == 0 && D_CCD && (!bce || D_BE)) { GotoPos(x1, y1); AddCStr(D_CCD); return; } xxe = xe; for (y = y1; y <= y2; y++, x1 = xs) { if (y == y2) xxe = x2; if (x1 == 0 && D_CB && (xxe != D_width - 1 || (D_x == xxe && D_y == y)) && (!bce || D_BE)) { GotoPos(xxe, y); AddCStr(D_CB); continue; } if (xxe == D_width - 1 && D_CE && (!bce || D_BE)) { GotoPos(x1, y); AddCStr(D_CE); continue; } if (uselayfn) { vp = 0; for (cv = D_cvlist; cv; cv = cv->c_next) { if (y < cv->c_ys || y > cv->c_ye || xxe < cv->c_xs || x1 > cv->c_xe) continue; for (vp = cv->c_vplist; vp; vp = vp->v_next) if (y >= vp->v_ys && y <= vp->v_ye && xxe >= vp->v_xs && x1 <= vp->v_xe) break; if (vp) break; } if (cv && cv->c_layer && x1 >= vp->v_xs && xxe <= vp->v_xe && y - vp->v_yoff >= 0 && y - vp->v_yoff < cv->c_layer->l_height && xxe - vp->v_xoff >= 0 && x1 - vp->v_xoff < cv->c_layer->l_width) { struct layer *oldflayer = flayer; struct canvas *cvlist, *cvlnext; flayer = cv->c_layer; cvlist = flayer->l_cvlist; cvlnext = cv->c_lnext; flayer->l_cvlist = cv; cv->c_lnext = 0; LayClearLine(y - vp->v_yoff, x1 - vp->v_xoff, xxe - vp->v_xoff, bce); flayer->l_cvlist = cvlist; cv->c_lnext = cvlnext; flayer = oldflayer; continue; } } ClearLine((struct mline *)0, y, x1, xxe, bce); } } /* * if cur_only > 0, we only redisplay current line, as a full refresh is * too expensive over a low baud line. */ void Redisplay(cur_only) int cur_only; { ASSERT(display); /* XXX do em all? */ InsertMode(0); ChangeScrollRegion(0, D_height - 1); KeypadMode(0); CursorkeysMode(0); CursorVisibility(0); MouseMode(0); ExtMouseMode(0); SetRendition(&mchar_null); SetFlow(FLOW_NOW); ClearAll(); #ifdef RXVT_OSC RefreshXtermOSC(); #endif if (cur_only > 0 && D_fore) RefreshArea(0, D_fore->w_y, D_width - 1, D_fore->w_y, 1); else RefreshAll(1); RefreshHStatus(); CV_CALL(D_forecv, LayRestore();LaySetCursor()); } void RedisplayDisplays(cur_only) int cur_only; { struct display *olddisplay = display; for (display = displays; display; display = display->d_next) Redisplay(cur_only); display = olddisplay; } /* XXX: use oml! */ void ScrollH(y, xs, xe, n, bce, oml) int y, xs, xe, n, bce; struct mline *oml; { int i; if (n == 0) return; if (xe != D_width - 1) { RefreshLine(y, xs, xe, 0); /* UpdateLine(oml, y, xs, xe); */ return; } GotoPos(xs, y); if (D_UT) SetRendition(&mchar_null); #ifdef COLOR if (D_BE) SetBackColor(bce); #endif if (n > 0) { if (n >= xe - xs + 1) n = xe - xs + 1; if (D_CDC && !(n == 1 && D_DC)) AddCStr2(D_CDC, n); else if (D_DC) { for (i = n; i--; ) AddCStr(D_DC); } else { RefreshLine(y, xs, xe, 0); /* UpdateLine(oml, y, xs, xe); */ return; } } else { if (-n >= xe - xs + 1) n = -(xe - xs + 1); if (!D_insert) { if (D_CIC && !(n == -1 && D_IC)) AddCStr2(D_CIC, -n); else if (D_IC) { for (i = -n; i--; ) AddCStr(D_IC); } else if (D_IM) { InsertMode(1); SetRendition(&mchar_null); #ifdef COLOR SetBackColor(bce); #endif for (i = -n; i--; ) INSERTCHAR(' '); bce = 0; /* all done */ } else { /* UpdateLine(oml, y, xs, xe); */ RefreshLine(y, xs, xe, 0); return; } } else { SetRendition(&mchar_null); #ifdef COLOR SetBackColor(bce); #endif for (i = -n; i--; ) INSERTCHAR(' '); bce = 0; /* all done */ } } if (bce && !D_BE) { if (n > 0) ClearLine((struct mline *)0, y, xe - n + 1, xe, bce); else ClearLine((struct mline *)0, y, xs, xs - n - 1, bce); } if (D_lp_missing && y == D_bot) { if (n > 0) WriteLP(D_width - 1 - n, y); D_lp_missing = 0; } } void ScrollV(xs, ys, xe, ye, n, bce) int xs, ys, xe, ye, n, bce; { int i; int up; int oldbot; int alok, dlok, aldlfaster; int missy = 0; ASSERT(display); if (n == 0) return; if (n >= ye - ys + 1 || -n >= ye - ys + 1) { ClearArea(xs, ys, xs, xe, xe, ye, bce, 0); return; } if (xs > D_vpxmin || xe < D_vpxmax) { RefreshArea(xs, ys, xe, ye, 0); return; } if (D_lp_missing) { if (D_bot > ye || D_bot < ys) missy = D_bot; else { missy = D_bot - n; if (missy > ye || missy < ys) D_lp_missing = 0; } } up = 1; if (n < 0) { up = 0; n = -n; } if (n >= ye - ys + 1) n = ye - ys + 1; oldbot = D_bot; if (ys < D_top || D_bot != ye) ChangeScrollRegion(ys, ye); alok = (D_AL || D_CAL || (ys >= D_top && ye == D_bot && up)); dlok = (D_DL || D_CDL || (ys >= D_top && ye == D_bot && !up)); if (D_top != ys && !(alok && dlok)) ChangeScrollRegion(ys, ye); if (D_lp_missing && (oldbot != D_bot || (oldbot == D_bot && up && D_top == ys && D_bot == ye))) { WriteLP(D_width - 1, oldbot); if (oldbot == D_bot) /* have scrolled */ { if (--n == 0) { /* XXX ChangeScrollRegion(oldtop, oldbot); */ if (bce && !D_BE) ClearLine((struct mline *)0, ye, xs, xe, bce); return; } } } if (D_UT) SetRendition(&mchar_null); #ifdef COLOR if (D_BE) SetBackColor(bce); #endif aldlfaster = (n > 1 && ys >= D_top && ye == D_bot && ((up && D_CDL) || (!up && D_CAL))); if ((up || D_SR) && D_top == ys && D_bot == ye && !aldlfaster) { if (up) { GotoPos(0, ye); for(i = n; i-- > 0; ) AddCStr(D_NL); /* was SF, I think NL is faster */ } else { GotoPos(0, ys); for(i = n; i-- > 0; ) AddCStr(D_SR); } } else if (alok && dlok) { if (up || ye != D_bot) { GotoPos(0, up ? ys : ye+1-n); if (D_CDL && !(n == 1 && D_DL)) AddCStr2(D_CDL, n); else for(i = n; i--; ) AddCStr(D_DL); } if (!up || ye != D_bot) { GotoPos(0, up ? ye+1-n : ys); if (D_CAL && !(n == 1 && D_AL)) AddCStr2(D_CAL, n); else for(i = n; i--; ) AddCStr(D_AL); } } else { RefreshArea(xs, ys, xe, ye, 0); return; } if (bce && !D_BE) { if (up) ClearArea(xs, ye - n + 1, xs, xe, xe, ye, bce, 0); else ClearArea(xs, ys, xs, xe, xe, ys + n - 1, bce, 0); } if (D_lp_missing && missy != D_bot) WriteLP(D_width - 1, missy); /* XXX ChangeScrollRegion(oldtop, oldbot); if (D_lp_missing && missy != D_bot) WriteLP(D_width - 1, missy); */ } void SetAttr(new) register int new; { register int i, j, old, typ; if (!display || (old = D_rend.attr) == new) return; #ifdef COLORS16 D_col16change = (old ^ new) & (A_BFG | A_BBG); new ^= D_col16change; if (old == new) return; #endif #if defined(TERMINFO) && defined(USE_SGR) if (D_SA) { char *tparm(); SetFont(ASCII); ospeed = D_dospeed; tputs(tparm(D_SA, new & A_SO, new & A_US, new & A_RV, new & A_BL, new & A_DI, new & A_BD, 0 , 0 , 0), 1, DoAddChar); D_rend.attr = new; D_atyp = 0; # ifdef COLOR if (D_hascolor) rend_setdefault(&D_rend); # endif return; } #endif D_rend.attr = new; typ = D_atyp; if ((new & old) != old) { if ((typ & ATYP_U)) AddCStr(D_UE); if ((typ & ATYP_S)) AddCStr(D_SE); if ((typ & ATYP_M)) { AddCStr(D_ME); #ifdef COLOR /* ansi attrib handling: \E[m resets color, too */ if (D_hascolor) rend_setdefault(&D_rend); #endif #ifdef FONT if (!D_CG0) { /* D_ME may also reset the alternate charset */ D_rend.font = 0; # ifdef ENCODINGS D_realfont = 0; # endif } #endif } old = 0; typ = 0; } old ^= new; for (i = 0, j = 1; old && i < NATTR; i++, j <<= 1) { if ((old & j) == 0) continue; old ^= j; if (D_attrtab[i]) { AddCStr(D_attrtab[i]); typ |= D_attrtyp[i]; } } D_atyp = typ; } #ifdef FONT void SetFont(new) int new; { int old = D_rend.font; if (!display || old == new) return; D_rend.font = new; #ifdef ENCODINGS if (D_encoding && CanEncodeFont(D_encoding, new)) return; if (new == D_realfont) return; D_realfont = new; #endif if (D_xtable && D_xtable[(int)(unsigned char)new] && D_xtable[(int)(unsigned char)new][256]) { AddCStr(D_xtable[(int)(unsigned char)new][256]); return; } if (!D_CG0 && new != '0') { new = ASCII; if (old == new) return; } if (new == ASCII) AddCStr(D_CE0); #ifdef DW_CHARS else if (new < ' ') { AddStr("\033$"); if (new > 2) AddChar('('); AddChar(new + '@'); } #endif else AddCStr2(D_CS0, new); } #endif #ifdef COLOR int color256to16(jj) int jj; { int min, max; int r, g, b; if (jj >= 232) { jj = (jj - 232) / 6; jj = (jj & 1) << 3 | (jj & 2 ? 7 : 0); } else if (jj >= 16) { jj -= 16; r = jj / 36; g = (jj / 6) % 6; b = jj % 6; min = r < g ? (r < b ? r : b) : (g < b ? g : b); max = r > g ? (r > b ? r : b) : (g > b ? g : b); if (min == max) jj = ((max + 1) & 2) << 2 | ((max + 1) & 4 ? 7 : 0); else jj = (b - min) / (max - min) << 2 | (g - min) / (max - min) << 1 | (r - min) / (max - min) | (max > 3 ? 8 : 0); } return jj; } #ifdef COLORS256 int color256to88(jj) int jj; { int r, g, b; if (jj >= 232) return (jj - 232) / 3 + 80; if (jj >= 16) { jj -= 16; r = jj / 36; g = (jj / 6) % 6; b = jj % 6; return ((r + 1) / 2) * 16 + ((g + 1) / 2) * 4 + ((b + 1) / 2) + 16; } return jj; } #endif void SetColor(f, b) int f, b; { int of, ob; static unsigned char sftrans[8] = {0,4,2,6,1,5,3,7}; if (!display) return; of = rend_getfg(&D_rend); ob = rend_getbg(&D_rend); #ifdef COLORS16 /* intense default not invented yet */ if (f == 0x100) f = 0; if (b == 0x100) b = 0; #endif debug2("SetColor %d %d", coli2e(of), coli2e(ob)); debug2(" -> %d %d\n", coli2e(f), coli2e(b)); debug2("(%d %d", of, ob); debug2(" -> %d %d)\n", f, b); if (!D_CAX && D_hascolor && ((f == 0 && f != of) || (b == 0 && b != ob))) { if (D_OP) AddCStr(D_OP); else { int oattr; oattr = D_rend.attr; AddCStr(D_ME ? D_ME : "\033[m"); #ifdef FONT if (D_ME && !D_CG0) { /* D_ME may also reset the alternate charset */ D_rend.font = 0; # ifdef ENCODINGS D_realfont = 0; # endif } #endif D_atyp = 0; D_rend.attr = 0; SetAttr(oattr); } of = ob = 0; } rend_setfg(&D_rend, f); rend_setbg(&D_rend, b); #ifdef COLORS16 D_col16change = 0; #endif if (!D_hascolor) return; f = f ? coli2e(f) : -1; b = b ? coli2e(b) : -1; of = of ? coli2e(of) : -1; ob = ob ? coli2e(ob) : -1; #ifdef COLORS256 if (f != of && f > 15 && D_CCO != 256) f = D_CCO == 88 && D_CAF ? color256to88(f) : color256to16(f); if (f != of && f > 15 && D_CAF) { AddCStr2(D_CAF, f); of = f; } if (b != ob && b > 15 && D_CCO != 256) b = D_CCO == 88 && D_CAB ? color256to88(b) : color256to16(b); if (b != ob && b > 15 && D_CAB) { AddCStr2(D_CAB, b); ob = b; } #endif if (f != of && f != (of | 8)) { if (f == -1) AddCStr("\033[39m"); /* works because AX is set */ else if (D_CAF) AddCStr2(D_CAF, f & 7); else if (D_CSF) AddCStr2(D_CSF, sftrans[f & 7]); } if (b != ob && b != (ob | 8)) { if (b == -1) AddCStr("\033[49m"); /* works because AX is set */ else if (D_CAB) AddCStr2(D_CAB, b & 7); else if (D_CSB) AddCStr2(D_CSB, sftrans[b & 7]); } #ifdef COLORS16 if (f != of && D_CXT && (f & 8) != 0 && f != -1) { # ifdef TERMINFO AddCStr2("\033[9%p1%dm", f & 7); # else AddCStr2("\033[9%dm", f & 7); # endif } if (b != ob && D_CXT && (b & 8) != 0 && b != -1) { # ifdef TERMINFO AddCStr2("\033[10%p1%dm", b & 7); # else AddCStr2("\033[10%dm", b & 7); # endif } #endif } static void SetBackColor(new) int new; { if (!display) return; SetColor(rend_getfg(&D_rend), new); } #endif /* COLOR */ void SetRendition(mc) struct mchar *mc; { if (!display) return; #ifdef COLOR if (nattr2color && D_hascolor && (mc->attr & nattr2color) != 0) { static struct mchar mmc; int i; mmc = *mc; for (i = 0; i < 8; i++) if (attr2color[i] && (mc->attr & (1 << i)) != 0) { if (mc->color == 0 && attr2color[i][3]) ApplyAttrColor(attr2color[i][3], &mmc); else if ((mc->color & 0x0f) == 0 && attr2color[i][2]) ApplyAttrColor(attr2color[i][2], &mmc); else if ((mc->color & 0xf0) == 0 && attr2color[i][1]) ApplyAttrColor(attr2color[i][1], &mmc); else ApplyAttrColor(attr2color[i][0], &mmc); } mc = &mmc; debug2("SetRendition: mapped to %02x %02x\n", (unsigned char)mc->attr, 0x99 - (unsigned char)mc->color); } # ifdef COLORS16 if (D_hascolor && D_CC8 && (mc->attr & (A_BFG|A_BBG))) { int a = mc->attr; if ((mc->attr & A_BFG) && D_MD) a |= A_BD; if ((mc->attr & A_BBG) && D_MB) a |= A_BL; if (D_rend.attr != a) SetAttr(a); } else # endif /* COLORS16 */ #endif /* COLOR */ if (D_rend.attr != mc->attr) SetAttr(mc->attr); #ifdef COLOR if (D_rend.color != mc->color # ifdef COLORS256 || D_rend.colorx != mc->colorx # endif # ifdef COLORS16 || D_col16change # endif ) SetColor(rend_getfg(mc), rend_getbg(mc)); #endif #ifdef FONT if (D_rend.font != mc->font) SetFont(mc->font); #ifdef UTF8 if (D_encoding == UTF8) D_rend.fontx = mc->fontx; #endif #endif } void SetRenditionMline(ml, x) struct mline *ml; int x; { if (!display) return; #ifdef COLOR if (nattr2color && D_hascolor && (ml->attr[x] & nattr2color) != 0) { struct mchar mc; copy_mline2mchar(&mc, ml, x); SetRendition(&mc); return; } # ifdef COLORS16 if (D_hascolor && D_CC8 && (ml->attr[x] & (A_BFG|A_BBG))) { int a = ml->attr[x]; if ((ml->attr[x] & A_BFG) && D_MD) a |= A_BD; if ((ml->attr[x] & A_BBG) && D_MB) a |= A_BL; if (D_rend.attr != a) SetAttr(a); } else # endif /* COLORS16 */ #endif /* COLOR */ if (D_rend.attr != ml->attr[x]) SetAttr(ml->attr[x]); #ifdef COLOR if (D_rend.color != ml->color[x] # ifdef COLORS256 || D_rend.colorx != ml->colorx[x] # endif # ifdef COLORS16 || D_col16change # endif ) { struct mchar mc; copy_mline2mchar(&mc, ml, x); SetColor(rend_getfg(&mc), rend_getbg(&mc)); } #endif #ifdef FONT if (D_rend.font != ml->font[x]) SetFont(ml->font[x]); #ifdef UTF8 if (D_encoding == UTF8) D_rend.fontx = ml->fontx[x]; #endif #endif } void MakeStatus(msg) char *msg; { register char *s, *t; register int max; if (!display) return; if (D_blocked) return; if (!D_tcinited) { debug("tc not inited, just writing msg\n"); if (D_processinputdata) return; /* XXX: better */ AddStr(msg); AddStr("\r\n"); Flush(0); return; } if (!use_hardstatus || !D_HS) { max = D_width; if (D_CLP == 0) max--; } else max = D_WS > 0 ? D_WS : (D_width - !D_CLP); if (D_status) { /* same message? */ if (strcmp(msg, D_status_lastmsg) == 0) { debug("same message - increase timeout"); if (!D_status_obufpos) SetTimeout(&D_statusev, MsgWait); return; } RemoveStatusMinWait(); } for (s = t = msg; *s && t - msg < max; ++s) if (*s == BELL) AddCStr(D_BL); else if ((unsigned char)*s >= ' ' && *s != 0177) *t++ = *s; *t = '\0'; if (t == msg) return; if (t - msg >= D_status_buflen) { char *buf; if (D_status_lastmsg) buf = realloc(D_status_lastmsg, t - msg + 1); else buf = malloc(t - msg + 1); if (buf) { D_status_lastmsg = buf; D_status_buflen = t - msg + 1; } } if (t - msg < D_status_buflen) strcpy(D_status_lastmsg, msg); D_status_len = t - msg; D_status_lastx = D_x; D_status_lasty = D_y; if (!use_hardstatus || D_has_hstatus == HSTATUS_IGNORE || D_has_hstatus == HSTATUS_MESSAGE) { D_status = STATUS_ON_WIN; debug1("using STATLINE %d\n", STATLINE); GotoPos(0, STATLINE); SetRendition(&mchar_so); InsertMode(0); AddStr(msg); if (D_status_len < max) { /* Wayne Davison: add extra space for readability */ D_status_len++; SetRendition(&mchar_null); AddChar(' '); if (D_status_len < max) { D_status_len++; AddChar(' '); AddChar('\b'); } AddChar('\b'); } D_x = -1; } else { D_status = STATUS_ON_HS; ShowHStatus(msg); } D_status_obufpos = D_obufp - D_obuf; ASSERT(D_status_obufpos > 0); if (D_status == STATUS_ON_WIN) { struct display *olddisplay = display; struct layer *oldflayer = flayer; /* this is copied over from RemoveStatus() */ D_status = 0; GotoPos(0, STATLINE); RefreshLine(STATLINE, 0, D_status_len - 1, 0); GotoPos(D_status_lastx, D_status_lasty); flayer = D_forecv ? D_forecv->c_layer : 0; if (flayer) LaySetCursor(); display = olddisplay; flayer = oldflayer; D_status = STATUS_ON_WIN; } } void RemoveStatus() { struct display *olddisplay; struct layer *oldflayer; int where; if (!display) return; if (!(where = D_status)) return; debug("RemoveStatus\n"); if (D_status_obuffree >= 0) { D_obuflen = D_status_obuflen; D_obuffree = D_status_obuffree; D_status_obuffree = -1; } D_status = 0; D_status_obufpos = 0; D_status_bell = 0; evdeq(&D_statusev); olddisplay = display; oldflayer = flayer; if (where == STATUS_ON_WIN) { if (captionalways || (D_canvas.c_slperp && D_canvas.c_slperp->c_slnext)) { GotoPos(0, STATLINE); RefreshLine(STATLINE, 0, D_status_len - 1, 0); GotoPos(D_status_lastx, D_status_lasty); } } else RefreshHStatus(); flayer = D_forecv ? D_forecv->c_layer : 0; if (flayer) LaySetCursor(); display = olddisplay; flayer = oldflayer; } /* Remove the status but make sure that it is seen for MsgMinWait ms */ static void RemoveStatusMinWait() { /* XXX: should flush output first if D_status_obufpos is set */ if (!D_status_bell && !D_status_obufpos) { struct timeval now; int ti; gettimeofday(&now, NULL); ti = (now.tv_sec - D_status_time.tv_sec) * 1000 + (now.tv_usec - D_status_time.tv_usec) / 1000; if (ti < MsgMinWait) DisplaySleep1000(MsgMinWait - ti, 0); } RemoveStatus(); } #ifdef UTF8 static int strlen_onscreen(unsigned char *c, unsigned char *end) { int len = 0; while (*c && (!end || c < end)) { int v, dec = 0; do { v = FromUtf8(*c++, &dec); if (v == -2) c--; } while (v < 0 && (!end || c < end)); if (!utf8_iscomb(v)) { if (utf8_isdouble(v)) len++; len++; } } return len; } static int PrePutWinMsg(s, start, max) char *s; int start, max; { /* Avoid double-encoding problem for a UTF-8 message on a UTF-8 locale. Ideally, this would not be necessary. But fixing it the Right Way will probably take way more time. So this will have to do for now. */ if (D_encoding == UTF8) { int chars = strlen_onscreen((unsigned char *)(s + start), (unsigned char *)(s + max)); D_encoding = 0; PutWinMsg(s, start, max + ((max - start) - chars)); /* Multibyte count */ D_encoding = UTF8; D_x -= (max - chars); /* Yak! But this is necessary to count for the fact that not every byte represents a character. */ return start + chars; } else { PutWinMsg(s, start, max); return max; } } #else static int PrePutWinMsg(s, start, max) char *s; int start, max; { PutWinMsg(s, start, max); return max; } #endif /* refresh the display's hstatus line */ void ShowHStatus(str) char *str; { int l, ox, oy, max; if (D_status == STATUS_ON_WIN && D_has_hstatus == HSTATUS_LASTLINE && STATLINE == D_height-1) return; /* sorry, in use */ if (D_blocked) return; if (D_HS && D_has_hstatus == HSTATUS_HS) { if (!D_hstatus && (str == 0 || *str == 0)) return; debug("ShowHStatus: using HS\n"); SetRendition(&mchar_null); InsertMode(0); if (D_hstatus) AddCStr(D_DS); D_hstatus = 0; if (str == 0 || *str == 0) return; AddCStr2(D_TS, 0); max = D_WS > 0 ? D_WS : (D_width - !D_CLP); if ((int)strlen(str) > max) AddStrn(str, max); else AddStr(str); AddCStr(D_FS); D_hstatus = 1; } else if (D_has_hstatus == HSTATUS_LASTLINE) { debug("ShowHStatus: using last line\n"); ox = D_x; oy = D_y; str = str ? str : ""; l = strlen(str); if (l > D_width) l = D_width; GotoPos(0, D_height - 1); SetRendition(captionalways || D_cvlist == 0 || D_cvlist->c_next ? &mchar_null: &mchar_so); l = PrePutWinMsg(str, 0, l); if (!captionalways && D_cvlist && !D_cvlist->c_next) while (l++ < D_width) PUTCHARLP(' '); if (l < D_width) ClearArea(l, D_height - 1, l, D_width - 1, D_width - 1, D_height - 1, 0, 0); if (ox != -1 && oy != -1) GotoPos(ox, oy); D_hstatus = *str ? 1 : 0; SetRendition(&mchar_null); } else if (D_has_hstatus == HSTATUS_FIRSTLINE) { debug("ShowHStatus: using first line\n"); ox = D_x; oy = D_y; str = str ? str : ""; l = strlen(str); if (l > D_width) l = D_width; GotoPos(0, 0); SetRendition(captionalways || D_cvlist == 0 || D_cvlist->c_next ? &mchar_null: &mchar_so); l = PrePutWinMsg(str, 0, l); if (!captionalways || (D_cvlist && !D_cvlist->c_next)) while (l++ < D_width) PUTCHARLP(' '); if (l < D_width) ClearArea(l, 0, l, D_width - 1, D_width - 1, 0, 0, 0); if (ox != -1 && oy != -1) GotoPos(ox, oy); D_hstatus = *str ? 1 : 0; SetRendition(&mchar_null); } else if (str && *str && D_has_hstatus == HSTATUS_MESSAGE) { debug("ShowHStatus: using message\n"); Msg(0, "%s", str); } } /* * Refreshes the harstatus of the fore window. Shouldn't be here... */ void RefreshHStatus() { char *buf; #ifdef UTF8 int extrabytes = strlen(hstatusstring) - strlen_onscreen(hstatusstring, NULL); #else int extrabytes = 0; #endif evdeq(&D_hstatusev); if (D_status == STATUS_ON_HS) return; buf = MakeWinMsgEv(hstatusstring, D_fore, '%', (D_HS && D_has_hstatus == HSTATUS_HS && D_WS > 0) ? D_WS : D_width - !D_CLP + extrabytes, &D_hstatusev, 0); if (buf && *buf) { ShowHStatus(buf); if (D_has_hstatus != HSTATUS_IGNORE && D_hstatusev.timeout.tv_sec) evenq(&D_hstatusev); } else ShowHStatus((char *)0); } /*********************************************************************/ /* * Here come the routines that refresh an arbitrary part of the screen. */ void RefreshAll(isblank) int isblank; { struct canvas *cv; ASSERT(display); debug("Signalling full refresh!\n"); for (cv = D_cvlist; cv; cv = cv->c_next) { CV_CALL(cv, LayRedisplayLine(-1, -1, -1, isblank)); display = cv->c_display; /* just in case! */ } RefreshArea(0, 0, D_width - 1, D_height - 1, isblank); } void RefreshArea(xs, ys, xe, ye, isblank) int xs, ys, xe, ye, isblank; { int y; ASSERT(display); debug2("Refresh Area: %d,%d", xs, ys); debug3(" - %d,%d (isblank=%d)\n", xe, ye, isblank); if (!isblank && xs == 0 && xe == D_width - 1 && ye == D_height - 1 && (ys == 0 || D_CD)) { ClearArea(xs, ys, xs, xe, xe, ye, 0, 0); isblank = 1; } for (y = ys; y <= ye; y++) RefreshLine(y, xs, xe, isblank); } void RefreshLine(y, from, to, isblank) int y, from, to, isblank; { struct viewport *vp, *lvp; struct canvas *cv, *lcv, *cvlist, *cvlnext; struct layer *oldflayer; int xx, yy, l; char *buf; struct win *p; ASSERT(display); debug2("RefreshLine %d %d", y, from); debug2(" %d %d\n", to, isblank); if (D_status == STATUS_ON_WIN && y == STATLINE) { if (to >= D_status_len) D_status_len = to + 1; return; /* can't refresh status */ } if (isblank == 0 && D_CE && to == D_width - 1 && from < to && D_status != STATUS_ON_HS) { GotoPos(from, y); if (D_UT || D_BE) SetRendition(&mchar_null); AddCStr(D_CE); isblank = 1; } if ((y == D_height - 1 && D_has_hstatus == HSTATUS_LASTLINE) || (y == 0 && D_has_hstatus == HSTATUS_FIRSTLINE) ) { RefreshHStatus(); return; } while (from <= to) { lcv = 0; lvp = 0; for (cv = display->d_cvlist; cv; cv = cv->c_next) { if (y == cv->c_ye + 1 && from >= cv->c_xs && from <= cv->c_xe) { #ifdef UTF8 int extrabytes = strlen(captionstring) - strlen_onscreen(captionstring, NULL); #else int extrabytes = 0; #endif p = Layer2Window(cv->c_layer); buf = MakeWinMsgEv(captionstring, p, '%', cv->c_xe - cv->c_xs + (cv->c_xe + 1 < D_width || D_CLP) + extrabytes, &cv->c_captev, 0); if (cv->c_captev.timeout.tv_sec) evenq(&cv->c_captev); xx = to > cv->c_xe ? cv->c_xe : to; l = strlen(buf); GotoPos(from, y); SetRendition(&mchar_so); if (l > xx - cv->c_xs + 1) l = xx - cv->c_xs + 1; l = PrePutWinMsg(buf, from - cv->c_xs, l + extrabytes); from = cv->c_xs + l; for (; from <= xx; from++) PUTCHARLP(' '); break; } if (from == cv->c_xe + 1 && y >= cv->c_ys && y <= cv->c_ye + 1) { GotoPos(from, y); SetRendition(&mchar_so); PUTCHARLP(' '); from++; break; } if (y < cv->c_ys || y > cv->c_ye || to < cv->c_xs || from > cv->c_xe) continue; debug2("- canvas hit: %d %d", cv->c_xs, cv->c_ys); debug2(" %d %d\n", cv->c_xe, cv->c_ye); for (vp = cv->c_vplist; vp; vp = vp->v_next) { debug2(" - vp: %d %d", vp->v_xs, vp->v_ys); debug2(" %d %d\n", vp->v_xe, vp->v_ye); /* find leftmost overlapping vp */ if (y >= vp->v_ys && y <= vp->v_ye && from <= vp->v_xe && to >= vp->v_xs && (lvp == 0 || lvp->v_xs > vp->v_xs)) { lcv = cv; lvp = vp; } } } if (cv) continue; /* we advanced from */ if (lvp == 0) break; if (from < lvp->v_xs) { if (!isblank) DisplayLine(&mline_null, &mline_blank, y, from, lvp->v_xs - 1); from = lvp->v_xs; } /* call LayRedisplayLine on canvas lcv viewport lvp */ yy = y - lvp->v_yoff; xx = to < lvp->v_xe ? to : lvp->v_xe; if (lcv->c_layer && lcv->c_xoff + lcv->c_layer->l_width == from) { GotoPos(from, y); SetRendition(&mchar_blank); PUTCHARLP('|'); from++; } if (lcv->c_layer && yy == lcv->c_layer->l_height) { GotoPos(from, y); SetRendition(&mchar_blank); while (from <= lvp->v_xe && from - lvp->v_xoff < lcv->c_layer->l_width) { PUTCHARLP('-'); from++; } if (from >= lvp->v_xe + 1) continue; } if (lcv->c_layer == 0 || yy >= lcv->c_layer->l_height || from - lvp->v_xoff >= lcv->c_layer->l_width) { if (!isblank) DisplayLine(&mline_null, &mline_blank, y, from, lvp->v_xe); from = lvp->v_xe + 1; continue; } if (xx - lvp->v_xoff >= lcv->c_layer->l_width) xx = lcv->c_layer->l_width + lvp->v_xoff - 1; oldflayer = flayer; flayer = lcv->c_layer; cvlist = flayer->l_cvlist; cvlnext = lcv->c_lnext; flayer->l_cvlist = lcv; lcv->c_lnext = 0; LayRedisplayLine(yy, from - lvp->v_xoff, xx - lvp->v_xoff, isblank); flayer->l_cvlist = cvlist; lcv->c_lnext = cvlnext; flayer = oldflayer; from = xx + 1; } if (!isblank && from <= to) DisplayLine(&mline_null, &mline_blank, y, from, to); } /*********************************************************************/ /* clear lp_missing by writing the char on the screen. The * position must be safe. */ static void WriteLP(x2, y2) int x2, y2; { struct mchar oldrend; ASSERT(display); ASSERT(D_lp_missing); oldrend = D_rend; debug2("WriteLP(%d,%d)\n", x2, y2); #ifdef DW_CHARS if (D_lpchar.mbcs) { if (x2 > 0) x2--; else D_lpchar = mchar_blank; } #endif /* Can't use PutChar */ GotoPos(x2, y2); SetRendition(&D_lpchar); PUTCHAR(D_lpchar.image); #ifdef DW_CHARS if (D_lpchar.mbcs) PUTCHAR(D_lpchar.mbcs); #endif D_lp_missing = 0; SetRendition(&oldrend); } void ClearLine(oml, y, from, to, bce) struct mline *oml; int from, to, y, bce; { int x; #ifdef COLOR struct mchar bcechar; #endif debug3("ClearLine %d,%d-%d\n", y, from, to); if (D_UT) /* Safe to erase ? */ SetRendition(&mchar_null); #ifdef COLOR if (D_BE) SetBackColor(bce); #endif if (from == 0 && D_CB && (to != D_width - 1 || (D_x == to && D_y == y)) && (!bce || D_BE)) { GotoPos(to, y); AddCStr(D_CB); return; } if (to == D_width - 1 && D_CE && (!bce || D_BE)) { GotoPos(from, y); AddCStr(D_CE); return; } if (oml == 0) oml = &mline_null; #ifdef COLOR if (!bce) { DisplayLine(oml, &mline_blank, y, from, to); return; } bcechar = mchar_null; rend_setbg(&bcechar, bce); for (x = from; x <= to; x++) copy_mchar2mline(&bcechar, &mline_old, x); DisplayLine(oml, &mline_old, y, from, to); #else DisplayLine(oml, &mline_blank, y, from, to); #endif } void DisplayLine(oml, ml, y, from, to) struct mline *oml, *ml; int from, to, y; { register int x; int last2flag = 0, delete_lp = 0; ASSERT(display); ASSERT(y >= 0 && y < D_height); ASSERT(from >= 0 && from < D_width); ASSERT(to >= 0 && to < D_width); if (!D_CLP && y == D_bot && to == D_width - 1) { if (D_lp_missing || !cmp_mline(oml, ml, to)) { #ifdef DW_CHARS if ((D_IC || D_IM) && from < to && !dw_left(ml, to, D_encoding)) #else if ((D_IC || D_IM) && from < to) #endif { last2flag = 1; D_lp_missing = 0; to--; } else { delete_lp = !cmp_mchar_mline(&mchar_blank, oml, to) && (D_CE || D_DC || D_CDC); D_lp_missing = !cmp_mchar_mline(&mchar_blank, ml, to); copy_mline2mchar(&D_lpchar, ml, to); } } to--; } #ifdef DW_CHARS if (D_mbcs) { /* finish dw-char (can happen after a wrap) */ debug("DisplayLine finishing kanji\n"); SetRenditionMline(ml, from); PUTCHAR(ml->image[from]); from++; } #endif for (x = from; x <= to; x++) { #if 0 /* no longer needed */ if (x || D_x != D_width || D_y != y - 1) #endif { if (ml != NULL && (x < to || x != D_width - 1 || ml->image[x + 1])) if (cmp_mline(oml, ml, x)) continue; GotoPos(x, y); } #ifdef DW_CHARS if (dw_right(ml, x, D_encoding)) { x--; debug1("DisplayLine on right side of dw char- x now %d\n", x); GotoPos(x, y); } if (x == to && dw_left(ml, x, D_encoding)) break; /* don't start new kanji */ #endif SetRenditionMline(ml, x); PUTCHAR(ml->image[x]); #ifdef DW_CHARS if (dw_left(ml, x, D_encoding)) PUTCHAR(ml->image[++x]); #endif } #if 0 /* not needed any longer */ /* compare != 0 because ' ' can happen when clipping occures */ if (to == D_width - 1 && y < D_height - 1 && D_x == D_width && ml->image[to + 1]) GotoPos(0, y + 1); #endif if (last2flag) { GotoPos(x, y); SetRenditionMline(ml, x + 1); PUTCHAR(ml->image[x + 1]); GotoPos(x, y); SetRenditionMline(ml, x); INSERTCHAR(ml->image[x]); } else if (delete_lp) { if (D_UT) SetRendition(&mchar_null); if (D_DC) AddCStr(D_DC); else if (D_CDC) AddCStr2(D_CDC, 1); else if (D_CE) AddCStr(D_CE); } } void PutChar(c, x, y) struct mchar *c; int x, y; { GotoPos(x, y); SetRendition(c); PUTCHARLP(c->image); #ifdef DW_CHARS if (c->mbcs) { # ifdef UTF8 if (D_encoding == UTF8) D_rend.font = 0; # endif PUTCHARLP(c->mbcs); } #endif } void InsChar(c, x, xe, y, oml) struct mchar *c; int x, xe, y; struct mline *oml; { GotoPos(x, y); if (y == D_bot && !D_CLP) { if (x == D_width - 1) { D_lp_missing = 1; D_lpchar = *c; return; } if (xe == D_width - 1) D_lp_missing = 0; } if (x == xe) { SetRendition(c); PUTCHARLP(c->image); return; } if (!(D_IC || D_CIC || D_IM) || xe != D_width - 1) { RefreshLine(y, x, xe, 0); GotoPos(x + 1, y); /* UpdateLine(oml, y, x, xe); */ return; } InsertMode(1); if (!D_insert) { #ifdef DW_CHARS if (c->mbcs && D_IC) AddCStr(D_IC); if (D_IC) AddCStr(D_IC); else AddCStr2(D_CIC, c->mbcs ? 2 : 1); #else if (D_IC) AddCStr(D_IC); else AddCStr2(D_CIC, 1); #endif } SetRendition(c); RAW_PUTCHAR(c->image); #ifdef DW_CHARS if (c->mbcs) { # ifdef UTF8 if (D_encoding == UTF8) D_rend.font = 0; # endif if (D_x == D_width - 1) PUTCHARLP(c->mbcs); else RAW_PUTCHAR(c->mbcs); } #endif } void WrapChar(c, x, y, xs, ys, xe, ye, ins) struct mchar *c; int x, y; int xs, ys, xe, ye; int ins; { int bce; #ifdef COLOR bce = rend_getbg(c); #else bce = 0; #endif debug("WrapChar:"); debug2(" x %d y %d", x, y); debug2(" Dx %d Dy %d", D_x, D_y); debug2(" xs %d ys %d", xs, ys); debug3(" xe %d ye %d ins %d\n", xe, ye, ins); if (xs != 0 || x != D_width || !D_AM) { if (y == ye) ScrollV(xs, ys, xe, ye, 1, bce); else if (y < D_height - 1) y++; if (ins) InsChar(c, xs, xe, y, 0); else PutChar(c, xs, y); return; } if (y == ye) /* we have to scroll */ { debug("- scrolling\n"); ChangeScrollRegion(ys, ye); if (D_bot != y || D_x != D_width || (!bce && !D_BE)) { debug("- have to call ScrollV\n"); ScrollV(xs, ys, xe, ye, 1, bce); y--; } } else if (y == D_bot) /* remove unusable region? */ ChangeScrollRegion(0, D_height - 1); if (D_x != D_width || D_y != y) { if (D_CLP && y >= 0) /* don't even try if !LP */ RefreshLine(y, D_width - 1, D_width - 1, 0); debug2("- refresh last char -> x,y now %d,%d\n", D_x, D_y); if (D_x != D_width || D_y != y) /* sorry, no bonus */ { if (y == ye) ScrollV(xs, ys, xe, ye, 1, bce); GotoPos(xs, y == ye || y == D_height - 1 ? y : y + 1); } } debug("- writeing new char"); if (y != ye && y < D_height - 1) y++; if (ins != D_insert) InsertMode(ins); if (ins && !D_insert) { InsChar(c, 0, xe, y, 0); debug2(" -> done with insert (%d,%d)\n", D_x, D_y); return; } D_y = y; D_x = 0; SetRendition(c); RAW_PUTCHAR(c->image); #ifdef DW_CHARS if (c->mbcs) { # ifdef UTF8 if (D_encoding == UTF8) D_rend.font = 0; # endif RAW_PUTCHAR(c->mbcs); } #endif debug2(" -> done (%d,%d)\n", D_x, D_y); } int ResizeDisplay(wi, he) int wi, he; { ASSERT(display); debug2("ResizeDisplay: to (%d,%d).\n", wi, he); if (D_width == wi && D_height == he) { debug("ResizeDisplay: No change\n"); return 0; } if (D_width != wi && (D_height == he || !D_CWS) && D_CZ0 && (wi == Z0width || wi == Z1width)) { debug("ResizeDisplay: using Z0/Z1\n"); AddCStr(wi == Z0width ? D_CZ0 : D_CZ1); ChangeScreenSize(wi, D_height, 0); return (he == D_height) ? 0 : -1; } if (D_CWS) { debug("ResizeDisplay: using WS\n"); AddCStr(tgoto(D_CWS, wi, he)); ChangeScreenSize(wi, he, 0); return 0; } return -1; } void ChangeScrollRegion(newtop, newbot) int newtop, newbot; { if (display == 0) return; if (newtop == newbot) return; /* xterm etc can't do it */ if (newtop == -1) newtop = 0; if (newbot == -1) newbot = D_height - 1; if (D_CS == 0) { D_top = 0; D_bot = D_height - 1; return; } if (D_top == newtop && D_bot == newbot) return; debug2("ChangeScrollRegion: (%d - %d)\n", newtop, newbot); AddCStr(tgoto(D_CS, newbot, newtop)); D_top = newtop; D_bot = newbot; D_y = D_x = -1; /* Just in case... */ } #ifdef RXVT_OSC #define WT_FLAG "2" /* change to "0" to set both title and icon */ void SetXtermOSC(i, s, t) int i; char *s; char *t; { static char *oscs[][2] = { { WT_FLAG ";", "screen" }, /* set window title */ { "11;", ""}, /* background RGB */ { "20;", "" }, /* background */ { "39;", "black" }, /* default foreground (black?) */ { "49;", "white" } /* default background (white?) */ }; ASSERT(display); if (!D_CXT) return; if (!s) s = ""; if (!D_xtermosc[i] && !*s) return; if (i == 0 && !D_xtermosc[0]) AddStr("\033[22;" WT_FLAG "t"); /* stack titles (xterm patch #251) */ if (!*s) s = oscs[i][1]; D_xtermosc[i] = 1; AddStr("\033]"); AddStr(oscs[i][0]); AddStr(s); AddStr(t); } void ClearAllXtermOSC() { int i; for (i = 4; i >= 0; i--) SetXtermOSC(i, 0, "\a"); if (D_xtermosc[0]) AddStr("\033[23;" WT_FLAG "t"); /* unstack titles (xterm patch #251) */ } #undef WT_FLAG #endif /* * Output buffering routines */ void AddStr(str) char *str; { register char c; ASSERT(display); #ifdef UTF8 if (D_encoding == UTF8) { while ((c = *str++)) AddUtf8((unsigned char)c); return; } #endif while ((c = *str++)) AddChar(c); } void AddStrn(str, n) char *str; int n; { register char c; ASSERT(display); #ifdef UTF8 if (D_encoding == UTF8) { while ((c = *str++) && n-- > 0) AddUtf8((unsigned char)c); } else #endif while ((c = *str++) && n-- > 0) AddChar(c); while (n-- > 0) AddChar(' '); } void Flush(progress) int progress; { register int l; int wr; register char *p; ASSERT(display); l = D_obufp - D_obuf; debug1("Flush(): %d\n", l); if (l == 0) return; ASSERT(l + D_obuffree == D_obuflen); if (D_userfd < 0) { D_obuffree += l; D_obufp = D_obuf; return; } p = D_obuf; if (!progress) { if (fcntl(D_userfd, F_SETFL, 0)) debug1("Warning: BLOCK fcntl failed: %d\n", errno); } while (l) { if (progress) { fd_set w; FD_ZERO(&w); FD_SET(D_userfd, &w); struct timeval t; t.tv_sec = progress; t.tv_usec = 0; wr = select(FD_SETSIZE, (fd_set *)0, &w, (fd_set *)0, &t); if (wr == -1) { if (errno == EINTR) continue; debug1("Warning: select failed: %d\n", errno); break; } if (wr == 0) { /* no progress after 3 seconds. sorry. */ debug1("Warning: no progress after %d seconds\n", progress); break; } } wr = write(D_userfd, p, l); if (wr <= 0) { if (errno == EINTR) continue; debug1("Writing to display: %d\n", errno); break; } D_obuffree += wr; p += wr; l -= wr; } if (l) debug1("Warning: Flush could not write %d bytes\n", l); D_obuffree += l; D_obufp = D_obuf; if (!progress) { if (fcntl(D_userfd, F_SETFL, FNBLOCK)) debug1("Warning: NBLOCK fcntl failed: %d\n", errno); } if (D_blocked == 1) D_blocked = 0; D_blocked_fuzz = 0; } void freetty() { if (D_userfd >= 0) close(D_userfd); debug1("did freetty %d\n", D_userfd); D_userfd = -1; D_obufp = 0; D_obuffree = 0; if (D_obuf) free(D_obuf); D_obuf = 0; D_obuflen = 0; D_obuflenmax = -D_obufmax; D_blocked = 0; D_blocked_fuzz = 0; } /* * Asynchronous output routines by * Tim MacKenzie (tym@dibbler.cs.monash.edu.au) */ void Resize_obuf() { register int ind; ASSERT(display); if (D_status_obuffree >= 0) { ASSERT(D_obuffree == -1); RemoveStatusMinWait(); if (--D_obuffree > 0) /* redo AddChar decrement */ return; } if (D_obuflen && D_obuf) { ind = D_obufp - D_obuf; D_obuflen += GRAIN; D_obuffree += GRAIN; D_obuf = realloc(D_obuf, D_obuflen); } else { ind = 0; D_obuflen = GRAIN; D_obuffree = GRAIN; D_obuf = malloc(D_obuflen); } if (!D_obuf) Panic(0, "Out of memory"); D_obufp = D_obuf + ind; D_obuflenmax = D_obuflen - D_obufmax; debug1("ResizeObuf: resized to %d\n", D_obuflen); } void DisplaySleep1000(n, eat) int n; int eat; { char buf; fd_set r; struct timeval t; if (n <= 0) return; if (!display) { debug("DisplaySleep has no display sigh\n"); sleep1000(n); return; } t.tv_usec = (n % 1000) * 1000; t.tv_sec = n / 1000; FD_ZERO(&r); FD_SET(D_userfd, &r); if (select(FD_SETSIZE, &r, (fd_set *)0, (fd_set *)0, &t) > 0) { debug("display activity stopped sleep\n"); if (eat) read(D_userfd, &buf, 1); } debug2("DisplaySleep(%d) ending, eat was %d\n", n, eat); } #ifdef AUTO_NUKE void NukePending() {/* Nuke pending output in current display, clear screen */ register int len; int oldtop = D_top, oldbot = D_bot; struct mchar oldrend; int oldkeypad = D_keypad, oldcursorkeys = D_cursorkeys; int oldcurvis = D_curvis; int oldmouse = D_mouse; int oldextmouse = D_extmouse; oldrend = D_rend; len = D_obufp - D_obuf; debug1("NukePending: nuking %d chars\n", len); /* Throw away any output that we can... */ # ifdef POSIX tcflush(D_userfd, TCOFLUSH); # else # ifdef TCFLSH (void) ioctl(D_userfd, TCFLSH, (char *) 1); # endif # endif D_obufp = D_obuf; D_obuffree += len; D_top = D_bot = -1; AddCStr(D_IS); AddCStr(D_TI); /* Turn off all attributes. (Tim MacKenzie) */ if (D_ME) AddCStr(D_ME); else { #ifdef COLOR if (D_hascolor) AddStr("\033[m"); /* why is D_ME not set? */ #endif AddCStr(D_SE); AddCStr(D_UE); } /* Check for toggle */ if (D_IM && strcmp(D_IM, D_EI)) AddCStr(D_EI); D_insert = 0; /* Check for toggle */ #ifdef MAPKEYS if (D_KS && strcmp(D_KS, D_KE)) AddCStr(D_KS); if (D_CCS && strcmp(D_CCS, D_CCE)) AddCStr(D_CCS); #else if (D_KS && strcmp(D_KS, D_KE)) AddCStr(D_KE); D_keypad = 0; if (D_CCS && strcmp(D_CCS, D_CCE)) AddCStr(D_CCE); D_cursorkeys = 0; #endif AddCStr(D_CE0); D_rend = mchar_null; D_atyp = 0; AddCStr(D_DS); D_hstatus = 0; AddCStr(D_VE); D_curvis = 0; ChangeScrollRegion(oldtop, oldbot); SetRendition(&oldrend); KeypadMode(oldkeypad); CursorkeysMode(oldcursorkeys); CursorVisibility(oldcurvis); MouseMode(oldmouse); ExtMouseMode(oldextmouse); if (D_CWS) { debug("ResizeDisplay: using WS\n"); AddCStr(tgoto(D_CWS, D_width, D_height)); } else if (D_CZ0 && (D_width == Z0width || D_width == Z1width)) { debug("ResizeDisplay: using Z0/Z1\n"); AddCStr(D_width == Z0width ? D_CZ0 : D_CZ1); } } #endif /* AUTO_NUKE */ #ifdef linux /* linux' select can't handle flow control, so wait 100ms if * we get EAGAIN */ static void disp_writeev_eagain(ev, data) struct event *ev; char *data; { display = (struct display *)data; evdeq(&D_writeev); D_writeev.type = EV_WRITE; D_writeev.handler = disp_writeev_fn; evenq(&D_writeev); } #endif static void disp_writeev_fn(ev, data) struct event *ev; char *data; { int len, size = OUTPUT_BLOCK_SIZE; display = (struct display *)data; len = D_obufp - D_obuf; if (len < size) size = len; if (D_status_obufpos && size > D_status_obufpos) size = D_status_obufpos; ASSERT(len >= 0); size = write(D_userfd, D_obuf, size); if (size >= 0) { len -= size; if (len) { bcopy(D_obuf + size, D_obuf, len); debug2("ASYNC: wrote %d - remaining %d\n", size, len); } D_obufp -= size; D_obuffree += size; if (D_status_obufpos) { D_status_obufpos -= size; if (!D_status_obufpos) { debug("finished writing the status message\n"); /* we're finished displaying the message! */ if (D_status == STATUS_ON_WIN) { /* setup continue trigger */ D_status_obuflen = D_obuflen; D_status_obuffree = D_obuffree; /* setting obbuffree to 0 will make AddChar call * ResizeObuf */ D_obuffree = D_obuflen = 0; } gettimeofday(&D_status_time, NULL); SetTimeout(&D_statusev, MsgWait); evenq(&D_statusev); #ifdef HAVE_BRAILLE RefreshBraille(); /* let user see multiple Msg()s */ #endif } } if (D_blocked_fuzz) { D_blocked_fuzz -= size; if (D_blocked_fuzz < 0) D_blocked_fuzz = 0; } if (D_blockedev.queued) { if (D_obufp - D_obuf > D_obufmax / 2) { debug2("%s: resetting timeout to %g secs\n", D_usertty, D_nonblock/1000.); SetTimeout(&D_blockedev, D_nonblock); } else { debug1("%s: deleting blocked timeout\n", D_usertty); evdeq(&D_blockedev); } } if (D_blocked == 1 && D_obuf == D_obufp) { /* empty again, restart output */ debug1("%s: buffer empty, unblocking\n", D_usertty); D_blocked = 0; Activate(D_fore ? D_fore->w_norefresh : 0); D_blocked_fuzz = D_obufp - D_obuf; } } else { #ifdef linux /* linux flow control is badly broken */ if (errno == EAGAIN) { evdeq(&D_writeev); D_writeev.type = EV_TIMEOUT; D_writeev.handler = disp_writeev_eagain; SetTimeout(&D_writeev, 100); evenq(&D_writeev); } #endif if (errno != EINTR && errno != EAGAIN) #if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN) if (errno != EWOULDBLOCK) #endif Msg(errno, "Error writing output to display"); } } /* maximum mouse sequence length is SGR: ESC [ < b ; x ; y M */ #define MAX_MOUSE_SEQUENCE (3+10+1+10+1+10+1) static void disp_readev_fn(ev, data) struct event *ev; char *data; { /* We have to intercept mouse sequences in order to translate them * properly, and an incoming sequence could be spread over multiple * I/O reads. When this occurs, we buffer intermediate state in * D_mouse_params, and then use the reservation at the front of * bufspace to prepend the completed and translated mouse sequence. */ int size; char bufspace[MAX_MOUSE_SEQUENCE + IOSIZE]; unsigned char *buf = bufspace + MAX_MOUSE_SEQUENCE; struct canvas *cv; display = (struct display *)data; /* Hmmmm... a bit ugly... */ if (D_forecv) for (cv = D_forecv->c_layer->l_cvlist; cv; cv = cv->c_lnext) { display = cv->c_display; if (D_status == STATUS_ON_WIN) RemoveStatus(); } display = (struct display *)data; if (D_fore == 0) size = IOSIZE; else { #ifdef PSEUDOS if (W_UWP(D_fore)) size = sizeof(D_fore->w_pwin->p_inbuf) - D_fore->w_pwin->p_inlen; else #endif size = sizeof(D_fore->w_inbuf) - D_fore->w_inlen; } if (size > IOSIZE) size = IOSIZE; if (size <= 0) size = 1; /* Always allow one char for command keys */ size = read(D_userfd, buf, size); if (size < 0) { if (errno == EINTR || errno == EAGAIN) return; #if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN) if (errno == EWOULDBLOCK) return; #endif debug1("Read error: %d - hangup!\n", errno); Hangup(); sleep(1); return; } else if (size == 0) { debug("Found EOF - hangup!\n"); Hangup(); sleep(1); return; } if (D_blocked == 4) { D_blocked = 0; #ifdef BLANKER_PRG KillBlanker(); #endif Activate(D_fore ? D_fore->w_norefresh : 0); ResetIdle(); return; } #ifdef ZMODEM if (D_blocked > 1) /* 2, 3 */ { char *bufp; struct win *p; flayer = 0; for (p = windows; p ; p = p->w_next) if (p->w_zdisplay == display) { flayer = &p->w_layer; bufp = buf; while (size > 0) LayProcess(&bufp, &size); return; } debug("zmodem window gone, deblocking display"); zmodem_abort(0, display); } #endif if (idletimo > 0) ResetIdle(); if (D_fore) D_fore->w_lastdisp = display; if (D_mouse && D_forecv) { unsigned char *bp = (unsigned char *)buf; unsigned char *end = bp + size; unsigned char *mark = NULL; /* When mouse mode is enabled, buffer up incoming CSI until we * know whether it is a mouse sequence. If not a mouse event, * emit the CSI unchanged; if an invalid mouse event, swallow * it; otherwise, translate the sequence and emit it. * * Supported mouse events take two flavors. * * VT200: CSI M Cb Cx Cy * SGR: CSI < Ps ; Ps ; Ps M|m * * UTF-8 and UXRVT modes are explicitly rejected because they * introduce incompatibilities with other control sequences. * * NOTE: applications wishing to use SGR mode will normally * enable VT200 mode first as a fallback in case the terminal * does not support SGR mode. Thus, we must expect to receive * either mode's sequences when mouse mode is enabled. We will * dutifully translate whatever arrives, without attempting to * convert between modes on behalf of the application. */ switch (D_mouse_parse.state) { case CSI_PY: case CSI_PX: case CSI_PB: /* Partial mouse sequence; do not restore suppressed * characters. We will emit a translated version (if valid) * or swallow them (otherwise). */ break; case CSI_BEGIN: /* Partial CSI; restore suppressed characters in case it * turns out not to be a mouse sequence after all. */ *(--buf) = '['; ++size; /* fall through */ case CSI_ESC_SEEN: /* Escape character; restore it in case this turns out not * to be the start of a mouse sequence after all. */ *(--buf) = '\033'; ++size; break; default: break; }; while (bp != end) { unsigned char c = *(bp++); switch (D_mouse_parse.state) { case CSI_INACTIVE: if (c == '\033') { /* potential escape sequence */ mark = bp-1; D_mouse_parse.state = CSI_ESC_SEEN; } break; case CSI_ESC_SEEN: if (c == '[') { /* continue buffering an escape sequence */ D_mouse_parse.state = CSI_BEGIN; } else D_mouse_parse.state = CSI_INACTIVE; break; case CSI_BEGIN: if (c == 'M') { /* VT200 mouse sequence */ D_mouse_parse.state = CSI_PB; D_mouse_parse.sgrmode = 0; } else if (c == '<') { /* SGR mouse sequence */ D_mouse_parse.state = CSI_PB; D_mouse_parse.params[D_mouse_parse.state] = 0; D_mouse_parse.sgrmode = 1; } else D_mouse_parse.state = CSI_INACTIVE; break; case CSI_PB: case CSI_PX: case CSI_PY: if (D_mouse_parse.sgrmode) { /* SGR mode: parse decimal numbers */ if ('0' <= c && c <= '9') { D_mouse_parse.params[D_mouse_parse.state] *= 10; D_mouse_parse.params[D_mouse_parse.state] += c - '0'; } else if (D_mouse_parse.state == CSI_PY) { if (c == 'M' || c == 'm') D_mouse_parse.state = CSI_DONE; else D_mouse_parse.state = CSI_INVALID; } else if (c == ';') { D_mouse_parse.state++; D_mouse_parse.params[D_mouse_parse.state] = 0; } else D_mouse_parse.state = CSI_INVALID; } else { /* VT200 mode: read raw binary values */ D_mouse_parse.params[D_mouse_parse.state++] = c; } break; default: break; } if (D_mouse_parse.state == CSI_INVALID) { /* swallow invalid sequence, but emit whatever came before */ if (buf < mark) disp_processinput(display, buf, mark-buf); buf = bp; size = end - bp; D_mouse_parse.state = CSI_INACTIVE; } else if (D_mouse_parse.state == CSI_DONE) { /* emit whatever came before this sequence */ if (buf < mark) disp_processinput(display, buf, mark-buf); buf = bp; size = end - bp; int x = D_mouse_parse.params[CSI_PX]; int y = D_mouse_parse.params[CSI_PY]; int bias = D_mouse_parse.sgrmode? 1 : 33; x -= bias; y -= bias; if (x >= D_forecv->c_xs && x <= D_forecv->c_xe && y >= D_forecv->c_ys && y <= D_forecv->c_ye) { if ((D_fore && D_fore->w_mouse) || (D_mousetrack && D_forecv->c_layer->l_mode == 1)) { /* Send clicks only if the window is expecting clicks */ x -= D_forecv->c_xoff; y -= D_forecv->c_yoff; if (x >= 0 && x < D_forecv->c_layer->l_width && y >= 0 && y < D_forecv->c_layer->l_height) { char tmp[MAX_MOUSE_SEQUENCE+1]; int n; x += bias; y += bias; if (D_mouse_parse.sgrmode) { n = snprintf( tmp, MAX_MOUSE_SEQUENCE, "\033[<%d;%d;%d%c", D_mouse_parse.params[CSI_PB], x, y, c); } else { n = snprintf( tmp, MAX_MOUSE_SEQUENCE, "\033[M%c%c%c", D_mouse_parse.params[CSI_PB], x, y); } if (n > MAX_MOUSE_SEQUENCE) n = MAX_MOUSE_SEQUENCE; /* emit sequence */ buf -= n; size += n; memcpy(buf, tmp, n); } } } else if (D_mousetrack) { /* 'focus' to the clicked region, only on mouse up */ int focus = 0; if (D_mouse_parse.sgrmode) focus = (c == 'm'); else focus = (D_mouse_parse.params[CSI_PB] == '#'); struct canvas *cv = FindCanvas(x, y); if (focus && cv) { SetForeCanvas(display, cv); /* XXX: Do we want to reset the input buffer? */ } } D_mouse_parse.state = CSI_INACTIVE; } } if (D_mouse_parse.state != CSI_INACTIVE) { /* suppress partial sequence at end */ size = mark? mark - buf : 0; } } if (size > 0) disp_processinput(display, buf, size); } static void disp_processinput(display, buf, size) struct display* display; unsigned char* buf; int size; { #ifdef ENCODINGS if (D_encoding != (D_forecv ? D_forecv->c_layer->l_encoding : 0)) { int i, j, c, enc; char buf2[IOSIZE * 2 + 10]; enc = D_forecv ? D_forecv->c_layer->l_encoding : 0; for (i = j = 0; i < size; i++) { c = ((unsigned char *)buf)[i]; c = DecodeChar(c, D_encoding, &D_decodestate); if (c == -2) i--; /* try char again */ if (c < 0) continue; if (pastefont) { int font = 0; j += EncodeChar(buf2 + j, c, enc, &font); j += EncodeChar(buf2 + j, -1, enc, &font); } else j += EncodeChar(buf2 + j, c, enc, 0); if (j > (int)sizeof(buf2) - 10) /* just in case... */ break; } (*D_processinput)(buf2, j); return; } #endif (*D_processinput)(buf, size); } static void disp_status_fn(ev, data) struct event *ev; char *data; { display = (struct display *)data; debug1("disp_status_fn for display %x\n", (int)display); if (D_status) RemoveStatus(); } static void disp_hstatus_fn(ev, data) struct event *ev; char *data; { display = (struct display *)data; if (D_status == STATUS_ON_HS) { SetTimeout(ev, 1); evenq(ev); return; } RefreshHStatus(); } static void disp_blocked_fn(ev, data) struct event *ev; char *data; { struct win *p; display = (struct display *)data; debug1("blocked timeout %s\n", D_usertty); if (D_obufp - D_obuf > D_obufmax + D_blocked_fuzz) { debug("stopping output to display\n"); D_blocked = 1; /* re-enable all windows */ for (p = windows; p; p = p->w_next) if (p->w_readev.condneg == &D_obuflenmax) { debug1("freeing window #%d\n", p->w_number); p->w_readev.condpos = p->w_readev.condneg = 0; } } } #ifdef MAPKEYS static void disp_map_fn(ev, data) struct event *ev; char *data; { char *p; int l, i; unsigned char *q; display = (struct display *)data; debug("Flushing map sequence\n"); if (!(l = D_seql)) return; p = (char *)D_seqp - l; D_seqp = D_kmaps + 3; D_seql = 0; if ((q = D_seqh) != 0) { D_seqh = 0; i = q[0] << 8 | q[1]; i &= ~KMAP_NOTIMEOUT; debug1("Mapping former hit #%d - ", i); debug2("%d(%s) - ", q[2], q + 3); if (StuffKey(i)) ProcessInput2((char *)q + 3, q[2]); if (display == 0) return; l -= q[2]; p += q[2]; } else D_dontmap = 1; ProcessInput(p, l); } #endif static void disp_idle_fn(ev, data) struct event *ev; char *data; { struct display *olddisplay; display = (struct display *)data; debug("idle timeout\n"); if (idletimo <= 0 || idleaction.nr == RC_ILLEGAL) return; olddisplay = display; flayer = D_forecv->c_layer; fore = D_fore; DoAction(&idleaction, -1); if (idleaction.nr == RC_BLANKER) return; for (display = displays; display; display = display->d_next) if (olddisplay == display) break; if (display) ResetIdle(); } void ResetIdle() { if (idletimo > 0) { SetTimeout(&D_idleev, idletimo); if (!D_idleev.queued) evenq(&D_idleev); } else evdeq(&D_idleev); } #ifdef BLANKER_PRG static void disp_blanker_fn(ev, data) struct event *ev; char *data; { char buf[IOSIZE], *b; int size; display = (struct display *)data; size = read(D_blankerev.fd, buf, IOSIZE); if (size <= 0) { evdeq(&D_blankerev); close(D_blankerev.fd); D_blankerev.fd = -1; return; } for (b = buf; size; size--) AddChar(*b++); } void KillBlanker() { int oldtop = D_top, oldbot = D_bot; struct mchar oldrend; if (D_blankerev.fd == -1) return; if (D_blocked == 4) D_blocked = 0; evdeq(&D_blankerev); close(D_blankerev.fd); D_blankerev.fd = -1; Kill(D_blankerpid, SIGHUP); D_top = D_bot = -1; oldrend = D_rend; if (D_ME) { AddCStr(D_ME); AddCStr(D_ME); } else { #ifdef COLOR if (D_hascolor) AddStr("\033[m\033[m"); /* why is D_ME not set? */ #endif AddCStr(D_SE); AddCStr(D_UE); } AddCStr(D_VE); AddCStr(D_CE0); D_rend = mchar_null; D_atyp = 0; D_curvis = 0; D_x = D_y = -1; ChangeScrollRegion(oldtop, oldbot); SetRendition(&oldrend); ClearAll(); } void RunBlanker(cmdv) char **cmdv; { char *m; int pid; int slave = -1; int ptype = 0; char termname[MAXTERMLEN + 6]; #ifndef TIOCSWINSZ char libuf[20], cobuf[20]; #endif char **np; strcpy(termname, "TERM="); strncpy(termname + 5, D_termname, MAXTERMLEN - 6); termname[sizeof(termname) - 1] = 0; KillBlanker(); D_blankerpid = -1; if ((D_blankerev.fd = OpenDevice(cmdv, 0, &ptype, &m)) == -1) { Msg(0, "OpenDevice failed"); return; } #ifdef O_NOCTTY if (pty_preopen) { if ((slave = open(m, O_RDWR|O_NOCTTY)) == -1) { Msg(errno, "%s", m); close(D_blankerev.fd); D_blankerev.fd = -1; return; } } #endif switch (pid = (int)fork()) { case -1: Msg(errno, "fork"); close(D_blankerev.fd); D_blankerev.fd = -1; close(slave); return; case 0: displays = 0; ServerSocket = -1; #ifdef SIGPIPE signal(SIGPIPE, SIG_DFL); #endif if (setgid(real_gid) || setuid(real_uid)) Panic(errno, "setuid/setgid"); eff_uid = real_uid; eff_gid = real_gid; brktty(D_userfd); freetty(); #ifdef DEBUG if (dfp && dfp != stderr) fclose(dfp); #endif if (slave != -1) { close(0); dup(slave); close(slave); closeallfiles(D_blankerev.fd); slave = dup(0); } else closeallfiles(D_blankerev.fd); #ifdef DEBUG if (dfp) { char buf[256]; sprintf(buf, "%s/screen.blanker", DEBUGDIR); if ((dfp = fopen(buf, "a")) == 0) dfp = stderr; else (void) chmod(buf, 0666); } debug1("=== RunBlanker: pid %d\n", (int)getpid()); #endif close(0); close(1); close(2); if (open(m, O_RDWR)) Panic(errno, "Cannot open %s", m); dup(0); dup(0); close(D_blankerev.fd); if (slave != -1) close(slave); InitPTY(0); fgtty(0); SetTTY(0, &D_OldMode); np = NewEnv + 3; *np++ = NewEnv[0]; *np++ = termname; #ifdef TIOCSWINSZ glwz.ws_col = D_width; glwz.ws_row = D_height; (void)ioctl(0, TIOCSWINSZ, (char *)&glwz); #else /* Always turn off nonblocking mode */ (void)fcntl(0, F_SETFL, 0); sprintf(libuf, "LINES=%d", D_height); sprintf(cobuf, "COLUMNS=%d", D_width); *np++ = libuf; *np++ = cobuf; #endif debug1("calling execvpe %s\n", *cmdv); execvpe(*cmdv, cmdv, NewEnv + 3); debug1("exec error: %d\n", errno); Panic(errno, "Cannot exec '%s'", *cmdv); default: break; } D_blankerpid = pid; evenq(&D_blankerev); D_blocked = 4; ClearAll(); close(slave); } #endif /* BLANKER_PRG */ screen-4.8.0/config.h.in0000644000175000017500000004640413616622370013743 0ustar amadeamade/* config.h.in. Generated from configure.ac by autoheader. */ /* Copyright (c) 1993-2000 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** * $Id$ GNU */ /********************************************************************** * * User Configuration Section */ /* * Maximum of simultaneously allowed windows per screen session. */ #ifndef MAXWIN # define MAXWIN 100 #endif /* * Define SOCKDIR to be the directory to contain the named sockets * screen creates. This should be in a common subdirectory, such as * /usr/local or /tmp. It makes things a little more secure if you * choose a directory which is not writable by everyone or where the * "sticky" bit is on, but this isn't required. * If SOCKDIR is not defined screen will put the named sockets in * the user's home directory. Notice that this can cause you problems * if some user's HOME directories are AFS- or NFS-mounted. Especially * AFS is unlikely to support named sockets. * * Screen will name the subdirectories "S-$USER" (e.g /tmp/S-davison). */ #undef SOCKDIR /* * Define this if the SOCKDIR is not shared between hosts. */ #define SOCKDIR_IS_LOCAL_TO_HOST /* * Screen can look for the environment variable $SYSSCREENRC and -if it * exists- load the file specified in that variable as global screenrc. * If you want to enable this feature, define ALLOW_SYSSCREENRC to one (1). * Otherwise ETCSCREENRC is always loaded. */ #define ALLOW_SYSSCREENRC 1 /* * Define CHECKLOGIN to force Screen users to enter their Unix password * in addition to the screen password. * * Define NOSYSLOG if yo do not have logging facilities. Currently * syslog() will be used to trace ``su'' commands only. */ #define CHECKLOGIN 1 #undef NOSYSLOG /* * define PTYMODE if you do not like the default of 0622, which allows * public write to your pty. * define PTYGROUP to some numerical group-id if you do not want the * tty to be in "your" group. * Note, screen is unable to change mode or group of the pty if it * is not installed with sufficient privilege. (e.g. set-uid-root) * define PTYROFS if the /dev/pty devices are mounted on a read-only * filesystem so screen should not even attempt to set mode or group * even if running as root (e.g. on TiVo). */ #undef PTYMODE #undef PTYGROUP #undef PTYROFS /* * If screen is NOT installed set-uid root, screen can provide tty * security by exclusively locking the ptys. While this keeps other * users from opening your ptys, it also keeps your own subprocesses * from being able to open /dev/tty. Define LOCKPTY to add this * exclusive locking. */ #undef LOCKPTY /* * If you'd rather see the status line on the first line of your * terminal rather than the last, define TOPSTAT. */ #undef TOPSTAT /* * define DETACH can detach a session. An absolute 'must'. */ #define DETACH /* * here come the erlangen extensions to screen: * define LOCK if you want to use a lock program for a screenlock. * define PASSWORD for secure reattach of your screen. * define COPY_PASTE to use the famous hacker's treasure zoo. * define POW_DETACH to have a detach_and_logout key (requires DETACH). * define REMOTE_DETACH (-d option) to move screen between terminals. * define AUTO_NUKE to enable Tim MacKenzies clear screen nuking * define PSEUDOS to allow window input/output filtering * define MULTI to allow multiple attaches. * define MULTIUSER to allow other users attach to your session * (if they are in the acl, of course) * define MAPKEYS to include input keyboard translation. * define FONT to support ISO2022/alternet charset support * define COLOR to include ansi color support. This may expose * a bug in x11r6-color-xterm. * define DW_CHARS to include support for double-width character * sets. * define ENCODINGS to include support for encodings like euc or big5. * Needs FONT to work. * define UTF8 if you want support for UTF-8 encoding. * Needs FONT and ENCODINGS to work. * define COLORS16 if you want 16 colors. * Needs COLOR to work. * define BUILTIN_TELNET to add telnet support to screen. * Syntax: screen //telnet host [port] * define RXVT_OSC if you want support for rxvts special * change fgcolor/bgcolor/bgpicture sequences */ #undef SIMPLESCREEN #ifndef SIMPLESCREEN # define LOCK # define PASSWORD # define COPY_PASTE # define REMOTE_DETACH # define POW_DETACH # define AUTO_NUKE # define PSEUDOS # define MULTI # define MULTIUSER # define MAPKEYS # define COLOR # define FONT # define DW_CHARS # define ENCODINGS # define UTF8 # define COLORS16 # define ZMODEM # define BLANKER_PRG #endif /* SIMPLESCREEN */ #undef BUILTIN_TELNET #undef RXVT_OSC #undef COLORS256 /* * If you have a braille display you should define HAVE_BRAILLE. * The code inside #ifdef HAVE_BRAILLE was contributed by Hadi Bargi * Rangin (bargi@dots.physics.orst.edu). * WARNING: this is more or less unsupported code, it may be full of * bugs leading to security holes, enable at your own risk! */ #undef HAVE_BRAILLE /* * As error messages are mostly meaningless to the user, we * try to throw out phrases that are somewhat more familiar * to ...well, at least familiar to us NetHack players. */ #ifndef NONETHACK # define NETHACK #endif /* NONETHACK */ /* * If screen is installed with permissions to update /etc/utmp (such * as if it is installed set-uid root), define UTMPOK. */ #define UTMPOK /* Set LOGINDEFAULT to one (1) * if you want entries added to /etc/utmp by default, else set it to * zero (0). * LOGINDEFAULT will be one (1) whenever LOGOUTOK is undefined! */ #define LOGINDEFAULT 1 /* Set LOGOUTOK to one (1) * if you want the user to be able to log her/his windows out. * (Meaning: They are there, but not visible in /etc/utmp). * Disabling this feature only makes sense if you have a secure /etc/utmp * database. * Negative examples: suns usually have a world writable utmp file, * xterm will run perfectly without s-bit. * * If LOGOUTOK is undefined and UTMPOK is defined, all windows are * initially and permanently logged in. * * Set CAREFULUTMP to one (1) if you want that users have at least one * window per screen session logged in. */ #define LOGOUTOK 1 #undef CAREFULUTMP /* * If UTMPOK is defined and your system (incorrectly) counts logins by * counting non-null entries in /etc/utmp (instead of counting non-null * entries with no hostname that are not on a pseudo tty), define USRLIMIT * to have screen put an upper-limit on the number of entries to write * into /etc/utmp. This helps to keep you from exceeding a limited-user * license. */ #undef USRLIMIT /* * both must be defined if you want to favor tcsendbreak over * other calls to generate a break condition on serial lines. * (Do not bother, if you are not using plain tty windows.) */ #define POSIX_HAS_A_GOOD_TCSENDBREAK #define SUNOS4_AND_WE_TRUST_TCSENDBREAK /* * to lower the interrupt load on the host machine, you may want to * adjust the VMIN and VTIME settings used for plain tty windows. * See the termio(4) manual page (Non-Canonical Mode Input Processing) * for details. * if undefined, VMIN=1, VTIME=0 is used as a default - this gives you * best user responsiveness, but highest interrupt frequency. * (Do not bother, if you are not using plain tty windows.) */ #define TTYVMIN 100 #define TTYVTIME 2 /* * looks like the above values are ignored by setting FNDELAY. * This is default for all pty/ttys, you may disable it for * ttys here. After playing with it for a while, one may find out * that this feature may cause screen to lock up. */ #ifdef bsdi # define TTY_DISABLE_FNBLOCK /* select barfs without it ... */ #endif /* * Some terminals, e.g. Wyse 120, use a bitfield to select attributes. * This doesn't work with the standard so/ul/m? terminal entries, * because they will cancel each other out. * On TERMINFO machines, "sa" (sgr) may work. If you want screen * to switch attributes only with sgr, define USE_SGR. * This is *not* recomended, do this only if you must. */ #undef USE_SGR /* * Define USE_LOCALE if you want screen to use the locale names * for the name of the month and day of the week. */ #undef USE_LOCALE /* * Define USE_PAM if your system supports PAM (Pluggable Authentication * Modules) and you want screen to use it instead of calling crypt(). * (You may also need to add -lpam to LIBS in the Makefile.) */ #undef USE_PAM /* * Define CHECK_SCREEN_W if you want screen to set TERM to screen-w * if the terminal width is greater than 131 columns. No longer needed * on modern systems which use $COLUMNS or the tty settings instead. */ #undef CHECK_SCREEN_W /********************************************************************** * * End of User Configuration Section * * Rest of this file is modified by 'configure' * Change at your own risk! * */ /* * Some defines to identify special unix variants */ #ifndef SVR4 #undef SVR4 #endif /* #ifndef __osf__ */ #ifndef MIPS #undef MIPS #endif /* #endif */ #ifndef OSX #undef OSX #endif #ifndef ISC #undef ISC #endif #ifndef sysV68 #undef sysV68 #endif #ifndef _POSIX_SOURCE #undef _POSIX_SOURCE #endif /* * Define POSIX if your system supports IEEE Std 1003.1-1988 (POSIX). */ #undef POSIX /* * Define BSDJOBS if you have BSD-style job control (both process * groups and a tty that deals correctly with them). */ #undef BSDJOBS /* * Define TERMIO if you have struct termio instead of struct sgttyb. * This is usually the case for SVID systems, where BSD uses sgttyb. * POSIX systems should define this anyway, even though they use * struct termios. */ #undef TERMIO /* * Define CYTERMIO if you have cyrillic termio modes. */ #undef CYTERMIO /* * Define TERMINFO if your machine emulates the termcap routines * with the terminfo database. * Thus the .screenrc file is parsed for * the command 'terminfo' and not 'termcap'. */ #undef TERMINFO /* * If your library does not define ospeed, define this. */ #undef NEED_OSPEED /* * Define SYSV if your machine is SYSV complient (Sys V, HPUX, A/UX) */ #ifndef SYSV #undef SYSV #endif /* * Define SIGVOID if your signal handlers return void. On older * systems, signal returns int, but on newer ones, it returns void. */ #undef SIGVOID /* * Define USESIGSET if you have sigset for BSD 4.1 reliable signals. */ #undef USESIGSET /* * Define SYSVSIGS if signal handlers must be reinstalled after * they have been called. */ #undef SYSVSIGS /* * Define BSDWAIT if your system defines a 'union wait' in * * Only allow BSDWAIT i.e. wait3 on nonposix systems, since * posix implies wait(3) and waitpid(3). vdlinden@fwi.uva.nl * */ #ifndef POSIX #undef BSDWAIT #endif /* * On RISCOS we prefer wait2() over wait3(). rouilj@sni-usa.com */ #ifdef BSDWAIT #undef USE_WAIT2 #endif /* * If your system has getutent(), pututline(), etc. to write to the * utmp file, define GETUTENT. */ #undef GETUTENT /* * Define UTHOST if the utmp file has a host field. */ #undef UTHOST /* * Define if you have the utempter utmp helper program */ #undef HAVE_UTEMPTER /* * If ttyslot() breaks getlogin() by returning indexes to utmp entries * of type DEAD_PROCESS, then our getlogin() replacement should be * selected by defining BUGGYGETLOGIN. */ #undef BUGGYGETLOGIN /* * If your system has the calls setreuid() and setregid(), * define HAVE_SETREUID. Otherwise screen will use a forked process to * safely create output files without retaining any special privileges. */ #undef HAVE_SETRESUID #undef HAVE_SETREUID /* * If your system supports BSD4.4's seteuid() and setegid(), define * HAVE_SETEUID. */ #undef HAVE_SETEUID /* * execvpe is now defined in some systems. */ #undef HAVE_EXECVPE /* * If you want the "time" command to display the current load average * define LOADAV. Maybe you must install screen with the needed * privileges to read /dev/kmem. * Note that NLIST_ stuff is only checked, when getloadavg() is not available. */ #undef LOADAV #undef LOADAV_NUM #undef LOADAV_TYPE #undef LOADAV_SCALE #undef LOADAV_GETLOADAVG #undef LOADAV_UNIX #undef LOADAV_AVENRUN #undef LOADAV_USE_NLIST64 #undef NLIST_DECLARED #undef NLIST_STRUCT #undef NLIST_NAME_UNION /* * If your system has the new format /etc/ttys (like 4.3 BSD) and the * getttyent(3) library functions, define GETTTYENT. */ #undef GETTTYENT /* * Define USEBCOPY if the bcopy/memcpy from your system's C library * supports the overlapping of source and destination blocks. When * undefined, screen uses its own (probably slower) version of bcopy(). * * SYSV machines may have a working memcpy() -- Oh, this is * quite unlikely. Tell me if you see one. * "But then, memmove() should work, if at all available" he thought... * Boing, never say "works everywhere" unless you checked SCO UNIX. * Their memove fails the test in the configure script. Sigh. (Juergen) */ #undef USEBCOPY #undef USEMEMCPY #undef USEMEMMOVE /* * If your system has vsprintf() and requires the use of the macros in * "varargs.h" to use functions with variable arguments, * define USEVARARGS. */ #undef USEVARARGS /* * If the select return value doesn't treat a descriptor that is * usable for reading and writing as two hits, define SELECT_BROKEN. */ #undef SELECT_BROKEN /* * Define this if your system exits select() immediatly if a pipe is * opened read-only and no writer has opened it. */ #undef BROKEN_PIPE /* * Define this if the unix-domain socket implementation doesn't * create a socket in the filesystem. */ #undef SOCK_NOT_IN_FS /* * If your system has setenv() and unsetenv() define USESETENV */ #undef USESETENV /* * If setenv() takes 3 arguments define HAVE_SETENV_3 */ #undef HAVE_SETENV_3 /* * If setenv() takes 2 arguments define HAVE_SETENV_2 */ #undef HAVE_SETENV_2 /* * If your system does not come with a setenv()/putenv()/getenv() * functions, you may bring in our own code by defining NEEDPUTENV. */ #undef NEEDPUTENV /* * If the passwords are stored in a shadow file and you want the * builtin lock to work properly, define SHADOWPW. */ #undef SHADOWPW /* * define HAVE_NL_LANGINFO if your system has the nl_langinfo() call * and defines CODESET. */ #undef HAVE_NL_LANGINFO /* * Newer versions of Solaris include fdwalk, which can greatly improve * the startup time of screen; otherwise screen spends a lot of time * closing file descriptors. */ #undef HAVE_FDWALK /* * define HAVE_DEV_PTC if you have a /dev/ptc character special * device. */ #undef HAVE_DEV_PTC /* * define HAVE_SVR4_PTYS if you have a /dev/ptmx character special * device and support the ptsname(), grantpt(), unlockpt() functions. */ #undef HAVE_SVR4_PTYS /* * define PTYRANGE0 and or PTYRANGE1 if you want to adapt screen * to unusual environments. E.g. For SunOs the defaults are "qpr" and * "0123456789abcdef". For SunOs 4.1.2 * #define PTYRANGE0 "pqrstuvwxyzPQRST" * is recommended by Dan Jacobson. */ #undef PTYRANGE0 #undef PTYRANGE1 /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the `fchmod' function. */ #undef HAVE_FCHMOD /* Define to 1 if you have the `fchown' function. */ #undef HAVE_FCHOWN /* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD /* Define to 1 if you have the `getpt' function. */ #undef HAVE_GETPT /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you support file names longer than 14 characters. */ #undef HAVE_LONG_FILE_NAMES /* Define to 1 if you have the `lstat' function. */ #undef HAVE_LSTAT /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the `openpty' function. */ #undef HAVE_OPENPTY /* Define to 1 if you have the `rename' function. */ #undef HAVE_RENAME /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the `strftime' function. */ #undef HAVE_STRFTIME /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_STROPTS_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `utimes' function. */ #undef HAVE_UTIMES /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* Define to 1 if you have the `_exit' function. */ #undef HAVE__EXIT /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE screen-4.8.0/pty.c0000644000175000017500000002207013616620402012663 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include #include #include #include #include "config.h" #include "screen.h" #ifndef sun # include #endif /* for solaris 2.1, Unixware (SVR4.2) and possibly others */ #ifdef HAVE_STROPTS_H # include #endif #if defined(sun) && defined(LOCKPTY) && !defined(TIOCEXCL) # include #endif #ifdef ISC # include # include # include #endif #ifdef sgi # include #endif /* sgi */ #include "extern.h" /* * if no PTYRANGE[01] is in the config file, we pick a default */ #ifndef PTYRANGE0 # define PTYRANGE0 "qpr" #endif #ifndef PTYRANGE1 # define PTYRANGE1 "0123456789abcdef" #endif /* SVR4 pseudo ttys don't seem to work with SCO-5 */ #ifdef M_UNIX # undef HAVE_SVR4_PTYS #endif extern int eff_uid; /* used for opening a new pty-pair: */ static char PtyName[32], TtyName[32]; #if !(defined(sequent) || defined(_SEQUENT_) || defined(HAVE_SVR4_PTYS)) # ifdef hpux static char PtyProto[] = "/dev/ptym/ptyXY"; static char TtyProto[] = "/dev/pty/ttyXY"; # else # ifdef M_UNIX static char PtyProto[] = "/dev/ptypXY"; static char TtyProto[] = "/dev/ttypXY"; # else static char PtyProto[] = "/dev/ptyXY"; static char TtyProto[] = "/dev/ttyXY"; # endif # endif /* hpux */ #endif static void initmaster __P((int)); #if defined(sun) /* sun's utmp_update program opens the salve side, thus corrupting */ int pty_preopen = 1; #else int pty_preopen = 0; #endif /* * Open all ptys with O_NOCTTY, just to be on the safe side * (RISCos mips breaks otherwise) */ #ifndef O_NOCTTY # define O_NOCTTY 0 #endif /***************************************************************/ static void initmaster(f) int f; { #ifdef POSIX tcflush(f, TCIOFLUSH); #else # ifdef TIOCFLUSH (void) ioctl(f, TIOCFLUSH, (char *) 0); # endif #endif #ifdef LOCKPTY (void) ioctl(f, TIOCEXCL, (char *) 0); #endif } void InitPTY(f) int f; { if (f < 0) return; #if defined(I_PUSH) && defined(HAVE_SVR4_PTYS) && !defined(sgi) && !defined(linux) && !defined(__GLIBC__) && !defined(__osf__) && !defined(M_UNIX) if (ioctl(f, I_PUSH, "ptem")) Panic(errno, "InitPTY: cannot I_PUSH ptem"); if (ioctl(f, I_PUSH, "ldterm")) Panic(errno, "InitPTY: cannot I_PUSH ldterm"); # ifdef sun if (ioctl(f, I_PUSH, "ttcompat")) Panic(errno, "InitPTY: cannot I_PUSH ttcompat"); # endif #endif } /***************************************************************/ #if defined(OSX) && !defined(PTY_DONE) #define PTY_DONE int OpenPTY(ttyn) char **ttyn; { register int f; if ((f = open_controlling_pty(TtyName)) < 0) return -1; initmaster(f); *ttyn = TtyName; return f; } #endif /***************************************************************/ #if (defined(sequent) || defined(_SEQUENT_)) && !defined(PTY_DONE) #define PTY_DONE int OpenPTY(ttyn) char **ttyn; { char *m, *s; register int f; if ((f = getpseudotty(&s, &m)) < 0) return -1; #ifdef _SEQUENT_ fvhangup(s); #endif strncpy(PtyName, m, sizeof(PtyName)); strncpy(TtyName, s, sizeof(TtyName)); initmaster(f); *ttyn = TtyName; return f; } #endif /***************************************************************/ #if defined(__sgi) && !defined(PTY_DONE) #define PTY_DONE int OpenPTY(ttyn) char **ttyn; { int f; char *name, *_getpty(); sigret_t (*sigcld)__P(SIGPROTOARG); /* * SIGCHLD set to SIG_DFL for _getpty() because it may fork() and * exec() /usr/adm/mkpts */ sigcld = signal(SIGCHLD, SIG_DFL); name = _getpty(&f, O_RDWR | O_NONBLOCK, 0600, 0); signal(SIGCHLD, sigcld); if (name == 0) return -1; initmaster(f); *ttyn = name; return f; } #endif /***************************************************************/ #if defined(MIPS) && defined(HAVE_DEV_PTC) && !defined(PTY_DONE) #define PTY_DONE int OpenPTY(ttyn) char **ttyn; { register int f; struct stat buf; strcpy(PtyName, "/dev/ptc"); if ((f = open(PtyName, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) return -1; if (fstat(f, &buf) < 0) { close(f); return -1; } sprintf(TtyName, "/dev/ttyq%d", minor(buf.st_rdev)); initmaster(f); *ttyn = TtyName; return f; } #endif /***************************************************************/ #if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE) #define PTY_DONE int OpenPTY(ttyn) char **ttyn; { register int f; char *m, *ptsname(); int unlockpt __P((int)), grantpt __P((int)); #if defined(HAVE_GETPT) && defined(linux) int getpt __P((void)); #endif sigret_t (*sigcld)__P(SIGPROTOARG); strcpy(PtyName, "/dev/ptmx"); #if defined(HAVE_GETPT) && (defined(linux) || defined(__GLIBC__)) if ((f = getpt()) == -1) #else if ((f = open(PtyName, O_RDWR | O_NOCTTY)) == -1) #endif return -1; /* * SIGCHLD set to SIG_DFL for grantpt() because it fork()s and * exec()s pt_chmod */ sigcld = signal(SIGCHLD, SIG_DFL); if ((m = ptsname(f)) == NULL || grantpt(f) || unlockpt(f)) { signal(SIGCHLD, sigcld); close(f); return -1; } signal(SIGCHLD, sigcld); if (strlen(m) < sizeof(TtyName)) strcpy(TtyName, m); else { close(f); return -1; } initmaster(f); *ttyn = TtyName; return f; } #endif /***************************************************************/ #if defined(_AIX) && defined(HAVE_DEV_PTC) && !defined(PTY_DONE) #define PTY_DONE int OpenPTY(ttyn) char **ttyn; { register int f; /* a dumb looking loop replaced by mycrofts code: */ strcpy (PtyName, "/dev/ptc"); if ((f = open (PtyName, O_RDWR | O_NOCTTY)) < 0) return -1; strncpy(TtyName, GetPtsPathOrSymlink(f), sizeof(TtyName)); if (eff_uid && access(TtyName, R_OK | W_OK)) { close(f); return -1; } initmaster(f); # ifdef _IBMR2 pty_preopen = 1; # endif *ttyn = TtyName; return f; } #endif /***************************************************************/ #if defined(HAVE_OPENPTY) && !defined(PTY_DONE) #define PTY_DONE int OpenPTY(ttyn) char **ttyn; { int f, s; if (openpty(&f, &s, TtyName, NULL, NULL) != 0) return -1; close(s); initmaster(f); pty_preopen = 1; *ttyn = TtyName; return f; } #endif /***************************************************************/ #ifndef PTY_DONE int OpenPTY(ttyn) char **ttyn; { register char *p, *q, *l, *d; register int f; debug("OpenPTY: Using BSD style ptys.\n"); strcpy(PtyName, PtyProto); strcpy(TtyName, TtyProto); for (p = PtyName; *p != 'X'; p++) ; for (q = TtyName; *q != 'X'; q++) ; for (l = PTYRANGE0; (*p = *l) != '\0'; l++) { for (d = PTYRANGE1; (p[1] = *d) != '\0'; d++) { debug1("OpenPTY tries '%s'\n", PtyName); if ((f = open(PtyName, O_RDWR | O_NOCTTY)) == -1) continue; q[0] = *l; q[1] = *d; if (eff_uid && access(TtyName, R_OK | W_OK)) { close(f); continue; } #if defined(sun) && defined(TIOCGPGRP) && !defined(SUNOS3) /* Hack to ensure that the slave side of the pty is * unused. May not work in anything other than SunOS4.1 */ { int pgrp; /* tcgetpgrp does not work (uses TIOCGETPGRP)! */ if (ioctl(f, TIOCGPGRP, (char *)&pgrp) != -1 || errno != EIO) { close(f); continue; } } #endif initmaster(f); *ttyn = TtyName; return f; } } return -1; } #endif /* len(/proc/self/fd/) + len(max 64 bit int) */ #define MAX_PTS_SYMLINK (14 + 21) char *GetPtsPathOrSymlink(int fd) { int ret; char *tty_name; static char tty_symlink[MAX_PTS_SYMLINK]; errno = 0; tty_name = ttyname(fd); if (!tty_name && errno == ENODEV) { ret = snprintf(tty_symlink, MAX_PTS_SYMLINK, "/proc/self/fd/%d", fd); if (ret < 0 || ret >= MAX_PTS_SYMLINK) return NULL; /* We are setting errno to ENODEV to allow callers to check * whether the pts device exists in another namespace. */ errno = ENODEV; return tty_symlink; } return tty_name; } screen-4.8.0/encoding.c0000644000175000017500000013357613616620402013653 0ustar amadeamade/* Copyright (c) 1993-2003 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include #include "config.h" #include "screen.h" #include "extern.h" #ifdef ENCODINGS extern unsigned char *null; extern struct display *display, *displays; extern struct layer *flayer; extern char *screenencodings; #ifdef DW_CHARS extern int cjkwidth; #endif static int encmatch __P((char *, char *)); # ifdef UTF8 static int recode_char __P((int, int, int)); static int recode_char_to_encoding __P((int, int)); static void comb_tofront __P((int, int)); # ifdef DW_CHARS static int recode_char_dw __P((int, int *, int, int)); static int recode_char_dw_to_encoding __P((int, int *, int)); # endif # endif struct encoding { char *name; char *charsets; int deffont; int usegr; int noc1; char *fontlist; }; /* big5 font: ^X */ /* KOI8-R font: 96 ! */ /* CP1251 font: 96 ? */ struct encoding encodings[] = { { "C", 0, 0, 0, 0, 0 }, { "eucJP", "B\002I\00401", 0, 1, 0, "\002\004I" }, { "SJIS", "BIBB01", 0, 1, 1, "\002I" }, { "eucKR", "B\003BB01", 0, 1, 0, "\003" }, { "eucCN", "B\001BB01", 0, 1, 0, "\001" }, { "Big5", "B\030BB01", 0, 1, 0, "\030" }, { "KOI8-R", 0, 0x80|'!', 0, 1, 0 }, { "CP1251", 0, 0x80|'?', 0, 1, 0 }, { "UTF-8", 0, -1, 0, 0, 0 }, { "ISO8859-2", 0, 0x80|'B', 0, 0, 0 }, { "ISO8859-3", 0, 0x80|'C', 0, 0, 0 }, { "ISO8859-4", 0, 0x80|'D', 0, 0, 0 }, { "ISO8859-5", 0, 0x80|'L', 0, 0, 0 }, { "ISO8859-6", 0, 0x80|'G', 0, 0, 0 }, { "ISO8859-7", 0, 0x80|'F', 0, 0, 0 }, { "ISO8859-8", 0, 0x80|'H', 0, 0, 0 }, { "ISO8859-9", 0, 0x80|'M', 0, 0, 0 }, { "ISO8859-10", 0, 0x80|'V', 0, 0, 0 }, { "ISO8859-15", 0, 0x80|'b', 0, 0, 0 }, { "jis", 0, 0, 0, 0, "\002\004I" }, { "GBK", "B\031BB01", 0x80|'b', 1, 1, "\031" } }; #ifdef UTF8 static unsigned short builtin_tabs[][2] = { { 0x30, 0 }, /* 0: special graphics (line drawing) */ { 0x005f, 0x25AE }, { 0x0060, 0x25C6 }, { 0x0061, 0x2592 }, { 0x0062, 0x2409 }, { 0x0063, 0x240C }, { 0x0064, 0x240D }, { 0x0065, 0x240A }, { 0x0066, 0x00B0 }, { 0x0067, 0x00B1 }, { 0x0068, 0x2424 }, { 0x0069, 0x240B }, { 0x006a, 0x2518 }, { 0x006b, 0x2510 }, { 0x006c, 0x250C }, { 0x006d, 0x2514 }, { 0x006e, 0x253C }, { 0x006f, 0x23BA }, { 0x0070, 0x23BB }, { 0x0071, 0x2500 }, { 0x0072, 0x23BC }, { 0x0073, 0x23BD }, { 0x0074, 0x251C }, { 0x0075, 0x2524 }, { 0x0076, 0x2534 }, { 0x0077, 0x252C }, { 0x0078, 0x2502 }, { 0x0079, 0x2264 }, { 0x007a, 0x2265 }, { 0x007b, 0x03C0 }, { 0x007c, 0x2260 }, { 0x007d, 0x00A3 }, { 0x007e, 0x00B7 }, { 0, 0}, { 0x34, 0 }, /* 4: Dutch */ { 0x0023, 0x00a3 }, { 0x0040, 0x00be }, { 0x005b, 0x00ff }, { 0x005c, 0x00bd }, { 0x005d, 0x007c }, { 0x007b, 0x00a8 }, { 0x007c, 0x0066 }, { 0x007d, 0x00bc }, { 0x007e, 0x00b4 }, { 0, 0}, { 0x35, 0 }, /* 5: Finnish */ { 0x005b, 0x00c4 }, { 0x005c, 0x00d6 }, { 0x005d, 0x00c5 }, { 0x005e, 0x00dc }, { 0x0060, 0x00e9 }, { 0x007b, 0x00e4 }, { 0x007c, 0x00f6 }, { 0x007d, 0x00e5 }, { 0x007e, 0x00fc }, { 0, 0}, { 0x36, 0 }, /* 6: Norwegian/Danish */ { 0x0040, 0x00c4 }, { 0x005b, 0x00c6 }, { 0x005c, 0x00d8 }, { 0x005d, 0x00c5 }, { 0x005e, 0x00dc }, { 0x0060, 0x00e4 }, { 0x007b, 0x00e6 }, { 0x007c, 0x00f8 }, { 0x007d, 0x00e5 }, { 0x007e, 0x00fc }, { 0, 0}, { 0x37, 0 }, /* 7: Swedish */ { 0x0040, 0x00c9 }, { 0x005b, 0x00c4 }, { 0x005c, 0x00d6 }, { 0x005d, 0x00c5 }, { 0x005e, 0x00dc }, { 0x0060, 0x00e9 }, { 0x007b, 0x00e4 }, { 0x007c, 0x00f6 }, { 0x007d, 0x00e5 }, { 0x007e, 0x00fc }, { 0, 0}, { 0x3d, 0}, /* =: Swiss */ { 0x0023, 0x00f9 }, { 0x0040, 0x00e0 }, { 0x005b, 0x00e9 }, { 0x005c, 0x00e7 }, { 0x005d, 0x00ea }, { 0x005e, 0x00ee }, { 0x005f, 0x00e8 }, { 0x0060, 0x00f4 }, { 0x007b, 0x00e4 }, { 0x007c, 0x00f6 }, { 0x007d, 0x00fc }, { 0x007e, 0x00fb }, { 0, 0}, { 0x41, 0}, /* A: UK */ { 0x0023, 0x00a3 }, { 0, 0}, { 0x4b, 0}, /* K: German */ { 0x0040, 0x00a7 }, { 0x005b, 0x00c4 }, { 0x005c, 0x00d6 }, { 0x005d, 0x00dc }, { 0x007b, 0x00e4 }, { 0x007c, 0x00f6 }, { 0x007d, 0x00fc }, { 0x007e, 0x00df }, { 0, 0}, { 0x51, 0}, /* Q: French Canadian */ { 0x0040, 0x00e0 }, { 0x005b, 0x00e2 }, { 0x005c, 0x00e7 }, { 0x005d, 0x00ea }, { 0x005e, 0x00ee }, { 0x0060, 0x00f4 }, { 0x007b, 0x00e9 }, { 0x007c, 0x00f9 }, { 0x007d, 0x00e8 }, { 0x007e, 0x00fb }, { 0, 0}, { 0x52, 0}, /* R: French */ { 0x0023, 0x00a3 }, { 0x0040, 0x00e0 }, { 0x005b, 0x00b0 }, { 0x005c, 0x00e7 }, { 0x005d, 0x00a7 }, { 0x007b, 0x00e9 }, { 0x007c, 0x00f9 }, { 0x007d, 0x00e8 }, { 0x007e, 0x00a8 }, { 0, 0}, { 0x59, 0}, /* Y: Italian */ { 0x0023, 0x00a3 }, { 0x0040, 0x00a7 }, { 0x005b, 0x00b0 }, { 0x005c, 0x00e7 }, { 0x005d, 0x00e9 }, { 0x0060, 0x00f9 }, { 0x007b, 0x00e0 }, { 0x007c, 0x00f2 }, { 0x007d, 0x00e8 }, { 0x007e, 0x00ec }, { 0, 0}, { 0x5a, 0}, /* Z: Spanish */ { 0x0023, 0x00a3 }, { 0x0040, 0x00a7 }, { 0x005b, 0x00a1 }, { 0x005c, 0x00d1 }, { 0x005d, 0x00bf }, { 0x007b, 0x00b0 }, { 0x007c, 0x00f1 }, { 0x007d, 0x00e7 }, { 0, 0}, { 0xe2, 0}, /* 96-b: ISO-8859-15 */ { 0x00a4, 0x20ac }, { 0x00a6, 0x0160 }, { 0x00a8, 0x0161 }, { 0x00b4, 0x017D }, { 0x00b8, 0x017E }, { 0x00bc, 0x0152 }, { 0x00bd, 0x0153 }, { 0x00be, 0x0178 }, { 0, 0}, { 0x4a, 0}, /* J: JIS 0201 Roman */ { 0x005c, 0x00a5 }, { 0x007e, 0x203e }, { 0, 0}, { 0x49, 0}, /* I: halfwidth katakana */ { 0x0021, 0xff61 }, { 0x005f|0x8000, 0xff9f }, { 0, 0}, { 0, 0} }; struct recodetab { unsigned short (*tab)[2]; int flags; }; #define RECODETAB_ALLOCED 1 #define RECODETAB_BUILTIN 2 #define RECODETAB_TRIED 4 static struct recodetab recodetabs[256]; void InitBuiltinTabs() { unsigned short (*p)[2]; for (p = builtin_tabs; (*p)[0]; p++) { recodetabs[(*p)[0]].flags = RECODETAB_BUILTIN; recodetabs[(*p)[0]].tab = p + 1; p++; while((*p)[0]) p++; } } static int recode_char(c, to_utf, font) int c, to_utf, font; { int f; unsigned short (*p)[2]; if (to_utf) { if (c < 256) return c; f = (c >> 8) & 0xff; c &= 0xff; /* map aliases to keep the table small */ switch (f) { case 'C': f ^= ('C' ^ '5'); break; case 'E': f ^= ('E' ^ '6'); break; case 'H': f ^= ('H' ^ '7'); break; default: break; } p = recodetabs[f].tab; if (p == 0 && recodetabs[f].flags == 0) { LoadFontTranslation(f, 0); p = recodetabs[f].tab; } if (p) for (; (*p)[0]; p++) { if ((p[0][0] & 0x8000) && (c <= (p[0][0] & 0x7fff)) && c >= p[-1][0]) return c - p[-1][0] + p[-1][1]; if ((*p)[0] == c) return (*p)[1]; } return c & 0xff; /* map to latin1 */ } if (font == -1) { if (c < 256) return c; /* latin1 */ for (font = 32; font < 128; font++) { p = recodetabs[font].tab; if (p) for (; (*p)[1]; p++) { if ((p[0][0] & 0x8000) && c <= p[0][1] && c >= p[-1][1]) return (c - p[-1][1] + p[-1][0]) | (font << 8); if ((*p)[1] == c) return (*p)[0] | (font << 8); } } return '?'; } if (c < 128 && (font & 128) != 0) return c; if (font >= 32) { p = recodetabs[font].tab; if (p == 0 && recodetabs[font].flags == 0) { LoadFontTranslation(font, 0); p = recodetabs[font].tab; } if (p) for (; (*p)[1]; p++) { if ((p[0][0] & 0x8000) && c <= p[0][1] && c >= p[-1][1]) return (c - p[-1][1] + p[-1][0]) | (font & 128 ? 0 : font << 8); if ((*p)[1] == c) return (*p)[0] | (font & 128 ? 0 : font << 8); } } return -1; } #ifdef DW_CHARS static int recode_char_dw(c, c2p, to_utf, font) int c, *c2p, to_utf, font; { int f; unsigned short (*p)[2]; if (to_utf) { f = (c >> 8) & 0xff; c = (c & 255) << 8 | (*c2p & 255); *c2p = 0xffff; p = recodetabs[f].tab; if (p == 0 && recodetabs[f].flags == 0) { LoadFontTranslation(f, 0); p = recodetabs[f].tab; } if (p) for (; (*p)[0]; p++) if ((*p)[0] == c) { #ifdef DW_CHARS if (!utf8_isdouble((*p)[1])) *c2p = ' '; #endif return (*p)[1]; } return UCS_REPL_DW; } if (font == -1) { for (font = 0; font < 030; font++) { p = recodetabs[font].tab; if (p) for (; (*p)[1]; p++) if ((*p)[1] == c) { *c2p = ((*p)[0] & 255) | font << 8 | 0x8000; return ((*p)[0] >> 8) | font << 8; } } *c2p = '?'; return '?'; } if (font < 32) { p = recodetabs[font].tab; if (p == 0 && recodetabs[font].flags == 0) { LoadFontTranslation(font, 0); p = recodetabs[font].tab; } if (p) for (; (*p)[1]; p++) if ((*p)[1] == c) { *c2p = ((*p)[0] & 255) | font << 8 | 0x8000; return ((*p)[0] >> 8) | font << 8; } } return -1; } #endif static int recode_char_to_encoding(c, encoding) int c, encoding; { char *fp; int x; if (encoding == UTF8) return recode_char(c, 1, -1); if ((fp = encodings[encoding].fontlist) != 0) while(*fp) if ((x = recode_char(c, 0, (unsigned char)*fp++)) != -1) return x; if (encodings[encoding].deffont) if ((x = recode_char(c, 0, encodings[encoding].deffont)) != -1) return x; return recode_char(c, 0, -1); } #ifdef DW_CHARS static int recode_char_dw_to_encoding(c, c2p, encoding) int c, *c2p, encoding; { char *fp; int x; if (encoding == UTF8) return recode_char_dw(c, c2p, 1, -1); if ((fp = encodings[encoding].fontlist) != 0) while(*fp) if ((x = recode_char_dw(c, c2p, 0, (unsigned char)*fp++)) != -1) return x; if (encodings[encoding].deffont) if ((x = recode_char_dw(c, c2p, 0, encodings[encoding].deffont)) != -1) return x; return recode_char_dw(c, c2p, 0, -1); } #endif struct mchar * recode_mchar(mc, from, to) struct mchar *mc; int from, to; { static struct mchar rmc; int c; debug3("recode_mchar %02x from %d to %d\n", mc->image, from, to); if (from == to || (from != UTF8 && to != UTF8)) return mc; rmc = *mc; if (rmc.font == 0 && from != UTF8) rmc.font = encodings[from].deffont; if (rmc.font == 0) /* latin1 is the same in unicode */ return mc; c = rmc.image | (rmc.font << 8); if (from == UTF8) c |= rmc.fontx << 16; #ifdef DW_CHARS if (rmc.mbcs) { int c2 = rmc.mbcs; c = recode_char_dw_to_encoding(c, &c2, to); rmc.mbcs = c2; } else #endif c = recode_char_to_encoding(c, to); rmc.image = c & 255; rmc.font = c >> 8 & 255; if (to == UTF8) rmc.fontx = c >> 16 & 255; return &rmc; } struct mline * recode_mline(ml, w, from, to) struct mline *ml; int w; int from, to; { static int maxlen; static int last; static struct mline rml[2], *rl; int i, c; if (from == to || (from != UTF8 && to != UTF8) || w == 0) return ml; if (ml->font == null && ml->fontx == null && encodings[from].deffont == 0) return ml; if (w > maxlen) { for (i = 0; i < 2; i++) { if (rml[i].image == 0) rml[i].image = malloc(w); else rml[i].image = realloc(rml[i].image, w); if (rml[i].font == 0) rml[i].font = malloc(w); else rml[i].font = realloc(rml[i].font, w); if (rml[i].fontx == 0) rml[i].fontx = malloc(w); else rml[i].fontx = realloc(rml[i].fontx, w); if (rml[i].image == 0 || rml[i].font == 0 || rml[i].fontx == 0) { maxlen = 0; return ml; /* sorry */ } } maxlen = w; } debug("recode_mline: from\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(ml->image[i] >> 4) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(ml->image[i] ) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(ml->font[i] >> 4) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(ml->font[i] ) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(ml->fontx[i] >> 4) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(ml->fontx[i] ) & 15]); debug("\n"); rl = rml + last; rl->attr = ml->attr; #ifdef COLOR rl->color = ml->color; # ifdef COLORS256 rl->colorx = ml->colorx; # endif #endif for (i = 0; i < w; i++) { c = ml->image[i] | (ml->font[i] << 8); if (from == UTF8) c |= ml->fontx[i] << 16; if (from != UTF8 && c < 256) c |= encodings[from].deffont << 8; #ifdef DW_CHARS if ((from != UTF8 && (c & 0x1f00) != 0 && (c & 0xe000) == 0) || (from == UTF8 && utf8_isdouble(c))) { if (i + 1 == w) c = '?'; else { int c2; i++; c2 = ml->image[i] | (ml->font[i] << 8); c = recode_char_dw_to_encoding(c, &c2, to); if (to == UTF8) rl->fontx[i - 1] = c >> 16 & 255; rl->font[i - 1] = c >> 8 & 255; rl->image[i - 1] = c & 255; c = c2; } } else #endif c = recode_char_to_encoding(c, to); rl->image[i] = c & 255; rl->font[i] = c >> 8 & 255; if (to == UTF8) rl->fontx[i] = c >> 16 & 255; } last ^= 1; debug("recode_mline: to\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(rl->image[i] >> 4) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(rl->image[i] ) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(rl->font[i] >> 4) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(rl->font[i] ) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(rl->fontx[i] >> 4) & 15]); debug("\n"); for (i = 0; i < w; i++) debug1("%c", "0123456789abcdef"[(rl->fontx[i] ) & 15]); debug("\n"); return rl; } struct combchar { unsigned int c1; unsigned int c2; unsigned int next; unsigned int prev; }; struct combchar **combchars; void AddUtf8(c) int c; { ASSERT(D_encoding == UTF8); if (c >= 0xd800 && c < 0xe000 && combchars && combchars[c - 0xd800]) { AddUtf8(combchars[c - 0xd800]->c1); c = combchars[c - 0xd800]->c2; } if (c >= 0x10000) { if (c >= 0x200000) { AddChar((c & 0x3000000) >> 12 ^ 0xf8); c = (c & 0xffffff) ^ ((0xf0 ^ 0x80) << 18); } AddChar((c & 0x1fc0000) >> 18 ^ 0xf0); c = (c & 0x3ffff) ^ ((0xe0 ^ 0x80) << 12); } if (c >= 0x800) { AddChar((c & 0x7f000) >> 12 ^ 0xe0); c = (c & 0x0fff) ^ ((0xc0 ^ 0x80) << 6); } if (c >= 0x80) { AddChar((c & 0x1fc0) >> 6 ^ 0xc0); c = (c & 0x3f) | 0x80; } AddChar(c); } int ToUtf8_comb(p, c) char *p; int c; { int l; if (c >= 0xd800 && c < 0xe000 && combchars && combchars[c - 0xd800]) { l = ToUtf8_comb(p, combchars[c - 0xd800]->c1); return l + ToUtf8(p ? p + l : 0, combchars[c - 0xd800]->c2); } return ToUtf8(p, c); } int ToUtf8(p, c) char *p; int c; { int l = 1; if (c >= 0x10000) { if (c >= 0x200000) { if (p) *p++ = (c & 0x3000000) >> 12 ^ 0xf8; l++; c = (c & 0xffffff) ^ ((0xf0 ^ 0x80) << 18); } if (p) *p++ = (c & 0x1fc0000) >> 18 ^ 0xf0; l++; c = (c & 0x3ffff) ^ ((0xe0 ^ 0x80) << 12); } if (c >= 0x800) { if (p) *p++ = (c & 0x7f000) >> 12 ^ 0xe0; l++; c = (c & 0x0fff) | 0x1000; } if (c >= 0x80) { if (p) *p++ = (c & 0x1fc0) >> 6 ^ 0xc0; l++; c = (c & 0x3f) | 0x80; } if (p) *p++ = c; return l; } /* * returns: * -1: need more bytes, sequence not finished * -2: corrupt sequence found, redo last char * >= 0: decoded character */ int FromUtf8(c, utf8charp) int c, *utf8charp; { int utf8char = *utf8charp; if (utf8char) { if ((c & 0xc0) != 0x80) { *utf8charp = 0; return -2; /* corrupt sequence! */ } else c = (c & 0x3f) | (utf8char << 6); if (!(utf8char & 0x40000000)) { /* check for overlong sequences */ if ((c & 0x820823e0) == 0x80000000) c = 0xfdffffff; else if ((c & 0x020821f0) == 0x02000000) c = 0xfff7ffff; else if ((c & 0x000820f8) == 0x00080000) c = 0xffffd000; else if ((c & 0x0000207c) == 0x00002000) c = 0xffffff70; } } else { /* new sequence */ if (c >= 0xfe) c = UCS_REPL; else if (c >= 0xfc) c = (c & 0x01) | 0xbffffffc; /* 5 bytes to follow */ else if (c >= 0xf8) c = (c & 0x03) | 0xbfffff00; /* 4 */ else if (c >= 0xf0) c = (c & 0x07) | 0xbfffc000; /* 3 */ else if (c >= 0xe0) c = (c & 0x0f) | 0xbff00000; /* 2 */ else if (c >= 0xc2) c = (c & 0x1f) | 0xfc000000; /* 1 */ else if (c >= 0xc0) c = 0xfdffffff; /* overlong */ else if (c >= 0x80) c = UCS_REPL; } *utf8charp = utf8char = (c & 0x80000000) ? c : 0; if (utf8char) return -1; #if 0 if (c & 0xffff0000) c = UCS_REPL; /* sorry, only know 16bit Unicode */ #else if (c & 0xff800000) c = UCS_REPL; /* sorry, only know 23bit Unicode */ #endif if (c >= 0xd800 && (c <= 0xdfff || c == 0xfffe || c == 0xffff)) c = UCS_REPL; /* illegal code */ return c; } void WinSwitchEncoding(p, encoding) struct win *p; int encoding; { int i, j, c; struct mline *ml; struct display *d; struct canvas *cv; struct layer *oldflayer; if ((p->w_encoding == UTF8) == (encoding == UTF8)) { p->w_encoding = encoding; return; } oldflayer = flayer; for (d = displays; d; d = d->d_next) for (cv = d->d_cvlist; cv; cv = cv->c_next) if (p == Layer2Window(cv->c_layer)) { flayer = cv->c_layer; while(flayer->l_next) { if (oldflayer == flayer) oldflayer = flayer->l_next; ExitOverlayPage(); } } flayer = oldflayer; for (j = 0; j < p->w_height + p->w_histheight; j++) { #ifdef COPY_PASTE ml = j < p->w_height ? &p->w_mlines[j] : &p->w_hlines[j - p->w_height]; #else ml = &p->w_mlines[j]; #endif if (ml->font == null && ml->fontx == 0 && encodings[p->w_encoding].deffont == 0) continue; for (i = 0; i < p->w_width; i++) { c = ml->image[i] | (ml->font[i] << 8); if (p->w_encoding == UTF8) c |= ml->fontx[i] << 16; if (p->w_encoding != UTF8 && c < 256) c |= encodings[p->w_encoding].deffont << 8; if (c < 256) continue; if (ml->font == null) { if ((ml->font = (unsigned char *)calloc(p->w_width + 1, 1)) == 0) { ml->font = null; break; } } #ifdef DW_CHARS if ((p->w_encoding != UTF8 && (c & 0x1f00) != 0 && (c & 0xe000) == 0) || (p->w_encoding == UTF8 && utf8_isdouble(c))) { if (i + 1 == p->w_width) c = '?'; else { int c2; i++; c2 = ml->image[i] | (ml->font[i] << 8) | (ml->fontx[i] << 16); c = recode_char_dw_to_encoding(c, &c2, encoding); if (encoding == UTF8) { if (c > 0x10000 && ml->fontx == null) { if ((ml->fontx = (unsigned char *)calloc(p->w_width + 1, 1)) == 0) { ml->fontx = null; break; } } ml->fontx[i - 1] = c >> 16 & 255; } else ml->fontx = null; ml->font[i - 1] = c >> 8 & 255; ml->image[i - 1] = c & 255; c = c2; } } else #endif c = recode_char_to_encoding(c, encoding); ml->image[i] = c & 255; ml->font[i] = c >> 8 & 255; if (encoding == UTF8) { if (c > 0x10000 && ml->fontx == null) { if ((ml->fontx = (unsigned char *)calloc(p->w_width + 1, 1)) == 0) { ml->fontx = null; break; } } ml->fontx[i] = c >> 16 & 255; } else ml->fontx = null; } } p->w_encoding = encoding; return; } #ifdef DW_CHARS struct interval { int first; int last; }; /* auxiliary function for binary search in interval table */ static int bisearch(int ucs, const struct interval *table, int max) { int min = 0; int mid; if (ucs < table[0].first || ucs > table[max].last) return 0; while (max >= min) { mid = (min + max) / 2; if (ucs > table[mid].last) min = mid + 1; else if (ucs < table[mid].first) max = mid - 1; else return 1; } return 0; } int utf8_isdouble(c) int c; { /* A sorted list of intervals of ambiguous width characters generated by * https://github.com/GNOME/glib/blob/glib-2-50/glib/gen-unicode-tables.pl */ static const struct interval ambiguous[] = { {0x00A1, 0x00A1}, {0x00A4, 0x00A4}, {0x00A7, 0x00A8}, {0x00AA, 0x00AA}, {0x00AD, 0x00AE}, {0x00B0, 0x00B4}, {0x00B6, 0x00BA}, {0x00BC, 0x00BF}, {0x00C6, 0x00C6}, {0x00D0, 0x00D0}, {0x00D7, 0x00D8}, {0x00DE, 0x00E1}, {0x00E6, 0x00E6}, {0x00E8, 0x00EA}, {0x00EC, 0x00ED}, {0x00F0, 0x00F0}, {0x00F2, 0x00F3}, {0x00F7, 0x00FA}, {0x00FC, 0x00FC}, {0x00FE, 0x00FE}, {0x0101, 0x0101}, {0x0111, 0x0111}, {0x0113, 0x0113}, {0x011B, 0x011B}, {0x0126, 0x0127}, {0x012B, 0x012B}, {0x0131, 0x0133}, {0x0138, 0x0138}, {0x013F, 0x0142}, {0x0144, 0x0144}, {0x0148, 0x014B}, {0x014D, 0x014D}, {0x0152, 0x0153}, {0x0166, 0x0167}, {0x016B, 0x016B}, {0x01CE, 0x01CE}, {0x01D0, 0x01D0}, {0x01D2, 0x01D2}, {0x01D4, 0x01D4}, {0x01D6, 0x01D6}, {0x01D8, 0x01D8}, {0x01DA, 0x01DA}, {0x01DC, 0x01DC}, {0x0251, 0x0251}, {0x0261, 0x0261}, {0x02C4, 0x02C4}, {0x02C7, 0x02C7}, {0x02C9, 0x02CB}, {0x02CD, 0x02CD}, {0x02D0, 0x02D0}, {0x02D8, 0x02DB}, {0x02DD, 0x02DD}, {0x02DF, 0x02DF}, {0x0300, 0x036F}, {0x0391, 0x03A1}, {0x03A3, 0x03A9}, {0x03B1, 0x03C1}, {0x03C3, 0x03C9}, {0x0401, 0x0401}, {0x0410, 0x044F}, {0x0451, 0x0451}, {0x2010, 0x2010}, {0x2013, 0x2016}, {0x2018, 0x2019}, {0x201C, 0x201D}, {0x2020, 0x2022}, {0x2024, 0x2027}, {0x2030, 0x2030}, {0x2032, 0x2033}, {0x2035, 0x2035}, {0x203B, 0x203B}, {0x203E, 0x203E}, {0x2074, 0x2074}, {0x207F, 0x207F}, {0x2081, 0x2084}, {0x20AC, 0x20AC}, {0x2103, 0x2103}, {0x2105, 0x2105}, {0x2109, 0x2109}, {0x2113, 0x2113}, {0x2116, 0x2116}, {0x2121, 0x2122}, {0x2126, 0x2126}, {0x212B, 0x212B}, {0x2153, 0x2154}, {0x215B, 0x215E}, {0x2160, 0x216B}, {0x2170, 0x2179}, {0x2189, 0x2189}, {0x2190, 0x2199}, {0x21B8, 0x21B9}, {0x21D2, 0x21D2}, {0x21D4, 0x21D4}, {0x21E7, 0x21E7}, {0x2200, 0x2200}, {0x2202, 0x2203}, {0x2207, 0x2208}, {0x220B, 0x220B}, {0x220F, 0x220F}, {0x2211, 0x2211}, {0x2215, 0x2215}, {0x221A, 0x221A}, {0x221D, 0x2220}, {0x2223, 0x2223}, {0x2225, 0x2225}, {0x2227, 0x222C}, {0x222E, 0x222E}, {0x2234, 0x2237}, {0x223C, 0x223D}, {0x2248, 0x2248}, {0x224C, 0x224C}, {0x2252, 0x2252}, {0x2260, 0x2261}, {0x2264, 0x2267}, {0x226A, 0x226B}, {0x226E, 0x226F}, {0x2282, 0x2283}, {0x2286, 0x2287}, {0x2295, 0x2295}, {0x2299, 0x2299}, {0x22A5, 0x22A5}, {0x22BF, 0x22BF}, {0x2312, 0x2312}, {0x2460, 0x24E9}, {0x24EB, 0x254B}, {0x2550, 0x2573}, {0x2580, 0x258F}, {0x2592, 0x2595}, {0x25A0, 0x25A1}, {0x25A3, 0x25A9}, {0x25B2, 0x25B3}, {0x25B6, 0x25B7}, {0x25BC, 0x25BD}, {0x25C0, 0x25C1}, {0x25C6, 0x25C8}, {0x25CB, 0x25CB}, {0x25CE, 0x25D1}, {0x25E2, 0x25E5}, {0x25EF, 0x25EF}, {0x2605, 0x2606}, {0x2609, 0x2609}, {0x260E, 0x260F}, {0x261C, 0x261C}, {0x261E, 0x261E}, {0x2640, 0x2640}, {0x2642, 0x2642}, {0x2660, 0x2661}, {0x2663, 0x2665}, {0x2667, 0x266A}, {0x266C, 0x266D}, {0x266F, 0x266F}, {0x269E, 0x269F}, {0x26BF, 0x26BF}, {0x26C6, 0x26CD}, {0x26CF, 0x26D3}, {0x26D5, 0x26E1}, {0x26E3, 0x26E3}, {0x26E8, 0x26E9}, {0x26EB, 0x26F1}, {0x26F4, 0x26F4}, {0x26F6, 0x26F9}, {0x26FB, 0x26FC}, {0x26FE, 0x26FF}, {0x273D, 0x273D}, {0x2776, 0x277F}, {0x2B56, 0x2B59}, {0x3248, 0x324F}, {0xE000, 0xF8FF}, {0xFE00, 0xFE0F}, {0xFFFD, 0xFFFD}, {0x1F100, 0x1F10A}, {0x1F110, 0x1F12D}, {0x1F130, 0x1F169}, {0x1F170, 0x1F18D}, {0x1F18F, 0x1F190}, {0x1F19B, 0x1F1AC}, {0xE0100, 0xE01EF}, {0xF0000, 0xFFFFD}, {0x100000, 0x10FFFD}, }; /* A sorted list of intervals of double width characters generated by * https://github.com/GNOME/glib/blob/glib-2-50/glib/gen-unicode-tables.pl */ static const struct interval wide[] = { {0x1100, 0x115F}, {0x231A, 0x231B}, {0x2329, 0x232A}, {0x23E9, 0x23EC}, {0x23F0, 0x23F0}, {0x23F3, 0x23F3}, {0x25FD, 0x25FE}, {0x2614, 0x2615}, {0x2648, 0x2653}, {0x267F, 0x267F}, {0x2693, 0x2693}, {0x26A1, 0x26A1}, {0x26AA, 0x26AB}, {0x26BD, 0x26BE}, {0x26C4, 0x26C5}, {0x26CE, 0x26CE}, {0x26D4, 0x26D4}, {0x26EA, 0x26EA}, {0x26F2, 0x26F3}, {0x26F5, 0x26F5}, {0x26FA, 0x26FA}, {0x26FD, 0x26FD}, {0x2705, 0x2705}, {0x270A, 0x270B}, {0x2728, 0x2728}, {0x274C, 0x274C}, {0x274E, 0x274E}, {0x2753, 0x2755}, {0x2757, 0x2757}, {0x2795, 0x2797}, {0x27B0, 0x27B0}, {0x27BF, 0x27BF}, {0x2B1B, 0x2B1C}, {0x2B50, 0x2B50}, {0x2B55, 0x2B55}, {0x2E80, 0x2E99}, {0x2E9B, 0x2EF3}, {0x2F00, 0x2FD5}, {0x2FF0, 0x2FFB}, {0x3000, 0x303E}, {0x3041, 0x3096}, {0x3099, 0x30FF}, {0x3105, 0x312F}, {0x3131, 0x318E}, {0x3190, 0x31BA}, {0x31C0, 0x31E3}, {0x31F0, 0x321E}, {0x3220, 0x3247}, {0x3250, 0x4DBF}, {0x4E00, 0xA48C}, {0xA490, 0xA4C6}, {0xA960, 0xA97C}, {0xAC00, 0xD7A3}, {0xF900, 0xFAFF}, {0xFE10, 0xFE19}, {0xFE30, 0xFE52}, {0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, {0xFF01, 0xFF60}, {0xFFE0, 0xFFE6}, {0x16FE0, 0x16FE3}, {0x17000, 0x187F7}, {0x18800, 0x18AF2}, {0x1B000, 0x1B11E}, {0x1B150, 0x1B152}, {0x1B164, 0x1B167}, {0x1B170, 0x1B2FB}, {0x1F004, 0x1F004}, {0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A}, {0x1F200, 0x1F202}, {0x1F210, 0x1F23B}, {0x1F240, 0x1F248}, {0x1F250, 0x1F251}, {0x1F260, 0x1F265}, {0x1F300, 0x1F320}, {0x1F32D, 0x1F335}, {0x1F337, 0x1F37C}, {0x1F37E, 0x1F393}, {0x1F3A0, 0x1F3CA}, {0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0}, {0x1F3F4, 0x1F3F4}, {0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440}, {0x1F442, 0x1F4FC}, {0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E}, {0x1F550, 0x1F567}, {0x1F57A, 0x1F57A}, {0x1F595, 0x1F596}, {0x1F5A4, 0x1F5A4}, {0x1F5FB, 0x1F64F}, {0x1F680, 0x1F6C5}, {0x1F6CC, 0x1F6CC}, {0x1F6D0, 0x1F6D2}, {0x1F6D5, 0x1F6D5}, {0x1F6EB, 0x1F6EC}, {0x1F6F4, 0x1F6FA}, {0x1F7E0, 0x1F7EB}, {0x1F90D, 0x1F971}, {0x1F973, 0x1F976}, {0x1F97A, 0x1F9A2}, {0x1F9A5, 0x1F9AA}, {0x1F9AE, 0x1F9CA}, {0x1F9CD, 0x1F9FF}, {0x1FA70, 0x1FA73}, {0x1FA78, 0x1FA7A}, {0x1FA80, 0x1FA82}, {0x1FA90, 0x1FA95}, {0x20000, 0x2FFFD}, {0x30000, 0x3FFFD}, }; return ((bisearch(c, wide, sizeof(wide) / sizeof(struct interval) - 1)) || (cjkwidth && bisearch(c, ambiguous, sizeof(ambiguous) / sizeof(struct interval) - 1))); } #endif int utf8_iscomb(c) int c; { /* taken from Markus Kuhn's wcwidth */ static const struct interval combining[] = { { 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 }, { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 }, { 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 }, { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A }, { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC }, { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F }, { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 }, { 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 }, { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B }, { 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 }, { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 }, { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF }, { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 }, { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F }, { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B }, { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB }, { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F }, { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 }, { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD }, { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F }, { 0xE0100, 0xE01EF } }; return bisearch(c, combining, sizeof(combining) / sizeof(struct interval) - 1); } static void comb_tofront(root, i) int root, i; { for (;;) { debug1("bring to front: %x\n", i); combchars[combchars[i]->prev]->next = combchars[i]->next; combchars[combchars[i]->next]->prev = combchars[i]->prev; combchars[i]->next = combchars[root]->next; combchars[i]->prev = root; combchars[combchars[root]->next]->prev = i; combchars[root]->next = i; i = combchars[i]->c1; if (i < 0xd800 || i >= 0xe000) return; i -= 0xd800; } } void utf8_handle_comb(c, mc) int c; struct mchar *mc; { int root, i, c1; int isdouble; c1 = mc->image | (mc->font << 8) | mc->fontx << 16; isdouble = c1 >= 0x1100 && utf8_isdouble(c1); if (!combchars) { combchars = (struct combchar **)calloc(0x802, sizeof(struct combchar *)); if (!combchars) return; combchars[0x800] = (struct combchar *)malloc(sizeof(struct combchar)); combchars[0x801] = (struct combchar *)malloc(sizeof(struct combchar)); if (!combchars[0x800] || !combchars[0x801]) { if (combchars[0x800]) free(combchars[0x800]); if (combchars[0x801]) free(combchars[0x801]); free(combchars); return; } combchars[0x800]->c1 = 0x000; combchars[0x800]->c2 = 0x700; combchars[0x800]->next = 0x800; combchars[0x800]->prev = 0x800; combchars[0x801]->c1 = 0x700; combchars[0x801]->c2 = 0x800; combchars[0x801]->next = 0x801; combchars[0x801]->prev = 0x801; } root = isdouble ? 0x801 : 0x800; for (i = combchars[root]->c1; i < combchars[root]->c2; i++) { if (!combchars[i]) break; if (combchars[i]->c1 == c1 && combchars[i]->c2 == c) break; } if (i == combchars[root]->c2) { /* full, recycle old entry */ if (c1 >= 0xd800 && c1 < 0xe000) comb_tofront(root, c1 - 0xd800); i = combchars[root]->prev; if (c1 == i + 0xd800) { /* completely full, can't recycle */ debug("utf8_handle_comp: completely full!\n"); mc->image = '?'; mc->font = 0; return; } /* FIXME: delete old char from all buffers */ } else if (!combchars[i]) { combchars[i] = (struct combchar *)malloc(sizeof(struct combchar)); if (!combchars[i]) return; combchars[i]->prev = i; combchars[i]->next = i; } combchars[i]->c1 = c1; combchars[i]->c2 = c; mc->image = i & 0xff; mc->font = (i >> 8) + 0xd8; mc->fontx = 0; debug3("combinig char %x %x -> %x\n", c1, c, i + 0xd800); comb_tofront(root, i); } #else /* !UTF8 */ void WinSwitchEncoding(p, encoding) struct win *p; int encoding; { p->w_encoding = encoding; return; } #endif /* UTF8 */ static int encmatch(s1, s2) char *s1; char *s2; { int c1, c2; do { c1 = (unsigned char)*s1; if (c1 >= 'A' && c1 <= 'Z') c1 += 'a' - 'A'; if (!(c1 >= 'a' && c1 <= 'z') && !(c1 >= '0' && c1 <= '9')) { s1++; continue; } c2 = (unsigned char)*s2; if (c2 >= 'A' && c2 <= 'Z') c2 += 'a' - 'A'; if (!(c2 >= 'a' && c2 <= 'z') && !(c2 >= '0' && c2 <= '9')) { s2++; continue; } if (c1 != c2) return 0; s1++; s2++; } while(c1); return 1; } int FindEncoding(name) char *name; { int encoding; debug1("FindEncoding %s\n", name); if (name == 0 || *name == 0) return 0; if (encmatch(name, "euc")) name = "eucJP"; if (encmatch(name, "off") || encmatch(name, "iso8859-1")) return 0; #ifndef UTF8 if (encmatch(name, "UTF-8")) return -1; #endif for (encoding = 0; encoding < (int)(sizeof(encodings)/sizeof(*encodings)); encoding++) if (encmatch(name, encodings[encoding].name)) { #ifdef UTF8 LoadFontTranslationsForEncoding(encoding); #endif return encoding; } return -1; } char * EncodingName(encoding) int encoding; { if (encoding >= (int)(sizeof(encodings)/sizeof(*encodings))) return 0; return encodings[encoding].name; } int EncodingDefFont(encoding) int encoding; { return encodings[encoding].deffont; } void ResetEncoding(p) struct win *p; { char *c; int encoding = p->w_encoding; c = encodings[encoding].charsets; if (c) SetCharsets(p, c); #ifdef UTF8 LoadFontTranslationsForEncoding(encoding); #endif if (encodings[encoding].usegr) { p->w_gr = 2; p->w_FontE = encodings[encoding].charsets[1]; } else p->w_FontE = 0; if (encodings[encoding].noc1) p->w_c1 = 0; } /* decoded char: 32-bit * fontx: non-bmp utf8 * c2: multi-byte character * font is always zero for utf8 * returns: -1 need more bytes * -2 decode error */ int DecodeChar(c, encoding, statep) int c; int encoding; int *statep; { int t; debug2("Decoding char %02x for encoding %d\n", c, encoding); #ifdef UTF8 if (encoding == UTF8) { c = FromUtf8(c, statep); if (c >= 0x10000) c = (c & 0x7f0000) << 8 | (c & 0xffff); return c; } #endif if (encoding == SJIS) { if (!*statep) { if ((0x81 <= c && c <= 0x9f) || (0xe0 <= c && c <= 0xef)) { *statep = c; return -1; } if (c < 0x80) return c; return c | (KANA << 16); } t = c; c = *statep; *statep = 0; if (0x40 <= t && t <= 0xfc && t != 0x7f) { if (c <= 0x9f) c = (c - 0x81) * 2 + 0x21; else c = (c - 0xc1) * 2 + 0x21; if (t <= 0x7e) t -= 0x1f; else if (t <= 0x9e) t -= 0x20; else t -= 0x7e, c++; return (c << 8) | t | (KANJI << 16); } return t; } if (encoding == EUC_JP || encoding == EUC_KR || encoding == EUC_CN) { if (!*statep) { if (c & 0x80) { *statep = c; return -1; } return c; } t = c; c = *statep; *statep = 0; if (encoding == EUC_JP) { if (c == 0x8e) return t | (KANA << 16); if (c == 0x8f) { *statep = t | (KANJI0212 << 8); return -1; } } c &= 0xff7f; t &= 0x7f; c = c << 8 | t; if (encoding == EUC_KR) return c | (3 << 16); if (encoding == EUC_CN) return c | (1 << 16); if (c & (KANJI0212 << 16)) return c; else return c | (KANJI << 16); } if (encoding == BIG5 || encoding == GBK) { if (!*statep) { if (c & 0x80) { if (encoding == GBK && c == 0x80) return 0xa4 | (('b'|0x80) << 16); *statep = c; return -1; } return c; } t = c; c = *statep; *statep = 0; c &= 0x7f; return c << 8 | t | (encoding == BIG5 ? 030 << 16 : 031 << 16); } return c | (encodings[encoding].deffont << 16); } int EncodeChar(bp, c, encoding, fontp) char *bp; int c; int encoding; int *fontp; { int t, f, l; debug2("Encoding char %02x for encoding %d\n", c, encoding); if (c == -1 && fontp) { if (*fontp == 0) return 0; if (bp) { *bp++ = 033; *bp++ = '('; *bp++ = 'B'; } return 3; } f = (c >> 16) & 0xff; #ifdef UTF8 if (encoding == UTF8) { if (f) { # ifdef DW_CHARS if (is_dw_font(f)) { int c2 = c & 0xff; c = (c >> 8 & 0xff) | (f << 8); c = recode_char_dw_to_encoding(c, &c2, encoding); } else # endif { c = (c & 0xff) | (f << 8); c = recode_char_to_encoding(c, encoding); } } return ToUtf8(bp, c); } if (f == 0 && (c & 0x7f00ff00) != 0) /* is_utf8? */ { if (c >= 0x10000) c = (c & 0x7f0000) >> 8 | (c & 0xffff); # ifdef DW_CHARS if (utf8_isdouble(c)) { int c2 = 0xffff; c = recode_char_dw_to_encoding(c, &c2, encoding); c = (c << 8) | (c2 & 0xff); } else # endif { c = recode_char_to_encoding(c, encoding); c = ((c & 0xff00) << 8) | (c & 0xff); } debug1("Encode: char mapped from utf8 to %x\n", c); f = c >> 16; } #endif if (f & 0x80) /* map special 96-fonts to latin1 */ f = 0; if (encoding == SJIS) { if (f == KANA) c = (c & 0xff) | 0x80; else if (f == KANJI) { if (!bp) return 2; t = c & 0xff; c = (c >> 8) & 0xff; t += (c & 1) ? ((t <= 0x5f) ? 0x1f : 0x20) : 0x7e; c = (c - 0x21) / 2 + ((c < 0x5f) ? 0x81 : 0xc1); *bp++ = c; *bp++ = t; return 2; } } if (encoding == EUC) { if (f == KANA) { if (bp) { *bp++ = 0x8e; *bp++ = c; } return 2; } if (f == KANJI) { if (bp) { *bp++ = (c >> 8) | 0x80; *bp++ = c | 0x80; } return 2; } if (f == KANJI0212) { if (bp) { *bp++ = 0x8f; *bp++ = c >> 8; *bp++ = c; } return 3; } } if ((encoding == EUC_KR && f == 3) || (encoding == EUC_CN && f == 1)) { if (bp) { *bp++ = (c >> 8) | 0x80; *bp++ = c | 0x80; } return 2; } if ((encoding == BIG5 && f == 030) || (encoding == GBK && f == 031)) { if (bp) { *bp++ = (c >> 8) | 0x80; *bp++ = c; } return 2; } if (encoding == GBK && f == 0 && c == 0xa4) c = 0x80; l = 0; if (fontp && f != *fontp) { *fontp = f; if (f && f < ' ') { if (bp) { *bp++ = 033; *bp++ = '$'; if (f > 2) *bp++ = '('; *bp++ = '@' + f; } l += f > 2 ? 4 : 3; } else if (f < 128) { if (f == 0) f = 'B'; if (bp) { *bp++ = 033; *bp++ = '('; *bp++ = f; } l += 3; } } if (c & 0xff00) { if (bp) *bp++ = c >> 8; l++; } if (bp) *bp++ = c; return l + 1; } int CanEncodeFont(encoding, f) int encoding, f; { switch(encoding) { #ifdef UTF8 case UTF8: return 1; #endif case SJIS: return f == KANJI || f == KANA; case EUC: return f == KANJI || f == KANA || f == KANJI0212; case EUC_KR: return f == 3; case EUC_CN: return f == 1; case BIG5: return f == 030; case GBK: return f == 031; default: break; } return 0; } #ifdef DW_CHARS int PrepareEncodedChar(c) int c; { int encoding; int t = 0; int f; encoding = D_encoding; f = D_rend.font; t = D_mbcs; if (encoding == SJIS) { if (f == KANA) return c | 0x80; else if (f == KANJI) { t += (c & 1) ? ((t <= 0x5f) ? 0x1f : 0x20) : 0x7e; c = (c - 0x21) / 2 + ((c < 0x5f) ? 0x81 : 0xc1); D_mbcs = t; } return c; } if (encoding == EUC) { if (f == KANA) { AddChar(0x8e); return c | 0x80; } if (f == KANJI) { D_mbcs = t | 0x80; return c | 0x80; } if (f == KANJI0212) { AddChar(0x8f); D_mbcs = t | 0x80; return c | 0x80; } } if ((encoding == EUC_KR && f == 3) || (encoding == EUC_CN && f == 1)) { D_mbcs = t | 0x80; return c | 0x80; } if ((encoding == BIG5 && f == 030) || (encoding == GBK && f == 031)) return c | 0x80; return c; } #endif int RecodeBuf(fbuf, flen, fenc, tenc, tbuf) unsigned char *fbuf; int flen; int fenc, tenc; unsigned char *tbuf; { int c, i, j; int decstate = 0, font = 0; for (i = j = 0; i < flen; i++) { c = fbuf[i]; c = DecodeChar(c, fenc, &decstate); if (c == -2) i--; if (c < 0) continue; j += EncodeChar(tbuf ? (char *)tbuf + j : 0, c, tenc, &font); } j += EncodeChar(tbuf ? (char *)tbuf + j : 0, -1, tenc, &font); return j; } #ifdef UTF8 int ContainsSpecialDeffont(ml, xs, xe, encoding) struct mline *ml; int xs, xe; int encoding; { unsigned char *f, *i; int c, x, dx; if (encoding == UTF8 || encodings[encoding].deffont == 0) return 0; i = ml->image + xs; f = ml->font + xs; dx = xe - xs + 1; while (dx-- > 0) { if (*f++) continue; c = *i++; x = recode_char_to_encoding(c | (encodings[encoding].deffont << 8), UTF8); if (c != x) { debug2("ContainsSpecialDeffont: yes %02x != %02x\n", c, x); return 1; } } debug("ContainsSpecialDeffont: no\n"); return 0; } int LoadFontTranslation(font, file) int font; char *file; { char buf[1024], *myfile; FILE *f; int i; int fo; int x, u, c, ok; unsigned short (*p)[2], (*tab)[2]; myfile = file; if (myfile == 0) { if (font == 0 || screenencodings == 0) return -1; if (strlen(screenencodings) > sizeof(buf) - 10) return -1; sprintf(buf, "%s/%02x", screenencodings, font & 0xff); myfile = buf; } debug1("LoadFontTranslation: trying %s\n", myfile); if ((f = secfopen(myfile, "r")) == 0) return -1; i = ok = 0; for (;;) { for(; i < 12; i++) if (getc(f) != "ScreenI2UTF8"[i]) break; if (getc(f) != 0) /* format */ break; fo = getc(f); /* id */ if (fo == EOF) break; if (font != -1 && font != fo) break; i = getc(f); x = getc(f); if (x == EOF) break; i = i << 8 | x; getc(f); while ((x = getc(f)) && x != EOF) getc(f); /* skip font name (padded to 2 bytes) */ if ((p = malloc(sizeof(*p) * (i + 1))) == 0) break; tab = p; while(i > 0) { x = getc(f); x = x << 8 | getc(f); u = getc(f); c = getc(f); u = u << 8 | c; if (c == EOF) break; (*p)[0] = x; (*p)[1] = u; p++; i--; } (*p)[0] = 0; (*p)[1] = 0; if (i || (tab[0][0] & 0x8000)) { free(tab); break; } if (recodetabs[fo].tab && (recodetabs[fo].flags & RECODETAB_ALLOCED) != 0) free(recodetabs[fo].tab); recodetabs[fo].tab = tab; recodetabs[fo].flags = RECODETAB_ALLOCED; debug1("Successful load of recodetab %02x\n", fo); c = getc(f); if (c == EOF) { ok = 1; break; } if (c != 'S') break; i = 1; } fclose(f); if (font != -1 && file == 0 && recodetabs[font].flags == 0) recodetabs[font].flags = RECODETAB_TRIED; return ok ? 0 : -1; } void LoadFontTranslationsForEncoding(encoding) int encoding; { char *c; int f; debug1("LoadFontTranslationsForEncoding: encoding %d\n", encoding); if ((c = encodings[encoding].fontlist) != 0) while ((f = (unsigned char)*c++) != 0) if (recodetabs[f].flags == 0) LoadFontTranslation(f, 0); f = encodings[encoding].deffont; if (f > 0 && recodetabs[f].flags == 0) LoadFontTranslation(f, 0); } #endif /* UTF8 */ #else /* !ENCODINGS */ /* Simple version of EncodeChar to encode font changes for * copy/paste mode */ int EncodeChar(bp, c, encoding, fontp) char *bp; int c; int encoding; int *fontp; { int f, l; f = (c == -1) ? 0 : c >> 16; l = 0; if (fontp && f != *fontp) { *fontp = f; if (f && f < ' ') { if (bp) { *bp++ = 033; *bp++ = '$'; if (f > 2) *bp++ = '('; *bp++ = '@' + f; } l += f > 2 ? 4 : 3; } else if (f < 128) { if (f == 0) f = 'B'; if (bp) { *bp++ = 033; *bp++ = '('; *bp++ = f; } l += 3; } } if (c == -1) return l; if (c & 0xff00) { if (bp) *bp++ = c >> 8; l++; } if (bp) *bp++ = c; return l + 1; } #endif /* ENCODINGS */ screen-4.8.0/patchlevel.h0000644000175000017500000010131313616622064014207 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** * $Id$ GNU */ /**************************************************************** * * patchlevel.h: Our life story. * * 08.07.91 -- 3.00.01 -wipe and a 'setenv TERM dumb' bugfix. * 17.07.91 -- 3.00.02 another patchlevel by Wayne Davison * 31.07.91 -- 3.00.03 E0, S0, C0 for flexible semi-graphics, nonblocking * window title input and 'C-a :' command input. * 10.08.91 -- 3.00.04 scrollback, markkeys and some bugfixes. * 13.08.91 -- 3.00.05 mark routine improved, ansi prototypes added. * 20.08.91 -- 3.00.06 screen -h, faster GotoPos in overlay, termcap %. * instead of %c * 28.08.91 -- 3.00.07 environment variable support. security. terminfo. * pyramid and ultrix support. * 07.09.91 -- 3.00.99 secopen(), MIPS support, SVR4 support. * 09.09.91 -- 3.01.00 backspace bug fixed. * 03.10.91 -- 3.01.01 ansi.c: null-ptr fixed, CLS now saves to scrollback. * Using setresuid on hpux. Memory leak fixed. * Better GotoPos(). Support for IC. Another resize bug. * Detach() w/o fore crashed. -T and -A(dapt) option. * GNU copyleft. * 19.12.91 -- 3.01.02 flow now really automatic (autoflow killed). * 7 bit restriction removed from WriteString(). * 09.01.92 -- 3.01.03 flow reattach bug fixed. VDISCARD bug fixed. * 13.01.92 -- 3.01.04 new flow concept: ^Af toggles now three states * 21.01.92 -- 3.01.05 '^A:screen 11' bug fixed. aflag in DoScreen(). * Some code cleanup. attach_tty and display_tty[] * added. * 26.01.92 -- 3.01.06 apollo support, "hardcopy_append on", "bufferfile", * SECURITY PROBLEM cleared.. * 28.01.92 -- 3.01.07 screen after su allowed. Pid became part of * SockName. sysvish 14 character restriction considered. * 31.01.92 -- 3.02.00 Ultrix port, Irix 3.3 SGI port, shadow pw support, * data loss on stdin overflow fixed. "refresh off". * 12.02.92 -- 3.02.02 stripdev() moved, -S introduced, bufferfile improved, * ShellProg coredump cleared. SVR4 bugfixes. * I/O code speedup added. * 24.04.92 -- 3.02.03 perfectly stackable overlays. One scrollback per window, * not per display. * 05.05.92 -- 3.02.04 very nasty initialisation bug fixed. * 09.05.92 -- 3.02.05 parsing for $:cl: termcap strings and \012 octal notation * in screenrc file. More structuring. Detached startup * with 'screen -d -m -S...' bugfixed. * 11.05.92 -- 3.02.06 setreuid() bugs cleared, C-a : setenv added. * "xn" capability in TERMCAP needed since "am" is there. * 25.06.92 -- 3.02.07 The multi display test version. Have merci. * 15.07.92 -- 3.02.08 :B8: supports automatic charset switching for 8-bit * 26.09.92 -- 3.02.09 Ported to linux. Ignoring bad files in $SCREENDIR * 22.10.92 -- 3.02.10 screen.c/ansi.c splitted in several pieces. * Better ISearch. Cleanup of loadav.c * 29.10.92 -- 3.02.11 Key mechanism rewritten. New command names. * New iscreenrc syntax. * 02.11.92 -- 3.02.12 'bind g copy_reg' and 'bind x ins_reg' as suggested by * stillson@tsfsrv.mitre.org (Ken Stillson). * 03.11.92 -- 3.02.13 Ported to SunOs 4.1.2. Gulp. Some NULL ptrs fixed and * misc. braindamage fixed. * 03.11.92 -- 3.02.14 Argument number checking, AKA fixed. * 05.11.92 -- 3.02.15 Memory leaks in Detach() and KillWindow() fixed. * Lockprg powerdetaches on SIGHUP. * 12.11.92 -- 3.02.16 Introduced two new termcaps: "CS" and "CE". * (Switch cursorkeys in application mode) * Tim's async output patch. * Fixed an ugly bug in WriteString(). * New command: 'process' * 16.11.92 -- 3.02.17 Nuking unsent tty output is now optional, (toxic * ESC radiation). * 30.11.92 -- 3.02.18 Lots of multi display bugs fixed. New layer * function 'Restore'. MULTIUSER code cleanup. * Rudimental acls added for multiuser. * No more error output, when output gives write errors. * 02.12.92 -- 3.02.19 BROKEN_PIPE and SOCK_NOT_IN_FS defines added for * braindead systems. Bug in recover socket code fixed. * Can create windows again from shell. * 22.12.92 -- 3.02.20 Made a superb configure script. STY and break fixed. * 01.02.93 -- 3.02.21 Coredump bug fixed: 8-bit output in background windows. * Console grabbing somewhat more useable. * 23.02.93 -- 3.02.22 Added ^:exec command, but not tested at all. * 23.02.93 -- 3.02.23 Added 'hardcopydir' and 'logdir' commands. * 11.03.93 -- 3.02.24 Prefixed display and window structure elements. * Screen now handles autowrapped lines correctly * in the redisplay and mark function. * 19.03.93 -- 3.03.00 Patched for BSD386. pseudos work. * 31.03.93 -- 3.03.01 Don't allocate so much empty attr and font lines. * 04.04.93 -- 3.03.02 fixed :exec !..| less and :|less, patched BELL_DONE & * ^B/^F. Fixed auto_nuke attribute resetting. Better linux * configure. ^AW shows '&' when window has other attacher. * MAXWIN > 10 patch. KEEP_UNDEF in config.h.in, shellaka * bug fixed. dec alpha port. Solaris port. * 02.05.93 -- 3.03.03 Configure tweaked for sgi. Update environment with * setenv command. Silence on|off, silencewait , * defautonuke commands added. Manual page updated. * 13.05.93 -- 3.03.04 exit in newsyntax script, finished _CX_UX port. * Texinfo page added by Jason Merrill. Much longish debug * output removed. Select window by title (or number). * 16.06.93 -- 3.04.00 Replaced ^A- by ^A^H to be complementary to ^A SPACE. * Moved into CVS. Yacc. * 28.06.93 -- 3.04.01 Fixed selecting windows with numeric title. Silence * now works without nethackoption set. * 01.07.93 -- 3.04.02 Implementing real acls. * 22.07.93 -- 3.05.00 Fixed SVR4, some multiuser bugs, -- DISTRIBUTED * 05.08.93 -- 3.05.01 ${srcdir} feature added. Shellprog bug fixed. * Motorola reattach bug fixed. Writelock bug fixed. * Copybuffer moved into struct acluser. Configure.in * uglified for Autoconf1.5. Paste may now have an * argument. Interactive setenv. Right margin bug * fixed. IRIX 5 patches. -- DISTRIBUTED * 13.08.93 -- 3.05.02 ultrix support added. expand_vars removed from * register function. Paste bug fixed. * sysmacros.h now included in pty.c on sgis * Strange hpux hack added for TTYCMP. * Zombie feature improved. * 08.09.93 -- 3.05.03 Makefile and OSF1 fine tuning. Eased attach to * multi sessions. Writelock now obeys acl write * permissions. UserDel() now preserves defaults. * acladd/aclchg syntax improved. Updated * documentation. Bug in at command fixed. * MakeWindow() now obeys perm defaults. * 03.10.93 -- 3.05.90 Multiple displays can now share the same window. * Layers now belong to Windows. "Select -" yields a blank * page. Debug output can be switched on/off at runtime. * Number command changes window number and utmp-slot. * 14.10.93 -- 3.05.91 Mechanism to find the "best" window added. Much * debugging done and still needed. Slowpaste setting now * per window. Preserving fore AND other window when * detached. Per user settings for `monitor' and `silence'. * New command `su'. BlankWindow performs now ColonInput. * History command fixed, it depended on paste code that * was previously changed to allow concatenation of buffers. * Fixing umask problem with WriteFile() reported by Jamie * Mason. * 30.11.93 -- 3.05.04 Kanji support added. New keymap feature: * bindkey and various map commands. GR and C1 * flags now define the character processing. * 30.11.93 -- 3.05.92 Kanji support added. New keymap feature: * bindkey and various map commands. GR and C1 * flags now define the character processing. * 17.12.93 -- 3.05.93 Tcon authentification mechanism. AddChar macro broken up * into 2 functions. Acl.c, network.c, misc.c, termcap.c * and tty.c are now display free! * 27.12.93 -- 3.05.94 Telnet login works, can export one window per mux. * Acl-groups added. Export rights is an acl. * connect works, can create shadow window thus import * command channel and switch windows. Can detach sessions * from each other. Can renumber imported and exported * windows. DL_LOOP prevents now SEGV, sessions have names * and can be connected to very flexible. * 03.01.94 -- 3.05.95 Import and export of any number of channels works, * except a small bug with margin handling when exporting. * Window titles are forwarded, break is forwarded and * tcon learned the mux protocoll. A few more bugs in * network.c fixed. Tcon has Mux arrays, Protocoll is '\0' * free. * 08.01.94 -- 3.05.96 More tcon work. Solaris debugging. * * 14.01.94 -- 3.05.05 New FindSocket() code. Nicer socket handling. * 20.01.94 -- 3.05.06 New attribute handling code. NeXT fixes. * 04.02.94 -- 3.05.07 Ugly bug in ScrollH fixed. Keymap defaults. * 10.03.94 -- 3.05.97 'defsilence' by Lloyd Zusman. Zombie resurrekt key. * -b, -p options. Fixed Compilekeys(), gulp. config.h * allows choice of VMIN/VTIME/NDELAY for ttys. * 13.04.94 -- 3.05.08 Kanji bug fixed. POSIX sigaction support. * os.h cleanup. UTNOKEEP splitted into * UT_CLOSE and UT_UNSORTED. linux no longer * implies UT_CLOSE. "struct display" name * convention change: _d_ to d_ and d_ to D_. * 20.04.94 -- 3.05.09 configure.in ptyrange bug fixed. Upgraded * to autoconf-1.8 * 27.04.94 -- 3.05.10 97801 obscure code support. Linux long * password workaround. * 09.05.94 -- 3.05.11 seteuid() support added. Security fixes. * _IBMR2 kludge makes call to sleep obsolete. * Small fixes in uname() code. djm suggests replace of * BSDI by __bsdi__. * 27.07.94 -- 3.05.12 seteuid attacher bug fixed. ks/ke changed * in termcap/info and termcap.c * 01.09.94 -- 3.05.58 (There are a few more patches to come, subtracted 40) * breaktype command to select how we cause breaks. * Testing logfile.c. Manual and texinfo documentation * updated to explain all new commands except keymapping. * Added modem lines to info of plain ttys. Using * cfset{i,o}speed() for POSIX is better, much better. * 07.09.94 -- 3.05.59 Flushing logfiles every 5 seconds. Testing new * resize linewrap code. Resize with care. * Resurrect now displays its command string. * 11.09.94 -- 3.05.60 Lines are now correctly wrapped, when window size * changes; this prevents loss of text. * 15.09.94 -- 3.05.61 umask renamed to aclumask, bell renamed to bell_msg. * *_msg commands show message when called w/o parameter. * Many changes in the manual, thanks to Sven Guckes. * -O removed. * 27.09.94 -- 3.05.13 defwlock stupidity fixed. MakeTermcap ks/ke * ':' removed. Termcap entry improved. * copy_reg and ins_reg obsoleted by better paste command: * paste => paste . * copy_reg r => paste . r * ins_reg r => paste r * ins_reg => paste * 18.10.94 -- 3.05.62 breaktype changed. -L option added to enable logging * from both command line and screenrc. SIGXFSZ ignored. * 28.11.94 -- 3.05.63 ACL's sharpened. No user has any rights, unless * explicitly given. Only two exceptions: 1) "acladd user" * without further parameters. 2) Evry user has a default * umask that gives himself all permissions on the windows * he creates. Bug with colon input on shared windows fixed. * The commad is now executed by the user typing the final * Enter-Key rather by a random user. * 30.11.94 -- 3.05.64 On demand grabbing of pending auto writelocks. * Solaris troubles us with kill(pid, 0) ... not fixed... * defbreaktype added. (breaktype is also global, still...) * SIGARGHACK cleared, to pamper poor little Ultrix4.4 cfe. * defescape added. * w_status changed to w_hstatus, it's a #define in * Domain/OS reported by ejackson@iastate.edu. * 05.12.94 -- 3.05.17 SVR4 pty bug fixed, don't update window status * line if not changed, onyx support. Manual * pages updated. * 14.12.94 -- 3.05.18 w_status changed to w_hstatus, it's a #define in * Domain/OS reported by ejackson@iastate.edu. * Screen manpage patches by larry. * Ugly seteuid bug in ForkWindow() fixed. * 20.12.94 -- 3.06.00 Solaris has broken seteuid(). * osf loadav patches. -- DISTRIBUTED * 08.01.95 -- 3.05.65 Bug with LOGOUTOK and -ln fixed. redundant secfopen() * avoided, when logfflush() looks at delayed nfs updates. * Option parser now allowes condensed options. -A fixed. * New commands 'preselect' and 'defpreselect'. New option * -WdmS starts a detached screen session with watchdog. * 16.01.95 -- 3.06.01 KANJI patch. doc/Makefile.in fixed. * Install now calls doc/Makefile install. * Don't use 'ds' too often, breaks MSkermit. * undef'd LOGOUTOK logs in now. * Ultrix is broken, too (seteuid). * Use \r (not \n) to join lines in pastebuf. * bindkey can now remove sequences. * InitTTY fixed for PLAIN. -- DISTRIBUTED * 06.02.95 -- 3.05.66 DisplayLine() does now clipping to reduce coredump- * frequency. Window size is adapted to the display that * types input, to reduce multi-user confusion. Scrollback * mode still may get the wrong size. * 07.02.95 -- 3.05.67 WinRewrite() also needs to clip. Users without unix * account, but with screen password allowed. Chacl * allows password change, su prompts for user name too. * 01.03.95 -- 3.05.68 Leaving a window may now cause a resize to match a * remaining display. Simple ESC-CR fix in the vt100 * state machine. * 26.03.95 -- 3.05.69 Markroutine() needs to resize the window to avoid * coredumps, just like WinProcess() already does. * More NEED_ flags added in comm.c to avoid coredumps. * 04.04.95 -- 3.06.02 Simple ESC-CR fix in the vt100 state machine. * Now compiles again with all extras disabled. * Zombie resurrect added. defc1, defgr, defkanji * added. Screen now replies to a secondary DA * query. Some missing NEED_XXX added in comm.c. * Better default tty permissions/group test. * More AUX support, now compiles with POSIX. * Function keycodes xtermified (F11, F12). * Paste bug fixed (only worked with KANJI). * Check bcopy before memcpy/memmove. * FindSocket code much fixed & improved. * 10.04.95 -- 3.05.70 Display_displays() now shows the users permissions on * the currently displayed window, this is easier than a * full featured lsacl, but also helps. chacl can now copy * users, but we need to copy windows. * 26.04.95 -- 3.05.71 Multi digit screen numbers in utmp. MakeWindow() now * echoes what it does, just like RemakeWindow() when * 'verbose on' (default off). * `screen -ls myname/' will find own(!) non-multi sessions. * Command line option -q improved and documented. * 'debug off' also shuts attacher debugging off now. * 03.05.95 -- 3.05.72 'connect' command bugfixed. colon prompt improved. * open(O_NONBLOCK) does not work on 4.1.3, using O_NDELAY. * There are writes to exp_wid2chan[-1], XXX I just added * fillers to the mux structure, please debug this ASAP! * WindowByName() prefers exact matches now. Esc forwarding * from Frontend to Backend suppressed unless specified. * 26.06.95 -- 3.05.73 Improving the combination of dflag and rflag: If both * are set, a screen session is reattached, regardless * if it was previously detached or attached elseewhere. * "screen -D -RR" is thus most powerful: Give me my screen * session here and now. No matter, if this means creating * a new session (due to the second R without warning * message), detching the session first (and due to the * capitalised D logging out), or simply attaching to it. * 13.07.95 -- 3.05.74 Markroutine learned new join mode: comma seperated. * Can disable the detach feature from config.h. * Configure.in now calls etc/toolcheck. Password is no * longer a static array. * 30.07.95 -- 3.05.75 Karl Heuer wants to install with a relative symlink. * Command line option -k removed (try -t). * 31.08.95 -- 3.06.03 Color support, digraph command, code * cleanup (struct mchar/mline added). * 03.09.95 -- 3.06.04 SetRendition display check. Solaris unblock * SIGHUP. w_curchar->w_rend, lintified. * Shadow-password code moved and rewritten * (includes sun C2). * 06.09.95 -- 3.05.76 Added support for braille displays (by Hadi Bargi Rangin * and Bill Barry, {bargy,barryb}@dots.physics.orst.edu * Added baud, cs8, istrip, ixon, ixoff options for plain * tty windows. Untested. * 09.09.95 -- 3.07.99 Merged 3.7.76 back into the main distribution but * without network, blankwindow and dlist support. * Global variable Password removed. * Resize code completely rewritten. * New commands: sorendition, (def)charset. * strftime-like message generation. * 26.09.95 -- 3.06.05 resize code completely rewritten. * Very visible cursor added. vbell sequence * \Eb added. _delay for terminfo libs added * to make the padding work for the first time. * New ProcessInput() makes "command command" * work. '[def]escape ""' clears escape chars. * Changed logdir command to logfile. It now uses * MakeWinMsg() to create the filename. * Updated the manuals. * 03.10.95 -- 3.08.00 Merged 3.07.99 back into my 3.06.05. * pause removed. NONROOT now in config.h. * sysV68 configure test. Socket protocol got * revision number. New command termcapinfo. * Screenrcs, docs & configure.in updated * 18.10.95 -- 3.08.01 Info shows parser state. * Very visible cursor added. vbell sequence * \Eb added. _delay for terminfo libs added * to make the padding work for the first time. * Braille code almost completely reworked. * New ProcessInput() makes "command command" * work. '[def]escape ""' clears escape chars. * Command logdir -> logfile and uses MakeWinMsg. * Updated the manuals. New mark command 'x'. * stuff has new "-k" parameter. * 28.10.95 -- 3.06.06 Added new 'XC' capability to provide * a method for character translation. * 17.11.95 -- 3.07.00 Added CheckEscape() function. * acl -> acls because of hpux10 nameclash * /stand/vmunix added to kernel list (hpux10) * stripdev changed to translate * /dev/pts to /dev/pts/ (unixware) * -lgen added to GETUTENT configure test. * 20.11.95 -- 3.07.01 corrected vbell null ptr reference. * -- DISTRIBUTED * 27.11.95 -- 3.08.02 Added CheckEscape() function. * acl -> acls because of hpux10 nameclash * /stand/vmunix added to kernel list (hpux10) * stripdev changed to translate * /dev/pts to /dev/pts/ (unixware) * -lgen added to GETUTENT configure test. * corrected vbell null ptr reference * -- 3.08.03 etc/toolcheck is now shouting louder. * Solaris 2.5 has /kernel/genunix. * Touching socket when detach/attach. * FindWindow corrected. AIX4 patch * from robert@mayday.cix.co.uk. * 1.09.96 -- 3.07.02 added #ifdef MAPKEYS for CheckEscape. * etc/toolcheck is now shouting louder. * Touching socket when detach/attach. * Linux tcflush hack. Linux md5 password suport. * USE_SGR support for dumb (wyse) terminals. * "at" and "reset" commands improved. * Now sensitive to broken AIX4 TIOCPKT. * tek patch unapplied. * linux utmp patch: set slot to DEAD_PROCESS. * include signal.h for killpg if hpux10.10. * linux: elf, but no SVR4, check for utmpx. * hpux10.10 libcurses breaks select()! * -- DISTRIBUTED * 27.09.96 -- 3.07.03 ncurses tgetflag returns -1 if cap not valid. * autonuke fix: reset application mode. An init * string may have cleared it. * Small UTMPOK patch from Douglas B. Jones. * 23.06.97 -- 3.07.04 Some bugfixes. Kanji fixed. * Code update from 3.8.6: Colon line editing added. * Digraph made line-editing resistant. * DEC ALPHA ut_user[0] = 0; * Added error messages to exit_with_usage. * FindSocket code improved (the MULTIUSER part). * Use utimes() if available. Power-detached start. * vsnprintf() support. exit -> _exit in window.c. * AddXChars now tolerates NULL string. * -- DISTRIBUTED * 10.11.98 -- 3.07.05 Wayne's resize.c patch to keep the cursor * onscreen. FindWindow corrected. AIX4 patch * from robert@mayday.cix.co.uk. * Fixed kanji am & markcursor bugs. * SCO support (Gert Doering). * Wayne's statusline extra space. New flag nospc * for MakeWinMsg. New TF capability: add missing * termcap/info caps. screen-exchange security * fix. Use kstat for Solaris' loadavg. * Check for mode 775 if screen runs setgid. * Fixed typo in silence command. * Allow detach with no tty. HPUX10.20 ltchars * hack. Use @1/@7 as replacement for kh/kH. * Use seteuid before calling tgetent. * Check for displays in Msg(). * Linux ncurses hack: redefine _nc_timed_wait. * Configure check for ncurses (sigh). * ITOH Yasufumi: kanji fixes, osf support, * bug fixes. More secure Rewrite(). * Increased line buffer size to 2048 bytes. * SCO-5 Fixes (Brian L. Gentry). * 25.11.98 -- 3.07.06 resize code now handles tabs correctly. * -- DISTRIBUTED * -- 3.09.00 loads'o'bugs fixed, 3.8 merged with 3.7. * new region clip code. * Many new features (see NEWS file). * 3.08.99 -- 3.09.02 -- DISTRIBUTED * 11.08.99 -- 3.09.04 small utmp fix, BSD chflags fix, tty mode fix * -- DISTRIBUTED * 1.09.99 -- 3.09.05 linux SVR4_PTYS fixes, better ShowWindos(), * Panic() displays bug fixed, strerror fixed, * missing $srcdir & bad prefix in Makefiles. * console grabbing with SRIOCSREDIR. * linux utmp workaround added. Some KANJI bugs * fixed. Stupid StuffKey() bug fixed. * -- DISTRIBUTED * 24.07.00 -- 3.09.06 kanji fixes. lock escape char fix. * removed delayed message hack. * resize command & focus subcomands by joze. * fix for solaris' utmp_helper bug. * linux tty handling fix. * mousetracking, rxvt osc sequences. * background color erase support. * don't log user in after hangup. * hstatus escape update bug fixed. * 1.09.00 -- 3.09.08 -- DISTRIBUTED * 25.05.01 -- 3.09.09 use $DESTDIR in Makefiles. * renamed struct user to acluser to fix hpux * problem for good. utf8 support. 16 color * support. New -X option and escape sequence * to send screen commands. * New commands: attrcolor, defutf8, dinfo, utf8. * Extended commands: width, height, readbuf, * writebuf. Better nlist64 detection. * New config.h option SOCKDIR_IS_LOCAL_TO_HOST. * Don't call tputs with an empty string. * New string escape %{ for attr/color changes. * LRefreshAll bug fixed (0 instead of -1 as bce). * New quote handling in Parse(). Workaround for * some bad termcap/info entries added. Set BE * for all xtermish emulators. Added '0x' and * 'U+' prefix in digraph command. LOADAV_TYPE * detection fixed. * -- DISTRIBUTED * 4.09.01 -- 3.09.10 '-R' security fix. Fixed array in MScrollV(). * -- DISTRIBUTED * Reset charset after 'me'. * 14.02.02 -- 3.09.11 Support for other encodings. Double width * utf-8 chars. 'L' modifier for %D, %M, %w * and %W. New %= (hfill), %H (hostname), * %f (flags), %F (focus) escapes. New commands * source, windowlist, deflog. Command key classes. * New login state: always. Time format * changeable. 256 color support. * Updated digraph table. Ignorecase. * Windowlist resizeable on blank window. * Added encoding to paste buffers. * Hpux loadtype detection fixed. * Disabled im/ic warning. Fixed a bug that * could cause window lockups in rare * circumstances. Made hangup signal to the * backend process detach all displays. * New escapes %< %>, + and - flag for %w. * Added eval command, added -h option to detach. * Also set flayer when processing -X commands. * use getpt() on linux systems. doc patches from * Adam Lazur. tty flow/intr cleanup. * -- DISTRIBUTED * 29.08.2002 3.09.12 Port to POSIX 1003.1-2001 hosts (Paul Eggert). * Fixed encoding for reattach password test. * Fixed NUL characters when encodings are active. * Fixed silly encodings bugs. Fixed bogus * oldflayer when a window gets freed. * Altscreen support by Gurusamy Sarathy. * Reuse old password in builtin_screenlock. * -- DISTRIBUTED * 05.09.2002 3.09.13 added missing break statement that broke * the eval command. * -- DISTRIBUTED * 13.03.2003 3.09.15 Console workaround for linux. Scrolling-region * reset fix. GBK encoding added. * support for unicode combining characters added. * openpty() support added (thomas@xs4all.nl). * preselect of blank window ('-') or window * list ('=') added. Added %` string escape * and backtick command. * -- DISTRIBUTED * 08.09.2003 4.00.00 rewrote nonblock command, added defnonblock. * added zmodem support (catch & passthrough). * added screenblanker. * fixed a couple of GBK bugs. * rewrote command parsing. * added -m option to windowlist (Felix Rosencrantz) * -- DISTRIBUTED * 18.09.2003 4.00.01 fixed two small bugs in the new parser. * -- DISTRIBUTED * 05.12.2003 4.00.02 fixed a bug in the ansi parser. fixed execs * on ttys. fixed hardstatus line on blanked screen. * -- DISTRIBUTED * 11.10.2004, 4.00.03jw handle StartRc errors nonfatal if due to a msg. * 12.10.2004, 4.00.03jw1 let docu of 'split' 'focus' 'remove' and 'only' refer to each other. * 01.11.2004, 4.00.03jw2 zombie command has new option 'onerror' * 2005-12-19, 4.00.03jw3 syntax error. */ #define ORIGIN "GNU" #define REV 4 #define VERS 8 #define PATCHLEVEL 0 #define DATE "05-Feb-20" #define STATE "" screen-4.8.0/term.c0000644000175000017500000001714313616620402013023 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include "term.h" #define KMAPDEF(s) #define KMAPADEF(s) #define KMAPMDEF(s) struct term term[T_N] = { /* display size */ { "li", T_NUM }, { "co", T_NUM }, /* terminal types*/ { "hc", T_FLG }, { "os", T_FLG }, { "ns", T_FLG }, /* cursor movement */ { "cm", T_STR }, { "ho", T_STR }, { "cr", T_STR }, { "up", T_STR }, { "UP", T_STR }, { "do", T_STR }, { "DO", T_STR }, { "bs", T_FLG }, { "bc", T_STR }, { "le", T_STR }, { "LE", T_STR }, { "nd", T_STR }, { "RI", T_STR }, /* scroll */ { "cs", T_STR }, { "nl", T_STR }, { "sf", T_STR }, { "sr", T_STR }, { "al", T_STR }, { "AL", T_STR }, { "dl", T_STR }, { "DL", T_STR }, /* insert/delete */ { "in", T_FLG }, { "im", T_STR }, { "ei", T_STR }, { "ic", T_STR }, { "IC", T_STR }, { "dc", T_STR }, { "DC", T_STR }, /* erase */ { "ut", T_FLG }, { "cl", T_STR }, { "cd", T_STR }, { "CD", T_STR }, { "ce", T_STR }, { "cb", T_STR }, /* initialise */ { "is", T_STR }, { "ti", T_STR }, { "te", T_STR }, /* bell */ { "bl", T_STR }, { "vb", T_STR }, /* resizing */ { "WS", T_STR }, { "Z0", T_STR }, { "Z1", T_STR }, /* attributes */ /* define T_ATTR */ { "mh", T_STR }, { "us", T_STR }, { "md", T_STR }, { "mr", T_STR }, { "so", T_STR }, { "mb", T_STR }, { "ue", T_STR }, { "se", T_STR }, { "me", T_STR }, { "ms", T_FLG }, { "sg", T_NUM }, { "ug", T_NUM }, { "sa", T_STR }, /* color */ { "AF", T_STR }, { "AB", T_STR }, { "Sf", T_STR }, { "Sb", T_STR }, { "op", T_STR }, { "Co", T_NUM }, { "be", T_FLG }, { "AX", T_FLG }, { "C8", T_FLG }, /* keypad/cursorkeys */ { "ks", T_STR }, { "ke", T_STR }, { "CS", T_STR }, { "CE", T_STR }, /* printer */ { "po", T_STR }, { "pf", T_STR }, /* status line */ { "hs", T_FLG }, { "ws", T_NUM }, { "ts", T_STR }, { "fs", T_STR }, { "ds", T_STR }, /* cursor visibility */ { "vi", T_STR }, { "vs", T_STR }, { "ve", T_STR }, /* margin handling */ { "am", T_FLG }, { "xv", T_FLG }, { "xn", T_FLG }, { "OP", T_FLG }, { "LP", T_FLG }, /* special settings */ { "NF", T_FLG }, { "nx", T_FLG }, { "AN", T_FLG }, { "OL", T_NUM }, { "KJ", T_STR }, { "VR", T_STR }, { "VN", T_STR }, { "TF", T_FLG }, { "XT", T_FLG }, /* d_font setting */ { "G0", T_FLG }, { "S0", T_STR }, { "E0", T_STR }, { "C0", T_STR }, { "as", T_STR }, { "ae", T_STR }, { "ac", T_STR }, { "eA", T_STR }, { "XC", T_STR }, /* keycaps */ /* define T_CAPS */ /* mouse */ { "Km", T_STR }, KMAPDEF("\033[M") KMAPMDEF("\222") /* nolist */ { "k0", T_STR }, KMAPDEF("\033[10~") { "k1", T_STR }, KMAPDEF("\033OP") { "k2", T_STR }, KMAPDEF("\033OQ") { "k3", T_STR }, KMAPDEF("\033OR") { "k4", T_STR }, KMAPDEF("\033OS") { "k5", T_STR }, KMAPDEF("\033[15~") { "k6", T_STR }, KMAPDEF("\033[17~") { "k7", T_STR }, KMAPDEF("\033[18~") { "k8", T_STR }, KMAPDEF("\033[19~") { "k9", T_STR }, KMAPDEF("\033[20~") { "k;", T_STR }, KMAPDEF("\033[21~") { "F1", T_STR }, KMAPDEF("\033[23~") { "F2", T_STR }, KMAPDEF("\033[24~") /* extra keys for vt220 (David.Leonard@it.uq.edu.au) */ /* define T_FEXTRA */ { "F3", T_STR }, { "F4", T_STR }, { "F5", T_STR }, { "F6", T_STR }, { "F7", T_STR }, { "F8", T_STR }, { "F9", T_STR }, { "FA", T_STR }, { "FB", T_STR }, { "FC", T_STR }, { "FD", T_STR }, { "FE", T_STR }, { "kb", T_STR }, { "K1", T_STR }, { "K2", T_STR }, { "K3", T_STR }, { "K4", T_STR }, { "K5", T_STR }, /* more keys for Andrew A. Chernov (ache@astral.msk.su) */ { "kA", T_STR }, { "ka", T_STR }, /* define T_BACKTAB */ { "kB", T_STR }, { "kC", T_STR }, { "kE", T_STR }, { "kF", T_STR }, KMAPMDEF("\004") { "kL", T_STR }, { "kM", T_STR }, { "kR", T_STR }, KMAPMDEF("\025") { "kS", T_STR }, { "kT", T_STR }, { "kt", T_STR }, { "*4", T_STR }, /* kDC */ { "*7", T_STR }, /* kEND */ { "#2", T_STR }, /* kHOM */ { "#3", T_STR }, /* kIC */ { "#4", T_STR }, /* kLFT */ { "%c", T_STR }, /* kNXT */ { "%e", T_STR }, /* kPRV */ { "%i", T_STR }, /* kRIT */ /* keys above the cursor */ /* define T_NAVIGATE */ { "kh", T_STR }, KMAPDEF("\033[1~") KMAPMDEF("\201") { "@1", T_STR }, { "kH", T_STR }, KMAPDEF("\033[4~") KMAPMDEF("\205") { "@7", T_STR }, KMAPDEF("\033[4~") KMAPMDEF("\205") { "kN", T_STR }, KMAPDEF("\033[6~") KMAPMDEF("\006") { "kP", T_STR }, KMAPDEF("\033[5~") KMAPMDEF("\002") { "kI", T_STR }, KMAPDEF("\033[2~") /* define T_NAVIGATE_DELETE */ { "kD", T_STR }, KMAPDEF("\033[3~") /* keys that can have two bindings */ /* define T_CURSOR */ { "ku", T_STR }, KMAPDEF("\033[A") KMAPADEF("\033OA") KMAPMDEF("\220") { "kd", T_STR }, KMAPDEF("\033[B") KMAPADEF("\033OB") KMAPMDEF("\216") { "kr", T_STR }, KMAPDEF("\033[C") KMAPADEF("\033OC") KMAPMDEF("\206") { "kl", T_STR }, KMAPDEF("\033[D") KMAPADEF("\033OD") KMAPMDEF("\202") /* define T_KEYPAD */ { "f0", T_STR }, KMAPDEF("0") KMAPADEF("\033Op") { "f1", T_STR }, KMAPDEF("1") KMAPADEF("\033Oq") { "f2", T_STR }, KMAPDEF("2") KMAPADEF("\033Or") { "f3", T_STR }, KMAPDEF("3") KMAPADEF("\033Os") { "f4", T_STR }, KMAPDEF("4") KMAPADEF("\033Ot") { "f5", T_STR }, KMAPDEF("5") KMAPADEF("\033Ou") { "f6", T_STR }, KMAPDEF("6") KMAPADEF("\033Ov") { "f7", T_STR }, KMAPDEF("7") KMAPADEF("\033Ow") { "f8", T_STR }, KMAPDEF("8") KMAPADEF("\033Ox") { "f9", T_STR }, KMAPDEF("9") KMAPADEF("\033Oy") { "f+", T_STR }, KMAPDEF("+") KMAPADEF("\033Ok") { "f-", T_STR }, KMAPDEF("-") KMAPADEF("\033Om") { "f*", T_STR }, KMAPDEF("*") KMAPADEF("\033Oj") { "f/", T_STR }, KMAPDEF("/") KMAPADEF("\033Oo") { "fq", T_STR }, KMAPDEF("=") KMAPADEF("\033OX") { "f.", T_STR }, KMAPDEF(".") KMAPADEF("\033On") { "f,", T_STR }, KMAPDEF(",") KMAPADEF("\033Ol") { "fe", T_STR }, KMAPDEF("\015") KMAPADEF("\033OM") /* other things related to keycaps */ /* define T_OCAPS */ { "km", T_FLG }, { "ko", T_STR }, { "l0", T_STR }, { "l1", T_STR }, { "l2", T_STR }, { "l3", T_STR }, { "l4", T_STR }, { "l5", T_STR }, { "l6", T_STR }, { "l7", T_STR }, { "l8", T_STR }, { "l9", T_STR }, { "la", T_STR }, /* list */ /* define T_ECAPS */ /* define T_N */ }; screen-4.8.0/sched.c0000644000175000017500000001607213616620402013142 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include #if !defined(sun) && !defined(B43) && !defined(ISC) && !defined(pyr) && !defined(_CX_UX) # include #endif #include #include "config.h" #include "screen.h" #include "extern.h" static struct event *evs; static struct event *tevs; static struct event *nextev; static int calctimeout; static struct event *calctimo __P((void)); #if (defined(sgi) && defined(SVR4)) || defined(__osf__) || defined(M_UNIX) static int sgihack __P((void)); #endif void evenq(ev) struct event *ev; { struct event *evp, **evpp; debug3("New event fd %d type %d queued %d\n", ev->fd, ev->type, ev->queued); if (ev->queued) return; evpp = &evs; if (ev->type == EV_TIMEOUT) { calctimeout = 1; evpp = &tevs; } for (; (evp = *evpp); evpp = &evp->next) if (ev->pri > evp->pri) break; ev->next = evp; *evpp = ev; ev->queued = 1; } void evdeq(ev) struct event *ev; { struct event *evp, **evpp; debug3("Deq event fd %d type %d queued %d\n", ev->fd, ev->type, ev->queued); if (!ev->queued) return; evpp = &evs; if (ev->type == EV_TIMEOUT) { calctimeout = 1; evpp = &tevs; } for (; (evp = *evpp); evpp = &evp->next) if (evp == ev) break; ASSERT(evp); *evpp = ev->next; ev->queued = 0; if (ev == nextev) nextev = nextev->next; } static struct event * calctimo() { struct event *ev, *min; long mins; if ((min = tevs) == 0) return 0; mins = min->timeout.tv_sec; for (ev = tevs->next; ev; ev = ev->next) { ASSERT(ev->type == EV_TIMEOUT); if (mins < ev->timeout.tv_sec) continue; if (mins > ev->timeout.tv_sec || min->timeout.tv_usec > ev->timeout.tv_usec) { min = ev; mins = ev->timeout.tv_sec; } } return min; } void sched() { struct event *ev; fd_set r, w, *set; struct event *timeoutev = 0; struct timeval timeout; int nsel; for (;;) { if (calctimeout) timeoutev = calctimo(); if (timeoutev) { gettimeofday(&timeout, NULL); /* tp - timeout */ timeout.tv_sec = timeoutev->timeout.tv_sec - timeout.tv_sec; timeout.tv_usec = timeoutev->timeout.tv_usec - timeout.tv_usec; if (timeout.tv_usec < 0) { timeout.tv_usec += 1000000; timeout.tv_sec--; } if (timeout.tv_sec < 0) { timeout.tv_usec = 0; timeout.tv_sec = 0; } } #ifdef DEBUG debug("waiting for events"); if (timeoutev) debug2(" timeout %d secs %d usecs", timeout.tv_sec, timeout.tv_usec); debug(":\n"); for (ev = evs; ev; ev = ev->next) debug3(" - fd %d type %d pri %d\n", ev->fd, ev->type, ev->pri); if (tevs) debug("timed events:\n"); for (ev = tevs; ev; ev = ev->next) debug3(" - pri %d sec %d usec %d\n", ev->pri, ev->timeout.tv_sec, ev->timeout.tv_usec); #endif FD_ZERO(&r); FD_ZERO(&w); for (ev = evs; ev; ev = ev->next) { if (ev->condpos && *ev->condpos <= (ev->condneg ? *ev->condneg : 0)) { debug2(" - cond ev fd %d type %d failed\n", ev->fd, ev->type); continue; } if (ev->type == EV_READ) FD_SET(ev->fd, &r); else if (ev->type == EV_WRITE) FD_SET(ev->fd, &w); } #ifdef DEBUG debug("readfds:"); for (nsel = 0; nsel < FD_SETSIZE; nsel++) if (FD_ISSET(nsel, &r)) debug1(" %d", nsel); debug("\n"); debug("writefds:"); for (nsel = 0; nsel < FD_SETSIZE; nsel++) if (FD_ISSET(nsel, &w)) debug1(" %d", nsel); debug("\n"); #endif nsel = select(FD_SETSIZE, &r, &w, (fd_set *)0, timeoutev ? &timeout : (struct timeval *) 0); if (nsel < 0) { if (errno != EINTR) { #if defined(sgi) && defined(SVR4) if (errno == EIO && sgihack()) continue; #endif #if defined(__osf__) || defined(M_UNIX) /* OSF/1 3.x, SCO bug: EBADF */ /* OSF/1 4.x bug: EIO */ if ((errno == EIO || errno == EBADF) && sgihack()) continue; #endif Panic(errno, "select"); } nsel = 0; } else if (nsel == 0) /* timeout */ { debug("TIMEOUT!\n"); ASSERT(timeoutev); evdeq(timeoutev); timeoutev->handler(timeoutev, timeoutev->data); } #ifdef SELECT_BROKEN /* * Sequents select emulation counts a descriptor which is * readable and writeable only as one hit. Waaaaa. */ if (nsel) nsel = 2 * FD_SETSIZE; #endif for (ev = evs; ev; ev = nextev) { nextev = ev->next; if (ev->type != EV_ALWAYS) { set = ev->type == EV_READ ? &r : &w; if (nsel == 0 || !FD_ISSET(ev->fd, set)) continue; nsel--; } if (ev->condpos && *ev->condpos <= (ev->condneg ? *ev->condneg : 0)) continue; debug2(" + hit ev fd %d type %d!\n", ev->fd, ev->type); ev->handler(ev, ev->data); } } } void SetTimeout(ev, timo) struct event *ev; int timo; { ASSERT(ev->type == EV_TIMEOUT); debug2("event %x new timeout %d ms\n", ev, timo); gettimeofday(&ev->timeout, NULL); ev->timeout.tv_sec += timo / 1000; ev->timeout.tv_usec += (timo % 1000) * 1000; if (ev->timeout.tv_usec > 1000000) { ev->timeout.tv_usec -= 1000000; ev->timeout.tv_sec++; } if (ev->queued) calctimeout = 1; } #if (defined(sgi) && defined(SVR4)) || defined(__osf__) || defined(M_UNIX) extern struct display *display, *displays; static int sgihack() { fd_set r, w; struct timeval tv; debug("IRIX5.2 workaround: searching for bad display\n"); for (display = displays; display; ) { FD_ZERO(&r); FD_ZERO(&w); FD_SET(D_userfd, &r); FD_SET(D_userfd, &w); tv.tv_sec = tv.tv_usec = 0; if (select(FD_SETSIZE, &r, &w, (fd_set *)0, &tv) == -1) { if (errno == EINTR) continue; Hangup(); /* goodbye display */ return 1; } display = display->d_next; } return 0; } #endif screen-4.8.0/FAQ0000777000175000017500000000000013607701732013336 2doc/FAQustar amadeamadescreen-4.8.0/osdef.sh0000644000175000017500000000340413616620402013337 0ustar amadeamade#! /bin/sh if test -z "$CPP"; then CPP="cc -E" fi if test -z "$srcdir"; then srcdir=. fi rm -f core* sed < $srcdir/osdef.h.in -n -e '/^extern/s@.*[)* ][)* ]*\([^ *]*\) __P.*@/[)*, ]\1[ (]/i\\\ \\/\\[^a-zA-Z_\\]\1 __P\\/d@p' > osdef1.sed cat << EOF > osdef0.c #include "config.h" #include #include #include #include #include #ifdef SHADOWPW #include #endif #ifndef sun #include #endif #ifdef linux #include #include #endif #include #ifndef NOSYSLOG #include #endif #include "os.h" #if defined(UTMPOK) && defined (GETTTYENT) && !defined(GETUTENT) #include #endif #ifdef SVR4 # include #endif EOF cat << EOF > osdef2.sed 1i\\ /* 1i\\ * This file is automagically created from osdef.sh -- DO NOT EDIT 1i\\ */ EOF $CPP -I. -I$srcdir osdef0.c | sed -n -f osdef1.sed >> osdef2.sed sed -f osdef2.sed < $srcdir/osdef.h.in > osdef.h rm osdef0.c osdef1.sed osdef2.sed if test -f core*; then file core* echo " Sorry, your sed is broken. Call the system administrator." echo " Meanwhile, you may try to compile screen with an empty osdef.h file." echo " But if your compiler needs to have all functions declared, you should" echo " retry 'make' now and only remove offending lines from osdef.h later." exit 1 fi if eval test "`diff osdef.h $srcdir/osdef.h.in | wc -l`" -eq 4; then echo " Hmm, sed is very pessimistic about your system header files." echo " But it did not dump core -- strange! Let's continue carefully..." echo " If this fails, you may want to remove offending lines from osdef.h" echo " or try with an empty osdef.h file, if your compiler can do without" echo " function declarations." fi screen-4.8.0/acls.c0000644000175000017500000007011013616620402012767 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include "config.h" #include /* XXX: WHY IS THIS HERE?? :XXX */ #ifdef CHECKLOGIN # ifdef _SEQUENT_ # include /* needed by */ # endif /* _SEQUENT_ */ # include # ifdef SHADOWPW # include # endif /* SHADOWPW */ #endif /* CHECKLOGIN */ #ifndef NOSYSLOG # include #endif #include "screen.h" /* includes acls.h */ #include "extern.h" /************************************************************************ * user managing code, this does not really belong into the acl stuff * ************************************************************************/ extern struct comm comms[]; extern struct win *windows, **wtab; extern char NullStr[]; extern char SockPath[]; extern struct display *display, *displays; struct acluser *users; #ifdef MULTIUSER int maxusercount = 0; /* used in process.c: RC_MONITOR, RC_SILENCE */ /* record given user ids here */ static AclBits userbits; /* * rights a new unknown user will have on windows and cmds. * These are changed by a "umask ?-..." command: */ static char default_w_bit[ACL_BITS_PER_WIN] = { 1, /* EXEC */ 1, /* WRITE */ 1 /* READ */ }; static char default_c_bit[ACL_BITS_PER_CMD] = { 0 /* EXEC */ }; /* rights of all users per newly created window */ /* * are now stored per user (umask) * static AclBits default_w_userbits[ACL_BITS_PER_WIN]; * static AclBits default_c_userbits[ACL_BITS_PER_CMD]; */ static int GrowBitfield __P((AclBits *, int, int, int)); static struct aclusergroup **FindGroupPtr __P((struct aclusergroup **, struct acluser *, int)); static int AclSetPermCmd __P((struct acluser *, char *, struct comm *)); static int AclSetPermWin __P((struct acluser *, struct acluser *, char *, struct win *)); static int UserAcl __P((struct acluser *, struct acluser **, int, char **)); static int UserAclCopy __P((struct acluser **, struct acluser **)); static int GrowBitfield(bfp, len, delta, defaultbit) AclBits *bfp; int len, delta, defaultbit; { AclBits n, o = *bfp; int i; if (!(n = (AclBits)calloc(1, (unsigned long)(&ACLBYTE((char *)0, len + delta + 1))))) return -1; for (i = 0; i < (len + delta); i++) { if (((i < len) && (ACLBIT(i) & ACLBYTE(o, i))) || ((i >= len) && (defaultbit))) ACLBYTE(n, i) |= ACLBIT(i); } if (len) free((char *)o); *bfp = n; return 0; } #endif /* MULTIUSER */ /* * Returns an nonzero Address. Its contents is either a User-ptr, * or NULL which may be replaced by a User-ptr to create the entry. */ struct acluser ** FindUserPtr(name) char *name; { struct acluser **u; for (u = &users; *u; u = &(*u)->u_next) if (!strcmp((*u)->u_name, name)) break; #ifdef MULTIUSER debug3("FindUserPtr %s %sfound, id %d\n", name, (*u)?"":"not ", (*u)?(*u)->u_id:-1); #else /* MULTIUSER */ debug2("FindUserPtr %s %sfound\n", name, (*u)?"":"not "); #endif /* MULTIUSER */ return u; } int DefaultEsc = -1; /* initialised by screen.c:main() */ int DefaultMetaEsc = -1; /* * Add a new user. His password may be NULL or "" if none. His name must not * be "none", as this represents the NULL-pointer when dealing with groups. * He has default rights, determined by umask. */ int UserAdd(name, pass, up) char *name, *pass; struct acluser **up; { #ifdef MULTIUSER int j; #endif if (!up) up = FindUserPtr(name); if (*up) { if (pass) (*up)->u_password = SaveStr(pass); return 1; /* he is already there */ } if (strcmp("none", name)) /* "none" is a reserved word */ *up = (struct acluser *)calloc(1, sizeof(struct acluser)); if (!*up) return -1; /* he still does not exist */ #ifdef COPY_PASTE (*up)->u_plop.buf = NULL; (*up)->u_plop.len = 0; # ifdef ENCODINGS (*up)->u_plop.enc = 0; # endif #endif (*up)->u_Esc = DefaultEsc; (*up)->u_MetaEsc = DefaultMetaEsc; strncpy((*up)->u_name, name, MAXLOGINLEN); (*up)->u_password = NULL; if (pass) (*up)->u_password = SaveStr(pass); if (!(*up)->u_password) (*up)->u_password = NullStr; (*up)->u_detachwin = -1; (*up)->u_detachotherwin = -1; #ifdef MULTIUSER (*up)->u_group = NULL; /* now find an unused index */ for ((*up)->u_id = 0; (*up)->u_id < maxusercount; (*up)->u_id++) if (!(ACLBIT((*up)->u_id) & ACLBYTE(userbits, (*up)->u_id))) break; debug2("UserAdd %s id %d\n", name, (*up)->u_id); if ((*up)->u_id == maxusercount) { int j; struct win *w; struct acluser *u; debug2("growing all bitfields %d += %d\n", maxusercount, USER_CHUNK); /* the bitfields are full, grow a chunk */ /* first, the used_uid_indicator: */ if (GrowBitfield(&userbits, maxusercount, USER_CHUNK, 0)) { free((char *)*up); *up = NULL; return -1; } /* second, default command bits */ /* (only if we generate commands dynamically) */ /* for (j = 0; j < ACL_BITS_PER_CMD; j++) if (GrowBitfield(&default_c_userbits[j], maxusercount, USER_CHUNK, default_c_bit[j])) { free((char *)*up); *up = NULL; return -1; } */ /* third, the bits for each commands */ for (j = 0; j <= RC_LAST; j++) { int i; for (i = 0; i < ACL_BITS_PER_CMD; i++) if (GrowBitfield(&comms[j].userbits[i], maxusercount, USER_CHUNK, default_c_bit[i])) { free((char *)*up); *up = NULL; return -1; } } /* fourth, default window creation bits per user */ for (u = users; u != *up; u = u->u_next) { for (j = 0; j < ACL_BITS_PER_WIN; j++) { if (GrowBitfield(&u->u_umask_w_bits[j], maxusercount, USER_CHUNK, default_w_bit[j])) { free((char *)*up); *up = NULL; return -1; } } } /* fifth, the bits for each window */ /* keep these in sync with NewWindowAcl() */ for (w = windows; w; w = w->w_next) { /* five a: the access control list */ for (j = 0; j < ACL_BITS_PER_WIN; j++) if (GrowBitfield(&w->w_userbits[j], maxusercount, USER_CHUNK, default_w_bit[j])) { free((char *)*up); *up = NULL; return -1; } /* five b: the activity notify list */ /* five c: the silence notify list */ if (GrowBitfield(&w->w_mon_notify, maxusercount, USER_CHUNK, 0) || GrowBitfield(&w->w_lio_notify, maxusercount, USER_CHUNK, 0)) { free((char *)*up); *up = NULL; return -1; } } maxusercount += USER_CHUNK; } /* mark the user-entry as "in-use" */ ACLBYTE(userbits, (*up)->u_id) |= ACLBIT((*up)->u_id); /* user id 0 is the session creator, he has all rights */ if ((*up)->u_id == 0) AclSetPerm(NULL, *up, "+a", "#?"); /* user nobody has a fixed set of rights: */ if (!strcmp((*up)->u_name, "nobody")) { AclSetPerm(NULL, *up, "-rwx", "#?"); AclSetPerm(NULL, *up, "+x", "su"); AclSetPerm(NULL, *up, "+x", "detach"); AclSetPerm(NULL, *up, "+x", "displays"); AclSetPerm(NULL, *up, "+x", "version"); } /* * Create his umask: * Give default_w_bit's for all users, * but allow himself everything on "his" windows. */ for (j = 0; j < ACL_BITS_PER_WIN; j++) { if (GrowBitfield(&(*up)->u_umask_w_bits[j], 0, maxusercount, default_w_bit[j])) { free((char *)*up); *up = NULL; return -1; } ACLBYTE((*up)->u_umask_w_bits[j], (*up)->u_id) |= ACLBIT((*up)->u_id); } #else /* MULTIUSER */ debug1("UserAdd %s\n", name); #endif /* MULTIUSER */ return 0; } #if 0 /* change user's password */ int UserSetPass(name, pass, up) char *name, *pass; struct acluser **up; { if (!up) up = FindUserPtr(name); if (!*up) return UserAdd(name, pass, up); if (!strcmp(name, "nobody")) /* he remains without password */ return -1; strncpy((*up)->u_password, pass ? pass : "", 20); (*up)->u_password[20] = '\0'; return 0; } #endif /* * Remove a user from the list. * Destroy all his permissions and completely detach him from the session. */ int UserDel(name, up) char *name; struct acluser **up; { struct acluser *u; #ifdef MULTIUSER int i; #endif struct display *old, *next; if (!up) up = FindUserPtr(name); if (!(u = *up)) return -1; /* he who does not exist cannot be removed */ old = display; for (display = displays; display; display = next) { next = display->d_next; /* read the next ptr now, Detach may zap it. */ if (D_user != u) continue; if (display == old) old = NULL; Detach(D_REMOTE); } display = old; *up = u->u_next; #ifdef MULTIUSER for (up = &users; *up; up = &(*up)->u_next) { /* unlink all group references to this user */ struct aclusergroup **g = &(*up)->u_group; while (*g) { if ((*g)->u == u) { struct aclusergroup *next = (*g)->next; free((char *)(*g)); *g = next; } else g = &(*g)->next; } } ACLBYTE(userbits, u->u_id) &= ~ACLBIT(u->u_id); /* restore the bits in his slot to default: */ AclSetPerm(NULL, u, default_w_bit[ACL_READ] ? "+r" : "-r", "#"); AclSetPerm(NULL, u, default_w_bit[ACL_WRITE]? "+w" : "-w", "#"); AclSetPerm(NULL, u, default_w_bit[ACL_EXEC] ? "+x" : "-x", "#"); AclSetPerm(NULL, u, default_c_bit[ACL_EXEC] ? "+x" : "-x", "?"); for (i = 0; i < ACL_BITS_PER_WIN; i++) free((char *)u->u_umask_w_bits[i]); #endif /* MULTIUSER */ debug1("FREEING user structure for %s\n", u->u_name); #ifdef COPY_PASTE UserFreeCopyBuffer(u); #endif free((char *)u); if (!users) { debug("Last user deleted. Feierabend.\n"); Finit(0); /* Destroying whole session. Noone could ever attach again. */ } return 0; } #ifdef COPY_PASTE /* * returns 0 if the copy buffer was really deleted. * Also removes any references into the users copybuffer */ int UserFreeCopyBuffer(u) struct acluser *u; { struct win *w; struct paster *pa; if (!u->u_plop.buf) return 1; for (w = windows; w; w = w->w_next) { pa = &w->w_paster; if (pa->pa_pasteptr >= u->u_plop.buf && pa->pa_pasteptr - u->u_plop.buf < u->u_plop.len) FreePaster(pa); } free((char *)u->u_plop.buf); u->u_plop.len = 0; u->u_plop.buf = 0; return 0; } #endif /* COPY_PASTE */ #ifdef MULTIUSER /* * Traverses group nodes. It searches for a node that references user u. * If recursive is true, nodes found in the users are also searched using * depth first method. If none of the nodes references u, the address of * the last next pointer is returned. This address will contain NULL. */ static struct aclusergroup ** FindGroupPtr(gp, u, recursive) struct aclusergroup **gp; struct acluser *u; int recursive; { struct aclusergroup **g; ASSERT(recursive < 1000); /* Ouch, cycle detection failed */ while (*gp) { if ((*gp)->u == u) return gp; /* found him here. */ if (recursive && *(g = FindGroupPtr(&(*gp)->u->u_group, u, recursive + 1))) return g; /* found him there. */ gp = &(*gp)->next; } return gp; /* *gp is NULL */ } static int PasswordMatches(pw, password) const char *pw, *password; { if (!*password) return 0; char *buf = crypt((char *)pw, (char *)password); return (buf && !strcmp(buf, password)); } /* * Returns nonzero if failed or already linked. * Both users are created on demand. * Cyclic links are prevented. */ int AclLinkUser(from, to) char *from, *to; { struct acluser **u1, **u2; struct aclusergroup **g; if (!*(u1 = FindUserPtr(from)) && UserAdd(from, NULL, u1)) return -1; if (!*(u2 = FindUserPtr(to)) && UserAdd(to, NULL, u2)) return -1; /* hmm, could not find both users. */ if (*FindGroupPtr(&(*u2)->u_group, *u1, 1)) return 1; /* cyclic link detected! */ if (*(g = FindGroupPtr(&(*u1)->u_group, *u2, 0))) return 2; /* aha, we are already linked! */ if (!(*g = (struct aclusergroup *)malloc(sizeof(struct aclusergroup)))) return -1; /* Could not alloc link. Poor screen */ (*g)->u = (*u2); (*g)->next = NULL; return 0; } /* * The user pointer stored at *up will be substituted by a pointer * to the named user's structure, if passwords match. * returns NULL if successfull, an static error string otherwise */ char * DoSu(up, name, pw1, pw2) struct acluser **up; char *name, *pw1, *pw2; { struct acluser *u; int sorry = 0; if (!(u = *FindUserPtr(name))) sorry++; else { #ifdef CHECKLOGIN struct passwd *pp; #ifdef SHADOWPW struct spwd *ss; int t, c; #endif char *pass = ""; if (!(pp = getpwnam(name))) { debug1("getpwnam(\"%s\") failed\n", name); if (!(pw1 && *pw1 && *pw1 != '\377')) { debug("no unix account, no screen passwd\n"); sorry++; } } else pass = pp->pw_passwd; #ifdef SHADOWPW for (t = 0; t < 13; t++) { c = pass[t]; if (!(c == '.' || c == '/' || (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) break; } if (t < 13) { if (!(ss = getspnam(name))) { debug1("getspnam(\"%s\") failed\n", name); sorry++; } else pass = ss->sp_pwdp; } #endif /* SHADOWPW */ if (pw2 && *pw2 && *pw2 != '\377') /* provided a system password */ { if (!PasswordMatches(pw2, pass)) { debug("System password mismatch\n"); sorry++; } } else /* no pasword provided */ if (*pass) /* but need one */ sorry++; #endif /* CHECKLOGIN */ if (pw1 && *pw1 && *pw1 != '\377') /* provided a screen password */ { if (!PasswordMatches(pw1, u->u_password)) { debug("screen password mismatch\n"); sorry++; } } else /* no pasword provided */ if (*u->u_password) /* but need one */ sorry++; } debug2("syslog(LOG_NOTICE, \"screen %s: \"su %s\" ", SockPath, name); debug2("%s for \"%s\"\n", sorry ? "failed" : "succeeded", (*up)->u_name); #ifndef NOSYSLOG # ifdef BSD_42 openlog("screen", LOG_PID); # else openlog("screen", LOG_PID, LOG_AUTH); # endif /* BSD_42 */ syslog(LOG_NOTICE, "%s: \"su %s\" %s for \"%s\"", SockPath, name, sorry ? "failed" : "succeeded", (*up)->u_name); closelog(); #else debug("NOT LOGGED.\n"); #endif /* NOSYSLOG */ if (sorry) return "Sorry."; else *up = u; /* substitute user now */ return NULL; } #endif /* MULTIUSER */ /************************************************************************ * end of user managing code * ************************************************************************/ #ifdef MULTIUSER /* This gives the users default rights to the new window w created by u */ int NewWindowAcl(w, u) struct win *w; struct acluser *u; { int i, j; debug2("NewWindowAcl %s's umask_w_bits for window %d\n", u ? u->u_name : "everybody", w->w_number); /* keep these in sync with UserAdd part five. */ if (GrowBitfield(&w->w_mon_notify, 0, maxusercount, 0) || GrowBitfield(&w->w_lio_notify, 0, maxusercount, 0)) return -1; for (j = 0; j < ACL_BITS_PER_WIN; j++) { /* we start with len 0 for the new bitfield size and add maxusercount */ if (GrowBitfield(&w->w_userbits[j], 0, maxusercount, 0)) { while (--j >= 0) free((char *)w->w_userbits[j]); free((char *)w->w_mon_notify); free((char *)w->w_lio_notify); return -1; } for (i = 0; i < maxusercount; i++) if (u ? (ACLBIT(i) & ACLBYTE(u->u_umask_w_bits[j], i)) : default_w_bit[j]) ACLBYTE(w->w_userbits[j], i) |= ACLBIT(i); } return 0; } void FreeWindowAcl(w) struct win *w; { int i; for (i = 0; i < ACL_BITS_PER_WIN; i++) free((char *)w->w_userbits[i]); free((char *)w->w_mon_notify); free((char *)w->w_lio_notify); } /* if mode starts with '-' we remove the users exec bit for cmd */ /* * NOTE: before you make this function look the same as * AclSetPermWin, try to merge both functions. */ static int AclSetPermCmd(u, mode, cmd) struct acluser *u; char *mode; struct comm *cmd; { int neg = 0; char *m = mode; while (*m) { switch (*m++) { case '-': neg = 1; continue; case '+': neg = 0; continue; case 'a': case 'e': case 'x': /* debug3("AclSetPermCmd %s %s %s\n", u->u_name, mode, cmd->name); */ if (neg) ACLBYTE(cmd->userbits[ACL_EXEC], u->u_id) &= ~ACLBIT(u->u_id); else ACLBYTE(cmd->userbits[ACL_EXEC], u->u_id) |= ACLBIT(u->u_id); break; case 'r': case 'w': break; default: return -1; } } return 0; } /* mode strings of the form +rwx -w+rx r -wx are parsed and evaluated */ /* * aclchg nerd -w+w 2 * releases a writelock on window 2 held by user nerd. * Letter n allows network access on a window. * uu should be NULL, except if you want to change his umask. */ static int AclSetPermWin(uu, u, mode, win) struct acluser *u, *uu; char *mode; struct win *win; { int neg = 0; int bit, bits; AclBits *bitarray; char *m = mode; if (uu) { debug3("AclSetPermWin %s UMASK %s %s\n", uu->u_name, u->u_name, mode); bitarray = uu->u_umask_w_bits; } else { ASSERT(win); bitarray = win->w_userbits; debug3("AclSetPermWin %s %s %d\n", u->u_name, mode, win->w_number); } while (*m) { switch (*m++) { case '-': neg = 1; continue; case '+': neg = 0; continue; case 'r': bits = (1 << ACL_READ); break; case 'w': bits = (1 << ACL_WRITE); break; case 'x': bits = (1 << ACL_EXEC); break; case 'a': bits = (1 << ACL_BITS_PER_WIN) - 1; break; default: return -1; } for (bit = 0; bit < ACL_BITS_PER_WIN; bit++) { if (!(bits & (1 << bit))) continue; if (neg) ACLBYTE(bitarray[bit], u->u_id) &= ~ACLBIT(u->u_id); else ACLBYTE(bitarray[bit], u->u_id) |= ACLBIT(u->u_id); if (!uu && (win->w_wlockuser == u) && neg && (bit == ACL_WRITE)) { debug2("%s lost writelock on win %d\n", u->u_name, win->w_number); win->w_wlockuser = NULL; if (win->w_wlock == WLOCK_ON) win->w_wlock = WLOCK_AUTO; } } } if (uu && u->u_name[0] == '?' && u->u_name[1] == '\0') { /* * It is Mr. '?', the unknown user. He deserves special treatment as * he defines the defaults. Sorry, this is global, not per user. */ if (win) { debug1("AclSetPermWin: default_w_bits '%s'.\n", mode); for (bit = 0; bit < ACL_BITS_PER_WIN; bit++) default_w_bit[bit] = (ACLBYTE(bitarray[bit], u->u_id) & ACLBIT(u->u_id)) ? 1 : 0; } else { /* * Hack. I do not want to duplicate all the above code for * AclSetPermCmd. This asumes that there are not more bits * per cmd than per win. */ debug1("AclSetPermWin: default_c_bits '%s'.\n", mode); for (bit = 0; bit < ACL_BITS_PER_CMD; bit++) default_c_bit[bit] = (ACLBYTE(bitarray[bit], u->u_id) & ACLBIT(u->u_id)) ? 1 : 0; } UserDel(u->u_name, NULL); } return 0; } /* * String is broken down into comand and window names, mode applies * A command name matches first, so do not use these as window names. * uu should be NULL, except if you want to change his umask. */ int AclSetPerm(uu, u, mode, s) struct acluser *uu, *u; char *mode, *s; { struct win *w; int i; char *p, ch; debug3("AclSetPerm(uu, user '%s', mode '%s', object '%s')\n", u->u_name, mode, s); while (*s) { switch (*s) { case '*': /* all windows and all commands */ return AclSetPerm(uu, u, mode, "#?"); case '#': if (uu) /* window umask or .. */ AclSetPermWin(uu, u, mode, (struct win *)1); else /* .. or all windows */ for (w = windows; w; w = w->w_next) AclSetPermWin((struct acluser *)0, u, mode, w); s++; break; case '?': if (uu) /* command umask or .. */ AclSetPermWin(uu, u, mode, (struct win *)0); else /* .. or all commands */ for (i = 0; i <= RC_LAST; i++) AclSetPermCmd(u, mode, &comms[i]); s++; break; default: for (p = s; *p && *p != ' ' && *p != '\t' && *p != ','; p++) ; if ((ch = *p)) *p++ = '\0'; if ((i = FindCommnr(s)) != RC_ILLEGAL) AclSetPermCmd(u, mode, &comms[i]); else if (((i = WindowByNoN(s)) >= 0) && wtab[i]) AclSetPermWin((struct acluser *)0, u, mode, wtab[i]); else /* checking group name */ return -1; if (ch) p[-1] = ch; s = p; } } return 0; } /* * Generic ACL Manager: * * This handles acladd and aclchg identical. * With 2 or 4 parameters, the second parameter is a password. * With 3 or 4 parameters the last two parameters specify the permissions * else user is added with full permissions. * With 1 parameter the users permissions are copied from user *argv. * Unlike the other cases, u->u_name should not match *argv here. * uu should be NULL, except if you want to change his umask. */ static int UserAcl(uu, u, argc, argv) struct acluser *uu, **u; int argc; char **argv; { if ((*u && !strcmp((*u)->u_name, "nobody")) || (argc > 1 && !strcmp(argv[0], "nobody"))) return -1; /* do not change nobody! */ switch (argc) { case 1+1+2: debug2("UserAcl: user '%s', password '%s':", argv[0], argv[1]); return (UserAdd(argv[0], argv[1], u) < 0) || AclSetPerm(uu, *u, argv[2], argv[3]); case 1+2: debug1("UserAcl: user '%s', no password:", argv[0]); return (UserAdd(argv[0], NULL, u) < 0) || AclSetPerm(uu, *u, argv[1], argv[2]); case 1+1: debug2("UserAcl: user '%s', password '%s'\n", argv[0], argv[1]); return UserAdd(argv[0], argv[1], u) < 0; case 1: debug1("UserAcl: user '%s', no password:", argv[0]); return (UserAdd(argv[0], NULL, u) < 0) || AclSetPerm(uu, *u, "+a", "#?"); default: return -1; } } static int UserAclCopy(to_up, from_up) struct acluser **to_up, **from_up; { struct win *w; int i, j, to_id, from_id; if (!*to_up || !*from_up) return -1; debug2("UserAclCopy: from user '%s' to user '%s'\n", (*from_up)->u_name, (*to_up)->u_name); if ((to_id = (*to_up)->u_id) == (from_id = (*from_up)->u_id)) return -1; for (w = windows; w; w = w->w_next) { for (i = 0; i < ACL_BITS_PER_WIN; i++) { if (ACLBYTE(w->w_userbits[i], from_id) & ACLBIT(from_id)) ACLBYTE(w->w_userbits[i], to_id) |= ACLBIT(to_id); else { ACLBYTE(w->w_userbits[i], to_id) &= ~ACLBIT(to_id); if ((w->w_wlockuser == *to_up) && (i == ACL_WRITE)) { debug2("%s lost wlock on win %d\n", (*to_up)->u_name, w->w_number); w->w_wlockuser = NULL; if (w->w_wlock == WLOCK_ON) w->w_wlock = WLOCK_AUTO; } } } } for (j = 0; j <= RC_LAST; j++) { for (i = 0; i < ACL_BITS_PER_CMD; i++) { if (ACLBYTE(comms[j].userbits[i], from_id) & ACLBIT(from_id)) ACLBYTE(comms[j].userbits[i], to_id) |= ACLBIT(to_id); else ACLBYTE(comms[j].userbits[i], to_id) &= ~ACLBIT(to_id); } } return 0; } /* * Syntax: * user [password] [+rwx #?] * * [password] [+rwx #?] * user1,user2,user3 [password] [+rwx #?] * user1,user2,user3=user * uu should be NULL, except if you want to change his umask. */ int UsersAcl(uu, argc, argv) struct acluser *uu; int argc; char **argv; { char *s; int r; struct acluser **cf_u = NULL; if (argc == 1) { char *p = NULL; s = argv[0]; while (*s) if (*s++ == '=') p = s; if (p) { p[-1] = '\0'; cf_u = FindUserPtr(p); } } if (argv[0][0] == '*' && argv[0][1] == '\0') { struct acluser **u; debug("all users acls.\n"); for (u = &users; *u; u = &(*u)->u_next) if (strcmp("nobody", (*u)->u_name) && ((cf_u) ? ((r = UserAclCopy(u, cf_u)) < 0) : ((r = UserAcl(uu, u, argc, argv)) < 0))) return -1; return 0; } do { for (s = argv[0]; *s && *s!=' ' && *s!='\t' && *s!=',' && *s!='='; s++) ; *s ? (*s++ = '\0') : (*s = '\0'); debug2("UsersAcl(uu, \"%s\", argc=%d)\n", argv[0], argc); if ((cf_u) ? ((r = UserAclCopy(FindUserPtr(argv[0]), cf_u)) < 0) : ((r = UserAcl(uu, FindUserPtr(argv[0]), argc, argv)) < 0)) return -1; } while (*(argv[0] = s)); return 0; } /* * Preprocess argments, so that umask can be set with UsersAcl * * all current users umask rwxn * one specific user umask user1rwxn * several users umask user1,user2,...rwxn * default_w_bits umask ?rwxn * default_c_bits umask ??rwxn */ int AclUmask(u, str, errp) struct acluser *u; char *str; char **errp; { char mode[16]; char *av[3]; char *p, c = '\0'; /* split str into user and bits section. */ for (p = str; *p; p++) if ((c = *p) == '+' || c == '-') break; if (!*p) { *errp = "Bad argument. Should be ``[user[,user...]{+|-}rwxn''."; return -1; } strncpy(mode, p, 15); mode[15] = '\0'; *p = '\0'; /* construct argument vector */ if (!strcmp("??", str)) { str++; av[2] = "?"; } else av[2] = "#"; av[1] = mode; av[0] = *str ? str : "*"; /* call UsersAcl */ if (UsersAcl(u, 3, av)) { *errp = "UsersAcl failed. Hmmm."; *p = c; return -1; } *p = c; return 0; } void AclWinSwap(a, b) int a, b; { debug2("AclWinSwap(%d, %d) NOP.\n", a, b); } struct acluser *EffectiveAclUser = NULL; /* hook for AT command permission */ int AclCheckPermWin(u, mode, w) struct acluser *u; int mode; struct win *w; { int ok; if (mode < 0 || mode >= ACL_BITS_PER_WIN) return -1; if (EffectiveAclUser) { debug1("AclCheckPermWin: WARNING user %s overridden!\n", u->u_name); u = EffectiveAclUser; } ok = ACLBYTE(w->w_userbits[mode], u->u_id) & ACLBIT(u->u_id); debug3("AclCheckPermWin(%s, %d, %d) = ", u->u_name, mode, w->w_number); if (!ok) { struct aclusergroup **g = &u->u_group; struct acluser *saved_eff = EffectiveAclUser; EffectiveAclUser = NULL; while (*g) { if (!AclCheckPermWin((*g)->u, mode, w)) break; g = &(*g)->next; } EffectiveAclUser = saved_eff; if (*g) ok = 1; } debug1("%d\n", !ok); return !ok; } int AclCheckPermCmd(u, mode, c) struct acluser *u; int mode; struct comm *c; { int ok; if (mode < 0 || mode >= ACL_BITS_PER_CMD) return -1; if (EffectiveAclUser) { debug1("AclCheckPermCmd: WARNING user %s overridden!\n", u->u_name); u = EffectiveAclUser; } ok = ACLBYTE(c->userbits[mode], u->u_id) & ACLBIT(u->u_id); debug3("AclCheckPermCmd(%s %d %s) = ", u->u_name, mode, c->name); if (!ok) { struct aclusergroup **g = &u->u_group; struct acluser *saved_eff = EffectiveAclUser; EffectiveAclUser = NULL; while (*g) { if (!AclCheckPermCmd((*g)->u, mode, c)) break; g = &(*g)->next; } EffectiveAclUser = saved_eff; if (*g) ok = 1; } debug1("%d\n", !ok); return !ok; } #endif /* MULTIUSER */ screen-4.8.0/fileio.c0000644000175000017500000004710013616620402013317 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include #include #include #include #ifndef SIGINT # include #endif #include "config.h" #include "screen.h" #include "extern.h" extern struct display *display, *displays; extern struct win *fore; extern struct layer *flayer; extern int ServerSocket; extern int real_uid, eff_uid; extern int real_gid, eff_gid; extern char *extra_incap, *extra_outcap; extern char *home, *RcFileName; extern char SockPath[], *SockName; #ifdef COPY_PASTE extern char *BufferFile; #endif extern int hardcopy_append; extern char *hardcopydir; static char *CatExtra __P((char *, char *)); static char *findrcfile __P((char *)); char *rc_name = ""; int rc_recursion = 0; static char * CatExtra(register char *str1, register char *str2) { register char *cp; register int len1, len2, add_colon; len1 = strlen(str1); if (len1 == 0) return str2; add_colon = (str1[len1 - 1] != ':'); if (str2) { len2 = strlen(str2); if ((cp = realloc(str2, (unsigned) len1 + len2 + add_colon + 1)) == NULL) Panic(0, "%s", strnomem); bcopy(cp, cp + len1 + add_colon, len2 + 1); } else { if ((cp = malloc((unsigned) len1 + add_colon + 1)) == NULL) Panic(0, "%s", strnomem); cp[len1 + add_colon] = '\0'; } bcopy(str1, cp, len1); if (add_colon) cp[len1] = ':'; return cp; } static char *findrcfile(char *rcfile) { char buf[256]; char *p; /* Tilde prefix support courtesy , * taken from a Debian patch. */ if (rcfile && *rcfile == '~') { static char rcfilename_tilde_exp[MAXPATHLEN+1]; char *slash_position = strchr(rcfile, '/'); if (slash_position == rcfile+1) { char *home = getenv("HOME"); if (!home) { Msg(0, "%s: source: tilde expansion failed", rc_name); return NULL; } snprintf(rcfilename_tilde_exp, MAXPATHLEN, "%s/%s", home, rcfile+2); } else if (slash_position) { struct passwd *p; *slash_position = 0; p = getpwnam(rcfile+1); if (!p){ Msg(0, "%s: source: tilde expansion failed for user %s", rc_name, rcfile+1); return NULL; } snprintf(rcfilename_tilde_exp, MAXPATHLEN, "%s/%s", p->pw_dir, slash_position+1); } else { Msg(0, "%s: source: illegal tilde expression.", rc_name); return NULL; } rcfile = rcfilename_tilde_exp; } if (rcfile) { char *rcend = rindex(rc_name, '/'); if (*rcfile != '/' && rcend && (rcend - rc_name) + strlen(rcfile) + 2 < sizeof(buf)) { strncpy(buf, rc_name, rcend - rc_name + 1); strcpy(buf + (rcend - rc_name) + 1, rcfile); if (access(buf, R_OK) == 0) return SaveStr(buf); } debug1("findrcfile: you specified '%s'\n", rcfile); return SaveStr(rcfile); } debug("findrcfile: you specified nothing...\n"); if ((p = getenv("SCREENRC")) != NULL && *p != '\0') { debug1(" $SCREENRC has: '%s'\n", p); return SaveStr(p); } else { debug(" ...nothing in $SCREENRC, defaulting $HOME/.screenrc\n"); if (strlen(home) > sizeof(buf) - 12) Panic(0, "Rc: home too large"); sprintf(buf, "%s/.screenrc", home); return SaveStr(buf); } } /* * this will be called twice: * 1) rcfilename = "/etc/screenrc" * 2) rcfilename = RcFileName */ int StartRc(char *rcfilename, int nopanic) { register int argc, len; register char *p, *cp; char buf[2048]; char *args[MAXARGS]; int argl[MAXARGS]; FILE *fp; char *oldrc_name = rc_name; /* always fix termcap/info capabilities */ extra_incap = CatExtra("TF", extra_incap); /* Special settings for vt100 and others */ if (display && (!strncmp(D_termname, "vt", 2) || !strncmp(D_termname, "xterm", 5))) extra_incap = CatExtra("xn:f0=\033Op:f1=\033Oq:f2=\033Or:f3=\033Os:f4=\033Ot:f5=\033Ou:f6=\033Ov:f7=\033Ow:f8=\033Ox:f9=\033Oy:f.=\033On:f,=\033Ol:fe=\033OM:f+=\033Ok:f-=\033Om:f*=\033Oj:f/=\033Oo:fq=\033OX", extra_incap); rc_name = findrcfile(rcfilename); if (rc_name == NULL || (fp = secfopen(rc_name, "r")) == NULL) { const char *rc_nonnull = rc_name ? rc_name : rcfilename; if (!rc_recursion && RcFileName && !strcmp(RcFileName, rc_nonnull)) { /* * User explicitly gave us that name, * this is the only case, where we get angry, if we can't read * the file. */ debug3("StartRc: '%s','%s', '%s'\n", RcFileName, rc_name ? rc_name : "(null)", rcfilename); if (!nopanic) Panic(0, "Unable to open \"%s\".", rc_nonnull); /* possibly NOTREACHED */ } debug1("StartRc: '%s' no good. ignored\n", rc_nonnull); if (rc_name) Free(rc_name); rc_name = oldrc_name; return 1; } while (fgets(buf, sizeof buf, fp) != NULL) { if ((p = rindex(buf, '\n')) != NULL) *p = '\0'; if ((argc = Parse(buf, sizeof buf, args, argl)) == 0) continue; if (strcmp(args[0], "echo") == 0) { if (!display) continue; if (argc < 2 || (argc == 3 && strcmp(args[1], "-n")) || argc > 3) { Msg(0, "%s: 'echo [-n] \"string\"' expected.", rc_name); continue; } AddStr(args[argc - 1]); if (argc != 3) { AddStr("\r\n"); Flush(0); } } else if (strcmp(args[0], "sleep") == 0) { if (!display) continue; debug("sleeeeeeep\n"); if (argc != 2) { Msg(0, "%s: sleep: one numeric argument expected.", rc_name); continue; } DisplaySleep1000(1000 * atoi(args[1]), 1); } #ifdef TERMINFO else if (!strcmp(args[0], "termcapinfo") || !strcmp(args[0], "terminfo")) { #else else if (!strcmp(args[0], "termcapinfo") || !strcmp(args[0], "termcap")) { #endif if (!display) continue; if (argc < 3 || argc > 4) { Msg(0, "%s: %s: incorrect number of arguments.", rc_name, args[0]); continue; } for (p = args[1]; p && *p; p = cp) { if ((cp = index(p, '|')) != 0) *cp++ = '\0'; len = strlen(p); if (p[len - 1] == '*') { if (!(len - 1) || !strncmp(p, D_termname, len - 1)) break; } else if (!strcmp(p, D_termname)) break; } if (!(p && *p)) continue; extra_incap = CatExtra(args[2], extra_incap); if (argc == 4) extra_outcap = CatExtra(args[3], extra_outcap); } else if (!strcmp(args[0], "source")) { if (rc_recursion <= 10) { rc_recursion++; (void)StartRc(args[1], 0); rc_recursion--; } } } fclose(fp); Free(rc_name); rc_name = oldrc_name; return 0; } void FinishRc(char *rcfilename) { char buf[2048]; FILE *fp; char *oldrc_name = rc_name; rc_name = findrcfile(rcfilename); if (rc_name == NULL || (fp = secfopen(rc_name, "r")) == NULL) { const char *rc_nonnull = rc_name ? rc_name : rcfilename; if (rc_recursion) Msg(errno, "%s: source %s", oldrc_name, rc_nonnull); else if (RcFileName && !strcmp(RcFileName, rc_nonnull)) { /* * User explicitly gave us that name, * this is the only case, where we get angry, if we can't read * the file. */ debug3("FinishRc:'%s','%s','%s'\n", RcFileName, rc_name ? rc_name : "(null)", rcfilename); Panic(0, "Unable to open \"%s\".", rc_nonnull); /* NOTREACHED */ } debug1("FinishRc: '%s' no good. ignored\n", rc_nonnull); if (rc_name) Free(rc_name); rc_name = oldrc_name; return; } debug("finishrc is going...\n"); while (fgets(buf, sizeof buf, fp) != NULL) RcLine(buf, sizeof buf); (void) fclose(fp); Free(rc_name); rc_name = oldrc_name; } void do_source(char *rcfilename) { if (rc_recursion > 10) { Msg(0, "%s: source: recursion limit reached", rc_name); return; } rc_recursion++; FinishRc(rcfilename); rc_recursion--; } /* * Running a Command Line in the environment determined by the display. * The fore window is taken from the display as well as the user. * This is bad when we run detached. */ void RcLine(char *ubuf, int ubufl) { char *args[MAXARGS]; int argl[MAXARGS]; #ifdef MULTIUSER extern struct acluser *EffectiveAclUser; /* acl.c */ extern struct acluser *users; /* acl.c */ #endif if (display) { fore = D_fore; flayer = D_forecv->c_layer; } else flayer = fore ? fore->w_savelayer : 0; if (Parse(ubuf, ubufl, args, argl) <= 0) return; #ifdef MULTIUSER if (!display) { /* the session owner does it, when there is no display here */ EffectiveAclUser = users; debug("RcLine: WARNING, no display no user! Session owner executes command\n"); } #endif DoCommand(args, argl); #ifdef MULTIUSER EffectiveAclUser = 0; #endif } /* needs display for copybuffer access and termcap dumping */ void WriteFile(struct acluser *user, char *fn, int dump) { /* dump==0: create .termcap, * dump==1: hardcopy, * #ifdef COPY_PASTE * dump==2: BUFFERFILE * #endif COPY_PASTE * dump==1: scrollback, */ register int i, j, k; register char *p; register FILE *f; char fnbuf[1024]; char *mode = "w"; #ifdef COPY_PASTE int public = 0; # ifdef HAVE_LSTAT struct stat stb, stb2; int fd, exists = 0; # endif #endif switch (dump) { case DUMP_TERMCAP: if (fn == 0) { i = SockName - SockPath; if (i > (int)sizeof(fnbuf) - 9) i = 0; strncpy(fnbuf, SockPath, i); strcpy(fnbuf + i, ".termcap"); fn = fnbuf; } break; case DUMP_HARDCOPY: case DUMP_SCROLLBACK: if (fn == 0) { if (fore == 0) return; if (hardcopydir && *hardcopydir && strlen(hardcopydir) < sizeof(fnbuf) - 21) sprintf(fnbuf, "%s/hardcopy.%d", hardcopydir, fore->w_number); else sprintf(fnbuf, "hardcopy.%d", fore->w_number); fn = fnbuf; } if (hardcopy_append && !access(fn, W_OK)) mode = "a"; break; #ifdef COPY_PASTE case DUMP_EXCHANGE: if (fn == 0) { strncpy(fnbuf, BufferFile, sizeof(fnbuf) - 1); fnbuf[sizeof(fnbuf) - 1] = 0; fn = fnbuf; } public = !strcmp(fn, DEFAULT_BUFFERFILE); # ifdef HAVE_LSTAT exists = !lstat(fn, &stb); if (public && exists && (S_ISLNK(stb.st_mode) || stb.st_nlink > 1)) { Msg(0, "No write to links, please."); return; } # endif break; #endif } debug2("WriteFile(%d) %s\n", dump, fn); if (UserContext() > 0) { debug("Writefile: usercontext\n"); #ifdef COPY_PASTE if (dump == DUMP_EXCHANGE && public) { # ifdef HAVE_LSTAT if (exists) { if ((fd = open(fn, O_WRONLY, 0666)) >= 0) { if (fstat(fd, &stb2) == 0 && stb.st_dev == stb2.st_dev && stb.st_ino == stb2.st_ino) ftruncate(fd, 0); else { close(fd); fd = -1; } } } else fd = open(fn, O_WRONLY|O_CREAT|O_EXCL, 0666); f = fd >= 0 ? fdopen(fd, mode) : 0; # else f = fopen(fn, mode); # endif } else #endif /* COPY_PASTE */ f = fopen(fn, mode); if (f == NULL) { debug2("WriteFile: fopen(%s,\"%s\") failed\n", fn, mode); UserReturn(0); } else { switch (dump) { case DUMP_HARDCOPY: case DUMP_SCROLLBACK: if (!fore) break; if (*mode == 'a') { putc('>', f); for (j = fore->w_width - 2; j > 0; j--) putc('=', f); fputs("<\n", f); } if (dump == DUMP_SCROLLBACK) { #ifdef COPY_PASTE for (i = fore->w_histheight - fore->w_scrollback_height; i < fore->w_histheight; i++) { p = (char *)(WIN(i)->image); for (k = fore->w_width - 1; k >= 0 && p[k] == ' '; k--) ; for (j = 0; j <= k; j++) putc(p[j], f); putc('\n', f); } #endif } for (i = 0; i < fore->w_height; i++) { p = (char *)fore->w_mlines[i].image; for (k = fore->w_width - 1; k >= 0 && p[k] == ' '; k--) ; for (j = 0; j <= k; j++) putc(p[j], f); putc('\n', f); } break; case DUMP_TERMCAP: DumpTermcap(fore->w_aflag, f); break; #ifdef COPY_PASTE case DUMP_EXCHANGE: p = user->u_plop.buf; for (i = user->u_plop.len; i-- > 0; p++) if (*p == '\r' && (i == 0 || p[1] != '\n')) putc('\n', f); else putc(*p, f); break; #endif } (void) fclose(f); UserReturn(1); } } if (UserStatus() <= 0) Msg(0, "Cannot open \"%s\"", fn); else if (display && !*rc_name) { switch (dump) { case DUMP_TERMCAP: Msg(0, "Termcap entry written to \"%s\".", fn); break; case DUMP_HARDCOPY: case DUMP_SCROLLBACK: Msg(0, "Screen image %s to \"%s\".", (*mode == 'a') ? "appended" : "written", fn); break; #ifdef COPY_PASTE case DUMP_EXCHANGE: Msg(0, "Copybuffer written to \"%s\".", fn); #endif } } } #ifdef COPY_PASTE /* * returns an allocated buffer which holds a copy of the file named fn. * lenp (if nonzero) points to a location, where the buffer size should be * stored. */ char *ReadFile(char *fn, int *lenp) { int i, l, size; char c, *bp, *buf; struct stat stb; ASSERT(lenp); debug1("ReadFile(%s)\n", fn); if ((i = secopen(fn, O_RDONLY, 0)) < 0) { Msg(errno, "no %s -- no slurp", fn); return NULL; } if (fstat(i, &stb)) { Msg(errno, "no good %s -- no slurp", fn); close(i); return NULL; } size = stb.st_size; if ((buf = malloc(size)) == NULL) { close(i); Msg(0, "%s", strnomem); return NULL; } errno = 0; if ((l = read(i, buf, size)) != size) { if (l < 0) l = 0; Msg(errno, "Got only %d bytes from %s", l, fn); } else { if (read(i, &c, 1) > 0) Msg(0, "Slurped only %d characters (of %d) into buffer - try again", l, size); else Msg(0, "Slurped %d characters into buffer", l); } close(i); *lenp = l; for (bp = buf; l-- > 0; bp++) if (*bp == '\n' && (bp == buf || bp[-1] != '\r')) *bp = '\r'; return buf; } void KillBuffers() { if (UserContext() > 0) UserReturn(unlink(BufferFile) ? errno : 0); errno = UserStatus(); Msg(errno, "%s %sremoved", BufferFile, errno ? "not " : ""); } #endif /* COPY_PASTE */ /* (Almost) secure open and fopen... */ FILE *secfopen(char *name, char *mode) { FILE *fi; #ifndef USE_SETEUID int flags, fd; #endif debug2("secfopen(%s, %s)\n", name, mode); #ifdef USE_SETEUID xseteuid(real_uid); xsetegid(real_gid); fi = fopen(name, mode); xseteuid(eff_uid); xsetegid(eff_gid); return fi; #else if (eff_uid == real_uid) return fopen(name, mode); if (mode[0] && mode[1] == '+') flags = O_RDWR; else flags = (mode[0] == 'r') ? O_RDONLY : O_WRONLY; if (mode[0] == 'w') flags |= O_CREAT | O_TRUNC; else if (mode[0] == 'a') flags |= O_CREAT | O_APPEND; else if (mode[0] != 'r') { errno = EINVAL; return 0; } if ((fd = secopen(name, flags, 0666)) < 0) return 0; if ((fi = fdopen(fd, mode)) == 0) { close(fd); return 0; } return fi; #endif } int secopen(char *name, int flags, int mode) { int fd; #ifndef USE_SETEUID int q; struct stat stb; #endif debug3("secopen(%s, 0x%x, 0%03o)\n", name, flags, mode); #ifdef USE_SETEUID xseteuid(real_uid); xsetegid(real_gid); fd = open(name, flags, mode); xseteuid(eff_uid); xsetegid(eff_gid); return fd; #else if (eff_uid == real_uid) return open(name, flags, mode); /* Truncation/creation is done in UserContext */ if ((flags & O_TRUNC) || ((flags & O_CREAT) && access(name, F_OK))) { if (UserContext() > 0) { if ((fd = open(name, flags, mode)) >= 0) { close(fd); UserReturn(0); } if (errno == 0) errno = EACCES; UserReturn(errno); } if ((q = UserStatus())) { if (q > 0) errno = q; return -1; } } if (access(name, F_OK)) return -1; if ((fd = open(name, flags & ~(O_TRUNC | O_CREAT), 0)) < 0) return -1; debug("open successful\n"); if (fstat(fd, &stb)) { close(fd); return -1; } debug("fstat successful\n"); if (stb.st_uid != real_uid) { switch (flags & (O_RDONLY | O_WRONLY | O_RDWR)) { case O_RDONLY: q = 0004; break; case O_WRONLY: q = 0002; break; default: q = 0006; break; } if ((stb.st_mode & q) != q) { debug1("secopen: permission denied (%03o)\n", stb.st_mode & 07777); close(fd); errno = EACCES; return -1; } } debug1("secopen ok - returning %d\n", fd); return fd; #endif } int printpipe(struct win *p, char *cmd) { int pi[2]; if (pipe(pi)) { WMsg(p, errno, "printing pipe"); return -1; } switch (fork()) { case -1: WMsg(p, errno, "printing fork"); return -1; case 0: display = p->w_pdisplay; displays = 0; ServerSocket = -1; #ifdef DEBUG if (dfp && dfp != stderr) fclose(dfp); #endif close(0); dup(pi[0]); closeallfiles(0); if (setgid(real_gid) || setuid(real_uid)) Panic(errno, "printpipe setuid"); eff_uid = real_uid; eff_gid = real_gid; #ifdef SIGPIPE signal(SIGPIPE, SIG_DFL); #endif execl("/bin/sh", "sh", "-c", cmd, (char *)0); Panic(errno, "/bin/sh"); default: break; } close(pi[0]); return pi[1]; } int readpipe(char **cmdv) { int pi[2]; if (pipe(pi)) { Msg(errno, "pipe"); return -1; } switch (fork()) { case -1: Msg(errno, "fork"); return -1; case 0: displays = 0; ServerSocket = -1; #ifdef DEBUG if (dfp && dfp != stderr) fclose(dfp); #endif close(1); if (dup(pi[1]) != 1) { close(pi[1]); Panic(0, "dup"); } closeallfiles(1); if (setgid(real_gid) || setuid(real_uid)) { close(1); Panic(errno, "setuid/setgid"); } eff_uid = real_uid; eff_gid = real_gid; #ifdef SIGPIPE signal(SIGPIPE, SIG_DFL); #endif execvp(*cmdv, cmdv); close(1); Panic(errno, "%s", *cmdv); default: break; } close(pi[1]); return pi[0]; } screen-4.8.0/HACKING0000644000175000017500000000343013607701732012677 0ustar amadeamadeWIP notes on hacking the Screen source. * Screen commands are handled by the DoAction function in process.c. The local variable nr is set to an integer value representing the command to be evaluated; for every command `foo', there is an integer value RC_FOO for use as nr's value to represent it. Find the matching case label to follow procesing of the command. The RC_FOO values are defined in comm.h, which is automatically generated by comm.sh, based on the names of the commands themselves (found in comm.c). * The current display is held in the global variable "display". Variable names like D_foo are shorthands for display->d_foo (where d_foo is a member of "struct display"). * Names like D_IS, D_TI, D_SG usually refer to the values of various termcap features of the current display. These are found in term.h, which is automatically generated from term.c by term.sh. * The main input-reading function for handling user input from a display, is disp_readev_fn in display.c. This also handles automatic transformation of mouse-tracking codes from display coordinates to screen-window coordinates, and decodes characters from the display's encoding, passing it on to the foreground input processor. Input is passed through ProcessInput in process.c to handle keybindings (specified by bindkey and such), and then processed by layer-specific input-processing functions, which you'll find in instances of struct LayFuncs. For instance, keystrokes are processed by: normal windows: WinPrGocess window in copy-mode: MarkProcess window list: WListProcess command input line: InpProcess * Handling string escapes (in hardstatus and the like), such as %w or %{= bw}, is done in screen.c, MakeWinMsgEv(). screen-4.8.0/comm.sh0000644000175000017500000000404013616620402013167 0ustar amadeamade#! /bin/sh if test -z "$AWK"; then AWK=awk fi if test -z "$CC"; then CC=cc fi if test -z "$srcdir"; then srcdir=. fi LC_ALL=C export LC_ALL rm -f comm.h cat << EOF > comm.h /* * This file is automagically created from comm.c -- DO NOT EDIT */ struct comm { char *name; int flags; #ifdef MULTIUSER AclBits userbits[ACL_BITS_PER_CMD]; #endif }; #define ARGS_MASK (3) #define ARGS_0 (0) #define ARGS_1 (1) #define ARGS_2 (2) #define ARGS_3 (3) #define ARGS_PLUS1 (1<<2) #define ARGS_PLUS2 (1<<3) #define ARGS_PLUS3 (1<<4) #define ARGS_ORMORE (1<<5) #define NEED_FORE (1<<6) /* this command needs a fore window */ #define NEED_DISPLAY (1<<7) /* this command needs a display */ #define NEED_LAYER (1<<8) /* this command needs a layer */ #define CAN_QUERY (1<<9) /* this command can be queried, i.e. used with -Q to get back a result to stdout */ #define ARGS_01 (ARGS_0 | ARGS_PLUS1) #define ARGS_02 (ARGS_0 | ARGS_PLUS2) #define ARGS_12 (ARGS_1 | ARGS_PLUS1) #define ARGS_23 (ARGS_2 | ARGS_PLUS1) #define ARGS_24 (ARGS_2 | ARGS_PLUS2) #define ARGS_34 (ARGS_3 | ARGS_PLUS1) #define ARGS_012 (ARGS_0 | ARGS_PLUS1 | ARGS_PLUS2) #define ARGS_0123 (ARGS_0 | ARGS_PLUS1 | ARGS_PLUS2 | ARGS_PLUS3) #define ARGS_123 (ARGS_1 | ARGS_PLUS1 | ARGS_PLUS2) #define ARGS_124 (ARGS_1 | ARGS_PLUS1 | ARGS_PLUS3) #define ARGS_1234 (ARGS_1 | ARGS_PLUS1 | ARGS_PLUS2 | ARGS_PLUS3) struct action { int nr; char **args; int *argl; int quiet; /* Suppress (currently unused) 0x01 - Error message 0x02 - Normal message */ }; #define RC_ILLEGAL -1 EOF $AWK < ${srcdir}/comm.c >> comm.h ' /^ [{] ".*/ { if (old > $2) { printf("***ERROR: %s <= %s !!!\n\n", $2, old); exit 1; } old = $2; } ' $CC -E -I. -I${srcdir} ${srcdir}/comm.c > comm.cpp sed < comm.cpp \ -n \ -e '/^ *{ "/y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ -e '/^ *{ "/s/^ *{ "\([^"]*\)".*/\1/p' \ | $AWK ' /.*/ { printf "#define RC_%s %d\n",$0,i++; } END { printf "\n#define RC_LAST %d\n",i-1; } ' >> comm.h chmod a-w comm.h rm -f comm.cpp screen-4.8.0/TODO0000644000175000017500000000035713607701732012405 0ustar amadeamade- display size adaption (Activate) - process.c cleanup via comm splitting - writelocks? - partial? - type into several windows at once (for cluster admins) - configurable digraph table - command line options should overwrite config files. screen-4.8.0/utmp.c0000644000175000017500000004572513616620402013050 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include #include #include #include "config.h" #include "screen.h" #include "extern.h" #ifdef HAVE_UTEMPTER #include #endif extern struct display *display; #ifdef CAREFULUTMP extern struct win *windows; #endif extern struct win *fore; extern char *LoginName; extern int real_uid, eff_uid; /* * UTNOKEEP: A (ugly) hack for apollo that does two things: * 1) Always close and reopen the utmp file descriptor. (I don't know * for what reason this is done...) * 2) Implement an unsorted utmp file much like GETUTENT. * (split into UT_CLOSE and UT_UNSORTED) */ #ifdef UTNOKEEP # define UT_CLOSE # define UT_UNSORTED #endif #ifdef UT_CLOSE # undef UT_CLOSE # define UT_CLOSE endutent() #else # define UT_CLOSE #endif /* * we have a suid-root helper app that changes the utmp for us * (won't work for login-slots) */ #if (defined(sun) && defined(SVR4) && defined(GETUTENT)) || defined(HAVE_UTEMPTER) # define UTMP_HELPER #endif #ifdef UTMPOK static slot_t TtyNameSlot __P((char *)); static void makeuser __P((struct utmp *, char *, char *, int)); static void makedead __P((struct utmp *)); static int pututslot __P((slot_t, struct utmp *, char *, struct win *)); static struct utmp *getutslot __P((slot_t)); #ifndef GETUTENT static struct utmp *getutent __P((void)); static void endutent __P((void)); static int initutmp __P((void)); static void setutent __P((void)); #endif #if defined(linux) && defined(GETUTENT) static struct utmp *xpututline __P((struct utmp *utmp)); # define pututline xpututline #endif static int utmpok; static char UtmpName[] = UTMPFILE; #ifndef UTMP_HELPER static int utmpfd = -1; #endif # if defined(GETUTENT) && (!defined(SVR4) || defined(__hpux)) && ! defined(__CYGWIN__) # if defined(hpux) /* cruel hpux release 8.0 */ # define pututline _pututline # endif /* hpux */ extern struct utmp *getutline(), *pututline(); # if defined(_SEQUENT_) extern struct utmp *ut_add_user(), *ut_delete_user(); extern char *ut_find_host(); # ifndef UTHOST # define UTHOST /* _SEQUENT_ has ut_find_host() */ # endif # endif /* _SEQUENT_ */ # endif /* GETUTENT && !SVR4 */ # if !defined(GETUTENT) && !defined(UT_UNSORTED) # ifdef GETTTYENT # include # else struct ttyent { char *ty_name; }; static void setttyent __P((void)); static struct ttyent *getttyent __P((void)); # endif # endif /* !GETUTENT && !UT_UNSORTED */ #ifndef _SEQUENT_ # undef D_loginhost # define D_loginhost D_utmp_logintty.ut_host #endif #ifndef UTHOST # undef D_loginhost # define D_loginhost ((char *)0) #endif #endif /* UTMPOK */ /* * SlotToggle - modify the utmp slot of the fore window. * * how > 0 do try to set a utmp slot. * how = 0 try to withdraw a utmp slot. * * w_slot = -1 window not logged in. * w_slot = 0 window not logged in, but should be logged in. * (unable to write utmp, or detached). */ #ifndef UTMPOK void SlotToggle(how) int how; { debug1("SlotToggle (!UTMPOK) %d\n", how); # ifdef UTMPFILE Msg(0, "Unable to modify %s.\n", UTMPFILE); # else Msg(0, "Unable to modify utmp-database.\n"); # endif } #endif #ifdef UTMPOK void SlotToggle(how) int how; { debug1("SlotToggle %d\n", how); if (fore->w_type != W_TYPE_PTY) { Msg(0, "Can only work with normal windows.\n"); return; } if (how) { debug(" try to log in\n"); if ((fore->w_slot == (slot_t) -1) || (fore->w_slot == (slot_t) 0)) { #ifdef USRLIMIT if (CountUsers() >= USRLIMIT) { Msg(0, "User limit reached."); return; } #endif if (SetUtmp(fore) == 0) Msg(0, "This window is now logged in."); else Msg(0, "This window should now be logged in."); WindowChanged(fore, 'f'); } else Msg(0, "This window is already logged in."); } else { debug(" try to log out\n"); if (fore->w_slot == (slot_t) -1) Msg(0, "This window is already logged out\n"); else if (fore->w_slot == (slot_t) 0) { debug("What a relief! In fact, it was not logged in\n"); Msg(0, "This window is not logged in."); fore->w_slot = (slot_t) -1; } else { RemoveUtmp(fore); if (fore->w_slot != (slot_t) -1) Msg(0, "What? Cannot remove Utmp slot?"); else Msg(0, "This window is no longer logged in."); #ifdef CAREFULUTMP CarefulUtmp(); #endif WindowChanged(fore, 'f'); } } } #ifdef CAREFULUTMP /* CAREFULUTMP: goodie for paranoid sysadmins: always leave one * window logged in */ void CarefulUtmp() { struct win *p; if (!windows) /* hopeless */ return; debug("CarefulUtmp counting slots\n"); for (p = windows; p; p = p->w_next) if (p->w_ptyfd >= 0 && p->w_slot != (slot_t)-1) return; /* found one, nothing to do */ debug("CarefulUtmp: no slots, log one in again.\n"); for (p = windows; p; p = p->w_next) if (p->w_ptyfd >= 0) /* no zombies please */ break; if (!p) return; /* really hopeless */ SetUtmp(p); Msg(0, "Window %d is now logged in.\n", p->w_number); } #endif /* CAREFULUTMP */ void InitUtmp() { debug1("InitUtmp testing '%s'...\n", UtmpName); #ifndef UTMP_HELPER if ((utmpfd = open(UtmpName, O_RDWR)) == -1) { if (errno != EACCES) Msg(errno, "%s", UtmpName); debug("InitUtmp failed.\n"); utmpok = 0; return; } # ifdef GETUTENT close(utmpfd); /* it was just a test */ utmpfd = -1; # endif /* GETUTENT */ #endif /* UTMP_HELPER */ utmpok = 1; } #ifdef USRLIMIT int CountUsers() { struct utmp *ut; int UserCount; debug1("CountUsers() - utmpok=%d\n", utmpok); if (!utmpok) return 0; UserCount = 0; setutent(); while (ut = getutent()) if (SLOT_USED(ut)) UserCount++; UT_CLOSE; return UserCount; } #endif /* USRLIMIT */ /* * the utmp entry for tty is located and removed. * it is stored in D_utmp_logintty. */ void RemoveLoginSlot() { struct utmp u, *uu; ASSERT(display); debug("RemoveLoginSlot: removing your logintty\n"); D_loginslot = TtyNameSlot(D_usertty); if (D_loginslot == (slot_t)0 || D_loginslot == (slot_t)-1) return; #ifdef UTMP_HELPER if (eff_uid) /* helpers can't do login slots. sigh. */ #else if (!utmpok) #endif { D_loginslot = 0; debug("RemoveLoginSlot: utmpok == 0\n"); } else { #ifdef _SEQUENT_ { char *p; if ((p = ut_find_host(D_loginslot)) != 0) strncpy(D_loginhost, p, sizeof(D_loginhost) - 1); D_loginhost[sizeof(D_loginhost) - 1] = 0; } #endif /* _SEQUENT_ */ if ((uu = getutslot(D_loginslot)) == 0) { debug("Utmp slot not found -> not removed"); D_loginslot = 0; } else { D_utmp_logintty = *uu; u = *uu; makedead(&u); if (pututslot(D_loginslot, &u, (char *)0, (struct win *)0) == 0) D_loginslot = 0; } UT_CLOSE; } debug1(" slot %d zapped\n", (int)D_loginslot); if (D_loginslot == (slot_t)0) { /* couldn't remove slot, do a 'mesg n' at least. */ struct stat stb; char *tty; debug("couln't zap slot -> do mesg n\n"); D_loginttymode = 0; if ((tty = GetPtsPathOrSymlink(D_userfd)) && stat(tty, &stb) == 0 && (int)stb.st_uid == real_uid && !CheckTtyname(tty) && ((int)stb.st_mode & 0777) != 0666) { D_loginttymode = (int)stb.st_mode & 0777; chmod(D_usertty, stb.st_mode & 0600); } } } /* * D_utmp_logintty is reinserted into utmp */ void RestoreLoginSlot() { char *tty; debug("RestoreLoginSlot()\n"); ASSERT(display); if (utmpok && D_loginslot != (slot_t)0 && D_loginslot != (slot_t)-1) { debug1(" logging you in again (slot %#x)\n", (int)D_loginslot); if (pututslot(D_loginslot, &D_utmp_logintty, D_loginhost, (struct win *)0) == 0) Msg(errno,"Could not write %s", UtmpName); } UT_CLOSE; D_loginslot = (slot_t)0; if (D_loginttymode && (tty = GetPtsPathOrSymlink(D_userfd)) && !CheckTtyname(tty)) chmod(tty, D_loginttymode); } /* * Construct a utmp entry for window wi. * the hostname field reflects what we know about the user (display) * location. If d_loginhost is not set, then he is local and we write * down the name of his terminal line; else he is remote and we keep * the hostname here. The letter S and the window id will be appended. * A saved utmp entry in wi->w_savut serves as a template, usually. */ int SetUtmp(wi) struct win *wi; { register slot_t slot; struct utmp u; int saved_ut; #ifdef UTHOST char *p; char host[sizeof(D_loginhost) + 15]; #else char *host = 0; #endif /* UTHOST */ wi->w_slot = (slot_t)0; if (!utmpok || wi->w_type != W_TYPE_PTY) return -1; if ((slot = TtyNameSlot(wi->w_tty)) == (slot_t)0) { debug1("SetUtmp failed (tty %s).\n",wi->w_tty); return -1; } debug2("SetUtmp %d will get slot %d...\n", wi->w_number, (int)slot); bzero((char *)&u, sizeof(u)); if ((saved_ut = bcmp((char *) &wi->w_savut, (char *)&u, sizeof(u)))) /* restore original, of which we will adopt all fields but ut_host */ bcopy((char *)&wi->w_savut, (char *) &u, sizeof(u)); if (!saved_ut) makeuser(&u, stripdev(wi->w_tty), LoginName, wi->w_pid); #ifdef UTHOST host[sizeof(host) - 15] = '\0'; if (display) { strncpy(host, D_loginhost, sizeof(host) - 15); if (D_loginslot != (slot_t)0 && D_loginslot != (slot_t)-1 && host[0] != '\0') { /* * we want to set our ut_host field to something like * ":ttyhf:s.0" or * "faui45:s.0" or * "132.199.81.4:s.0" (even this may hurt..), but not * "faui45.informati"......:s.0 * HPUX uses host:0.0, so chop at "." and ":" (Eric Backus) */ for (p = host; *p; p++) if ((*p < '0' || *p > '9') && (*p != '.')) break; if (*p) { for (p = host; *p; p++) if (*p == '.' || (*p == ':' && p != host)) { *p = '\0'; break; } } } else { strncpy(host + 1, stripdev(D_usertty), sizeof(host) - 15 - 1); host[0] = ':'; } } else strncpy(host, "local", sizeof(host) - 15); sprintf(host + strlen(host), ":S.%d", wi->w_number); debug1("rlogin hostname: '%s'\n", host); # if !defined(_SEQUENT_) && !defined(sequent) strncpy(u.ut_host, host, sizeof(u.ut_host)); # endif #endif /* UTHOST */ if (pututslot(slot, &u, host, wi) == 0) { Msg(errno,"Could not write %s", UtmpName); UT_CLOSE; return -1; } debug("SetUtmp successful\n"); wi->w_slot = slot; bcopy((char *)&u, (char *)&wi->w_savut, sizeof(u)); UT_CLOSE; return 0; } /* * if slot could be removed or was 0, wi->w_slot = -1; * else not changed. */ int RemoveUtmp(wi) struct win *wi; { struct utmp u, *uu; slot_t slot; slot = wi->w_slot; debug1("RemoveUtmp slot=%#x\n", slot); if (!utmpok) return -1; if (slot == (slot_t)0 || slot == (slot_t)-1) { wi->w_slot = (slot_t)-1; return 0; } bzero((char *) &u, sizeof(u)); #ifdef sgi bcopy((char *)&wi->w_savut, (char *)&u, sizeof(u)); uu = &u; #else if ((uu = getutslot(slot)) == 0) { Msg(0, "Utmp slot not found -> not removed"); return -1; } bcopy((char *)uu, (char *)&wi->w_savut, sizeof(wi->w_savut)); #endif u = *uu; makedead(&u); if (pututslot(slot, &u, (char *)0, wi) == 0) { Msg(errno,"Could not write %s", UtmpName); UT_CLOSE; return -1; } debug("RemoveUtmp successfull\n"); wi->w_slot = (slot_t)-1; UT_CLOSE; return 0; } /********************************************************************* * * routines using the getut* api */ #ifdef GETUTENT #define SLOT_USED(u) (u->ut_type == USER_PROCESS) static struct utmp * getutslot(slot) slot_t slot; { struct utmp u; bzero((char *)&u, sizeof(u)); strncpy(u.ut_line, slot, sizeof(u.ut_line)); setutent(); return getutline(&u); } static int pututslot(slot, u, host, wi) slot_t slot; struct utmp *u; char *host; struct win *wi; { #ifdef _SEQUENT_ if (SLOT_USED(u) && host && *host) return ut_add_user(u.ut_name, slot, u.ut_pid, host) != 0; if (!SLOT_USED(u)) return ut_delete_user(slot, u.ut_pid, 0, 0) != 0; #endif #ifdef HAVE_UTEMPTER if (eff_uid && wi && wi->w_ptyfd != -1) { /* sigh, linux hackers made the helper functions void */ if (SLOT_USED(u)) addToUtmp(wi->w_tty, host, wi->w_ptyfd); else removeLineFromUtmp(wi->w_tty, wi->w_ptyfd); return 1; /* pray for success */ } #endif setutent(); #ifndef __CYGWIN__ return pututline(u) != 0; #else return 1; #endif } static void makedead(u) struct utmp *u; { u->ut_type = DEAD_PROCESS; #if (!defined(linux) || defined(EMPTY)) && !defined(__CYGWIN__) u->ut_exit.e_termination = 0; u->ut_exit.e_exit = 0; #endif #if !defined(sun) || !defined(SVR4) u->ut_user[0] = 0; /* for Digital UNIX, kilbi@rad.rwth-aachen.de */ #endif } static void makeuser(u, line, user, pid) struct utmp *u; char *line, *user; int pid; { time_t now; u->ut_type = USER_PROCESS; strncpy(u->ut_user, user, sizeof(u->ut_user)); /* Now the tricky part... guess ut_id */ #if defined(sgi) || defined(linux) strncpy(u->ut_id, line + 3, sizeof(u->ut_id)); #else /* sgi */ # ifdef _IBMR2 strncpy(u->ut_id, line, sizeof(u->ut_id)); # else strncpy(u->ut_id, line + strlen(line) - 2, sizeof(u->ut_id)); # endif #endif /* sgi */ strncpy(u->ut_line, line, sizeof(u->ut_line)); u->ut_pid = pid; /* must use temp variable because of NetBSD/sparc64, where * ut_xtime is long(64) but time_t is int(32) */ (void)time(&now); u->ut_time = now; } static slot_t TtyNameSlot(nam) char *nam; { return stripdev(nam); } #else /* GETUTENT */ /********************************************************************* * * getut emulation for systems lacking the api */ static struct utmp uent; #define SLOT_USED(u) (u.ut_name[0] != 0) static int initutmp() { if (utmpfd >= 0) return 1; return (utmpfd = open(UtmpName, O_RDWR)) >= 0; } static void setutent() { if (utmpfd >= 0) (void)lseek(utmpfd, (off_t)0, 0); } static void endutent() { if (utmpfd >= 0) close(utmpfd); utmpfd = -1; } static struct utmp * getutent() { if (utmpfd < 0 && !initutmp()) return 0; if (read(utmpfd, &uent, sizeof(uent)) != sizeof(uent)) return 0; return &uent; } static struct utmp * getutslot(slot) slot_t slot; { if (utmpfd < 0 && !initutmp()) return 0; lseek(utmpfd, (off_t)(slot * sizeof(struct utmp)), 0); if (read(utmpfd, &uent, sizeof(uent)) != sizeof(uent)) return 0; return &uent; } static int pututslot(slot, u, host, wi) slot_t slot; struct utmp *u; char *host; struct win *wi; { #ifdef sequent if (SLOT_USED(u)) return add_utmp(slot, u) != -1; #endif if (utmpfd < 0 && !initutmp()) return 0; lseek(utmpfd, (off_t)(slot * sizeof(*u)), 0); if (write(utmpfd, u, sizeof(*u)) != sizeof(*u)) return 0; return 1; } static void makedead(u) struct utmp *u; { #ifdef UT_UNSORTED bzero(u->ut_name, sizeof(u->ut_name)); # ifdef UTHOST bzero(u->ut_host, sizeof(u->ut_host)); # endif #else bzero((char *)u, sizeof(*u)); #endif } static void makeuser(u, line, user, pid) struct utmp *u; char *line, *user; int pid; { time_t now; strncpy(u->ut_line, line, sizeof(u->ut_line)); strncpy(u->ut_name, user, sizeof(u->ut_name)); (void)time(&now); u->ut_time = now; } static slot_t TtyNameSlot(nam) char *nam; { slot_t slot; char *line; #ifndef UT_UNSORTED struct ttyent *tp; #endif line = stripdev(nam); #ifdef UT_UNSORTED setutent(); if (utmpfd < 0) return -1; for (slot = 0; getutent(); slot++) if (strcmp(uent.ut_line, line) == 0) break; UT_CLOSE; #else slot = 1; setttyent(); while ((tp = getttyent()) != 0 && strcmp(line, tp->ty_name) != 0) slot++; #endif return slot; } #endif /* GETUTENT */ /********************************************************************* * * Cheap plastic imitation of ttyent routines. */ #if !defined(GETTTYENT) && !defined(GETUTENT) && !defined(UT_UNSORTED) static char *tt, *ttnext; static char ttys[] = "/etc/ttys"; static void setttyent() { if (ttnext == 0) { struct stat s; register int f; register char *p, *ep; if ((f = open(ttys, O_RDONLY)) == -1 || fstat(f, &s) == -1) Panic(errno, ttys); if ((tt = malloc((unsigned) s.st_size + 1)) == 0) Panic(0, strnomem); if (read(f, tt, s.st_size) != s.st_size) Panic(errno, ttys); close(f); for (p = tt, ep = p + s.st_size; p < ep; p++) if (*p == '\n') *p = '\0'; *p = '\0'; } ttnext = tt; } static struct ttyent * getttyent() { static struct ttyent t; if (*ttnext == '\0') return NULL; t.ty_name = ttnext + 2; ttnext += strlen(ttnext) + 1; return &t; } #endif /* !GETTTYENT && !GETUTENT && !UT_UNSORTED*/ #endif /* UTMPOK */ /********************************************************************* * * getlogin() replacement (for SVR4 machines) */ # if defined(BUGGYGETLOGIN) && defined(UTMP_FILE) char * getlogin() { char *tty = NULL; #ifdef utmp # undef utmp #endif struct utmp u; static char retbuf[sizeof(u.ut_user)+1]; int fd; for (fd = 0; fd <= 2 && (tty = GetPtsPathOrSymlink(fd)) == NULL; fd++) ; if ((tty == NULL) || CheckTtyname(tty) || ((fd = open(UTMP_FILE, O_RDONLY)) < 0)) return NULL; tty = stripdev(tty); retbuf[0] = '\0'; while (read(fd, (char *)&u, sizeof(struct utmp)) == sizeof(struct utmp)) { if (!strncmp(tty, u.ut_line, sizeof(u.ut_line))) { strncpy(retbuf, u.ut_user, sizeof(u.ut_user)); retbuf[sizeof(u.ut_user)] = '\0'; if (u.ut_type == USER_PROCESS) break; } } close(fd); return *retbuf ? retbuf : NULL; } # endif /* BUGGYGETLOGIN */ #if defined(linux) && defined(GETUTENT) # undef pututline /* aargh, linux' pututline returns void! */ struct utmp * xpututline(u) struct utmp *u; { struct utmp *u2; pututline(u); setutent(); u2 = getutline(u); if (u2 == 0) return u->ut_type == DEAD_PROCESS ? u : 0; return u->ut_type == u2->ut_type ? u : 0; } #endif screen-4.8.0/resize.c0000644000175000017500000006274713616620402013367 0ustar amadeamade/* 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) 1993-2002, 2003, 2005, 2006, 2007 * 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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, see * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include #include #ifndef sun #include #endif #ifdef ISC # include # include # include #endif #include "config.h" #include "screen.h" #include "extern.h" /* maximum window width */ #define MAXWIDTH 1000 static void CheckMaxSize __P((int)); static void FreeMline __P((struct mline *)); static int AllocMline __P((struct mline *ml, int)); static void MakeBlankLine __P((unsigned char *, int)); static void kaablamm __P((void)); static int BcopyMline __P((struct mline *, int, struct mline *, int, int, int)); static void SwapAltScreen __P((struct win *)); extern struct layer *flayer; extern struct display *display, *displays; extern unsigned char *blank, *null; extern struct mline mline_blank, mline_null, mline_old; extern struct win *windows; extern const int Z0width, Z1width; extern int captionalways; #if defined(TIOCGWINSZ) || defined(TIOCSWINSZ) struct winsize glwz; #endif static struct mline mline_zero = { (unsigned char *)0, (unsigned char *)0 #ifdef FONT ,(unsigned char *)0 #endif #ifdef COLOR ,(unsigned char *)0 # ifdef COLORS256 ,(unsigned char *)0 # endif #endif }; /* * ChangeFlag: 0: try to modify no window * 1: modify fore (and try to modify no other) + redisplay * 2: modify all windows * * Note: Activate() is only called if change_flag == 1 * i.e. on a WINCH event */ void CheckScreenSize(change_flag) int change_flag; { int wi, he; if (display == 0) { debug("CheckScreenSize: No display -> no check.\n"); return; } #ifdef TIOCGWINSZ if (ioctl(D_userfd, TIOCGWINSZ, (char *)&glwz) != 0) { debug2("CheckScreenSize: ioctl(%d, TIOCGWINSZ) errno %d\n", D_userfd, errno); wi = D_CO; he = D_LI; } else { wi = glwz.ws_col; he = glwz.ws_row; if (wi == 0) wi = D_CO; if (he == 0) he = D_LI; } #else wi = D_CO; he = D_LI; #endif debug2("CheckScreenSize: screen is (%d,%d)\n", wi, he); #if 0 /* XXX: Fixme */ if (change_flag == 2) { 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, p->w_histheight); } #endif if (D_width == wi && D_height == he) { debug("CheckScreenSize: No change -> return.\n"); return; } #ifdef BLANKER_PRG KillBlanker(); #endif ResetIdle(); ChangeScreenSize(wi, he, change_flag); /* XXX Redisplay logic */ #if 0 if (change_flag == 1) Redisplay(D_fore ? D_fore->w_norefresh : 0); #endif } void ChangeScreenSize(wi, he, change_fore) int wi, 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 0 if (D_CZ0 && p->w_width != wi && (wi == Z0width || wi == Z1width)) { if (p->w_width > (Z0width + Z1width) / 2) wwi = Z0width; else wwi = Z1width; } #endif if (p->w_savelayer && p->w_savelayer->l_cvlist == 0) ResizeLayer(p->w_savelayer, wwi, he, 0); #if 0 ChangeWindowSize(p, wwi, he, p->w_histheight); #endif } } } void ResizeLayersToCanvases() { struct canvas *cv; struct layer *l; int lx, ly; debug("ResizeLayersToCanvases\n"); D_kaablamm = 0; for (cv = D_cvlist; cv; cv = cv->c_next) { l = cv->c_layer; if (l == 0) continue; debug("Doing canvas: "); if (l->l_width == cv->c_xe - cv->c_xs + 1 && l->l_height == cv->c_ye - cv->c_ys + 1) { debug("already fitting.\n"); continue; } if (!MayResizeLayer(l)) { debug("may not resize.\n"); } else { debug("doing resize.\n"); ResizeLayer(l, cv->c_xe - cv->c_xs + 1, cv->c_ye - cv->c_ys + 1, display); } /* normalize window, see screen.c */ lx = cv->c_layer->l_x; ly = cv->c_layer->l_y; if (ly + cv->c_yoff < cv->c_ys) { cv->c_yoff = cv->c_ys - ly; RethinkViewportOffsets(cv); } else if (ly + cv->c_yoff > cv->c_ye) { cv->c_yoff = cv->c_ye - ly; RethinkViewportOffsets(cv); } if (lx + cv->c_xoff < cv->c_xs) { int n = cv->c_xs - (lx + cv->c_xoff); if (n < (cv->c_xe - cv->c_xs + 1) / 2) n = (cv->c_xe - cv->c_xs + 1) / 2; if (cv->c_xoff + n > cv->c_xs) n = cv->c_xs - cv->c_xoff; cv->c_xoff += n; RethinkViewportOffsets(cv); } else if (lx + cv->c_xoff > cv->c_xe) { int n = lx + cv->c_xoff - cv->c_xe; if (n < (cv->c_xe - cv->c_xs + 1) / 2) n = (cv->c_xe - cv->c_xs + 1) / 2; if (cv->c_xoff - n + cv->c_layer->l_width - 1 < cv->c_xe) n = cv->c_xoff + cv->c_layer->l_width - 1 - cv->c_xe; cv->c_xoff -= n; RethinkViewportOffsets(cv); } } Redisplay(0); if (D_kaablamm) { kaablamm(); D_kaablamm = 0; } } int MayResizeLayer(l) struct layer *l; { int cvs = 0; debug("MayResizeLayer:\n"); for (; l; l = l->l_next) { if (l->l_cvlist) if (++cvs > 1 || l->l_cvlist->c_lnext) { debug1("may not - cvs %d\n", cvs); return 0; } } debug("may resize\n"); return 1; } /* * Easy implementation: rely on the fact that the only layers * supporting resize are Win and Blank. So just kill all overlays. * * This is a lot harder if done the right way... */ static void kaablamm() { Msg(0, "Aborted because of window size change."); } /* Kills non-resizable layers. */ #define RESIZE_OR_KILL_LAYERS(l, wi, he) do \ { \ struct layer *_last = NULL; \ flayer = (l); \ while (flayer->l_next) \ { \ if (LayResize(wi, he) == 0) \ { \ _last = flayer; \ flayer = flayer->l_next; \ } \ else \ { \ struct canvas *_cv; \ for (_cv = flayer->l_cvlist; _cv; _cv = _cv->c_lnext) \ _cv->c_display->d_kaablamm = 1; \ ExitOverlayPage(); \ if (_last) \ _last->l_next = flayer; \ } \ } \ /* We assume that the bottom-most layer, i.e. when flayer->l_next == 0, \ * is always resizable. Currently, WinLf and BlankLf can be the bottom-most layers. \ */ \ LayResize(wi, he); \ } while (0) void ResizeLayer(l, wi, he, norefdisp) struct layer *l; int wi, he; struct display *norefdisp; { struct win *p; struct canvas *cv; struct layer *oldflayer = flayer; struct display *d, *olddisplay = display; if (l->l_width == wi && l->l_height == he) return; p = Layer2Window(l); /* If 'flayer' and 'l' are for the same window, then we will not * restore 'flayer'. */ if (oldflayer && (l == oldflayer || Layer2Window(oldflayer) == p)) oldflayer = NULL; flayer = l; if (p) { /* It's a window layer. Kill the overlays on it in all displays. */ for (d = displays; d; d = d->d_next) for (cv = d->d_cvlist; cv; cv = cv->c_next) { if (p == Layer2Window(cv->c_layer)) { /* Canvas 'cv' on display 'd' shows this window. Remove any non-resizable * layers over it. */ RESIZE_OR_KILL_LAYERS(cv->c_layer, wi, he); } } } else { /* It's a Blank layer. Just kill the non-resizable overlays over it. */ RESIZE_OR_KILL_LAYERS(flayer, wi, he); } for (display = displays; display; display = display->d_next) { if (display == norefdisp) continue; for (cv = D_cvlist; cv; cv = cv->c_next) if (Layer2Window(cv->c_layer) == p) { CV_CALL(cv, LayRedisplayLine(-1, -1, -1, 0)); RefreshArea(cv->c_xs, cv->c_ys, cv->c_xe, cv->c_ye, 0); } if (D_kaablamm) { kaablamm(); D_kaablamm = 0; } } /* If we started resizing a non-flayer layer, then restore the flayer. * Otherwise, flayer should already be updated to the topmost foreground layer. */ if (oldflayer) flayer = oldflayer; display = olddisplay; } static void FreeMline(ml) struct mline *ml; { if (ml->image) free(ml->image); if (ml->attr && ml->attr != null) free(ml->attr); #ifdef FONT if (ml->font && ml->font != null) free(ml->font); if (ml->fontx && ml->fontx != null) free(ml->fontx); #endif #ifdef COLOR if (ml->color && ml->color != null) free(ml->color); # ifdef COLORS256 if (ml->colorx && ml->colorx != null) free(ml->colorx); # endif #endif *ml = mline_zero; } static int AllocMline(ml, w) struct mline *ml; int w; { ml->image = malloc(w); ml->attr = null; #ifdef FONT ml->font = null; ml->fontx = null; #endif #ifdef COLOR ml->color = null; # ifdef COLORS256 ml->colorx = null; # endif #endif if (ml->image == 0) return -1; return 0; } static int BcopyMline(mlf, xf, mlt, xt, l, w) struct mline *mlf, *mlt; int xf, xt, l, w; { int r = 0; bcopy((char *)mlf->image + xf, (char *)mlt->image + xt, l); if (mlf->attr != null && mlt->attr == null) { if ((mlt->attr = (unsigned char *)calloc(w, 1)) == 0) mlt->attr = null, r = -1; } if (mlt->attr != null) bcopy((char *)mlf->attr + xf, (char *)mlt->attr + xt, l); #ifdef FONT if (mlf->font != null && mlt->font == null) { if ((mlt->font = (unsigned char *)calloc(w, 1)) == 0) mlt->font = null, r = -1; } if (mlt->font != null) bcopy((char *)mlf->font + xf, (char *)mlt->font + xt, l); if (mlf->fontx != null && mlt->fontx == null) { if ((mlt->fontx = (unsigned char *)calloc(w, 1)) == 0) mlt->fontx = null, r = -1; } if (mlt->fontx != null) bcopy((char *)mlf->fontx + xf, (char *)mlt->fontx + xt, l); #endif #ifdef COLOR if (mlf->color != null && mlt->color == null) { if ((mlt->color = (unsigned char *)calloc(w, 1)) == 0) mlt->color = null, r = -1; } if (mlt->color != null) bcopy((char *)mlf->color + xf, (char *)mlt->color + xt, l); # ifdef COLORS256 if (mlf->colorx != null && mlt->colorx == null) { if ((mlt->colorx = (unsigned char *)calloc(w, 1)) == 0) mlt->colorx = null, r = -1; } if (mlt->colorx != null) bcopy((char *)mlf->colorx + xf, (char *)mlt->colorx + xt, l); # endif #endif return r; } static int maxwidth; static void CheckMaxSize(wi) int wi; { unsigned char *oldnull = null; unsigned char *oldblank = blank; struct win *p; int i; struct mline *ml; if (wi > MAXWIDTH) wi = MAXWIDTH; if (wi <= maxwidth) return; maxwidth = wi + 1; debug1("New maxwidth: %d\n", maxwidth); blank = (unsigned char *)xrealloc((char *)blank, maxwidth); null = (unsigned char *)xrealloc((char *)null, maxwidth); mline_old.image = (unsigned char *)xrealloc((char *)mline_old.image, maxwidth); mline_old.attr = (unsigned char *)xrealloc((char *)mline_old.attr, maxwidth); #ifdef FONT mline_old.font = (unsigned char *)xrealloc((char *)mline_old.font, maxwidth); mline_old.fontx = (unsigned char *)xrealloc((char *)mline_old.fontx, maxwidth); #endif #ifdef COLOR mline_old.color = (unsigned char *)xrealloc((char *)mline_old.color, maxwidth); # ifdef COLORS256 mline_old.colorx = (unsigned char *)xrealloc((char *)mline_old.colorx, maxwidth); # endif #endif if (!(blank && null && mline_old.image && mline_old.attr IFFONT(&& mline_old.font) IFFONTX(&& mline_old.fontx) IFCOLOR(&& mline_old.color) IFCOLORX(&& mline_old.colorx))) Panic(0, "%s", strnomem); MakeBlankLine(blank, maxwidth); bzero((char *)null, maxwidth); mline_blank.image = blank; mline_blank.attr = null; mline_null.image = null; mline_null.attr = null; #ifdef FONT mline_blank.font = null; mline_null.font = null; mline_blank.fontx = null; mline_null.fontx = null; #endif #ifdef COLOR mline_blank.color = null; mline_null.color = null; # ifdef COLORS256 mline_blank.colorx = null; mline_null.colorx = null; # endif #endif #define RESET_AFC(x, bl) do { if (x == old##bl) x = bl; } while (0) #define RESET_LINES(lines, count) \ do { \ ml = lines; \ for (i = 0; i < count; i++, ml++) \ { \ RESET_AFC(ml->image, blank); \ RESET_AFC(ml->attr, null); \ IFFONT(RESET_AFC(ml->font, null)); \ IFFONT(RESET_AFC(ml->fontx, null)); \ IFCOLOR(RESET_AFC(ml->color, null)); \ IFCOLORX(RESET_AFC(ml->colorx, null)); \ } \ } while (0) /* We have to run through all windows to substitute * the null and blank references. */ for (p = windows; p; p = p->w_next) { RESET_LINES(p->w_mlines, p->w_height); #ifdef COPY_PASTE RESET_LINES(p->w_hlines, p->w_histheight); RESET_LINES(p->w_alt.hlines, p->w_alt.histheight); #endif RESET_LINES(p->w_alt.mlines, p->w_alt.height); } } char * xrealloc(mem, len) char *mem; int len; { register char *nmem; if (mem == 0) return malloc(len); if ((nmem = realloc(mem, len))) return nmem; free(mem); return (char *)0; } static void MakeBlankLine(p, n) register unsigned char *p; register int n; { while (n--) *p++ = ' '; } #ifdef COPY_PASTE #define OLDWIN(y) ((y < p->w_histheight) \ ? &p->w_hlines[(p->w_histidx + y) % p->w_histheight] \ : &p->w_mlines[y - p->w_histheight]) #define NEWWIN(y) ((y < hi) ? &nhlines[y] : &nmlines[y - hi]) #else #define OLDWIN(y) (&p->w_mlines[y]) #define NEWWIN(y) (&nmlines[y]) #endif int ChangeWindowSize(p, wi, he, hi) struct win *p; int wi, he, hi; { struct mline *mlf = 0, *mlt = 0, *ml, *nmlines, *nhlines; int fy, ty, l, lx, lf, lt, yy, oty, addone; int ncx, ncy, naka, t; int y, shift; if (wi <= 0 || he <= 0) wi = he = hi = 0; if (p->w_type == W_TYPE_GROUP) return 0; if (wi > MAXWIDTH) { Msg(0, "Window width too large. Truncated to %d.", MAXWIDTH); wi = MAXWIDTH; } if (he > MAXWIDTH) { Msg(0, "Window height too large. Truncated to %d.", MAXWIDTH); he = MAXWIDTH; } if (p->w_width == wi && p->w_height == he && p->w_histheight == hi) { debug("ChangeWindowSize: No change.\n"); return 0; } CheckMaxSize(wi); /* XXX */ #if 0 /* just in case ... */ if (wi && (p->w_width != wi || p->w_height != he) && p->w_lay != &p->w_winlay) { debug("ChangeWindowSize: No resize because of overlay?\n"); return -1; } #endif debug("ChangeWindowSize"); debug3(" from (%d,%d)+%d", p->w_width, p->w_height, p->w_histheight); debug3(" to(%d,%d)+%d\n", wi, he, hi); fy = p->w_histheight + p->w_height - 1; ty = hi + he - 1; nmlines = nhlines = 0; ncx = 0; ncy = 0; naka = 0; if (wi) { if (wi != p->w_width || he != p->w_height) { if ((nmlines = (struct mline *)calloc(he, sizeof(struct mline))) == 0) { KillWindow(p); Msg(0, "%s", strnomem); return -1; } } else { debug1("image stays the same: %d lines\n", he); nmlines = p->w_mlines; fy -= he; ty -= he; ncx = p->w_x; ncy = p->w_y; naka = p->w_autoaka; } } #ifdef COPY_PASTE if (hi) { if ((nhlines = (struct mline *)calloc(hi, sizeof(struct mline))) == 0) { Msg(0, "No memory for history buffer - turned off"); hi = 0; ty = he - 1; } } #endif /* special case: cursor is at magic margin position */ addone = 0; if (p->w_width && p->w_x == p->w_width) { debug2("Special addone case: %d %d\n", p->w_x, p->w_y); addone = 1; p->w_x--; } /* handle the cursor and autoaka lines now if the widths are equal */ if (p->w_width == wi) { ncx = p->w_x + addone; ncy = p->w_y + he - p->w_height; /* never lose sight of the line with the cursor on it */ shift = -ncy; for (yy = p->w_y + p->w_histheight - 1; yy >= 0 && ncy + shift < he; yy--) { ml = OLDWIN(yy); if (!ml->image) break; if (ml->image[p->w_width] == ' ') break; shift++; } if (shift < 0) shift = 0; else debug1("resize: cursor out of bounds, shifting %d\n", shift); ncy += shift; if (p->w_autoaka > 0) { naka = p->w_autoaka + he - p->w_height + shift; if (naka < 1 || naka > he) naka = 0; } while (shift-- > 0) { ml = OLDWIN(fy); FreeMline(ml); fy--; } } debug2("fy %d ty %d\n", fy, ty); if (fy >= 0) mlf = OLDWIN(fy); if (ty >= 0) mlt = NEWWIN(ty); while (fy >= 0 && ty >= 0) { if (p->w_width == wi) { /* here is a simple shortcut: just copy over */ *mlt = *mlf; *mlf = mline_zero; if (--fy >= 0) mlf = OLDWIN(fy); if (--ty >= 0) mlt = NEWWIN(ty); continue; } /* calculate lenght */ for (l = p->w_width - 1; l > 0; l--) if (mlf->image[l] != ' ' || mlf->attr[l]) break; if (fy == p->w_y + p->w_histheight && l < p->w_x) l = p->w_x; /* cursor is non blank */ l++; lf = l; /* add wrapped lines to length */ for (yy = fy - 1; yy >= 0; yy--) { ml = OLDWIN(yy); if (ml->image[p->w_width] == ' ') break; l += p->w_width; } /* rewrap lines */ lt = (l - 1) % wi + 1; /* lf is set above */ oty = ty; while (l > 0 && fy >= 0 && ty >= 0) { lx = lt > lf ? lf : lt; if (mlt->image == 0) { if (AllocMline(mlt, wi + 1)) goto nomem; MakeBlankLine(mlt->image + lt, wi - lt); mlt->image[wi] = ((oty == ty) ? ' ' : 0); } if (BcopyMline(mlf, lf - lx, mlt, lt - lx, lx, wi + 1)) goto nomem; /* did we copy the cursor ? */ if (fy == p->w_y + p->w_histheight && lf - lx <= p->w_x && lf > p->w_x) { ncx = p->w_x + lt - lf + addone; ncy = ty - hi; shift = wi ? -ncy + (l - lx) / wi : 0; if (ty + shift > hi + he - 1) shift = hi + he - 1 - ty; if (shift > 0) { debug3("resize: cursor out of bounds, shifting %d [%d/%d]\n", shift, lt - lx, wi); for (y = hi + he - 1; y >= ty; y--) { mlt = NEWWIN(y); FreeMline(mlt); if (y - shift < ty) continue; ml = NEWWIN(y - shift); *mlt = *ml; *ml = mline_zero; } ncy += shift; ty += shift; mlt = NEWWIN(ty); if (naka > 0) naka = naka + shift > he ? 0 : naka + shift; } ASSERT(ncy >= 0); } /* did we copy autoaka line ? */ if (p->w_autoaka > 0 && fy == p->w_autoaka - 1 + p->w_histheight && lf - lx <= 0) naka = ty - hi >= 0 ? 1 + ty - hi : 0; lf -= lx; lt -= lx; l -= lx; if (lf == 0) { FreeMline(mlf); lf = p->w_width; if (--fy >= 0) mlf = OLDWIN(fy); } if (lt == 0) { lt = wi; if (--ty >= 0) mlt = NEWWIN(ty); } } ASSERT(l != 0 || fy == yy); } while (fy >= 0) { FreeMline(mlf); if (--fy >= 0) mlf = OLDWIN(fy); } while (ty >= 0) { if (AllocMline(mlt, wi + 1)) goto nomem; MakeBlankLine(mlt->image, wi + 1); if (--ty >= 0) mlt = NEWWIN(ty); } #ifdef DEBUG if (nmlines != p->w_mlines) for (fy = 0; fy < p->w_height + p->w_histheight; fy++) { ml = OLDWIN(fy); ASSERT(ml->image == 0); } #endif if (p->w_mlines && p->w_mlines != nmlines) free((char *)p->w_mlines); p->w_mlines = nmlines; #ifdef COPY_PASTE if (p->w_hlines && p->w_hlines != nhlines) free((char *)p->w_hlines); p->w_hlines = nhlines; #endif nmlines = nhlines = 0; /* change tabs */ if (p->w_width != wi) { if (wi) { t = p->w_tabs ? p->w_width : 0; p->w_tabs = xrealloc(p->w_tabs, wi + 1); if (p->w_tabs == 0) goto nomem; for (; t < wi; t++) p->w_tabs[t] = t && !(t & 7) ? 1 : 0; p->w_tabs[wi] = 0; } else { if (p->w_tabs) free(p->w_tabs); p->w_tabs = 0; } } /* Change w_saved.y - this is only an estimate... */ p->w_saved.y += ncy - p->w_y; p->w_x = ncx; p->w_y = ncy; if (p->w_autoaka > 0) p->w_autoaka = naka; /* do sanity checks */ if (p->w_x > wi) p->w_x = wi; if (p->w_y >= he) p->w_y = he - 1; if (p->w_saved.x > wi) p->w_saved.x = wi; if (p->w_saved.y >= he) p->w_saved.y = he - 1; if (p->w_saved.y < 0) p->w_saved.y = 0; if (p->w_alt.cursor.x > wi) p->w_alt.cursor.x = wi; if (p->w_alt.cursor.y >= he) p->w_alt.cursor.y = he - 1; if (p->w_alt.cursor.y < 0) p->w_alt.cursor.y = 0; /* reset scrolling region */ p->w_top = 0; p->w_bot = he - 1; /* signal new size to window */ #ifdef TIOCSWINSZ if (wi && (p->w_width != wi || p->w_height != he) && p->w_width != 0 && p->w_height != 0 && p->w_ptyfd >= 0 && p->w_pid) { glwz.ws_col = wi; glwz.ws_row = he; debug("Setting pty winsize.\n"); if (ioctl(p->w_ptyfd, TIOCSWINSZ, (char *)&glwz)) debug2("SetPtySize: errno %d (fd:%d)\n", errno, p->w_ptyfd); } #endif /* TIOCSWINSZ */ /* store new size */ p->w_width = wi; p->w_height = he; if(p->w_scrollback_height > hi) p->w_scrollback_height = hi; #ifdef COPY_PASTE p->w_histidx = 0; p->w_histheight = hi; #endif #ifdef BUILTIN_TELNET if (p->w_type == W_TYPE_TELNET) TelWindowSize(p); #endif #ifdef DEBUG /* Test if everything was ok */ for (fy = 0; fy < p->w_height + p->w_histheight; fy++) { ml = OLDWIN(fy); ASSERT(ml->image); # ifdef UTF8 if (p->w_encoding == UTF8) { for (l = 0; l < p->w_width; l++) ASSERT(ml->image[l] >= ' ' || ml->font[l] || ml->fontx); } else #endif for (l = 0; l < p->w_width; l++) ASSERT(ml->image[l] >= ' '); } #endif return 0; nomem: if (nmlines || nhlines) { for (ty = he + hi - 1; ty >= 0; ty--) { mlt = NEWWIN(ty); FreeMline(mlt); } if (nmlines && p->w_mlines != nmlines) free((char *)nmlines); #ifdef COPY_PASTE if (nhlines && p->w_hlines != nhlines) free((char *)nhlines); #endif } KillWindow(p); Msg(0, "%s", strnomem); return -1; } void FreeAltScreen(p) struct win *p; { int i; if (p->w_alt.mlines) { for (i = 0; i < p->w_alt.height; i++) FreeMline(p->w_alt.mlines + i); free(p->w_alt.mlines); } p->w_alt.mlines = 0; p->w_alt.width = 0; p->w_alt.height = 0; #ifdef COPY_PASTE if (p->w_alt.hlines) { for (i = 0; i < p->w_alt.histheight; i++) FreeMline(p->w_alt.hlines + i); free(p->w_alt.hlines); } p->w_alt.hlines = 0; p->w_alt.histidx = 0; p->w_alt.histheight = 0; #endif } static void SwapAltScreen(p) struct win *p; { struct mline *ml; int t; #define SWAP(item, t) do { (t) = p->w_alt. item; p->w_alt. item = p->w_##item; p->w_##item = (t); } while (0) SWAP(mlines, ml); SWAP(width, t); SWAP(height, t); #ifdef COPY_PASTE SWAP(histheight, t); SWAP(hlines, ml); SWAP(histidx, t); #endif #undef SWAP } void EnterAltScreen(p) struct win *p; { if (!p->w_alt.on) { /* If not already using the alternate screen buffer, then create a new one and swap it with the 'real' screen buffer. */ FreeAltScreen(p); SwapAltScreen(p); } else { /* Already using the alternate buffer. Just clear the screen. To do so, it is only necessary to reset the height(s) without resetting the width. */ p->w_height = 0; p->w_histheight = 0; } ChangeWindowSize(p, p->w_alt.width, p->w_alt.height, p->w_alt.histheight); p->w_alt.on = 1; } void LeaveAltScreen(p) struct win *p; { if (!p->w_alt.on) return; SwapAltScreen(p); ChangeWindowSize(p, p->w_alt.width, p->w_alt.height, p->w_alt.histheight); FreeAltScreen(p); p->w_alt.on = 0; } screen-4.8.0/terminfo/0000755000175000017500000000000013607701733013534 5ustar amadeamadescreen-4.8.0/terminfo/8bits0000644000175000017500000000132013607701733014504 0ustar amadeamade We test some umlauts and other characters coded in the ISO 8859-1 (Latin 1) standard: umlaut A umlaut a umlaut O umlaut o umlaut U umlaut u sharp s paragraph e + / e + \ e + ^ a + \ u + \ degree log. not + over - << >> fraction 1/2 fraction 1/4 power of 2 middle dot --- screen-4.8.0/terminfo/checktc.c0000644000175000017500000001055213607701733015307 0ustar amadeamade#include char *CL, *CM, *CS, *SR; int CO, LI, AM, XN; char *tgetstr(), *getenv(); void PutStr(), CPutStr(), CCPutStr(), GotoPos(), RETURN(); main() { char *term, *s; char tcbuf[1024]; char tcstr[1024], *tp; if ((term = getenv("TERM")) == 0) { fprintf(stderr, "No $TERM set\n"); exit(1); } switch (tgetent(tcbuf, term)) { case -1: fprintf(stderr, "Could not open termcap file\n"); exit(1); case 0: fprintf(stderr, "I don't know what a '%s' terminal is.\n", term); exit(1); } tp = tcstr; if ((CL = tgetstr("cl", &tp)) == 0) { fprintf(stderr, "cl capability required\n"); exit(1); } if ((CM = tgetstr("cm", &tp)) == 0) { fprintf(stderr, "cm capability required\n"); exit(1); } if ((s = getenv("COLUMNS"))) CO = atoi(s); if ((s = getenv("LINES"))) LI = atoi(s); if (CO == 0) CO = tgetnum("co"); if (LI == 0) LI = tgetnum("li"); if (CO == 0) CO = 80; if (LI == 0) LI = 24; GotoPos(5, 1); printf("******* cl capability does not work !!! *******"); GotoPos(5, 2); PutStr(CL); printf("******* cl capability does not home cursor *******"); GotoPos(0, 0); printf(" "); GotoPos(5, 4); printf("******* cm capability does not work !!! *******"); GotoPos(5, 4); printf(" "); GotoPos(CO/2-12, LI/2); printf("Your terminal size is"); GotoPos(CO/2-3, LI/2+1); printf("%dx%d", CO, LI); GotoPos(CO/2-2, 0); printf("top"); GotoPos(CO/2-3, LI-1); printf("bottom"); GotoPos(0, LI/2-2);printf("l"); GotoPos(0, LI/2-1);printf("e"); GotoPos(0, LI/2+0);printf("f"); GotoPos(0, LI/2+1);printf("t"); GotoPos(CO-1, LI/2-2);printf("r"); GotoPos(CO-1, LI/2-1);printf("i"); GotoPos(CO-1, LI/2+0);printf("g"); GotoPos(CO-1, LI/2+1);printf("h"); GotoPos(CO-1, LI/2+2);printf("t"); GotoPos(CO/2-15, LI/2+3); RETURN(); AM = tgetflag("am"); printf("Termcap: terminal does %sauto-wrap", AM ? "" : "not "); GotoPos(0, 5); if (AM) { printf(" am capability set, but terminal does not wrap"); GotoPos(CO-1, 3); } else { printf(" am capability not set, but terminal does wrap"); GotoPos(CO-1, 4); } printf(" \n "); GotoPos(0, 10); RETURN(); if (AM) { XN = tgetflag("xn"); printf("Termcap: terminal has %smagic margins", XN ? "" : "no "); GotoPos(0, 5); if ((XN = tgetflag("xn"))) { printf(" xn capability set, but terminal has no magic-margins"); GotoPos(CO-1, 4); } else { printf(" xn capability not set, but terminal has magic-margins"); GotoPos(CO-1, 3); } printf(" \n"); printf(" "); GotoPos(0, 10); RETURN(); if (XN) { GotoPos(0, 6); printf(" last col in last row is not usable"); GotoPos(CO-1, LI-1); printf(" "); GotoPos(0, 6); printf(" "); GotoPos(0, 0); printf("testing magic margins in last row"); GotoPos(0, 10); RETURN(); } } if ((CS = tgetstr("cs", &tp))) { printf("Termcap: terminal has scrollregions"); GotoPos(0, 5); printf(" cs capability set, but doesn't work"); CCPutStr(CS, 4, 5); GotoPos(0, 5); printf("\n\n"); CCPutStr(CS, 0, LI-1); GotoPos(0, 10); RETURN(); } if ((SR = tgetstr("sr", &tp))) { GotoPos(0, 5); printf(" sr capability set, but doesn't work"); GotoPos(0, 0); PutStr(SR); GotoPos(0, 6); printf(" "); GotoPos(0, 0); printf("Termcap: terminal can scroll backwards"); GotoPos(0, 10); RETURN(); } } void putcha(c) char c; { putchar(c); } void PutStr(s) char *s; { tputs(s, 1, putcha); fflush(stdout); } void CPutStr(s, c) char *s; int c; { tputs(tgoto(s, 0, c), 1, putcha); fflush(stdout); } void CCPutStr(s, x, y) char *s; int x, y; { tputs(tgoto(s, y, x), 1, putcha); fflush(stdout); } void GotoPos(x,y) int x,y; { tputs(tgoto(CM, x, y), 1, putcha); fflush(stdout); } void RETURN() { printf("Press to continue"); fflush(stdout); while(getchar() != '\n'); PutStr(CL); } screen-4.8.0/terminfo/README0000644000175000017500000000110213607701733014406 0ustar amadeamade This directory contains various file for termcap/terminfo installation and testing: screencap Termcap entry for screen. Add it to /etc/termcap. On NetBSD, you should run /usr/bin/cap_mkdb afterwards. screeninfo.src Terminfo entry. Use 'tic screeninfo.src' to install (Sun: /usr/5bin/tic). checktc.c Termcap/info test program. Checks margin handling and other things. 8bits Some chars from the ISO 8859-1 charset. test.txt Test file for alternate charset. tetris.c The popular game, by John Tromp. This is one of the winners of the 1989 IOCCC contest. screen-4.8.0/terminfo/screencap0000644000175000017500000000222313607701733015421 0ustar amadeamadeSC|screen|VT 100/ANSI X3.64 virtual terminal:\ :am:xn:ms:mi:G0:km:\ :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:\ :cb=\E[1K:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\ :do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\ :le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\ :li#24:co#80:us=\E[4m:ue=\E[24m:so=\E[3m:se=\E[23m:\ :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:sr=\EM:al=\E[L:\ :AL=\E[%dL:dl=\E[M:DL=\E[%dM:cs=\E[%i%d;%dr:dc=\E[P:\ :DC=\E[%dP:im=\E[4h:ei=\E[4l:IC=\E[%d@:\ :ks=\E[?1h\E=:ke=\E[?1l\E>:vb=\Eg:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:\ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:\ :k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:F1=\E[23~:F2=\E[24~:\ :kh=\E[1~:kI=\E[2~:kD=\E[3~:kH=\E[4~:@7=\E[4~:kP=\E[5~:\ :kN=\E[6~:eA=\E(B\E)0:as=^N:ae=^O:ti=\E[?1049h:te=\E[?1049l:\ :vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l:\ :Co#8:pa#64:AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:\ :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00: SB|screen-bce|VT 100/ANSI X3.64 virtual terminal with bce:\ :ut:tc=screen: SH|screen-s|VT 100/ANSI X3.64 virtual terminal with hardstatus line:\ :ts=\E_:fs=\E\\:ds=\E_\E\\:tc=screen: screen-4.8.0/terminfo/test.txt0000644000175000017500000011376313607701733015267 0ustar amadeamade <(A)0[?4h[?5l lqqqqqqqqqwwwqqqqqqqqqk sssssssssssssssssssssssssssss xMerry Chrxxxmas * Merx \ / xry Christxxx * Merry x pr rp xChristmasxxxMerry Chrx oqrs srqo xistmas * xxxry Christx ooppqqwqwqqppoo tqqqqqqqqqjxmqqqqqqqqqu x x tqqqqqqqqqq`qqqqqqqqqqu x x tqqqqqqqqqkxlqqqqqqqqqu x x xry Christxxx * Merry x x x xChristmasxxxMerry Chrx x x xistmas * xxxry Christx x x xmas * MerxxxChristmasx srqqj mqqrs mqqqqqqqqqvvvqqqqqqqqqj  rqpo opqr  lmxx lqmqx x lqwmqvx xx x lqwqmqvqx x x x lqwqmqvqx x x x lqwqmqvqx x x x lqwqmqvqx x x x lqwqmqvqx x x x lqwqmqvqx x x x lqwqmqvqx x x x // // //  / / //  / /// //  //// //  //// // /  //// / /  // / // // / // / //s/ //  sssssssssss / / //  // / ss  / //  //  // rrrrrrrrrrr / /s //  // qqqqqqqqq //  //  // srqqqqqqqqqrs   //  /// srrs //  //// // rrqqqqrr /  //// / / ppppppp  // / // rrqqrr // / // / rqppppqr //s/ //  rqpppooooooopppqr / / //  // / qppoooooooooooppq  / //  //  // sssssssooo ooo. o f / /s //  //.f ssss .f //  //  // f ssssrrrrqqqqqrrrrsssss s   //  ///. . . sssrrrrqqqqqqqqqrrrrsssf f . f //  //// / f . rrrqqqqpppppppppqqqqrss. . o f /  //// / /f .f qqqppppooooooooopppqrss .f . s// / // f f sssssssssqppoooo oopqrss.o . // / // /f f. . ssrrrrrrrrrsqpooo opqrssf f f . f //s/ // f o o f . ssssssrrrrssssss   f o o .. . o f s/ //  /  . o o ff .f srrrrrrqqqqqqqqqqqqqqrrssrqf o o .  .f . / //  / mqvqqqqqq lqwqqqqqq x x x x . o f rqqqqqqppppppppppppppq mqvqqqqq lqwqqqqq x x x xf .o . o /s /  mqvqqqq lqwqqqq x x x x f f [14;51 qppppppoooooooooooooo mqvqqq lqwqqq x x x xf  .f f . f s /  mqvqq lqwqq x x x x. o f o o f f poooooo  mqvq lqwq x x x x o o of o o . rrrrrrrrrrrrrrrrrrrrrrrrrrrrr   mqv lqw x x x xo  mq lq x  x  . o o of o o .  .f .  m l x x. o o f o . . . o ff f     f o o f . ff .o . o #3 Cheers! #4 Cheers!   . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . #5 #5 f . o . f o ff  .f f . f  f f f . o f o o f f .  /ooooooooooooooo\  o o of o o .. . o f  / sss sss \ o o o . o o ff .f  x (sOs) (sOs) x  . o o of o o .  .f .  x ` x . o o f o . . . o ff f  \ \sssssssss/ / f o o f . ff .o . o  \ /  . o o . o f  f f . . .  \sssssssssss/ f . o . f o ff  .f f . f  ooppqqrrsss  f f f . o f o o f f .  ooppqqrrsss  o o of o o .. . o f  ooppqqrrsss o o o . o o ff .f  ooppqqrrsss  . o o of o o .  .f .  ooppqqrrsss . o o f o . . . o ff f  ooppqqrrsss f o o f . ff .o . o  ooppqqrrsss . o o . o f  f f . . . M x ` x f . o . f o ff  .f f . f M x (sOs) (sOs) x  f f f . o f o o f f . M / sss sss \  o o of o o .. . o f M /ooooooooooooooo\ o o o . o o ff .f M  . o o of o o .  .f . M . o o f o . . . o ff f M f o o f . ff .o . o M  . o o . o f  f f . . .  \ / f . o . f o ff  .f f . f  \sssssssssss/  f f f . o f o o f f .  ooppqqrrsss  o o of o o .. . o f  ooppqqrrsss o o o . o o ff .f  ooppqqrrsss  . o o of o o .  .f .  ooppqqrrsss . o o f o . . . o ff f  ooppqqrrsssf o o f . ff .o . o M / sss sss \  . o o . o f  f f . . . M /ooooooooooooooo\ f . o . f o ff  .f f . f M  f f f . o f o o f f . M  o o of o o .. . o f  ooppqqrrsss o o o . o o ff .f  ooppqqrrsss  . o o of o o .  .f .  ooppqqrrsss . o o f o . . . o ff f  ooppqqrrsssf o o f . ff .o . o M /ooooooooooooooo\  . o o . o f  f f . . . M f . o . f o ff  .f f . f M  f f f . o f o o f f . M  o o of o o .. . o f  \sssssssssss/ o o o . o o ff .f  ooppqqrrsss  . o o of o o .  .f .  ooppqqrrsss . o o f o . . . o ff f f o o f . ff .o . o Jin  . o o . o f  f f . . . gle f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f Bells,  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f Jin  . o o of o o .  .f . gle . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f Bells,  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f Jin  f f f . o f o o f f . gle  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f all f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f . the  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f way, f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f Oh! f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f . What  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f fun f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f . it  o o of o o .. . o f is o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o to  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f ride, o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f On o o o . o o ff .f a  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . one- f . o . f o ff  .f f . f horse  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f op  f f f . o f o o f f . en  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f . sleigh.  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff f  o o of o o  . o o o   f o o     o o o . o o ff f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff f  o o of o o  . o o o   f o o     Merry Christmas  -  o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff f  o o of o o  . o o o   f o o     o o o . o o ff f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff .f  . o o of o o .  .f . . o o f o . . . o ff f f o o f . ff .o . o  . o o . o f  f f . . . f . o . f o ff  .f f . f  f f f . o f o o f f .  o o of o o .. . o f o o o . o o ff f  o o of o o  . o o o   f o o     [?4l screen-4.8.0/terminfo/tetris.c0000644000175000017500000000267413607701733015223 0ustar amadeamadelong h[4];t(){h[3]-=h[3]/3000;setitimer(0,h,0);}c,d,l,v[]={(int)t,0,2},w,s,I,K =0,i=276,j,k,q[276],Q[276],*n=q,*m,x=17,f[]={7,-13,-12,1,8,-11,-12,-1,9,-1,1, 12,3,-13,-12,-1,12,-1,11,1,15,-1,13,1,18,-1,1,2,0,-12,-1,11,1,-12,1,13,10,-12, 1,12,11,-12,-1,1,2,-12,-1,12,13,-12,12,13,14,-11,-1,1,4,-13,-12,12,16,-11,-12, 12,17,-13,1,-1,5,-12,12,11,6,-12,12,24};u(){for(i=11;++i<264;)if((k=q[i])-Q[i] ){Q[i]=k;if(i-++I||i%12<1)printf("\033[%d;%dH",(I=i)/12,i%12*2+28);printf( "\033[%dm "+(K-k?0:5),k);K=k;}Q[263]=c=getchar();}G(b){for(i=4;i--;)if(q[i?b+ n[i]:b])return 0;return 1;}g(b){for(i=4;i--;q[i?x+n[i]:x]=b);}main(C,V,a)char* *V,*a;{h[3]=1000000/(l=C>1?atoi(V[1]):2);for(a=C>2?V[2]:"jkl pq";i;i--)*n++=i< 25||i%12<2?7:0;srand(getpid());system("stty cbreak -echo stop u");sigvec(14,v, 0);t();puts("\033[H\033[J");for(n=f+rand()%7*4;;g(7),u(),g(0)){if(c<0){if(G(x+ 12))x+=12;else{g(7);++w;for(j=0;j<252;j=12*(j/12+1))for(;q[++j];)if(j%12==10){ for(;j%12;q[j--]=0);u();for(;--j;q[j+12]=q[j]);u();}n=f+rand()%7*4;G(x=17)||(c =a[5]);}}if(c==*a)G(--x)||++x;if(c==a[1])n=f+4**(m=n),G(x)||(n=m);if(c==a[2])G (++x)||--x;if(c==a[3])for(;G(x+12);++w)x+=12;if(c==a[4]||c==a[5]){s=sigblock( 8192);printf("\033[H\033[J\033[0m%d\n",w);if(c==a[5])break;for(j=264;j--;Q[j]= 0);while(getchar()-a[4]);puts("\033[H\033[J\033[7m");sigsetmask(s);}}d=popen( "stty -cbreak echo stop \023;sort -mnr -o HI - HI;cat HI","w");fprintf(d, "%4d from level %1d by %s\n",w,l,getlogin());pclose(d);} screen-4.8.0/terminfo/screeninfo.src0000644000175000017500000000764413607701733016413 0ustar amadeamadescreen|VT 100/ANSI X3.64 virtual terminal, am, km, mir, msgr, xenl, cols#80, it#8, lines#24, colors#8, pairs#64, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\b, cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, home=\E[H, ht=\t, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n, is2=\E)0, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kend=\E[4~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[23m, rmul=\E[24m, rs2=\Ec, sc=\E7, sgr0=\E[m, smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[3m, smul=\E[4m, tbc=\E[3g, smacs=^N, rmacs=^O, flash=\Eg, civis=\E[?25l, cnorm=\E[34h\E[?25h, cvvis=\E[34l, op=\E[39;49m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++\054\054hhII00, screen-bce|VT 100/ANSI X3.64 virtual terminal with bce, am, bce, km, mir, msgr, xenl, cols#80, it#8, lines#24, colors#8, pairs#64, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\b, cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, home=\E[H, ht=\t, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n, is2=\E)0, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kend=\E[4~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[23m, rmul=\E[24m, rs2=\Ec, sc=\E7, sgr0=\E[m, smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[3m, smul=\E[4m, tbc=\E[3g, smacs=^N, rmacs=^O, flash=\Eg, civis=\E[?25l, cnorm=\E[34h\E[?25h, cvvis=\E[34l, op=\E[39;49m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++\054\054hhII00, screen-s|VT 100/ANSI X3.64 virtual terminal with hardstatus line, am, bce, hs, km, mir, msgr, xenl, cols#80, it#8, lines#24, colors#8, pairs#64, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\b, cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, home=\E[H, ht=\t, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n, is2=\E)0, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kend=\E[4~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[23m, rmul=\E[24m, rs2=\Ec, sc=\E7, sgr0=\E[m, smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[3m, smul=\E[4m, tbc=\E[3g, smacs=^N, rmacs=^O, flash=\Eg, tsl=\E_, fsl=\E\\, dsl=\E_\E\\, civis=\E[?25l, cnorm=\E[34h\E[?25h, cvvis=\E[34l, op=\E[39;49m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++\054\054hhII00, screen-256color|VT 100/ANSI X3.64 virtual terminal, ccc, colors#256, pairs#32767, initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, setab=\E[48;5;%p1%dm, setaf=\E[38;5;%p1%dm, setb=\E[48;5;%p1%dm, setf=\E[38;5;%p1%dm, use=screen, screen-4.8.0/doc/0000755000175000017500000000000013616622356012461 5ustar amadeamadescreen-4.8.0/doc/FAQ0000644000175000017500000003340113616620402013002 0ustar amadeamade jw 21.10.93 05.05.94 screen: frequently asked questions -- known problems -- unimplemented bugs =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Q: Why is it impossible to download a file with Kermit/sz/rz when screen is running? Do I need to set some special variables? A: Screen always interprets control-sequences sent by the applications and translates/optimizes them for the current terminal type. Screen always parses the user input for its escape character (CTRL-A). Both are basic screen features and cannot be switched off. Even if it were possible to switch screen into a completely transparent mode, you could never switch between windows, while kermit/sz/rz is downloading a file. You must wait til the end as kermit/sz/rz will not transmit your input during a file transfer and as kermit/sz/rz would be very confused if screen switched away the window containing the other kermit/sz/rz. Simply detach your screen session for each file transfer and start the transfer program only from the shell where you started screen. Q: I am using screen with a YYY terminal, which supports the XXX graphic language. I am very happy with it, except one thing: I cannot render graphics into screen windows. A: You are out of luck there. Screen provides a fixed set of escape sequences in order to make it possible to switch terminal types. Screen has to know exactly what the escape sequences do to the terminal because it must hold an image in memory. Otherwise screen could not restore the image if you switch to another window. Because of this you have to change screens escape sequence parser (ansi.c) to pass the XXX graphics sequences to the terminal. Of course the graphics will be lost if you switch to another window. Screen will only honour graphics sequences that are demanded by an overwhelming majority. Q: For some unknown reason, the fifo in /tmp/screens/S-myname is gone, and i can't resume my screen session. Is there a way to recreate the fifo? A: Screen checks the fifo/socket whenever it receives a SIGCHLD signal. If missing, the fifo/socket is recreated then. If screen is running non set-uid the user can issue a 'kill -CHLD screenpid' directly (it is -CHILD on some systems). Screenpid is the process-id of the screen process found in a 'ps -x' listing. But usually this won't work, as screen should be installed set- uid root. In this case you will not be able to send it a signal, but the kernel will. It does so, whenever a child of screen changes its state. Find the process-id (shellpid below) of the "least important" shell running inside screen. The try 'kill -STOP shellpid'. If the fifo/socket does not reappear, destroy the shell process. You sacrify one shell to save the rest. If nothing works, please do not forget to remove all processes running in the lost screen session. Q: When you start "screen" a page of text comes up to start you off. Is there a way to get rid of this text as a command line argument or by using a switch of some sort. A: Just put the following line in your ~/.screenrc: startup_message off Many peole ask this, although it is in the man page, too :-) Q: Start "screen emacs" and run emacs function suspend-emacs (ctrl-z). The window containing emacs vanishes. A: This is a known bug. Unfortunatly there is no easy fix because this is specified in the POSIX standard. When a new window is created Screen opens up a new session because the window has to get the pty as a controlling terminal (a session can only have one controlling terminal). With the setsid() call the process also creates a new process group. This process group is orphaned, because there is no process in the session which is not in the process group. Now if the process group leader (i.e. your program) gets a TTIN/TTOU/TSTP, POSIX states that the kernel must send a KILL signal to the process group because there is no one left to continue the process. Even if screen would try to restart the program, that would be after it received the KILL signal which cannot be caught or ignored. tromey@klab.caltech.edu (Tom Tromey): I've noticed this exact same problem. I put this in my .emacs file. It seems to work: ;; If running under screen, disable C-z. (if (and (getenv "STY") (not window-system)) (global-unset-key "\C-z")) Q: Screen gets the terminal size wrong and messes up. A: Before you start screen: Check with 'stty -a' what the terminal driver thinks about rows and columns. Check the environment variables LINES and COLUMNS. Then from within screen check with the info command (CTRL-A i) what size screen thinks your terminal is. If correcting tty driver setting and environment variables does not help, look up the terminal capability definition. First the TERMCAP environment variable. If this is not set, look up the terminals name as defined in the environment variable TERM in /etc/termcap or in the terminfo database with untic or infocmp. There may be :li=...: and :co=...: or even :ll=...: entries (cols#... and lines#... when it's terminfo) defined incorrectly. Either construct your own TERMCAP environment variables with correct settings, use screens terminfo/termcap command in your .screenrc file or have the database corrected by the system administrator. Q: Screen messes up the terminal output when I use my favourite ap- plication. Setting the terminal size does not help. A: Probably you got the termcap/terminfo entries wrong. Fixing this is a three stage procedure. First, find out if terminfo or termcap is used. If your system only has /etc/termcap, but not /usr/lib/terminfo/... then you are using termcap. Easy. But if your system has both, then it depends how the appli- cation and how screen were linked. Beware, if your applica- tion runs on another host via rlogin, telnet or the like, you should check the terminfo/termcap databases there. If you cannot tell if terminfo or termcap is used (or you just want to be save), the do all steps in stage 3 in parallel for both systems (on all envolved hosts). Second: Understand the basic rules how screen does its terminal emulation. When screen is started or reattached, it relies on the TERM environment variable to correctly reflect the terminal type you have physically in front of you. And the entry should either exist in the system terminfo/termcap database or be specified via the TERMCAP en- vironment variable (if screen is using the termcap system). On the other end, screen understands one set of control codes. It relies on the application using these codes. This means applica- tions that run under screen must be able to adapt their con- trol codes to screen. The application should use the TERM vari- able and termcap or terminfo library to find out how to drive its terminal. When running under screen, the terminal is virtual and is only defined by the set of control codes that screen understands. The TERM variable is automatically set to "screen" and the "screen"-entries should exist in the data- bases. If your application uses hardcoded control codes rather than a database, you are on your own. Hint: The codes under- stood by screen are a superset of the very common definition named "vt100". Look at the documentation of screen. The codes are listed there. Third: Have the entry "screen" in- stalled on all hosts or make sure you can live with "vt100". Check the codes sent by your application, when the TERM variable is set to "screen". Do not try to set the TERM variable inside screen to anything other than "screen" or "vt100" or compati- ble. Thus your application can drive screen correctly. Also take care that a good entry is installed for your physical terminal that screen has to drive. Even if the entry was good enough for your application to drive the terminal directly, screen may find flaws, as it tries to use other capabilities while op- timizing the screen output. The screenrc commands "termcap" and/or "terminfo" may help to fine-tune capabilities without calling the supervisor to change the database. Q: I cannot configure screen. Sed does not work. A: The regular expressions used in our configure scrip are too complicated for GNU sed version 2.03. In this regard it is bug compatible with Ultrix 3.1 "sed": GNU sed version 2.03 dumps core with our configure script. Try an older release. E.g. from ftp.uni-erlangen.de:/pub/utilities/screen/sed-2.02b.tar.gz Q: When reattaching a session from a different Workstation, the DISPLAY environment variable should be updated. Even ``CTLR-A : setenv DISPLAY newhost:0'' does not work as expected. A: Under unix every process has its own environment. The environ- ment of the SCREEN process can be changed with the `setenv' com- mand. This however cannot affect the environment of the shells or applications already running under screen. Subsequently spawned processes will reflect the changes. One should be aware of this problem when running applications from very old shells. Screen is a means for keeping processes alive. Q: About once every 5 times I ran the program, rather than getting a "screen," I got someone elses IRC output/input. A: What probably happened is that an IRC process was left running on a pseudo tty in such a way that the kernel thought the tty was available for reallocation. You can fix this behaviour by applying the SunOS 4.1.x tty jumbo patch (100513-04). Q: Screen compiled on SunOS 5.3 cannot reattach a detached session. A: You are using /usr/ucb/cc, this compiler is wrong. Actually it links with a C-library that mis-interprets dirent. Try again with /opt/SUNWspro/bin/cc! Q: The "talk" command does not work when Screen is active. A: Talk and several other programs rely on entries in the Utmp- Database (/etc/utmp). On some systems this Database is world writable, on others it is not. If it is not, screen must be installed with the appropriate permissions (user or group s-bit) just like any program that uses PTYs (rlogin, xterm, ...). When screen cannot write to utmp, you will see messages on you display which do not belong to any screen window. When screen can update utmp, it is not guaranteed that it does as you expect. First this depends on the config.h file defining UTMPOK, LOGINDEFAULT, and perhaps CAREFULUTMP. Second it depends on the screenrc files (system wide and per user), if utmp entries are done. Third, you can control whether windows are logged in with screens ``login'' command. Q: Seteuid() does not work as expected in AIX. Attempting a multi- user-attach results in a screen-panic: "seteuid: not owner". A: This is not a screen problem. According to Kay Nettle (pkn@cs.utexas.edu) you need the AIX patch PTF 423674. Q: When I type cd directory (any directory or just blank) from within one of the windows in screen, the whole thing just freezes up. A: You display the current working directory in xterm's title bar, This may be caused by hardcoded ESC-sequences in the shell prompt or in an cd alias. In Xterm the coding is ESC ] n ; string_to_display ^G where n = 1, 2, 3 selects the location of the displayed string. Screen misinterprets this as the ansi operating system comment sequence: ESC ] osc_string and waits (according to ansi) for the string terminator ESC \ Screen versions after 3.5.12 may provide a workaround. Q: Mesg or biff cannot be turned on or off while running screen. A: Screen failed to change the owner of the pty it uses. You need to install screen setuid-root. See the file INSTALL for details. Q: The cursor left key deletes the characters instead of just moving the cursor. A redisplay (^Al) brings everything back. A: Your terminal emulator treats the backspace as "destructive". You can probably change this somewhere in the setup. We can't think of a reason why anybody would want a destructive backspace, but if you really must have it, add the lines termcap 'bc@:bs@' terminfo 'bc@:bs@' to your ~/.screenrc (replace with the terminal type your emulator uses). Q: I have an old SysV OS (like Motorola SysV68) and sometimes screen doesn't reset the attributes correctly. A redisplay (^Al) doesn't make things better. A: The libcurses library has a bug if attributes are cleared with the special ue/se capabilities. As a workaround (other than upgrading your system) modify 'rmul' (and 'rmso'?) in screen's terminfo entry: rmul=\E[m, rmso=\E[m screen-4.8.0/doc/make.help0000644000175000017500000000402713607701733014250 0ustar amadeamade###### ###### ###### The following lines should be obsolete because of the 'configure' script. ###### It is here only for reference if 'configure' needs human help. ###### ### If you choose to compile with the tried and true: #CC= cc #CFLAGS= -O #CFLAGS= -g ### gcc specific CFLAGS: #CC= gcc # If your system include files are bad, don't use -Wall #CFLAGS= -O6 -g #-Wall #CFLAGS = -g -fstrength-reduce -fcombine-regs -finline-functions #-Wall ### On some machines special CFLAGS are required: #M_CFLAGS= #M_CFLAGS= -D__NetBSD__ # NetBsd Machines like this (a.kalb@rrze) #M_CFLAGS= -Dapollo -A cpu,mathchip -A nansi # Apollo DN3000/4000/4500 #M_CFLAGS= -DISC -D_POSIX_SOURCE # isc #M_CFLAGS= -systype bsd43 -DMIPS # mips #M_CFLAGS= -fforce-mem -fforce-addr\ # -fomit-frame-pointer -finline-functions -bsd # NeXT #M_CFLAGS= -qlanglvl=ansi # RS6000/AIX #M_CFLAGS= -qlanglvl=ansi -D_AIX32 # RS6000/AIX 3.2 #M_CFLAGS= -ansi # sgi/IRIX 3.x ansi #M_CFLAGS= -xansi # sgi/IRIX 4.x ext ansi #M_CFLAGS= -YBSD # Ultrix 4.x #M_CFLAGS= -DSVR4=1 # Bob Kline rvk@blink.att.com 80386 Unix SVR4.0 #M_CFLAGS= -D_CX_UX # Ken Beal kbeal@amber.ssd.csd.harris.com Harris CX/UX #M_CFLAGS= -K pentium # Thanh Ma tma@encore.com Unixware, SVR4-2 ### Choose one of the LIBS setting below: #LIBS= -ltermcap -lc -lsocket -linet -lsec -lseq # Sequent/ptx #LIBS= -lcurses -lelf -lcrypt -lsocket -lnsl # Solaris, when it sucks #LIBS= -ltermcap # SunOS, Linux, Apollo, # gould_np1, NeXT, Ultrix #LIBS= -ltermcap -lelf # SVR4 #LIBS= -ltermlib -linet -lcposix # isc #LIBS= -ltermcap -lmld # mips (nlist is in mld) #LIBS= -ltermlib -lsun -lmld #-lc_s # sgi/IRIX #LIBS= -lcurses # RS6000/AIX #LIBS= -lcrypt_d -ltinfo # sco32 #LIBS= -lcrypt_i -ltinfo # sco32 #LIBS= -lcrypt -lsec # sco322 (msilano@sra.com) #LIBS= -ltermcap -lcrypt.o -ldir -lx # SCO XENIX 2.3.4 #LIBS= -ltermcap -lcrypt -ldir -l2.3 -lx # SCO UNIX XENIX cross dev. #LIBS= -ltermcap -lelf -lcrypt -lsocket -lnet -lnsl # Bob Kline SVR4 #LIBS= -lcurses -lelf -lcrypt -lgen # Thanh Ma, Unixware, SVR4-2 screen-4.8.0/doc/install.sh0000777000175000017500000000000013607701733016672 2../install.shustar amadeamadescreen-4.8.0/doc/fdpat.ps0000644000175000017500000022530613607701733014130 0ustar amadeamade%!PS-Adobe-2.0 EPSF-1.2 %%DocumentFonts: Courier Helvetica-Bold Times-Roman %%Pages: 1 %%BoundingBox: 5 34 589 773 %%EndComments /arrowHeight 10 def /arrowWidth 5 def /IdrawDict 53 dict def IdrawDict begin /reencodeISO { dup dup findfont dup length dict begin { 1 index /FID ne { def }{ pop pop } ifelse } forall /Encoding ISOLatin1Encoding def currentdict end definefont } def /ISOLatin1Encoding [ /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright /parenleft/parenright/asterisk/plus/comma/minus/period/slash /zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon /less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N /O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright /asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m /n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve /dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut /ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar /section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot /hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior /acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine /guillemotright/onequarter/onehalf/threequarters/questiondown /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute /Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis /aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave /iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex /otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis /yacute/thorn/ydieresis ] def /Courier reencodeISO def /Helvetica-Bold reencodeISO def /Times-Roman reencodeISO def /none null def /numGraphicParameters 17 def /stringLimit 65535 def /Begin { save numGraphicParameters dict begin } def /End { end restore } def /SetB { dup type /nulltype eq { pop false /brushRightArrow idef false /brushLeftArrow idef true /brushNone idef } { /brushDashOffset idef /brushDashArray idef 0 ne /brushRightArrow idef 0 ne /brushLeftArrow idef /brushWidth idef false /brushNone idef } ifelse } def /SetCFg { /fgblue idef /fggreen idef /fgred idef } def /SetCBg { /bgblue idef /bggreen idef /bgred idef } def /SetF { /printSize idef /printFont idef } def /SetP { dup type /nulltype eq { pop true /patternNone idef } { dup -1 eq { /patternGrayLevel idef /patternString idef } { /patternGrayLevel idef } ifelse false /patternNone idef } ifelse } def /BSpl { 0 begin storexyn newpath n 1 gt { 0 0 0 0 0 0 1 1 true subspline n 2 gt { 0 0 0 0 1 1 2 2 false subspline 1 1 n 3 sub { /i exch def i 1 sub dup i dup i 1 add dup i 2 add dup false subspline } for n 3 sub dup n 2 sub dup n 1 sub dup 2 copy false subspline } if n 2 sub dup n 1 sub dup 2 copy 2 copy false subspline patternNone not brushLeftArrow not brushRightArrow not and and { ifill } if brushNone not { istroke } if 0 0 1 1 leftarrow n 2 sub dup n 1 sub dup rightarrow } if end } dup 0 4 dict put def /Circ { newpath 0 360 arc patternNone not { ifill } if brushNone not { istroke } if } def /CBSpl { 0 begin dup 2 gt { storexyn newpath n 1 sub dup 0 0 1 1 2 2 true subspline 1 1 n 3 sub { /i exch def i 1 sub dup i dup i 1 add dup i 2 add dup false subspline } for n 3 sub dup n 2 sub dup n 1 sub dup 0 0 false subspline n 2 sub dup n 1 sub dup 0 0 1 1 false subspline patternNone not { ifill } if brushNone not { istroke } if } { Poly } ifelse end } dup 0 4 dict put def /Elli { 0 begin newpath 4 2 roll translate scale 0 0 1 0 360 arc patternNone not { ifill } if brushNone not { istroke } if end } dup 0 1 dict put def /Line { 0 begin 2 storexyn newpath x 0 get y 0 get moveto x 1 get y 1 get lineto brushNone not { istroke } if 0 0 1 1 leftarrow 0 0 1 1 rightarrow end } dup 0 4 dict put def /MLine { 0 begin storexyn newpath n 1 gt { x 0 get y 0 get moveto 1 1 n 1 sub { /i exch def x i get y i get lineto } for patternNone not brushLeftArrow not brushRightArrow not and and { ifill } if brushNone not { istroke } if 0 0 1 1 leftarrow n 2 sub dup n 1 sub dup rightarrow } if end } dup 0 4 dict put def /Poly { 3 1 roll newpath moveto -1 add { lineto } repeat closepath patternNone not { ifill } if brushNone not { istroke } if } def /Rect { 0 begin /t exch def /r exch def /b exch def /l exch def newpath l b moveto l t lineto r t lineto r b lineto closepath patternNone not { ifill } if brushNone not { istroke } if end } dup 0 4 dict put def /Text { ishow } def /idef { dup where { pop pop pop } { exch def } ifelse } def /ifill { 0 begin gsave patternGrayLevel -1 ne { fgred bgred fgred sub patternGrayLevel mul add fggreen bggreen fggreen sub patternGrayLevel mul add fgblue bgblue fgblue sub patternGrayLevel mul add setrgbcolor eofill } { eoclip originalCTM setmatrix pathbbox /t exch def /r exch def /b exch def /l exch def /w r l sub ceiling cvi def /h t b sub ceiling cvi def /imageByteWidth w 8 div ceiling cvi def /imageHeight h def bgred bggreen bgblue setrgbcolor eofill fgred fggreen fgblue setrgbcolor w 0 gt h 0 gt and { l b translate w h scale w h true [w 0 0 h neg 0 h] { patternproc } imagemask } if } ifelse grestore end } dup 0 8 dict put def /istroke { gsave brushDashOffset -1 eq { [] 0 setdash 1 setgray } { brushDashArray brushDashOffset setdash fgred fggreen fgblue setrgbcolor } ifelse brushWidth setlinewidth originalCTM setmatrix stroke grestore } def /ishow { 0 begin gsave fgred fggreen fgblue setrgbcolor printFont printSize scalefont setfont /descender 0 printFont /FontBBox get 1 get printFont /FontMatrix get transform exch pop def /vertoffset 1 printSize sub descender sub def { 0 vertoffset moveto show /vertoffset vertoffset printSize sub def } forall grestore end } dup 0 2 dict put def /patternproc { 0 begin /patternByteLength patternString length def /patternHeight patternByteLength 8 mul sqrt cvi def /patternWidth patternHeight def /patternByteWidth patternWidth 8 idiv def /imageByteMaxLength imageByteWidth imageHeight mul stringLimit patternByteWidth sub min def /imageMaxHeight imageByteMaxLength imageByteWidth idiv patternHeight idiv patternHeight mul patternHeight max def /imageHeight imageHeight imageMaxHeight sub store /imageString imageByteWidth imageMaxHeight mul patternByteWidth add string def 0 1 imageMaxHeight 1 sub { /y exch def /patternRow y patternByteWidth mul patternByteLength mod def /patternRowString patternString patternRow patternByteWidth getinterval def /imageRow y imageByteWidth mul def 0 patternByteWidth imageByteWidth 1 sub { /x exch def imageString imageRow x add patternRowString putinterval } for } for imageString end } dup 0 12 dict put def /min { dup 3 2 roll dup 4 3 roll lt { exch } if pop } def /max { dup 3 2 roll dup 4 3 roll gt { exch } if pop } def /midpoint { 0 begin /y1 exch def /x1 exch def /y0 exch def /x0 exch def x0 x1 add 2 div y0 y1 add 2 div end } dup 0 4 dict put def /thirdpoint { 0 begin /y1 exch def /x1 exch def /y0 exch def /x0 exch def x0 2 mul x1 add 3 div y0 2 mul y1 add 3 div end } dup 0 4 dict put def /subspline { 0 begin /movetoNeeded exch def y exch get /y3 exch def x exch get /x3 exch def y exch get /y2 exch def x exch get /x2 exch def y exch get /y1 exch def x exch get /x1 exch def y exch get /y0 exch def x exch get /x0 exch def x1 y1 x2 y2 thirdpoint /p1y exch def /p1x exch def x2 y2 x1 y1 thirdpoint /p2y exch def /p2x exch def x1 y1 x0 y0 thirdpoint p1x p1y midpoint /p0y exch def /p0x exch def x2 y2 x3 y3 thirdpoint p2x p2y midpoint /p3y exch def /p3x exch def movetoNeeded { p0x p0y moveto } if p1x p1y p2x p2y p3x p3y curveto end } dup 0 17 dict put def /storexyn { /n exch def /y n array def /x n array def n 1 sub -1 0 { /i exch def y i 3 2 roll put x i 3 2 roll put } for } def %%EndProlog %%BeginIdrawPrologue /arrowhead { 0 begin transform originalCTM itransform /taily exch def /tailx exch def transform originalCTM itransform /tipy exch def /tipx exch def /dy tipy taily sub def /dx tipx tailx sub def /angle dx 0 ne dy 0 ne or { dy dx atan } { 90 } ifelse def gsave originalCTM setmatrix tipx tipy translate angle rotate newpath arrowHeight neg arrowWidth 2 div moveto 0 0 lineto arrowHeight neg arrowWidth 2 div neg lineto patternNone not { originalCTM setmatrix /padtip arrowHeight 2 exp 0.25 arrowWidth 2 exp mul add sqrt brushWidth mul arrowWidth div def /padtail brushWidth 2 div def tipx tipy translate angle rotate padtip 0 translate arrowHeight padtip add padtail add arrowHeight div dup scale arrowheadpath ifill } if brushNone not { originalCTM setmatrix tipx tipy translate angle rotate arrowheadpath istroke } if grestore end } dup 0 9 dict put def /arrowheadpath { newpath arrowHeight neg arrowWidth 2 div moveto 0 0 lineto arrowHeight neg arrowWidth 2 div neg lineto } def /leftarrow { 0 begin y exch get /taily exch def x exch get /tailx exch def y exch get /tipy exch def x exch get /tipx exch def brushLeftArrow { tipx tipy tailx taily arrowhead } if end } dup 0 4 dict put def /rightarrow { 0 begin y exch get /tipy exch def x exch get /tipx exch def y exch get /taily exch def x exch get /tailx exch def brushRightArrow { tipx tipy tailx taily arrowhead } if end } dup 0 4 dict put def %%EndIdrawPrologue %I Idraw 10 Grid 8.86154 8.86154 %%Page: 1 1 Begin %I b u %I cfg u %I cbg u %I f u %I p u %I t [ .959646 0 0 .959646 0 0 ] concat /originalCTM matrix currentmatrix def Begin %I Line %I b 65535 0 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg none SetP %I p n %I t [ .833333 -0 -0 .833333 -23.3333 378.333 ] concat %I 37 397 764 397 Line %I 1 End Begin %I Line %I b 65535 0 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg none SetP %I p n %I t [ .833333 -0 -0 .833333 -23.3333 282.5 ] concat %I 37 397 764 397 Line %I 1 End Begin %I Line %I b 65535 0 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg none SetP %I p n %I t [ .833333 -0 -0 .833333 -24.1667 185.833 ] concat %I 37 397 764 397 Line %I 1 End Begin %I Line %I b 65535 0 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg none SetP %I p n %I t [ .833333 -0 -0 .833333 -23.3333 -5.83331 ] concat %I 37 397 764 397 Line %I 1 End Begin %I Line %I b 65535 0 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg none SetP %I p n %I t [ .833333 -0 -0 .833333 -23.3333 -101.667 ] concat %I 37 397 764 397 Line %I 1 End Begin %I Line %I b 65535 0 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg none SetP %I p n %I t [ .833333 -0 -0 .833333 -23.3333 -197.5 ] concat %I 37 397 764 397 Line %I 1 End Begin %I Line %I b 65535 0 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg none SetP %I p n %I t [ .833333 -0 -0 .833333 -23.3333 392.5 ] concat %I 37 34 764 34 Line %I 1 End Begin %I Line %I b 65535 0 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg none SetP %I p n %I t [ .833333 -0 -0 .833333 -15.8333 2.5 ] concat %I 258 963 258 41 Line %I 1 End Begin %I Line %I b 65535 0 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg none SetP %I p n %I t [ .833333 -0 -0 .833333 198.833 3 ] concat %I 258 963 258 41 Line %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 213.667 797 ] concat %I [ (Subshell, error back) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 428 797 ] concat %I [ (Input echo filter) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 22.8333 704.333 ] concat %I [ (Input filter) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 214.833 704.333 ] concat %I [ (Input Filter, error back) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 428.833 704.333 ] concat %I [ (input filter, error echo) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 214 607.5 ] concat %I [ (Output filter) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 428 607.5 ] concat %I [ (Error robot) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 15 729.966 ] concat %I [ (...) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 15 57.4667 ] concat %I [ (...) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 214.167 57.4667 ] concat %I [ (...) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 428.333 57.4667 ] concat %I [ (...) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 45.8332 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 45.8332 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 45.8332 ] concat %I 2 55 743 143 743 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -50.0001 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -50.0001 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -57.5001 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -50.0001 ] concat %I 2 55 743 143 743 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -50.0001 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -50.0001 ] concat %I 5 489 760 471 760 462 760 462 752 462 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 134.167 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 2 55 743 143 743 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -145.833 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -153.333 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 0 -671.666 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 -214.167 -671.666 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 199.166 -671.666 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 5 444 707 444 760 444 778 471 778 489 778 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 141.667 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 141.667 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 134.167 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 141.667 ] concat %I 2 55 743 143 743 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 141.667 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 428.333 729.966 ] concat %I [ (..: .:. .::) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 45.8332 ] concat %I 2 55 743 143 743 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 30.8334 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 45 ] concat %I 5 444 707 444 760 444 778 471 778 489 778 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 141.667 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 141.667 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 141.667 ] concat %I 2 55 743 143 743 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 141.667 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 134.167 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 175.833 237.5 ] concat %I 6 400 619 391 619 365 619 365 645 391 645 489 645 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 141.667 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 15 633.3 ] concat %I [ (.!.) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 45.8333 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 38.3334 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -237.5 45.8332 ] concat %I 5 453 707 453 752 453 769 471 769 489 769 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 45.8333 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 214.167 633.3 ] concat %I [ (.!!) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 45.8332 ] concat %I 5 453 707 453 752 453 769 471 769 489 769 5 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 214.167 729.966 ] concat %I [ (..!) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 45.8332 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 45.8332 ] concat %I 2 55 743 143 743 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 45.8334 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 175.833 45.8332 ] concat %I 5 453 707 453 752 453 769 471 769 489 769 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 175.833 141.667 ] concat %I 6 400 619 391 619 365 619 365 645 391 645 489 645 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 45.8333 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 428.333 633.3 ] concat %I [ (.!:) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 15 537.466 ] concat %I [ (.:!) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -236.667 -50.8333 ] concat %I 5 444 707 444 760 444 778 471 778 489 778 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -237.5 45.8333 ] concat %I 6 400 619 391 619 365 619 365 645 391 645 489 645 6 BSpl %I 1 End Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t u Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 -214.167 6.10352e-05 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 199.166 7.62939e-05 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 0 -95.8334 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 -214.167 -95.8333 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 199.166 -95.8333 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 214.167 537.466 ] concat %I [ (!..) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 189.167 -50 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 -57.5 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 -50.8333 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 175.833 -50.0001 ] concat %I 5 489 760 471 760 462 760 462 752 462 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -50 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -57.5 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -50.8333 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 176.667 -50 ] concat %I 5 444 707 444 760 444 778 471 778 489 778 5 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 428.333 537.466 ] concat %I [ (!.!) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 22 607.5 ] concat %I [ (Input echo filter, error back) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 21.1667 510.833 ] concat %I [ (Robot) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 15 441.633 ] concat %I [ (!!.) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -237.5 -145.833 ] concat %I 5 489 760 471 760 462 760 462 752 462 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -237.5 -145.833 ] concat %I 5 453 707 453 752 453 769 471 769 489 769 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -145.833 ] concat %I 5 489 760 471 760 462 760 462 752 462 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -145.833 ] concat %I 5 453 707 453 752 453 769 471 769 489 769 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -145.833 ] concat %I 5 444 707 444 760 444 778 471 778 489 778 5 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 214.167 441.633 ] concat %I [ (!!!) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 427.167 510.833 ] concat %I [ (Full robot, error echo) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 175.833 -145.833 ] concat %I 5 489 760 471 760 462 760 462 752 462 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 175.833 -145.833 ] concat %I 5 453 707 453 752 453 769 471 769 489 769 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -146.667 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 6 639 388 630 388 586 388 586 433 631 433 728 433 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 5 684 361 684 379 684 388 675 388 657 388 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 334.167 ] concat %I 5 684 361 684 379 684 388 675 388 657 388 5 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 428.333 441.633 ] concat %I [ (!!:) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -237.5 -241.667 ] concat %I 5 489 760 471 760 462 760 462 752 462 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -242.5 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 6 143 273 134 273 99 273 99 309 134 309 232 309 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -242.5 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 -214.167 -191.667 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 0 -191.667 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 199.166 -191.667 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 15 345.8 ] concat %I [ (!:!) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 213.167 510.833 ] concat %I [ (Full robot) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 214.167 345.8 ] concat %I [ (!:: !:. !.:) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 213.167 415 ] concat %I [ (Full robot, out & error echo) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -241.667 ] concat %I 5 489 760 471 760 462 760 462 752 462 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 -242.5 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 141.667 ] concat %I 6 143 273 134 273 99 273 99 309 134 309 232 309 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 -242.5 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -38.3333 -4.16667 ] concat %I 5 471 652 471 661 471 679 454 679 436 679 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 189.167 -242.5 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 199.166 -287.5 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 0 -287.5 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 -214.167 -287.5 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 428.333 345.8 ] concat %I [ (:..) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 427.167 415 ] concat %I [ (Output echo filter) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -242.5 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -242.5 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -242.5 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -242.5 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -249.167 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -242.5 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 199.166 -383.333 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 0 -383.333 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 -214.167 -383.333 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -38.3333 -4.16667 ] concat %I 6 657 484 649 484 622 484 622 457 649 457 657 457 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -339.167 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -339.167 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -345.833 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -339.167 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -451.667 -100.833 ] concat %I 6 657 484 649 484 622 484 622 457 649 457 657 457 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -236.667 -338.333 ] concat %I 5 444 707 444 752 444 778 471 778 489 778 5 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 21.1667 415 ] concat %I [ (Full Robot, output echo) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 21.1667 319.167 ] concat %I [ (Output echo filter, error back) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 15 249.967 ] concat %I [ (:.!) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190 -339.167 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190 -339.167 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 427.167 319.167 ] concat %I [ (Robot, input echo) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 21.1667 223.333 ] concat %I [ (Full robot, input echo) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 427.167 223.333 ] concat %I [ (Full robot, input & output echo) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 213.167 223.333 ] concat %I [ (Full robot, input & error echo) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 213.167 319.167 ] concat %I [ (Full robot, full echo) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 214.167 249.967 ] concat %I [ (::: ::. :.:) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 428.333 249.967 ] concat %I [ (:!.) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 15 154.133 ] concat %I [ (:!!) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 214.167 154.133 ] concat %I [ (:!:) ] Text End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-helvetica-bold-r-*-140-* Helvetica-Bold 14 SetF %I t [ 1.6 0 0 1.6 428.333 154.133 ] concat %I [ (::!) ] Text End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190 -338.333 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -15.8333 .833333 ] concat %I 6 391 353 382 353 365 353 365 336 382 336 391 336 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 .833333 ] concat %I 6 400 327 391 327 356 327 356 363 391 363 489 362 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 .833364 ] concat %I 2 489 353 312 353 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 .833364 ] concat %I 2 400 327 312 327 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -339.167 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -338.333 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 184.167 .833333 ] concat %I 6 391 353 382 353 365 353 365 336 382 336 391 336 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 176.667 .833364 ] concat %I 2 489 353 312 353 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 175.833 -337.5 ] concat %I 5 453 707 453 752 453 769 471 769 489 769 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -345.833 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -435 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -229.167 -95 ] concat %I 6 391 353 382 353 365 353 365 336 382 336 391 336 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -236.667 -94.9999 ] concat %I 2 489 353 312 353 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -237.5 -433.333 ] concat %I 5 453 707 453 752 453 769 471 769 489 769 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3332 -441.667 ] concat %I 2 143 734 55 734 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -236.667 -434.166 ] concat %I 5 444 707 444 752 444 778 471 778 489 778 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190 -435 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190 -434.167 ] concat %I 5 188 707 188 716 188 725 179 725 161 725 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -15.8333 -95 ] concat %I 6 391 353 382 353 365 353 365 336 382 336 391 336 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -94.9999 ] concat %I 2 489 353 312 353 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 -94.9999 ] concat %I 2 400 327 312 327 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -24.1669 -434.166 ] concat %I 5 453 707 453 752 453 769 471 769 489 769 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 .833333 ] concat %I 5 188 415 188 460 188 486 214 486 233 486 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 -338.333 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 -242.5 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3332 -145.833 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3332 -353.333 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -338.333 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3332 -434.167 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3332 -249.167 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 190.833 -145.833 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390.833 -145.833 ] concat %I 2 232 778 55 778 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 389.167 -435 ] concat %I 5 161 743 179 743 205 743 205 716 205 707 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 183.333 -95 ] concat %I 6 391 353 382 353 365 353 365 336 382 336 391 336 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 175.833 -94.9999 ] concat %I 2 489 353 312 353 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 175.833 -94.9999 ] concat %I 2 400 327 312 327 2 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 390 -434.167 ] concat %I 5 196 707 196 716 196 734 179 734 161 734 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 176.667 -434.167 ] concat %I 5 444 707 444 760 444 778 471 778 489 778 5 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 .833333 ] concat %I 2 728 247 551 247 2 BSpl %I 1 End Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 -214.167 -480 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 0 -480 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 199.166 -480 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 199.166 -575.833 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 -0.000432014 -575.833 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I Pict %I b 65535 1 0 0 [] 0 SetB %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 -214.167 -575.833 ] concat Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 214.167 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 143 716 161 716 161 752 143 752 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 99.8333 758.833 ] concat %I [ (P) ] Text End End %I eop Begin %I Pict %I b u %I cfg u %I cbg u %I f u %I p u %I t [ 1 0 0 1 221.667 -0.000366211 ] concat Begin %I Poly %I b 65535 2 0 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 -23.3333 141.667 ] concat %I 4 223 752 241 752 241 787 223 787 4 Poly End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 164 788.416 ] concat %I [ (W) ] Text End End %I eop Begin %I Text %I cfg Black 0 0 0 SetCFg %I f *-times-medium-r-*-140-* Times-Roman 14 SetF %I t [ 1 0 0 1 344.333 725.833 ] concat %I [ (210) ] Text End End %I eop Begin %I BSpl %I b 65535 1 0 1 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 125 181.667 ] concat %I 6 222 -5 213 -5 169 -5 169 39 240 39 311 39 6 BSpl %I 1 End Begin %I BSpl %I b 65535 1 1 0 [] 0 SetB %I cfg Black 0 0 0 SetCFg %I cbg White 1 1 1 SetCBg %I p 1 SetP %I t [ .833333 -0 -0 .833333 125 181.667 ] concat %I 2 222 39 134 39 2 BSpl %I 1 End Begin %I Text %I cfg Black 0 0 0 SetCFg %I f -*-courier-medium-r-normal-*-8-*-*-*-*-*-*-* Courier 8 SetF %I t [ 1 0 0 1 22 797 ] concat %I [ (Subshell) ] Text End End %I eop showpage %%Trailer end screen-4.8.0/doc/screen.texinfo0000644000175000017500000071113113616622032015331 0ustar amadeamade\input texinfo @c -*-texinfo-*- @c %**start of header @c vi:set wm=5 @documentencoding ISO-8859-15 @setfilename screen.info @settitle Screen User's Manual @dircategory General Commands @finalout @setchapternewpage odd @c %**end of header @set version 4.8.0 @direntry * Screen: (screen). Full-screen window manager. @end direntry @c For examples, use a literal escape in info. @ifinfo @set esc ^[ @end ifinfo @iftex @set esc @end iftex @ifinfo This file documents the @code{Screen} virtual terminal manager. Copyright (c) 1993-2018 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @ignore Permission is granted to process this file through TeX and print the results, provided the printed document carries copying permission notice identical to this one except for the removal of this paragraph (this paragraph not being relevant to the printed manual). @end ignore Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation. @end ifinfo @titlepage @title Screen @subtitle The virtual terminal manager @subtitle for Version @value{version} @subtitle Feb 2020 @page @vskip 0pt plus 1filll Copyright @copyright{} 1993-2018 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation. @end titlepage @shortcontents @contents @node Top, Overview, (dir), (dir) @ifinfo @top Screen This file documents the @code{Screen} virtual terminal manager, version @value{version}. @end ifinfo @menu * Overview:: Preliminary information. * Getting Started:: An introduction to @code{screen}. * Invoking Screen:: Command line options for @code{screen}. * Customization:: The @file{.screenrc} file. * Commands:: List all of the commands. * New Window:: Running a program in a new window. * Selecting:: Selecting a window to display. * Session Management:: Suspend/detach, grant access, connect sessions. * Regions:: Split-screen commands. * Window Settings:: Titles, logging, etc. * Virtual Terminal:: Controlling the @code{screen} VT100 emulation. * Copy and Paste:: Exchanging text between windows and sessions. * Subprocess Execution:: I/O filtering with @code{exec}. * Key Binding:: Binding commands to keys. * Flow Control:: Trap or pass flow control characters. * Termcap:: Tweaking your terminal's termcap entry. * Message Line:: The @code{screen} message line. * Logging:: Keeping a record of your session. * Startup:: Functions only useful at @code{screen} startup. * Miscellaneous:: Various other commands. * String Escapes:: Inserting current information into strings * Environment:: Environment variables used by @code{screen}. * Files:: Files used by @code{screen}. * Credits:: Who's who of @code{screen}. * Bugs:: What to do if you find a bug. * Installation:: Getting @code{screen} running on your system. * Concept Index:: Index of concepts. * Command Index:: Index of all @code{screen} commands. * Keystroke Index:: Index of default key bindings. @end menu @node Overview, Getting Started, Top, Top @chapter Overview @cindex overview Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. Each virtual terminal provides the functions of the DEC VT100 terminal and, in addition, several control functions from the ISO 6429 (ECMA 48, ANSI X3.64) and ISO 2022 standards (e.g. insert/delete line and support for multiple character sets). There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows the user to move text regions between windows. When @code{screen} is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill the current window, view a list of the active windows, turn output logging on and off, copy text between windows, view the scrollback history, switch between windows, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the user's terminal. When a program terminates, @code{screen} (per default) kills the window that contained it. If this window was in the foreground, the display switches to the previously displayed window; if none are left, @code{screen} exits. Shells usually distinguish between running as login-shell or sub-shell. Screen runs them as sub-shells, unless told otherwise (See @code{shell} .screenrc command). Everything you type is sent to the program running in the current window. The only exception to this is the one keystroke that is used to initiate a command to the window manager. By default, each command begins with a control-a (abbreviated @kbd{C-a} from now on), and is followed by one other keystroke. The command character (@pxref{Command Character}) and all the key bindings (@pxref{Key Binding}) can be fully customized to be anything you like, though they are always two characters in length. @code{Screen} does not understand the prefix @kbd{C-} to mean control, although this notation is used in this manual for readability. Please use the caret notation (@kbd{^A} instead of @kbd{C-a}) as arguments to e.g. the @code{escape} command or the @code{-e} option. @code{Screen} will also print out control characters in caret notation. The standard way to create a new window is to type @kbd{C-a c}. This creates a new window running a shell and switches to that window immediately, regardless of the state of the process running in the current window. Similarly, you can create a new window with a custom command in it by first binding the command to a keystroke (in your @file{.screenrc} file or at the @kbd{C-a :} command line) and then using it just like the @kbd{C-a c} command. In addition, new windows can be created by running a command like: @example screen emacs prog.c @end example @noindent from a shell prompt within a previously created window. This will not run another copy of @code{screen}, but will instead supply the command name and its arguments to the window manager (specified in the $STY environment variable) who will use it to create the new window. The above example would start the @code{emacs} editor (editing @file{prog.c}) and switch to its window. - Note that you cannot transport environment variables from the invoking shell to the application (emacs in this case), because it is forked from the parent screen process, not from the invoking shell. If @file{/etc/utmp} is writable by @code{screen}, an appropriate record will be written to this file for each window, and removed when the window is closed. This is useful for working with @code{talk}, @code{script}, @code{shutdown}, @code{rsend}, @code{sccs} and other similar programs that use the utmp file to determine who you are. As long as @code{screen} is active on your terminal, the terminal's own record is removed from the utmp file. @xref{Login}. @node Getting Started, Invoking Screen, Overview, Top @chapter Getting Started @cindex introduction Before you begin to use @code{screen} you'll need to make sure you have correctly selected your terminal type, just as you would for any other termcap/terminfo program. (You can do this by using @code{tset}, @code{qterm}, or just @code{set term=mytermtype}, for example.) If you're impatient and want to get started without doing a lot more reading, you should remember this one command: @kbd{C-a ?} (@pxref{Key Binding}). Typing these two characters will display a list of the available @code{screen} commands and their bindings. Each keystroke is discussed in the section on keystrokes (@pxref{Default Key Bindings}). Another section (@pxref{Customization}) deals with the contents of your @file{.screenrc}. If your terminal is a ``true'' auto-margin terminal (it doesn't allow the last position on the screen to be updated without scrolling the screen) consider using a version of your terminal's termcap that has automatic margins turned @emph{off}. This will ensure an accurate and optimal update of the screen in all circumstances. Most terminals nowadays have ``magic'' margins (automatic margins plus usable last column). This is the VT100 style type and perfectly suited for @code{screen}. If all you've got is a ``true'' auto-margin terminal @code{screen} will be content to use it, but updating a character put into the last position on the screen may not be possible until the screen scrolls or the character is moved into a safe position in some other way. This delay can be shortened by using a terminal with insert-character capability. @xref{Special Capabilities}, for more information about telling @code{screen} what kind of terminal you have. @node Invoking Screen, Customization, Getting Started, Top @chapter Invoking @code{Screen} @cindex invoking @cindex options @cindex command line options Screen has the following command-line options: @table @samp @item -a Include @emph{all} capabilities (with some minor exceptions) in each window's termcap, even if @code{screen} must redraw parts of the display in order to implement a function. @item -A Adapt the sizes of all windows to the size of the display. By default, @code{screen} may try to restore its old window sizes when attaching to resizable terminals (those with @samp{WS} in their descriptions, e.g. @code{suncmd} or some varieties of @code{xterm}). @item -c @var{file} Use @var{file} as the user's configuration file instead of the default of @file{$HOME/.screenrc}. @item -d [@var{pid.sessionname}] @itemx -D [@var{pid.sessionname}] Do not start @code{screen}, but instead detach a @code{screen} session running elsewhere (@pxref{Detach}). @samp{-d} has the same effect as typing @kbd{C-a d} from the controlling terminal for the session. @samp{-D} is the equivalent to the power detach key. If no session can be detached, this option is ignored. In combination with the @code{-r}/@code{-R} option more powerful effects can be achieved: @table @code @item -d -r Reattach a session and if necessary detach it first. @item -d -R Reattach a session and if necessary detach or even create it first. @item -d -RR Reattach a session and if necessary detach or create it. Use the first session if more than one session is available. @item -D -r Reattach a session. If necessary detach and logout remotely first. @item -D -R Attach here and now. In detail this means: If a session is running, then reattach. If necessary detach and logout remotely first. If it was not running create it and notify the user. This is the author's favorite. @item -D -RR Attach here and now. Whatever that means, just do it. @end table @emph{Note}: It is a good idea to check the status of your sessions with @code{screen -list} before using this option. @item -e @var{xy} Set the command character to @var{x}, and the character generating a literal command character (when typed after the command character) to @var{y}. The defaults are @kbd{C-a} and @kbd{a}, which can be specified as @samp{-e^Aa}. When creating a @code{screen} session, this option sets the default command character. In a multiuser session all users added will start off with this command character. But when attaching to an already running session, this option only changes the command character of the attaching user. This option is equivalent to the commands @code{defescape} or @code{escape} respectively. (@pxref{Command Character}). @item -f @itemx -fn @itemx -fa Set flow-control to on, off, or automatic switching mode, respectively. This option is equivalent to the @code{defflow} command (@pxref{Flow Control}). @item -h @var{num} Set the history scrollback buffer to be @var{num} lines high. Equivalent to the @code{defscrollback} command (@pxref{Copy}). @item -i Cause the interrupt key (usually @kbd{C-c}) to interrupt the display immediately when flow control is on. This option is equivalent to the @code{interrupt} argument to the @code{defflow} command (@pxref{Flow Control}). Its use is discouraged. @item -l @itemx -ln Turn login mode on or off (for @file{/etc/utmp} updating). This option is equivalent to the @code{deflogin} command (@pxref{Login}). @item -ls [@var{match}] @itemx -list [@var{match}] Do not start @code{screen}, but instead print a list of session identification strings (usually of the form @var{pid.tty.host}; @pxref{Session Name}). Sessions marked @samp{detached} can be resumed with @code{screen -r}. Those marked @samp{attached} are running and have a controlling terminal. If the session runs in multiuser mode, it is marked @samp{multi}. Sessions marked as @samp{unreachable} either live on a different host or are dead. An unreachable session is considered dead, when its name matches either the name of the local host, or the specified parameter, if any. See the @code{-r} flag for a description how to construct matches. Sessions marked as @samp{dead} should be thoroughly checked and removed. Ask your system administrator if you are not sure. Remove sessions with the @samp{-wipe} option. @item -L Tell @code{screen} to turn on automatic output logging for the windows. @item -Logfile "file" By default logfile name is "screenlog.0". You can set new logfile name with the @code{-Logfile} option. @item -m Tell @code{screen} to ignore the @code{$STY} environment variable. When this option is used, a new session will always be created, regardless of whether @code{screen} is being called from within another @code{screen} session or not. This flag has a special meaning in connection with the @samp{-d} option: @table @code @item -d -m Start @code{screen} in @emph{detached} mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts. @item -D -m This also starts @code{screen} in @emph{detached} mode, but doesn't fork a new process. The command exits if the session terminates. @end table @item -O Select a more optimal output mode for your terminal rather than true VT100 emulation (only affects auto-margin terminals without @samp{LP}). This can also be set in your @file{.screenrc} by specifying @samp{OP} in the @code{termcap} command. @item -p @var{name_or_number}|-|=|+ Preselect a window. This is useful when you want to reattach to a specific window or you want to send a command via the @samp{-X} option to a specific window. As with screen's select command, @samp{-} selects the blank window. As a special case for reattach, @samp{=} brings up the windowlist on the blank window, while a @samp{+} will create new window. The command will not be executed if the specified window could not be found. @item -q Suppress printing of error messages. In combination with @samp{-ls} the exit value is set as follows: 9 indicates a directory without sessions. 10 indicates a directory with running but not attachable sessions. 11 (or more) indicates 1 (or more) usable sessions. In combination with @samp{-r} the exit value is as follows: 10 indicates that there is no session to resume. 12 (or more) indicates that there are 2 (or more) sessions to resume and you should specify which one to choose. In all other cases @samp{-q} has no effect. @item -Q Some commands now can be queried from a remote session using this flag, e.g. 'screen -Q windows'. The commands will send the response to the stdout of the querying process. If there was an error in the command, then the querying process will exit with a non-zero status. The commands that can be queried now are: @code{echo} @code{info} @code{lastmsg} @code{number} @code{select} @code{time} @code{title} @code{windows} @item -r [@var{pid.sessionname}] @itemx -r @var{sessionowner}/[@var{pid.sessionname}] Resume a detached @code{screen} session. No other options (except combinations with @samp{-d} or @samp{-D}) may be specified, though the session name (@pxref{Session Name}) may be needed to distinguish between multiple detached @code{screen} sessions. The second form is used to connect to another user's screen session which runs in multiuser mode. This indicates that screen should look for sessions in another user's directory. This requires setuid-root. @item -R resumes screen only when it's unambiguous which one to attach, usually when only one @code{screen} is detached. Otherwise lists available sessions. @item -RR Resume the first appropriate detached @code{screen} session. If successful, all other command-line options are ignored. If no detached session exists, start a new session using the specified options, just as if @samp{-R} had not been specified. This option is set by default if screen is run as a login-shell (actually screen uses @samp{-xRR} in that case). For combinations with the @samp{-D}/@samp{-d} option see there. @item -s @var{program} Set the default shell to be @var{program}. By default, @code{screen} uses the value of the environment variable @code{$SHELL}, or @file{/bin/sh} if it is not defined. This option is equivalent to the @code{shell} command (@pxref{Shell}). See also there. @item -S @var{sessionname} Set the name of the new session to @var{sessionname}. This option can be used to specify a meaningful name for the session in place of the default @var{tty.host} suffix. This name identifies the session for the @code{screen -list} and @code{screen -r} commands. This option is equivalent to the @code{sessionname} command (@pxref{Session Name}). @item -t @var{name} Set the title (name) for the default shell or specified program. This option is equivalent to the @code{shelltitle} command (@pxref{Shell}). @item -T @var{term} Set the $TERM enviroment variable using the specified @emph{term} as opposed to the default setting of @code{screen}. @item -U Run screen in UTF-8 mode. This option tells screen that your terminal sends and understands UTF-8 encoded characters. It also sets the default encoding for new windows to @samp{utf8}. @item -v Print the version number. @item -wipe [@var{match}] List available screens like @code{screen -ls}, but remove destroyed sessions instead of marking them as @samp{dead}. An unreachable session is considered dead, when its name matches either the name of the local host, or the explicitly given parameter, if any. See the @code{-r} flag for a description how to construct matches. @item -x Attach to a session which is already attached elsewhere (multi-display mode). @code{Screen} refuses to attach from within itself. But when cascading multiple screens, loops are not detected; take care. @item -X Send the specified command to a running screen session. You may use the @code{-S} option to specify the screen session if you have several running. You can use the @code{-d} or @code{-r} option to tell screen to look only for attached or detached screen sessions. Note that this command doesn't work if the session is password protected. @end table @node Customization, Commands, Invoking Screen, Top @chapter Customizing @code{Screen} @cindex customization You can modify the default settings for @code{screen} to fit your tastes either through a personal @file{.screenrc} file which contains commands to be executed at startup, or on the fly using the @code{colon} command. @menu * Startup Files:: The @file{.screenrc} file. * Source:: Read commands from a file. * Colon:: Entering customization commands interactively. @end menu @node Startup Files, Source, , Customization @section The @file{.screenrc} file @cindex .screenrc @cindex screenrc When @code{screen} is invoked, it executes initialization commands from the files @file{.screenrc} in the user's home directory and @file{/usr/local/etc/screenrc}. These defaults can be overridden in the following ways: For the global screenrc file @code{screen} searches for the environment variable @code{$SYSSCREENRC} (this override feature may be disabled at compile-time). The user specific screenrc file is searched for in @code{$SCREENRC}, then @file{@code{$HOME}/.screenrc}. The command line option @samp{-c} specifies which file to use (@pxref{Invoking Screen}. Commands in these files are used to set options, bind commands to keys, and to automatically establish one or more windows at the beginning of your @code{screen} session. Commands are listed one per line, with empty lines being ignored. A command's arguments are separated by tabs or spaces, and may be surrounded by single or double quotes. A @samp{#} turns the rest of the line into a comment, except in quotes. Unintelligible lines are warned about and ignored. Commands may contain references to environment variables. The syntax is the shell-like @code{$VAR} or @code{$@{VAR@}}. Note that this causes incompatibility with previous @code{screen} versions, as now the '$'-character has to be protected with '\' if no variable substitution is intended. A string in single-quotes is also protected from variable substitution. Two configuration files are shipped as examples with your screen distribution: @file{etc/screenrc} and @file{etc/etcscreenrc}. They contain a number of useful examples for various commands. @node Source, Colon, Startup Files, Customization @section Source @deffn Command source file (none)@* Read and execute commands from file @var{file}. Source commands may be nested to a maximum recursion level of ten. If @var{file} is not an absolute path and screen is already processing a source command, the parent directory of the running source command file is used to search for the new command file before screen's current directory. Note that termcap/terminfo/termcapinfo commands only work at startup and reattach time, so they must be reached via the default screenrc files to have an effect. @end deffn @node Colon, , Source, Customization @section Colon Customization can also be done online, with this command: @kindex : @deffn Command colon (@kbd{C-a :})@* Allows you to enter @file{.screenrc} command lines. Useful for on-the-fly modification of key bindings, specific window creation and changing settings. Note that the @code{set} keyword no longer exists, as of version 3.3. Change default settings with commands starting with @samp{def}. You might think of this as the @code{ex} command mode of @code{screen}, with @code{copy} as its @code{vi} command mode (@pxref{Copy and Paste}). @end deffn @node Commands, New Window, Customization, Top @chapter Commands A command in @code{screen} can either be bound to a key, invoked from a screenrc file, or called from the @code{colon} prompt (@pxref{Customization}). As of version 3.3, all commands can be bound to keys, although some may be less useful than others. For a number of real life working examples of the most important commands see the files @file{etc/screenrc} and @file{etc/etcscreenrc} of your screen distribution. In this manual, a command definition looks like this: @table @asis @item -- Command: command [-n] ARG1 [ARG2] @dots{} (@var{keybindings})@* This command does something, but I can't remember what. @end table An argument in square brackets (@samp{[]}) is optional. Many commands take an argument of @samp{on} or @samp{off}, which is indicated as @var{state} in the definition. @menu * Default Key Bindings:: @code{screen} keyboard commands. * Command Summary:: List of all commands. @end menu @node Default Key Bindings, Command Summary, , Commands @section Default Key Bindings As mentioned previously, each keyboard command consists of a @kbd{C-a} followed by one other character. For your convenience, all commands that are bound to lower-case letters are also bound to their control character counterparts (with the exception of @kbd{C-a a}; see below). Thus, both @kbd{C-a c} and @kbd{C-a C-c} can be used to create a window. The following table shows the default key bindings: @table @asis @item @kbd{C-a '} (select)@* Prompt for a window identifier and switch. @xref{Selecting}. @item @kbd{C-a "} (windowlist -b)@* Present a list of all windows for selection. @xref{Selecting}. @item @kbd{C-a 0@dots{}9, -} (select 0@dots{}select 9, select -)@* Switch to window number 0@dots{}9, or the blank window. @xref{Selecting}. @item @kbd{C-a @key{Tab}} (focus)@* Switch the input focus to the next region. @xref{Regions}. @item @kbd{C-a C-a} (other)@* Toggle to the window displayed previously. If this window does no longer exist, @code{other} has the same effect as @code{next}. @xref{Selecting}. @item @kbd{C-a a} (meta)@* Send the command character (C-a) to window. See @code{escape} command. @xref{Command Character}. @item @kbd{C-a A} (title)@* Allow the user to enter a title for the current window. @xref{Naming Windows}. @item @kbd{C-a b} @itemx @kbd{C-a C-b} (break)@* Send a break to the tty. @xref{Break}. @item @kbd{C-a B} (pow_break)@* Close and reopen the tty-line. @xref{Break}. @item @kbd{C-a c} @itemx @kbd{C-a C-c} (screen)@* Create a new window with a shell and switch to that window. @xref{Screen Command}. @item @kbd{C-a C} (clear)@* Clear the screen. @xref{Clear}. @item @kbd{C-a d} @itemx @kbd{C-a C-d} (detach)@* Detach @code{screen} from this terminal. @xref{Detach}. @item @kbd{C-a D D} (pow_detach)@* Detach and logout. @xref{Power Detach}. @item @kbd{C-a f} @itemx @kbd{C-a C-f} (flow)@* Cycle flow among @samp{on}, @samp{off} or @samp{auto}. @xref{Flow}. @item @kbd{C-a F} (fit)@* Resize the window to the current region size. @xref{Fit}. @item @kbd{C-a C-g} (vbell)@* Toggle visual bell mode. @xref{Bell}. @item @kbd{C-a h} (hardcopy)@* Write a hardcopy of the current window to the file ``hardcopy.@var{n}''. @xref{Hardcopy}. @item @kbd{C-a H} (log)@* Toggle logging of the current window to the file ``screenlog.@var{n}''. @xref{Log}. @item @kbd{C-a i} @itemx @kbd{C-a C-i} (info)@* Show info about the current window. @xref{Info}. @item @kbd{C-a k} @itemx @kbd{C-a C-k} (kill)@* Destroy the current window. @xref{Kill}. @item @kbd{C-a l} @itemx @kbd{C-a C-l} (redisplay)@* Fully refresh the current window. @xref{Redisplay}. @item @kbd{C-a L} (login)@* Toggle the current window's login state. @xref{Login}. @item @kbd{C-a m} @itemx @kbd{C-a C-m} (lastmsg)@* Repeat the last message displayed in the message line. @xref{Last Message}. @item @kbd{C-a M} (monitor) Toggle monitoring of the current window. @xref{Monitor}. @item @kbd{C-a @key{SPC}} @itemx @kbd{C-a n} @itemx @kbd{C-a C-n} (next)@* Switch to the next window. @xref{Selecting}. @item @kbd{C-a N} (number)@* Show the number (and title) of the current window. @xref{Number}. @item @kbd{C-a p} @itemx @kbd{C-a C-p} @itemx @kbd{C-a C-h} @itemx @kbd{C-a @key{BackSpace}} (prev)@* Switch to the previous window (opposite of @kbd{C-a n}). @xref{Selecting}. @item @kbd{C-a q} @itemx @kbd{C-a C-q} (xon)@* Send a ^Q (ASCII XON) to the current window. @xref{XON/XOFF}. @item @kbd{C-a Q} (only)@* Delete all regions but the current one. @xref{Regions}. @item @kbd{C-a r} @itemx @kbd{C-a C-r} (wrap)@* Toggle the current window's line-wrap setting (turn the current window's automatic margins on or off). @xref{Wrap}. @item @kbd{C-a s} @itemx @kbd{C-a C-s} (xoff)@* Send a ^S (ASCII XOFF) to the current window. @xref{XON/XOFF}. @item @kbd{C-a S} (split)@* Split the current region horizontally into two new ones. @xref{Regions}. @item @kbd{C-a t} @itemx @kbd{C-a C-t} (time)@* Show the load average and xref. @xref{Time}. @item @kbd{C-a v} (version)@* Display the version and compilation date. @xref{Version}. @item @kbd{C-a C-v} (digraph)@* Enter digraph. @xref{Digraph}. @item @kbd{C-a w} @itemx @kbd{C-a C-w} (windows)@* Show a list of active windows. @xref{Windows}. @item @kbd{C-a W} (width)@* Toggle between 80 and 132 columns. @xref{Window Size}. @item @kbd{C-a x} @itemx @kbd{C-a C-x} (lockscreen)@* Lock your terminal. @xref{Lock}. @item @kbd{C-a X} (remove)@* Kill the current region. @xref{Regions}. @item @kbd{C-a z} @itemx @kbd{C-a C-z} (suspend)@* Suspend @code{screen}. @xref{Suspend}. @item @kbd{C-a Z} (reset)@* Reset the virtual terminal to its ``power-on'' values. @xref{Reset}. @item @kbd{C-a .} (dumptermcap)@* Write out a @file{.termcap} file. @xref{Dump Termcap}. @item @kbd{C-a ?} (help)@* Show key bindings. @xref{Help}. @item @kbd{C-a \} (quit)@* Kill all windows and terminate @code{screen}. @xref{Quit}. @item @kbd{C-a :} (colon)@* Enter a command line. @xref{Colon}. @item @kbd{C-a [} @itemx @kbd{C-a C-[} @itemx @kbd{C-a @key{ESC}} (copy)@* Enter copy/scrollback mode. @xref{Copy}. @item @kbd{C-a ]} @itemx @kbd{C-a C-]} (paste .)@* Write the contents of the paste buffer to the stdin queue of the current window. @xref{Paste}. @item @kbd{C-a @{} @itemx @kbd{C-a @}} (history)@* Copy and paste a previous (command) line. @xref{History}. @item @kbd{C-a >} (writebuf)@* Write the paste buffer out to the screen-exchange file. @xref{Screen Exchange}. @item @kbd{C-a <} (readbuf)@* Read the screen-exchange file into the paste buffer. @xref{Screen Exchange}. @item @kbd{C-a =} (removebuf)@* Delete the screen-exchange file. @xref{Screen Exchange}. @item @kbd{C-a _} (silence)@* Start/stop monitoring the current window for inactivity. @xref{Monitor}. @item @kbd{C-a |} (split -v)@* Split the current region vertically into two new ones. @xref{Regions}. @item @kbd{C-a ,} (license)@* Show the copyright page. @xref{License}. @item @kbd{C-a *} (displays)@* Show the listing of attached displays. @xref{Displays}. @end table @node Command Summary, , Default Key Bindings, Commands @section Command Summary @cindex command summary @table @code @item acladd @var{usernames} Allow other users in this session. @xref{Multiuser Session}. @item aclchg @var{usernames permbits list} Change a user's permissions. @xref{Multiuser Session}. @item acldel @var{username} Disallow other user in this session. @xref{Multiuser Session}. @item aclgrp @var{usrname} [@var{groupname}] Inherit permissions granted to a group leader. @xref{Multiuser Session}. @item aclumask [@var{users}]+/-@var{bits} ... Predefine access to new windows. @xref{Umask}. @item activity @var{message} Set the activity notification message. @xref{Monitor}. @item addacl @var{usernames} Synonym to @code{acladd}. @xref{Multiuser Session}. @item allpartial @var{state} Set all windows to partial refresh. @xref{Redisplay}. @item altscreen @var{state} Enables support for the "alternate screen" terminal capability. @xref{Redisplay}. @item at [@var{ident}][@kbd{#}@var{|}@kbd{*}@var{|}@kbd{%}] @var{command} [@var{args}] Execute a command at other displays or windows. @xref{At}. @item attrcolor @var{attrib} [@var{attribute/color-modifier}] Map attributes to colors. @xref{Attrcolor}. @item autodetach @var{state} Automatically detach the session on SIGHUP. @xref{Detach}. @item autonuke @var{state} Enable a clear screen to discard unwritten output. @xref{Autonuke}. @item backtick @var{id} @var{lifespan} @var{autorefresh} @var{command} [@var{args}] Define a command for the backtick string escape. @xref{Backtick}. @item bce [@var{state}] Change background color erase. @xref{Character Processing}. @item bell_msg [@var{message}] Set the bell notification message. @xref{Bell}. @item bind [-c @var{class}] @var{key} [@var{command} [@var{args}]] Bind a command to a key. @xref{Bind}. @item bindkey [@var{opts}] [@var{string} [@var{cmd args}]] Bind a string to a series of keystrokes. @xref{Bindkey}. @item blanker Blank the screen. @xref{Screen Saver}. @item blankerprg Define a blanker program. @xref{Screen Saver}. @item break [@var{duration}] Send a break signal to the current window. @xref{Break}. @item breaktype [@var{tcsendbreak} | @var{TCSBRK} | @var{TIOCSBRK}] Specify how to generate breaks. @xref{Break}. @item bufferfile [@var{exchange-file}] Select a file for screen-exchange. @xref{Screen Exchange}. @item bumpleft Swaps window with previous one on window list. @xref{Bumpleft}. @item bumpright Swaps window with previous one on window list. @xref{Bumpright}. @item c1 [@var{state}] Change c1 code processing. @xref{Character Processing}. @item caption @var{mode} [@var{string}] Change caption mode and string. @xref{Regions}. @item chacl @var{usernames permbits list} Synonym to @code{aclchg}. @xref{Multiuser Session}. @item charset @var{set} Change character set slot designation. @xref{Character Processing}. @item chdir [@var{directory}] Change the current directory for future windows. @xref{Chdir}. @item cjkwidth Treat ambiguous width characters as full/half width. @xref{Character Processing}. @item clear Clear the window screen. @xref{Clear}. @item colon Enter a @code{screen} command. @xref{Colon}. @item collapse Reorders window on window list, removing number gaps between them. @xref{Collapse}. @item command [-c @var{class}] Simulate the screen escape key. @xref{Command Character}. @item compacthist [@var{state}] Selects compaction of trailing empty lines. @xref{Scrollback}. @item console [@var{state}] Grab or ungrab console output. @xref{Console}. @item copy Enter copy mode. @xref{Copy}. @item copy_reg [@var{key}] Removed. Use @code{paste} instead. @xref{Registers}. @item crlf @var{state} Select line break behavior for copying. @xref{Line Termination}. @item debug @var{state} Suppress/allow debugging output. @xref{Debug}. @item defautonuke @var{state} Select default autonuke behavior. @xref{Autonuke}. @item defbce @var{state} Select background color erase. @xref{Character Processing}. @item defbreaktype [@var{tcsendbreak} | @var{TCSBRK} | @var{TIOCSBRK}] Specify the default for generating breaks. @xref{Break}. @item defc1 @var{state} Select default c1 processing behavior. @xref{Character Processing}. @item defcharset [@var{set}] Change defaul character set slot designation. @xref{Character Processing}. @item defencoding @var{enc} Select default window encoding. @xref{Character Processing}. @item defescape @var{xy} Set the default command and @code{meta} characters. @xref{Command Character}. @item defflow @var{fstate} Select default flow control behavior. @xref{Flow}. @item defgr @var{state} Select default GR processing behavior. @xref{Character Processing}. @item defhstatus [@var{status}] Select default window hardstatus line. @xref{Hardstatus}. @item deflog @var{state} Select default window logging behavior. @xref{Log}. @item deflogin @var{state} Select default utmp logging behavior. @xref{Login}. @item defmode @var{mode} Select default file mode for ptys. @xref{Mode}. @item defmonitor @var{state} Select default activity monitoring behavior. @xref{Monitor}. @item defmousetrack @var{on}|@var{off} Select the default mouse tracking behavior. @xref{Mousetrack}. @item defnonblock @var{state}|@var{numsecs} Select default nonblock mode. @xref{Nonblock}. @item defobuflimit @var{limit} Select default output buffer limit. @xref{Obuflimit}. @item defscrollback @var{num} Set default lines of scrollback. @xref{Scrollback}. @item defshell @var{command} Set the default program for new windows. @xref{Shell}. @item defsilence @var{state} Select default idle monitoring behavior. @xref{Monitor}. @item defslowpaste @var{msec} Select the default inter-character timeout when pasting. @xref{Paste}. @item defutf8 @var{state} Select default character encoding. @xref{Character Processing}. @item defwrap @var{state} Set default line-wrapping behavior. @xref{Wrap}. @item defwritelock @var{on|off|auto} Set default writelock behavior. @xref{Multiuser Session}. @item zombie_timeout [@var{seconds}] Try to reconnect dead windows after timeout. @xref{Zombie}. @item detach [-h] Disconnect @code{screen} from the terminal. @xref{Detach}. @item digraph [@var{preset} [@var{unicode-value}]] Enter a digraph sequence. @xref{Digraph}. @item dinfo Display terminal information. @xref{Info}. @item displays List currently active user interfaces. @xref{Displays}. @item dumptermcap Write the window's termcap entry to a file. @xref{Dump Termcap}. @item echo [-n] @var{message} Display a message on startup. @xref{Startup}. @item encoding @var{enc} [@var{denc}] Set the encoding of a window. @xref{Character Processing}. @item escape @var{xy} Set the command and @code{meta} characters. @xref{Command Character}. @item eval @var{command1} [@var{command2} ...] Parse and execute each argument. @xref{Eval}. @item exec [[@var{fdpat}] @var{command} [@var{args} ...]] Run a subprocess (filter). @xref{Exec}. @item fit Change window size to current display size. @xref{Window Size}. @item flow [@var{fstate}] Set flow control behavior. @xref{Flow}. @item focus [@code{next}|@code{prev}|@code{up}|@code{down}|@code{left}|@code{right}|@code{top}|@code{bottom}] Move focus to next region. @xref{Regions}. @item focusminsize Force the current region to a certain size. @xref{Focusminsize}. @item gr [@var{state}] Change GR charset processing. @xref{Character Processing}. @item group [@var{grouptitle}] Change or show the group the current window belongs to. @xref{Window Groups}. @item hardcopy [-h] [@var{file}] Write out the contents of the current window. @xref{Hardcopy}. @item hardcopy_append @var{state} Append to hardcopy files. @xref{Hardcopy}. @item hardcopydir @var{directory} Place, where to dump hardcopy files. @xref{Hardcopy}. @item hardstatus [@var{state}] Use the hardware status line. @xref{Hardware Status Line}. @item height [@var{lines} [@var{cols}]] Set display height. @xref{Window Size}. @item help [-c @var{class}] Display current key bindings. @xref{Help}. @item history Find previous command beginning @dots{}. @xref{History}. @item hstatus @var{status} Change the window's hardstatus line. @xref{Hardstatus}. @item idle [@var{timeout} [@var{cmd} @var{args}]] Define a screen saver command. @xref{Screen Saver}. @item ignorecase [on|off] Ignore character case in searches. @xref{Searching}. @item info Display window settings. @xref{Info}. @item ins_reg [@var{key}] Removed, use @code{paste} instead. @xref{Registers}. @item kill Destroy the current window. @xref{Kill}. @item lastmsg Redisplay the last message. @xref{Last Message}. @item layout new [@var{title}] Create a layout. @xref{Layout}. @item layout remove [@var{n}|@var{title}] Delete a layout. @xref{Layout}. @item layout next Select the next layout. @xref{Layout}. @item layout prev Select the previous layout. @xref{Layout}. @item layout select [@var{n}|@var{title}] Jump to a layout. @xref{Layout}. @item layout show List the available layouts. @xref{Layout}. @item layout title [@var{title}] Show or set the title of a layout. @xref{Layout}. @item layout number [@var{n}] Show or set the number of a layout. @xref{Layout}. @item layout attach [@var{title}|:last] Show or set which layout to reattach to. @xref{Layout}. @item layout save [@var{n}|@var{title}] Remember the organization of a layout. @xref{Layout}. @item layout autosave [@var{on}|@var{off}] Show or set the status of layout saving. @xref{Layout}. @item layout dump [filename] Save the layout arrangement to a file. @xref{Layout}. @item license Display licensing information. @xref{Startup}. @item lockscreen Lock the controlling terminal. @xref{Lock}. @item log [@var{state}] Log all output in the current window. @xref{Log}. @item logfile @var{filename} Place where to collect logfiles. @xref{Log}. @item login [@var{state}] Log the window in @file{/etc/utmp}. @xref{Login}. @item logtstamp [@var{state}] Configure logfile time-stamps. @xref{Log}. @item mapdefault Use only the default mapping table for the next keystroke. @xref{Bindkey Control}. @item mapnotnext Don't try to do keymapping on the next keystroke. @xref{Bindkey Control}. @item maptimeout @var{n} Set the inter-character timeout used for keymapping. @xref{Bindkey Control}. @item markkeys @var{string} Rebind keys in copy mode. @xref{Copy Mode Keys}. @item maxwin @var{n} Set the maximum window number. @xref{Maxwin}. @item meta Insert the command character. @xref{Command Character}. @item monitor [@var{state}] Monitor activity in window. @xref{Monitor}. @item mousetrack [@var{on}|@var{off}] Enable selecting split regions with mouse clicks. @xref{Mousetrack}. @item msgminwait @var{sec} Set minimum message wait. @xref{Message Wait}. @item msgwait @var{sec} Set default message wait. @xref{Message Wait}. @item multiuser @var{state} Go into single or multi user mode. @xref{Multiuser Session}. @item nethack @var{state} Use @code{nethack}-like error messages. @xref{Nethack}. @item next Switch to the next window. @xref{Selecting}. @item nonblock [@var{state}|@var{numsecs}] Disable flow control to the current display. @xref{Nonblock}.|@var{numsecs}] @item number [@var{n}] Change/display the current window's number. @xref{Number}. @item obuflimit [@var{limit}] Select output buffer limit. @xref{Obuflimit}. @item only Kill all other regions. @xref{Regions}. @item other Switch to the window you were in last. @xref{Selecting}. @item partial @var{state} Set window to partial refresh. @xref{Redisplay}. @item password [@var{crypted_pw}] Set reattach password. @xref{Detach}. @item paste [@var{src_regs} [@var{dest_reg}]] Paste contents of paste buffer or registers somewhere. @xref{Paste}. @item pastefont [@var{state}] Include font information in the paste buffer. @xref{Paste}. @item pow_break Close and Reopen the window's terminal. @xref{Break}. @item pow_detach Detach and hang up. @xref{Power Detach}. @item pow_detach_msg [@var{message}] Set message displayed on @code{pow_detach}. @xref{Power Detach}. @item prev Switch to the previous window. @xref{Selecting}. @item printcmd [@var{cmd}] Set a command for VT100 printer port emulation. @xref{Printcmd}. @item process [@var{key}] Treat a register as input to @code{screen}. @xref{Registers}. @item quit Kill all windows and exit. @xref{Quit}. @item readbuf [-e @var{encoding}] [@var{filename}] Read the paste buffer from the screen-exchange file. @xref{Screen Exchange}. @item readreg [-e @var{encoding}] [@var{reg} [@var{file}]] Load a register from paste buffer or file. @xref{Registers}. @item redisplay Redisplay the current window. @xref{Redisplay}. @item register [-e @var{encoding}] @var{key} @var{string} Store a string to a register. @xref{Registers}. @item remove Kill current region. @xref{Regions}. @item removebuf Delete the screen-exchange file. @xref{Screen Exchange}. @item rendition bell | monitor | silence | so @var{attr} [@var{color}] Change text attributes in caption for flagged windows. @xref{Rendition}. @item reset Reset the terminal settings for the window. @xref{Reset}. @item resize [(+/-)lines] Grow or shrink a region. @xref{Resize}. @item screen [@var{opts}] [@var{n}] [@var{cmd} [@var{args}] | //group] Create a new window. @xref{Screen Command}. @item scrollback @var{num} Set size of scrollback buffer. @xref{Scrollback}. @item select [@var{n}|-|.] Switch to a specified window. @xref{Selecting}. @item sessionname [@var{name}] Name this session. @xref{Session Name}. @item setenv [@var{var} [@var{string}]] Set an environment variable for new windows. @xref{Setenv}. @item setsid @var{state} Controll process group creation for windows. @xref{Setsid}. @item shell @var{command} Set the default program for new windows. @xref{Shell}. @item shelltitle @var{title} Set the default name for new windows. @xref{Shell}. @item silence [@var{state}|@var{seconds}] Monitor a window for inactivity. @xref{Monitor}. @item silencewait @var{seconds} Default timeout to trigger an inactivity notify. @xref{Monitor}. @item sleep @var{num} Pause during startup. @xref{Startup}. @item slowpaste @var{msec} Slow down pasting in windows. @xref{Paste}. @item source @var{file} Run commands from a file. @xref{Source}. @item sorendition [@var{attr} [@var{color}]] Deprecated. Use @code{rendition so} instead. @xref{Rendition}. @item split Split region into two parts. @xref{Regions}. @item startup_message @var{state} Display copyright notice on startup. @xref{Startup}. @item stuff [@var{string}] Stuff a string in the input buffer of a window. @xref{Paste}. @item su [@var{username} [@var{password} [@var{password2}]]] Identify a user. @xref{Multiuser Session}. @item suspend Put session in background. @xref{Suspend}. @item term @var{term} Set @code{$TERM} for new windows. @xref{Term}. @item termcap @var{term} @var{terminal-tweaks} [@var{window-tweaks}] Tweak termcap entries for best performance. @xref{Termcap Syntax}. @item terminfo @var{term} @var{terminal-tweaks} [@var{window-tweaks}] Ditto, for terminfo systems. @xref{Termcap Syntax}. @item termcapinfo @var{term} @var{terminal-tweaks} [@var{window-tweaks}] Ditto, for both systems. @xref{Termcap Syntax}. @item time [@var{string}] Display time and load average. @xref{Time}. @item title [@var{windowtitle}] Set the name of the current window. @xref{Title Command}. @item umask [@var{users}]+/-@var{bits} ... Synonym to @code{aclumask}. @xref{Umask}. @item unbindall Unset all keybindings. @xref{Bind}. @item unsetenv @var{var} Unset environment variable for new windows. @xref{Setenv}. @item utf8 [@var{state} [@var{dstate}]] Select character encoding of the current window. @xref{Character Processing}. @item vbell [@var{state}] Use visual bell. @xref{Bell}. @item vbell_msg [@var{message}] Set vbell message. @xref{Bell}. @item vbellwait @var{sec} Set delay for vbell message. @xref{Bell}. @item version Display @code{screen} version. @xref{Version}. @item wall @var{message} Write a message to all displays. @xref{Multiuser Session}. @item width [@var{cols} [@var{lines}]] Set the width of the window. @xref{Window Size}. @item windowlist [[-b] [-m] [-g]] | string [@var{string}] | title [@var{title}] Present a list of all windows for selection. @xref{Windowlist}. @item windows List active windows. @xref{Windows}. @item wrap [ on | off ] Control line-wrap behavior. @xref{Wrap}. @item writebuf [-e @var{encoding}] [@var{filename}] Write paste buffer to screen-exchange file. @xref{Screen Exchange}. @item writelock @var{on}|@var{off}|@var{auto} Grant exclusive write permission. @xref{Multiuser Session}. @item xoff Send an XOFF character. @xref{XON/XOFF}. @item xon Send an XON character. @xref{XON/XOFF}. @item zmodem [off|auto|catch|pass] Define how screen treats zmodem requests. @xref{Zmodem}. @item zombie [@var{keys} [onerror] ] Keep dead windows. @xref{Zombie}. @end table @node New Window, Selecting, Commands, Top @chapter New Window This section describes the commands for creating a new window for running programs. When a new window is created, the first available number is assigned to it. The number of windows is limited at compile-time by the MAXWIN configuration parameter (which defaults to 40). @menu * Chdir:: Change the working directory for new windows. * Screen Command:: Create a new window. * Setenv:: Set environment variables for new windows. * Shell:: Parameters for shell windows. * Term:: Set the terminal type for new windows. * Window Types:: Creating different types of windows. * Window Groups:: Grouping windows together @end menu @node Chdir, Screen Command, , New Window @section Chdir @deffn Command chdir [directory] (none)@* Change the current directory of @code{screen} to the specified directory or, if called without an argument, to your home directory (the value of the environment variable @code{$HOME}). All windows that are created by means of the @code{screen} command from within @file{.screenrc} or by means of @kbd{C-a : screen @dots{}} or @kbd{C-a c} use this as their default directory. Without a @code{chdir} command, this would be the directory from which @code{screen} was invoked. Hardcopy and log files are always written to the @emph{window's} default directory, @emph{not} the current directory of the process running in the window. You can use this command multiple times in your @file{.screenrc} to start various windows in different default directories, but the last @code{chdir} value will affect all the windows you create interactively. @end deffn @node Screen Command, Setenv, Chdir, New Window @section Screen Command @kindex c @kindex C-c @deffn Command screen [opts] [n] [cmd [args] @var{| //group}] (@kbd{C-a c}, @kbd{C-a C-c})@* Establish a new window. The flow-control options (@samp{-f}, @samp{-fn} and @samp{-fa}), title option (@samp{-t}), login options (@samp{-l} and @samp{-ln}) , terminal type option (@samp{-T @var{term}}), the all-capability-flag (@samp{-a}) and scrollback option (@samp{-h @var{num}}) may be specified with each command. The option (@samp{-M}) turns monitoring on for this window. The option (@samp{-L}) turns output logging on for this window. If an optional number @var{n} in the range 0@dots{}MAXWIN-1 is given, the window number @var{n} is assigned to the newly created window (or, if this number is already in-use, the next available number). If a command is specified after @code{screen}, this command (with the given arguments) is started in the window; otherwise, a shell is created. If @samp{//group} is supplied, a container-type window is created in which other windows may be created inside it. @xref{Window Groups}. Screen has built in some functionality of @samp{cu} and @samp{telnet}. @xref{Window Types}. @end deffn Thus, if your @file{.screenrc} contains the lines @example # example for .screenrc: screen 1 screen -fn -t foobar 2 -L telnet foobar @end example @noindent @code{screen} creates a shell window (in window #1) and a window with a TELNET connection to the machine foobar (with no flow-control using the title @samp{foobar} in window #2) and will write a logfile @samp{screenlog.2} of the telnet session. If you do not include any @code{screen} commands in your @file{.screenrc} file, then @code{screen} defaults to creating a single shell window, number zero. When the initialization is completed, @code{screen} switches to the last window specified in your .screenrc file or, if none, it opens default window #0. @node Setenv, Shell, Screen Command, New Window @section Setenv @deffn Command setenv var string (none)@* Set the environment variable @var{var} to value @var{string}. If only @var{var} is specified, the user will be prompted to enter a value. If no parameters are specified, the user will be prompted for both variable and value. The environment is inherited by all subsequently forked shells. @end deffn @deffn Command unsetenv var (none)@* Unset an environment variable. @end deffn @node Shell, Term, Setenv, New Window @section Shell @deffn Command shell command @deffnx Command defshell command (none)@* Set the command to be used to create a new shell. This overrides the value of the environment variable @code{$SHELL}. This is useful if you'd like to run a tty-enhancer which is expecting to execute the program specified in @code{$SHELL}. If the command begins with a @samp{-} character, the shell will be started as a login-shell. Typical shells do only minimal initialization when not started as a login-shell. E.g. Bash will not read your @file{~/.bashrc} unless it is a login-shell. @code{defshell} is currently a synonym to the @code{shell} .screenrc command. @end deffn @deffn Command shelltitle title (none)@* Set the title for all shells created during startup or by the C-a C-c command. @xref{Naming Windows}, for details about what titles are. @end deffn @node Term, Window Types , Shell, New Window @section Term @deffn Command term term (none)@* In each window @code{screen} opens, it sets the @code{$TERM} variable to @code{screen} by default, unless no description for @code{screen} is installed in the local termcap or terminfo data base. In that case it pretends that the terminal emulator is @samp{vt100}. This won't do much harm, as @code{screen} is VT100/ANSI compatible. The use of the @code{term} command is discouraged for non-default purpose. That is, one may want to specify special @code{$TERM} settings (e.g. vt100) for the next @code{screen rlogin othermachine} command. Use the command @code{screen -T vt100 rlogin othermachine} rather than setting and resetting the default. @end deffn @node Window Types, Window Groups, Term, New Window @section Window Types @cindex window types Screen provides three different window types. New windows are created with @code{screen}'s @samp{screen} command (@pxref{Screen Command}). The first parameter to the @samp{screen} command defines which type of window is created. The different window types are all special cases of the normal type. They have been added in order to allow @code{screen} to be used efficiently as a console with 100 or more windows. @itemize @bullet @item The normal window contains a shell (default, if no parameter is given) or any other system command that could be executed from a shell. (e.g. @samp{slogin}, etc...). @item If a tty (character special device) name (e.g. @samp{/dev/ttya}) is specified as the first parameter, then the window is directly connected to this device. This window type is similar to @samp{screen cu -l /dev/ttya}. Read and write access is required on the device node, an exclusive open is attempted on the node to mark the connection line as busy. An optional parameter is allowed consisting of a comma separated list of flags in the notation used by @samp{stty(1)}: @table @code @item Usually 300, 1200, 9600 or 19200. This affects transmission as well as receive speed. @item cs8 or cs7 Specify the transmission of eight (or seven) bits per byte. @item ixon or -ixon Enables (or disables) software flow-control (CTRL-S/CTRL-Q) for sending data. @item ixoff or -ixoff Enables (or disables) software flow-control for receiving data. @item istrip or -istrip Clear (or keep) the eight bit in each received byte. @end table You may want to specify as many of these options as applicable. Unspecified options cause the terminal driver to make up the parameter values of the connection. These values are system-dependent and may be in defaults or values saved from a previous connection. For tty windows, the @code{info} command shows some of the modem control lines in the status line. These may include @samp{RTS}, @samp{CTS}, @samp{DTR}, @samp{CD} and more. This depends rather on on the available @code{ioctl()}'s and system header files than on the physical capabilities of the serial board. The name of a logical low (inactive) signal is preceded by an exclamation mark (@samp{!}), otherwise the signal is logical high (active). Unsupported but shown signals are usually shown low. When the @code{CLOCAL} status bit is true, the whole set of modem signals is placed inside curly braces (@samp{@{} and @samp{@}}). When the @code{CRTSCTS} or @code{TIOCSOFTCAR} bit is true, the signals @samp{CTS} or @samp{CD} are shown in parenthesis, respectively. For tty windows, the command @code{break} causes the Data transmission line (TxD) to go low for a specified period of time. This is expected to be interpreted as break signal on the other side. No data is sent and no modem control line is changed when a @code{break} is issued. @item If the first parameter is @code{//telnet}, the second parameter is expected to be a host name, and an optional third parameter may specify a TCP port number (default decimal 23). Screen will connect to a server listening on the remote host and use the telnet protocol to communicate with that server. For telnet windows, the command @code{info} shows details about the connection in square brackets (@samp{[} and @samp{]}) at the end of the status line. @table @code @item b BINARY. The connection is in binary mode. @item e ECHO. Local echo is disabled. @item c SGA. The connection is in `character mode' (default: `line mode'). @item t TTYPE. The terminal type has been requested by the remote host. Screen sends the name @code{screen} unless instructed otherwise (see also the command @samp{term}). @item w NAWS. The remote site is notified about window size changes. @item f LFLOW. The remote host will send flow control information. (Ignored at the moment.) @end table Additional flags for debugging are @samp{x}, @samp{t} and @samp{n} (XDISPLOC, TSPEED and NEWENV). For telnet windows, the command @code{break} sends the telnet code @code{IAC BREAK} (decimal 243) to the remote host. @end itemize @node Window Groups, , Window Types, New Window @section Window Groups @cindex window groups Screen provides a method for grouping windows together. Windows can be organized in a hierarchical fashion, resembling a tree structure. New screens are created using the @code{screen} command while new groups are created using @code{screen //group}. @xref{Screen Command}. Once a new group is created, it will act as a container for windows and even other groups. When a group is selected, you will see the output of the @code{windowlist} command, allowing you to select a window inside. If there are no windows inside a group, use the @code{screen} command to create one. Once inside a group, using the commands @code{next} and @code{prev} will switch between windows only in that group. Using the @code{windowlist} command will give you the opportunity to leave the group you are in. @xref{Windowlist}. @deffn Command group [grouptitle] (none)@* Change or show the group the current window belongs to. Windows can be moved around between different groups by specifying the name of the destination group. Without specifying a group, the title of the current group is displayed. @end deffn Using groups in combination with layouts will help create a multi-desktop experience. One group can be assigned for each layout made. Windows can be made, split, and organized within each group as desired. Afterwhich, switching between groups can be as easy as switching layouts. @node Selecting, Session Management, New Window, Top @chapter Selecting a Window This section describes the commands for switching between windows in an @code{screen} session. The windows are numbered from 0 to 9, and are created in that order by default (@pxref{New Window}). @menu * Next and Previous:: Forward or back one window. * Other Window:: Switch back and forth between two windows. * Select:: Switch to a window (and to one after @code{kill}). * Windowlist:: Present a list of all windows for selection. @end menu @node Next and Previous, Other Window, , Selecting @section Moving Back and Forth @kindex SPC @kindex n @kindex C-n @deffn Command next (@kbd{C-a @key{SPC}}, @kbd{C-a n}, @kbd{C-a C-n})@* Switch to the next window. This command can be used repeatedly to cycle through the list of windows. (On some terminals, C-@key{SPC} generates a NUL character, so you must release the control key before pressing space.) @end deffn @kindex p @kindex C-p @kindex C-h @kindex Backspace @deffn Command prev (@kbd{C-a p}, @kbd{C-a C-p}, @kbd{C-a C-h}, @kbd{C-a @key{Backspace}})@* Switch to the previous window (the opposite of @kbd{C-a n}). @end deffn @node Other Window, Select, Next and Previous, Selecting @section Other Window @kindex C-a @deffn Command other (@kbd{C-a C-a})@* Switch to the last window displayed. Note that this command defaults to the command character typed twice, unless overridden. For instance, if you use the option @samp{-e]x}, this command becomes @kbd{]]} (@pxref{Command Character}). @end deffn @node Select, Windowlist, Other Window, Selecting @section Select @kindex 0@dots{}9 @kindex ' @deffn Command select [n @var{|-|.}] (@kbd{C-a @var{n}}, @kbd{C-a '})@* Switch to the window with the number @var{n}. If no window number is specified, you get prompted for an identifier. This can be a window name (title) or a number. When a new window is established, the lowest available number is assigned to this window. Thus, the first window can be activated by @code{select 0}; there can be no more than 10 windows present simultaneously (unless screen is compiled with a higher MAXWIN setting). There are two special arguments, @code{select -} switches to the internal blank window and @code{select .} switches to the current window. The latter is useful if used with screen's @code{-X} option. @end deffn @node Windowlist, , Select, Selecting @section Windowlist @kindex " @deffn Command windowlist [-b] [-m] [-g] @deffnx Command windowlist string [@var{string}] @deffnx Command windowlist title [@var{title}] (@kbd{C-a "})@* Display all windows in a table for visual window selection. If screen was in a window group, screen will back out of the group and then display the windows in that group. If the @code{-b} option is given, screen will switch to the blank window before presenting the list, so that the current window is also selectable. The @code{-m} option changes the order of the windows, instead of sorting by window numbers screen uses its internal most-recently-used list. The @code{-g} option will show the windows inside any groups in that level and downwards. The following keys are used to navigate in @code{windowlist}: @noindent @kbd{k}, @kbd{C-p}, or @kbd{up} Move up one line. @noindent @kbd{j}, @kbd{C-n}, or @kbd{down} Move down one line. @noindent @kbd{C-g} or @kbd{escape} Exit windowlist. @noindent @kbd{C-a} or @kbd{home} Move to the first line. @noindent @kbd{C-e} or @kbd{end} Move to the last line. @noindent @kbd{C-u} or @kbd{C-d} Move one half page up or down. @noindent @kbd{C-b} or @kbd{C-f} Move one full page up or down. @indent @kbd{0..9} Using the number keys, move to the selected line. @noindent @kbd{mouseclick} Move to the selected line. Available when @code{mousetrack} is set to @code{on}. @noindent @kbd{/} Search. @noindent @kbd{n} Repeat search in the forward direction. @noindent @kbd{N} Repeat search in the backward direction. @noindent @kbd{m} Toggle MRU. @noindent @kbd{g} Toggle group nesting. @noindent @kbd{a} All window view. @noindent @kbd{C-h} or @kbd{backspace} Back out the group. @noindent @kbd{,} Switch numbers with the previous window. @noindent @kbd{.} Switch numbers with the next window. @noindent @kbd{K} Kill that window. @noindent @kbd{space} or @kbd{enter} Select that window. The table format can be changed with the string and title option, the title is displayed as table heading, while the lines are made by using the string setting. The default setting is @samp{Num Name%=Flags} for the title and @samp{%3n %t%=%f} for the lines. See the string escapes chapter (@pxref{String Escapes}) for more codes (e.g. color settings). @code{Windowlist} needs a region size of at least 10 characters wide and 6 characters high in order to display. @end deffn @node Session Management, Regions, Selecting, Top @chapter Session Management Commands Perhaps the most useful feature of @code{screen} is the way it allows the user to move a session between terminals, by detaching and reattaching. This also makes life easier for modem users who have to deal with unexpected loss of carrier. @menu * Detach:: Disconnect @code{screen} from your terminal. * Power Detach:: Detach and log out. * Lock:: Lock your terminal temporarily. * Multiuser Session:: Changing number of allowed users. * Session Name:: Rename your session for later reattachment. * Suspend:: Suspend your session. * Quit:: Terminate your session. @end menu @node Detach, Power Detach, , Session Management @section Detach @deffn Command autodetach state (none)@* Sets whether @code{screen} will automatically detach upon hangup, which saves all your running programs until they are resumed with a @code{screen -r} command. When turned off, a hangup signal will terminate @code{screen} and all the processes it contains. Autodetach is on by default. @end deffn @kindex d @kindex C-d @deffn Command detach (@kbd{C-a d}, @kbd{C-a C-d})@* Detach the @code{screen} session (disconnect it from the terminal and put it into the background). A detached @code{screen} can be resumed by invoking @code{screen} with the @code{-r} option (@pxref{Invoking Screen}). The @code{-h} option tells screen to immediately close the connection to the terminal (@samp{hangup}). @end deffn @deffn Command password [crypted_pw] (none)@* Present a crypted password in your @file{.screenrc} file and screen will ask for it, whenever someone attempts to resume a detached session. This is useful, if you have privileged programs running under @code{screen} and you want to protect your session from reattach attempts by users that managed to assume your uid. (I.e. any superuser.) If no crypted password is specified, screen prompts twice a password and places its encryption in the paste buffer. Default is `none', which disables password checking. @end deffn @node Power Detach, Lock, Detach, Session Management @section Power Detach @kindex D @deffn Command pow_detach (@kbd{C-a D D})@* Mainly the same as @code{detach}, but also sends a HANGUP signal to the parent process of @code{screen}.@* @emph{Caution}: This will result in a logout if @code{screen} was started from your login-shell. @end deffn @deffn Command pow_detach_msg [message] (none)@* The @var{message} specified here is output whenever a power detach is performed. It may be used as a replacement for a logout message or to reset baud rate, etc. Without a parameter, the current message is shown. @end deffn @node Lock, Multiuser Session, Power Detach, Session Management @section Lock @kindex x @kindex C-x @deffn Command lockscreen (@kbd{C-a x}, @kbd{C-a C-x})@* Call a screenlock program (@file{/local/bin/lck} or @file{/usr/bin/lock} or a builtin, if no other is available). Screen does not accept any command keys until this program terminates. Meanwhile processes in the windows may continue, as the windows are in the detached state. The screenlock program may be changed through the environment variable @code{$LOCKPRG} (which must be set in the shell from which @code{screen} is started) and is executed with the user's uid and gid. Warning: When you leave other shells unlocked and have no password set on @code{screen}, the lock is void: One could easily re-attach from an unlocked shell. This feature should rather be called @code{lockterminal}. @end deffn @node Multiuser Session, Session Name, Lock, Session Management @section Multiuser Session @cindex multiuser session These commands allow other users to gain access to one single @code{screen} session. When attaching to a multiuser @code{screen} the sessionname is specified as @code{username/sessionname} to the @code{-S} command line option. @code{Screen} must be compiled with multiuser support to enable features described here. @menu * Multiuser:: Enable / Disable multiuser mode. * Acladd:: Enable a specific user. * Aclchg:: Change a users permissions. * Acldel:: Disable a specific user. * Aclgrp:: Grant a user permissions to other users. * Displays:: List all active users at their displays. * Umask:: Predefine access to new windows. * Wall:: Write a message to all users. * Writelock:: Grant exclusive window access. * Su:: Substitute user. @end menu @node Multiuser, Acladd, , Multiuser Session @subsection Multiuser @deffn Command multiuser @var{state} (none)@* Switch between single-user and multi-user mode. Standard screen operation is single-user. In multi-user mode the commands @code{acladd}, @code{aclchg} and @code{acldel} can be used to enable (and disable) other users accessing this @code{screen}. @end deffn @node Acladd, Aclchg, Multiuser, Multiuser Session @subsection Acladd @deffn Command acladd @var{usernames} @deffnx Command addacl @var{usernames} (none)@* Enable users to fully access this screen session. @var{Usernames} can be one user or a comma separated list of users. This command enables to attach to the @code{screen} session and performs the equivalent of @code{aclchg @var{usernames} +rwx "#?"}. To add a user with restricted access, use the @code{aclchg} command below. @code{Addacl} is a synonym to @code{acladd}. Multi-user mode only. @end deffn @node Aclchg, Acldel, Acladd, Multiuser Session @subsection Aclchg @deffn Command aclchg @var{usernames permbits list} @deffnx Command chacl @var{usernames permbits list} (none)@* Change permissions for a comma separated list of users. Permission bits are represented as @samp{r}, @samp{w} and @samp{x}. Prefixing @samp{+} grants the permission, @samp{-} removes it. The third parameter is a comma separated list of commands or windows (specified either by number or title). The special list @samp{#} refers to all windows, @samp{?} to all commands. If @var{usernames} consists of a single @samp{*}, all known users are affected. A command can be executed when the user has the @samp{x} bit for it. The user can type input to a window when he has its @samp{w} bit set and no other user obtains a writelock for this window. Other bits are currently ignored. To withdraw the writelock from another user in e.g. window 2: @samp{aclchg @var{username} -w+w 2}. To allow read-only access to the session: @samp{aclchg @var{username} -w "#"}. As soon as a user's name is known to screen, he can attach to the session and (per default) has full permissions for all command and windows. Execution permission for the acl commands, @code{at} and others should also be removed or the user may be able to regain write permission. @code{Chacl} is a synonym to @code{aclchg}. Multi-user mode only. @end deffn @node Acldel, Aclgrp, Aclchg, Multiuser Session @subsection Acldel @deffn Command acldel @var{username} (none)@* Remove a user from screen's access control list. If currently attached, all the user's displays are detached from the session. He cannot attach again. Multi-user mode only. @end deffn @node Aclgrp, Displays, Acldel, Multiuser Session @subsection Aclgrp @deffn Command aclgrp @var{username} [@var{groupname}] (none)@* Creates groups of users that share common access rights. The name of the group is the username of the group leader. Each member of the group inherits the permissions that are granted to the group leader. That means, if a user fails an access check, another check is made for the group leader. A user is removed from all groups the special value @samp{none} is used for @var{groupname}. If the second parameter is omitted all groups the user is in are listed. @end deffn @node Displays, Umask, Aclgrp, Multiuser Session @subsection Displays @kindex * @deffn Command displays (@kbd{C-a *})@* Shows a tabular listing of all currently connected user front-ends (displays). This is most useful for multiuser sessions. The following keys can be used in @code{displays} list: @noindent @kbd{k}, @kbd{C-p}, or @kbd{up} Move up one line. @noindent @kbd{j}, @kbd{C-n}, or @kbd{down} Move down one line. @noindent @kbd{C-a} or @kbd{home} Move to the first line. @noindent @kbd{C-e} or @kbd{end} Move to the last line. @noindent @kbd{C-u} or @kbd{C-d} Move one half page up or down. @noindent @kbd{C-b} or @kbd{C-f} Move one full page up or down. @noindent @kbd{mouseclick} Move to the selected line. Available when @code{mousetrack} is set to @code{on}. @noindent @kbd{space} Refresh the list. @noindent @kbd{d} Detach the selected display. @noindent @kbd{D} Power detach the selected display. @noindent @kbd{C-g}, @kbd{enter}, or @kbd{escape} Exit the list. The following is an example of what @code{displays} could look like: @example xterm 80x42 jnweiger@@/dev/ttyp4 0(m11) &rWx facit 80x24 mlschroe@@/dev/ttyhf nb 11(tcsh) rwx xterm 80x42 jnhollma@@/dev/ttyp5 0(m11) &R.x (A) (B) (C) (D) (E) (F)(G) (H)(I) @end example The legend is as follows: @*(A) The terminal type known by @code{screen} for this display. @*(B) Displays geometry as width x height. @*(C) Username who is logged in at the display. @*(D) Device name of the display or the attached device @*(E) Display is in blocking or nonblocking mode. The available modes are "nb", "NB", "Z<", "Z>", and "BL". @*(F) Number of the window @*(G) Name/title of window @*(H) Whether the window is shared @*(I) Window permissions. Made up of three characters: @display (1st character) @samp{-} : no read @samp{r} : read @samp{R} : read only due to foreign wlock (2nd character) @samp{-} : no write @samp{.} : write suppressed by foreign wlock @samp{w} : write @samp{W} : own wlock (3rd character) @samp{-} : no execute @samp{x} : execute @end display @code{Displays} needs a region size of at least 10 characters wide and 5 characters high in order to display. @end deffn @node Umask, Wall, Displays, Multiuser Session @subsection aclumask @deffn Command aclumask [@var{users}]+/-@var{bits} ... @deffnx Command umask [@var{users}]+/-@var{bits} ... (none)@* This specifies the access other users have to windows that will be created by the caller of the command. @var{Users} may be no, one or a comma separated list of known usernames. If no users are specified, a list of all currently known users is assumed. @var{Bits} is any combination of access control bits allowed defined with the @code{aclchg} command. The special username @samp{?} predefines the access that not yet known users will be granted to any window initially. The special username @samp{??} predefines the access that not yet known users are granted to any command. Rights of the special username nobody cannot be changed (see the @code{su} command). @code{Umask} is a synonym to @code{aclumask}. @end deffn @node Wall, Writelock, Umask, Multiuser Session @subsection Wall @deffn Command wall @var{message} (none)@* Write a message to all displays. The message will appear in the terminal's status line. @end deffn @node Writelock, Su , Wall, Multiuser Session @subsection Writelock @deffn Command writelock @var{on|off|auto} (none)@* In addition to access control lists, not all users may be able to write to the same window at once. Per default, writelock is in @samp{auto} mode and grants exclusive input permission to the user who is the first to switch to the particular window. When he leaves the window, other users may obtain the writelock (automatically). The writelock of the current window is disabled by the command @code{writelock off}. If the user issues the command @code{writelock on} he keeps the exclusive write permission while switching to other windows. @end deffn @deffn Command defwritelock @var{on|off|auto} (none)@* Sets the default writelock behavior for new windows. Initially all windows will be created with no writelocks. @end deffn @node Su, , Writelock, Multiuser Session @subsection Su @deffn Command su [@var{username} [@var{password} [@var{password2}]]] (none)@* Substitute the user of a display. The command prompts for all parameters that are omitted. If passwords are specified as parameters, they have to be specified un-crypted. The first password is matched against the systems passwd database, the second password is matched against the @code{screen} password as set with the commands @code{acladd} or @code{password}. @code{Su} may be useful for the @code{screen} administrator to test multiuser setups. When the identification fails, the user has access to the commands available for user @samp{nobody}. These are @code{detach}, @code{license}, @code{version}, @code{help} and @code{displays}. @end deffn @node Session Name, Suspend, Multiuser Session, Session Management @section Session Name @deffn Command sessionname [@var{name}] (none)@* Rename the current session. Note that for @code{screen -list} the name shows up with the process-id prepended. If the argument @var{name} is omitted, the name of this session is displayed.@* @emph{Caution}: The @code{$STY} environment variable will still reflect the old name in pre-existing shells. This may result in confusion. Use of this command is generally discouraged. Use the @code{-S} command-line option if you want to name a new session.The default is constructed from the tty and host names. @end deffn @node Suspend, Quit, Session Name, Session Management @section Suspend @kindex z @kindex C-z @deffn Command suspend (@kbd{C-a z}, @kbd{C-a C-z})@* Suspend @code{screen}. The windows are in the detached state while @code{screen} is suspended. This feature relies on the parent shell being able to do job control. @end deffn @node Quit, , Suspend, Session Management @section Quit @kindex \ @deffn Command quit (@kbd{C-a \})@* Kill all windows and terminate @code{screen}. (@pxref{Key Binding}). @end deffn @node Regions, Window Settings, Session Management, Top @chapter Regions @cindex regions Screen has the ability to display more than one window on the user's display. This is done by splitting the screen in regions, which can contain different windows. @menu * Split:: Split a region into two * Focus:: Change to the next region * Only:: Delete all other regions * Remove:: Delete the current region * Resize:: Grow or shrink a region * Caption:: Control the window's caption * Fit:: Resize a window to fit the region * Focusminsize:: Force a minimum size on a current region * Layout:: Manage groups of regions @end menu @node Split, Focus, , Regions @section Split @kindex S @kindex | @deffn Command split [-v] (@kbd{C-a S}, @kbd{C-a |})@* Split the current region into two new ones. All regions on the display are resized to make room for the new region. The blank window is displayed in the new region. The default is to create a horizontal split, putting the new regions on the top and bottom of each other. Using @samp{-v} will create a vertical split, causing the new regions to appear side by side of each other. Use the @code{remove} or the @code{only} command to delete regions. Use @code{focus} to toggle between regions. When a region is split opposite of how it was previously split (that is, vertical then horizontal or horizontal then vertical), a new layer is created. The layer is used to group together the regions that are split the same. Normally, as a user, you should not see nor have to worry about layers, but they will affect how some commands (@code{focus} and @code{resize}) behave. With this current implementation of @code{screen}, scrolling data will appear much slower in a vertically split region than one that is not. This should be taken into consideration if you need to use system commands such as @code{cat} or @code{tail -f}. @end deffn @node Focus, Only, Split, Regions @section Focus @kindex TAB @deffn Command focus [ @code{next|prev|up|down|left|right|top|bottom} ] (@kbd{C-a @key{Tab}})@* Move the input focus to the next region. This is done in a cyclic way so that the top left region is selected after the bottom right one. If no option is given it defaults to @code{next}. The next region to be selected is determined by how the regions are layered. Normally, the next region in the same layer would be selected. However, if that next region contains one or more layers, the first region in the highest layer is selected first. If you are at the last region of the current layer, @code{next} will move the focus to the next region in the lower layer (if there is a lower layer). @code{Prev} cycles in the opposite order. @xref{Split} for more information about layers. The rest of the options (@code{up}, @code{down}, @code{left}, @code{right}, @code{top}, and @code{bottom}) are more indifferent to layers. The option @code{up} will move the focus upward to the region that is touching the upper left corner of the current region. @code{Down} will move downward to the region that is touching the lower left corner of the current region. The option @code{left} will move the focus leftward to the region that is touching the upper left corner of the current region, while @code{right} will move rightward to the region that is touching the upper right corner of the current region. Moving left from a left most region or moving right from a right most region will result in no action. The option @code{top} will move the focus to the very first region in the upper list corner of the screen, and @code{bottom} will move to the region in the bottom right corner of the screen. Moving up from a top most region or moving down from a bottom most region will result in no action. Useful bindings are (h, j, k, and l as in vi): @example bind h focus left bind j focus down bind k focus up bind l focus right bind t focus top bind b focus bottom @end example Note that @samp{k} is traditionally bound to the @code{kill} command. @end deffn @node Only, Remove, Focus, Regions @section Only @kindex Q @deffn Command only (@kbd{C-a Q})@* Kill all regions but the current one. @end deffn @node Remove, Resize, Only, Regions @section Remove @kindex X @deffn Command remove (@kbd{C-a X})@* Kill the current region. This is a no-op if there is only one region. @end deffn @node Resize, Caption, Remove, Regions @section Resize @deffn Command resize [@code{-h|-v|-b|-l|-p}] [ [+|-]@var{n}[@code{%}] | @code{=} | @code{max} | @code{min} | @code{_} | @code{0} ] (none)@* Resize the current region. The space will be removed from or added to the surrounding regions depending on the order of the splits. The available options for resizing are @samp{-h}(horizontal), @samp{-v}(vertical), @samp{-b}(both), @samp{-l}(local to layer), and @samp{-p}(perpendicular). Horizontal resizes will add or remove width to a region, vertical will add or remove height, and both will add or remove size from both dimensions. Local and perpendicular are similar to horizontal and vertical, but they take in account of how a region was split. If a region's last split was horizontal, a local resize will work like a vertical resize. If a region's last split was vertical, a local resize will work like a horizontal resize. Perpendicular resizes work in opposite of local resizes. If no option is specified, local is the default. The amount of lines to add or remove can be expressed a couple of different ways. By specifying a number @var{n} by itself will resize the region by that absolute amount. You can specify a relative amount by prefixing a plus @samp{+} or minus @samp{-} to the amount, such as adding @code{+n} lines or removing @code{-n} lines. Resizing can also be expressed as an absolute or relative percentage by postfixing a percent sign @samp{%}. Using zero @samp{0} is a synonym for @code{min} and using an underscore @samp{_} is a synonym for @code{max}. Some examples are: @example resize +N increase current region by N resize -N decrease current region by N resize N set current region to N resize 20% set current region to 20% of original size resize +20% increase current region by 20% resize -b = make all windows equally resize max maximize current region resize min minimize current region @end example Without any arguments, @code{screen} will prompt for how you would like to resize the current region. See @code{focusminsize} if you want to restrict the minimun size a region can have. @end deffn @node Caption, Fit, Resize, Regions @section Caption @deffn Command caption @code{always}|@code{splitonly} [string] @deffnx Command caption @code{string} [string] (none)@* This command controls the display of the window captions. Normally a caption is only used if more than one window is shown on the display (split screen mode). But if the type is set to @code{always}, @code{screen} shows a caption even if only one window is displayed. The default is @samp{splitonly}. The second form changes the text used for the caption. You can use all string escapes (@pxref{String Escapes}). @code{Screen} uses a default of @samp{%3n %t}. You can mix both forms by providing the string as an additional argument. @end deffn @node Fit, Focusminsize, Caption, Regions @section Fit @kindex F @deffn Command fit (@kbd{C-a F})@* Change the window size to the size of the current region. This command is needed because screen doesn't adapt the window size automatically if the window is displayed more than once. @end deffn @node Focusminsize, Layout, Fit, Regions @section Focusminsize @deffn Command focusminsize [ (width|@code{max}|@code{_}) (height|@code{max}|@code{_}) ] (none)@* This forces any currently selected region to be automatically resized at least a certain @var{width} and @var{height}. All other surrounding regions will be resized in order to accommodate. This constraint follows every time the @code{focus} command is used. The @code{resize} command can be used to increase either dimension of a region, but never below what is set with @code{focusminsize}. The underscore @samp{_} is a synonym for @code{max}. Setting a @var{width} and @var{height} of @code{0 0} (zero zero) will undo any constraints and allow for manual resizing. Without any parameters, the minimum width and height is shown. @end deffn @node Layout, , Focusminsize, Regions @section Layout @cindex layout Using regions, and perhaps a large enough terminal, you can give @code{screen} more of a desktop feel. By being able to split regions horizontally or vertically, you can take advantage of the lesser used spaces of your terminal. The catch to these splits has been that they're not kept between screen detachments and reattachments. Layouts will help organize your regions. You can create one layout of four horizontal regions and then create a separate layout of regions in a two by two array. The regions could contain the same windows, but they don't have to. You can easily switch between layouts and keep them between detachments and reattachments. Note that there are several subcommands to @code{layout}. @deffn Command layout @code{new} [title] (none)@* Create a new layout. The screen will change to one whole region and be switched to the blank window. From here, you build the regions and the windows they show as you desire. The new layout will be numbered with the smallest available integer, starting with zero. You can optionally give a title to your new layout. Otherwise, it will have a default title of @code{layout}. You can always change the title later by using the command @code{layout title}. @end deffn @deffn Command layout @code{remove} [n|title] (none)@* Remove, or in other words, delete the specified layout. Either the number or the title can be specified. Without either specification, @code{screen} will remove the current layout. Removing a layout does not affect your set windows or regions. @end deffn @deffn Command layout @code{next} (none)@* Switch to the next layout available @end deffn @deffn Command layout @code{prev} (none)@* Switch to the previous layout available @end deffn @deffn Command layout @code{select} [n|title] (none)@* Select the desired layout. Either the number or the title can be specified. Without either specification, @code{screen} will prompt and ask which screen is desired. To see which layouts are available, use the @code{layout show} command. @end deffn @deffn Command layout @code{show} (none)@* List on the message line the number(s) and title(s) of the available layout(s). The current layout is flagged. @end deffn @deffn Command layout @code{title} [title] (none)@* Change or display the title of the current layout. A string given will be used to name the layout. Without any options, the current title and number is displayed on the message line. @end deffn @deffn Command layout @code{number} [n] (none)@* Change or display the number of the current layout. An integer given will be used to number the layout. Without any options, the current number and title is displayed on the message line. @end deffn @deffn Command layout @code{attach} [title|@code{:last}] (none)@* Change or display which layout to reattach back to. The default is @code{:last}, which tells @code{screen} to reattach back to the last used layout just before detachment. By supplying a title, You can instruct @code{screen} to reattach to a particular layout regardless which one was used at the time of detachment. Without any options, the layout to reattach to will be shown in the message line. @end deffn @deffn Command layout @code{save} [n|title] (none)@* Remember the current arrangement of regions. When used, @code{screen} will remember the arrangement of vertically and horizontally split regions. This arrangement is restored when a @code{screen} session is reattached or switched back from a different layout. If the session ends or the @code{screen} process dies, the layout arrangements are lost. The @code{layout dump} command should help in this siutation. If a number or title is supplied, @code{screen} will remember the arrangement of that particular layout. Without any options, @code{screen} will remember the current layout. Saving your regions can be done automatically by using the @code{layout autosave} command. @end deffn @deffn Command layout @code{autosave} [@code{on}|@code{off}] (none)@* Change or display the status of automatically saving layouts. The default is @code{on}, meaning when @code{screen} is detached or changed to a different layout, the arrangement of regions and windows will be remembered at the time of change and restored upon return. If autosave is set to @code{off}, that arrangement will only be restored to either to the last manual save, using @code{layout save}, or to when the layout was first created, to a single region with a single window. Without either an @code{on} or an @code{off}, the current status is displayed on the message line. @end deffn @deffn Command layout @code{dump} [filename] (none)@* Write to a file the order of splits made in the current layout. This is useful to recreate the order of your regions used in your current layout. Only the current layout is recorded. While the order of the regions are recorded, the sizes of those regions and which windows correspond to which regions are not. If no filename is specified, the default is @file{layout-dump}, saved in the directory that the @code{screen} process was started in. If the file already exists, @code{layout dump} will append to that file. As an example: @example layout dump /home/user/.screenrc @end example will save or append the layout to the user's @file{.screenrc} file. @end deffn @node Window Settings, Virtual Terminal, Regions, Top @chapter Window Settings These commands control the way @code{screen} treats individual windows in a session. @xref{Virtual Terminal}, for commands to control the terminal emulation itself. @menu * Naming Windows:: Control the name of the window * Console:: See the host's console messages * Kill:: Destroy an unwanted window * Login:: Control @file{/etc/utmp} logging * Mode:: Control the file mode of the pty * Monitor:: Watch for activity or inactivity in a window * Windows:: List the active windows * Hardstatus:: Set a window's hardstatus line @end menu @node Naming Windows, Console, , Window Settings @section Naming Windows (Titles) @cindex title You can customize each window's name in the window display (viewed with the @code{windows} command (@pxref{Windows}) by setting it with one of the title commands. Normally the name displayed is the actual command name of the program created in the window. However, it is sometimes useful to distinguish various programs of the same name or to change the name on-the-fly to reflect the current state of the window. The default name for all shell windows can be set with the @code{shelltitle} command (@pxref{Shell}). You can specify the name you want for a window with the @samp{-t} option to the @code{screen} command when the window is created (@pxref{Screen Command}). To change the name after the window has been created you can use the title-string escape-sequence (@kbd{@key{ESC} k @var{name} @key{ESC} \}) and the @code{title} command (C-a A). The former can be output from an application to control the window's name under software control, and the latter will prompt for a name when typed. You can also bind predefined names to keys with the @code{title} command to set things quickly without prompting. @menu * Title Command:: The @code{title} command. * Dynamic Titles:: Make shell windows change titles dynamically. * Title Prompts:: Set up your shell prompt for dynamic Titles. * Title Screenrc:: Set up Titles in your @file{.screenrc}. @end menu @node Title Command, Dynamic Titles, , Naming Windows @subsection Title Command @kindex A @deffn Command title [windowtitle] (@kbd{C-a A})@* Set the name of the current window to @var{windowtitle}. If no name is specified, screen prompts for one. @end deffn @node Dynamic Titles, Title Prompts, Title Command, Naming Windows @subsection Dynamic Titles @code{screen} has a shell-specific heuristic that is enabled by setting the window's name to @var{search|name} and arranging to have a null title escape-sequence output as a part of your prompt. The @var{search} portion specifies an end-of-prompt search string, while the @var{name} portion specifies the default shell name for the window. If the @var{name} ends in a @samp{:} @code{screen} will add what it believes to be the current command running in the window to the end of the specified name (e.g. @var{name:cmd}). Otherwise the current command name supersedes the shell name while it is running. Here's how it works: you must modify your shell prompt to output a null title-escape-sequence (@key{ESC} k @key{ESC} \) as a part of your prompt. The last part of your prompt must be the same as the string you specified for the @var{search} portion of the title. Once this is set up, @code{screen} will use the title-escape-sequence to clear the previous command name and get ready for the next command. Then, when a newline is received from the shell, a search is made for the end of the prompt. If found, it will grab the first word after the matched string and use it as the command name. If the command name begins with @samp{!}, @samp{%}, or @samp{^}, @code{screen} will use the first word on the following line (if found) in preference to the just-found name. This helps csh users get more accurate titles when using job control or history recall commands. @node Title Prompts, Title Screenrc, Dynamic Titles, Naming Windows @subsection Setting up your prompt for shell titles One thing to keep in mind when adding a null title-escape-sequence to your prompt is that some shells (like the csh) count all the non-control characters as part of the prompt's length. If these invisible characters aren't a multiple of 8 then backspacing over a tab will result in an incorrect display. One way to get around this is to use a prompt like this: @example set prompt='@value{esc}[0000m@value{esc}k@value{esc}\% ' @end example The escape-sequence @samp{@value{esc}[0000m} not only normalizes the character attributes, but all the zeros round the length of the invisible characters up to 8. Tcsh handles escape codes in the prompt more intelligently, so you can specify your prompt like this: @example set prompt="%@{\ek\e\\%@}\% " @end example Bash users will probably want to echo the escape sequence in the PROMPT_COMMAND: @example PROMPT_COMMAND='printf "\033k\033\134"' @end example (I used @samp{\134} to output a @samp{\} because of a bug in v1.04). @node Title Screenrc, , Title Prompts, Naming Windows @subsection Setting up shell titles in your @file{.screenrc} Here are some .screenrc examples: @example screen -t top 2 nice top @end example Adding this line to your .screenrc would start a niced version of the @code{top} command in window 2 named @samp{top} rather than @samp{nice}. @example shelltitle '> |csh' screen 1 @end example This file would start a shell using the given shelltitle. The title specified is an auto-title that would expect the prompt and the typed command to look something like the following: @example /usr/joe/src/dir> trn @end example (it looks after the '> ' for the command name). The window status would show the name @samp{trn} while the command was running, and revert to @samp{csh} upon completion. @example bind R screen -t '% |root:' su @end example Having this command in your .screenrc would bind the key sequence @kbd{C-a R} to the @code{su} command and give it an auto-title name of @samp{root:}. For this auto-title to work, the screen could look something like this: @example % !em emacs file.c @end example Here the user typed the csh history command @code{!em} which ran the previously entered @code{emacs} command. The window status would show @samp{root:emacs} during the execution of the command, and revert to simply @samp{root:} at its completion. @example bind o title bind E title "" bind u title (unknown) @end example The first binding doesn't have any arguments, so it would prompt you for a title when you type @kbd{C-a o}. The second binding would clear an auto-titles current setting (C-a E). The third binding would set the current window's title to @samp{(unknown)} (C-a u). @node Console, Kill, Naming Windows, Window Settings @section Console @deffn Command console [@var{state}] (none)@* Grabs or un-grabs the machines console output to a window. When the argument is omitted the current state is displayed. @emph{Note}: Only the owner of @file{/dev/console} can grab the console output. This command is only available if the host supports the ioctl @code{TIOCCONS}. @end deffn @node Kill, Login, Console, Window Settings @section Kill @kindex k @kindex C-k @deffn Command kill (@kbd{C-a k}, @kbd{C-a C-k})@* Kill the current window.@* If there is an @code{exec} command running (@pxref{Exec}) then it is killed. Otherwise the process (e.g. shell) running in the window receives a @code{HANGUP} condition, the window structure is removed and screen (your display) switches to another window. When the last window is destroyed, @code{screen} exits. After a kill screen switches to the previously displayed window. @* @emph{Caution}: @code{emacs} users may find themselves killing their @code{emacs} session when trying to delete the current line. For this reason, it is probably wise to use a different command character (@pxref{Command Character}) or rebind @code{kill} to another key sequence, such as @kbd{C-a K} (@pxref{Key Binding}). @end deffn @node Login, Mode, Kill, Window Settings @section Login @deffn Command deflogin state (none)@* Same as the @code{login} command except that the default setting for new windows is changed. This defaults to `on' unless otherwise specified at compile time (@pxref{Installation}). Both commands are only present when @code{screen} has been compiled with utmp support. @end deffn @kindex L @deffn Command login [state] (@kbd{C-a L})@* Adds or removes the entry in @file{/etc/utmp} for the current window. This controls whether or not the window is @dfn{logged in}. In addition to this toggle, it is convenient to have ``log in'' and ``log out'' keys. For instance, @code{bind I login on} and @code{bind O login off} will map these keys to be @kbd{C-a I} and @kbd{C-a O} (@pxref{Key Binding}). @end deffn @node Mode, Monitor, Login, Window Settings @section Mode @deffn Command defmode mode (none)@* The mode of each newly allocated pseudo-tty is set to @var{mode}. @var{mode} is an octal number as used by chmod(1). Defaults to 0622 for windows which are logged in, 0600 for others (e.g. when @code{-ln} was specified for creation, @pxref{Screen Command}). @end deffn @node Monitor, Windows, Mode, Window Settings @section Monitoring @deffn Command activity message (none)@* When any activity occurs in a background window that is being monitored, @code{screen} displays a notification in the message line. The notification message can be redefined by means of the @code{activity} command. Each occurrence of @samp{%} in @var{message} is replaced by the number of the window in which activity has occurred, and each occurrence of @samp{^G} is replaced by the definition for bell in your termcap (usually an audible bell). The default message is @example 'Activity in window %n' @end example Note that monitoring is off for all windows by default, but can be altered by use of the @code{monitor} command (@kbd{C-a M}). @end deffn @deffn Command defmonitor state (none)@* Same as the @code{monitor} command except that the default setting for new windows is changed. Initial setting is `off'. @end deffn @kindex M @deffn Command monitor [state] (@kbd{C-a M})@* Toggles monitoring of the current window. When monitoring is turned on and the affected window is switched into the background, the activity notification message will be displayed in the status line at the first sign of output, and the window will also be marked with an @samp{@@} in the window-status display (@pxref{Windows}). Monitoring defaults to @samp{off} for all windows. @end deffn @kindex _ @deffn Command silence [@var{state}|@var{sec}] (@kbd{C-a _})@* Toggles silence monitoring of windows. When silence is turned on and an affected window is switched into the background, you will receive the silence notification message in the status line after a specified period of inactivity (silence). The default timeout can be changed with the @code{silencewait} command or by specifying a number of seconds instead of @code{on} or @code{off}. Silence is initially off for all windows. @end deffn @deffn Command defsilence state (none)@* Same as the @code{silence} command except that the default setting for new windows is changed. Initial setting is `off'. @end deffn @deffn Command silencewait @var{seconds} (none)@* Define the time that all windows monitored for silence should wait before displaying a message. Default is 30 seconds. @end deffn @node Windows, Hardstatus, Monitor, Window Settings @section Windows @kindex w @kindex C-w @deffn Command windows [ string ] (@kbd{C-a w}, @kbd{C-a C-w})@* Uses the message line to display a list of all the windows. Each window is listed by number with the name of the program running in the window (or its title). The current window is marked with a @samp{*}; the previous window is marked with a @samp{-}; all the windows that are logged in are marked with a @samp{$} (@pxref{Login}); a background window that has received a bell is marked with a @samp{!}; a background window that is being monitored and has had activity occur is marked with an @samp{@@} (@pxref{Monitor}); a window which has output logging turned on is marked with @samp{(L)}; windows occupied by other users are marked with @samp{&} or @samp{&&} if the window is shared by other users; windows in the zombie state are marked with @samp{Z}. If this list is too long to fit on the terminal's status line only the portion around the current window is displayed. You can customize the output format to any string you like including string escapes (@pxref{String Escapes}). In this case, if the string parameter is passed, the maximum output size is unlimited (instead of 1024 bytes if no parameter is passed). @end deffn @node Hardstatus, Mousetrack, Windows, Window Settings @section Hardstatus @code{Screen} maintains a hardstatus line for every window. If a window gets selected, the display's hardstatus will be updated to match the window's hardstatus line. The hardstatus line can be changed with the ANSI Application Program Command (APC): @samp{ESC_ESC\}. As a convenience for xterm users the sequence @samp{ESC]0..2;^G} is also accepted. @deffn Command defhstatus [status] (none)@* The hardstatus line that all new windows will get is set to @var{status}. This command is useful to make the hardstatus of every window display the window number or title or the like. @var{status} may contain the same directives as in the window messages, but the directive escape character is @samp{^E} (octal 005) instead of @samp{%}. This was done to make a misinterpretation of program generated hardstatus lines impossible. If the parameter @var{status} is omitted, the current default string is displayed. Per default the hardstatus line of new windows is empty. @end deffn @deffn Command hstatus status (none)@* Changes the current window's hardstatus line to @var{status}. @end deffn @node Mousetrack, , Hardstatus, Miscellaneous @section Mousetrack @deffn Command mousetrack [ @code{on|off} ] (none)@* This command determines whether @code{screen} will watch for mouse clicks. When this command is enabled, regions that have been split in various ways can be selected by pointing to them with a mouse and left-clicking them. Without specifying @var{on} or @var{off}, the current state is displayed. The default state is determined by the @code{defmousetrack} command. @end deffn @deffn Command defmousetrack @code{on|off} (none)@* This command determines the default state of the @code{mousetrack} command, currently defaulting of @var{off}. @end deffn @node Virtual Terminal, Copy and Paste, Window Settings, Top @chapter Virtual Terminal Each window in a @code{screen} session emulates a VT100 terminal, with some extra functions added. The VT100 emulator is hard-coded, no other terminal types can be emulated. The commands described here modify the terminal emulation. @menu * Control Sequences:: Details of the internal VT100 emulation. * Input Translation:: How keystrokes are remapped. * Digraph:: Entering digraph sequences. * Bell:: Getting your attention. * Clear:: Clear the window display. * Info:: Terminal emulation statistics. * Redisplay:: When the display gets confusing. * Wrap:: Automatic margins. * Reset:: Recovering from ill-behaved applications. * Window Size:: Changing the size of your terminal. * Character Processing:: Change the effect of special characters. @end menu @node Control Sequences, Input Translation, , Virtual Terminal @section Control Sequences @cindex control sequences The following is a list of control sequences recognized by @code{screen}. @samp{(V)} and @samp{(A)} indicate VT100-specific and ANSI- or ISO-specific functions, respectively. @example ESC E Next Line ESC D Index ESC M Reverse Index ESC H Horizontal Tab Set ESC Z Send VT100 Identification String ESC 7 (V) Save Cursor and Attributes ESC 8 (V) Restore Cursor and Attributes ESC [s (A) Save Cursor and Attributes ESC [u (A) Restore Cursor and Attributes ESC c Reset to Initial State ESC g Visual Bell ESC Pn p Cursor Visibility (97801) Pn = 6 Invisible 7 Visible ESC = (V) Application Keypad Mode ESC > (V) Numeric Keypad Mode ESC # 8 (V) Fill Screen with E's ESC \ (A) String Terminator ESC ^ (A) Privacy Message String (Message Line) ESC ! Global Message String (Message Line) ESC k Title Definition String ESC P (A) Device Control String Outputs a string directly to the host terminal without interpretation. ESC _ (A) Application Program Command (Hardstatus) ESC ] 0 ; string ^G (A) Operating System Command (Hardstatus, xterm title hack) ESC ] 83 ; cmd ^G (A) Execute screen command. This only works if multi-user support is compiled into screen. The pseudo-user ":window:" is used to check the access control list. Use "addacl :window: -rwx #?" to create a user with no rights and allow only the needed commands. Control-N (A) Lock Shift G1 (SO) Control-O (A) Lock Shift G0 (SI) ESC n (A) Lock Shift G2 ESC o (A) Lock Shift G3 ESC N (A) Single Shift G2 ESC O (A) Single Shift G3 ESC ( Pcs (A) Designate character set as G0 ESC ) Pcs (A) Designate character set as G1 ESC * Pcs (A) Designate character set as G2 ESC + Pcs (A) Designate character set as G3 ESC [ Pn ; Pn H Direct Cursor Addressing ESC [ Pn ; Pn f same as above ESC [ Pn J Erase in Display Pn = None or 0 From Cursor to End of Screen 1 From Beginning of Screen to Cursor 2 Entire Screen ESC [ Pn K Erase in Line Pn = None or 0 From Cursor to End of Line 1 From Beginning of Line to Cursor 2 Entire Line ESC [ Pn X Erase character ESC [ Pn A Cursor Up ESC [ Pn B Cursor Down ESC [ Pn C Cursor Right ESC [ Pn D Cursor Left ESC [ Pn E Cursor next line ESC [ Pn F Cursor previous line ESC [ Pn G Cursor horizontal position ESC [ Pn ` same as above ESC [ Pn d Cursor vertical position ESC [ Ps ;...; Ps m Select Graphic Rendition Ps = None or 0 Default Rendition 1 Bold 2 (A) Faint 3 (A) @i{Standout} Mode (ANSI: Italicized) 4 Underlined 5 Blinking 7 Negative Image 22 (A) Normal Intensity 23 (A) @i{Standout} Mode off (ANSI: Italicized off) 24 (A) Not Underlined 25 (A) Not Blinking 27 (A) Positive Image 30 (A) Foreground Black 31 (A) Foreground Red 32 (A) Foreground Green 33 (A) Foreground Yellow 34 (A) Foreground Blue 35 (A) Foreground Magenta 36 (A) Foreground Cyan 37 (A) Foreground White 39 (A) Foreground Default 40 (A) Background Black ... ... 49 (A) Background Default ESC [ Pn g Tab Clear Pn = None or 0 Clear Tab at Current Position 3 Clear All Tabs ESC [ Pn ; Pn r (V) Set Scrolling Region ESC [ Pn I (A) Horizontal Tab ESC [ Pn Z (A) Backward Tab ESC [ Pn L (A) Insert Line ESC [ Pn M (A) Delete Line ESC [ Pn @@ (A) Insert Character ESC [ Pn P (A) Delete Character ESC [ Pn S Scroll Scrolling Region Up ESC [ Pn T Scroll Scrolling Region Down ESC [ Pn ^ same as above ESC [ Ps ;...; Ps h Set Mode ESC [ Ps ;...; Ps l Reset Mode Ps = 4 (A) Insert Mode 20 (A) @samp{Automatic Linefeed} Mode. 34 Normal Cursor Visibility ?1 (V) Application Cursor Keys ?3 (V) Change Terminal Width to 132 columns ?5 (V) Reverse Video ?6 (V) @samp{Origin} Mode ?7 (V) @samp{Wrap} Mode ?9 X10 mouse tracking ?25 (V) Visible Cursor ?47 Alternate Screen (old xterm code) ?1000 (V) VT200 mouse tracking ?1047 Alternate Screen (new xterm code) ?1049 Alternate Screen (new xterm code) ESC [ 5 i (A) Start relay to printer (ANSI Media Copy) ESC [ 4 i (A) Stop relay to printer (ANSI Media Copy) ESC [ 8 ; Ph ; Pw t Resize the window to @samp{Ph} lines and @samp{Pw} columns (SunView special) ESC [ c Send VT100 Identification String ESC [ x (V) Send Terminal Parameter Report ESC [ > c Send Secondary Device Attributes String ESC [ 6 n Send Cursor Position Report @end example @node Input Translation, Digraph, Control Sequences, Virtual Terminal @section Input Translation @cindex input translation In order to do a full VT100 emulation @code{screen} has to detect that a sequence of characters in the input stream was generated by a keypress on the user's keyboard and insert the VT100 style escape sequence. @code{Screen} has a very flexible way of doing this by making it possible to map arbitrary commands on arbitrary sequences of characters. For standard VT100 emulation the command will always insert a string in the input buffer of the window (see also command @code{stuff}, @pxref{Paste}). Because the sequences generated by a keypress can change after a reattach from a different terminal type, it is possible to bind commands to the termcap name of the keys. @code{Screen} will insert the correct binding after each reattach. See @ref{Bindkey} for further details on the syntax and examples. Here is the table of the default key bindings. (A) means that the command is executed if the keyboard is switched into application mode. @example Key name Termcap name Command ----------------------------------------------------- Cursor up ku stuff \033[A stuff \033OA (A) Cursor down kd stuff \033[B stuff \033OB (A) Cursor right kr stuff \033[C stuff \033OC (A) Cursor left kl stuff \033[D stuff \033OD (A) Function key 0 k0 stuff \033[10~ Function key 1 k1 stuff \033OP Function key 2 k2 stuff \033OQ Function key 3 k3 stuff \033OR Function key 4 k4 stuff \033OS Function key 5 k5 stuff \033[15~ Function key 6 k6 stuff \033[17~ Function key 7 k7 stuff \033[18~ Function key 8 k8 stuff \033[19~ Function key 9 k9 stuff \033[20~ Function key 10 k; stuff \033[21~ Function key 11 F1 stuff \033[23~ Function key 12 F2 stuff \033[24~ Home kh stuff \033[1~ End kH stuff \033[4~ Insert kI stuff \033[2~ Delete kD stuff \033[3~ Page up kP stuff \033[5~ Page down kN stuff \033[6~ Keypad 0 f0 stuff 0 stuff \033Op (A) Keypad 1 f1 stuff 1 stuff \033Oq (A) Keypad 2 f2 stuff 2 stuff \033Or (A) Keypad 3 f3 stuff 3 stuff \033Os (A) Keypad 4 f4 stuff 4 stuff \033Ot (A) Keypad 5 f5 stuff 5 stuff \033Ou (A) Keypad 6 f6 stuff 6 stuff \033Ov (A) Keypad 7 f7 stuff 7 stuff \033Ow (A) Keypad 8 f8 stuff 8 stuff \033Ox (A) Keypad 9 f9 stuff 9 stuff \033Oy (A) Keypad + f+ stuff + stuff \033Ok (A) Keypad - f- stuff - stuff \033Om (A) Keypad * f* stuff * stuff \033Oj (A) Keypad / f/ stuff / stuff \033Oo (A) Keypad = fq stuff = stuff \033OX (A) Keypad . f. stuff . stuff \033On (A) Keypad , f, stuff , stuff \033Ol (A) Keypad enter fe stuff \015 stuff \033OM (A) @end example @node Digraph, Bell, Input Translation, Virtual Terminal @section Digraph @kindex C-v @deffn Command digraph [preset [unicode-value]] (@kbd{C-a C-v})@* This command prompts the user for a digraph sequence. The next two characters typed are looked up in a builtin table and the resulting character is inserted in the input stream. For example, if the user enters @samp{a"}, an a-umlaut will be inserted. If the first character entered is a 0 (zero), @code{screen} will treat the following characters (up to three) as an octal number instead. The optional argument @var{preset} is treated as user input, thus one can create an "umlaut" key. For example the command @samp{bindkey ^K digraph '"'} enables the user to generate an a-umlaut by typing @samp{CTRL-K a}. When a non-zero @var{unicode-value} is specified, a new digraph is created with the specified preset. The digraph is unset if a zero value is provided for the @var{unicode-value}. The following table is the builtin sequences. @example Sequence Octal Digraph Unicode Equivalent ----------------------------------------------- ' ', ' ' 160 (space) U+00A0 'N', 'S' 160 (space) U+00A0 '~', '!' 161 U+00A1 '!', '!' 161 U+00A1 '!', 'I' 161 U+00A1 'c', '|' 162 U+00A2 'c', 't' 162 U+00A2 '$', '$' 163 U+00A3 'P', 'd' 163 U+00A3 'o', 'x' 164 U+00A4 'C', 'u' 164 U+00A4 'C', 'u' 164 U+00A4 'E', 'u' 164 U+00A4 'Y', '-' 165 U+00A5 'Y', 'e' 165 U+00A5 '|', '|' 166 U+00A6 'B', 'B' 166 U+00A6 'p', 'a' 167 U+00A7 'S', 'E' 167 U+00A7 '"', '"' 168 U+00A8 ''', ':' 168 U+00A8 'c', 'O' 169 U+00A9 'C', 'o' 169 U+00A9 'a', '-' 170 U+00AA '<', '<' 171 U+00AB '-', ',' 172 U+00AC 'N', 'O' 172 U+00AC '-', '-' 173 U+00AD 'r', 'O' 174 U+00AE 'R', 'g' 174 U+00AE '-', '=' 175 U+00AF ''', 'm' 175 U+00AF '~', 'o' 176 U+00B0 'D', 'G' 176 U+00B0 '+', '-' 177 U+00B1 '2', '2' 178 U+00B2 '2', 'S' 178 U+00B2 '3', '3' 179 U+00B3 '3', 'S' 179 U+00B3 ''', ''' 180 U+00B4 'j', 'u' 181 U+00B5 'M', 'y' 181 U+00B5 'p', 'p' 182 U+00B6 'P', 'I' 182 U+00B6 '~', '.' 183 U+00B7 '.', 'M' 183 U+00B7 ',', ',' 184 U+00B8 ''', ',' 184 U+00B8 '1', '1' 185 U+00B9 '1', 'S' 185 U+00B9 'o', '-' 186 U+00BA '>', '>' 187 U+00BB '1', '4' 188 U+00BC '1', '2' 189 U+00BD '3', '4' 190 U+00BE '~', '?' 191 U+00BF '?', '?' 191 U+00BF '?', 'I' 191 U+00BF 'A', '`' 192 U+00C0 'A', '!' 192 U+00C0 'A', ''' 193 U+00C1 'A', '^' 194 U+00C2 'A', '>' 194 U+00C2 'A', '~' 195 U+00C3 'A', '?' 195 U+00C3 'A', '"' 196 U+00C4 'A', ':' 196 U+00C4 'A', '@@' 197 U+00C5 'A', 'A' 197 U+00C5 'A', 'E' 198 U+00C6 'C', ',' 199 U+00C7 'E', '`' 200 U+00C8 'E', '!' 200 U+00C8 'E', ''' 201 U+00C9 'E', '^' 202 U+00CA 'E', '>' 202 U+00CA 'E', '"' 203 U+00CB 'E', ':' 203 U+00CB 'I', '`' 204 U+00CC 'I', '!' 204 U+00CC 'I', ''' 205 U+00CD 'I', '^' 206 U+00CE 'I', '>' 206 U+00CE 'I', '"' 207 U+00CF 'I', ':' 207 U+00CF 'D', '-' 208 U+00D0 'N', '~' 209 U+00D1 'N', '?' 209 U+00D1 'O', '`' 210 U+00D2 'O', '!' 210 U+00D2 'O', ''' 211 U+00D3 'O', '^' 212 U+00D4 'O', '>' 212 U+00D4 'O', '~' 213 U+00D5 'O', '?' 213 U+00D5 'O', '"' 214 U+00D6 'O', ':' 214 U+00D6 '/', '\' 215 U+00D7 '*', 'x' 215 U+00D7 'O', '/' 216 U+00D8 'U', '`' 217 U+00D9 'U', '!' 217 U+00D9 'U', ''' 218 U+00DA 'U', '^' 219 U+00DB 'U', '>' 219 U+00DB 'U', '"' 220 U+00DC 'U', ':' 220 U+00DC 'Y', ''' 221 U+00DD 'I', 'p' 222 U+00DE 'T', 'H' 222 U+00DE 's', 's' 223 U+00DF 's', '"' 223 U+00DF 'a', '`' 224 U+00E0 'a', '!' 224 U+00E0 'a', ''' 225 U+00E1 'a', '^' 226 U+00E2 'a', '>' 226 U+00E2 'a', '~' 227 U+00E3 'a', '?' 227 U+00E3 'a', '"' 228 U+00E4 'a', ':' 228 U+00E4 'a', 'a' 229 U+00E5 'a', 'e' 230 U+00E6 'c', ',' 231 U+00E7 'e', '`' 232 U+00E8 'e', '!' 232 U+00E8 'e', ''' 233 U+00E9 'e', '^' 234 U+00EA 'e', '>' 234 U+00EA 'e', '"' 235 U+00EB 'e', ':' 235 U+00EB 'i', '`' 236 U+00EC 'i', '!' 236 U+00EC 'i', ''' 237 U+00ED 'i', '^' 238 U+00EE 'i', '>' 238 U+00EE 'i', '"' 239 U+00EF 'i', ':' 239 U+00EF 'd', '-' 240 U+00F0 'n', '~' 241 U+00F1 'n', '?' 241 U+00F1 'o', '`' 242 U+00F2 'o', '!' 242 U+00F2 'o', ''' 243 U+00F3 'o', '^' 244 U+00F4 'o', '>' 244 U+00F4 'o', '~' 245 U+00F5 'o', '?' 245 U+00F5 'o', '"' 246 U+00F6 'o', ':' 246 U+00F6 ':', '-' 247 U+00F7 'o', '/' 248 U+00F8 'u', '`' 249 U+00F9 'u', '!' 249 U+00F9 'u', ''' 250 U+00FA 'u', '^' 251 U+00FB 'u', '>' 251 U+00FB 'u', '"' 252 U+00FC 'u', ':' 252 U+00FC 'y', ''' 253 U+00FD 'i', 'p' 254 U+00FE 't', 'h' 254 U+00FE 'y', '"' 255 U+00FF 'y', ':' 255 U+00FF '"', '[' 196 U+00C4 '"', '\' 214 U+00D6 '"', ']' 220 U+00DC '"', '@{' 228 U+00E4 '"', '|' 246 U+00F6 '"', '@}' 252 U+00FC '"', '~' 223 U+00DF @end example @end deffn @node Bell, Clear, Digraph, Virtual Terminal @section Bell @deffn Command bell_msg [message] (none)@* When a bell character is sent to a background window, @code{screen} displays a notification in the message line. The notification message can be re-defined by this command. Each occurrence of @samp{%} in @var{message} is replaced by the number of the window to which a bell has been sent, and each occurrence of @samp{^G} is replaced by the definition for bell in your termcap (usually an audible bell). The default message is @example 'Bell in window %n' @end example An empty message can be supplied to the @code{bell_msg} command to suppress output of a message line (@code{bell_msg ""}). Without a parameter, the current message is shown. @end deffn @kindex C-g @deffn Command vbell [state] (@kbd{C-a C-g})@* Sets or toggles the visual bell setting for the current window. If @code{vbell} is switched to @samp{on}, but your terminal does not support a visual bell, the visual bell message is displayed in the status line when the bell character is received. Visual bell support of a terminal is defined by the termcap variable @code{vb}. @xref{Bell}, for more information on visual bells. The equivalent terminfo capability is @code{flash}. Per default, @code{vbell} is @samp{off}, thus the audible bell is used. @end deffn @deffn Command vbell_msg [message] (none)@* Sets the visual bell message. @var{Message} is printed to the status line if the window receives a bell character (^G), @code{vbell} is set to @samp{on} and the terminal does not support a visual bell. The default message is @samp{Wuff, Wuff!!}. Without a parameter, the current message is shown. @end deffn @deffn Command vbellwait sec (none)@* Define a delay in seconds after each display of @code{screen} 's visual bell message. The default is 1 second. @end deffn @node Clear, Info, Bell, Virtual Terminal @section Clear @kindex C @deffn Command clear (@kbd{C-a C})@* Clears the screen and saves its contents to the scrollback buffer. @end deffn @node Info, Redisplay, Clear, Virtual Terminal @section Info @kindex i @kindex C-i @deffn Command info (@kbd{C-a i}, @kbd{C-a C-i})@* Uses the message line to display some information about the current window: the cursor position in the form @samp{(@var{column},@var{row})} starting with @samp{(1,1)}, the terminal width and height plus the size of the scrollback buffer in lines, like in @samp{(80,24)+50}, the current state of window XON/XOFF flow control is shown like this (@pxref{Flow Control}): @example +flow automatic flow control, currently on. -flow automatic flow control, currently off. +(+)flow flow control enabled. Agrees with automatic control. -(+)flow flow control disabled. Disagrees with automatic control. +(-)flow flow control enabled. Disagrees with automatic control. -(-)flow flow control disabled. Agrees with automatic control. @end example The current line wrap setting (@samp{+wrap} indicates enabled, @samp{-wrap} not) is also shown. The flags @samp{ins}, @samp{org}, @samp{app}, @samp{log}, @samp{mon} and @samp{nored} are displayed when the window is in insert mode, origin mode, application-keypad mode, has output logging, activity monitoring or partial redraw enabled. The currently active character set (@samp{G0}, @samp{G1}, @samp{G2}, or @samp{G3}), and in square brackets the terminal character sets that are currently designated as @samp{G0} through @samp{G3}. If the window is in UTF-8 mode, the string @samp{UTF-8} is shown instead. Additional modes depending on the type of the window are displayed at the end of the status line (@pxref{Window Types}). If the state machine of the terminal emulator is in a non-default state, the info line is started with a string identifying the current state. For system information use @code{time}. @end deffn @deffn Command dinfo (none)@* Show what @code{screen} thinks about your terminal. Useful if you want to know why features like color or the alternate charset don't work. @end deffn @node Redisplay, Wrap, Info, Virtual Terminal @section Redisplay @deffn Command allpartial state (none)@* If set to on, only the current cursor line is refreshed on window change. This affects all windows and is useful for slow terminal lines. The previous setting of full/partial refresh for each window is restored with @code{allpartial off}. This is a global flag that immediately takes effect on all windows overriding the @code{partial} settings. It does not change the default redraw behavior of newly created windows. @end deffn @deffn Command altscreen state (none)@* If set to on, "alternate screen" support is enabled in virtual terminals, just like in xterm. Initial setting is @samp{off}. @end deffn @deffn Command partial state (none)@* Defines whether the display should be refreshed (as with @code{redisplay}) after switching to the current window. This command only affects the current window. To immediately affect all windows use the @code{allpartial} command. Default is @samp{off}, of course. This default is fixed, as there is currently no @code{defpartial} command. @end deffn @kindex l @kindex C-l @deffn Command redisplay (@kbd{C-a l}, @kbd{C-a C-l})@* Redisplay the current window. Needed to get a full redisplay in partial redraw mode. @end deffn @node Wrap, Reset, Redisplay, Virtual Terminal @section Wrap @kindex r @kindex C-r @deffn Command wrap [ on | off ] (@kbd{C-a r}, @kbd{C-a C-r}) @* Sets the line-wrap setting for the current window. When line-wrap is on, the second consecutive printable character output at the last column of a line will wrap to the start of the following line. As an added feature, backspace (^H) will also wrap through the left margin to the previous line. Default is @samp{on}. Without any options, the state of @code{wrap} is toggled. @end deffn @deffn Command defwrap state (none) @* Same as the @code{wrap} command except that the default setting for new windows is changed. Initially line-wrap is on and can be toggled with the @code{wrap} command (@kbd{C-a r}) or by means of "C-a : wrap on|off". @end deffn @node Reset, Window Size, Wrap, Virtual Terminal @section Reset @kindex Z @deffn Command reset (@kbd{C-a Z})@* Reset the virtual terminal to its ``power-on'' values. Useful when strange settings (like scroll regions or graphics character set) are left over from an application. @end deffn @node Window Size, Character Processing, Reset, Virtual Terminal @section Window Size @kindex W @deffn Command width [@code{-w}|@code{-d}] [cols [lines]] (@kbd{C-a W})@* Toggle the window width between 80 and 132 columns, or set it to @var{cols} columns if an argument is specified. This requires a capable terminal and the termcap entries @samp{Z0} and @samp{Z1}. See the @code{termcap} command (@pxref{Termcap}), for more information. You can also specify a height if you want to change both values. The @code{-w} option tells screen to leave the display size unchanged and just set the window size, @code{-d} vice versa. @end deffn @deffn Command height [@code{-w}|@code{-d}] [lines [cols]] (none)@* Set the display height to a specified number of lines. When no argument is given it toggles between 24 and 42 lines display. @end deffn @node Character Processing, ,Window Size, Virtual Terminal @section Character Processing @deffn Command c1 [state] (none)@* Change c1 code processing. @samp{c1 on} tells screen to treat the input characters between 128 and 159 as control functions. Such an 8-bit code is normally the same as ESC followed by the corresponding 7-bit code. The default setting is to process c1 codes and can be changed with the @samp{defc1} command. Users with fonts that have usable characters in the c1 positions may want to turn this off. @end deffn @deffn Command gr [state] (none)@* Turn GR charset switching on/off. Whenever screen sees an input char with an 8th bit set, it will use the charset stored in the GR slot and print the character with the 8th bit stripped. The default (see also @samp{defgr}) is not to process GR switching because otherwise the ISO88591 charset would not work. @end deffn @deffn Command bce [state] (none)@* Change background-color-erase setting. If @samp{bce} is set to on, all characters cleared by an erase/insert/scroll/clear operation will be displayed in the current background color. Otherwise the default background color is used. @end deffn @deffn Command encoding enc [denc] (none)@* Tell screen how to interpret the input/output. The first argument sets the encoding of the current window. Each window can emulate a different encoding. The optional second parameter overwrites the encoding of the connected terminal. It should never be needed as screen uses the locale setting to detect the encoding. There is also a way to select a terminal encoding depending on the terminal type by using the @samp{KJ} termcap entry. @xref{Special Capabilities}. Supported encodings are @code{eucJP}, @code{SJIS}, @code{eucKR}, @code{eucCN}, @code{Big5}, @code{GBK}, @code{KOI8-R}, @code{CP1251}, @code{UTF-8}, @code{ISO8859-2}, @code{ISO8859-3}, @code{ISO8859-4}, @code{ISO8859-5}, @code{ISO8859-6}, @code{ISO8859-7}, @code{ISO8859-8}, @code{ISO8859-9}, @code{ISO8859-10}, @code{ISO8859-15}, @code{jis}. See also @samp{defencoding}, which changes the default setting of a new window. @end deffn @deffn Command charset set (none)@* Change the current character set slot designation and charset mapping. The first four character of @var{set} are treated as charset designators while the fifth and sixth character must be in range @samp{0} to @samp{3} and set the GL/GR charset mapping. On every position a @samp{.} may be used to indicate that the corresponding charset/mapping should not be changed (@var{set} is padded to six characters internally by appending @samp{.} chars). New windows have @samp{BBBB02} as default charset, unless a @samp{encoding} command is active. The current setting can be viewed with the @ref{Info} command. @end deffn @deffn Command utf8 [state [dstate]] (none)@* Change the encoding used in the current window. If utf8 is enabled, the strings sent to the window will be UTF-8 encoded and vice versa. Omitting the parameter toggles the setting. If a second parameter is given, the display's encoding is also changed (this should rather be done with screen's @samp{-U} option). See also @samp{defutf8}, which changes the default setting of a new window. @end deffn @deffn Command defc1 state (none)@* Same as the @samp{c1} command except that the default setting for new windows is changed. Initial setting is @samp{on}. @end deffn @deffn Command defgr state (none)@* Same as the @samp{gr} command except that the default setting for new windows is changed. Initial setting is @samp{off}. @end deffn @deffn Command defbce state (none)@* Same as the @samp{bce} command except that the default setting for new windows is changed. Initial setting is @samp{off}. @end deffn @deffn Command defencoding enc (none)@* Same as the @samp{encoding} command except that the default setting for new windows is changed. Initial setting is the encoding taken from the terminal. @end deffn @deffn Command defcharset [set] (none)@* Like the @samp{charset} command except that the default setting for new windows is changed. Shows current default if called without argument. @end deffn @deffn Command defutf8 state (none)@* Same as the @samp{utf8} command except that the default setting for new windows is changed. Initial setting is @code{on} if screen was started with @samp{-U}, otherwise @code{off}. @end deffn @deffn Command cjkwidth [state] (none)@* Toggle how ambiguoous characters are treated. If cjkwidth is on screen interprets them as double (full) width characters. If off then they are seen as one cell (half) width characters. @end deffn @node Copy and Paste, Subprocess Execution, Virtual Terminal, Top @chapter Copy and Paste @cindex copy and paste For those confined to a hardware terminal, these commands provide a cut and paste facility more powerful than those provided by most windowing systems. @menu * Copy:: Copy from scrollback to buffer * Paste:: Paste from buffer into window * Registers:: Longer-term storage * Screen Exchange:: Sharing data between screen users * History:: Recalling previous input @end menu @node Copy, Paste, , Copy and Paste @section Copying @cindex marking @cindex scrollback @kindex [ @kindex C-[ @kindex ESC @deffn Command copy (@kbd{C-a [}, @kbd{C-a C-[}, @kbd{C-a @key{ESC}})@* Enter copy/scrollback mode. This allows you to copy text from the current window and its history into the paste buffer. In this mode a @code{vi}-like full screen editor is active, with controls as outlined below. @end deffn @menu * Line Termination:: End copied lines with CR/LF * Scrollback:: Set the size of the scrollback buffer * Copy Mode Keys:: Remap keys in copy mode * Movement:: Move around in the scrollback buffer * Marking:: Select the text you want * Repeat count:: Repeat a command * Searching:: Find the text you want * Specials:: Other random keys @end menu @node Line Termination, Scrollback, , Copy @subsection CR/LF @deffn Command crlf [state] (none)@* This affects the copying of text regions with the @code{copy} command. If it is set to @samp{on}, lines will be separated by the two character sequence @samp{CR}/@samp{LF}. Otherwise only @samp{LF} is used. @code{crlf} is off by default. When no parameter is given, the state is toggled. @end deffn @node Scrollback, Copy Mode Keys, Line Termination, Copy @subsection Scrollback To access and use the contents in the scrollback buffer, use the @code{copy} command. @xref{Copy}. @deffn Command defscrollback num (none)@* Same as the @code{scrollback} command except that the default setting for new windows is changed. Defaults to 100. @end deffn @deffn Command scrollback num (none)@* Set the size of the scrollback buffer for the current window to @var{num} lines. The default scrollback is 100 lines. Use @code{info} to view the current setting. @end deffn @deffn Command compacthist [state] (none)@* This tells screen whether to suppress trailing blank lines when scrolling up text into the history buffer. Turn compacting @samp{on} to hold more useful lines in your scrollback buffer. @end deffn @node Copy Mode Keys, Movement, Scrollback, Copy @subsection Markkeys @deffn Command markkeys string (none)@* This is a method of changing the keymap used for copy/history mode. The string is made up of @var{oldchar}=@var{newchar} pairs which are separated by @samp{:}. Example: The command @code{markkeys h=^B:l=^F:$=^E} would set some keys to be more familiar to @code{emacs} users. If your terminal sends characters, that cause you to abort copy mode, then this command may help by binding these characters to do nothing. The no-op character is `@@' and is used like this: @code{markkeys @@=L=H} if you do not want to use the `H' or `L' commands any longer. As shown in this example, multiple keys can be assigned to one function in a single statement. @end deffn @node Movement, Marking, Copy Mode Keys, Copy @subsection Movement Keys @noindent @kbd{h}, @kbd{C-h}, or @kbd{left arrow} move the cursor left. @noindent @kbd{j}, @kbd{C-n}, or @kbd{down arrow} move the cursor down. @noindent @kbd{k}, @kbd{C-p}, or @kbd{up arrow} move the cursor up. @noindent @kbd{l} ('el'), or @kbd{right arrow} move the cursor right. @noindent @kbd{0} (zero) or @kbd{C-a} move to the leftmost column. @noindent @kbd{+} and @kbd{-} move the cursor to the leftmost column of the next or previous line. @noindent @kbd{H}, @kbd{M} and @kbd{L} move the cursor to the leftmost column of the top, center or bottom line of the window. @noindent @kbd{|} moves to the specified absolute column. @noindent @kbd{g} or @kbd{home} moves to the beginning of the buffer. @noindent @kbd{G} or @kbd{end} moves to the specified absolute line (default: end of buffer). @noindent @kbd{%} jumps to the specified percentage of the buffer. @noindent @kbd{^} or @kbd{$} move to the first or last non-whitespace character on the line. @noindent @kbd{w}, @kbd{b}, and @kbd{e} move the cursor word by word. @noindent @kbd{B}, @kbd{E} move the cursor WORD by WORD (as in vi). @noindent @kbd{f}/@kbd{F}, @kbd{t}/@kbd{T} move the cursor forward/backward to the next occurence of the target. (eg, '3fy' will move the cursor to the 3rd 'y' to the right.) @noindent @kbd{;} and @kbd{,} Repeat the last f/F/t/T command in the same/opposite direction. @noindent @kbd{C-e} and @kbd{C-y} scroll the display up/down by one line while preserving the cursor position. @noindent @kbd{C-u} and @kbd{C-d} scroll the display up/down by the specified amount of lines while preserving the cursor position. (Default: half screenful). @noindent @kbd{C-b} and @kbd{C-f} move the cursor up/down a full screen. Note that Emacs-style movement keys can be specified by a .screenrc command. (@code{markkeys "h=^B:l=^F:$=^E"}) There is no simple method for a full emacs-style keymap, however, as this involves multi-character codes. @node Marking, Repeat count, Movement, Copy @subsection Marking The copy range is specified by setting two marks. The text between these marks will be highlighted. Press: @noindent @kbd{space} or @kbd{enter} to set the first or second mark respectively. If @code{mousetrack} is set to @code{on}, marks can also be set using @kbd{left mouse click}. @noindent @kbd{Y} and @kbd{y} can be used to mark one whole line or to mark from start of line. @noindent @kbd{W} marks exactly one word. @node Repeat count, Searching, Marking, Copy @subsection Repeat Count Any command in copy mode can be prefixed with a number (by pressing digits @kbd{0@dots{}9}) which is taken as a repeat count. Example: @example @kbd{C-a C-[ H 10 j 5 Y} @end example @noindent will copy lines 11 to 15 into the paste buffer. @node Searching, Specials, Repeat count, Copy @subsection Searching @noindent @kbd{/} @code{vi}-like search forward. @noindent @kbd{?} @code{vi}-like search backward. @noindent @kbd{C-a s} @code{emacs} style incremental search forward. @noindent @kbd{C-r} @code{emacs} style reverse i-search. @deffn Command ignorecase [on|off] (none)@* Tell screen to ignore the case of characters in searches. Default is @code{off}. Without any options, the state of @code{ignorecase} is toggled. @end deffn @noindent @kbd{n} Repeat search in forward direction. @noindent @kbd{N} Repeat search in backward direction. @node Specials, , Searching, Copy @subsection Specials There are, however, some keys that act differently here from in @code{vi}. @code{Vi} does not allow to yank rectangular blocks of text, but @code{screen} does. Press: @noindent @kbd{c} or @kbd{C} to set the left or right margin respectively. If no repeat count is given, both default to the current cursor position.@* Example: Try this on a rather full text screen: @example @kbd{C-a [ M 20 l SPACE c 10 l 5 j C SPACE}. @end example @noindent This moves one to the middle line of the screen, moves in 20 columns left, marks the beginning of the paste buffer, sets the left column, moves 5 columns down, sets the right column, and then marks the end of the paste buffer. Now try: @example @kbd{C-a [ M 20 l SPACE 10 l 5 j SPACE} @end example @noindent and notice the difference in the amount of text copied. @noindent @kbd{J} joins lines. It toggles between 4 modes: lines separated by a newline character (012), lines glued seamless, lines separated by a single space or comma separated lines. Note that you can prepend the newline character with a carriage return character, by issuing a @code{set crlf on}. @noindent @kbd{v} or @kbd{V} is for all the @code{vi} users who use @code{:set numbers} - it toggles the left margin between column 9 and 1. @noindent @kbd{a} before the final @kbd{space} key turns on append mode. Thus the contents of the paste buffer will not be overwritten, but appended to. @noindent @kbd{A} turns on append mode and sets a (second) mark. @noindent @kbd{>} sets the (second) mark and writes the contents of the paste buffer to the screen-exchange file (@file{/tmp/screen-exchange} per default) once copy-mode is finished. @xref{Screen Exchange}.@* This example demonstrates how to dump the whole scrollback buffer to that file: @example @kbd{C-a [ g SPACE G $ >}. @end example @noindent @kbd{C-g} gives information about the current line and column. @noindent @kbd{x} or @kbd{o} ('oh') exchanges the first mark and the current cursor position. You can use this to adjust an already placed mark. @noindent @kbd{C-l} ('el') will redraw the screen. @noindent @kbd{@@} does nothing. Absolutely nothing. Does not even exit copy mode. @noindent All keys not described here exit copy mode. @node Paste, Registers, Copy, Copy and Paste @section Paste @kindex ] @kindex C-] @deffn Command paste [registers [destination]] (@kbd{C-a ]}, @kbd{C-a C-]})@* Write the (concatenated) contents of the specified registers to the stdin stream of the current window. The register @samp{.} is treated as the paste buffer. If no parameter is specified the user is prompted to enter a single register. The paste buffer can be filled with the @code{copy}, @code{history} and @code{readbuf} commands. Other registers can be filled with the @code{register}, @code{readreg} and @code{paste} commands. If @code{paste} is called with a second argument, the contents of the specified registers is pasted into the named destination register rather than the window. If @samp{.} is used as the second argument, the display's paste buffer is the destination. Note, that @code{paste} uses a wide variety of resources: Usually both, a current window and a current display are required. But whenever a second argument is specified no current window is needed. When the source specification only contains registers (not the paste buffer) then there need not be a current display (terminal attached), as the registers are a global resource. The paste buffer exists once for every user. @end deffn @deffn Command stuff [string] (none)@* Stuff the string @var{string} in the input buffer of the current window. This is like the @code{paste} command, but with much less overhead. Without a paramter, @code{screen} will prompt for a string to stuff. You cannot paste large buffers with the @code{stuff} command. It is most useful for key bindings. @xref{Bindkey}. @end deffn @deffn Command pastefont [state] Tell screen to include font information in the paste buffer. The default is not to do so. This command is especially useful for multi character fonts like kanji. @end deffn @deffn Command slowpaste msec @deffnx Command defslowpaste msec (none)@* Define the speed text is inserted in the current window by the @code{paste} command. If the slowpaste value is nonzero text is written character by character. @code{screen} will pause for @var{msec} milliseconds after each write to allow the application to process the input. only use @code{slowpaste} if your underlying system exposes flow control problems while pasting large amounts of text. @code{defslowpaste} specifies the default for new windows. @end deffn @deffn Command readreg [-e encoding] [register [filename]] (none)@* Does one of two things, dependent on number of arguments: with zero or one arguments it duplicates the paste buffer contents into the register specified or entered at the prompt. With two arguments it reads the contents of the named file into the register, just as @code{readbuf} reads the screen-exchange file into the paste buffer. You can tell screen the encoding of the file via the @code{-e} option. The following example will paste the system's password file into the screen window (using register p, where a copy remains): @example C-a : readreg p /etc/passwd C-a : paste p @end example @end deffn @node Registers, Screen Exchange, Paste, Copy and Paste @section Registers @deffn Command copy_reg [key] (none)@* Removed. Use @code{readreg} instead. @end deffn @deffn Command ins_reg [key] (none)@* Removed. Use @code{paste} instead. @end deffn @deffn Command process [key] (none)@* Stuff the contents of the specified register into the @code{screen} input queue. If no argument is given you are prompted for a register name. The text is parsed as if it had been typed in from the user's keyboard. This command can be used to bind multiple actions to a single key. @end deffn @deffn Command register [-e encoding] key string (none)@* Save the specified @var{string} to the register @var{key}. The encoding of the string can be specified via the @code{-e} option. @end deffn @node Screen Exchange, History, Registers, Copy and Paste @section Screen Exchange @deffn Command bufferfile [@var{exchange-file}] (none)@* Change the filename used for reading and writing with the paste buffer. If the @var{exchange-file} parameter is omitted, @code{screen} reverts to the default of @file{/tmp/screen-exchange}. The following example will paste the system's password file into the screen window (using the paste buffer, where a copy remains): @example C-a : bufferfile /etc/passwd C-a < C-a ] C-a : bufferfile @end example @end deffn @kindex < @deffn Command readbuf [-e @var{encoding}] [@var{filename}] (@kbd{C-a <})@* Reads the contents of the specified file into the paste buffer. You can tell screen the encoding of the file via the @code{-e} option. If no file is specified, the screen-exchange filename is used. @end deffn @kindex = @deffn Command removebuf (@kbd{C-a =})@* Unlinks the screen-exchange file. @end deffn @kindex > @deffn Command writebuf [-e @var{encoding}] [@var{filename}] (@kbd{C-a >})@* Writes the contents of the paste buffer to the specified file, or the public accessible screen-exchange file if no filename is given. This is thought of as a primitive means of communication between @code{screen} users on the same host. If an encoding is specified the paste buffer is recoded on the fly to match the encoding. See also @kbd{C-a @key{ESC}} (@pxref{Copy}). @end deffn @node History, , Screen Exchange, Copy and Paste @section History @kindex @{ @kindex @} @deffn Command history (@kbd{C-a @{}, @kbd{C-a @}})@* Usually users work with a shell that allows easy access to previous commands. For example, @code{csh} has the command @code{!!} to repeat the last command executed. @code{screen} provides a primitive way of recalling ``the command that started @dots{}'': You just type the first letter of that command, then hit @kbd{C-a @{} and @code{screen} tries to find a previous line that matches with the prompt character to the left of the cursor. This line is pasted into this window's input queue. Thus you have a crude command history (made up by the visible window and its scrollback buffer). @end deffn @node Subprocess Execution, Key Binding, Copy and Paste, Top @chapter Subprocess Execution Control Input or Output of a window by another filter process. Use with care! @menu * Exec:: The @code{exec} command syntax. * Using Exec:: Weird things that filters can do. @end menu @node Exec, Using Exec, , Subprocess Execution @section Exec @deffn Command exec [[@var{fdpat}] @var{newcommand} [@var{args} ... ]] (none)@* Run a unix subprocess (specified by an executable path @var{newcommand} and its optional arguments) in the current window. The flow of data between newcommands stdin/stdout/stderr, the process originally started (let us call it "application-process") and screen itself (window) is controlled by the file descriptor pattern @var{fdpat}. This pattern is basically a three character sequence representing stdin, stdout and stderr of newcommand. A dot (@code{.}) connects the file descriptor to screen. An exclamation mark (@code{!}) causes the file descriptor to be connected to the application-process. A colon (@code{:}) combines both. @* User input will go to newcommand unless newcommand receives the application-process' output (@var{fdpat}s first character is @samp{!} or @samp{:}) or a pipe symbol (@samp{|}) is added to the end of @var{fdpat}. @* Invoking @code{exec} without arguments shows name and arguments of the currently running subprocess in this window. Only one subprocess can be running per window. @* When a subprocess is running the @code{kill} command will affect it instead of the windows process. Only one subprocess a time can be running in each window. @* Refer to the postscript file @file{doc/fdpat.ps} for a confusing illustration of all 21 possible combinations. Each drawing shows the digits 2, 1, 0 representing the three file descriptors of newcommand. The box marked `W' is usual pty that has the application-process on its slave side. The box marked `P' is the secondary pty that now has screen at its master side. @end deffn @node Using Exec, , Exec, Subprocess Execution @section Using Exec @noindent Abbreviations: @itemize @bullet @item Whitespace between the word @samp{exec} and @var{fdpat} and the command name can be omitted. @item Trailing dots and a @var{fdpat} consisting only of dots can be omitted. @item A simple @samp{|} is synonymous for the @samp{!..|} pattern. @item The word @samp{exec} can be omitted when the @samp{|} abbreviation is used. @item The word @samp{exec} can always be replaced by leading @samp{!}. @end itemize @noindent Examples: @table @code @item !/bin/sh @itemx exec /bin/sh @itemx exec ... /bin/sh All of the above are equivalent. Creates another shell in the same window, while the original shell is still running. Output of both shells is displayed and user input is sent to the new @file{/bin/sh}. @item !!stty 19200 @itemx exec!stty 19200 @itemx exec !.. stty 19200 All of the above are equivalent. Set the speed of the window's tty. If your stty command operates on stdout, then add another @samp{!}. This is a useful command, when a screen window is directly connected to a serial line that needs to be configured. @item |less @itemx exec !..| less Both are equivalent. This adds a pager to the window output. The special character @samp{|} is needed to give the user control over the pager although it gets its input from the window's process. This works, because @samp{less} listens on stderr (a behavior that @code{screen} would not expect without the @samp{|}) when its stdin is not a tty. @code{Less} versions newer than 177 fail miserably here; good old @code{pg} still works. @item !:sed -n s/.*Error.*/\007/p Sends window output to both, the user and the sed command. The sed inserts an additional bell character (oct. 007) to the window output seen by screen. This will cause 'Bell in window x' messages, whenever the string @samp{Error} appears in the window. @end table @node Key Binding, Flow Control, Subprocess Execution, Top @chapter Key Binding @cindex key binding @cindex binding You may disagree with some of the default bindings (I know I do). The @code{bind} command allows you to redefine them to suit your preferences. @menu * Bind:: @code{bind} syntax. * Bind Examples:: Using @code{bind}. * Command Character:: The character used to start keyboard commands. * Help:: Show current key bindings. * Bindkey:: @code{bindkey} syntax. * Bindkey Examples:: Some easy examples. * Bindkey Control:: How to control the bindkey mechanism. @end menu @node Bind, Bind Examples, , Key Binding @section The @code{bind} command @deffn Command bind [-c class] key [command [args]] (none)@* Bind a command to a key. The @var{key} argument is either a single character, a two-character sequence of the form @samp{^x} (meaning @kbd{C-x}), a backslash followed by an octal number (specifying the ASCII code of the character), or a backslash followed by a second character, such as @samp{\^} or @samp{\\}. The argument can also be quoted, if you like. If no further argument is given, any previously established binding for this key is removed. The @var{command} argument can be any command (@pxref{Command Index}). If a command class is specified via the @code{-c} option, the key is bound for the specified class. Use the @code{command} command to activate a class. Command classes can be used to create multiple command keys or multi-character bindings. By default, most suitable commands are bound to one or more keys (@pxref{Default Key Bindings}); for instance, the command to create a new window is bound to @kbd{C-c} and @kbd{c}. The @code{bind} command can be used to redefine the key bindings and to define new bindings. @end deffn @deffn Command unbindall (none)@* Unbind all the bindings. This can be useful when screen is used solely for its detaching abilities, such as when letting a console application run as a daemon. If, for some reason, it is necessary to bind commands after this, use 'screen -X'. @end deffn @node Bind Examples, Command Character, Bind, Key Binding @section Examples of the @code{bind} command @noindent Some examples: @example bind ' ' windows bind ^f screen telnet foobar bind \033 screen -ln -t root -h 1000 9 su @end example @noindent would bind the space key to the command that displays a list of windows (so that the command usually invoked by @kbd{C-a C-w} would also be available as @kbd{C-a space}), bind @kbd{C-f} to the command ``create a window with a TELNET connection to foobar'', and bind @key{ESC} to the command that creates an non-login window with title @samp{root} in slot #9, with a superuser shell and a scrollback buffer of 1000 lines. @example bind -c demo1 0 select 10 bind -c demo1 1 select 11 bind -c demo1 2 select 12 bindkey "^B" command -c demo1 @end example makes @kbd{C-b 0} select window 10, @kbd{C-b 1} window 11, etc. @example bind -c demo2 0 select 10 bind -c demo2 1 select 11 bind -c demo2 2 select 12 bind - command -c demo2 @end example makes @kbd{C-a - 0} select window 10, @kbd{C-a - 1} window 11, etc. @node Command Character, Help, Bind Examples, Key Binding @cindex escape character @cindex command character @section Command Character @deffn Command escape xy (none)@* Set the command character to @var{x} and the character generating a literal command character (by triggering the @code{meta} command) to @var{y} (similar to the @samp{-e} option). Each argument is either a single character, a two-character sequence of the form @samp{^x} (meaning @kbd{C-x}), a backslash followed by an octal number (specifying the ASCII code of the character), or a backslash followed by a second character, such as @samp{\^} or @samp{\\}. The default is @samp{^Aa}, but @samp{``} is recommended by one of the authors. @end deffn @deffn Command defescape xy (none)@* Set the default command characters. This is equivalent to the command @code{escape} except that it is useful for multiuser sessions only. In a multiuser session @code{escape} changes the command character of the calling user, where @code{defescape} changes the default command characters for users that will be added later. @end deffn @kindex a @deffn Command meta (@kbd{C-a a})@* Send the command character (@kbd{C-a}) to the process in the current window. The keystroke for this command is the second parameter to the @samp{-e} command line switch (@pxref{Invoking Screen}), or the @code{escape} .screenrc directive. @end deffn @deffn Command command [-c @var{class}] (none)@* This command has the same effect as typing the screen escape character (@kbd{C-a}). It is probably only useful for key bindings. If the @samp{-c} option is given, select the specified command class. @xref{Bind}, @xref{Bindkey}. @end deffn @node Help, Bindkey, Command Character, Key Binding @section Help @kindex ? @deffn Command help (@kbd{C-a ?})@* Displays a help screen showing you all the key bindings. The first pages list all the internal commands followed by their bindings. Subsequent pages will display the custom commands, one command per key. Press space when you're done reading each page, or return to exit early. All other characters are ignored. If the @samp{-c} option is given, display all bound commands for the specified command class. @xref{Default Key Bindings}. @end deffn @node Bindkey, Bindkey Examples, Help, Key Binding @section Bindkey @deffn Command bindkey [@var{opts}] [@var{string} [@var{cmd} @var{args}]] (none)@* This command manages screen's input translation tables. Every entry in one of the tables tells screen how to react if a certain sequence of characters is encountered. There are three tables: one that should contain actions programmed by the user, one for the default actions used for terminal emulation and one for screen's copy mode to do cursor movement. See @ref{Input Translation} for a list of default key bindings. If the @samp{-d} option is given, bindkey modifies the default table, @samp{-m} changes the copy mode table and with neither option the user table is selected. The argument @samp{string} is the sequence of characters to which an action is bound. This can either be a fixed string or a termcap keyboard capability name (selectable with the @samp{-k} option). Some keys on a VT100 terminal can send a different string if application mode is turned on (e.g. the cursor keys). Such keys have two entries in the translation table. You can select the application mode entry by specifying the @samp{-a} option. The @samp{-t} option tells screen not to do inter-character timing. One cannot turn off the timing if a termcap capability is used. @samp{cmd} can be any of screen's commands with an arbitrary number of @samp{args}. If @samp{cmd} is omitted the key-binding is removed from the table. @end deffn @node Bindkey Examples, Bindkey Control,Bindkey, Key Binding @section Bindkey Examples @noindent Here are some examples of keyboard bindings: @example bindkey -d @end example @noindent Show all of the default key bindings. The application mode entries are marked with [A]. @example bindkey -k k1 select 1 @end example @noindent Make the "F1" key switch to window one. @example bindkey -t foo stuff barfoo @end example @noindent Make @samp{foo} an abbreviation of the word @samp{barfoo}. Timeout is disabled so that users can type slowly. @example bindkey "\024" mapdefault @end example @noindent This key-binding makes @samp{C-t} an escape character for key-bindings. If you did the above @samp{stuff barfoo} binding, you can enter the word @samp{foo} by typing @samp{C-t foo}. If you want to insert a @samp{C-t} you have to press the key twice (i.e., escape the escape binding). @example bindkey -k F1 command @end example @noindent Make the F11 (not F1!) key an alternative screen escape (besides @samp{C-a}). @node Bindkey Control, , Bindkey Examples, Key Binding @section Bindkey Control @deffn Command mapdefault (none)@* Tell screen that the next input character should only be looked up in the default bindkey table. @end deffn @deffn Command mapnotnext (none)@* Like mapdefault, but don't even look in the default bindkey table. @end deffn @deffn Command maptimeout n (none)@* Set the inter-character timer for input sequence detection to a timeout of @var{n} ms. The default timeout is 300ms. Maptimeout with no arguments shows the current setting. @end deffn @node Flow Control, Termcap, Key Binding, Top @chapter Flow Control @cindex flow control @code{screen} can trap flow control characters or pass them to the program, as you see fit. This is useful when your terminal wants to use XON/XOFF flow control and you are running a program which wants to use ^S/^Q for other purposes (i.e. @code{emacs}). @menu * Flow Control Summary:: The effect of @code{screen} flow control * Flow:: Setting the flow control behavior * XON/XOFF:: Sending XON or XOFF to the window @end menu @node Flow Control Summary, Flow, , Flow Control @section About @code{screen} flow control settings Each window has a flow-control setting that determines how screen deals with the XON and XOFF characters (and perhaps the interrupt character). When flow-control is turned off, screen ignores the XON and XOFF characters, which allows the user to send them to the current program by simply typing them (useful for the @code{emacs} editor, for instance). The trade-off is that it will take longer for output from a ``normal'' program to pause in response to an XOFF. With flow-control turned on, XON and XOFF characters are used to immediately pause the output of the current window. You can still send these characters to the current program, but you must use the appropriate two-character screen commands (typically @kbd{C-a q} (xon) and @kbd{C-a s} (xoff)). The xon/xoff commands are also useful for typing C-s and C-q past a terminal that intercepts these characters. Each window has an initial flow-control value set with either the @samp{-f} option or the @code{defflow} command. By default the windows are set to automatic flow-switching. It can then be toggled between the three states 'fixed on', 'fixed off' and 'automatic' interactively with the @code{flow} command bound to @kbd{C-a f}. The automatic flow-switching mode deals with flow control using the TIOCPKT mode (like @code{rlogin} does). If the tty driver does not support TIOCPKT, screen tries to determine the right mode based on the current setting of the application keypad --- when it is enabled, flow-control is turned off and visa versa. Of course, you can still manipulate flow-control manually when needed. If you're running with flow-control enabled and find that pressing the interrupt key (usually C-c) does not interrupt the display until another 6-8 lines have scrolled by, try running screen with the @samp{interrupt} option (add the @samp{interrupt} flag to the @code{flow} command in your .screenrc, or use the @samp{-i} command-line option). This causes the output that @code{screen} has accumulated from the interrupted program to be flushed. One disadvantage is that the virtual terminal's memory contains the non-flushed version of the output, which in rare cases can cause minor inaccuracies in the output. For example, if you switch screens and return, or update the screen with @kbd{C-a l} you would see the version of the output you would have gotten without @samp{interrupt} being on. Also, you might need to turn off flow-control (or use auto-flow mode to turn it off automatically) when running a program that expects you to type the interrupt character as input, as the @samp{interrupt} parameter only takes effect when flow-control is enabled. If your program's output is interrupted by mistake, a simple refresh of the screen with @kbd{C-a l} will restore it. Give each mode a try, and use whichever mode you find more comfortable. @node Flow, XON/XOFF, Flow Control Summary, Flow Control @section Flow @deffn Command defflow fstate [interrupt] (none)@* Same as the @code{flow} command except that the default setting for new windows is changed. Initial setting is `auto'. Specifying @code{flow auto interrupt} has the same effect as the command-line options @samp{-fa} and @samp{-i}. Note that if @samp{interrupt} is enabled, all existing displays are changed immediately to forward interrupt signals. @end deffn @kindex f @kindex C-f @deffn Command flow [fstate] (@kbd{C-a f}, @kbd{C-a C-f})@* Sets the flow-control mode for this window to @var{fstate}, which can be @samp{on}, @samp{off} or @samp{auto}. Without parameters it cycles the current window's flow-control setting. Default is set by `defflow'. @end deffn @node XON/XOFF, , Flow, Flow Control @section XON and XOFF @kindex q @kindex C-q @deffn Command xon (@kbd{C-a q}, @kbd{C-a C-q})@* Send a ^Q (ASCII XON) to the program in the current window. Redundant if flow control is set to @samp{off} or @samp{auto}. @end deffn @kindex s @kindex C-s @deffn Command xoff (@kbd{C-a s}, @kbd{C-a C-s})@* Send a ^S (ASCII XOFF) to the program in the current window. @end deffn @node Termcap, Message Line, Flow Control, Top @chapter Termcap @code{Screen} demands the most out of your terminal so that it can perform its VT100 emulation most efficiently. These functions provide means for tweaking the termcap entries for both your physical terminal and the one simulated by @code{screen}. @menu * Window Termcap:: Choosing a termcap entry for the window. * Dump Termcap:: Write out a termcap entry for the window. * Termcap Syntax:: The @code{termcap} and @code{terminfo} commands. * Termcap Examples:: Uses for @code{termcap}. * Special Capabilities:: Non-standard capabilities used by @code{screen}. * Autonuke:: Flush unseen output * Obuflimit:: Allow pending output when reading more * Character Translation:: Emulating fonts and charsets. @end menu @node Window Termcap, Dump Termcap, , Termcap @section Choosing the termcap entry for a window Usually @code{screen} tries to emulate as much of the VT100/ANSI standard as possible. But if your terminal lacks certain capabilities the emulation may not be complete. In these cases @code{screen} has to tell the applications that some of the features are missing. This is no problem on machines using termcap, because @code{screen} can use the @code{$TERMCAP} variable to customize the standard screen termcap. But if you do a rlogin on another machine or your machine supports only terminfo this method fails. Because of this @code{screen} offers a way to deal with these cases. Here is how it works: When @code{screen} tries to figure out a terminal name for itself, it first looks for an entry named @code{screen.@var{term}}, where @var{term} is the contents of your @code{$TERM} variable. If no such entry exists, @code{screen} tries @samp{screen} (or @samp{screen-w}, if the terminal is wide (132 cols or more)). If even this entry cannot be found, @samp{vt100} is used as a substitute. The idea is that if you have a terminal which doesn't support an important feature (e.g. delete char or clear to EOS) you can build a new termcap/terminfo entry for @code{screen} (named @samp{screen.@var{dumbterm}}) in which this capability has been disabled. If this entry is installed on your machines you are able to do a rlogin and still keep the correct termcap/terminfo entry. The terminal name is put in the @code{$TERM} variable of all new windows. @code{screen} also sets the @code{$TERMCAP} variable reflecting the capabilities of the virtual terminal emulated. Furthermore, the variable @code{$WINDOW} is set to the window number of each window. The actual set of capabilities supported by the virtual terminal depends on the capabilities supported by the physical terminal. If, for instance, the physical terminal does not support underscore mode, @code{screen} does not put the @samp{us} and @samp{ue} capabilities into the window's @code{$TERMCAP} variable, accordingly. However, a minimum number of capabilities must be supported by a terminal in order to run @code{screen}; namely scrolling, clear screen, and direct cursor addressing (in addition, @code{screen} does not run on hardcopy terminals or on terminals that over-strike). Also, you can customize the @code{$TERMCAP} value used by @code{screen} by using the @code{termcap} command, or by defining the variable @code{$SCREENCAP} prior to startup. When the latter defined, its value will be copied verbatim into each window's @code{$TERMCAP} variable. This can either be the full terminal definition, or a filename where the terminal @samp{screen} (and/or @samp{screen-w}) is defined. Note that @code{screen} honors the @code{terminfo} command if the system uses the terminfo database rather than termcap. On such machines the @code{$TERMCAP} variable has no effect and you must use the @code{dumptermcap} command (@pxref{Dump Termcap}) and the @code{tic} program to generate terminfo entries for @code{screen} windows. When the boolean @samp{G0} capability is present in the termcap entry for the terminal on which @code{screen} has been called, the terminal emulation of @code{screen} supports multiple character sets. This allows an application to make use of, for instance, the VT100 graphics character set or national character sets. The following control functions from ISO 2022 are supported: @samp{lock shift G0} (@samp{SI}), @samp{lock shift G1} (@samp{SO}), @samp{lock shift G2}, @samp{lock shift G3}, @samp{single shift G2}, and @samp{single shift G3}. When a virtual terminal is created or reset, the ASCII character set is designated as @samp{G0} through @samp{G3}. When the @samp{G0} capability is present, screen evaluates the capabilities @samp{S0}, @samp{E0}, and @samp{C0} if present. @samp{S0} is the sequence the terminal uses to enable and start the graphics character set rather than @samp{SI}. @samp{E0} is the corresponding replacement for @samp{SO}. @samp{C0} gives a character by character translation string that is used during semi-graphics mode. This string is built like the @samp{acsc} terminfo capability. When the @samp{po} and @samp{pf} capabilities are present in the terminal's termcap entry, applications running in a @code{screen} window can send output to the printer port of the terminal. This allows a user to have an application in one window sending output to a printer connected to the terminal, while all other windows are still active (the printer port is enabled and disabled again for each chunk of output). As a side-effect, programs running in different windows can send output to the printer simultaneously. Data sent to the printer is not displayed in the window. The @code{info} command displays a line starting with @samp{PRIN} while the printer is active. Some capabilities are only put into the @code{$TERMCAP} variable of the virtual terminal if they can be efficiently implemented by the physical terminal. For instance, @samp{dl} (delete line) is only put into the @code{$TERMCAP} variable if the terminal supports either delete line itself or scrolling regions. Note that this may provoke confusion, when the session is reattached on a different terminal, as the value of @code{$TERMCAP} cannot be modified by parent processes. You can force @code{screen} to include all capabilities in @code{$TERMCAP} with the @samp{-a} command-line option (@pxref{Invoking Screen}). The "alternate screen" capability is not enabled by default. Set the @code{altscreen} @file{.screenrc} command to enable it. @node Dump Termcap, Termcap Syntax, Window Termcap, Termcap @section Write out the window's termcap entry @kindex . @deffn Command dumptermcap (@kbd{C-a .})@* Write the termcap entry for the virtual terminal optimized for the currently active window to the file @file{.termcap} in the user's @file{$HOME/.screen} directory (or wherever @code{screen} stores its sockets. @pxref{Files}). This termcap entry is identical to the value of the environment variable @code{$TERMCAP} that is set up by @code{screen} for each window. For terminfo based systems you will need to run a converter like @code{captoinfo} and then compile the entry with @code{tic}. @end deffn @node Termcap Syntax, Termcap Examples, Dump Termcap, Termcap @section The @code{termcap} command @deffn Command termcap term terminal-tweaks [window-tweaks] @deffnx Command terminfo term terminal-tweaks [window-tweaks] @deffnx Command termcapinfo term terminal-tweaks [window-tweaks] (none)@* Use this command to modify your terminal's termcap entry without going through all the hassles involved in creating a custom termcap entry. Plus, you can optionally customize the termcap generated for the windows. You have to place these commands in one of the screenrc startup files, as they are meaningless once the terminal emulator is booted. If your system uses the terminfo database rather than termcap, @code{screen} will understand the @code{terminfo} command, which has the same effects as the @code{termcap} command. Two separate commands are provided, as there are subtle syntactic differences, e.g. when parameter interpolation (using @samp{%}) is required. Note that the termcap names of the capabilities should also be used with the @code{terminfo} command. In many cases, where the arguments are valid in both terminfo and termcap syntax, you can use the command @code{termcapinfo}, which is just a shorthand for a pair of @code{termcap} and @code{terminfo} commands with identical arguments. @end deffn The first argument specifies which terminal(s) should be affected by this definition. You can specify multiple terminal names by separating them with @samp{|}s. Use @samp{*} to match all terminals and @samp{vt*} to match all terminals that begin with @samp{vt}. Each @var{tweak} argument contains one or more termcap defines (separated by @samp{:}s) to be inserted at the start of the appropriate termcap entry, enhancing it or overriding existing values. The first tweak modifies your terminal's termcap, and contains definitions that your terminal uses to perform certain functions. Specify a null string to leave this unchanged (e.g. ""). The second (optional) tweak modifies all the window termcaps, and should contain definitions that screen understands (@pxref{Virtual Terminal}). @node Termcap Examples, Special Capabilities, Termcap Syntax, Termcap @section Termcap Examples Some examples: @example termcap xterm* xn:hs@@ @end example @noindent Informs @code{screen} that all terminals that begin with @samp{xterm} have firm auto-margins that allow the last position on the screen to be updated (xn), but they don't really have a status line (no 'hs' -- append @samp{@@} to turn entries off). Note that we assume @samp{xn} for all terminal names that start with @samp{vt}, but only if you don't specify a termcap command for that terminal. @example termcap vt* xn termcap vt102|vt220 Z0=\E[?3h:Z1=\E[?3l @end example @noindent Specifies the firm-margined @samp{xn} capability for all terminals that begin with @samp{vt}, and the second line will also add the escape-sequences to switch into (Z0) and back out of (Z1) 132-character-per-line mode if this is a VT102 or VT220. (You must specify Z0 and Z1 in your termcap to use the width-changing commands.) @example termcap vt100 "" l0=PF1:l1=PF2:l2=PF3:l3=PF4 @end example @noindent This leaves your vt100 termcap alone and adds the function key labels to each window's termcap entry. @example termcap h19|z19 am@@:im=\E@@:ei=\EO dc=\E[P @end example @noindent Takes a h19 or z19 termcap and turns off auto-margins (am@@) and enables the insert mode (im) and end-insert (ei) capabilities (the @samp{@@} in the @samp{im} string is after the @samp{=}, so it is part of the string). Having the @samp{im} and @samp{ei} definitions put into your terminal's termcap will cause screen to automatically advertise the character-insert capability in each window's termcap. Each window will also get the delete-character capability (dc) added to its termcap, which screen will translate into a line-update for the terminal (we're pretending it doesn't support character deletion). If you would like to fully specify each window's termcap entry, you should instead set the @code{$SCREENCAP} variable prior to running @code{screen}. @xref{Virtual Terminal}, for the details of the @code{screen} terminal emulation. @xref{Termcap}, for more information on termcap definitions. @node Special Capabilities, Autonuke, Termcap Examples, Termcap @section Special Terminal Capabilities @cindex terminal capabilities @cindex capabilities The following table describes all terminal capabilities that are recognized by @code{screen} and are not in the termcap manual (@pxref{Termcap}). You can place these capabilities in your termcap entries (in @file{/etc/termcap}) or use them with the commands @code{termcap}, @code{terminfo} and @code{termcapinfo} in your @code{screenrc} files. It is often not possible to place these capabilities in the terminfo database. @table @samp @item LP (bool)@* Terminal has VT100 style margins (`magic margins'). Note that this capability is obsolete --- @code{screen} now uses the standard @samp{xn} instead. @item Z0 (str)@* Change width to 132 columns. @item Z1 (str)@* Change width to 80 columns. @item WS (str)@* Resize display. This capability has the desired width and height as arguments. SunView(tm) example: @samp{\E[8;%d;%dt}. @item NF (bool)@* Terminal doesn't need flow control. Send ^S and ^Q direct to the application. Same as @code{flow off}. The opposite of this capability is @samp{nx}. @item G0 (bool)@* Terminal can deal with ISO 2022 font selection sequences. @item S0 (str)@* Switch charset @samp{G0} to the specified charset. Default is @samp{\E(%.}. @item E0 (str)@* Switch charset @samp{G0} back to standard charset. Default is @samp{\E(B}. @item C0 (str)@* Use the string as a conversion table for font 0. See the @samp{ac} capability for more details. @item CS (str)@* Switch cursor-keys to application mode. @item CE (str)@* Switch cursor-keys to cursor mode. @item AN (bool)@* Enable autonuke for displays of this terminal type. (@pxref{Autonuke}). @item OL (num)@* Set the output buffer limit. See the @samp{obuflimit} command (@pxref{Obuflimit}) for more details. @item KJ (str)@* Set the encoding of the terminal. See the @samp{encoding} command (@pxref{Character Processing}) for valid encodings. @item AF (str)@* Change character foreground color in an ANSI conform way. This capability will almost always be set to @samp{\E[3%dm} (@samp{\E[3%p1%dm} on terminfo machines). @item AB (str)@* Same as @samp{AF}, but change background color. @item AX (bool)@* Does understand ANSI set default fg/bg color (@samp{\E[39m / \E[49m}). @item XC (str)@* Describe a translation of characters to strings depending on the current font. (@pxref{Character Translation}). @item XT (bool)@* Terminal understands special xterm sequences (OSC, mouse tracking). @item C8 (bool)@* Terminal needs bold to display high-intensity colors (e.g. Eterm). @item TF (bool)@* Add missing capabilities to the termcap/info entry. (Set by default). @end table @node Autonuke, Obuflimit, Special Capabilities, Termcap @section Autonuke @deffn Command autonuke @var{state} (none)@* Sets whether a clear screen sequence should nuke all the output that has not been written to the terminal. @xref{Obuflimit}. This property is set per display, not per window. @end deffn @deffn Command defautonuke @var{state} (none)@* Same as the @code{autonuke} command except that the default setting for new displays is also changed. Initial setting is @code{off}. Note that you can use the special @code{AN} terminal capability if you want to have a terminal type dependent setting. @end deffn @node Obuflimit, Character Translation, Autonuke, Termcap @section Obuflimit @deffn Command obuflimit [@var{limit}] (none)@* If the output buffer contains more bytes than the specified limit, no more data will be read from the windows. The default value is 256. If you have a fast display (like @code{xterm}), you can set it to some higher value. If no argument is specified, the current setting is displayed. This property is set per display, not per window. @end deffn @deffn Command defobuflimit @var{limit} (none)@* Same as the @code{obuflimit} command except that the default setting for new displays is also changed. Initial setting is 256 bytes. Note that you can use the special @code{OL} terminal capability if you want to have a terminal type dependent limit. @end deffn @node Character Translation, , Obuflimit, Termcap @section Character Translation @code{Screen} has a powerful mechanism to translate characters to arbitrary strings depending on the current font and terminal type. Use this feature if you want to work with a common standard character set (say ISO8851-latin1) even on terminals that scatter the more unusual characters over several national language font pages. Syntax: @example XC=@var{}@{,,@var{}@} @var{} := @var{}@var{