screen-4.3.1/0000755000175000017500000000000012544065147011706 5ustar amadeamadescreen-4.3.1/mark.h0000644000175000017500000000455512544062660013017 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 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** * $Id$ GNU */ struct markdata { struct win *md_window;/* pointer to window we are working on */ struct acluser *md_user; /* The user who brought us up */ int cx, cy; /* cursor Position in WIN coords*/ int x1, y1; /* first mark in WIN coords */ int second; /* first mark dropped flag */ int left_mar, right_mar, nonl; int rep_cnt; /* number of repeats */ int append_mode; /* shall we overwrite or append to copybuffer */ int write_buffer; /* shall we do a KEY_WRITE_EXCHANGE right away? */ int hist_offset; /* how many lines are on top of the screen */ char isstr[100]; /* string we are searching for */ int isstrl; char isistr[200]; /* string of chars user has typed */ int isistrl; int isdir; /* current search direction */ int isstartpos; /* position where isearch was started */ int isstartdir; /* direction when isearch was started */ struct { /* bookkeeping for fFtT;, commands */ int flag, target, direction; } f_cmd; }; #define W2D(y) ((y) - markdata->hist_offset) #define D2W(y) ((y) + markdata->hist_offset) screen-4.3.1/list_window.c0000644000175000017500000004121312544062660014412 0ustar amadeamade/* Copyright (c) 2010 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net) * * 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 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ /* Deals with the list of windows */ /* NOTE: A 'struct win *' is used as the 'data' for each row. It might make more sense * to use 'struct win* ->w_number' as the 'data', instead, because that way, we can * verify that the window does exist (by looking at wtab[]). */ #include "config.h" #include "screen.h" #include "layer.h" #include "extern.h" #include "list_generic.h" extern struct layer *flayer; extern struct display *display, *displays; extern char *wlisttit; extern char *wliststr; extern struct mchar mchar_blank, mchar_so; extern int renditions[]; extern struct win **wtab, *windows, *fore; extern int maxwin; extern char *noargs[]; static char ListID[] = "window"; struct gl_Window_Data { struct win *group; /* Set only for a W_TYPE_GROUP window */ int order; /* MRU? NUM? */ int onblank; int nested; struct win *fore; /* The foreground window we had. */ }; /* Is this wdata for a group window? */ #define WLIST_FOR_GROUP(wdate) ((wdata)->group && !(wdata)->onblank && Layer2Window(flayer) && Layer2Window(flayer)->w_type == W_TYPE_GROUP) /* This macro should not be used if 'fn' is expected to update the window list */ #define FOR_EACH_WINDOW(_wdata, _w, fn) do { \ if ((_wdata)->order == WLIST_MRU) \ { \ struct win *_ww; \ for (_ww = windows; _ww; _ww = _ww->w_next) \ { \ _w = _ww; \ fn \ } \ } \ else \ { \ struct win **_ww, *_witer; \ for (_ww = wtab, _witer = windows; _witer && _ww - wtab < maxwin; _ww++) \ { \ if (!(_w = *_ww)) continue; \ fn \ _witer = _witer->w_next; \ } \ } \ } while (0) /* Is 'a' an ancestor of 'd'? */ static int window_ancestor(struct win *a, struct win *d) { if (!a) return 1; /* Every window is a descendant of the 'null' group */ for (; d; d = d->w_group) if (d->w_group == a) return 1; return 0; } static void window_kill_confirm(char *buf, int len, char *data) { struct win *w = windows; struct action act; if (len || (*buf != 'y' && *buf != 'Y')) { *buf = 0; return; } /* Loop over the windows to make sure that the window actually still exists. */ for (; w; w = w->w_next) if (w == (struct win *)data) break; if (!w) return; /* Pretend the selected window is the foreground window. Then trigger a non-interactive 'kill' */ fore = w; act.nr = RC_KILL; act.args = noargs; act.argl = 0; act.quiet = 0; DoAction(&act, -1); } static struct ListRow * gl_Window_add_group(struct ListData *ldata, struct ListRow *row) { /* Right now, 'row' doesn't have any child. */ struct gl_Window_Data *wdata = ldata->data; struct win *group = row->data, *w; struct ListRow *cur = row; ASSERT(wdata->nested); FOR_EACH_WINDOW(wdata, w, if (w->w_group != group) continue; cur = glist_add_row(ldata, w, cur); if (w == wdata->fore) ldata->selected = cur; if (w->w_type == W_TYPE_GROUP) cur = gl_Window_add_group(ldata, cur); ); return cur; } static void gl_Window_rebuild(struct ListData *ldata) { struct ListRow *row = NULL; struct gl_Window_Data *wdata = ldata->data; struct win *w; FOR_EACH_WINDOW(wdata, w, if (w->w_group != wdata->group) continue; row = glist_add_row(ldata, w, row); if (w == wdata->fore) ldata->selected = row; if (w->w_type == W_TYPE_GROUP && wdata->nested) row = gl_Window_add_group(ldata, row); ); glist_display_all(ldata); } static struct ListRow * gl_Window_findrow(struct ListData *ldata, struct win *p) { struct ListRow *row = ldata->root; for (; row; row = row->next) { if (row->data == p) break; } return row; } static int gl_Window_remove(struct ListData *ldata, struct win *p) { struct ListRow *row = gl_Window_findrow(ldata, p); if (!row) return 0; /* Remove 'row'. Update 'selected', 'top', 'root' if necessary. */ if (row->next) row->next->prev = row->prev; if (row->prev) row->prev->next = row->next; if (ldata->selected == row) ldata->selected = row->prev ? row->prev : row->next; if (ldata->top == row) ldata->top = row->prev ? row->prev : row->next; if (ldata->root == row) ldata->root = row->next; ldata->list_fn->gl_freerow(ldata, row); free(row); return 1; } static int gl_Window_header(struct ListData *ldata) { char *str; struct gl_Window_Data *wdata = ldata->data; int g; if ((g = (wdata->group != NULL))) { LPutWinMsg(flayer, "Group: ", 7, &mchar_blank, 0, 0); LPutWinMsg(flayer, wdata->group->w_title, strlen(wdata->group->w_title), &mchar_blank, 7, 0); } display = 0; str = MakeWinMsgEv(wlisttit, (struct win *)0, '%', flayer->l_width, (struct event *)0, 0); LPutWinMsg(flayer, str, strlen(str), &mchar_blank, 0, g); return 2 + g; } static int gl_Window_footer(struct ListData *ldata) { return 0; } static int gl_Window_row(struct ListData *ldata, struct ListRow *lrow) { char *str; struct win *w, *g; int xoff; struct mchar *mchar; struct mchar mchar_rend = mchar_blank; struct gl_Window_Data *wdata = ldata->data; w = lrow->data; /* First, make sure we want to display this window in the list. * If we are showing a list for a group, and not on blank, then we must * only show the windows directly belonging to that group. * Otherwise, do some more checks. */ for (xoff = 0, g = w->w_group; g != wdata->group; g = g->w_group) xoff += 2; display = Layer2Window(flayer) ? 0 : flayer->l_cvlist ? flayer->l_cvlist->c_display : 0; str = MakeWinMsgEv(wliststr, w, '%', flayer->l_width - xoff, NULL, 0); if (ldata->selected == lrow) mchar = &mchar_so; else if (w->w_monitor == MON_DONE && renditions[REND_MONITOR] != -1) { mchar = &mchar_rend; ApplyAttrColor(renditions[REND_MONITOR], mchar); } else if ((w->w_bell == BELL_DONE || w->w_bell == BELL_FOUND) && renditions[REND_BELL] != -1) { mchar = &mchar_rend; ApplyAttrColor(renditions[REND_BELL], mchar); } else if ((w->w_silence == SILENCE_FOUND || w->w_silence == SILENCE_DONE) && renditions[REND_SILENCE] != -1) { mchar = &mchar_rend; ApplyAttrColor(renditions[REND_SILENCE], mchar); } else mchar = &mchar_blank; LPutWinMsg(flayer, str, flayer->l_width, mchar, xoff, lrow->y); if (xoff) LPutWinMsg(flayer, "", xoff, mchar, 0, lrow->y); return 1; } static int gl_Window_input(struct ListData *ldata, char **inp, int *len) { struct win *win; unsigned char ch; struct display *cd = display; struct gl_Window_Data *wdata = ldata->data; if (!ldata->selected) return 0; ch = (unsigned char) **inp; ++*inp; --*len; win = ldata->selected->data; switch (ch) { case ' ': case '\n': case '\r': if (!win) break; #ifdef MULTIUSER if (display && AclCheckPermWin(D_user, ACL_READ, win)) return 0; /* Not allowed to switch to this window. */ #endif if (WLIST_FOR_GROUP(wdata)) SwitchWindow(win->w_number); else { /* Abort list only when not in a group window. */ glist_abort(); display = cd; if (D_fore != win) SwitchWindow(win->w_number); } *len = 0; break; case 'm': /* Toggle MRU-ness */ wdata->order = wdata->order == WLIST_MRU ? WLIST_NUM : WLIST_MRU; glist_remove_rows(ldata); gl_Window_rebuild(ldata); break; case 'g': /* Toggle nestedness */ wdata->nested = !wdata->nested; glist_remove_rows(ldata); gl_Window_rebuild(ldata); break; case 'a': /* All-window view */ if (wdata->group) { int order = wdata->order | (wdata->nested ? WLIST_NESTED : 0); glist_abort(); display = cd; display_windows(1, order, NULL); *len = 0; } else if (!wdata->nested) { wdata->nested = 1; glist_remove_rows(ldata); gl_Window_rebuild(ldata); } break; case 010: /* ^H */ case 0177: /* Backspace */ if (!wdata->group) break; if (wdata->group->w_group) { /* The parent is another group window. So switch to that window. */ struct win *g = wdata->group->w_group; glist_abort(); display = cd; SetForeWindow(g); *len = 0; } else { /* We were in a group view. Now we are moving to an all-window view. * So treat it as 'windowlist on blank'. */ int order = wdata->order | (wdata->nested ? WLIST_NESTED : 0); glist_abort(); display = cd; display_windows(1, order, NULL); *len = 0; } break; case ',': /* Switch numbers with the previous window. */ if (wdata->order == WLIST_NUM && ldata->selected->prev) { struct win *pw = ldata->selected->prev->data; if (win->w_group != pw->w_group) break; /* Do not allow switching with the parent group */ /* When a windows's number is successfully changed, it triggers a WListUpdatecv * with NULL window. So that causes a redraw of the entire list. So reset the * 'selected' after that. */ wdata->fore = win; WindowChangeNumber(win->w_number, pw->w_number); } break; case '.': /* Switch numbers with the next window. */ if (wdata->order == WLIST_NUM && ldata->selected->next) { struct win *nw = ldata->selected->next->data; if (win->w_group != nw->w_group) break; /* Do not allow switching with the parent group */ wdata->fore = win; WindowChangeNumber(win->w_number, nw->w_number); } break; case 'K': /* Kill a window */ { char str[MAXSTR]; snprintf(str, sizeof(str) - 1, "Really kill window %d (%s) [y/n]", win->w_number, win->w_title); Input(str, 1, INP_RAW, window_kill_confirm, (char *)win, 0); } break; case 033: /* escape */ case 007: /* ^G */ if (!WLIST_FOR_GROUP(wdata)) { int fnumber = wdata->onblank ? wdata->fore->w_number : -1; glist_abort(); display = cd; if (fnumber >= 0) SwitchWindow(fnumber); *len = 0; } break; default: if (ch >= '0' && ch <= '9') { struct ListRow *row = ldata->root; for (; row; row = row->next) { struct win *w = row->data; if (w->w_number == ch - '0') { struct ListRow *old = ldata->selected; if (old == row) break; ldata->selected = row; if (ldata->selected->y == -1) { /* We need to list all the rows, since we are scrolling down. But first, * find the top of the visible list. */ ldata->top = row; glist_display_all(ldata); } else { /* just redisplay the two lines. */ ldata->list_fn->gl_printrow(ldata, old); ldata->list_fn->gl_printrow(ldata, ldata->selected); flayer->l_y = ldata->selected->y; LaySetCursor(); } break; } } break; } --*inp; ++*len; return 0; } return 1; } static int gl_Window_freerow(struct ListData *ldata, struct ListRow *row) { return 0; } static int gl_Window_free(struct ListData *ldata) { Free(ldata->data); return 0; } static int gl_Window_match(struct ListData *ldata, struct ListRow *row, const char *needle) { struct win *w = row->data; if (InStr(w->w_title, needle)) return 1; return 0; } static struct GenericList gl_Window = { gl_Window_header, gl_Window_footer, gl_Window_row, gl_Window_input, gl_Window_freerow, gl_Window_free, gl_Window_match }; void display_windows(int onblank, int order, struct win *group) { struct win *p; struct ListData *ldata; struct gl_Window_Data *wdata; if (flayer->l_width < 10 || flayer->l_height < 6) { LMsg(0, "Window size too small for window list page"); return; } if (group) onblank = 0; /* When drawing a group window, ignore 'onblank' */ if (onblank) { debug3("flayer %x %d %x\n", flayer, flayer->l_width, flayer->l_height); if (!display) { LMsg(0, "windowlist -b: display required"); return; } p = D_fore; if (p) { SetForeWindow((struct win *)0); if (p->w_group) { D_fore = p->w_group; flayer->l_data = (char *)p->w_group; } Activate(0); } if (flayer->l_width < 10 || flayer->l_height < 6) { LMsg(0, "Window size too small for window list page"); return; } } else p = Layer2Window(flayer); if (!group && p) group = p->w_group; ldata = glist_display(&gl_Window, ListID); if (!ldata) { if (onblank && p) { /* Could not display the list. So restore the window. */ SetForeWindow(p); Activate(1); } return; } wdata = calloc(1, sizeof(struct gl_Window_Data)); wdata->group = group; wdata->order = (order & ~WLIST_NESTED); wdata->nested = !!(order & WLIST_NESTED); wdata->onblank = onblank; /* Set the most recent window as selected. */ wdata->fore = windows; while (wdata->fore && wdata->fore->w_group != group) wdata->fore = wdata->fore->w_next; ldata->data = wdata; gl_Window_rebuild(ldata); } static void WListUpdate(struct win *p, struct ListData *ldata) { struct gl_Window_Data *wdata = ldata->data; struct ListRow *row, *rbefore; struct win *before; int d = 0, sel = 0; if (!p) { if (ldata->selected) wdata->fore = ldata->selected->data; /* Try to retain the current selection */ glist_remove_rows(ldata); gl_Window_rebuild(ldata); return; } /* First decide if this window should be displayed at all. */ d = 1; if (wdata->order == WLIST_NUM || wdata->order == WLIST_MRU) { if (p->w_group != wdata->group) { if (!wdata->nested) d = 0; else d = window_ancestor(wdata->group, p); } } if (!d) { if (gl_Window_remove(ldata, p)) glist_display_all(ldata); return; } /* OK, so we keep the window in the list. Update the ordering. * First, find the row where this window should go to. Then, either create * a new row for that window, or move the exising row for the window to the * correct place. */ before = NULL; if (wdata->order == WLIST_MRU) { if (windows != p) for (before = windows; before; before = before->w_next) if (before->w_next == p) break; } else if (wdata->order == WLIST_NUM) { if (p->w_number != 0) { struct win **w = wtab + p->w_number - 1; for (; w >= wtab; w--) { if (*w && (*w)->w_group == wdata->group) { before = *w; break; } } } } /* Now, find the row belonging to 'before' */ if (before) rbefore = gl_Window_findrow(ldata, before); else if (wdata->nested && p->w_group) /* There's no 'before'. So find the group window */ rbefore = gl_Window_findrow(ldata, p->w_group); else rbefore = NULL; /* For now, just remove the row containing 'p' if it is not already in the right place . */ row = gl_Window_findrow(ldata, p); if (row) { if (row->prev != rbefore) { sel = ldata->selected->data == p; gl_Window_remove(ldata, p); } else p = NULL; /* the window is in the correct place */ } if (p) { row = glist_add_row(ldata, p, rbefore); if (sel) ldata->selected = row; } glist_display_all(ldata); } void WListUpdatecv(cv, p) struct canvas *cv; struct win *p; { struct ListData *ldata; struct gl_Window_Data *wdata; if (cv->c_layer->l_layfn != &ListLf) return; ldata = cv->c_layer->l_data; if (ldata->name != ListID) return; wdata = ldata->data; CV_CALL(cv, WListUpdate(p, ldata)); } void WListLinkChanged() { struct display *olddisplay = display; struct canvas *cv; struct ListData *ldata; struct gl_Window_Data *wdata; for (display = displays; display; display = display->d_next) for (cv = D_cvlist; cv; cv = cv->c_next) { if (!cv->c_layer || cv->c_layer->l_layfn != &ListLf) continue; ldata = cv->c_layer->l_data; if (ldata->name != ListID) continue; wdata = ldata->data; if (!(wdata->order & WLIST_MRU)) continue; CV_CALL(cv, WListUpdate(0, ldata)); } display = olddisplay; } screen-4.3.1/terminfo/0000755000175000017500000000000012441035356013524 5ustar amadeamadescreen-4.3.1/terminfo/tetris.c0000644000175000017500000000267412326531270015211 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.3.1/terminfo/screeninfo.src0000644000175000017500000000764412441035356016403 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.3.1/terminfo/8bits0000644000175000017500000000132012326531270014472 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.3.1/terminfo/README0000644000175000017500000000110212326531270014374 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.3.1/terminfo/checktc.c0000644000175000017500000001055212326531270015275 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.3.1/terminfo/test.txt0000644000175000017500000011376312326531270015255 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.3.1/terminfo/screencap0000644000175000017500000000222312326531270015407 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.3.1/osdef.sh0000644000175000017500000000343512544062660013344 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 #ifndef NAMEDPIPE #include #endif #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.3.1/nethack.c0000644000175000017500000001122612544062660013466 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 * http://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" #ifdef NETHACK extern int nethackflag; #endif struct nlstrans { char *from; char *to; }; #ifdef NETHACK static struct nlstrans nethacktrans[] = { {"Cannot lock terminal - fork failed", "Cannot fork terminal - lock failed"}, {"Got only %d bytes from %s", "You choke on your food: %d bytes from %s"}, {"Copy mode - Column %d Line %d(+%d) (%d,%d)", "Welcome to hacker's treasure zoo - Column %d Line %d(+%d) (%d,%d)"}, {"First mark set - Column %d Line %d", "You drop a magic marker - Column %d Line %d"}, {"Copy mode aborted", "You escaped the dungeon."}, {"Filter removed.", "You have a sad feeling for a moment..."}, {"Window %d (%s) killed.", "You destroy poor window %d (%s)."}, {"Window %d (%s) is now being monitored for all activity.", "You feel like someone is watching you..."}, {"Window %d (%s) is no longer being monitored for activity.", "You no longer sense the watcher's presence."}, {"empty buffer", "Nothing happens."}, {"switched to audible bell.", "Suddenly you can't see your bell!"}, {"switched to visual bell.", "Your bell is no longer invisible."}, {"The window is now being monitored for %d sec. silence.", "You feel like someone is waiting for %d sec. silence..."}, {"The window is no longer being monitored for silence.", "You no longer sense the watcher's silence."}, {"No other window.", "You cannot escape from window %d!"}, {"Logfile \"%s\" closed.", "You put away your scroll of logging named \"%s\"." }, {"Error opening logfile \"%s\"", "You don't seem to have a scroll of logging named \"%s\"."}, {"Creating logfile \"%s\".", "You start writing on your scroll of logging named \"%s\"."}, {"Appending to logfile \"%s\".", "You add to your scroll of logging named \"%s\"."}, {"Detach aborted.", "The blast of disintegration whizzes by you!"}, {"Empty register.", "Nothing happens."}, {"[ Passwords don't match - checking turned off ]", "[ Passwords don't match - your armor crumbles away ]"}, {"Aborted because of window size change.", "KAABLAMM!!! You triggered a land mine!"}, {"Out of memory.", "Who was that Maude person anyway?"}, {"getpwuid() can't identify your account!", "An alarm sounds through the dungeon...\nThe Keystone Kops are after you!"}, {"Must be connected to a terminal.", "You must play from a terminal."}, {"No Sockets found in %s.\n", "This room is empty (%s).\n"}, {"New screen...", "Be careful! New screen tonight."}, {"Child has been stopped, restarting.", "You regain consciousness."}, {"There are screens on:", "Your inventory:"}, {"There is a screen on:", "Your inventory:"}, {"There are several screens on:", "Prove thyself worthy or perish:"}, {"There is a suitable screen on:", "You see here a good looking screen:"}, {"There are several suitable screens on:", "You may wish for a screen, what do you want?"}, {"%d socket%s wiped out.", "You hear %d distant explosion%s."}, {"Remove dead screens with 'screen -wipe'.", "The dead screen%s touch%s you. Try 'screen -wipe'."}, {"Illegal reattach attempt from terminal %s.", "'%s' tries to touch your session, but fails."}, {"Could not write %s", "%s is too hard to dig in"}, {0, 0} }; #endif const char * DoNLS(from) const char *from; { #ifdef NETHACK struct nlstrans *t; if (nethackflag) { for (t = nethacktrans; t->from; t++) if (strcmp(from, t->from) == 0) return t->to; } #endif return from; } screen-4.3.1/resize.c0000644000175000017500000006271112544062660013357 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 * http://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 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 /* 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) { nomem: if (nmlines) { 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); if (nmlines) free(nmlines); if (nhlines) free(nhlines); return -1; } 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; #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; } 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.3.1/.iscreenrc0000644000175000017500000001516612326531270013666 0ustar amadeamade# # A sample .screenrc which I use for everyday work. # # some of the commands commented out here, have been moved to # /local/etc/screenrc # # we want no password, right? #password # This will ask us for a password. password none # Same as not even mentioning it. #password 12Bz/9hNlPLZk # "1234" #password YahtrWblnJw # ypmatch jnweiger passwd. Well, ... :-) scrollback 200 # we have a 200 lines history buffer markkeys "@=\177:@=^C" # our mad facit-twist terminal buffer overflow... markkeys "h=^B:l=^F:\$=^E" # some missing emacs style bindings in copymode echo -n "booting screen" # let it flash, not horn! #vbell on # "vbell" don't work any longer, sorry. #vbell_msg " Wuff, Wuff!! " # this is the default message #bell "Bimmmel No. %" # sounds the bell and shows a message # we want to login all windows we create. #login on # "login", "nologin" don't work any longer, sorry 2. echo -n "." # we have no termcap entry for screen on the target machine? Well then # we tell a lie. term screen # would be the obvious default here. #term vt100 # screen will understand vt100 for 99%. # we want to survive hangups # note that the default setting is off now! autodetach on # when we open a window, where shall its CWD be? chdir # without argument it's my $HOME echo -n "." # I hate nonexisting status lines! Force screen to believe me. #hardstatus off # now some Terminal setup: # Printing in the leftmost column is not save. We express that fact as :LP@: # # Emacs tends to smear it's highlighted status bar across the screen, producing # ugly areas of bright background, if termcap is'nt perfectly sober. # Give a little :ms@: in the termcap, this may help. # # And who invented the initialisation for facit terminals? We tell him that # we non't like smooth scroll, by specifying :ti=\E[?l:. # \E[?3l 80 Zeichen # \E[?3h 132 Zeichen # LP Last column Printable # \E[A cursor up # \E[B cursor down # \E[?4h smooth scroll # \E[?4l jump scroll # \E[%dL insert %d lines # \E[K clear to end of line # cs \E[%i%d;%dr for twist and xterm # ms@ Move in Standout mode is NOT save. # WS our private variable, it declares that the terminal can # be resized by an escape-sequence # The termcap statement takes 2 or three parameters. First parameter lists # which TERMCAPs are affected by this statement. Second we specify changes # in screen's view of that terminals. Third we may specify some capabilities # that user-programs want to see in the $TERMCAP environment variable or in # screen's termcap entry. termcap vt* cl=\E[H\E[J\E[?1h:vi=\E[?35h:ve=\E[35l:ti=\E[?4l[vt100] termcap facit ti=\E[?4l[facit] termcap xterm* is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l:Z0=\E[?3h:Z1=\E[?3l echo -n "." # "\E(B", "\E(0", "\E(1", "\E(2", ... to switch between charsets. # screen internally emulates G1: "\E)..", G2: "\E*..", G3: "\E+.." # you can switch between them, with: # # code | switch to # ------+------ # ^O | G0 # ^N | G1 # \En | G2 # \Eo | G3 #termcap facit|vt100|xterm* G0 # how do we resize windows? under sunview, this is standard, but xterm # needs to be a specially hacked xterm, to make this work. termcap xterm* WS=\E[8;%d;%dt # ICL 6402 testing: termcap icl* G0:S0=\E$[start]:E0=\E%[end]:C0=j9kx5 GS=\E(0^O:GE=\E(B^O:G1=k:G2=l:G3=m:G4=j:GV=x:GH=q:GR=u:GL=t:GU=w:GD=v:GC=n # Flowcontrol produces trouble. ^S und ^Q will never reach screen, as our # terminals catch them locally. Who can explain that to me?: #flow on|off|auto [interrupt] # Long Lines get wrapped around (the back of your terminal). This is the # default for vt100. But now programs make different asumptions about your # terminal. You may find two linefeeds where you'd expect one, or you may # be confronted with a truncated line. Currently there is no fix, but pressing # C-A r and doing a redraw. #wrap on # the autoaka allows you to see the currently executing shell command in the # window name field. To use that, your shell prompt must contain ^[k^[\ or # you will see the string "(init)" as a name. # in my .cshrc I may use this for a wonderfull tcsh-prompt: # set prompt="%{^[k^[\\%}%h %c2(%m)%# " # # defining a shellaka that contains a pipe-symbol (|) activites the # autoaka feature. To the left of that | you specify a constant part of # your prompt as a trigger, to the right you may place a default string # as in shellaka '> |tc' # but beware! specifying a window name with the -t option has priority over # the autoaka mechanism. Although specifying -t "> |foo" will work. # shellaka tc # ... now a little bit of key bindings # In case we don't have write permission for /etc/utmp (no s-bit) # we create even local windows via rlogin. -> Et voila: a utmp-slot # utmp-slots are strongly recomended to keep sccs and talk happy. # (thus we have ^A# or. ^Ac for windowcreation with or without utmp-slot.) # but if we run suid-root, we produce all the rlogins with -ln, # as nobody shall refer to these pty's. bind '!' screen -ln -k faui41 rlogin faui41 bind '@' screen -ln -k vme2 rlogin faui4_vme2 #bind '#' screen -k faui43 bind '#' screen -ln -k faui43 rlogin faui43 bind '$' screen -ln -k faui44 rlogin faui44 bind '%' screen -ln -k faui45 rlogin faui45 bind '\^' screen -ln -k sup1 rlogin fausup1 bind '&' screen -ln -k sup2 rlogin fausup2 bind '*' screen -ln -k faui48 rlogin faui48 bind '(' screen -ln -k faui09 rlogin faui09 bind ')' screen -ln -k faui10 rlogin faui10 bind 'J' screen -ln -k 4j rlogin faui4j bind 'P' screen -ln -k 4p rlogin faui4p bind '^C' screen -ln -k 45c rlogin faui45c bind '^D' screen -ln -k 45d rlogin faui45d bind '^E' screen -ln -k 45e rlogin faui45e bind '^I' screen -ln -k 45i rlogin faui45i # these two are logIn and logOut. As a toggle is too stupid. #bind 'I' set login on #bind 'O' set login off bind 'L' # What happens, when you 'think emacs' and want to erase a whole # line? You type ^A^K right? Under screen it should be ^Aa^K. But... # killing the window would be a real punishment for a little mistyping. bind k #wow! I even amange to type ^Ak by accident. #bind ^k #bind K kill echo -n "." #screen 1:faui43 # My good old : syntax #screen -k faui43 # The way Wayne Davison thinks about it. #screen -ln -k faui43 # this one not logged in. #screen -ln 2:faui09 rlogin faui09 -l jnweiger # Finally another bonus feature for people using strange terminal settings like # different baud rate, etc. The next user will get standard settings # as ^[c is a reset sequence. #pow_detach_msg "" # is the default pow_detach_msg "c" echo "done." screen-4.3.1/attacher.c0000644000175000017500000006236512544062657013664 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 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include "config.h" #include #include #include #include #include #include "screen.h" #include "extern.h" #include static int WriteMessage __P((int, struct msg *)); static sigret_t AttacherSigInt __P(SIGPROTOARG); #if defined(SIGWINCH) && defined(TIOCGWINSZ) static sigret_t AttacherWinch __P(SIGPROTOARG); #endif #ifdef LOCK static sigret_t DoLock __P(SIGPROTOARG); static void LockTerminal __P((void)); static sigret_t LockHup __P(SIGPROTOARG); static void screen_builtin_lck __P((void)); #endif #ifdef DEBUG static sigret_t AttacherChld __P(SIGPROTOARG); #endif static sigret_t AttachSigCont __P(SIGPROTOARG); extern int real_uid, real_gid, eff_uid, eff_gid; extern char *SockName, *SockMatch, SockPath[]; extern char HostName[]; extern struct passwd *ppp; extern char *attach_tty, *attach_term, *LoginName, *preselect; extern int xflag, dflag, rflag, quietflag, adaptflag; extern struct mode attach_Mode; extern struct NewWindow nwin_options; extern int MasterPid, attach_fd; #ifdef MULTIUSER extern char *multi; extern int multiattach, multi_uid, own_uid; extern int tty_mode, tty_oldmode; # ifndef USE_SETEUID static int multipipe[2]; # endif #endif static int ContinuePlease; static sigret_t AttachSigCont SIGDEFARG { debug("SigCont()\n"); ContinuePlease = 1; SIGRETURN; } static int QueryResult; static sigret_t QueryResultSuccess SIGDEFARG { QueryResult = 1; SIGRETURN; } static sigret_t QueryResultFail SIGDEFARG { QueryResult = 2; SIGRETURN; } /* * Send message to a screen backend. * returns 1 if we could attach one, or 0 if none. * Understands MSG_ATTACH, MSG_DETACH, MSG_POW_DETACH * MSG_CONT, MSG_WINCH and nothing else! * * if type == MSG_ATTACH and sockets are used, attaches * tty filedescriptor. */ static int WriteMessage(s, m) int s; struct msg *m; { int r, l = sizeof(*m); #ifndef NAMEDPIPE if (m->type == MSG_ATTACH) return SendAttachMsg(s, m, attach_fd); #endif while(l > 0) { r = write(s, (char *)m + (sizeof(*m) - l), l); if (r == -1 && errno == EINTR) continue; if (r == -1 || r == 0) return -1; l -= r; } return 0; } int Attach(how) int how; { int n, lasts; struct msg m; struct stat st; char *s; debug2("Attach: how=%d, tty=%s\n", how, attach_tty); #ifdef MULTIUSER # ifndef USE_SETEUID while ((how == MSG_ATTACH || how == MSG_CONT) && multiattach) { int ret; if (pipe(multipipe)) Panic(errno, "pipe"); if (chmod(attach_tty, 0666)) Panic(errno, "chmod %s", attach_tty); tty_oldmode = tty_mode; eff_uid = -1; /* make UserContext fork */ real_uid = multi_uid; if ((ret = UserContext()) <= 0) { char dummy; eff_uid = 0; real_uid = own_uid; if (ret < 0) Panic(errno, "UserContext"); close(multipipe[1]); read(multipipe[0], &dummy, 1); if (tty_oldmode >= 0) { chmod(attach_tty, tty_oldmode); tty_oldmode = -1; } ret = UserStatus(); #ifdef LOCK if (ret == SIG_LOCK) LockTerminal(); else #endif #ifdef SIGTSTP if (ret == SIG_STOP) kill(getpid(), SIGTSTP); else #endif if (ret == SIG_POWER_BYE) { int ppid; if (setgid(real_gid) || setuid(real_uid)) Panic(errno, "setuid/gid"); if ((ppid = getppid()) > 1) Kill(ppid, SIGHUP); exit(0); } else exit(ret); dflag = 0; #ifdef MULTI xflag = 1; #endif how = MSG_ATTACH; continue; } close(multipipe[0]); eff_uid = real_uid; break; } # else /* USE_SETEUID */ if ((how == MSG_ATTACH || how == MSG_CONT) && multiattach) { real_uid = multi_uid; eff_uid = own_uid; #ifdef HAVE_SETRESUID if (setresuid(multi_uid, own_uid, multi_uid)) Panic(errno, "setresuid"); #else xseteuid(multi_uid); xseteuid(own_uid); #endif if (chmod(attach_tty, 0666)) Panic(errno, "chmod %s", attach_tty); tty_oldmode = tty_mode; } # endif /* USE_SETEUID */ #endif /* MULTIUSER */ bzero((char *) &m, sizeof(m)); m.type = how; m.protocol_revision = MSG_REVISION; strncpy(m.m_tty, attach_tty, sizeof(m.m_tty) - 1); m.m_tty[sizeof(m.m_tty) - 1] = 0; if (how == MSG_WINCH) { if ((lasts = MakeClientSocket(0)) >= 0) { WriteMessage(lasts, &m); close(lasts); } return 0; } if (how == MSG_CONT) { if ((lasts = MakeClientSocket(0)) < 0) { Panic(0, "Sorry, cannot contact session \"%s\" again.\r\n", SockName); } } else { n = FindSocket(&lasts, (int *)0, (int *)0, SockMatch); switch (n) { case 0: if (rflag && (rflag & 1) == 0) return 0; if (quietflag) eexit(10); if (SockMatch && *SockMatch) { Panic(0, "There is no screen to be %sed matching %s.", xflag ? "attach" : dflag ? "detach" : "resum", SockMatch); } else { Panic(0, "There is no screen to be %sed.", xflag ? "attach" : dflag ? "detach" : "resum"); } /* NOTREACHED */ case 1: break; default: if (rflag < 3) { if (quietflag) eexit(10 + n); Panic(0, "Type \"screen [-d] -r [pid.]tty.host\" to resume one of them."); } /* NOTREACHED */ } } /* * Go in UserContext. Advantage is, you can kill your attacher * when things go wrong. Any disadvantages? jw. * Do this before the attach to prevent races! */ #ifdef MULTIUSER if (!multiattach) #endif { if (setuid(real_uid)) Panic(errno, "setuid"); } #if defined(MULTIUSER) && defined(USE_SETEUID) else { /* This call to xsetuid should also set the saved uid */ xseteuid(real_uid); /* multi_uid, allow backend to send signals */ } #endif if (setgid(real_gid)) Panic(errno, "setgid"); eff_uid = real_uid; eff_gid = real_gid; debug2("Attach: uid %d euid %d\n", (int)getuid(), (int)geteuid()); MasterPid = 0; for (s = SockName; *s; s++) { if (*s > '9' || *s < '0') break; MasterPid = 10 * MasterPid + (*s - '0'); } debug1("Attach decided, it is '%s'\n", SockPath); debug1("Attach found MasterPid == %d\n", MasterPid); if (stat(SockPath, &st) == -1) Panic(errno, "stat %s", SockPath); if ((st.st_mode & 0600) != 0600) Panic(0, "Socket is in wrong mode (%03o)", (int)st.st_mode); /* * Change: if -x or -r ignore failing -d */ if ((xflag || rflag) && dflag && (st.st_mode & 0700) == 0600) dflag = 0; /* * Without -x, the mode must match. * With -x the mode is irrelevant unless -d. */ if ((dflag || !xflag) && (st.st_mode & 0700) != (dflag ? 0700 : 0600)) Panic(0, "That screen is %sdetached.", dflag ? "already " : "not "); #ifdef REMOTE_DETACH if (dflag && (how == MSG_DETACH || how == MSG_POW_DETACH)) { m.m.detach.dpid = getpid(); strncpy(m.m.detach.duser, LoginName, sizeof(m.m.detach.duser) - 1); m.m.detach.duser[sizeof(m.m.detach.duser) - 1] = 0; # ifdef POW_DETACH if (dflag == 2) m.type = MSG_POW_DETACH; else # endif m.type = MSG_DETACH; /* If there is no password for the session, or the user enters the correct * password, then we get a SIGCONT. Otherwise we get a SIG_BYE */ signal(SIGCONT, AttachSigCont); if (WriteMessage(lasts, &m)) Panic(errno, "WriteMessage"); close(lasts); while (!ContinuePlease) pause(); /* wait for SIGCONT */ signal(SIGCONT, SIG_DFL); ContinuePlease = 0; if (how != MSG_ATTACH) return 0; /* we detached it. jw. */ sleep(1); /* we dont want to overrun our poor backend. jw. */ if ((lasts = MakeClientSocket(0)) == -1) Panic(0, "Cannot contact screen again. Sigh."); m.type = how; } #endif ASSERT(how == MSG_ATTACH || how == MSG_CONT); strncpy(m.m.attach.envterm, attach_term, sizeof(m.m.attach.envterm) - 1); m.m.attach.envterm[sizeof(m.m.attach.envterm) - 1] = 0; debug1("attach: sending %d bytes... ", (int)sizeof(m)); strncpy(m.m.attach.auser, LoginName, sizeof(m.m.attach.auser) - 1); m.m.attach.auser[sizeof(m.m.attach.auser) - 1] = 0; m.m.attach.esc = DefaultEsc; m.m.attach.meta_esc = DefaultMetaEsc; strncpy(m.m.attach.preselect, preselect ? preselect : "", sizeof(m.m.attach.preselect) - 1); m.m.attach.preselect[sizeof(m.m.attach.preselect) - 1] = 0; m.m.attach.apid = getpid(); m.m.attach.adaptflag = adaptflag; m.m.attach.lines = m.m.attach.columns = 0; if ((s = getenv("LINES"))) m.m.attach.lines = atoi(s); if ((s = getenv("COLUMNS"))) m.m.attach.columns = atoi(s); m.m.attach.encoding = nwin_options.encoding > 0 ? nwin_options.encoding + 1 : 0; #ifdef REMOTE_DETACH #ifdef POW_DETACH if (dflag == 2) m.m.attach.detachfirst = MSG_POW_DETACH; else #endif if (dflag) m.m.attach.detachfirst = MSG_DETACH; else #endif m.m.attach.detachfirst = MSG_ATTACH; #ifdef MULTIUSER /* setup CONT signal handler to repair the terminal mode */ if (multi && (how == MSG_ATTACH || how == MSG_CONT)) signal(SIGCONT, AttachSigCont); #endif if (WriteMessage(lasts, &m)) Panic(errno, "WriteMessage"); close(lasts); debug1("Attach(%d): sent\n", m.type); #ifdef MULTIUSER if (multi && (how == MSG_ATTACH || how == MSG_CONT)) { while (!ContinuePlease) pause(); /* wait for SIGCONT */ signal(SIGCONT, SIG_DFL); ContinuePlease = 0; # ifndef USE_SETEUID close(multipipe[1]); # else xseteuid(own_uid); if (tty_oldmode >= 0) if (chmod(attach_tty, tty_oldmode)) Panic(errno, "chmod %s", attach_tty); tty_oldmode = -1; xseteuid(real_uid); # endif } #endif rflag = 0; return 1; } static int AttacherPanic = 0; #ifdef DEBUG static sigret_t AttacherChld SIGDEFARG { AttacherPanic = 1; SIGRETURN; } #endif static sigret_t AttacherSigAlarm SIGDEFARG { #ifdef DEBUG static int tick_cnt = 0; if ((tick_cnt = (tick_cnt + 1) % 4) == 0) debug("tick\n"); #endif SIGRETURN; } /* * the frontend's Interrupt handler * we forward SIGINT to the poor backend */ static sigret_t AttacherSigInt SIGDEFARG { signal(SIGINT, AttacherSigInt); Kill(MasterPid, SIGINT); SIGRETURN; } /* * Unfortunately this is also the SIGHUP handler, so we have to * check if the backend is already detached. */ sigret_t AttacherFinit SIGDEFARG { struct stat statb; struct msg m; int s; debug("AttacherFinit();\n"); signal(SIGHUP, SIG_IGN); /* Check if signal comes from backend */ if (stat(SockPath, &statb) == 0 && (statb.st_mode & 0777) != 0600) { debug("Detaching backend!\n"); bzero((char *) &m, sizeof(m)); strncpy(m.m_tty, attach_tty, sizeof(m.m_tty) - 1); m.m_tty[sizeof(m.m_tty) - 1] = 0; debug1("attach_tty is %s\n", attach_tty); m.m.detach.dpid = getpid(); m.type = MSG_HANGUP; m.protocol_revision = MSG_REVISION; if ((s = MakeClientSocket(0)) >= 0) { WriteMessage(s, &m); close(s); } } #ifdef MULTIUSER if (tty_oldmode >= 0) { if (setuid(own_uid)) Panic(errno, "setuid"); chmod(attach_tty, tty_oldmode); } #endif exit(0); SIGRETURN; } #ifdef POW_DETACH static sigret_t AttacherFinitBye SIGDEFARG { int ppid; debug("AttacherFintBye()\n"); #if defined(MULTIUSER) && !defined(USE_SETEUID) if (multiattach) exit(SIG_POWER_BYE); #endif if (setgid(real_gid)) Panic(errno, "setgid"); #ifdef MULTIUSER if (setuid(own_uid)) Panic(errno, "setuid"); #else if (setuid(real_uid)) Panic(errno, "setuid"); #endif /* we don't want to disturb init (even if we were root), eh? jw */ if ((ppid = getppid()) > 1) Kill(ppid, SIGHUP); /* carefully say good bye. jw. */ exit(0); SIGRETURN; } #endif #if defined(DEBUG) && defined(SIG_NODEBUG) static sigret_t AttacherNoDebug SIGDEFARG { debug("AttacherNoDebug()\n"); signal(SIG_NODEBUG, AttacherNoDebug); if (dfp) { debug("debug: closing debug file.\n"); fflush(dfp); fclose(dfp); dfp = NULL; } SIGRETURN; } #endif /* SIG_NODEBUG */ static int SuspendPlease; static sigret_t SigStop SIGDEFARG { debug("SigStop()\n"); SuspendPlease = 1; SIGRETURN; } #ifdef LOCK static int LockPlease; static sigret_t DoLock SIGDEFARG { # ifdef SYSVSIGS signal(SIG_LOCK, DoLock); # endif debug("DoLock()\n"); LockPlease = 1; SIGRETURN; } #endif #if defined(SIGWINCH) && defined(TIOCGWINSZ) static int SigWinchPlease; static sigret_t AttacherWinch SIGDEFARG { debug("AttacherWinch()\n"); SigWinchPlease = 1; SIGRETURN; } #endif /* * Attacher loop - no return */ void Attacher() { signal(SIGHUP, AttacherFinit); signal(SIG_BYE, AttacherFinit); #ifdef POW_DETACH signal(SIG_POWER_BYE, AttacherFinitBye); #endif #if defined(DEBUG) && defined(SIG_NODEBUG) signal(SIG_NODEBUG, AttacherNoDebug); #endif #ifdef LOCK signal(SIG_LOCK, DoLock); #endif signal(SIGINT, AttacherSigInt); #ifdef BSDJOBS signal(SIG_STOP, SigStop); #endif #if defined(SIGWINCH) && defined(TIOCGWINSZ) signal(SIGWINCH, AttacherWinch); #endif #ifdef DEBUG signal(SIGCHLD, AttacherChld); #endif debug("attacher: going for a nap.\n"); dflag = 0; #ifdef MULTI xflag = 1; #endif for (;;) { signal(SIGALRM, AttacherSigAlarm); alarm(15); pause(); alarm(0); if (kill(MasterPid, 0) < 0 && errno != EPERM) { debug1("attacher: Panic! MasterPid %d does not exist.\n", MasterPid); AttacherPanic++; } if (AttacherPanic) { fcntl(0, F_SETFL, 0); SetTTY(0, &attach_Mode); printf("\nError: Cannot find master process to attach to!\n"); eexit(1); } #ifdef BSDJOBS if (SuspendPlease) { SuspendPlease = 0; #if defined(MULTIUSER) && !defined(USE_SETEUID) if (multiattach) exit(SIG_STOP); #endif signal(SIGTSTP, SIG_DFL); debug("attacher: killing myself SIGTSTP\n"); kill(getpid(), SIGTSTP); debug("attacher: continuing from stop\n"); signal(SIG_STOP, SigStop); (void) Attach(MSG_CONT); } #endif #ifdef LOCK if (LockPlease) { LockPlease = 0; #if defined(MULTIUSER) && !defined(USE_SETEUID) if (multiattach) exit(SIG_LOCK); #endif LockTerminal(); # ifdef SYSVSIGS signal(SIG_LOCK, DoLock); # endif (void) Attach(MSG_CONT); } #endif /* LOCK */ #if defined(SIGWINCH) && defined(TIOCGWINSZ) if (SigWinchPlease) { SigWinchPlease = 0; # ifdef SYSVSIGS signal(SIGWINCH, AttacherWinch); # endif (void) Attach(MSG_WINCH); } #endif /* SIGWINCH */ } } #ifdef LOCK /* ADDED by Rainer Pruy 10/15/87 */ /* POLISHED by mls. 03/10/91 */ static char LockEnd[] = "Welcome back to screen !!\n"; static sigret_t LockHup SIGDEFARG { int ppid = getppid(); if (setgid(real_gid)) Panic(errno, "setgid"); #ifdef MULTIUSER if (setuid(own_uid)) Panic(errno, "setuid"); #else if (setuid(real_uid)) Panic(errno, "setuid"); #endif if (ppid > 1) Kill(ppid, SIGHUP); exit(0); } static void LockTerminal() { char *prg; int sig, pid; sigret_t (*sigs[NSIG])__P(SIGPROTOARG); for (sig = 1; sig < NSIG; sig++) sigs[sig] = signal(sig, sig == SIGCHLD ? SIG_DFL : SIG_IGN); signal(SIGHUP, LockHup); printf("\n"); prg = getenv("LOCKPRG"); if (prg && strcmp(prg, "builtin") && !access(prg, X_OK)) { signal(SIGCHLD, SIG_DFL); debug1("lockterminal: '%s' seems executable, execl it!\n", prg); if ((pid = fork()) == 0) { /* Child */ if (setgid(real_gid)) Panic(errno, "setgid"); #ifdef MULTIUSER if (setuid(own_uid)) Panic(errno, "setuid"); #else if (setuid(real_uid)) /* this should be done already */ Panic(errno, "setuid"); #endif closeallfiles(0); /* important: /etc/shadow may be open */ execl(prg, "SCREEN-LOCK", NULL); exit(errno); } if (pid == -1) Msg(errno, "Cannot lock terminal - fork failed"); else { #ifdef BSDWAIT union wait wstat; #else int wstat; #endif int wret; #ifdef hpux signal(SIGCHLD, SIG_DFL); #endif errno = 0; while (((wret = wait(&wstat)) != pid) || ((wret == -1) && (errno == EINTR)) ) errno = 0; if (errno) { Msg(errno, "Lock"); sleep(2); } else if (WTERMSIG(wstat) != 0) { fprintf(stderr, "Lock: %s: Killed by signal: %d%s\n", prg, WTERMSIG(wstat), WIFCORESIG(wstat) ? " (Core dumped)" : ""); sleep(2); } else if (WEXITSTATUS(wstat)) { debug2("Lock: %s: return code %d\n", prg, WEXITSTATUS(wstat)); } else printf("%s", LockEnd); } } else { if (prg) { debug1("lockterminal: '%s' seems NOT executable, we use our builtin\n", prg); } else { debug("lockterminal: using buitin.\n"); } screen_builtin_lck(); } /* reset signals */ for (sig = 1; sig < NSIG; sig++) { if (sigs[sig] != (sigret_t(*)__P(SIGPROTOARG)) -1) signal(sig, sigs[sig]); } } /* LockTerminal */ #ifdef USE_PAM /* * PAM support by Pablo Averbuj */ #include static int PAM_conv __P((int, const struct pam_message **, struct pam_response **, void *)); static int PAM_conv(num_msg, msg, resp, appdata_ptr) int num_msg; const struct pam_message **msg; struct pam_response **resp; void *appdata_ptr; { int replies = 0; struct pam_response *reply = NULL; reply = malloc(sizeof(struct pam_response)*num_msg); if (!reply) return PAM_CONV_ERR; #define COPY_STRING(s) (s) ? strdup(s) : NULL for (replies = 0; replies < num_msg; replies++) { switch (msg[replies]->msg_style) { case PAM_PROMPT_ECHO_OFF: /* wants password */ reply[replies].resp_retcode = PAM_SUCCESS; reply[replies].resp = appdata_ptr ? strdup((char *)appdata_ptr) : 0; break; case PAM_TEXT_INFO: /* ignore the informational mesage */ /* but first clear out any drek left by malloc */ reply[replies].resp = NULL; break; case PAM_PROMPT_ECHO_ON: /* user name given to PAM already */ /* fall through */ default: /* unknown or PAM_ERROR_MSG */ free(reply); return PAM_CONV_ERR; } } *resp = reply; return PAM_SUCCESS; } static struct pam_conv PAM_conversation = { &PAM_conv, NULL }; #endif /* -- original copyright by Luigi Cannelloni 1985 (luigi@faui70.UUCP) -- */ static void screen_builtin_lck() { char fullname[100], *cp1, message[100 + 100]; #ifdef USE_PAM pam_handle_t *pamh = 0; int pam_error; char *tty_name; #endif char *pass = 0, mypass[16 + 1], salt[3]; int using_pam = 1; #ifdef USE_PAM if (!ppp->pw_uid) { #endif using_pam = 0; pass = ppp->pw_passwd; if (pass == 0 || *pass == 0) { if ((pass = getpass("Key: "))) { strncpy(mypass, pass, sizeof(mypass) - 1); mypass[sizeof(mypass) - 1] = 0; if (*mypass == 0) return; if ((pass = getpass("Again: "))) { if (strcmp(mypass, pass)) { fprintf(stderr, "Passwords don't match.\007\n"); sleep(2); return; } } } if (pass == 0) { fprintf(stderr, "Getpass error.\007\n"); sleep(2); return; } salt[0] = 'A' + (int)(time(0) % 26); salt[1] = 'A' + (int)((time(0) >> 6) % 26); salt[2] = 0; pass = crypt(mypass, salt); if (!pass) { fprintf(stderr, "crypt() error.\007\n"); sleep(2); return; } pass = ppp->pw_passwd = SaveStr(pass); } #ifdef USE_PAM } #endif debug("screen_builtin_lck looking in gcos field\n"); strncpy(fullname, ppp->pw_gecos, sizeof(fullname) - 9); fullname[sizeof(fullname) - 9] = 0; if ((cp1 = index(fullname, ',')) != NULL) *cp1 = '\0'; if ((cp1 = index(fullname, '&')) != NULL) { strncpy(cp1, ppp->pw_name, 8); cp1[8] = 0; if (*cp1 >= 'a' && *cp1 <= 'z') *cp1 -= 'a' - 'A'; } sprintf(message, "Screen used by %s%s<%s> on %s.\nPassword:\007", fullname, fullname[0] ? " " : "", ppp->pw_name, HostName); /* loop here to wait for correct password */ for (;;) { debug("screen_builtin_lck awaiting password\n"); errno = 0; if ((cp1 = getpass(message)) == NULL) { AttacherFinit(SIGARG); /* NOTREACHED */ } if (using_pam) { #ifdef USE_PAM PAM_conversation.appdata_ptr = cp1; pam_error = pam_start("screen", ppp->pw_name, &PAM_conversation, &pamh); if (pam_error != PAM_SUCCESS) AttacherFinit(SIGARG); /* goodbye */ if (strncmp(attach_tty, "/dev/", 5) == 0) tty_name = attach_tty + 5; else tty_name = attach_tty; pam_error = pam_set_item(pamh, PAM_TTY, tty_name); if (pam_error != PAM_SUCCESS) AttacherFinit(SIGARG); /* goodbye */ pam_error = pam_authenticate(pamh, 0); pam_end(pamh, pam_error); PAM_conversation.appdata_ptr = 0; if (pam_error == PAM_SUCCESS) break; #endif } else { char *buf = crypt(cp1, pass); if (buf && !strncmp(buf, pass, strlen(pass))) break; } debug("screen_builtin_lck: NO!!!!!\n"); bzero(cp1, strlen(cp1)); } bzero(cp1, strlen(cp1)); debug("password ok.\n"); } #endif /* LOCK */ void SendCmdMessage(sty, match, av, query) char *sty; char *match; char **av; int query; { int i, s; struct msg m; char *p; int len, n; if (sty == 0) { i = FindSocket(&s, (int *)0, (int *)0, match); if (i == 0) Panic(0, "No screen session found."); if (i != 1) Panic(0, "Use -S to specify a session."); } else { #ifdef NAME_MAX if (strlen(sty) > NAME_MAX) sty[NAME_MAX] = 0; #endif if (strlen(sty) > 2 * MAXSTR - 1) sty[2 * MAXSTR - 1] = 0; sprintf(SockPath + strlen(SockPath), "/%s", sty); if ((s = MakeClientSocket(1)) == -1) exit(1); } bzero((char *)&m, sizeof(m)); m.type = query ? MSG_QUERY : MSG_COMMAND; if (attach_tty) { strncpy(m.m_tty, attach_tty, sizeof(m.m_tty) - 1); m.m_tty[sizeof(m.m_tty) - 1] = 0; } p = m.m.command.cmd; n = 0; for (; *av && n < MAXARGS - 1; ++av, ++n) { len = strlen(*av) + 1; if (p + len >= m.m.command.cmd + sizeof(m.m.command.cmd) - 1) break; strcpy(p, *av); p += len; } *p = 0; m.m.command.nargs = n; strncpy(m.m.attach.auser, LoginName, sizeof(m.m.attach.auser) - 1); m.m.command.auser[sizeof(m.m.command.auser) - 1] = 0; m.protocol_revision = MSG_REVISION; strncpy(m.m.command.preselect, preselect ? preselect : "", sizeof(m.m.command.preselect) - 1); m.m.command.preselect[sizeof(m.m.command.preselect) - 1] = 0; m.m.command.apid = getpid(); debug1("SendCommandMsg writing '%s'\n", m.m.command.cmd); if (query) { /* Create a server socket so we can get back the result */ char *sp = SockPath + strlen(SockPath); char query[] = "-queryX"; char c; int r = -1; for (c = 'A'; c <= 'Z'; c++) { query[6] = c; strcpy(sp, query); /* XXX: strncpy? */ if ((r = MakeServerSocket()) >= 0) break; } if (r < 0) { for (c = '0'; c <= '9'; c++) { query[6] = c; strcpy(sp, query); if ((r = MakeServerSocket()) >= 0) break; } } if (r < 0) Panic(0, "Could not create a listening socket to read the results."); strncpy(m.m.command.writeback, SockPath, sizeof(m.m.command.writeback) - 1); m.m.command.writeback[sizeof(m.m.command.writeback) - 1] = '\0'; /* Send the message, then wait for a response */ signal(SIGCONT, QueryResultSuccess); signal(SIG_BYE, QueryResultFail); if (WriteMessage(s, &m)) Msg(errno, "write"); close(s); while (!QueryResult) pause(); signal(SIGCONT, SIG_DFL); signal(SIG_BYE, SIG_DFL); /* Read the result and spit it out to stdout */ ReceiveRaw(r); unlink(SockPath); if (QueryResult == 2) /* An error happened */ exit(1); } else { if (WriteMessage(s, &m)) Msg(errno, "write"); close(s); } } screen-4.3.1/list_generic.h0000644000175000017500000000510612544062660014525 0ustar amadeamade/* Copyright (c) 2010 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net) * * 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 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ struct ListData; struct ListRow { void *data; /* Some data relevant to this row */ struct ListRow *next, *prev; /* doubly linked list */ int y; /* -1 if not on display */ }; struct GenericList { int (*gl_printheader) __P((struct ListData *)); /* Print the header */ int (*gl_printfooter) __P((struct ListData *)); /* Print the footer */ int (*gl_printrow) __P((struct ListData *, struct ListRow *)); /* Print one row */ int (*gl_pinput) __P((struct ListData *, char **inp, int *len)); /* Process input */ int (*gl_freerow) __P((struct ListData *, struct ListRow *)); /* Free data for a row */ int (*gl_free) __P((struct ListData *)); /* Free data for the list */ int (*gl_matchrow) __P((struct ListData *, struct ListRow *, const char *)); }; struct ListData { const char *name; /* An identifier for the list */ struct ListRow *root; /* The first item in the list */ struct ListRow *selected; /* The selected row */ struct ListRow *top; /* The topmost visible row */ struct GenericList *list_fn; /* The functions that deal with the list */ char *search; /* The search term, if any */ void *data; /* List specific data */ }; extern struct LayFuncs ListLf; struct ListRow * glist_add_row __P((struct ListData *ldata, void *data, struct ListRow *after)); void glist_remove_rows __P((struct ListData *ldata)); void glist_display_all __P((struct ListData *list)); struct ListData * glist_display __P((struct GenericList *list, const char *name)); void glist_abort __P((void)); void display_displays __P((void)); void display_windows __P((int onblank, int order, struct win *group)); screen-4.3.1/NEWS0000644000175000017500000000135212543211734012400 0ustar amadeamade ------------------------------ What's new in screen-4.0.3 ? ------------------------------ * zombie command has new option 'onerror' * buffer overflow in resize.c fixed * minor docu update * more robust startup * use setresuid; SendAttachMsg() for fd-passing added; DoCSI enhanced. ------------------------------ What's new in screen-4.0.0 ? ------------------------------ * new screenrc parser, not 100% compatible. * screenblanker support: new 'idle', 'blanker', 'blankerprg' commands. * zmodem support via the 'zmodem' command. * nonblock code rewritten, nonblock now understands a timeout. new command 'defnonblock'. screen-4.3.1/etc/0000755000175000017500000000000012544062657012464 5ustar amadeamadescreen-4.3.1/etc/toolcheck0000755000175000017500000000223212326531270014352 0ustar amadeamade#!/bin/sh # toolcheck -- check for tools that have severe bugs. Good that all the buggy # tools identify by version numbers. This is the spirit of GNU :-) # # 24.7.95 jw. retval=0 reply="`sh -version 2>&1 < /dev/null | sed q`" case "$reply" in GNU*1.14.3*) echo "- sh is '$reply'"; echo " CAUTION: This shell has a buggy 'trap' command."; echo " The configure script may fail silently."; retval=1; ;; GNU*1.14.2*|GNU*1.14.4*|GNU*1.13.*) echo "- sh is '$reply' - good."; ;; GNU*) echo "- sh is '$reply'."; ;; *) ;; esac reply="`sed --version 2>&1 < /dev/null | sed q`" case "$reply" in GNU\ sed\ version\ 2.0[34]) echo "- sed is '$reply'"; echo " CAUTION: This sed cannot configure screen properly." retval=1; ;; GNU\ sed\ version\ 2.05|GNU\ sed\ version\ 2.03\ kevin) echo "- sed is '$reply' - good."; ;; GNU*) echo "- sed is '$reply'."; ;; *) ;; esac if [ "$retval" != 0 ]; then echo " ***********************************************************" echo " Please fix the above problem before reporting a screen bug!" echo " ***********************************************************" fi exit $retval screen-4.3.1/etc/etcscreenrc0000644000175000017500000000635612543211734014710 0ustar amadeamade# # This is an example for the global screenrc file. # You may want to install this file as /usr/local/etc/screenrc. # Check config.h for the exact location. # # Flaws of termcap and standard settings are done here. # #startup_message off #defflow on # will force screen to process ^S/^Q deflogin on #autodetach off vbell on vbell_msg " Wuff ---- Wuff!! " # all termcap entries are now duplicated as terminfo entries. # only difference should be the slightly modified syntax, and check for # terminfo entries, that are already corected in the database. # # G0 we have a SEMI-GRAPHICS-CHARACTER-MODE # WS this sequence resizes our window. # cs this sequence changes the scrollregion # hs@ we have no hardware statusline. screen will only believe that # there is a hardware status line if hs,ts,fs,ds are all set. # ts to statusline # fs from statusline # ds delete statusline # al add one line # AL add multiple lines # dl delete one line # DL delete multiple lines # ic insert one char (space) # IC insert multiple chars # nx terminal uses xon/xoff termcap facit|vt100|xterm LP:G0 terminfo facit|vt100|xterm LP:G0 #the vt100 description does not mention "dl". *sigh* termcap vt100 dl=5\E[M terminfo vt100 dl=5\E[M #facit's "al" / "dl" are buggy if the current / last line #contain attributes... termcap facit al=\E[L\E[K:AL@:dl@:DL@:cs=\E[%i%d;%dr:ic@ terminfo facit al=\E[L\E[K:AL@:dl@:DL@:cs=\E[%i%p1%d;%p2%dr:ic@ #make sun termcap/info better termcap sun 'up=^K:AL=\E[%dL:DL=\E[%dM:UP=\E[%dA:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:IC=\E[%d@:WS=1000\E[8;%d;%dt' terminfo sun 'up=^K:AL=\E[%p1%dL:DL=\E[%p1%dM:UP=\E[%p1%dA:DO=\E[%p1%dB:LE=\E[%p1%dD:RI=\E[%p1%dC:IC=\E[%p1%d@:WS=\E[8;%p1%d;%p2%dt$<1000>' #xterm understands both im/ic and doesn't have a status line. #Note: Do not specify im and ic in the real termcap/info file as #some programs (e.g. vi) will (no,no, may (jw)) not work anymore. termcap xterm|fptwist hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l terminfo xterm|fptwist hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l # Long time I had this in my private screenrc file. But many people # seem to want it (jw): # we do not want the width to change to 80 characters on startup: # on suns, /etc/termcap has :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l: termcap xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l' terminfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l' # # Do not use xterms alternate window buffer. # This one would not add lines to the scrollback buffer. termcap xterm|xterms|xs ti=\E7\E[?47l terminfo xterm|xterms|xs ti=\E7\E[?47l #make hp700 termcap/info better termcap hp700 'Z0=\E[?3h:Z1=\E[?3l:hs:ts=\E[62"p\E[0$~\E[2$~\E[1$}:fs=\E[0}\E[61"p:ds=\E[62"p\E[1$~\E[61"p:ic@' terminfo hp700 'Z0=\E[?3h:Z1=\E[?3l:hs:ts=\E[62"p\E[0$~\E[2$~\E[1$}:fs=\E[0}\E[61"p:ds=\E[62"p\E[1$~\E[61"p:ic@' #wyse-75-42 must have defflow control (xo = "terminal uses xon/xoff") #(nowadays: nx = padding doesn't work, have to use xon/off) #essential to have it here, as this is a slow terminal. termcap wy75-42 nx:xo:Z0=\E[?3h\E[31h:Z1=\E[?3l\E[31h terminfo wy75-42 nx:xo:Z0=\E[?3h\E[31h:Z1=\E[?3l\E[31h #remove some stupid / dangerous key bindings bind ^k #bind L bind ^\ #make them better bind \\ quit bind K kill bind I login on bind O login off bind } history screen-4.3.1/etc/gr-braille.tbl0000644000175000017500000002277612326531270015213 0ustar amadeamade# GERMAN BRAILLE TABLE # # Dec Hex Braille Description # ------------------------------------------------------------------------ 0 00 (--345--8) NUL 1 01 (1------8) SOH 2 02 (12-----8) STX 3 03 (1--4---8) ETX 4 04 (1--45--8) EOT 5 05 (1---5--8) ENQ 6 06 (12-4---8) ACK 7 07 (12-45--8) BEL 8 08 (12--5--8) BS 9 09 (-2-4---8) HT 10 OA (-2-45--8) LF 11 0B (1-3----8) VT 12 OC (123----8) FF 13 0D (1-34---8) CR 14 0E (1-345--8) SO 15 OF (1-3-5--8) SI 16 10 (1234---8) DLE 17 11 (12345--8) DC1 18 12 (123-5--8) DC2 19 13 (-234---8) DC3 20 14 (-2345--8) DC4 21 15 (1-3--6-8) NAK 22 16 (123--6-8) SYN 23 17 (-2-456-8) ETB 24 18 (1-34-6-8) CAN 25 19 (1-3456-8) EM 26 1A (1-3-56-8) SUB 27 lB (123-56-8) ESC 28 lC (--34---8) FS 29 1D (-23456-8) GS 30 lE (-234-6-8) RS 31 1F (---456-8) US 32 20 (--------) Space 33 21 (----5---) ! 34 22 (---4----) " 35 23 (--3456--) # 36 24 (---4-6--) $ 37 25 (123456--) % 38 26 (1234-6--) & 39 27 (-----6--) ' 40 28 (-23--6--) ( 41 29 (--3-56--) ) 42 2A (--3-5---) * 43 2B (-23-5---) + 44 2C (-2------) , 45 2D (--3--6--) - 46 2E (--3-----) . 47 2F (-2--56--) / 48 30 (--34-6--) 0 49 31 (1----6--) 1 50 32 (12---6--) 2 51 33 (1--4-6--) 3 52 34 (1--456--) 4 53 35 (1---56--) 5 54 36 (12-4-6--) 6 55 37 (12-456--) 7 56 38 (12--56--) 8 57 39 (-2-4-6--) 9 58 3A (-2--5---) : 59 3B (-23-----) ; 60 3C (----56--) < 61 3D (-23-56--) 62 3E (---45---) > 63 3F (-2---6--) ? 64 40 (--345---) Special sign 65 41 (1-----7-) A 66 42 (12----7-) B 67 43 (1--4--7-) C 68 44 (1--45-7-) D 69 45 (1---5-7-) E 70 46 (12-4--7-) F 71 47 (12-45-7-) G 72 48 (12--5-7-) H 73 49 (-2-4--7-) I 74 4A (-2-45-7-) j 75 4B (1-3---7-) K 76 4C (123---7-) L 77 4D (1-34--7-) M 78 4E (1-345-7-) N 79 4F (1-3-5-7-) O 80 50 (1234--7-) P 81 51 (12345-7-) Q 82 52 (123-5-7-) R 83 53 (-234--7-) S 84 54 (-2345-7-) T 85 55 (1-3--67-) U 86 56 (123--67-) V 87 57 (-2-4567-) W 88 58 (1-34-67-) X 89 59 (1-34567-) Y 90 5A (1-3-567-) Z 91 5B (123-567-) [ or A umlaut 92 5C (--34--7-) \ or umlaut O 93 5D (-234567-) ] or umlaut U 94 5E (-234-67-) ^ or tilde 95 5F (---456--) _ 96 60 (--345--8) ' 97 61 (1-------) a 98 62 (12------) b 99 63 (1--4----) c 100 64 (1--45---) d 101 65 (1---5---) e 102 66 (12-4----) f 103 67 (12-45---) g 104 68 (12--5---) h 105 69 (-2-4----) i 106 6A (-2-45---) j 107 6B (1-3-----) k 108 6C (123-----) l 109 6D (1-34----) m 110 6E (1-345---) n 111 6F (1-3-5---) o 112 70 (1234----) p 113 71 (12345---) q 114 72 (123-5---) r 115 73 (-234----) s 116 74 (-2345---) t 117 75 (1-3--6--) u 118 76 (123--6--) v 119 77 (-2-456--) w 120 78 (1-34-6--) x 121 79 (1-3456--) y 122 7A (1-3-56--) z 123 7B (123-56--) { or umlaut a 124 7C (--34----) | or umlaut o 125 7D (-23456--) } or umlaut u 126 7E (-234-6--) ' 127 7F (---456-8) DEL 128 80 (1234-67-) C Cedilla (upper case) 129 81 (12-456--) u Umlaut (lower case) 130 82 (123456-8) e Acute (lower case) 131 83 (1----6-8) a Circumflex 132 84 (123-56--) a Umlaut (lower case) 133 85 (123-56-8) a Grave 134 86 (-2-----8) a Ring (lower case) 135 87 (1234-6-8) c Cedilla (lower case) 136 88 (12---6-8) e Circumflex 137 89 (12-4-6-8) e Umlaut (lower case) 138 8A (-234-6-8) e Grave 139 8B (12-456-8) i Umlaut (lower case) 140 8C (1--4-6-8) i Circumflex 141 8D (-2-4---8) I Grave 142 8E (123-567-) A Umlaut (upper case) 143 8F (1----67-) A Ring (upper case) 144 90 (1234567-) E Acute (upper case) 145 91 (123-56--) ae Digraph (lower case) 146 92 (123-567-) AE Digraph (upper case) 147 93 (1--456-8) o Circumflex 148 94 (--34----) o Umlaut (lower case) 149 95 (--34-6-8) o Grave 150 96 (1---56-8) u Circumflex 151 97 (-23456-8) u Grave 152 98 (1-3456-8) y Umlaut 153 99 (--34--7-) O Umlaut (upper case) 154 9A (-234567-) U Umlaut (upper case) 155 9B (-23-5678) Cent 156 9C (----56-8) Pound/Sterling 157 9D (-2--5678) Yen 158 9E (-23-5--8) Peseta 159 9F (12-4---8) Franc 160 A0 (-23--678) a Acute (lower case) 161 Al (----5-7-) i Acute (lower case) 162 A2 (----5-78) o Acute (lower case) 163 A3 (--3-5678) u Acute (lower case) 164 A4 (1-345--8) n Tilde (lower case) 165 A5 (--345-7-) N Tilde (upper case) 166 A6 (1------8) Feminine Spanish Ordinal 167 A7 (1-3-5--8) Masculine Spanish Ordinal 168 A8 (--3----8) Inverted Question Mark 169 A9 (--3--67-) Left square corner 170 AA (--3--6-8) Right square corner 171 AB (-23----8) 1/2 172 AC (-2--56-8) 1/4 173 AD (----5--8) Inverted Exclamation Mark 174 AE (--3----8) Left Double Guillemet 175 AF (--3---7-) Right Double Guillemet 176 B0 (--34-67-) Box [Shade 1] 177 B1 (---4-678) Box [Shade 2] 178 B2 (12---67-) Box [Shade 3] 179 B3 (1--4-67-) Box [top bottom] 180 B4 (1--4567-) Box [left top bottom] 181 B5 (1---567-) Box [LEFT top bottom] 182 B6 (12-4-67-) Box [left TOP BOTTOM] 183 B7 (12-4567-) Box [left BOTTOM] 184 B8 (12--567-) Box [LEFT bottom] 185 B9 (-2-4-67-) Box [LEFT TOP BOTTOM] 186 BA (-2--5-7-) Box [TOP BOTTOM] 187 BB (-23---7-) Box [LEFT BOTTOM] 188 BC (----567-) Box [LEFT TOP] 189 BD (-23-567-) Box [left TOP] 190 BE (---45-7-) Box [LEFT top] 191 BF (-2---67-) Box [left bottom] 192 CO (--345--8) Box [top right] 193 C1 (--3---78) Box [left top right] 194 C2 (1--45678) Box [left right bottom] 195 C3 (-2-4-678) Box [top right bottom] 196 C4 (1--45--8) Box [left right] 197 C5 (1---5--8) Box [left top right bottom] 198 C6 (-2--5-78) Box [top RIGHT bottom] 199 C7 (12-45--8) Box [TOP right BOTTOM] 200 C8 (------78) Box [TOP RIGHT] 201 C9 (-2--5--8) Box [RIGHT BOTTOM] 202 CA (-2-45--8) Box [LEFT TOP RIGHT] 203 CB (1-3----8) Box [LEFT RIGHT BOTTOM] 204 CC (123----8) Box [TOP RIGHT BOTTOM] 205 CD (1-34---8) Box [LEFT RIGHT] 206 CE (---4--78) Box [LEFT TOP RIGHT BOTTOM] 207 CF (--345678) Box [LEFT top RIGHT] 208 DO (123----8) Box [left TOP right] 209 D1 (12345--8) Box [LEFT RIGHT bottom] 210 D2 (123-5--8) Box [left right BOTTOM] 211 D3 (-234---8) Box [TOP right] 212 D4 (-2345--8) Box [top RIGHT] 213 D5 (1-3--6-8) Box [RIGHT bottom] 214 D6 (123--6-8) Box [right BOTTOM] 215 D7 (-2-456-8) Box [left TOP right BOTTOM] 216 D8 (1-34-6-8) Box [LEFT top RIGHT bottom] 217 D9 (12345678) Box [left top] 218 DA (1-3-56-8) Box [right bottom] 219 DB (-----678) Box [Shade 4] 220 DC (--34-678) Box [box bottom] 221 DD (1234-678) Box [box right] 222 DE (--3-5-78) Box [box left] 223 DF (---4567-) Box [box top] 224 E0 (------7-) Alpha (lower case) 225 E1 (-234-6--) Beta (lower case) 226 E2 (-23-5-78) Gamma (upper case) 227 E3 (-23-5-7-) Pi (lower case) 228 E4 (---4-6-8) Sigma (upper case) 229 E5 (-2----78) Sigma (lower case) 230 E6 (--3--678) Mu (lower case) 231 E7 (-----6-8) Tau (lower case) 232 E8 (-23--6-8) Phi (upper case) 233 E9 (--3-56-8) Theta (lower case) 234 EA (--3-5--8) Omega (upper case) 235 EB (1----678) Delta (lower case) 236 EC (12---678) infinity 237 ED (1--4-678) Phi (lower case) 238 EE (1---5678) Epsilon (lower case) 239 EF (12-4-678) Intersection 240 F0 (12-45678) Equivalent (Member) 241 F1 (12--5678) Plus or minus 242 F2 (------7-) Greater than or equal 243 F3 (--34567-) Less than or equal 244 F4 (---4-67-) Integral [top] 245 F5 (-23---78) Integral [bottom] 246 F6 (-----67-) Division 247 F7 (-23--67-) Approximately equal 248 F8 (12--56-8) Small circle 249 F9 (-2-4-6-8) Bullet 250 FA (-2--5--8) Small bullet 251 FB (--3-567-) Bent Radical 252 FC (----56-8) Power of n 253 FD (-23-56-8) Power of 2 254 FE (---45--8) Large square bullet 255 FF (-2---6-8) blank (hard space) screen-4.3.1/etc/ccdefs0000755000175000017500000000143712326531270013634 0ustar amadeamade#!/bin/sh cd /tmp umask 022 CC=cc CPP=cpp PATH="$PATH:/lib" TEMP=def$$ trap 'rm -f ${TEMP}*; trap 0; exit' 0 1 2 3 15 set `type $CC` q=$# set x `type $CC` shift $q cc=$1 set `type $CPP` q=$# set x `type $CPP` shift $q cpp=$1 strings - "$cc" 2>/dev/null | tr ' ' '\012' > ${TEMP}.x if test -x "$cpp"; then strings - "$cpp" 2>/dev/null | tr ' ' '\012' >> ${TEMP}.x else echo "Warning: cpp not found." fi sort < ${TEMP}.x | uniq | awk ' /^-D[A-Za-z_][A-Za-z_0-9]*$/ { printf("#ifdef %s\n", substr($0,3)) printf("\"%s\": %s\n", substr($0,3), substr($0,3)) print "#endif" } /^[A-Za-z_][A-Za-z_0-9]*$/ { printf("#ifdef %s\n", $0) printf("\"%s\": %s\n", $0, $0) print "#endif" } ' > ${TEMP}.c echo "Defines in cc are:" cc -E ${TEMP}.c | sed -n -e 's/"\([^:]*\)":/\1:/p' | sort | uniq screen-4.3.1/etc/countmail0000755000175000017500000000255212326531270014377 0ustar amadeamade#!/usr/bin/perl sub countmsgs { return -1 unless open(M, "<$mbox"); my $inhdr = 0; my $cl = undef; my $msgread = 0; my $count = 0; while() { if (!$inhdr && /^From\s+\S+\s+(?i:sun|mon|tue|wed|thu|fri|sat)\s+(?i:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s+\d+\s/) { $inhdr = 1; $msgread = 0; undef $cl; next; } if ($inhdr) { if (/^content-length:\s+(\d+)/i) { $cl = 0+$1; next; } if (/^status:\s+(\S)/i) { $msgread = 1 unless $1 eq 'N' || $1 eq 'U'; next; } if ($_ eq "\n") { $count++ if !$msgread; seek(M, $cl, 1) if defined $cl; $inhdr = 0; } } } close M; return $count; } $| = 1; $mbox = $ARGV[0] || $ENV{'MAIL'}; $oldfmt = $ARGV[1] || "%4d "; $newfmt = $ARGV[2] || "\005{Rk}%4d \005{-}"; @oldstat = stat($mbox); if (!@oldstat) { print "\005{Rk} ??? \005{-}\n"; exit 1; } $oldcount = 0; while(1) { $count = countmsgs($mbox); if ($count == -1) { print "\005{Rk} ??? \005{-}\n"; } elsif ($count < $oldcount || $count == 0) { printf "$oldfmt\n", $count; } else { printf "$newfmt\n", $count; } $oldcount = $count; while (1) { @newstat = stat($mbox); if (!@newstat) { print "\005{Rk} ??? \005{-}\n"; exit 1; } last if $newstat[7] != $oldstat[7] || $newstat[9] != $oldstat[9]; sleep 1; } @oldstat = @newstat; } screen-4.3.1/etc/screenrc0000644000175000017500000000722112326531270014203 0ustar amadeamade# # Example of a user's .screenrc file # # This is how one can set a reattach password: # password ODSJQf.4IJN7E # "1234" # no annoying audible bell, please vbell on # detach on hangup autodetach on # don't display the copyright page startup_message off # emulate .logout message pow_detach_msg "Screen session of \$LOGNAME \$:cr:\$:nl:ended." # advertise hardstatus support to $TERMCAP # termcapinfo * '' 'hs:ts=\E_:fs=\E\\:ds=\E_\E\\' # make the shell in every window a login shell #shell -$SHELL # autoaka testing # shellaka '> |tcsh' # shellaka '$ |sh' # set every new windows hardstatus line to somenthing descriptive # defhstatus "screen: ^En (^Et)" defscrollback 1000 # don't kill window after the process died # zombie "^[" # enable support for the "alternate screen" capability in all windows # altscreen on ################ # # xterm tweaks # #xterm understands both im/ic and doesn't have a status line. #Note: Do not specify im and ic in the real termcap/info file as #some programs (e.g. vi) will not work anymore. termcap xterm hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l terminfo xterm hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l #80/132 column switching must be enabled for ^AW to work #change init sequence to not switch width termcapinfo xterm Z0=\E[?3h:Z1=\E[?3l:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l # Make the output buffer large for (fast) xterms. #termcapinfo xterm* OL=10000 termcapinfo xterm* OL=100 # tell screen that xterm can switch to dark background and has function # keys. termcapinfo xterm 'VR=\E[?5h:VN=\E[?5l' termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~' termcapinfo xterm 'kh=\EOH:kI=\E[2~:kD=\E[3~:kH=\EOF:kP=\E[5~:kN=\E[6~' # special xterm hardstatus: use the window title. termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007' #terminfo xterm 'vb=\E[?5h$<200/>\E[?5l' termcapinfo xterm 'vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l' # emulate part of the 'K' charset termcapinfo xterm 'XC=K%,%\E(B,[\304,\\\\\326,]\334,{\344,|\366,}\374,~\337' # xterm-52 tweaks: # - uses background color for delete operations termcapinfo xterm* be ################ # # wyse terminals # #wyse-75-42 must have flow control (xo = "terminal uses xon/xoff") #essential to have it here, as this is a slow terminal. termcapinfo wy75-42 xo:hs@ # New termcap sequences for cursor application mode. termcapinfo wy* CS=\E[?1h:CE=\E[?1l:vi=\E[?25l:ve=\E[?25h:VR=\E[?5h:VN=\E[?5l:cb=\E[1K:CD=\E[1J ################ # # other terminals # # make hp700 termcap/info better termcapinfo hp700 'Z0=\E[?3h:Z1=\E[?3l:hs:ts=\E[62"p\E[0$~\E[2$~\E[1$}:fs=\E[0}\E[61"p:ds=\E[62"p\E[1$~\E[61"p:ic@' # Extend the vt100 desciption by some sequences. termcap vt100* ms:AL=\E[%dL:DL=\E[%dM:UP=\E[%dA:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC terminfo vt100* ms:AL=\E[%p1%dL:DL=\E[%p1%dM:UP=\E[%p1%dA:DO=\E[%p1%dB:LE=\E[%p1%dD:RI=\E[%p1%dC termcapinfo linux C8 # old rxvt versions also need this # termcapinfo rxvt C8 ################ # # keybindings # #remove some stupid / dangerous key bindings bind k bind ^k bind . bind ^\ bind \\ bind ^h bind h #make them better bind 'K' kill bind 'I' login on bind 'O' login off bind '}' history # Yet another hack: # Prepend/append register [/] to the paste if ^a^] is pressed. # This lets me have autoindent mode in vi. register [ "\033:se noai\015a" register ] "\033:se ai\015a" bind ^] paste [.] ################ # # default windows # # screen -t local 0 # screen -t mail 1 mutt # screen -t 40 2 rlogin server # caption always "%3n %t%? @%u%?%? [%h]%?%=%c" # hardstatus alwaysignore # hardstatus alwayslastline "%Lw" # bind = resize = # bind + resize +1 # bind - resize -1 # bind _ resize max # # defnonblock 1 # blankerprg rain -d 100 # idle 30 blanker screen-4.3.1/etc/mkinstalldirs0000755000175000017500000000115312326531270015260 0ustar amadeamade#!/bin/sh # Make directory hierarchy. # Written by Noah Friedman # Public domain. defaultIFS=' ' IFS="${IFS-${defaultIFS}}" errstatus=0 for file in ${1+"$@"} ; do oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${file} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' for d in ${1+"$@"} ; do pathcomp="${pathcomp}${d}" if test ! -d "${pathcomp}"; then echo "mkdir $pathcomp" 1>&2 mkdir "${pathcomp}" || errstatus=$? fi pathcomp="${pathcomp}/" done done exit $errstatus # eof screen-4.3.1/etc/completer.zsh0000644000175000017500000000725112544062657015211 0ustar amadeamade#compdef screen #Generated by # help2simple.pl -c screen -p -f # simple2long.xsl # args.xsl # For details see: # http://www.geocities.com/f_rosencrantz/xml_completion.htm local context state line typeset -A opt_args _arguments \ "-a[Force all capabilities into each window's termcap.]" \ '-A:Adapt all windows to the new display width & height.' \ "-c:Read configuration file instead of '.screenrc'.:_files -/" \ '-d:Detach the elsewhere running screen (with -r: reattach here).:->sessionname' \ '-dmS:Start as daemon: Screen session in detached mode.' \ '-D:Detach and logout remote (with -r: reattach here).' \ '-e:Change command characters.' \ '-f-:Flow control on, -fn = off, -fa = auto.:((n\:Flow\ conrol\ off a\:Flow\ conrol\ auto))' \ '-h:Set the size of the scrollback history buffer.' \ '-i[Interrupt output sooner when flow control is on.]' \ '-l[Login mode on (update /var/run/utmp), -ln = off.]' \ '-list[Do nothing, just list our SockDir.]' \ '-ls[Do nothing, just list our SockDir.]' \ "-L[Terminal's last character can be safely updated.]" \ '-m[ignore $STY variable, do create a new screen session.]' \ '-O[Choose optimal output rather than exact vt100 emulation.]' \ '-p:Preselect the named window if it exists.' \ '-q[Quiet startup. Exits with non-zero return code if unsuccessful.]' \ '-r[Reattach to a detached screen process.]:Handling Tag sessionname:->sessionname' \ '-R[Reattach if possible, otherwise start a new session.]' \ '-s:Shell to execute rather than $SHELL.' \ '-S:Name this session .sockname instead of ...' \ "-t:Set title. (window's name)." \ '-T:Use term as $TERM for windows, rather than "screen".' \ '-U[Tell screen to use UTF-8 encoding.]' \ '-v[Print "Screen version 3.09.11beta (FAU) 11-Oct-01".]' \ '-wipe[Do nothing, just clean up SockDir.]' \ '-x[Attach to a not detached screen. (Multi display mode).]' \ '-X[Execute as a screen command in the specified session.]:Handling Tag screencmd:( acladd addacl aclchg acldel aclgrp aclumask activity allpartial at attrcolor autodetach autonuke bce bell_msg bind bindkey break breaktype bufferfile c1 caption charset chdir clear colon command compacthist console copy copy_reg crlf debug defc1 defautonuke defbce defbreaktype defcharset defescape defflow defgr defhstatus defkanji deflogin defmode defmonitor defobuflimit defscrollback defshell defsilence defslowpaste defutf8 defwrap defwritelock defzombie detach dinfo displays digraph dumptermcap echo escape exec fit flow focus gr hardcopy hardcopy_append hardcopydir hardstatus height help history hstatus info ins_reg kill lastmsg license lockscreen log logfile login logtstamp mapdefault mapnotnext maptimeout markkeys meta monitor msgminwait msgwait multiuser nethack next nonblock number obu! ! flimit only other partial password paste pastefont pow_break pow_detach pow_detach_msg prev printcmd process quit readbuf readreg redisplay register remove removebuf reset resize screen scrollback select sessionname setenv shell shelltitle silence silencewait sleep slowpaste sorendition split startup_message stuff su term termcap terminfo termcapinfo time title unsetenv utf8 vbell vbell_msg vbellwait verbose version wall width windows wrap writebuf writelock xoff xon zombie defzombie)' case $state in "sessionname") # Complete folder names. local screendir screendir=(`screen -ls | grep Socket | sed -n -e 's/\.$//' -e '$p' | awk '{print $NF;}'`) _wanted files expl 'screen process' _path_files -W screendir ;; esac screen-4.3.1/etc/gs-braille.tbl0000644000175000017500000002376712326531270015215 0ustar amadeamade# GS BRAILLE TABLE # # Dec Hex Braille Description # ------------------------------------------------------------------------ 0 0 (--------) NUL 1 1 (--------) SOH 2 2 (--------) STX 3 3 (--------) ETX 4 4 (--------) EOT 5 5 (--------) ENQ 6 6 (--------) ACK 7 7 (--------) BEL 8 8 (--------) BS 9 9 (--------) HT 10 A (--------) LF 11 B (--------) VT 12 C (--------) FF 13 D (--------) CR 14 E (--------) SO 15 F (--------) SI 16 10 (--------) DLE 17 11 (--------) DC1 18 12 (--------) DC2 19 13 (--------) DC3 20 14 (--------) DC4 21 15 (--------) NAK 22 16 (--------) SYN 23 17 (--------) ETB 24 18 (--------) CAN 25 19 (--------) EM 26 1A (--------) SUB 27 1B (--------) ESC 28 1C (--------) FS 29 1D (--------) GS 30 1E (--------) RS 31 1F (--------) US 32 20 (--------) space 33 21 (-23-5---) bang 34 22 (--3--678) unidirectional double quote 35 23 (----5678) # (number or hash) symbol 36 24 (--34567-) $ 37 25 (--34---8) % symbol 38 26 (-23-5-78) & symbol 39 27 (--3-----) apostrophe 40 28 (-23----8) left parenthesis symbol 41 29 (----567-) right parenthesis symbol 42 2A (--34--7-) asterisk 43 2B (-2--5-7-) plus symbol 44 2C (-2------) comma 45 2D (--3--6--) dash, also used as over/under bar. 46 2E (-2--56--) period, decimal point 47 2F (--34--78) / symbol 48 30 (-2-45-78) zero 49 31 (1-----78) one 50 32 (12----78) two 51 33 (1--4--78) three 52 34 (1--45-78) four 53 35 (1---5-78) five 54 36 (12-4--78) six 55 37 (12-45-78) seven 56 38 (12--5-78) eight 57 39 (-2-4--78) nine 58 3A (-2--5---) colon 59 3B (-23-----) semicolon 60 3C (1234567-) open angle bracket 61 3D (-2--5-78) equals symbol 62 3E (123456-8) close angle bracket 63 3F (-23--6--) question mark 64 40 (--345-78) @ sign 65 41 (1-----7-) A 66 42 (12----7-) B 67 43 (1--4--7-) C 68 44 (1--45-7-) D 69 45 (1---5-7-) E 70 46 (12-4--7-) F 71 47 (12-45-7-) G 72 48 (12--5-7-) H 73 49 (-2-4--7-) I 74 4A (-2-45-7-) J 75 4B (1-3---7-) K 76 4C (123---7-) L 77 4D (1-34--7-) M 78 4E (1-345-7-) N 79 4F (1-3-5-7-) O 80 50 (1234--7-) P 81 51 (12345-7-) Q 82 52 (123-5-7-) R 83 53 (-234--7-) S 84 54 (-2345-7-) T 85 55 (1-3--67-) U 86 56 (123--67-) V 87 57 (-2-4567-) W 88 58 (1-34-67-) X 89 59 (1-34567-) Y 90 5A (1-3-567-) Z 91 5B (-23--678) [ symbol 92 5C (1----678) \ symbol 93 5D (--3-5678) ] symbol 94 5E (--345-7-) ^ 95 5F (-2---6-8) _ 96 60 (--3----8) opening single quote 97 61 (1-------) a 98 62 (12------) b 99 63 (1--4----) c 100 64 (1--45---) d 101 65 (1---5---) e 102 66 (12-4----) f 103 67 (12-45---) g 104 68 (12--5---) h 105 69 (-2-4----) i 106 6A (-2-45---) j 107 6B (1-3-----) k 108 6C (123-----) l 109 6D (1-34----) m 110 6E (1-345---) n 111 6F (1-3-5---) o 112 70 (1234----) p 113 71 (12345---) q 114 72 (123-5---) r 115 73 (-234----) s 116 74 (-2345---) t 117 75 (1-3--6--) u 118 76 (123--6--) v 119 77 (-2-456--) w 120 78 (1-34-6--) x 121 79 (1-3456--) y 122 7A (1-3-56--) z 123 7B (123-5678) { symbol 124 7C (--34-678) | 125 7D (-2345678) } symbol 126 7E (--34-67-) ~ 127 7F (1--4-678) del, nabla sign 128 80 (--3-5-7-) negative power indicator 129 81 (--34-67-) ~ 130 82 (--3---78) opening double quote 131 83 (--34----) complex fraction line indicator 132 84 (--3-5-78) left superscript 133 85 (--345678) start extended math mode 134 86 (-23---7-) end of line in 2-D array 135 87 (-23--67-) right arrow sign 136 88 (-23-567-) proportional to sign 137 89 (-23---78) ` (grave accent) 138 8A (-234-678) integral sign 139 8B (-23-5678) identically equals sign 140 8C (--3-5--8) < (less) symbol 141 8D (-2---67-) > (greater) symbol 142 8E (123--678) end extended math mode. 143 8F (12345678) infinity sign 144 90 (1--4-6--) overscript indicator 145 91 (1---56--) slashed symbol or NOT indicator 146 92 (1--456--) function indicator 147 93 (---45-7-) bold symbol indicator 148 94 (---4-67-) italic symbol indicator 149 95 (---4567-) special (text default=underlined) symbol indicator 150 96 (------78) minus sign 151 97 (---4--78) gothic font symbol indicator 152 98 (----5-78) divide by sign 153 99 (---45-78) special font 1 symbol indicator 154 9A (-----678) closing double quote 155 9B (---4-678) special font 2 symbol indicator 156 9C (---45678) special font 3 symbol indicator 157 9D (-2----78) times cross sign 158 9E (-2---678) left subscript 159 9F (--3---7-) end of element in 2-D array 160 A0 (-2-4-6--) radical indicator 161 A1 (-----67-) closing single quote 162 A2 (----5---) In 8 dot code in shapes and as a soft hyphen. 163 A3 (---45---) To be used for foreign indicators and/or phonetic indicators. 164 A4 (-----6--) 04 never appears in 8 dot code except shapes. 165 A5 (---4-6--) 05 never appears in 8 dot code except shapes. 166 A6 (----56--) grade 1 indicator in both codes. 167 A7 (---456--) Converts upper cell to cell + dot-67, other root to root + dot-78. 168 A8 (-------8) Under user control can indicate hyperlinks or font enhancements or... 169 A9 (---4---8) start shape beginning with 01 and ending at first root cell 170 AA (----5--8) start shape beginning with 02 171 AB (---45--8) start shape beginning with 03 172 AC (-----6-8) start shape beginning with 04 173 AD (---4-6-8) start shape beginning with 05 174 AE (----56-8) start shape beginning with 06 175 AF (---456-8) start shape beginning with 07 176 B0 (1--4---8) Copyright sign 177 B1 (1--4-6-8) partial differential sign 178 B2 (-2---6--) subscript indicator 179 B3 (1------8) alpha 180 B4 (12-----8) beta 181 B5 (12-45--8) gamma 182 B6 (1--45--8) delta 183 B7 (1---5--8) epsilon 184 B8 (1-3-56-8) zeta 185 B9 (1---56-8) eta 186 BA (1--456-8) theta 187 BB (-2-4---8) iota 188 BC (1-3----8) kappa 189 BD (123----8) lambda 190 BE (1-34---8) mu 191 BF (1-345--8) nu 192 C0 (1-34-6-8) xi 193 C1 (1-3-5--8) omichron 194 C2 (1234---8) pi 195 C3 (123-5--8) rho 196 C4 (-234---8) sigma 197 C5 (-2345--8) tau 198 C6 (1-3--6-8) upsilon 199 C7 (12-4---8) phi 200 C8 (1234-6-8) chi 201 C9 (1-3456-8) psi 202 CA (-2-456-8) omega 203 CB (1----67-) cap Alpha 204 CC (12---67-) cap Beta 205 CD (12-4567-) cap Gamma 206 CE (1--4567-) cap Delta 207 CF (1---567-) cap Epsilon 208 D0 (1-3-5678) cap zeta 209 D1 (1---5678) cap Eta 210 D2 (1--45678) cap Theta 211 D3 (-2-4-67-) cap Iota 212 D4 (1-3---78) cap kappa 213 D5 (123---78) cap lambda 214 D6 (1-34--78) cap mu 215 D7 (1-345-78) cap nu 216 D8 (1-34-678) cap xi 217 D9 (1-3-5-78) cap omichron 218 DA (1234--78) cap pi 219 DB (123-5-78) cap rho 220 DC (-234--78) cap sigma 221 DD (-2345-78) cap tau 222 DE (1-3--678) cap upsilon 223 DF (12-4-67-) cap Phi 224 E0 (1234-678) cap chi 225 E1 (1-345678) cap psi 226 E2 (-2-45678) cap omega 227 E3 (-2--5--8) times dot sign 228 E4 (-2-45--8) small circle sign 229 E5 (-2-4-6-8) radical sign, not operator 230 E6 (12---6--) open braille bracket 231 E7 (12-4-6--) horizontal combination symbol indicator 232 E8 (12--56--) vertical stack symbol indicator 233 E9 (12-456--) superimposed combination symbol indicator 234 EA (12--56-8) absolute value bar sign 235 EB (--3-5---) superscript indicator 236 EC (--345---) close braille bracket 237 ED (--34-6--) underscript indicator 238 EE (--3-56--) start math word indicator 239 EF (--3456--) Number indicator (6 dot code) 240 F0 (---4----) Accent mark 241 F1 (--3--6-8) ellipses sign 242 F2 (--34-6-8) dagger, transpose sign 243 F3 (--3-56-8) left arrow sign 244 F4 (--3456-8) UK pound 245 F5 (-234-6--) two dimensional array indicator 246 F6 (1----6--) simple fraction line indicator 247 F7 (-23-56--) contraction indicator. 248 F8 (-23456--) close fraction indicator 249 F9 (-234-6-8) end of two dimensional array 250 FA (-23-56-8) approximately equals sign, single tilde over single bar. 251 FB (1234-6--) Large symbol indicator. 252 FC (123-56--) open fraction indicator 253 FD (123456--) quantity indicator 254 FE (------7-) prime mark 255 FF (---4--7-) script font symbol indicator screen-4.3.1/etc/newsyntax380000755000175000017500000000373612326531270014624 0ustar amadeamade#! /bin/sh # # newsyntax38 -- update a screenrc file from 3.3 to 3.8 syntax # # Please bring your scripts up to syntax level 3.3 before running this script. # Please check all comments after running this script and watch out # for funny passages. # # * aka and shellaka are replaced by title and shelltitle. # # * Pairs of termcap and terminfo commands are folded into a single # termcapinfo command where possible. # # * trailing blanks are zapped. Unintentionally. # # 12.10.95, jnweiger, use at your own risk. # if [ $# != 1 ]; then echo "usage $0 screenrcfile" echo "" echo "The named file will be updated in place to the syntax of screen 3.8" echo "A backup copy will be written to .bak" exit 1; fi #Ultrix 4.2 /bin/sh does not handle "read a < $1" #Dean Gaudet exec < $1 read a if [ "$a" = "#3.8" ]; then echo "$1 already updated" exit 0 fi rm -f $1.old $1.dups cp $1 $1.old echo "#3.8" > $1 echo "# Do not remove the above line. This screen rc file was updated" >> $1 echo "# by the newsyntax script." >> $1 # termcap and terminfo lines can only be folded when there is no parameter # expansion in the codes. Parameters are denoted differently in # termcap and termcap syntax. Everything else is identical, I assume. # Thus codes not containing '%' can be savely folded. sed < $1.old > $1.dups \ -e 's/^\([ #]*\)aka/\1title/' \ -e 's/^\([ #]*\)shellaka/\1shelltitle/' \ -e 's/^\([ #]*\)termcap[ ][ ]*\([^%]*$\)/\1termcapinfo \2/' \ -e 's/^\([ #]*\)terminfo[ ][ ]*\([^%]*$\)/\1termcapinfo \2/' \ -e 's/\\/\\\\/g' # Oh, my bourne shell seems to gobble backslashes while reading. # Thus the sed above duplicates them in advance. # Hope this is not just another silly bash featureism. # It still zaps trailing blanks. I do not know why. But that is nice. exec < $1.dups while read a ; do if [ "$a" = "$b" ]; then case "$a" in *termcapinfo*) continue ;; esac fi echo "$a" >> $1 b="$a" done rm -f $1.dups screen-4.3.1/etc/newsyntax0000755000175000017500000000360312326531270014442 0ustar amadeamade#!/bin/sh # # newsyntax -- update a screenrc file from 3.2 to 3.3 syntax # # please check all comments after running this script and watch out # for funny passages. # if [ $# != 1 ]; then echo "usage $0 screenrcfile" exit 1; fi #Ultrix 4.2 /bin/sh does not handle "read a < $1" #Dean Gaudet exec < $1 read a if [ ."$a" = '.#3.3' ]; then echo "$1 already updated" exit 0 fi cp $1 $1.old echo "#3.3" > $1 echo "# Do not remove the above line. This screen rc file was updated" >> $1 echo "# by the newsyntax script." >> $1 sed < $1.old >> $1 \ -e 's/\([ #]\)flow/\1defflow/g' \ -e 's/^flow/defflow/g' \ -e 's/\([ #]\)set[ ]*defflow/\1flow/g' \ -e 's/^set[ ]*defflow/flow/g' \ -e 's/\([ #]\)mode/\1defmode/g' \ -e 's/^mode/defmode/g' \ -e 's/\([ #]\)set[ ]*defmode/\1defmode/g' \ -e 's/^set[ ]*defmode/defmode/g' \ -e 's/\([ #]\)monitor/\1defmonitor/g' \ -e 's/^monitor/defmonitor/g' \ -e 's/\([ #]\)set[ ]*defmonitor/\1monitor/g' \ -e 's/^set[ ]*defmonitor/monitor/g' \ -e 's/\([ #]\)login/\1deflogin/g' \ -e 's/^login/deflogin/g' \ -e 's/\([ #]\)set[ ]*deflogin/\1login/g' \ -e 's/^set[ ]*deflogin/login/g' \ -e 's/\([ #]\)wrap/\1defwrap/g' \ -e 's/^wrap/defwrap/g' \ -e 's/\([ #]\)set[ ]*defwrap/\1wrap/g' \ -e 's/^set[ ]*defwrap/wrap/g' \ -e 's/\([ #]\)scrollback/\1defscrollback/g' \ -e 's/^scrollback/defscrollback/g' \ -e 's/\([ #]\)set[ ]*defscrollback/\1scrollback/g' \ -e 's/^set[ ]*defscrollback/scrollback/g' \ -e 's/\([ #]\)refresh/\1allPARtial/g' \ -e 's/^refresh/allPARtial/g' \ -e 's/\([ #]\)redraw/\1allPARtial/g' \ -e 's/^redraw/allPARtial/g' \ -e 's/\([ #]\)set[ ]*allPARtial/\1PARtial/g' \ -e 's/^set[ ]*allPARtial/PARtial/g' \ -e 's/\([ #]\)visualbell/\1vbell/g' \ -e 's/^visualbell/vbell/g' \ -e 's/PARtial\([ ]*\)on/partial\1off/g' \ -e 's/PARtial\([ ]*\)off/partial\1on/g' \ -e 's/allPARtial/refresh/g' \ -e 's/^set[ ]//g' screen-4.3.1/etc/us-braille.tbl0000644000175000017500000002264312326531270015223 0ustar amadeamade# U.S. BRAILLE TABLE # # Dec Hex Braille Description # ------------------------------------------------------------------------ 0 00 (---4--78) NUL 1 01 (1-----78) SOH 2 02 (12----78) STX 3 03 (1--4--78) ETX 4 04 (1--45-78) EOT 5 05 (1---5-78) ENQ 6 06 (12-4--78) ACK 7 07 (12-45-78) BEL 8 08 (12--5-78) BS 9 09 (-2-4--78) HT 10 OA (-2-45-78) LF 11 0B (1-3---78) VT 12 OC (123---78) FF 13 0D (1-34--78) CR 14 0E (1-345-78) SO 15 OF (1-3-5-78) SI 16 10 (1234--78) DLE 17 11 (12345-78) DC1 18 12 (123-5-78) DC2 19 13 (-234--78) DC3 20 14 (-2345-78) DC4 21 15 (1-3--678) NAK 22 16 (123--678) SYN 23 17 (-2-45678) ETB 24 18 (1-34-678) CAN 25 19 (1-345678) EM 26 1A (1-3-5678) SUB 27 lB (-2-4-678) ESC 28 lC (12--5678) FS 29 1D (12-45678) GS 30 lE (---45-78) RS 31 1F (---45678) US 32 20 (--------) Space 33 21 (-234-6--) ! 34 22 (----5---) " 35 23 (--3456--) # 36 24 (12-4-6--) $ 37 25 (1--4-6--) % 38 26 (1234-6--) & 39 27 (--3-----) ' 40 28 (123-56--) ( 41 29 (-23456--) ) 42 2A (1----6--) * 43 2B (--34-6--) + 44 2C (-----6--) , 45 2D (--3--6--) - 46 2E (---4-6--) . 47 2F (--34----) / 48 30 (--3-56--) 0 49 31 (-2------) 1 50 32 (-23-----) 2 51 33 (-2--5---) 3 52 34 (-2--56--) 4 53 35 (-2---6--) 5 54 36 (-23-5---) 6 55 37 (-23-56--) 7 56 38 (-23--6--) 8 57 39 (--3-5---) 9 58 3A (1---56--) : 59 3B (----56--) ; 60 3C (12---6--) < 61 3D (123456--) - 62 3E (--345---) > 63 3F (1--456--) ? 64 40 (---4--7-) @ 65 41 (1-----7-) A 66 42 (12----7-) B 67 43 (1--4--7-) C 68 44 (1--45-7-) D 69 45 (1---5-7-) E 70 46 (12-4--7-) F 71 47 (12-45-7-) G 72 48 (12--5-7-) H 73 49 (-2-4--7-) I 74 4A (-2-45-7-) J 75 4B (1-3---7-) K 76 4C (123---7-) L 77 4D (1-34--7-) M 78 4E (1-345-7-) N 79 4F (1-3-5-7-) O 80 50 (1234--7-) P 81 51 (12345-7-) Q 82 52 (123-5-7-) R 83 53 (-234--7-) S 84 54 (-2345-7-) T 85 55 (1-3--67-) U 86 56 (123--67-) V 87 57 (-2-4567-) W 88 58 (1-34-67-) X 89 59 (1-34567-) Y 90 5A (1-3-567-) Z 91 5B (-2-4-67-) [ 92 5C (12--567-) \ 93 5D (12-4567-) ] 94 5E (---45-7-) ^ 95 5F (---4567-) _ 96 60 (---4----) ' 97 61 (1-------) a 98 62 (12------) b 99 63 (1--4----) c 100 64 (1--45---) d 101 65 (1---5---) e 102 66 (12-4----) f 103 67 (12-45---) g 104 68 (12--5---) h 105 69 (-2-4----) i 106 6A (-2-45---) j 107 6B (1-3-----) k 108 6C (123-----) l 109 6D (1-34----) m 110 6E (1-345---) n 111 6F (1-3-5---) o 112 70 (1234----) p 113 71 (12345---) q 114 72 (123-5---) r 115 73 (-234----) s 116 74 (-2345---) t 117 75 (1-3--6--) u 118 76 (123--6--) v 119 77 (-2-456--) w 120 78 (1-34-6--) x 121 79 (1-3456--) y 122 7A (1-3-56--) z 123 7B (-2-4-6--) { 124 7C (12--56--) | 125 7D (12-456--) } 126 7E (---45---) ~ 127 7F (---456--) DEL 128 80 (---4---8) C Cedilla (upper case) 129 81 (1------8) u Umlaut (lower case) 130 82 (12-----8) e Acute (lower case) 131 83 (1--4---8) a Circumflex 132 84 (1--45--8) a Umlaut (lower case) 133 85 (1---5--8) a Grave 134 86 (12-4---8) a Ring (lower case) 135 87 (12-45--8) c Cedilla (lower case) 136 88 (12--5--8) e Circumflex 137 89 (-2-4---8) e Umlaut (lower case) 138 8A (--2-45-8) e Grave 139 8B (1-3----8) i Umlaut (lower case) 140 8C (123----8) i Circumflex 141 8D (1-34---8) I Grave 142 8E (1-345--8) A Umlaut (upper case) 143 8F (1-3-5--8) A Ring (upper case) 144 90 (1234---8) E Acute (upper case) 145 91 (12345--8) ae Digraph (lower case) 146 92 (123-5--8) AE Digraph (upper case) 147 93 (-234---8) o Circumflex 148 94 (-2345--8) o Umlaut (lower case) 149 95 (1-3--6-8) o Grave 150 96 (123--6-8) u Circumflex 151 97 (-2-456-8) u Grave 152 98 (1-34-6-8) y Umlaut 153 99 (1-3456-8) O Umlaut (upper case) 154 9A (1-3-56-8) U Umlaut (upper case) 155 9B (-2-4-6-8) Cent 156 9C (12--56-8) Pound/Sterling 157 9D (12-456-8) Yen 158 9E (---45--8) Peseta 159 9F (---456-8) Franc 160 A0 (------7-) a Acute (lower case) 161 Al (-234-67-) i Acute (lower case) 162 A2 (----5-7-) o Acute (lower case) 163 A3 (--34567-) u Acute (lower case) 164 A4 (12-4-67-) n Tilde (lower case) 165 A5 (1--4-67-) N Tilde (upper case) 166 A6 (1234-67-) Feminine Spanish Ordinal 167 A7 (--3---7-) Masculine Spanish Ordinal 168 A8 (123-567-) Inverted Question Mark 169 A9 (-234567-) Left square corner 170 AA (1----67-) Right square corner 171 AB (--34-67-) 1/2 172 AC (-----67-) 1/4 173 AD (--3--67-) Inverted Exclamation Mark 174 AE (---4-67-) Left Double Guillemet 175 AF (--34--7-) Right Double Guillemet 176 B0 (--3-567-) Box [Shade 1] 177 B1 (-2----7-) Box [Shade 2] 178 B2 (-23---7-) Box [Shade 3] 179 B3 (-2--5-7-) Box [top bottom] 180 B4 (-2--567-) Box [left top bottom] 181 B5 (-2---67-) Box [LEFT top bottom] 182 B6 (-23-5-7-) Box [left TOP BOTTOM] 183 B7 (-23-567-) Box [left BOTTOM] 184 B8 (-23--67-) Box [LEFT bottom] 185 B9 (--3-5-7-) Box [LEFT TOP BOTTOM] 186 BA (1---567-) Box [TOP BOTTOM] 187 BB (----567-) Box [LEFT BOTTOM] 188 BC (12---67-) Box [LEFT TOP] 189 BD (1234567-) Box [left TOP] 190 BE (--345-7-) Box [LEFT top] 191 BF (1--4567-) Box [left bottom] 192 CO (------78) Box [top right] 193 C1 (-234-678) Box [left top right] 194 C2 (----5-78) Box [left right bottom] 195 C3 (--345678) Box [top right bottom] 196 C4 (12-4-678) Box [left right] 197 C5 (1--4-678) Box [left top right bottom] 198 C6 (1234-678) Box [top RIGHT bottom] 199 C7 (--3---78) Box [TOP right BOTTOM] 200 C8 (123-5678) Box [TOP RIGHT] 201 C9 (-2345678) Box [RIGHT BOTTOM] 202 CA (1----678) Box [LEFT TOP RIGHT] 203 CB (--34-678) Box [LEFT RIGHT BOTTOM] 204 CC (-----678) Box [TOP RIGHT BOTTOM] 205 CD (--3--678) Box [LEFT RIGHT] 206 CE (---4-678) Box [LEFT TOP RIGHT BOTTOM] 207 CF (--34--78) Box [LEFT top RIGHT] 208 DO (--3-5678) Box [left TOP right] 209 D1 (-2----78) Box [LEFT RIGHT bottom] 210 D2 (-23---78) Box [left right BOTTOM] 211 D3 (-2--5-78) Box [TOP right] 212 D4 (-2--5678) Box [top RIGHT] 213 D5 (-2---678) Box [RIGHT bottom] 214 D6 (-23-5-78) Box [right BOTTOM] 215 D7 (-23-5678) Box [left TOP right BOTTOM] 216 D8 (-23--678) Box [LEFT top RIGHT bottom] 217 D9 (--3-5-78) Box [left top] 218 DA (1---5678) Box [right bottom] 219 DB (----5678) Box [Shade 4] 220 DC (12---678) Box [box bottom] 221 DD (12345678) Box [box right] 222 DE (--345-78) Box [box left] 223 DF (1--45678) Box [box top] 224 E0 (-------8) Alpha (lower case) 225 E1 (-234-6-8) Beta (lower case) 226 E2 (----5--8) Gamma (upper case) 227 E3 (--3456-8) Pi (lower case) 228 E4 (12-4-6-8) Sigma (upper case) 229 E5 (1--4-6-8) Sigma (lower case) 230 E6 (1234-6-8) Mu (lower case) 231 E7 (--3----8) Tau (lower case) 232 E8 (123-56-8) Phi (upper case) 233 E9 (-23456-8) Theta (lower case) 234 EA (1----6-8) Omega (upper case) 235 EB (--34-6-8) Delta (lower case) 236 EC (-----6-8) infinity 237 ED (--3--6-8) Phi (lower case) 238 EE (---4-6-8) Epsilon (lower case) 239 EF (--34---8) Intersection 240 F0 (--3-56-8) Equivalent (Member) 241 F1 (-2-----8) Plus or minus 242 F2 (-23----8) Greater than or equal 243 F3 (-2--5--8) Less than or equal 244 F4 (-2--56-8) Integral [top] 245 F5 (-2---6-8) Integral [bottom] 246 F6 (-23-5--8) Division 247 F7 (-23-56-8) Approximately equal 248 F8 (-23--6-8) Small circle 249 F9 (--3-5--8) Bullet 250 FA (1---56-8) Small bullet 251 FB (----56-8) Bent Radical 252 FC (12---6-8) Power of n 253 FD (123456-8) Power of 2 254 FE (--345--8) Large square bullet 255 FF (1--456-8) blank (hard space) screen-4.3.1/logfile.c0000644000175000017500000001635312544062660013500 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 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * **************************************************************** */ #include /* dev_t, ino_t, off_t, ... */ #include /* struct stat */ #include /* O_WRONLY for logfile_reopen */ #include "config.h" #include "screen.h" #include "extern.h" #include "logfile.h" static void changed_logfile __P((struct logfile *)); static struct logfile *lookup_logfile __P((char *)); static int stolen_logfile __P((struct logfile *)); static struct logfile *logroot = NULL; static void changed_logfile(l) struct logfile *l; { struct stat o, *s = l->st; if (fstat(fileno(l->fp), &o) < 0) /* get trouble later */ return; if (o.st_size > s->st_size) /* aha, appended text */ { s->st_size = o.st_size; /* this should have changed */ s->st_mtime = o.st_mtime; /* only size and mtime */ } } /* * Requires fd to be open and need_fd to be closed. * If possible, need_fd will be open afterwards and refer to * the object originally reffered by fd. fd will be closed then. * Works just like ``fcntl(fd, DUPFD, need_fd); close(fd);'' * * need_fd is returned on success, else -1 is returned. */ int lf_move_fd(fd, need_fd) int need_fd, fd; { int r = -1; if (fd == need_fd) return fd; if (fd >=0 && fd < need_fd) r = lf_move_fd(dup(fd), need_fd); close(fd); return r; } static int logfile_reopen(name, wantfd, l) char *name; int wantfd; struct logfile *l; { int got_fd; close(wantfd); if (((got_fd = open(name, O_WRONLY | O_CREAT | O_APPEND, 0666)) < 0) || lf_move_fd(got_fd, wantfd) < 0) { logfclose(l); debug1("logfile_reopen: failed for %s\n", name); return -1; } changed_logfile(l); debug2("logfile_reopen: %d = %s\n", wantfd, name); return 0; } static int (* lf_reopen_fn)() = logfile_reopen; /* * Whenever logfwrite discoveres that it is required to close and * reopen the logfile, the function registered here is called. * If you do not register anything here, the above logfile_reopen() * will be used instead. * Your function should perform the same steps as logfile_reopen(): * a) close the original filedescriptor without flushing any output * b) open a new logfile for future output on the same filedescriptor number. * c) zero out st_dev, st_ino to tell the stolen_logfile() indcator to * reinitialise itself. * d) return 0 on success. */ void logreopen_register(fn) int (*fn) __P((char *, int, struct logfile *)); { lf_reopen_fn = fn ? fn : logfile_reopen; } /* * If the logfile has been removed, truncated, unlinked or the like, * return nonzero. * The l->st structure initialised by logfopen is updated * on every call. */ static int stolen_logfile(l) struct logfile *l; { struct stat o, *s = l->st; o = *s; if (fstat(fileno(l->fp), s) < 0) /* remember that stat failed */ s->st_ino = s->st_dev = 0; ASSERT(s == l->st); if (!o.st_dev && !o.st_ino) /* nothing to compare with */ return 0; if ((!s->st_dev && !s->st_ino) || /* stat failed, that's new! */ !s->st_nlink || /* red alert: file unlinked */ (s->st_size < o.st_size) || /* file truncated */ (s->st_mtime != o.st_mtime) || /* file modified */ ((s->st_ctime != o.st_ctime) && /* file changed (moved) */ !(s->st_mtime == s->st_ctime && /* and it was not a change */ o.st_ctime < s->st_ctime))) /* due to delayed nfs write */ { debug1("stolen_logfile: %s stolen!\n", l->name); debug3("st_dev %d, st_ino %d, st_nlink %d\n", (int)s->st_dev, (int)s->st_ino, (int)s->st_nlink); debug2("s->st_size %d, o.st_size %d\n", (int)s->st_size, (int)o.st_size); debug2("s->st_mtime %d, o.st_mtime %d\n", (int)s->st_mtime, (int)o.st_mtime); debug2("s->st_ctime %d, o.st_ctime %d\n", (int)s->st_ctime, (int)o.st_ctime); return -1; } debug1("stolen_logfile: %s o.k.\n", l->name); return 0; } static struct logfile * lookup_logfile(name) char *name; { struct logfile *l; for (l = logroot; l; l = l->next) if (!strcmp(name, l->name)) return l; return NULL; } struct logfile * logfopen(name, fp) char *name; FILE *fp; { struct logfile *l; if (!fp) { if (!(l = lookup_logfile(name))) return NULL; l->opencount++; return l; } if (!(l = (struct logfile *)malloc(sizeof(struct logfile)))) return NULL; if (!(l->st = (struct stat *)malloc(sizeof(struct stat)))) { free((char *)l); return NULL; } if (!(l->name = SaveStr(name))) { free((char *)l->st); free((char *)l); return NULL; } l->fp = fp; l->opencount = 1; l->writecount = 0; l->flushcount = 0; changed_logfile(l); l->next = logroot; logroot = l; return l; } int islogfile(name) char *name; { if (!name) return logroot ? 1 : 0; return lookup_logfile(name) ? 1 : 0; } int logfclose(l) struct logfile *l; { struct logfile **lp; for (lp = &logroot; *lp; lp = &(*lp)->next) if (*lp == l) break; if (!*lp) return -1; if ((--l->opencount) > 0) return 0; if (l->opencount < 0) abort(); *lp = l->next; fclose(l->fp); free(l->name); free((char *)l); return 0; } /* * XXX * write and flush both *should* check the file's stat, if it disappeared * or changed, re-open it. */ int logfwrite(l, buf, n) struct logfile *l; char *buf; int n; { int r; if (stolen_logfile(l) && lf_reopen_fn(l->name, fileno(l->fp), l)) return -1; r = fwrite(buf, n, 1, l->fp); l->writecount += l->flushcount + 1; l->flushcount = 0; changed_logfile(l); return r; } int logfflush(l) struct logfile *l; { int r = 0; if (!l) for (l = logroot; l; l = l->next) { if (stolen_logfile(l) && lf_reopen_fn(l->name, fileno(l->fp), l)) return -1; r |= fflush(l->fp); l->flushcount++; changed_logfile(l); } else { if (stolen_logfile(l) && lf_reopen_fn(l->name, fileno(l->fp), l)) return -1; r = fflush(l->fp); l->flushcount++; changed_logfile(l); } return r; } screen-4.3.1/NEWS.3.70000644000175000017500000000270212543211734012706 0ustar amadeamade ---------------------------- What's new in screen-3.7 ? ---------------------------- * Color support. Screen understands the following capabilities: AF (setaf) = Set foreground color (ANSI compatible) AB (setab) = Set background color (ANSI compatible) AX = Does understand ANSI set default fg/bg color (\E[39m / \E[49m) The tweaks for the color xterm would be: termcap xterm 'AF=\E[3%dm:AB=\E[4%dm' terminfo xterm 'AF=\E[3%p1%dm:AB=\E[4%p1%dm' * New 'digraph' command (bound to ^A^V) ^A^Va" or ^A^V0344 input an a-umlaut * activity/bell message strings can now include the window title: %t - title %n - number (a single % still works) * 'defhstatus' command to give everey window a default hardstatus line. ^E is used as a string escape instead of % (see above). Try 'defhstatus "Screen: window ^E (^Et)"' * Input parser changed to understand '^' (see ^E above). Note that the linux color xterm has a stupid bug: the characters get the color of the cursor, therefore if you change color and move the cursor around all the characters will get the new color... Here is a patch: pub/utilities/screen/color_xterm_patch Btw.: rxvt works fine. * 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.3.1/NEWS.3.60000644000175000017500000000327412543211734012712 0ustar amadeamade ---------------------------- What's new in screen-3.6 ? ---------------------------- * Input translation! This makes the vt100 emulation complete. As an addition it is now possible to bind any command to any (function-) key. See the man page for more details (bindkey command). * Status line support. Each window can have a different status line. Use the ANSI APC string to set the status line, i.e.: _\ (For convenience the xterm sequence is also accepted.) You may want to add termcap * '' ':hs:ts=\E_:fs=\E\\:ds=\E_\E\\:' terminfo * '' ':hs:ts=\E_:fs=\E\\:ds=\E_\E\\:' to your ~/.screenrc to make screen advertise the hardstatus support. * Zombie feature added. Windows now may generate a message (with a timestamp) if they die and stay around until the user presses a key. * New paste syntax: Paste can now concatenate registers and paste either on screen or in anouther register. This makes the old "ins_reg", "copy_reg" commands obsolete. * More architecures supported. Screen now runs on AIX3.2.5, Solaris, NeXT and some other exotic platforms. * Kanji support added. Screen understands JIS, EUC and SJIS coding. This is an experimental feature. * GR charset switching (ISO 2022) implemented. Can be enabled with the "gr" command. * C1 sequences implemented (see the "c1" command). * Tek support from Xiaoguang Zhang. Apply tek.patch if you want to make screen pass tek sequences. * List of new commands: bindkey, c1, command, defc1, defgr, defkanji, gr, kanji, mapdefault, mapnotnext, maptimeout, pastefont, printcmd, readreg, stuff, zombie * Lots of other bugs fixed. screen-4.3.1/encoding.c0000644000175000017500000012616712544062657013660 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 * http://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; { /* sorted list of non-overlapping intervals of East Asian Ambiguous * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */ static const struct interval ambiguous[] = { { 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 }, { 0x00AA, 0x00AA }, { 0x00AE, 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 }, { 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 }, { 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 }, { 0x2614, 0x2615 }, { 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 }, { 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 }, { 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F }, { 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0xE000, 0xF8FF }, { 0xFFFD, 0xFFFD }, { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD } }; return ((c >= 0x1100 && (c <= 0x115f || /* Hangul Jamo init. consonants */ c == 0x2329 || c == 0x232a || (c >= 0x2e80 && c <= 0xa4cf && c != 0x303f) || /* CJK ... Yi */ (c >= 0xac00 && c <= 0xd7a3) || /* Hangul Syllables */ (c >= 0xf900 && c <= 0xfaff) || /* CJK Compatibility Ideographs */ (c >= 0xfe30 && c <= 0xfe6f) || /* CJK Compatibility Forms */ (c >= 0xff00 && c <= 0xff60) || /* Fullwidth Forms */ (c >= 0xffe0 && c <= 0xffe6) || (c >= 0x20000 && c <= 0x2fffd) || (c >= 0x30000 && c <= 0x3fffd))) || (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.3.1/search.c0000644000175000017500000002301412544062660013314 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 * http://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 "mark.h" #include "extern.h" #define INPUTLINE (flayer->l_height - 1) extern struct layer *flayer; extern struct win *fore; #ifdef COPY_PASTE int search_ic; /******************************************************************** * VI style Search */ static int matchword __P((char *, int, int, int)); static void searchend __P((char *, int, char *)); static void backsearchend __P((char *, int, char *)); void Search(dir) int dir; { struct markdata *markdata; if (dir == 0) { markdata = (struct markdata *)flayer->l_data; if (markdata->isdir > 0) searchend(0, 0, NULL); else if (markdata->isdir < 0) backsearchend(0, 0, NULL); else LMsg(0, "No previous pattern"); } else Input((dir > 0 ? "/" : "?"), sizeof(markdata->isstr)-1, INP_COOKED, (dir > 0 ? searchend : backsearchend), NULL, 0); } static void searchend(buf, len, data) char *buf; int len; char *data; /* dummy */ { int x = 0, sx, ex, y; struct markdata *markdata; struct win *p; markdata = (struct markdata *)flayer->l_data; p = markdata->md_window; markdata->isdir = 1; if (len) strcpy(markdata->isstr, buf); sx = markdata->cx + 1; ex = flayer->l_width - 1; for (y = markdata->cy; y < p->w_histheight + flayer->l_height; y++, sx = 0) { if ((x = matchword(markdata->isstr, y, sx, ex)) >= 0) break; } if (y >= p->w_histheight + flayer->l_height) { LGotoPos(flayer, markdata->cx, W2D(markdata->cy)); LMsg(0, "Pattern not found"); } else revto(x, y); } static void backsearchend(buf, len, data) char *buf; int len; char *data; /* dummy */ { int sx, ex, x = -1, y; struct markdata *markdata; markdata = (struct markdata *)flayer->l_data; markdata->isdir = -1; if (len) strcpy(markdata->isstr, buf); ex = markdata->cx - 1; for (y = markdata->cy; y >= 0; y--, ex = flayer->l_width - 1) { sx = 0; while ((sx = matchword(markdata->isstr, y, sx, ex)) >= 0) x = sx++; if (x >= 0) break; } if (y < 0) { LGotoPos(flayer, markdata->cx, W2D(markdata->cy)); LMsg(0, "Pattern not found"); } else revto(x, y); } static int matchword(pattern, y, sx, ex) char *pattern; int y, sx, ex; { unsigned char *ip, *ipe, *cp, *pp; struct mline *ml; /* *sigh* to make WIN work */ fore = ((struct markdata *)flayer->l_data)->md_window; ml = WIN(y); ip = ml->image + sx; ipe = ml->image + flayer->l_width; for (;sx <= ex; sx++) { cp = ip++; pp = (unsigned char *)pattern; for (;;) { if (*cp != *pp) if (!search_ic || ((*cp ^ *pp) & 0xdf) || (*cp | 0x20) < 'a' || (*cp | 0x20) > 'z') break; cp++; pp++; if (*pp == 0) return sx; if (cp == ipe) break; } } return -1; } /******************************************************************** * Emacs style ISearch */ static char *isprompts[] = { "I-search backward: ", "failing I-search backward: ", "I-search: ", "failing I-search: " }; static int is_redo __P((struct markdata *)); static void is_process __P((char *, int, char *)); static int is_bm __P((char *, int, int, int, int)); static int is_bm(str, l, p, end, dir) char *str; int l, p, end, dir; { int tab[256]; int i, q; unsigned char *s, c; int w = flayer->l_width; /* *sigh* to make WIN work */ fore = ((struct markdata *)flayer->l_next->l_data)->md_window; debug2("is_bm: searching for %s len %d\n", str, l); debug3("start at %d end %d dir %d\n", p, end, dir); if (p < 0 || p + l > end) return -1; if (l == 0) return p; if (dir < 0) str += l - 1; for (i = 0; i < 256; i++) tab[i] = l * dir; for (i = 0; i < l - 1; i++, str += dir) { q = *(unsigned char *)str; tab[q] = (l - 1 - i) * dir; if (search_ic && (q | 0x20) >= 'a' && ((q | 0x20) <= 'z')) tab[q ^ 0x20] = (l - 1 - i) * dir; } if (dir > 0) p += l - 1; debug1("first char to match: %c\n", *str); while (p >= 0 && p < end) { q = p; s = (unsigned char *)str; for (i = 0;;) { c = (WIN(q / w))->image[q % w]; if (i == 0) p += tab[(int)(unsigned char) c]; if (c != *s) if (!search_ic || ((c ^ *s) & 0xdf) || (c | 0x20) < 'a' || (c | 0x20) > 'z') break; q -= dir; s -= dir; if (++i == l) return q + (dir > 0 ? 1 : -l); } } return -1; } /*ARGSUSED*/ static void is_process(p, n, data) /* i-search */ char *p; int n; char *data; /* dummy */ { int pos, x, y, dir; struct markdata *markdata; if (n == 0) return; ASSERT(p); markdata = (struct markdata *)flayer->l_next->l_data; pos = markdata->cx + markdata->cy * flayer->l_width; LGotoPos(flayer, markdata->cx, W2D(markdata->cy)); switch (*p) { case '\007': /* CTRL-G */ pos = markdata->isstartpos; /*FALLTHROUGH*/ case '\033': /* ESC */ *p = 0; break; case '\013': /* CTRL-K */ case '\027': /* CTRL-W */ markdata->isistrl = 1; /*FALLTHROUGH*/ case '\b': case '\177': if (markdata->isistrl == 0) return; markdata->isistrl--; pos = is_redo(markdata); *p = '\b'; break; case '\023': /* CTRL-S */ case '\022': /* CTRL-R */ if (markdata->isistrl >= (int)sizeof(markdata->isistr)) return; dir = (*p == '\023') ? 1 : -1; pos += dir; if (markdata->isdir == dir && markdata->isistrl == 0) { strcpy(markdata->isistr, markdata->isstr); markdata->isistrl = markdata->isstrl = strlen(markdata->isstr); break; } markdata->isdir = dir; markdata->isistr[markdata->isistrl++] = *p; break; default: if (*p < ' ' || markdata->isistrl >= (int)sizeof(markdata->isistr) || markdata->isstrl >= (int)sizeof(markdata->isstr) - 1) return; markdata->isstr[markdata->isstrl++] = *p; markdata->isistr[markdata->isistrl++] = *p; markdata->isstr[markdata->isstrl] = 0; debug2("New char: %c - left %d\n", *p, (int)sizeof(markdata->isistr) - markdata->isistrl); } if (*p && *p != '\b') pos = is_bm(markdata->isstr, markdata->isstrl, pos, flayer->l_width * (markdata->md_window->w_histheight + flayer->l_height), markdata->isdir); if (pos >= 0) { x = pos % flayer->l_width; y = pos / flayer->l_width; LAY_CALL_UP ( LayRedisplayLine(INPUTLINE, 0, flayer->l_width - 1, 0); revto(x, y); if (W2D(markdata->cy) == INPUTLINE) revto_line(markdata->cx, markdata->cy, INPUTLINE > 0 ? INPUTLINE - 1 : 1); ); } if (*p) inp_setprompt(isprompts[markdata->isdir + (pos < 0) + 1], markdata->isstrl ? markdata->isstr : ""); flayer->l_x = markdata->cx; flayer->l_y = W2D(markdata->cy); LGotoPos(flayer, flayer->l_x, flayer->l_y); if (!*p) { /* we are about to finish, keep cursor position */ flayer->l_next->l_x = markdata->cx; flayer->l_next->l_y = W2D(markdata->cy); } } static int is_redo(markdata) struct markdata *markdata; { int i, pos, npos, dir; char c; npos = pos = markdata->isstartpos; dir = markdata->isstartdir; markdata->isstrl = 0; for (i = 0; i < markdata->isistrl; i++) { c = markdata->isistr[i]; if (c == '\022') /* ^R */ pos += (dir = -1); else if (c == '\023') /* ^S */ pos += (dir = 1); else markdata->isstr[markdata->isstrl++] = c; if (pos >= 0) { npos = is_bm(markdata->isstr, markdata->isstrl, pos, flayer->l_width * (markdata->md_window->w_histheight + flayer->l_height), dir); if (npos >= 0) pos = npos; } } markdata->isstr[markdata->isstrl] = 0; markdata->isdir = dir; return npos; } void ISearch(dir) int dir; { struct markdata *markdata; markdata = (struct markdata *)flayer->l_data; markdata->isdir = markdata->isstartdir = dir; markdata->isstartpos = markdata->cx + markdata->cy * flayer->l_width; markdata->isistrl = markdata->isstrl = 0; if (W2D(markdata->cy) == INPUTLINE) revto_line(markdata->cx, markdata->cy, INPUTLINE > 0 ? INPUTLINE - 1 : 1); Input(isprompts[dir + 1], sizeof(markdata->isstr) - 1, INP_RAW, is_process, NULL, 0); LGotoPos(flayer, markdata->cx, W2D(markdata->cy)); flayer->l_x = markdata->cx; flayer->l_y = W2D(markdata->cy); } #endif /* COPY_PASTE */ screen-4.3.1/.gitignore0000644000175000017500000000026112544062657013700 0ustar amadeamade*.o .*.swp \#*\# *~ Makefile autom4te.cache cscope.out TAGS tags comm.h config.h config.h.in config.log config.status configure kmapdef.c osdef.h term.h screen stamp-h.in tty.c screen-4.3.1/braille_tsi.c0000644000175000017500000002217412544062657014354 0ustar amadeamade/* bd-tsi.c, TSI specific key bindings and display commands * * dotscreen * A braille interface to unix tty terminals * Authors: Hadi Bargi Rangin bargi@dots.physics.orst.edu * Bill Barry barryb@dots.physics.orst.edu * * Copyright (c) 1995 by Science Access Project, Oregon State University. * * * 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 * http://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 "braille.h" #ifdef HAVE_BRAILLE extern struct display *display; struct key2rc { int key; int nr; char *arg1; char *arg2; }; static int tsi_ctype = 1; /* cursor type, 0,1,2 */ static int tsi_line_type; /* indicates number of cells on powerbraille display 01=20 cells 02=40 cells 03=80 cells */ static int display_status_tsi __P((void)); static int write_line_tsi __P((char *, int, int)); static void buttonpress_tsi __P((struct key2rc *)); static void buttonpress_navigator_40 __P((void)); static void buttonpress_powerbraille_40 __P((void)); static void buttonpress_powerbraille_80 __P((void)); int bd_init_powerbraille_40() { bd.write_line_braille = write_line_tsi; bd.buttonpress = buttonpress_powerbraille_40; bd.bd_response_test = display_status_tsi; bd.bd_ncells = 40; tsi_line_type = 2; return 0; } int bd_init_powerbraille_80() { bd.write_line_braille = write_line_tsi; bd.buttonpress = buttonpress_powerbraille_80; bd.bd_response_test = display_status_tsi; bd.bd_ncells = 80; tsi_line_type = 3; return 0; } int bd_init_navigator_40() { bd.write_line_braille = write_line_tsi; bd.buttonpress = buttonpress_navigator_40; bd.bd_response_test = display_status_tsi; bd.bd_ncells = 40; tsi_line_type = 2; return 0; } static int display_status_tsi() { char obuf[3],ibuf[20]; int r; obuf[0] = 0xff; obuf[1] = 0xff; obuf[2] = 0x0a; r = read(bd.bd_fd, ibuf, 20); /* flush the input port */ r = write(bd.bd_fd, obuf, 3); if (r != 3) return -1; /* we have written to the display asking for a response we wait 1 second for the response, read it and if no response we wait 2 seconds, if still no response, return -1 to indicate no braille display available */ sleep(1); r = read(bd.bd_fd, ibuf, 2); if (r == -1) { sleep(2); r = read(bd.bd_fd, ibuf, 2); } debug2("first chars from braille display %d %d\n",ibuf[0],ibuf[1]); if (r != 2 || ibuf[0] != 0 || ibuf[1] != 5) return -1; r= read(bd.bd_fd,ibuf,2); if (r != 2) return -1; debug2("braille display size:%d dots:%d\n", ibuf[0], ibuf[1]); bd.bd_ncells = (unsigned char)ibuf[0]; if (bd.bd_ncells <= 1) return -1; r = read(bd.bd_fd,ibuf,1); if (r != 1) return -1; if (ibuf[0] == 'V') r = read(bd.bd_fd, ibuf, 3); else r = read(bd.bd_fd, ibuf + 1, 2) + 1; if (r != 3) return -1; ibuf[3] = 0; debug1("braille display version %s\n", ibuf); bd.bd_version = atof(ibuf); return 0; } static int write_line_tsi (bstr,line_length, cursor_pos) char *bstr; int line_length, cursor_pos; { int obp, i; bd.bd_obuf[0] = 0xff; bd.bd_obuf[1] = 0xff; bd.bd_obuf[2] = tsi_line_type; bd.bd_obuf[3] = 0x07; bd.bd_obuf[4] = cursor_pos; bd.bd_obuf[5] = tsi_ctype; obp=6; for (i=0; i < line_length; i++) { bd.bd_obuf[2*i+obp] = 0; bd.bd_obuf[2*i+1+obp] = bd.bd_btable[(int)(unsigned char)bstr[i]]; } for (i=line_length; i < bd.bd_ncells; i++) { bd.bd_obuf[2*i+obp] = 0; bd.bd_obuf[2*i+1+obp] = bd.bd_btable[(int)' ']; } bd.bd_obuflen = 2*bd.bd_ncells + obp ; return 0; } static struct key2rc keys_navigator_40[] = { {0x4000000, RC_STUFF, "-k", "kl"}, /* 1 */ {0x10000000, RC_STUFF, "-k", "kr"}, /* 3 */ {0x8000000, RC_STUFF, "-k", "ku"}, /* 2 */ {0x20000000, RC_STUFF, "-k", "kd"}, /* 4 */ {0x2000, RC_BD_BC_LEFT, 0, 0}, /* 6 */ {0x8000, RC_BD_BC_RIGHT, 0, 0}, /* 8 */ {0x4000, RC_BD_BC_UP, 0, 0}, /* 7 */ {0x10000, RC_BD_BC_DOWN, 0, 0}, /* 9 */ {0x6000, RC_BD_UPPER_LEFT, 0, 0}, /* 6, 7 */ {0xc000, RC_BD_UPPER_RIGHT, 0, 0}, /* 7, 8 */ {0x12000, RC_BD_LOWER_LEFT, 0, 0}, /* 6, 9 */ {0x18000, RC_BD_LOWER_RIGHT, 0, 0}, /* 8, 9 */ {0xa000, RC_BD_INFO, "1032", 0}, /* bc 6, 8 */ {0x14000000, RC_BD_INFO, "2301", 0}, /* sc 1, 3 */ {0x4008000, RC_BD_INFO, "3330", 0}, /* bc+sc 1, 8 */ {0x8010000, RC_BD_BELL, 0, 0}, /* 2, 9 */ {0x8004000, RC_BD_EIGHTDOT, 0, 0}, /* 2, 7 */ {0x40000000, RC_STUFF, "\015", 0}, /* 5 */ {0x20000, RC_BD_LINK, 0, 0}, /* 10 */ {0x10002000, RC_BD_SCROLL, 0, 0}, /* 3, 6 */ {0x20010000, RC_BD_NCRC, "+", 0}, /* 4, 9 */ {0x14000, RC_BD_SKIP, 0, 0}, /* 7, 9*/ {-1, RC_ILLEGAL, 0, 0} }; static struct key2rc keys_powerbraille_40[] = { {0x4000000, RC_STUFF, "-k", "kl"}, /* 1 */ {0x10000000, RC_STUFF, "-k", "kr"}, /* 3 */ {0x8000000, RC_STUFF, "-k", "ku"}, /* 2 */ {0x20000000, RC_STUFF, "-k", "kd"}, /* 4 */ {0x2000, RC_BD_BC_LEFT, 0, 0}, /* 6 */ {0x8000, RC_BD_BC_RIGHT, 0, 0}, /* 8 */ {0x4000, RC_BD_BC_UP, 0, 0}, /* 7 */ {0x10000, RC_BD_BC_DOWN, 0, 0}, /* 9 */ {0x8002000, RC_BD_UPPER_LEFT, 0, 0}, /* 2, 6 */ {0xc000, RC_BD_UPPER_RIGHT, 0, 0}, /* 7, 8 */ {0x20002000, RC_BD_LOWER_LEFT, 0, 0}, /* 3, 6 */ {0x18000, RC_BD_LOWER_RIGHT, 0, 0}, /* 8, 9 */ {0x8008000, RC_BD_INFO, "1032", 0}, /* bc 2, 8 */ {0x6000, RC_BD_INFO, "2301", 0}, /* 6, 7 */ {0x8004000, RC_BD_INFO, "3330", 0}, /* bc+sc 2, 7 */ {0x8010000, RC_BD_BELL, 0, 0}, /* 2, 9 */ {0x20008000, RC_BD_EIGHTDOT, 0, 0}, /* 4, 6 */ {0x40000000, RC_STUFF, "\015", 0}, /* 5 */ {0x20000, RC_BD_LINK, 0, 0}, /* 10 */ {0xa000, RC_BD_SCROLL, 0, 0}, /* 6, 8 */ {0x20010000, RC_BD_NCRC, "+", 0}, /* 4, 9 */ {0x20004000, RC_BD_SKIP, 0, 0}, /* 4, 7 */ {-1, RC_ILLEGAL, 0, 0} }; static struct key2rc keys_powerbraille_80[] = { {0x4000000, RC_STUFF, "-k", "kl"}, /* 1 */ {0x10000000, RC_STUFF, "-k", "kr"}, /* 3 */ {0x8000000, RC_STUFF, "-k", "ku"}, /* 2 */ {0x20000000, RC_STUFF, "-k", "kd"}, /* 4 */ {0x40000, RC_BD_BC_LEFT, 0, 0}, /* 6 */ {0x100000, RC_BD_BC_RIGHT, 0, 0}, /* 8 */ {0x4000, RC_BD_BC_UP, 0, 0}, /* 7 */ {0x10000, RC_BD_BC_DOWN, 0, 0}, /* 9 */ {0x44000, RC_BD_UPPER_LEFT, 0, 0}, /* 6, 7 */ {0x104000, RC_BD_UPPER_RIGHT, 0, 0}, /* 7, 8 */ {0x50000, RC_BD_LOWER_LEFT, 0, 0}, /* 6, 9 */ {0x110000, RC_BD_LOWER_RIGHT, 0, 0}, /* 8, 9 */ {0x8100000, RC_BD_INFO, "1032", 0}, /* 2, 8 */ {0x8040000, RC_BD_INFO, "2301", 0}, /* 2, 6 */ {0x140000, RC_BD_INFO, "3330", 0}, /* 6, 8 */ {0x8010000, RC_BD_BELL, 0, 0}, /* 2, 9 */ {0x8004000, RC_BD_EIGHTDOT, 0, 0}, /* 2, 7 */ {0x40000000, RC_STUFF, "\015", 0}, /* 5 */ {0x20000, RC_BD_LINK, 0, 0}, /* 10 */ {0x20004000, RC_BD_SCROLL, 0, 0}, /* 4, 7 */ {0x20010000, RC_BD_NCRC, "+", 0}, /* 4, 9 */ {0x40010000, RC_BD_SKIP, 0, 0}, /* 5, 9 */ {-1, RC_ILLEGAL, 0, 0} }; static void buttonpress_tsi(tab) struct key2rc *tab; { int i, nb; int bkeys; unsigned char buf[10]; nb = read(bd.bd_fd, buf, 10); debug1("buttonpress_tsi: read %d bytes\n", nb); for (i=0, bkeys=0; i < nb; i++) { switch (buf[i] & 0xE0) { case 0x00: bkeys += ((int)(buf[i] & 0x1f) ); break; case 0x20: bkeys += ((int)(buf[i] & 0x1f) << 5 ); break; case 0x40: bkeys += ((int)(buf[i] & 0x1f) << 9 ); break; case 0x60: bkeys += ((int)(buf[i] & 0x1f) << 13 ); break; case 0xA0: bkeys += ((int)(buf[i] & 0x1f) << 18 ); break; case 0xC0: bkeys += ((int)(buf[i] & 0x1f) << 22 ); break; case 0xE0: bkeys += ((int)(buf[i] & 0x1f) << 26 ); break; default: break; } } debug1("bkeys %x\n", bkeys); for (i = 0; tab[i].key != -1; i++) if (bkeys == tab[i].key) break; debug1("bkey index %d\n", i); if (tab[i].key != -1 && tab[i].nr != RC_ILLEGAL) { char *args[3]; int argl[2]; struct action act; args[0] = tab[i].arg1; args[1] = tab[i].arg2; args[2] = 0; argl[0] = args[0] ? strlen(args[0]) : 0; argl[1] = args[1] ? strlen(args[1]) : 0; act.nr = tab[i].nr; act.args = args; act.argl = argl; display = bd.bd_dpy; DoAction(&act, -2); } } static void buttonpress_navigator_40() { buttonpress_tsi(keys_navigator_40); } static void buttonpress_powerbraille_40() { buttonpress_tsi(keys_powerbraille_40); } static void buttonpress_powerbraille_80() { buttonpress_tsi(keys_powerbraille_80); } #endif /* HAVE_BRAILLE */ screen-4.3.1/doc/0000755000175000017500000000000012544064625012453 5ustar amadeamadescreen-4.3.1/doc/screen.texinfo0000644000175000017500000070136512544064607015344 0ustar amadeamade\input texinfo @c -*-texinfo-*- @c %**start of header @c vi:set wm=5 @setfilename screen.info @settitle Screen User's Manual @dircategory General Commands @finalout @setchapternewpage odd @c %**end of header @set version 4.3.1 @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-2003 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 May 2015 @page @vskip 0pt plus 1filll Copyright @copyright{} 1993-2003 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 -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 varible using the spcified @emph{term} as opposed to the defualt 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 defzombie [@var{keys}] Keep dead windows. @xref{Zombie}. @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 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 @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 on the new region. The default is to create a horizontal split, putting the new regions on the top and bottom of each other. Using -v will create a vertical split, causing the new regions to appear side by side of each other. 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 (@kbd{C-a @key{Tab}})@* Move the input focus to the next region. This is done in a cyclic way so that the top region is selected after the bottom one. If no subcommand is given it defaults to `down'. `up' cycles in the opposite order, `top' and `bottom' go to the top and bottom region respectively. Useful bindings are (j and k as in vi) @example bind j focus down bind k focus up bind t focus top bind b focus bottom @end example @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 [(+/-)@var{lines}] (none)@* Resize the current region. The space will be removed from or added to the region below or if there's not enough space from the region above. @example resize +N increase current region height by N resize -N decrease current region height by N resize N set current region height to N resize = make all windows equally high resize max maximize current region height resize min minimize current region height @end example @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. @documentencoding ISO-8859-1 @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, , Visual Bell, termcap, The Termcap Manual}, 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 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{Top, , Termcap, termcap, The Termcap Manual}, 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{Top, , Termcap, termcap, The Termcap Manual}). 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{