home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume28 / screen32 / part04 < prev    next >
Encoding:
Text File  |  1992-02-08  |  55.0 KB  |  1,889 lines

  1. Newsgroups: comp.sources.misc
  2. From: jnweiger@immd4.informatik.uni-erlangen.de (Juergen Weigert)
  3. Subject:  v28i021:  screen-3.2 - multiple windows on an ASCII terminal, v3.2, Part04/11
  4. Message-ID: <1992Feb9.223542.6587@sparky.imd.sterling.com>
  5. X-Md4-Signature: 6a19c8e6934cd429c5533731d9021d09
  6. Date: Sun, 9 Feb 1992 22:35:42 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: jnweiger@immd4.informatik.uni-erlangen.de (Juergen Weigert)
  10. Posting-number: Volume 28, Issue 21
  11. Archive-name: screen-3.2/part04
  12. Environment: UNIX
  13.  
  14. #!/bin/sh
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file screen3.2/mark.c continued
  17. #
  18. if test ! -r _shar_seq_.tmp; then
  19.     echo 'Please unpack part 1 first!'
  20.     exit 1
  21. fi
  22. (read Scheck
  23.  if test "$Scheck" != 4; then
  24.     echo Please unpack part "$Scheck" next!
  25.     exit 1
  26.  else
  27.     exit 0
  28.  fi
  29. ) < _shar_seq_.tmp || exit 1
  30. if test ! -f _shar_wnt_.tmp; then
  31.     echo 'x - still skipping screen3.2/mark.c'
  32. else
  33. echo 'x - continuing file screen3.2/mark.c'
  34. sed 's/^X//' << 'SHAR_EOF' >> 'screen3.2/mark.c' &&
  35. X    {
  36. X      if (oq == 0 || !(flags & NW_ENDOFWORD))
  37. X        *xp = x;
  38. X      else
  39. X        *xp = x-sx;
  40. X      *yp = y;
  41. X      if ((!(flags & NW_ENDOFWORD) && q) ||
  42. X          ((flags & NW_ENDOFWORD) && oq))
  43. X        {
  44. X          if (--num <= 0)
  45. X            return;
  46. X        }
  47. X    }
  48. X      if (x == xx)
  49. X    {
  50. X      x = -1;
  51. X      if (++y >= yy)
  52. X        return;
  53. X    }
  54. X      else if (x < 0)
  55. X    {
  56. X      x = xx;
  57. X      if (--y < 0)
  58. X        return;
  59. X    }
  60. X    }
  61. }
  62. X
  63. X
  64. /*
  65. X * y1, y2 are WIN coordinates
  66. X *
  67. X * redisplay:    0  -  just copy
  68. X *         1  -  redisplay + copy
  69. X *        2  -  count + copy, don't redisplay
  70. X */
  71. X
  72. static int rem(x1, y1, x2, y2, redisplay, pt, yend)
  73. int x1, y1, x2, y2, redisplay, yend;
  74. char *pt;
  75. {
  76. X  int i, j, from, to, ry;
  77. X  int l = 0;
  78. X  char *im;
  79. X
  80. X  second = 0;
  81. X  if (y2 < y1 || ((y2 == y1) && (x2 < x1)))
  82. X    {
  83. X      i = y2;
  84. X      y2 = y1;
  85. X      y1 = i;
  86. X      i = x2;
  87. X      x2 = x1;
  88. X      x1 = i;
  89. X    }
  90. X  ry = y1 - hist_offset;
  91. X  
  92. X  i = y1;
  93. X  if (redisplay != 2 && pt == 0 && ry <0)
  94. X    {
  95. X      i -= ry;
  96. X      ry = 0;
  97. X    }
  98. X  for (; i <= y2; i++, ry++)
  99. X    {
  100. X      if (redisplay != 2 && pt == 0 && ry > yend)
  101. X    break;
  102. X      from = (i == y1) ? x1 : 0;
  103. X      if (from < left_mar)
  104. X    from = left_mar;
  105. X      for (to = screenwidth-1, im = iWIN(i)+to; to>=0; to--)
  106. X        if (*im-- != ' ')
  107. X      break;
  108. X      if (i == y2 && x2 < to)
  109. X    to = x2;
  110. X      if (to > right_mar)
  111. X    to = right_mar;
  112. X      if (redisplay == 1 && from <= to && ry >=0 && ry <= yend)
  113. X    MarkRedisplayLine(ry, from, to, 0);
  114. X      if (redisplay != 2 && pt == 0)    /* don't count/copy */
  115. X    continue;
  116. X      for (j = from, im = iWIN(i)+from; j <= to; j++)
  117. X    {
  118. X      if (pt)
  119. X        *pt++ = *im++;
  120. X      l++;
  121. X    }
  122. X      if (i != y2)
  123. X    {
  124. X      /* 
  125. X       * this code defines, what glues lines together
  126. X       */
  127. X      switch (nonl)
  128. X        {
  129. X        case 0:        /* lines separated by newlines */
  130. X          if (join_with_cr)
  131. X        {
  132. X          if (pt)
  133. X            *pt++ = '\r';
  134. X          l++;
  135. X        }
  136. X          if (pt)
  137. X        *pt++ = '\n';
  138. X          l++;
  139. X          break;
  140. X        case 1:        /* nothing to separate lines */
  141. X          break;
  142. X        case 2:        /* lines separated by blanks */
  143. X          if (pt)
  144. X        *pt++ = ' ';
  145. X          l++;
  146. X          break;
  147. X        }
  148. X    }
  149. X    }
  150. X  return(l);
  151. }
  152. X
  153. static int eq(a, b)
  154. int a, b;
  155. {
  156. X  if (a == b)
  157. X    return 1;
  158. X  if (a == 0 || b == 0)
  159. X    return 1;
  160. X  if (a <= '9' && a >= '0' && b <= '9' && b >= '0')
  161. X    return 1;
  162. X  return 0;
  163. }
  164. X
  165. static int crazychar = 0;
  166. static int crazy_y = -1;
  167. static int crazy_x = -1;
  168. X
  169. int MarkRoutine(flag)    /* return value 1 when copybuffer changed; */
  170. int flag;
  171. {
  172. X  int x, y, i;
  173. X  hist_offset = fore->histheight;
  174. X  if (!fore->active)
  175. X    {
  176. X      Msg(0, "Fore window is not active !!!");
  177. X      return 0;
  178. X    }
  179. X
  180. X  second = 0;
  181. X  rep_cnt = 0;
  182. X  append_mode = 0;
  183. X  write_buffer = 0;
  184. X  nonl = left_mar = 0;
  185. X  right_mar = screenwidth-1;
  186. X  x = fore->x;
  187. X  y = D2W(fore->y);
  188. X  if (x >= screenwidth)
  189. X    x = screenwidth-1;
  190. X
  191. X  if (flag == CRAZY && crazychar != 0 && crazy_x != -1 && crazy_y != -1)
  192. X    {
  193. X      Msg(0, "CRAZY mode not impl.\n");
  194. X    }
  195. X  crazychar = 0;
  196. X  crazy_y = -1;
  197. X  crazy_x = -1;
  198. X  if (flag == TRICKY)
  199. X    {
  200. X      int f, q = 0, xx, yy;
  201. X      char *linep;
  202. X
  203. X      debug2("cursor is at x=%d, y=%d\n", fore->x, D2W(fore->y));
  204. X      for (xx = fore->x - 1, linep = iWIN(y) + xx; xx >= 0; xx--)
  205. X    if ((q = *linep--) != ' ' )
  206. X      break;
  207. X      debug3("%c at (%d,%d)\n", q, xx, y);
  208. X      for (yy = D2W(fore->y) - 1; yy >= 0; yy--)
  209. X    if (xx < 0 || eq(iWIN(yy)[xx], q))
  210. X      {        /* line is matching... */
  211. X        f = 0;
  212. X        for (i = fore->x; i < screenwidth-1; i++)
  213. X          {
  214. X        if (iWIN(yy)[i] != ' ')
  215. X          {
  216. X            f = 1;
  217. X            break;
  218. X          }
  219. X          }
  220. X        if (f)
  221. X          break;
  222. X      }
  223. X      if (yy < 0)
  224. X    return 0;
  225. X      xx = 0;
  226. X      for (i = screenwidth-1, linep = iWIN(yy)+i; i>0; i--)
  227. X    if (*linep-- != ' ')
  228. X      break;
  229. X      if (i < x)
  230. X    i = x;
  231. X      if (copybuffer != NULL)
  232. X    Free(copybuffer);
  233. X      if ((copybuffer = malloc((unsigned) (i - x + 2))) == NULL)
  234. X    {
  235. X      Msg(0, "Not enough memoooh!... Sorry.");
  236. X      return 0;
  237. X    }
  238. X      rem(x, yy, i, yy, 0, copybuffer, 0);
  239. X      copylen = i - x + 1;
  240. X      return 1;
  241. X    }
  242. X  InitOverlayPage(process_mark_input, MarkRedisplayLine, MarkRewrite, 1);
  243. X  GotoPos(x, W2D(y));
  244. #ifdef NETHACK
  245. X  if (nethackflag)
  246. X    Msg(0, "Welcome to hacker's treasure zoo - Column %d Line %d(+%d) (%d,%d)",
  247. X    x+1, W2D(y+1), fore->histheight, fore->width, fore->height);
  248. X  else
  249. #endif
  250. X  Msg(0, "Copy mode - Column %d Line %d(+%d) (%d,%d)",
  251. X      x+1, W2D(y+1), fore->histheight, fore->width, fore->height);
  252. X  fflush(stdout);
  253. X  cx = x1 = x;
  254. X  cy = y1 = y;
  255. X  in_mark = 1;
  256. X  return 0;
  257. }
  258. X
  259. static void process_mark_input(inbufp,inlenp)
  260. char **inbufp;
  261. int *inlenp;
  262. {
  263. X  char *inbuf, *pt;
  264. X  int inlen;
  265. X  int x2, y2, i, j, yend;
  266. X  int newcopylen = 0, od;
  267. /*
  268. X  char *extrap = 0, extrabuf[100];
  269. */
  270. X      
  271. X  if (inbufp == 0)
  272. X    {
  273. X      AbortMarkRoutine();
  274. X      return;
  275. X    }
  276. X  inbuf= *inbufp;
  277. X  inlen= *inlenp;
  278. X  pt = inbuf;
  279. X  while (in_mark && (inlen /* || extrap */))
  280. X    {
  281. X      if (!HS)
  282. X    RemoveStatus();
  283. /*
  284. X      if (extrap)
  285. X    {
  286. X      od = *extrap++;
  287. X      if (*extrap == 0)
  288. X        extrap = 0;
  289. X    }
  290. X      else
  291. */
  292. X    {
  293. X          od = mark_key_tab[*pt++];
  294. X          inlen--;
  295. X    }
  296. X      if (od >= '0' && od <= '9')
  297. X        {
  298. X      if (rep_cnt < 1001 && (od != '0' || rep_cnt != 0))
  299. X        {
  300. X          rep_cnt = 10 * rep_cnt + od - '0';
  301. X          continue;
  302. X           /*
  303. X           * Now what is that 1001 here? Well, we have a screen with
  304. X           * 25 * 80 = 2000 characters. Movement is at most across the full
  305. X           * screen. This we do with word by word movement, as character by
  306. X           * character movement never steps over line boundaries. The most words
  307. X           * we can place on the screen are 1000 single letter words. Thus 1001
  308. X           * is sufficient. Users with bigger screens never write in single letter
  309. X           * words, as they should be more advanced. jw.
  310. X           * Oh, wrong. We still give even the experienced user a factor of ten.
  311. X           */
  312. X        }
  313. X    }
  314. X      switch (od)
  315. X    {
  316. X    case '\014':    /* CTRL-L Redisplay */
  317. X      Redisplay(0);
  318. X      GotoPos(cx, W2D(cy));
  319. X      break;
  320. X    case '\010':    /* CTRL-H Backspace */
  321. X    case 'h':
  322. X      if (rep_cnt == 0)
  323. X        rep_cnt = 1;
  324. X      revto(cx - rep_cnt, cy);
  325. X      break;
  326. X    case '\016':    /* CTRL-N */
  327. X    case 'j':
  328. X      if (rep_cnt == 0)
  329. X        rep_cnt = 1;
  330. X      revto(cx, cy + rep_cnt);
  331. X      break;
  332. X    case '+':
  333. X      if (rep_cnt == 0)
  334. X        rep_cnt = 1;
  335. X      j = cy + rep_cnt;
  336. X      if (j > fore->histheight + screenheight - 1)
  337. X        j = fore->histheight + screenheight - 1;
  338. X      revto(linestart(j), j);
  339. X      break;
  340. X    case '-':
  341. X      if (rep_cnt == 0)
  342. X        rep_cnt = 1;
  343. X      j = cy - rep_cnt;
  344. X      if (j < 0)
  345. X        j = 0;
  346. X      revto(linestart(j), j);
  347. X      break;
  348. X    case '^':
  349. X      revto(linestart(cy), cy);
  350. X      break;
  351. X    case '\n':
  352. X      revto(left_mar, cy + 1);
  353. X      break;
  354. X    case 'k':
  355. X    case '\020':    /* CTRL-P */
  356. X      if (rep_cnt == 0)
  357. X        rep_cnt = 1;
  358. X      revto(cx, cy - rep_cnt);
  359. X      break;
  360. X    case 'l':
  361. X      if (rep_cnt == 0)
  362. X        rep_cnt = 1;
  363. X      revto(cx + rep_cnt, cy);
  364. X      break;
  365. X    case '\001':    /* CTRL-A from tcsh/emacs */
  366. X    case '0':
  367. X      revto(left_mar, cy);
  368. X      break;
  369. X    case '\004':    /* CTRL-D down half screen */
  370. X      if (rep_cnt == 0)
  371. X        rep_cnt = (screenheight+1) >> 1;
  372. X      revto_line(cx, cy + rep_cnt, W2D(cy));
  373. X      break;
  374. X    case '$':
  375. X      revto(lineend(cy), cy);
  376. X      break;
  377. X    case '\025':    /* CTRL-U up half screen */
  378. X      if (rep_cnt == 0)
  379. X        rep_cnt = (screenheight+1) >> 1;
  380. X      revto_line(cx, cy - rep_cnt, W2D(cy));
  381. X      break;
  382. X    case '?':
  383. X      if (left_mar == 0 && right_mar == screenwidth - 1)
  384. X        Msg(0, "Column %d Line %d(+%d)", cx+1, W2D(cy)+1,
  385. X        hist_offset);
  386. X      else
  387. X        Msg(0, "Column %d(%d..%d) Line %d(+%d)", cx+1,
  388. X        left_mar+1, right_mar+1, W2D(cy)+1, hist_offset);
  389. X      break;
  390. X    case '\002':    /* CTRL-B  back one page */
  391. X      if (rep_cnt == 0)
  392. X        rep_cnt = 1;
  393. X      rep_cnt *= (screenheight-1);
  394. X      revto(cx, cy - rep_cnt);
  395. X      break;
  396. X    case '\006':    /* CTRL-F  forward one page */
  397. X      if (rep_cnt == 0)
  398. X        rep_cnt = 1;
  399. X      rep_cnt *= (screenheight-1);
  400. X      revto(cx, cy + rep_cnt);
  401. X      break;
  402. X    case '\005':    /* CTRL-E  scroll up */
  403. X      if (rep_cnt == 0)
  404. X        rep_cnt = 1;
  405. X      rep_cnt = MarkScrollUpDisplay(rep_cnt);
  406. X      if (cy < D2W(0))
  407. X            revto(cx, D2W(0));
  408. X      else
  409. X            GotoPos(cx, W2D(cy));
  410. X      break;
  411. X    case '\031': /* CTRL-Y  scroll down */
  412. X      if (rep_cnt == 0)
  413. X        rep_cnt = 1;
  414. X      rep_cnt = MarkScrollDownDisplay(rep_cnt);
  415. X      if (cy > D2W(screenheight-1))
  416. X            revto(cx, D2W(screenheight-1));
  417. X      else
  418. X            GotoPos(cx, W2D(cy));
  419. X      break;
  420. X    case '@':
  421. X      /* it may be usefull to have a key that does nothing */
  422. X      break;
  423. X    case '%':
  424. X      rep_cnt--;
  425. X      /* rep_cnt is a percentage for the history buffer */
  426. X      if (rep_cnt < 0)
  427. X        rep_cnt = 0;
  428. X      if (rep_cnt > 100)
  429. X        rep_cnt = 100;
  430. X      revto_line(left_mar, (rep_cnt * (fore->histheight + screenheight)) / 100, (screenheight-1)/2);
  431. X      break;
  432. X    case 'g':
  433. X      rep_cnt = 1;
  434. X      /* FALLTHROUGH */
  435. X    case 'G':
  436. X      /* rep_cnt is here the WIN line number */
  437. X      if (rep_cnt == 0)
  438. X        rep_cnt = fore->histheight + screenheight;
  439. X      revto_line(left_mar, --rep_cnt, (screenheight-1)/2);
  440. X      break;
  441. X    case 'H':
  442. X      revto(left_mar, D2W(0));
  443. X      break;
  444. X    case 'M':
  445. X      revto(left_mar, D2W((screenheight-1) / 2));
  446. X      break;
  447. X    case 'L':
  448. X      revto(left_mar, D2W(screenheight-1));
  449. X      break;
  450. X    case '|':
  451. X      revto(--rep_cnt, cy);
  452. X      break;
  453. X    case 'w':
  454. X      i = cx;
  455. X      j = cy;
  456. X      if (rep_cnt == 0)
  457. X        rep_cnt = 1;
  458. X      nextword(&i, &j, NW_MUSTMOVE, rep_cnt);
  459. X      revto(i, j);
  460. X      break;
  461. X    case 'e':
  462. X      i = cx;
  463. X      j = cy;
  464. X      if (rep_cnt == 0)
  465. X        rep_cnt = 1;
  466. X      nextword(&i, &j, NW_ENDOFWORD|NW_MUSTMOVE, rep_cnt);
  467. X      revto(i, j);
  468. X      break;
  469. X    case 'b':
  470. X      i = cx;
  471. X      j = cy;
  472. X      if (rep_cnt == 0)
  473. X        rep_cnt = 1;
  474. X      nextword(&i, &j, NW_BACK|NW_ENDOFWORD|NW_MUSTMOVE, rep_cnt);
  475. X      revto(i, j);
  476. X      break;
  477. X    case 'a':
  478. X      append_mode = 1 - append_mode;
  479. X      debug1("append mode %d--\n", append_mode);
  480. X      Msg(0, (append_mode) ? ":set append" : ":set noappend");
  481. X      break;
  482. X    case 'v':
  483. X    case 'V':
  484. X      /* this sets start column to column 9 for VI :set nu users */
  485. X      if (left_mar == 8)
  486. X        rep_cnt = 1;
  487. X      else
  488. X        rep_cnt = 9;
  489. X      /* FALLTHROUGH */
  490. X    case 'c':
  491. X    case 'C':
  492. X      /* set start column (c) and end column (C) */
  493. X      if (second)
  494. X        {
  495. X          rem(x1, y1, cx, cy, 1, (char *)0, screenheight-1); /* Hack */
  496. X          second = 1;    /* rem turns off second */
  497. X        }
  498. X      rep_cnt--;
  499. X      if (rep_cnt < 0)
  500. X        rep_cnt = cx;
  501. X      if (od != 'C')
  502. X        {
  503. X          left_mar = rep_cnt;
  504. X          if (left_mar > right_mar)
  505. X        left_mar = right_mar;
  506. X        }
  507. X      else
  508. X        {
  509. X          right_mar = rep_cnt;
  510. X          if (left_mar > right_mar)
  511. X        right_mar = left_mar;
  512. X        }
  513. X      if (second)
  514. X        {
  515. X          int x = cx, y = cy;
  516. X          cx = x1; cy = y1;
  517. X          revto(x, y);
  518. X        }
  519. X      if (od == 'v' || od == 'V')
  520. X        Msg(0, (left_mar != 8) ? ":set nonu" : ":set nu");
  521. X      break;
  522. X    case 'J':
  523. X      /* how do you join lines in VI ? */
  524. X      nonl = (nonl + 1) % 3;
  525. X      switch (nonl)
  526. X        {
  527. X        case 0:
  528. X          if (join_with_cr)
  529. X        Msg(0, "Multiple lines (CR/LF)");
  530. X          else
  531. X        Msg(0, "Multiple lines (LF)");
  532. X          break;
  533. X        case 1:
  534. X          Msg(0, "Lines joined");
  535. X          break;
  536. X        case 2:
  537. X          Msg(0, "Lines joined with blanks");
  538. X          break;
  539. X        }
  540. X      break;
  541. X    case 'y':
  542. X    case 'Y':
  543. X      if (!second)
  544. X        {
  545. X          revto(linestart(cy), cy);
  546. X          second++;
  547. X          x1 = cx;
  548. X          y1 = cy;
  549. X        }
  550. X      if (--rep_cnt > 0)
  551. X        revto(cx, cy + rep_cnt);
  552. X      revto(lineend(cy), cy);
  553. X      if (od == 'y')
  554. X        break;
  555. X      /* FALLTHROUGH */
  556. X    case 'W':
  557. X      if (od == 'W')
  558. X        {
  559. X          if (rep_cnt == 0)
  560. X        rep_cnt = 1;
  561. X          if (!second)
  562. X        {
  563. X          i = cx;
  564. X          j = cy;
  565. X          nextword(&i, &j, NW_BACK|NW_ENDOFWORD, 1);
  566. X          revto(i, j);
  567. X          second++;
  568. X          x1 = cx;
  569. X          y1 = cy;
  570. X        }
  571. X          i = cx;
  572. X          j = cy;
  573. X          nextword(&i, &j, NW_ENDOFWORD, rep_cnt);
  574. X          revto(i, j);
  575. X        }
  576. X      /* FALLTHROUGH */
  577. X    case 'A':
  578. X      if (od == 'A')
  579. X        append_mode = 1;
  580. X      /* FALLTHROUGH */
  581. X    case '>':
  582. X      if (od == '>')
  583. X        write_buffer = 1;
  584. X      /* FALLTHROUGH */
  585. X    case ' ':
  586. X    case '\r':
  587. X      if (!second)
  588. X        {
  589. X          second++;
  590. X          x1 = cx;
  591. X          y1 = cy;
  592. X          revto(x1, y1);
  593. #ifdef NETHACK
  594. X          if (nethackflag)
  595. X        Msg(0, "You drop a magic marker - Column %d Line %d",
  596. X                cx+1, W2D(cy)+1, hist_offset);
  597. X          else
  598. #endif
  599. X          Msg(0, "First mark set - Column %d Line %d", cx+1, cy+1);
  600. X          break;
  601. X        }
  602. X      else
  603. X        {
  604. X          x2 = cx;
  605. X          y2 = cy;
  606. X          newcopylen = rem(x1, y1, x2, y2, 2, (char *)0, 0); /* count */
  607. X          if (copybuffer != NULL && !append_mode)
  608. X        {
  609. X          copylen = 0;
  610. X          Free(copybuffer);
  611. X        }
  612. X          if (newcopylen > 0)
  613. X        {
  614. X          /* the +3 below is for : cr + lf + \0 */
  615. X          if (copybuffer != NULL)
  616. X            copybuffer = realloc(copybuffer,
  617. X            (unsigned) (copylen + newcopylen + 3));
  618. X          else
  619. X            {
  620. X            copylen = 0;
  621. X            copybuffer = malloc((unsigned) (newcopylen + 3));
  622. X            }
  623. X          if (copybuffer == NULL)
  624. X            {
  625. X              AbortMarkRoutine();
  626. X              Msg(0, "Not enough memoooh!... Sorry.");
  627. X              copylen = 0;
  628. X              copybuffer = NULL;
  629. X              break;
  630. X            }
  631. X          if (append_mode)
  632. X            {
  633. X              switch (nonl)
  634. X            /* 
  635. X             * this code defines, what glues lines together
  636. X             */
  637. X            {
  638. X            case 0:
  639. X              if (join_with_cr)
  640. X                {
  641. X                  copybuffer[copylen] = '\r';
  642. X                  copylen++;
  643. X                }
  644. X              copybuffer[copylen] = '\n';
  645. X              copylen++;
  646. X              break;
  647. X            case 1:
  648. X              break;
  649. X            case 2:
  650. X              copybuffer[copylen] = ' ';
  651. X              copylen++;
  652. X              break;
  653. X            }
  654. X            }
  655. X          yend = screenheight - 1;
  656. X          if (fore->histheight - hist_offset < screenheight)
  657. X            {
  658. X              second = 0;
  659. X              yend -= MarkScrollUpDisplay(fore->histheight - hist_offset);
  660. X            }
  661. X          copylen += rem(x1, y1, x2, y2, hist_offset == fore->histheight, copybuffer + copylen, yend);
  662. X        }
  663. X          if (hist_offset != fore->histheight)
  664. X        {
  665. X          in_ovl = 0;    /* So we can use Activate() */
  666. X          Activate(0);
  667. X        }
  668. X          ExitOverlayPage();
  669. X          if (append_mode)
  670. X        Msg(0, "Appended %d characters to buffer",
  671. X            newcopylen);
  672. X          else
  673. X        Msg(0, "Copied %d characters into buffer", copylen);
  674. X          if (write_buffer)
  675. X        WriteFile(DUMP_EXCHANGE);
  676. X          in_mark = 0;
  677. X          break;
  678. X        }
  679. X    default:
  680. X      AbortMarkRoutine();
  681. #ifdef NETHACK
  682. X      if (nethackflag)
  683. X        Msg(0, "You escaped the dungeon.");
  684. X      else
  685. #endif
  686. X      Msg(0, "Copy mode aborted");
  687. X      break;
  688. X    }
  689. X      rep_cnt = 0;
  690. X    }
  691. X  fflush(stdout);
  692. X  *inbufp = pt;
  693. X  *inlenp = inlen;
  694. }
  695. X
  696. static void revto(tx, ty)
  697. int tx, ty;
  698. {
  699. X  revto_line(tx, ty, -1);
  700. }
  701. X
  702. /* tx, ty: WINDOW,  line: DISPLAY */
  703. static void revto_line(tx, ty, line)
  704. int tx, ty, line;
  705. {
  706. X  int fx, fy;
  707. X  int x, y, t, revst, reven, qq, ff, tt, st, en, ce = 0;
  708. X  int ystart = 0, yend = screenheight-1;
  709. X  int i, ry;
  710. X  if (tx < 0)
  711. X    tx = 0;
  712. X  else if (tx > screenwidth - 1)
  713. X    tx = screenwidth -1;
  714. X  if (ty < 0)
  715. X    ty = 0;
  716. X  else if (ty > fore->histheight + screenheight - 1)
  717. X    ty = fore->histheight + screenheight - 1;
  718. X  
  719. X  fx = cx; fy = cy;
  720. X  cx = tx; cy = ty;
  721. /*debug2("revto(%d, %d, ", x1, y1);
  722. X  debug2("%d, %d, ", fx, fy);
  723. X  debug2("%d, %d)\n", tx, ty);*/
  724. X  /*
  725. X   * if we go to a position that is currently offscreen 
  726. X   * then scroll the screen
  727. X   */
  728. X  i = 0;
  729. X  if (line >= 0 && line < screenheight)
  730. X    i = W2D(ty) - line;
  731. X  else if (ty < hist_offset)
  732. X    i = ty - hist_offset;
  733. X  else if (ty > hist_offset + (screenheight-1))
  734. X    i = ty-hist_offset-(screenheight-1);
  735. X  if (i > 0)
  736. X    yend -= MarkScrollUpDisplay(i);
  737. X  else if (i < 0)
  738. X    ystart += MarkScrollDownDisplay(-i);
  739. X
  740. X  if (second == 0)
  741. X    {
  742. X      GotoPos(tx, W2D(cy));
  743. X      return;
  744. X    }
  745. X  
  746. X  qq = x1 + y1 * screenwidth;
  747. X  ff = fx + fy * screenwidth; /* "from" offset in WIN coords */
  748. X  tt = tx + ty * screenwidth; /* "to" offset  in WIN coords*/
  749. X  if (ff > tt)
  750. X    {
  751. X      st = tt; en = ff;
  752. X      x = tx; y = ty;
  753. X    }
  754. X  else
  755. X    {
  756. X      st = ff; en = tt;
  757. X      x = fx; y = fy;
  758. X    }
  759. X  if (st > qq)
  760. X    {
  761. X      st++;
  762. X      x++;
  763. X    }
  764. X  if (en < qq)
  765. X    en--;
  766. X  if (tt > qq)
  767. X    {
  768. X      revst = qq; reven = tt;
  769. X    }
  770. X  else
  771. X    {
  772. X      revst = tt; reven = qq;
  773. X    }
  774. X  ry = y - hist_offset;
  775. X  if (ry < ystart)
  776. X    {
  777. X      y += (ystart - ry);
  778. X      x = 0;
  779. X      st = y * screenwidth;
  780. X      ry = ystart;
  781. X    }
  782. X  for (t = st; t <= en; t++, x++)
  783. X    {
  784. X      if (x >= screenwidth)
  785. X    {
  786. X      x = 0;
  787. X      y++, ry++;
  788. X    }
  789. X      if (ry > yend)
  790. X    break;
  791. X      if (t == st || x == 0)
  792. X    {
  793. X      for (ce = screenwidth-1; ce >= 0; ce--)
  794. X        if (iWIN(y)[ce] != ' ')
  795. X          break;
  796. X    }
  797. X      if (x <= ce && x >= left_mar && x <= right_mar
  798. X          && (LP || x < screenwidth-1 || ry < screenbot))
  799. X    {
  800. X      GotoPos(x, W2D(y));
  801. X      if (t >= revst && t <= reven)
  802. X        SaveSetAttr(A_SO, ASCII);
  803. X      else
  804. X        SaveSetAttr(aWIN(y)[x], fWIN(y)[x]);
  805. X      PUTCHAR(iWIN(y)[x]);
  806. X    }
  807. X    }
  808. X  GotoPos(tx, W2D(cy));
  809. }
  810. X
  811. static void AbortMarkRoutine()
  812. {
  813. X  int yend, redisp;
  814. X
  815. X  yend = screenheight - 1;
  816. X  redisp = second;
  817. X  if (fore->histheight - hist_offset < screenheight)
  818. X    {
  819. X      second = 0;
  820. X      yend -= MarkScrollUpDisplay(fore->histheight - hist_offset);
  821. X    }
  822. X  if (hist_offset != fore->histheight)
  823. X    {
  824. X      in_ovl = 0;    /* So we can use Activate() */
  825. X      Activate(0);    /* to do a complete redisplay */
  826. X    }
  827. X  else
  828. X    {
  829. X      rem(x1, y1, cx, cy, redisp, (char *)0, yend);
  830. X    }
  831. X  ExitOverlayPage();
  832. X  in_mark = 0;
  833. }
  834. X
  835. X
  836. static void MarkRedisplayLine(y, xs, xe, isblank)
  837. int y; /* NOTE: y is in DISPLAY coords system! */
  838. int xs, xe;
  839. int isblank;
  840. {
  841. X  int x, i, rm;
  842. X  int sta, sto, cp; /* NOTE: these 3 are in WINDOW coords system */
  843. X  char *wi, *wa, *wf, *oldi;
  844. X  InsertMode(0); /* Not done in DisplayLine() */
  845. X
  846. X  wi = iWIN(D2W(y));
  847. X  wa = aWIN(D2W(y));
  848. X  wf = fWIN(D2W(y));
  849. X  oldi = isblank ? blank : null;
  850. X  if (second == 0)
  851. X    {
  852. X      DisplayLine(oldi, null, null, wi, wa, wf, y, xs, xe);
  853. X      return;
  854. X    }
  855. X  sta = y1 * screenwidth + x1;
  856. X  sto = cy * screenwidth + cx;
  857. X  if (sta > sto)
  858. X    {
  859. X      i=sta; sta=sto; sto=i;
  860. X    }
  861. X  cp = D2W(y) * screenwidth + xs;
  862. X  rm = right_mar;
  863. X  for (x = screenwidth - 1; x >= 0; x--)
  864. X    if (wi[x] != ' ')
  865. X      break;
  866. X  if (x < rm)
  867. X    rm = x;
  868. X  for (x = xs; x <= xe; x++, cp++)
  869. X    if (cp >= sta && x >= left_mar)
  870. X      break;
  871. X  if (x > xs)
  872. X    DisplayLine(oldi, null, null, wi, wa, wf, y, xs, x-1);
  873. X  for (; x <= xe; x++, cp++)
  874. X    {
  875. X      if (cp > sto || x > rm || (!LP && x >= screenwidth-1 && y == screenbot))
  876. X    break;
  877. X      GotoPos(x, y);
  878. X      SaveSetAttr(A_SO, ASCII);
  879. X      PUTCHAR(wi[x]);
  880. X    }
  881. X  if (x<=xe)
  882. X    DisplayLine(oldi, null, null, wi, wa, wf, y, x, xe);
  883. }
  884. X
  885. X
  886. static int
  887. MarkRewrite(ry, xs, xe, doit)
  888. int ry, xs, xe, doit;
  889. {
  890. X  int dx, x, y, st, en, t, rm;
  891. X  char *a, *f, *i;
  892. X
  893. X  y = D2W(ry);
  894. X  dx = xe - xs;
  895. X  if (doit)
  896. X    {
  897. X      i = iWIN(y) + xs;
  898. X      while (dx--)
  899. X        PUTCHAR(*i++);
  900. X      return(0);
  901. X    }
  902. X  
  903. X  a = aWIN(y) + xs,
  904. X  f = fWIN(y) + xs;
  905. X  if (second == 0)
  906. X    st = en = -1;
  907. X  else
  908. X    {
  909. X      st = y1 * screenwidth + x1;
  910. X      en = cy * screenwidth + cx;
  911. X      if (st > en)
  912. X        {
  913. X          t = st; st = en; en = t;
  914. X        }
  915. X    }
  916. X  t = y * screenwidth + xs;
  917. X  for (rm=screenwidth-1, i=iWIN(y) + screenwidth-1; rm>=0; rm--)
  918. X    if (*i-- != ' ')
  919. X      break;
  920. X  if (rm > right_mar)
  921. X    rm = right_mar;
  922. X  x = xs;
  923. X  while (dx--)
  924. X    {
  925. X      if (t >= st && t <= en && x >= left_mar && x <= rm)
  926. X        {
  927. X      if (GlobalAttr != A_SO || GlobalCharset != ASCII)
  928. X        return(EXPENSIVE);
  929. X        }
  930. X      else
  931. X        {
  932. X      if (GlobalAttr != *a || GlobalCharset != *f)
  933. X        return(EXPENSIVE);
  934. X        }
  935. X      a++, f++, t++, x++;
  936. X    }
  937. X  return(xe - xs);
  938. }
  939. X
  940. X
  941. /*
  942. X * scroll the screen contents up/down.
  943. X */
  944. static int MarkScrollUpDisplay(n)
  945. int n;
  946. {
  947. X  int i;
  948. X  debug1("MarkScrollUpDisplay(%d)\n", n);
  949. X  if (n <= 0)
  950. X    return 0;
  951. X  if (n > fore->histheight - hist_offset)
  952. X    n = fore->histheight - hist_offset;
  953. X  i = (n < screenheight) ? n : (screenheight);
  954. X  ScrollRegion(0, screenheight - 1, i);
  955. X  hist_offset += n;
  956. X  while (i-- > 0)
  957. X    MarkRedisplayLine(screenheight-i-1, 0, screenwidth-1, 1);
  958. X  return n;
  959. }
  960. X
  961. static int MarkScrollDownDisplay(n)
  962. int n;
  963. {
  964. X  int i;
  965. X  debug1("MarkScrollDownDisplay(%d)\n", n);
  966. X  if (n <= 0)
  967. X    return 0;
  968. X  if (n > hist_offset)
  969. X    n = hist_offset;
  970. X  i = (n < screenheight) ? n : (screenheight);
  971. X  ScrollRegion(0, screenheight - 1, -i);
  972. X  hist_offset -= n;
  973. X  while (i-- > 0)
  974. X    MarkRedisplayLine(i, 0, screenwidth-1, 1);
  975. X  return n;
  976. }
  977. X
  978. SHAR_EOF
  979. echo 'File screen3.2/mark.c is complete' &&
  980. chmod 0444 screen3.2/mark.c ||
  981. echo 'restore of screen3.2/mark.c failed'
  982. Wc_c="`wc -c < 'screen3.2/mark.c'`"
  983. test 25395 -eq "$Wc_c" ||
  984.     echo 'screen3.2/mark.c: original size 25395, current size' "$Wc_c"
  985. rm -f _shar_wnt_.tmp
  986. fi
  987. # ============= screen3.2/patchlevel.h ==============
  988. if test -f 'screen3.2/patchlevel.h' -a X"$1" != X"-c"; then
  989.     echo 'x - skipping screen3.2/patchlevel.h (File already exists)'
  990.     rm -f _shar_wnt_.tmp
  991. else
  992. > _shar_wnt_.tmp
  993. echo 'x - extracting screen3.2/patchlevel.h (Text)'
  994. sed 's/^X//' << 'SHAR_EOF' > 'screen3.2/patchlevel.h' &&
  995. /* Copyright (c) 1991
  996. X *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
  997. X *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
  998. X * Copyright (c) 1987 Oliver Laumann
  999. X *
  1000. X * This program is free software; you can redistribute it and/or modify
  1001. X * it under the terms of the GNU General Public License as published by
  1002. X * the Free Software Foundation; either version 1, or (at your option)
  1003. X * any later version.
  1004. X *
  1005. X * This program is distributed in the hope that it will be useful,
  1006. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1007. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1008. X * GNU General Public License for more details.
  1009. X *
  1010. X * You should have received a copy of the GNU General Public License
  1011. X * along with this program (see the file COPYING); if not, write to the
  1012. X * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1013. X *
  1014. X * Noteworthy contributors to screen's design and implementation:
  1015. X *    Wayne Davison (davison@borland.com)
  1016. X *    Patrick Wolfe (pat@kai.com, kailand!pat)
  1017. X *    Bart Schaefer (schaefer@cse.ogi.edu)
  1018. X *    Nathan Glasser (nathan@brokaw.lcs.mit.edu)
  1019. X *    Larry W. Virden (lwv27%cas.BITNET@CUNYVM.CUNY.Edu)
  1020. X *    Howard Chu (hyc@hanauma.jpl.nasa.gov)
  1021. X *    Tim MacKenzie (tym@dibbler.cs.monash.edu.au)
  1022. X *    Markku Jarvinen (mta@{cc,cs,ee}.tut.fi)
  1023. X *    Marc Boucher (marc@CAM.ORG)
  1024. X *
  1025. X ****************************************************************
  1026. X */
  1027. X
  1028. /****************************************************************
  1029. X * $Header: /src.stand/pub/utilities/screen/3.2/RCS/patchlevel.h,v 1.2 92/02/03 02:27:59 jnweiger Exp $ 
  1030. X *
  1031. X * patchlevel.h: Our life story.
  1032. X *   8.7.91 -- 3.00.01 -wipe and a 'setenv TERM dumb' bugfix.
  1033. X *  17.7.91 -- 3.00.02 another patchlevel by Wayne Davison
  1034. X *  31.7.91 -- 3.00.03 E0, S0, C0 for flexible semi-graphics, nonblocking 
  1035. X *                     window title input and 'C-a :' command input.
  1036. X *  10.8.91 -- 3.00.04 scrollback, markkeys and some bugfixes.
  1037. X *  13.8.91 -- 3.00.05 mark routine improved, ansi prototypes added.
  1038. X *  20.8.91 -- 3.00.06 screen -h, faster GotoPos in overlay, termcap %.
  1039. X *                     instead of %c
  1040. X *  28.8.91 -- 3.00.07 environment variable support. security. terminfo.
  1041. X *                     pyramid and ultrix support.
  1042. X *  07.9.91 -- 3.00.99 secopen(), MIPS support, SVR4 support.
  1043. X *  09.9.91 -- 3.01.00 backspace bug fixed.
  1044. X * 03.10.91 -- 3.01.01 ansi.c: null-ptr fixed, CLS now saves to scrollback.
  1045. X *                     Using setresuid on hpux. Memory leak fixed.
  1046. X *               Better GotoPos(). Support for IC. Another resize bug.
  1047. X *                     Detach() w/o fore crashed. -T and -A(dapt) option.
  1048. X *                     GNU copyleft.
  1049. X * 19.12.91 -- 3.01.02 flow now really automatic (autoflow killed).
  1050. X *               7 bit restriction removed from WriteString().
  1051. X * 09.01.92 -- 3.01.03 flow reattach bug fixed. VDISCARD bug fixed.
  1052. X * 13.01.92 -- 3.01.04 new flow concept: ^Af toggles now three states
  1053. X * 21.01.92 -- 3.01.05 '^A:screen 11' bug fixed. aflag in DoScreen().
  1054. X *                     Some code cleanup. attach_tty and display_tty[]
  1055. X *                     added.
  1056. X * 26.01.92 -- 3.01.06 apollo support, "hardcopy_append on", "bufferfile", 
  1057. X *                     SECURITY PROBLEM cleared..
  1058. X * 28.01.92 -- 3.01.07 screen after su allowed. Pid became part of 
  1059. X *                     SockName. sysvish 14 character restriction considered.
  1060. X * 31.01.92 -- 3.02.00 Ultrix port, Irix 3.3 SGI port, shadow pw support,
  1061. X *                     data loss on stdin overflow fixed. "refresh off".
  1062. X */
  1063. X
  1064. #define ORIGIN "FAU"
  1065. #define REV 3
  1066. #define VERS 2
  1067. #define PATCHLEVEL 0
  1068. #define DATE "01/31/92"
  1069. #define STATE ""
  1070. SHAR_EOF
  1071. chmod 0444 screen3.2/patchlevel.h ||
  1072. echo 'restore of screen3.2/patchlevel.h failed'
  1073. Wc_c="`wc -c < 'screen3.2/patchlevel.h'`"
  1074. test 3666 -eq "$Wc_c" ||
  1075.     echo 'screen3.2/patchlevel.h: original size 3666, current size' "$Wc_c"
  1076. rm -f _shar_wnt_.tmp
  1077. fi
  1078. # ============= screen3.2/putenv.c ==============
  1079. if test -f 'screen3.2/putenv.c' -a X"$1" != X"-c"; then
  1080.     echo 'x - skipping screen3.2/putenv.c (File already exists)'
  1081.     rm -f _shar_wnt_.tmp
  1082. else
  1083. > _shar_wnt_.tmp
  1084. echo 'x - extracting screen3.2/putenv.c (Text)'
  1085. sed 's/^X//' << 'SHAR_EOF' > 'screen3.2/putenv.c' &&
  1086. /* Copyright (c) 1991
  1087. X *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
  1088. X *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
  1089. X * Copyright (c) 1987 Oliver Laumann
  1090. X *
  1091. X * This program is free software; you can redistribute it and/or modify
  1092. X * it under the terms of the GNU General Public License as published by
  1093. X * the Free Software Foundation; either version 1, or (at your option)
  1094. X * any later version.
  1095. X *
  1096. X * This program is distributed in the hope that it will be useful,
  1097. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1098. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1099. X * GNU General Public License for more details.
  1100. X *
  1101. X * You should have received a copy of the GNU General Public License
  1102. X * along with this program (see the file COPYING); if not, write to the
  1103. X * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1104. X *
  1105. X * Noteworthy contributors to screen's design and implementation:
  1106. X *    Wayne Davison (davison@borland.com)
  1107. X *    Patrick Wolfe (pat@kai.com, kailand!pat)
  1108. X *    Bart Schaefer (schaefer@cse.ogi.edu)
  1109. X *    Nathan Glasser (nathan@brokaw.lcs.mit.edu)
  1110. X *    Larry W. Virden (lwv27%cas.BITNET@CUNYVM.CUNY.Edu)
  1111. X *    Howard Chu (hyc@hanauma.jpl.nasa.gov)
  1112. X *    Tim MacKenzie (tym@dibbler.cs.monash.edu.au)
  1113. X *    Markku Jarvinen (mta@{cc,cs,ee}.tut.fi)
  1114. X *    Marc Boucher (marc@CAM.ORG)
  1115. X *
  1116. X ****************************************************************
  1117. X */
  1118. X
  1119. /*
  1120. X *  putenv  --  put value into environment
  1121. X *
  1122. X *  Usage:  i = putenv (string)
  1123. X *    int i;
  1124. X *    char  *string;
  1125. X *
  1126. X *  where string is of the form <name>=<value>.
  1127. X *  If "value" is 0, then "name" will be deleted from the environment.
  1128. X *  Putenv returns 0 normally, -1 on error (not enough core for malloc).
  1129. X *
  1130. X *  Putenv may need to add a new name into the environment, or to
  1131. X *  associate a value longer than the current value with a particular
  1132. X *  name.  So, to make life simpler, putenv() copies your entire
  1133. X *  environment into the heap (i.e. malloc()) from the stack
  1134. X *  (i.e. where it resides when your process is initiated) the first
  1135. X *  time you call it.
  1136. X *
  1137. X *  HISTORY
  1138. X *  3-Sep-91 Michael Schroeder (mlschroe). Modified to behave as
  1139. X *    as putenv.
  1140. X * 16-Aug-91 Tim MacKenzie (tym) at Monash University. Modified for
  1141. X *    use in screen (iScreen) (ignores final int parameter)
  1142. X * 14-Oct-85 Michael Mauldin (mlm) at Carnegie-Mellon University
  1143. X *      Ripped out of CMU lib for Rob-O-Matic portability
  1144. X * 20-Nov-79  Steven Shafer (sas) at Carnegie-Mellon University
  1145. X *    Created for VAX.  Too bad Bell Labs didn't provide this.  It's
  1146. X *    unfortunate that you have to copy the whole environment onto the
  1147. X *    heap, but the bookkeeping-and-not-so-much-copying approach turns
  1148. X *    out to be much hairier.  So, I decided to do the simple thing,
  1149. X *    copying the entire environment onto the heap the first time you
  1150. X *    call putenv(), then doing realloc() uniformly later on.
  1151. X */
  1152. #include "config.h"
  1153. X
  1154. #if defined(NEEDSETENV)
  1155. X
  1156. #define EXTRASIZE 5        /* increment to add to env. size */
  1157. X
  1158. char *index(), *malloc(), *realloc();
  1159. int   strlen();
  1160. X
  1161. static int  envsize = -1;    /* current size of environment */
  1162. extern char **environ;        /* the global which is your env. */
  1163. X
  1164. static int  findenv();        /* look for a name in the env. */
  1165. static int  newenv();        /* copy env. from stack to heap */
  1166. static int  moreenv();        /* incr. size of env. */
  1167. X
  1168. int unsetenv(name)
  1169. char *name;
  1170. {
  1171. X  register int i;
  1172. X  
  1173. X  i = findenv(name);
  1174. X  if (i<0)
  1175. X    return;            /* Already here */
  1176. X  
  1177. X  free(environ[i]);
  1178. X  if (envsize > 0)
  1179. X    envsize--;
  1180. X  for (; environ[i]; i++)
  1181. X    environ[i] = environ[i+1];
  1182. }
  1183. X
  1184. int putenv(string)
  1185. char *string;
  1186. X  register int  i, j;
  1187. X  register char *p;
  1188. X  
  1189. X  if (envsize < 0)
  1190. X    {                /* first time putenv called */
  1191. X      if (newenv() < 0)        /* copy env. to heap */
  1192. X    return (-1);
  1193. X    }
  1194. X  
  1195. X  i = findenv(string);        /* look for name in environment */
  1196. X
  1197. X  if (i < 0)
  1198. X    {            /* name must be added */
  1199. X      for (i = 0; environ[i]; i++);
  1200. X      if (i >= (envsize - 1))
  1201. X    {            /* need new slot */
  1202. X      if (moreenv() < 0)
  1203. X        return (-1);
  1204. X    }
  1205. X      p = malloc(strlen(string) + 1);
  1206. X      if (p == 0)        /* not enough core */
  1207. X    return (-1);
  1208. X      environ[i + 1] = 0;    /* new end of env. */
  1209. X    }
  1210. X  else
  1211. X    {            /* name already in env. */
  1212. X      p = realloc(environ[i], strlen(string) + 1);
  1213. X      if (p == 0)
  1214. X    return (-1);
  1215. X    }
  1216. X  sprintf(p, "%s", string); /* copy into env. */
  1217. X  environ[i] = p;
  1218. X  
  1219. X  return (0);
  1220. }
  1221. X
  1222. static int  findenv(name)
  1223. char *name;
  1224. {
  1225. X  register char *namechar, *envchar;
  1226. X  register int  i, found;
  1227. X  
  1228. X  found = 0;
  1229. X  for (i = 0; environ[i] && !found; i++)
  1230. X    { 
  1231. X      envchar = environ[i];
  1232. X      namechar = name;
  1233. X      while (*namechar && *namechar != '=' && (*namechar == *envchar))
  1234. X        { 
  1235. X      namechar++;
  1236. X      envchar++;
  1237. X        }
  1238. X      found = ((*namechar == '\0' || *namechar == '=') && *envchar == '=');
  1239. X    }
  1240. X  return (found ? i - 1 : -1);
  1241. }
  1242. X
  1243. static int newenv()
  1244. X  register char **env, *elem;
  1245. X  register int i, esize;
  1246. X
  1247. X  for (i = 0; environ[i]; i++)
  1248. X    ;
  1249. X  esize = i + EXTRASIZE + 1;
  1250. X  env = (char **)malloc(esize * sizeof (elem));
  1251. X  if (env == 0)
  1252. X    return (-1);
  1253. X
  1254. X  for (i = 0; environ[i]; i++)
  1255. X    { 
  1256. X      elem = malloc(strlen(environ[i]) + 1);
  1257. X      if (elem == 0)
  1258. X    return (-1);
  1259. X      env[i] = elem;
  1260. X      strcpy(elem, environ[i]);
  1261. X    }
  1262. X   
  1263. X  env[i] = 0;
  1264. X  environ = env;
  1265. X  envsize = esize;
  1266. X  return (0);
  1267. }
  1268. X
  1269. static int moreenv()
  1270. X  register int  esize;
  1271. X  register char **env;
  1272. X  
  1273. X  esize = envsize + EXTRASIZE;
  1274. X  env = (char **)realloc(environ, esize * sizeof (*env));
  1275. X  if (env == 0)
  1276. X    return (-1);
  1277. X  environ = env;
  1278. X  envsize = esize;
  1279. X  return (0);
  1280. }
  1281. X
  1282. #endif /* NEEDSETENV */
  1283. X
  1284. X
  1285. SHAR_EOF
  1286. chmod 0444 screen3.2/putenv.c ||
  1287. echo 'restore of screen3.2/putenv.c failed'
  1288. Wc_c="`wc -c < 'screen3.2/putenv.c'`"
  1289. test 5664 -eq "$Wc_c" ||
  1290.     echo 'screen3.2/putenv.c: original size 5664, current size' "$Wc_c"
  1291. rm -f _shar_wnt_.tmp
  1292. fi
  1293. # ============= screen3.2/screen.1 ==============
  1294. if test -f 'screen3.2/screen.1' -a X"$1" != X"-c"; then
  1295.     echo 'x - skipping screen3.2/screen.1 (File already exists)'
  1296.     rm -f _shar_wnt_.tmp
  1297. else
  1298. > _shar_wnt_.tmp
  1299. echo 'x - extracting screen3.2/screen.1 (Text)'
  1300. sed 's/^X//' << 'SHAR_EOF' > 'screen3.2/screen.1' &&
  1301. .if n .ds Q \&"
  1302. .if n .ds U \&"
  1303. .if t .ds Q ``
  1304. .if t .ds U ''
  1305. .TH SCREEN 1 "31 January 1992"
  1306. .UC 4
  1307. .SH NAME
  1308. screen \- screen manager with VT100/ANSI terminal emulation
  1309. .SH SYNOPSIS
  1310. .B screen
  1311. [
  1312. .B -\fIoptions\fP
  1313. ] [
  1314. .B \fIcmd\fP
  1315. [
  1316. .B \fIargs\fP
  1317. ] ]
  1318. .br
  1319. .B screen \-r
  1320. [
  1321. .BR \fI\fP[\fIpid.\fP]\fItty\fP[\fI.host\fP]
  1322. ]
  1323. .ta .5i 1.8i
  1324. .SH DESCRIPTION
  1325. .I Screen
  1326. is a full-screen window manager that
  1327. multiplexes a physical terminal between several processes (typically
  1328. interactive shells).
  1329. Each virtual terminal provides the functions
  1330. of the DEC VT100 terminal and, in addition, several control functions
  1331. from the ANSI X3.64 (ISO 6429) and ISO 2022 standards
  1332. (e.\|g. insert/delete line and support for multiple character sets).
  1333. There is a scrollback history buffer for each virtual terminal and a 
  1334. copy-and-paste mechanism that allows moving text regions between
  1335. windows.
  1336. .PP 
  1337. The name of this program was changed to
  1338. .I iScreen
  1339. to be able to distinguish it from Oliver Laumann's original 
  1340. .I screen
  1341. program. Despite that fact, this manual will continue to use the name
  1342. .IR screen .
  1343. This is, because often the binary is installed as 'screen'.
  1344. .PP
  1345. When
  1346. .I screen
  1347. is called, it creates a single window with a shell in it (or the specified
  1348. command) and then gets out of your way so that you can use the program as you
  1349. normally would.
  1350. Then, at any time, you can create new (full-screen) windows with other programs
  1351. in them (including more shells), kill existing windows, view a list of the
  1352. current windows, turn output logging on and off, copy-and-paste text between
  1353. windows, view the scrollback history, switch between windows
  1354. in whatever manner you wish, etc.
  1355. When a program terminates,
  1356. .I screen
  1357. kills the window that contained it.
  1358. If this window was in the foreground, the display switches to the previous
  1359. window; if none are left,
  1360. .I screen
  1361. exits.
  1362. .PP
  1363. Everything you type is sent to the program running in the current window.
  1364. The only exception to this is the one keystroke that is used to initiate
  1365. a command to the window manager.
  1366. By default, each command begins with a control-a (abbreviated C-a from
  1367. now on), and is followed by one other keystroke.
  1368. The command character and all the key bindings can be fully customized
  1369. to be anything you like, though they are always two characters in length.
  1370. .PP
  1371. The standard way to create a new window is to type \*QC-a c\*U.
  1372. This creates a new window running a shell and switches to that
  1373. window immediately, regardless of the state of the process running
  1374. in the current window.
  1375. Similarly, you can create a new window with a custom command in it by
  1376. first binding the command to a keystroke (in your .screenrc file) and
  1377. then using it just like the \*QC-a c\*U command.
  1378. In addition, new windows can be created by running a command like:
  1379. .IP
  1380. screen emacs prog.c
  1381. .PP
  1382. from a shell prompt within a previously created window.
  1383. This will not run another copy of 
  1384. .IR screen ,
  1385. but will instead supply the
  1386. command name and its arguments to the window manager who will use it to
  1387. create the new window.
  1388. The above example would start the emacs editor (editing prog.c) and switch
  1389. to its window.
  1390. .PP
  1391. If \*Q/etc/utmp\*U is writable by
  1392. .IR screen ,
  1393. an appropriate record will be written to this file for each window, and
  1394. removed when the window is terminated.
  1395. This is useful for working with \*Qtalk\*U, \*Qscript\*U, \*Qshutdown\*U,
  1396. \*Qrsend\*U, \*Qsccs\*U and other similar programs that use the utmp
  1397. file to determine who you are. As long as 
  1398. .I screen
  1399. is active on your terminal,
  1400. the terminals own record is removed from the utmp file. See also \*QC-a L\*U.
  1401. .SH GETTING STARTED
  1402. Before you begin to use
  1403. .I screen
  1404. you'll need to make sure you have correctly selected your terminal type,
  1405. just as you would for any other termcap/terminfo program.
  1406. (You can do this by using
  1407. .IR tset
  1408. or
  1409. .IR stty , 
  1410. for example.)
  1411. .PP
  1412. If you're impatient and want to get started without doing a lot more reading,
  1413. you should remember this one command:  \*QC-a ?\*U.
  1414. Typing these two characters will display a list of the available
  1415. .I screen
  1416. commands and their bindings. Each keystroke is discussed in
  1417. the section \*QCOMMAND KEYS\*U. The manual section \*QCUSTOMIZATION\*U 
  1418. deals with the contents of your .screenrc.
  1419. .PP
  1420. If possible, choose a version of your terminal's termcap that has automatic
  1421. margins turned \fIoff\fP.
  1422. This will ensure an accurate and optimal update of the screen
  1423. in all circumstances.
  1424. The next best thing is an auto-margin terminal that allows the last position
  1425. on the screen to be updated without scrolling the screen (such as a vt100).
  1426. This also allows the entire screen to be updated.
  1427. Lastly, if all you've got is a \*Qtrue\*U auto-margin terminal
  1428. .I screen
  1429. will be content to use it, but updating a character put into the last position
  1430. on the screen may not be possible until the screen scrolls or the character
  1431. is moved into a safe position in some other way.
  1432. This delay can be shortened by using a terminal with insert-character
  1433. capability.
  1434. .PP
  1435. If your terminal is of the second type (firm-margined `am'), you will
  1436. want to let
  1437. .I screen
  1438. know about this, since a normal termcap doesn't distinguish this type of
  1439. automatic margins from a \*Qtrue\*U `am' terminal.
  1440. You do this by specifying the `LP' capability in your termcap
  1441. (see the \*Qtermcap\*U .screenrc command), or by using the
  1442. .B \-L
  1443. command-line option.
  1444. .I Screen
  1445. needs this information to correctly update the screen.
  1446. .PP
  1447. If you are using a \*Qtrue\*U auto-margin terminal (no `LP') at low baud
  1448. rates, you may want to turn on a more optimal output mode by including the
  1449. flag `OP' in your termcap entry, or by specifying the
  1450. .B \-O
  1451. command-line option.
  1452. The trade-off is that
  1453. .I screen
  1454. will no-longer accurately emulate the vt100's line-end quirks (e.\|g. the
  1455. screen will scroll after putting \fIone\fP character in the last screen
  1456. position).
  1457. .SH "COMMAND KEYS"
  1458. As mentioned, each
  1459. .I screen
  1460. command consists of a
  1461. \*QC-a\*U followed by one other character.
  1462. For your convenience, all commands that are bound to lower-case letters are
  1463. also bound to their control character counterparts (with the exception
  1464. of \*QC-a a\*U; see below), thus, \*QC-a c\*U as well as \*QC-a C-c\*U can
  1465. be used to create a window.
  1466. .PP
  1467. The following keystroke commands are available:
  1468. .IP "\fBC-a 0\fP  -  \fBC-a 9\fP   (select0 - select9)"
  1469. Switch to the window with the number 0 through 9.
  1470. When a new window is established, the first available number from the
  1471. range 0..9 is assigned to this window.
  1472. Thus, the first window can be activated by \*QC-a 0\*U (there can be no more
  1473. than 10 windows present at any one time).
  1474. .IP "\fBC-a C-a\fP   (other)"
  1475. Switch to the window displayed previously.
  1476. Note that this function defaults to the command character typed twice,
  1477. unless overridden; for instance, if you use the option \*Q\fB\-e]x\fP\*U,
  1478. this function becomes \*Q]]\*U, not \*Q]C-a\*U.
  1479. .IP "\fBC-a a\fP\0\0\0\0\0"
  1480. Send the command character (C-a) to the processes in the current window.
  1481. .IP "\fBC-a A\fP   (aka)"
  1482. Allow the user to enter an a.\|k.\|a (also-known-as). for the current window.
  1483. .IP "\fBC-a c\fP  or  \fBC-a C-c\fP   (shell)"
  1484. Create a new window with a shell and switch to that window.
  1485. .IP "\fBC-a C\fP   (clear)"
  1486. Clear the screen.
  1487. .IP "\fBC-a d\fP  or  \fBC-a C-d\fP   (detach)"
  1488. Detach
  1489. .I screen
  1490. (disconnect it from the terminal and put it into the background).
  1491. A detached
  1492. .I screen
  1493. can be resumed by invoking
  1494. .I screen
  1495. with the
  1496. .B \-r
  1497. option. (See also section \*QCOMMAND-LINE OPTIONS\*U.)
  1498. .IP "\fBC-a D D\fP   (pow_detach)"
  1499. Power detach. Mainly the same as above, but also sends a HANGUP signal to
  1500. the parent process of
  1501. .IR screen .
  1502. CAUTION: This will result in a logout, when 
  1503. .I screen
  1504. was started from your login shell.
  1505. .IP "\fBC-a f\fP  or  \fBC-a C-f\fP   (flow)"
  1506. Cycles the current window's flow-control setting from "automatic" to "on" to 
  1507. "off", see the section titled FLOW-CONTROL for details.
  1508. .IP "\fBC-a C-g\fP   (vbell)"
  1509. Toggles 
  1510. .I screen's
  1511. visual bell mode. If your terminal does not support
  1512. a visual bell, a `vbell-message' is displayed in the status line. 
  1513. .IP "\fBC-a h\fP  or  \fBC-a C-h\fP   (hardcopy)"
  1514. Write a hardcopy of the current window to the file \*Qhardcopy.\fIn\fP\*U
  1515. in the window's default directory, where \fIn\fP is the number
  1516. of the current window. 
  1517. .IP "\fBC-a H\fP   (log)"
  1518. Begins/ends logging of the current window to the file \*Qscreenlog.\fIn\fP\*U
  1519. in the window's default directory, where \fIn\fP is the number
  1520. of the current window.
  1521. The session log is appended to the previous contents of the file
  1522. if it already exists. 
  1523. The current contents and the contents of the scrollback history are not
  1524. included in the session log.
  1525. .IP "\fBC-a i\fP  or  \fBC-a C-i\fP   (info)"
  1526. Uses the message line to display some information about the current window:
  1527. the cursor position in the form \*Q(column,row)\*U starting with \*Q(1,1)\*U,
  1528. the terminal width and height plus the size of the scrollback buffer in lines, 
  1529. like in \*U(80,24)+50\*U, various flag settings (flow-control, insert mode,
  1530. origin
  1531. mode, wrap mode, application-keypad mode, output logging, and activity
  1532. monitoring (`+' indicates enabled, `-' not)),
  1533. the currently active character set (\fIG0\fP, \fIG1\fP, \fIG2\fP,
  1534. or \fIG3\fP), and in square brackets the terminal character sets that are
  1535. currently designated as \fIG0\fP through \fIG3\fP.
  1536. For system information use \*QC-a t\*U.
  1537. .IP "\fBC-a k\fP  or  \fBC-a C-k\fP   (kill)"
  1538. Kill the current window and switch to the previously displayed window.
  1539. Note:
  1540. .I Emacs
  1541. users should keep this command in mind, when killing a line.
  1542. It is recommended not to use \*QC-a\*U as the
  1543. .I screen
  1544. escape key or that kill is rebound to \*QC-a K\*U.
  1545. .IP "\fBC-a l\fP  or  \fBC-a C-l\fP   (redisplay)"
  1546. Redisplay the current window.
  1547. .IP "\fBC-a L\fP   (login)"
  1548. Adds or removes the entry in /etc/utmp file for the current window.
  1549. This controls if the window is `logged in'. See also above.
  1550. Additionally to that toggle, it is convenient having a `log in' and a `log out'
  1551. key. E.\|g. `bind I set login on' and `bind O set login off' will map these
  1552. keys to be C-a I and C-a O.
  1553. .IP "\fBC-a m\fP  or  \fBC-a C-m\fP   (lastmsg)"
  1554. Repeat the last message displayed in the message line.
  1555. Useful if you're typing when a message appears, because (unless your terminal
  1556. has a status line) the message goes away when you press a key.
  1557. .IP "\fBC-a M\fP   (monitor)"
  1558. Toggles monitoring of the current window.
  1559. When monitoring is turned on and the affected window is switched into the
  1560. background, you will receive the activity notification message in the
  1561. status line at the first sign of output and the window will also be marked
  1562. with an `@' in the window-status display.
  1563. Monitoring is initially off for all windows.
  1564. .IP "\fBC-a space\fP  or  \fBC-a n\fP  or  \fBC-a C-n\fP   (next)"
  1565. Switch to the next window.
  1566. This function can be used repeatedly to cycle through the list of windows.
  1567. (Some terminals require you to release the control key before pressing space.)
  1568. .IP "\fBC-a p\fP  or  \fBC-a C-p\fP   (prev)"
  1569. Switch to the previous window (the opposite of \fBC-a n\fP).
  1570. .IP "\fBC-a q\fP  or  \fBC-a C-q\fP   (xon)"
  1571. Send a control-q to the program in the current window.
  1572. .IP "\fBC-a r\fP  or  \fBC-a C-r\fP   (wrap)"
  1573. Toggle the current window's line-wrap setting (turn the current window's
  1574. automatic margins on and off).
  1575. .IP "\fBC-a s\fP  or  \fBC-a C-s\fP   (xoff)"
  1576. Send a control-s to the program in the current window.
  1577. .IP "\fBC-a t\fP  or  \fBC-a C-t\fP   (time)"
  1578. Uses the message line to display the time of day, the host name, and the load
  1579. averages over 1, 5, and 15 minutes (if this is available on your system).
  1580. For window specific information use \*QC-a i\*U.
  1581. .IP "\fBC-a v\fP  or  \fBC-a C-v\fP   (version)"
  1582. Display the version and compilation date.
  1583. .IP "\fBC-a w\fP  or  \fBC-a C-w\fP   (windows)"
  1584. Uses the message line to display a list of all the windows.
  1585. Each window is listed by number with the name of process that has been
  1586. started in the window (or its a.\|k.\|a.);
  1587. the current window is marked with a `*';
  1588. the previous window is marked with a `-';
  1589. all the windows that are \*Qlogged in\*U are marked with a `$';
  1590. a background window that has received a bell is marked with a `!';
  1591. a background window that is being monitored and has had activity occur
  1592. is marked with an `@';
  1593. a window which has output logging turned on is marked with `(L)'.
  1594. .IP "\fBC-a W\fP   (width)"
  1595. Toggle the window width between 80 and 132 columns. As this command became
  1596. a toggle, \*QC-a N\*U is no longer supported.
  1597. This requires a capable terminal and the termcap entries \*QZ0\*U and \*QZ1\*U.
  1598. See the \*Qtermcap\*U command in section \*QCUSTOMIZATION\*U 
  1599. for more information.
  1600. .IP "\fBC-a x\fP  or  \fBC-a C-x\fP   (lock)"
  1601. Call a screenlock program (/local/bin/lck or /usr/bin/lock or a builtin, if no
  1602. other is available). Screen does not accept any command keys until this program
  1603. terminates. Meanwhile processes in the windows may continue, as the windows 
  1604. are in the `detached' state. The screenlock program may be changed through the
  1605. environment variable $LOCKPRG (which must be set in the shell from which 
  1606. .I screen
  1607. is started) and is executed with the user's uid and gid.
  1608. .IP "\fBC-a z\fP  or  \fBC-a C-z\fP   (suspend)"
  1609. Suspend
  1610. .IR screen .
  1611. The windows are in the `detached' state, while 
  1612. .IR screen
  1613. is suspended.
  1614. .IP "\fBC-a Z\fP   (reset)"
  1615. Reset the virtual terminal to its \*Qpower-on\*U values.
  1616. .IP "\fBC-a .\fP   (termcap)"
  1617. Write the termcap entry for the virtual terminal of the currently active
  1618. window to the file \*Q.termcap\*U in the user's \*Q$HOME/.screen\*U directory
  1619. (or wherever 
  1620. .I screen
  1621. stores its sockets. See the \*QFILES\*U section below).
  1622. This termcap entry is identical to the value of the environment variable
  1623. $TERMCAP that is set up by
  1624. .I screen
  1625. for each window. For terminfo based systems you will need to run a converter
  1626. like 
  1627. .IR captoinfo
  1628. and then compile the entry with 
  1629. .IR tic .
  1630. .IP "\fBC-a ?\fP   (help)"
  1631. Displays a help screen showing you all the key bindings.
  1632. The first pages list all the internal commands followed by their bindings.
  1633. Subsequent pages will display the custom commands, one command per key.
  1634. Press space when you're done reading each page, or return to exit early.
  1635. All other characters are ignored, except for the command character, which will
  1636. exit the help display and begin a command.
  1637. .IP "\fBC-a C-\e\fP   (quit)"
  1638. Kill all windows and terminate
  1639. .IR screen .
  1640. Note that on vt100-style terminals the keys C-4 and C-\e are identical.
  1641. So be careful not to write C-a C-4 when selecting window no. 4.
  1642. Use the empty bind command (as in \*Qbind '^\'\*U) to remove a key binding.
  1643. .IP "\fBC-a :\fP   (colon)"
  1644. Allows you to enter \*Q.screenrc\*U command lines as well as names of 
  1645. key-bound-functions. Useful for on-the-fly modification of key bindings, 
  1646. specific window creation and changing settings. Settings of the current window
  1647. can be changed by prepending the command (if appropriate) with the keyword
  1648. \*Qset\*U.  If you consider this as the `Ex command mode' of 
  1649. .IR screen ,
  1650. you may regard \*QC-a esc\*U as its `Vi command mode'.
  1651. .IP "\fBC-a [\fP  or  \fBC-a C-[\fP  or  \fBC-a esc\fP   (copy)"
  1652. Enter copy/scrollback mode. This allows you to copy text from the current
  1653. window and its history into the paste buffer. In this mode a vi-like
  1654. `full screen editor' is active:
  1655. .br
  1656. .IR "Movement keys" :
  1657. .br
  1658. \fBh\fP, \fBj\fP, \fBk\fP, \fBl\fP move the cursor line by line or column by column.
  1659. .br
  1660. \fB0\fP, \fB^\fP and \fB$\fP move to the leftmost column, to the first or last
  1661. non-whitespace
  1662. character on the line.
  1663. .br
  1664. \fBH\fP, \fBM\fP and \fBL\fP move the cursor to the leftmost column
  1665. of the top, center or bottom line of the window. 
  1666. .br
  1667. \fB+\fP and \fB-\fP positions one line up and down.
  1668. .br
  1669. \fBG\fP moves to the specified absolute line (default: end of buffer).
  1670. .br 
  1671. \fB|\fP moves to the specified absolute column.
  1672. .br
  1673. \fBw\fP, \fBb\fP, \fBe\fP move the cursor word by word.
  1674. .br 
  1675. \fBC-u\fP and \fBC-d\fP scroll the display up/down by the specified amount of 
  1676. lines while preserving the cursor position. (Default: half screenfull). 
  1677. .br
  1678. \fBC-b\fP and \fBC-f\fP scroll the display up/down a full screen.
  1679. .br
  1680. \fBg\fP moves to the beginning of the buffer, whereas
  1681. .br
  1682. \fB%\fP jumps to the specified percentage.
  1683. .br
  1684. .IR Note :
  1685. Emacs style movement keys can be customized by a .screenrc command. (E.\|g.
  1686. markkeys "h=^B:l=^F:$=^E") There is no simple method for a full emacs-style
  1687. keymap, as this involves multi-character codes.
  1688. .br
  1689. .IR Marking :
  1690. .br
  1691. The copy range is specified by setting two marks. The text between these marks 
  1692. will be highlighted. Press \fBspace\fP to set the first or second mark
  1693. respectively.
  1694. .br
  1695. \fBY\fP and \fBy\fP can be used to mark one whole line or to mark from 
  1696. start of line.
  1697. .br
  1698. \fBW\fP marks exactly one word. 
  1699. .br 
  1700. .IR "Repeat count" :
  1701. .br
  1702. Any of these commands can be prefixed with a number (by pressing digits 
  1703. \fB0\fP..\fB9\fP) which
  1704. is taken as a repeat count. Example: \*QC-a C-[ H 10 j 5 Y\*U will copy lines
  1705. 11 to 15 into the pastebuffer.
  1706. .br
  1707. .IR Specials :
  1708. .br
  1709. There are however some keys that act differently here and in
  1710. .IR vi .
  1711. .I Vi
  1712. does not allow to yank rectangular blocks of text, but
  1713. .I screen
  1714. does. Press 
  1715. .br
  1716. \fBc\fP or \fBC\fP to set the left or right margin respectively. If no repeat count is
  1717. given, both default to the current cursor position. Try this on a rather 
  1718. full text screen as an example: \*QC-A [ S-M 20 l SPACE c 10 l 5 j S-C SPACE\*U.
  1719. .br
  1720. \fBJ\fP joins lines. It toggles between 
  1721. 3 modes: lines separated by a newline character (012), lines glued seamless,
  1722. lines separated by a single whitespace. Note that you can prepend the newline
  1723. character with a carriage return character, by issuing a \*Qset crlf on\*U.
  1724. .br
  1725. \fBv\fP is for all the
  1726. .I vi 
  1727. users with \*Q:set numbers\*U - it toggles the left margin between column 9
  1728. and 1.
  1729. .br
  1730. Press \fBa\fP before the final space key to toggle in append mode. Thus
  1731. the contents of the pastebuffer will not be overwritten, but appended to.
  1732. .br
  1733. \fBA\fP toggles in append mode and sets a (second) mark.
  1734. .br
  1735. \fB>\fP sets the (second) mark and writes the contents of the copybuffer to
  1736. the screen-exchange file (/tmp/screen-exchange per default) once copy-mode is 
  1737. finished. This example demonstrates how to dump the whole scrollback buffer 
  1738. to that file: \*QC-A [ g SPACE G $ >\*U.
  1739. .br
  1740. \fB?\fP gives information about the current line and column.
  1741. .IP "\fBC-a ]\fP  or  \fBC-a C-]\fP   (paste)"
  1742. Paste. Write the contents of the paste buffer to the stdin queue of the
  1743. current window.
  1744. .IP "\fBC-a {\fP   (history)"
  1745. Usually users work with a shell that allows easy access to previous commands.
  1746. E.g. csh has the command \*Q!!\*U to repeat the last command executed. 
  1747. .I Screen
  1748. allows you to have a primitive way of re-calling \*Qthe command that
  1749. started ...\*U: You just type the first letter of that command, then hit
  1750. `C-a {' and
  1751. .I screen
  1752. tries to find a previous line that matches with the `prompt character' 
  1753. to the left of the cursor. This line is pasted into this window's input queue.
  1754. Thus you have a crude command history (made up by the visible window and its
  1755. scrollback buffer). 
  1756. .IP "\fBC-a >\fP   (write_buffer)"
  1757. Writes the contents of the paste buffer to a public accessible screen-exchange
  1758. file. This is thought of as a primitive means of communication between
  1759. .I screen
  1760. users on the same host. See also \*QC-a esc\*U.
  1761. .IP "\fBC-a <\fP   (read_buffer)"
  1762. Reads the screen-exchange file into the pastebuffer. See also \*QC-a ]\*U.
  1763. .IP "\fBC-a =\fP   (kill_buffer)"
  1764. Removes the exchange file used by \*QC-a <\*U and \*QC-a >\*U.
  1765. .SH "COMMAND-LINE OPTIONS"
  1766. Screen has the following command-line options:
  1767. .TP 5
  1768. .B \-a
  1769. include \fIall\fP capabilities (with some minor exceptions) in each
  1770. window's termcap, even if
  1771. .I screen
  1772. must redraw parts of the display in order to implement a function.
  1773. .TP 5
  1774. .B "\-c \fIfile\fP"
  1775. override the default configuration file from \*Q$HOME/.screenrc\*U
  1776. to \fIfile\fP.
  1777. .TP 5
  1778. .B "\-d\fP|\fB\-D \fP[\fIpid.tty.host\fP\]\fB"
  1779. does not start
  1780. .IR screen ,
  1781. but detach the elsewhere running 
  1782. .I screen
  1783. session. It has the same effect as typing \*QC-a d\*U from 
  1784. .I screen's
  1785. controlling terminal. \fB-D\fP is the equivalent to the power detach key.
  1786. If no session can be detached, this option is ignored. 
  1787. The combination \*Qscreen -D -r\*U can be used to `transport' the elsewhere 
  1788. running session to this terminal and logout there. 
  1789. Note: It is a good idea to have the status of your sessions checked by means of
  1790. \*Qscreen -list\*U.
  1791. .TP 5
  1792. .B "\-e \fIxy\fP"
  1793. specifies the command character to be \fIx\fP and the character generating a
  1794. literal command character to \fIy\fP (when typed after the command character).
  1795. The default is \*QC-a\*U and `a', which can be specified as \*Q-e^Aa\*U.
  1796. See the \*Qescape\*U .screenrc command for more details.
  1797. .TP 5
  1798. .B "\-f\fP, \fB\-fn\fP, and \fB\-fa"
  1799. turns flow-control on, off, or \*Qautomatic switching mode\*U.
  1800. This can also be defined through the \*Qflow\*U .screenrc command.
  1801. .TP 5
  1802. .B "\-h \fInum\fP"
  1803. Specifies the history scrollback buffer to be \fInum\fP lines high.
  1804. .TP 5
  1805. .B \-i
  1806. will cause the interrupt key (usually C-c) to interrupt the display
  1807. immediately when flow-control is on.
  1808. See the \*Qflow\*U .screenrc command for details.
  1809. .TP 5
  1810. .B "\-l \fPand\fB -ln"
  1811. turns login mode on or off (for /etc/utmp updating).
  1812. This can also be defined through the \*Qlogin\*U .screenrc command.
  1813. .TP 5
  1814. .B "\-ls \fPand\fB -list"
  1815. does not start
  1816. .IR screen ,
  1817. but prints a list of
  1818. .I pid.tty.host
  1819. strings identifying your 
  1820. .I screen
  1821. sessions.
  1822. Sessions marked `detached' can be resumed with \*Qscreen -r\*U. Those marked 
  1823. `attached' are running and have a controlling terminal. Sessions marked as
  1824. `dead' should be thoroughly checked and removed. Ask your system administrator
  1825. if you are not sure. Remove sessions with the \fB-wipe\fP option.
  1826. .TP 5
  1827. .B "\-t \fIname\fP"
  1828. sets the title (a.\|k.\|a.) for the default shell or specified program.
  1829. See also the \*Qshellaka\*U .screenrc command.
  1830. .TP 5
  1831. .B "\-wipe"
  1832. does the same as \*Qscreen -ls\*U, but removes destroyed sessions instead of 
  1833. marking them as `dead'.
  1834. .TP 5
  1835. .B \-L
  1836. tells 
  1837. .I screen
  1838. your auto-margin terminal has a writable last-position on
  1839. the screen.
  1840. This can also be set in your .screenrc by specifying `LP' in a \*Qtermcap\*U
  1841. command.
  1842. .TP 5
  1843. .B \-O
  1844. selects a more optimal output mode for your terminal rather than true vt100
  1845. emulation (only affects auto-margin terminals without `LP').
  1846. This can also be set in your .screenrc by specifying `OP' in a \*Qtermcap\*U
  1847. command.
  1848. .TP 5
  1849. .B "\-r \fP[\fIpid.tty.host\fP]"
  1850. resumes a detached
  1851. .I screen
  1852. session.
  1853. No other options (except \*Q-d -r\*U or \*Q-D -r\*U) may be specified, though
  1854. an optional prefix of [\fIpid.\fP]\fItty.host\fP
  1855. may be needed to distinguish between multiple detached
  1856. .I screen
  1857. sessions.
  1858. .TP 5
  1859. .B \-R
  1860. attempts to resume the first detached 
  1861. .I screen
  1862. session it finds.
  1863. If successful, all other command-line options are ignored.
  1864. If no detached session exists, starts a new session using the specified
  1865. SHAR_EOF
  1866. true || echo 'restore of screen3.2/screen.1 failed'
  1867. fi
  1868. echo 'End of  part 4'
  1869. echo 'File screen3.2/screen.1 is continued in part 5'
  1870. echo 5 > _shar_seq_.tmp
  1871. exit 0
  1872. exit 0 # Just in case...
  1873.