home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2387 < prev    next >
SHell self-extracting ARchive  |  1990-12-28  |  19.8 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: SHell self-extracting ARchive (archive/shar).

You can browse this item here: 2387

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news or mail, ASCII text default
100% TrID E-Mail message (Var. 2) default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/rfc822 default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 3a 20 67 6f | 65 72 40 65 6c 6c 69 73 |From: go|er@ellis|
|00000010| 2e 75 63 68 69 63 61 67 | 6f 2e 65 64 75 20 28 52 |.uchicag|o.edu (R|
|00000020| 69 63 68 61 72 64 20 4c | 2e 20 47 6f 65 72 77 69 |ichard L|. Goerwi|
|00000030| 74 7a 29 0a 4e 65 77 73 | 67 72 6f 75 70 73 3a 20 |tz).News|groups: |
|00000040| 61 6c 74 2e 73 6f 75 72 | 63 65 73 0a 53 75 62 6a |alt.sour|ces.Subj|
|00000050| 65 63 74 3a 20 69 74 6c | 69 62 20 70 61 72 74 20 |ect: itl|ib part |
|00000060| 31 20 6f 66 20 33 0a 4d | 65 73 73 61 67 65 2d 49 |1 of 3.M|essage-I|
|00000070| 44 3a 20 3c 31 39 39 30 | 44 65 63 32 31 2e 30 35 |D: <1990|Dec21.05|
|00000080| 35 35 33 36 2e 32 32 35 | 30 39 40 6d 69 64 77 61 |5536.225|09@midwa|
|00000090| 79 2e 75 63 68 69 63 61 | 67 6f 2e 65 64 75 3e 0a |y.uchica|go.edu>.|
|000000a0| 44 61 74 65 3a 20 32 31 | 20 44 65 63 20 39 30 20 |Date: 21| Dec 90 |
|000000b0| 30 35 3a 35 35 3a 33 36 | 20 47 4d 54 0a 0a 48 65 |05:55:36| GMT..He|
|000000c0| 72 65 20 61 72 65 20 61 | 20 73 65 74 20 6f 66 20 |re are a| set of |
|000000d0| 74 65 72 6d 6c 69 62 2d | 6c 69 6b 65 20 72 6f 75 |termlib-|like rou|
|000000e0| 74 69 6e 65 73 20 66 6f | 72 20 49 63 6f 6e 20 70 |tines fo|r Icon p|
|000000f0| 72 6f 67 72 61 6d 6d 65 | 72 73 2e 0a 41 6e 20 4d |rogramme|rs..An M|
|00000100| 53 2d 44 4f 53 20 69 6d | 70 6c 65 6d 65 6e 74 61 |S-DOS im|plementa|
|00000110| 74 69 6f 6e 20 69 73 20 | 69 6e 63 6c 75 64 65 64 |tion is |included|
|00000120| 2e 0a 0a 2d 52 69 63 68 | 61 72 64 20 28 67 6f 65 |...-Rich|ard (goe|
|00000130| 72 40 73 6f 70 68 69 73 | 74 2e 75 63 68 69 63 61 |r@sophis|t.uchica|
|00000140| 67 6f 2e 65 64 75 29 0a | 0a 2d 2d 2d 2d 20 43 75 |go.edu).|.---- Cu|
|00000150| 74 20 48 65 72 65 20 61 | 6e 64 20 66 65 65 64 20 |t Here a|nd feed |
|00000160| 74 68 65 20 66 6f 6c 6c | 6f 77 69 6e 67 20 74 6f |the foll|owing to|
|00000170| 20 73 68 20 2d 2d 2d 2d | 0a 23 21 2f 62 69 6e 2f | sh ----|.#!/bin/|
|00000180| 73 68 0a 23 20 54 68 69 | 73 20 69 73 20 61 20 73 |sh.# Thi|s is a s|
|00000190| 68 65 6c 6c 20 61 72 63 | 68 69 76 65 20 28 70 72 |hell arc|hive (pr|
|000001a0| 6f 64 75 63 65 64 20 62 | 79 20 73 68 61 72 20 33 |oduced b|y shar 3|
|000001b0| 2e 34 39 29 0a 23 20 54 | 6f 20 65 78 74 72 61 63 |.49).# T|o extrac|
|000001c0| 74 20 74 68 65 20 66 69 | 6c 65 73 20 66 72 6f 6d |t the fi|les from|
|000001d0| 20 74 68 69 73 20 61 72 | 63 68 69 76 65 2c 20 73 | this ar|chive, s|
|000001e0| 61 76 65 20 69 74 20 74 | 6f 20 61 20 66 69 6c 65 |ave it t|o a file|
|000001f0| 2c 20 72 65 6d 6f 76 65 | 0a 23 20 65 76 65 72 79 |, remove|.# every|
|00000200| 74 68 69 6e 67 20 61 62 | 6f 76 65 20 74 68 65 20 |thing ab|ove the |
|00000210| 22 21 2f 62 69 6e 2f 73 | 68 22 20 6c 69 6e 65 20 |"!/bin/s|h" line |
|00000220| 61 62 6f 76 65 2c 20 61 | 6e 64 20 74 79 70 65 20 |above, a|nd type |
|00000230| 22 73 68 20 66 69 6c 65 | 5f 6e 61 6d 65 22 2e 0a |"sh file|_name"..|
|00000240| 23 0a 23 20 6d 61 64 65 | 20 31 32 2f 31 37 2f 31 |#.# made| 12/17/1|
|00000250| 39 39 30 20 31 36 3a 35 | 30 20 55 54 43 20 62 79 |990 16:5|0 UTC by|
|00000260| 20 67 6f 65 72 40 73 6f | 70 68 69 73 74 2e 75 63 | goer@so|phist.uc|
|00000270| 68 69 63 61 67 6f 2e 65 | 64 75 0a 23 20 53 6f 75 |hicago.e|du.# Sou|
|00000280| 72 63 65 20 64 69 72 65 | 63 74 6f 72 79 20 2f 75 |rce dire|ctory /u|
|00000290| 2f 72 69 63 68 61 72 64 | 2f 49 74 65 72 6d 6c 69 |/richard|/Itermli|
|000002a0| 62 0a 23 0a 23 20 65 78 | 69 73 74 69 6e 67 20 66 |b.#.# ex|isting f|
|000002b0| 69 6c 65 73 20 77 69 6c | 6c 20 4e 4f 54 20 62 65 |iles wil|l NOT be|
|000002c0| 20 6f 76 65 72 77 72 69 | 74 74 65 6e 20 75 6e 6c | overwri|tten unl|
|000002d0| 65 73 73 20 2d 63 20 69 | 73 20 73 70 65 63 69 66 |ess -c i|s specif|
|000002e0| 69 65 64 0a 23 20 54 68 | 69 73 20 66 6f 72 6d 61 |ied.# Th|is forma|
|000002f0| 74 20 72 65 71 75 69 72 | 65 73 20 76 65 72 79 20 |t requir|es very |
|00000300| 6c 69 74 74 6c 65 20 69 | 6e 74 65 6c 6c 69 67 65 |little i|ntellige|
|00000310| 6e 63 65 20 61 74 20 75 | 6e 73 68 61 72 20 74 69 |nce at u|nshar ti|
|00000320| 6d 65 2e 0a 23 20 22 69 | 66 20 74 65 73 74 22 2c |me..# "i|f test",|
|00000330| 20 22 63 61 74 22 2c 20 | 22 72 6d 22 2c 20 22 65 | "cat", |"rm", "e|
|00000340| 63 68 6f 22 2c 20 22 74 | 72 75 65 22 2c 20 61 6e |cho", "t|rue", an|
|00000350| 64 20 22 73 65 64 22 20 | 6d 61 79 20 62 65 20 6e |d "sed" |may be n|
|00000360| 65 65 64 65 64 2e 0a 23 | 0a 23 20 54 68 69 73 20 |eeded..#|.# This |
|00000370| 69 73 20 70 61 72 74 20 | 31 20 6f 66 20 61 20 6d |is part |1 of a m|
|00000380| 75 6c 74 69 70 61 72 74 | 20 61 72 63 68 69 76 65 |ultipart| archive|
|00000390| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000003a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000003b0| 20 20 20 20 0a 23 20 64 | 6f 20 6e 6f 74 20 63 6f | .# d|o not co|
|000003c0| 6e 63 61 74 65 6e 61 74 | 65 20 74 68 65 73 65 20 |ncatenat|e these |
|000003d0| 70 61 72 74 73 2c 20 75 | 6e 70 61 63 6b 20 74 68 |parts, u|npack th|
|000003e0| 65 6d 20 69 6e 20 6f 72 | 64 65 72 20 77 69 74 68 |em in or|der with|
|000003f0| 20 2f 62 69 6e 2f 73 68 | 20 20 20 20 20 20 20 20 | /bin/sh| |
|00000400| 0a 23 0a 23 20 54 68 69 | 73 20 73 68 61 72 20 63 |.#.# Thi|s shar c|
|00000410| 6f 6e 74 61 69 6e 73 3a | 0a 23 20 6c 65 6e 67 74 |ontains:|.# lengt|
|00000420| 68 20 20 6d 6f 64 65 20 | 20 20 20 20 20 20 6e 61 |h mode | na|
|00000430| 6d 65 0a 23 20 2d 2d 2d | 2d 2d 2d 20 2d 2d 2d 2d |me.# ---|--- ----|
|00000440| 2d 2d 2d 2d 2d 2d 20 2d | 2d 2d 2d 2d 2d 2d 2d 2d |------ -|--------|
|00000450| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000460| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000470| 2d 0a 23 20 20 20 38 35 | 33 38 20 2d 72 2d 2d 72 |-.# 85|38 -r--r|
|00000480| 2d 2d 72 2d 2d 20 67 65 | 74 63 68 6c 69 62 2e 69 |--r-- ge|tchlib.i|
|00000490| 63 6e 0a 23 20 20 31 32 | 32 34 30 20 2d 72 2d 2d |cn.# 12|240 -r--|
|000004a0| 72 2d 2d 72 2d 2d 20 69 | 74 6c 69 62 2e 69 63 6e |r--r-- i|tlib.icn|
|000004b0| 0a 23 20 20 20 34 34 31 | 38 20 2d 72 2d 2d 72 2d |.# 441|8 -r--r-|
|000004c0| 2d 72 2d 2d 20 69 73 63 | 72 65 65 6e 2e 69 63 6e |-r-- isc|reen.icn|
|000004d0| 0a 23 20 20 31 34 35 38 | 36 20 2d 72 2d 2d 72 2d |.# 1458|6 -r--r-|
|000004e0| 2d 72 2d 2d 20 69 74 6c | 69 62 64 6f 73 2e 69 63 |-r-- itl|ibdos.ic|
|000004f0| 6e 0a 23 20 20 20 32 33 | 39 31 20 2d 72 2d 2d 72 |n.# 23|91 -r--r|
|00000500| 2d 2d 72 2d 2d 20 74 65 | 72 6d 63 61 70 2e 64 6f |--r-- te|rmcap.do|
|00000510| 73 0a 23 0a 69 66 20 74 | 65 73 74 20 2d 72 20 5f |s.#.if t|est -r _|
|00000520| 73 68 61 72 5f 73 65 71 | 5f 2e 74 6d 70 3b 20 74 |shar_seq|_.tmp; t|
|00000530| 68 65 6e 0a 09 65 63 68 | 6f 20 27 4d 75 73 74 20 |hen..ech|o 'Must |
|00000540| 75 6e 70 61 63 6b 20 61 | 72 63 68 69 76 65 73 20 |unpack a|rchives |
|00000550| 69 6e 20 73 65 71 75 65 | 6e 63 65 21 27 0a 09 65 |in seque|nce!'..e|
|00000560| 63 68 6f 20 50 6c 65 61 | 73 65 20 75 6e 70 61 63 |cho Plea|se unpac|
|00000570| 6b 20 70 61 72 74 20 60 | 63 61 74 20 5f 73 68 61 |k part `|cat _sha|
|00000580| 72 5f 73 65 71 5f 2e 74 | 6d 70 60 20 6e 65 78 74 |r_seq_.t|mp` next|
|00000590| 0a 09 65 78 69 74 20 31 | 0a 66 69 0a 23 20 3d 3d |..exit 1|.fi.# ==|
|000005a0| 3d 3d 3d 3d 3d 3d 3d 3d | 3d 3d 3d 20 67 65 74 63 |========|=== getc|
|000005b0| 68 6c 69 62 2e 69 63 6e | 20 3d 3d 3d 3d 3d 3d 3d |hlib.icn| =======|
|000005c0| 3d 3d 3d 3d 3d 3d 3d 0a | 69 66 20 74 65 73 74 20 |=======.|if test |
|000005d0| 2d 66 20 27 67 65 74 63 | 68 6c 69 62 2e 69 63 6e |-f 'getc|hlib.icn|
|000005e0| 27 20 2d 61 20 58 22 24 | 31 22 20 21 3d 20 58 22 |' -a X"$|1" != X"|
|000005f0| 2d 63 22 3b 20 74 68 65 | 6e 0a 09 65 63 68 6f 20 |-c"; the|n..echo |
|00000600| 27 78 20 2d 20 73 6b 69 | 70 70 69 6e 67 20 67 65 |'x - ski|pping ge|
|00000610| 74 63 68 6c 69 62 2e 69 | 63 6e 20 28 46 69 6c 65 |tchlib.i|cn (File|
|00000620| 20 61 6c 72 65 61 64 79 | 20 65 78 69 73 74 73 29 | already| exists)|
|00000630| 27 0a 09 72 6d 20 2d 66 | 20 5f 73 68 61 72 5f 77 |'..rm -f| _shar_w|
|00000640| 6e 74 5f 2e 74 6d 70 0a | 65 6c 73 65 0a 3e 20 5f |nt_.tmp.|else.> _|
|00000650| 73 68 61 72 5f 77 6e 74 | 5f 2e 74 6d 70 0a 65 63 |shar_wnt|_.tmp.ec|
|00000660| 68 6f 20 27 78 20 2d 20 | 65 78 74 72 61 63 74 69 |ho 'x - |extracti|
|00000670| 6e 67 20 67 65 74 63 68 | 6c 69 62 2e 69 63 6e 20 |ng getch|lib.icn |
|00000680| 28 54 65 78 74 29 27 0a | 73 65 64 20 27 73 2f 5e |(Text)'.|sed 's/^|
|00000690| 58 2f 2f 27 20 3c 3c 20 | 27 53 48 41 52 5f 45 4f |X//' << |'SHAR_EO|
|000006a0| 46 27 20 3e 20 27 67 65 | 74 63 68 6c 69 62 2e 69 |F' > 'ge|tchlib.i|
|000006b0| 63 6e 27 20 26 26 0a 58 | 23 23 23 23 23 23 23 23 |cn' &&.X|########|
|000006c0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|000006d0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|000006e0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|000006f0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00000700| 23 23 23 23 0a 58 23 0a | 58 23 09 4e 61 6d 65 3a |####.X#.|X#.Name:|
|00000710| 09 20 67 65 74 63 68 6c | 69 62 2e 69 63 6e 0a 58 |. getchl|ib.icn.X|
|00000720| 23 0a 58 23 09 54 69 74 | 6c 65 3a 09 20 49 6d 70 |#.X#.Tit|le:. Imp|
|00000730| 6c 65 6d 65 6e 74 61 74 | 69 6f 6e 20 6f 66 20 67 |lementat|ion of g|
|00000740| 65 74 63 68 28 29 20 66 | 6f 72 20 55 6e 69 78 20 |etch() f|or Unix |
|00000750| 28 61 6e 64 20 6d 6f 72 | 65 29 0a 58 23 0a 58 23 |(and mor|e).X#.X#|
|00000760| 09 41 75 74 68 6f 72 3a | 09 20 52 69 63 68 61 72 |.Author:|. Richar|
|00000770| 64 20 4c 2e 20 47 6f 65 | 72 77 69 74 7a 0a 58 23 |d L. Goe|rwitz.X#|
|00000780| 0a 58 23 09 56 65 72 73 | 69 6f 6e 3a 20 31 2e 31 |.X#.Vers|ion: 1.1|
|00000790| 31 0a 58 23 0a 58 23 23 | 23 23 23 23 23 23 23 23 |1.X#.X##|########|
|000007a0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|000007b0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|000007c0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|000007d0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|000007e0| 23 23 0a 58 23 0a 58 23 | 20 20 49 20 70 6c 61 63 |##.X#.X#| I plac|
|000007f0| 65 20 74 68 69 73 20 61 | 6e 64 20 66 75 74 75 72 |e this a|nd futur|
|00000800| 65 20 76 65 72 73 69 6f | 6e 73 20 6f 66 20 67 65 |e versio|ns of ge|
|00000810| 74 63 68 6c 69 62 20 69 | 6e 20 74 68 65 20 70 75 |tchlib i|n the pu|
|00000820| 62 6c 69 63 20 64 6f 6d | 61 69 6e 20 2d 20 52 4c |blic dom|ain - RL|
|00000830| 47 0a 58 23 0a 58 23 23 | 23 23 23 23 23 23 23 23 |G.X#.X##|########|
|00000840| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00000850| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00000860| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00000870| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00000880| 23 23 0a 58 23 0a 58 23 | 20 20 49 6d 70 6c 65 6d |##.X#.X#| Implem|
|00000890| 65 6e 74 69 6e 67 20 67 | 65 74 63 68 28 29 20 69 |enting g|etch() i|
|000008a0| 73 20 61 20 6d 75 63 68 | 2c 20 6d 75 63 68 20 6d |s a much|, much m|
|000008b0| 6f 72 65 20 63 6f 6d 70 | 6c 65 78 20 61 66 66 61 |ore comp|lex affa|
|000008c0| 69 72 20 75 6e 64 65 72 | 20 55 6e 69 78 0a 58 23 |ir under| Unix.X#|
|000008d0| 20 20 74 68 61 6e 20 69 | 74 20 69 73 20 75 6e 64 | than i|t is und|
|000008e0| 65 72 2c 20 73 61 79 2c | 20 4d 53 2d 44 4f 53 2e |er, say,| MS-DOS.|
|000008f0| 20 20 54 68 69 73 20 6c | 69 62 72 61 72 79 20 72 | This l|ibrary r|
|00000900| 65 70 72 65 73 65 6e 74 | 73 20 6f 6e 65 2c 0a 58 |epresent|s one,.X|
|00000910| 23 20 20 73 6f 6c 75 74 | 69 6f 6e 20 74 6f 20 74 |# solut|ion to t|
|00000920| 68 65 20 70 72 6f 62 6c | 65 6d 20 2d 20 6f 6e 65 |he probl|em - one|
|00000930| 20 77 68 69 63 68 20 63 | 61 6e 20 62 65 20 72 75 | which c|an be ru|
|00000940| 6e 20 61 73 20 61 20 6c | 69 62 72 61 72 79 2c 20 |n as a l|ibrary, |
|00000950| 61 6e 64 0a 58 23 20 20 | 6e 65 65 64 20 6e 6f 74 |and.X# |need not|
|00000960| 20 62 65 20 63 6f 6d 70 | 69 6c 65 64 20 69 6e 74 | be comp|iled int|
|00000970| 6f 20 74 68 65 20 72 75 | 6e 2d 74 69 6d 65 20 73 |o the ru|n-time s|
|00000980| 79 73 74 65 6d 2e 0a 58 | 23 0a 58 23 20 20 46 6f |ystem..X|#.X# Fo|
|00000990| 75 72 20 62 61 73 69 63 | 20 75 74 69 6c 69 74 69 |ur basic| utiliti|
|000009a0| 65 73 20 61 72 65 20 69 | 6e 63 6c 75 64 65 64 20 |es are i|ncluded |
|000009b0| 68 65 72 65 3a 0a 58 23 | 0a 58 23 09 67 65 74 63 |here:.X#|.X#.getc|
|000009c0| 68 28 29 09 09 2d 20 77 | 61 69 74 73 20 75 6e 74 |h()..- w|aits unt|
|000009d0| 69 6c 20 61 20 6b 65 79 | 73 74 72 6f 6b 65 20 69 |il a key|stroke i|
|000009e0| 73 20 61 76 61 69 6c 61 | 62 6c 65 20 26 0a 58 23 |s availa|ble &.X#|
|000009f0| 09 20 20 20 20 72 65 74 | 75 72 6e 73 20 69 74 20 |. ret|urns it |
|00000a00| 77 69 74 68 6f 75 74 20 | 64 69 73 70 6c 61 79 69 |without |displayi|
|00000a10| 6e 67 20 69 74 20 6f 6e | 20 74 68 65 20 73 63 72 |ng it on| the scr|
|00000a20| 65 65 6e 0a 58 23 09 67 | 65 74 63 68 65 28 29 09 |een.X#.g|etche().|
|00000a30| 2d 20 73 61 6d 65 20 61 | 73 20 67 65 74 63 68 28 |- same a|s getch(|
|00000a40| 29 20 6f 6e 6c 79 20 77 | 69 74 68 20 65 63 68 6f |) only w|ith echo|
|00000a50| 0a 58 23 09 67 65 74 73 | 65 28 73 29 09 2d 20 6c |.X#.gets|e(s).- l|
|00000a60| 69 6b 65 20 67 65 74 63 | 68 65 28 29 20 6f 6e 6c |ike getc|he() onl|
|00000a70| 79 20 66 6f 72 20 73 74 | 72 69 6e 67 73 2e 20 20 |y for st|rings. |
|00000a80| 54 68 65 20 6f 70 74 69 | 6f 6e 61 6c 0a 58 23 09 |The opti|onal.X#.|
|00000a90| 20 20 20 20 61 72 67 75 | 6d 65 6e 74 20 73 20 67 | argu|ment s g|
|00000aa0| 69 76 65 73 20 67 65 74 | 73 65 28 29 20 73 6f 6d |ives get|se() som|
|00000ab0| 65 74 68 69 6e 67 20 74 | 6f 20 73 74 61 72 74 20 |ething t|o start |
|00000ac0| 77 69 74 68 2e 20 20 55 | 73 65 20 74 68 69 73 0a |with. U|se this.|
|00000ad0| 58 23 20 20 20 20 20 20 | 20 20 20 20 20 69 66 2c |X# | if,|
|00000ae0| 20 73 61 79 2c 20 79 6f | 75 20 77 61 6e 74 20 74 | say, yo|u want t|
|00000af0| 6f 20 72 65 61 64 20 73 | 69 6e 67 6c 65 20 63 68 |o read s|ingle ch|
|00000b00| 61 72 61 63 74 65 72 73 | 20 69 6e 20 63 62 72 65 |aracters| in cbre|
|00000b10| 61 6b 20 6d 6f 64 65 2c | 0a 58 23 20 20 20 20 20 |ak mode,|.X# |
|00000b20| 20 20 20 20 20 20 62 75 | 74 20 67 65 74 20 6d 6f | bu|t get mo|
|00000b30| 72 65 20 69 6e 70 75 74 | 20 69 66 20 74 68 65 20 |re input| if the |
|00000b40| 63 68 61 72 61 63 74 65 | 72 20 72 65 61 64 20 69 |characte|r read i|
|00000b50| 73 20 74 68 65 20 66 69 | 72 73 74 20 70 61 72 74 |s the fi|rst part|
|00000b60| 0a 58 23 20 20 20 20 20 | 20 20 20 20 20 20 6f 66 |.X# | of|
|00000b70| 20 61 20 6c 6f 6e 67 65 | 72 20 63 6f 6d 6d 61 6e | a longe|r comman|
|00000b80| 64 2e 20 20 49 66 20 74 | 68 65 20 75 73 65 72 20 |d. If t|he user |
|00000b90| 62 61 63 6b 73 70 61 63 | 65 73 20 6f 76 65 72 20 |backspac|es over |
|00000ba0| 65 76 65 72 79 74 68 69 | 6e 67 0a 58 23 20 20 20 |everythi|ng.X# |
|00000bb0| 20 20 20 20 20 20 20 20 | 74 68 61 74 20 68 61 73 | |that has|
|00000bc0| 20 62 65 65 6e 20 69 6e | 70 75 74 2c 20 67 65 74 | been in|put, get|
|00000bd0| 73 65 28 29 20 66 61 69 | 6c 73 2e 20 20 52 65 74 |se() fai|ls. Ret|
|00000be0| 75 72 6e 73 20 6f 6e 20 | 5c 72 20 6f 72 20 5c 6e |urns on |\r or \n|
|00000bf0| 2e 0a 58 23 09 72 65 73 | 65 74 5f 74 74 79 28 29 |..X#.res|et_tty()|
|00000c00| 09 2d 20 61 62 73 6f 6c | 75 74 65 6c 79 20 76 69 |.- absol|utely vi|
|00000c10| 74 61 6c 20 72 6f 75 74 | 69 6e 65 20 66 6f 72 20 |tal rout|ine for |
|00000c20| 70 75 74 74 69 6e 67 20 | 74 68 65 20 63 75 72 2d |putting |the cur-|
|00000c30| 0a 58 23 20 20 20 20 20 | 20 20 20 20 20 20 72 65 |.X# | re|
|00000c40| 6e 74 20 74 74 79 20 6c | 69 6e 65 20 62 61 63 6b |nt tty l|ine back|
|00000c50| 20 69 6e 74 6f 20 63 6f | 6f 6b 65 64 20 6d 6f 64 | into co|oked mod|
|00000c60| 65 3b 20 63 61 6c 6c 20 | 69 74 20 62 65 66 6f 72 |e; call |it befor|
|00000c70| 65 20 65 78 69 74 69 6e | 67 0a 58 23 20 20 20 20 |e exitin|g.X# |
|00000c80| 20 20 20 20 20 20 20 6f | 72 20 79 6f 75 20 77 69 | o|r you wi|
|00000c90| 6c 6c 20 66 69 6e 64 20 | 79 6f 75 72 73 65 6c 66 |ll find |yourself|
|00000ca0| 20 77 69 74 68 20 61 20 | 6c 6f 63 6b 65 64 2d 75 | with a |locked-u|
|00000cb0| 70 20 74 65 72 6d 69 6e | 61 6c 3b 20 75 73 65 20 |p termin|al; use |
|00000cc0| 69 74 0a 58 23 20 20 20 | 20 20 20 20 20 20 20 20 |it.X# | |
|00000cd0| 61 6c 73 6f 20 69 66 20 | 79 6f 75 20 6d 75 73 74 |also if |you must|
|00000ce0| 20 74 65 6d 70 6f 72 61 | 72 69 6c 79 20 72 65 73 | tempora|rily res|
|00000cf0| 74 6f 72 65 20 74 68 65 | 20 74 65 72 6d 69 6e 61 |tore the| termina|
|00000d00| 6c 20 74 6f 20 63 6f 6f | 6b 65 64 0a 58 23 20 20 |l to coo|ked.X# |
|00000d10| 20 20 20 20 20 20 20 20 | 20 6d 6f 64 65 0a 58 23 | | mode.X#|
|00000d20| 0a 58 23 20 20 4e 6f 74 | 65 20 74 68 61 74 20 67 |.X# Not|e that g|
|00000d30| 65 74 73 65 28 29 20 2a | 6d 75 73 74 2a 20 62 65 |etse() *|must* be|
|00000d40| 20 75 73 65 64 20 69 6e | 20 70 6c 61 63 65 20 6f | used in| place o|
|00000d50| 66 20 72 65 61 64 28 26 | 69 6e 70 75 74 29 20 69 |f read(&|input) i|
|00000d60| 66 20 79 6f 75 0a 58 23 | 20 20 61 72 65 20 70 6c |f you.X#| are pl|
|00000d70| 61 6e 6e 69 6e 67 20 6f | 6e 20 75 73 69 6e 67 20 |anning o|n using |
|00000d80| 67 65 74 63 68 28 29 20 | 6f 72 20 67 65 74 63 68 |getch() |or getch|
|00000d90| 65 28 29 2c 20 73 69 6e | 63 65 20 72 65 61 64 28 |e(), sin|ce read(|
|00000da0| 26 69 6e 70 75 74 29 0a | 58 23 20 20 61 73 73 75 |&input).|X# assu|
|00000db0| 6d 65 73 20 61 20 74 74 | 79 20 77 69 74 68 20 22 |mes a tt|y with "|
|00000dc0| 73 61 6e 65 22 20 73 65 | 74 74 69 6e 67 73 2e 0a |sane" se|ttings..|
|00000dd0| 58 23 0a 58 23 20 20 57 | 61 72 6e 69 6e 67 3a 20 |X#.X# W|arning: |
|00000de0| 20 54 68 65 20 72 6f 75 | 74 69 6e 65 73 20 62 65 | The rou|tines be|
|00000df0| 6c 6f 77 20 64 6f 20 6e | 6f 74 20 64 6f 20 61 6e |low do n|ot do an|
|00000e00| 79 20 73 6f 70 68 69 73 | 74 69 63 61 74 65 64 20 |y sophis|ticated |
|00000e10| 6f 75 74 70 75 74 0a 58 | 23 20 20 70 72 6f 63 65 |output.X|# proce|
|00000e20| 73 73 69 6e 67 2e 20 20 | 41 73 20 6e 6f 74 65 64 |ssing. |As noted|
|00000e30| 20 61 62 6f 76 65 2c 20 | 74 68 65 79 20 61 6c 73 | above, |they als|
|00000e40| 6f 20 70 75 74 20 79 6f | 75 72 20 74 74 79 20 6c |o put yo|ur tty l|
|00000e50| 69 6e 65 20 69 6e 20 72 | 61 77 0a 58 23 20 20 6d |ine in r|aw.X# m|
|00000e60| 6f 64 65 2e 20 20 49 20 | 6b 6e 6f 77 2c 20 49 20 |ode. I |know, I |
|00000e70| 6b 6e 6f 77 3a 20 20 22 | 52 61 77 20 69 73 20 6f |know: "|Raw is o|
|00000e80| 76 65 72 6b 69 6c 6c 20 | 2d 20 75 73 65 20 63 62 |verkill |- use cb|
|00000e90| 72 65 61 6b 2e 22 20 20 | 42 75 74 20 69 6e 0a 58 |reak." |But in.X|
|00000ea0| 23 20 20 61 20 77 6f 72 | 6c 64 20 74 68 61 74 20 |# a wor|ld that |
|00000eb0| 69 6e 63 6c 75 64 65 73 | 20 53 79 73 56 2c 20 6f |includes| SysV, o|
|00000ec0| 6e 65 20 6d 75 73 74 20 | 70 69 63 6b 20 61 20 6c |ne must |pick a l|
|00000ed0| 6f 77 65 73 74 20 63 6f | 6d 6d 6f 6e 20 64 65 6e |owest co|mmon den|
|00000ee0| 6f 6d 69 2d 0a 58 23 20 | 20 6e 61 74 6f 72 2e 20 |omi-.X# | nator. |
|00000ef0| 20 41 6e 64 20 6e 6f 2c | 20 69 63 61 6e 6f 6e 20 | And no,| icanon |
|00000f00| 21 3d 20 63 62 72 65 61 | 6b 2e 0a 58 23 0a 58 23 |!= cbrea|k..X#.X#|
|00000f10| 20 20 42 75 67 73 3a 20 | 20 54 68 65 73 65 20 72 | Bugs: | These r|
|00000f20| 6f 75 74 69 6e 65 73 20 | 77 69 6c 6c 20 6e 6f 74 |outines |will not|
|00000f30| 20 77 6f 72 6b 20 6f 6e | 20 73 79 73 74 65 6d 73 | work on| systems|
|00000f40| 20 74 68 61 74 20 64 6f | 20 6e 6f 74 20 69 6d 70 | that do| not imp|
|00000f50| 6c 65 2d 0a 58 23 20 20 | 6d 65 6e 74 20 74 68 65 |le-.X# |ment the|
|00000f60| 20 2d 67 20 6f 70 74 69 | 6f 6e 20 66 6f 72 20 74 | -g opti|on for t|
|00000f70| 68 65 20 73 74 74 79 20 | 63 6f 6d 6d 61 6e 64 2e |he stty |command.|
|00000f80| 20 20 54 68 65 20 4e 65 | 58 54 20 77 6f 72 6b 73 | The Ne|XT works|
|00000f90| 74 61 74 69 6f 6e 20 69 | 73 0a 58 23 20 20 61 6e |tation i|s.X# an|
|00000fa0| 20 65 78 61 6d 70 6c 65 | 20 6f 66 20 73 75 63 68 | example| of such|
|00000fb0| 20 61 20 73 79 73 74 65 | 6d 2e 20 20 54 69 73 6b | a syste|m. Tisk|
|00000fc0| 2c 20 74 69 73 6b 2e 0a | 58 23 0a 58 23 23 23 23 |, tisk..|X#.X####|
|00000fd0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00000fe0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00000ff0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00001000| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00001010| 23 23 23 23 23 23 23 23 | 0a 58 23 0a 58 23 20 20 |########|.X#.X# |
|00001020| 45 78 61 6d 70 6c 65 20 | 70 72 6f 67 72 61 6d 3a |Example |program:|
|00001030| 0a 58 23 0a 58 23 20 20 | 20 20 20 20 54 68 65 20 |.X#.X# | The |
|00001040| 66 6f 6c 6c 6f 77 69 6e | 67 20 70 72 6f 67 72 61 |followin|g progra|
|00001050| 6d 20 69 73 20 61 20 73 | 69 6d 70 6c 65 20 66 69 |m is a s|imple fi|
|00001060| 6c 65 20 76 69 65 77 65 | 72 2e 20 20 54 6f 20 72 |le viewe|r. To r|
|00001070| 75 6e 2c 20 69 74 0a 58 | 23 20 20 6e 65 65 64 73 |un, it.X|# needs|
|00001080| 20 74 6f 20 62 65 20 6c | 69 6e 6b 65 64 20 77 69 | to be l|inked wi|
|00001090| 74 68 20 69 74 6c 69 62 | 2e 69 63 6e 2c 20 69 73 |th itlib|.icn, is|
|000010a0| 63 72 65 65 6e 2e 69 63 | 6e 2c 20 61 6e 64 20 74 |creen.ic|n, and t|
|000010b0| 68 69 73 20 66 69 6c 65 | 0a 58 23 20 20 28 67 65 |his file|.X# (ge|
|000010c0| 74 63 68 6c 69 62 2e 69 | 63 6e 29 2e 0a 58 23 0a |tchlib.i|cn)..X#.|
|000010d0| 58 23 20 20 70 72 6f 63 | 65 64 75 72 65 20 6d 61 |X# proc|edure ma|
|000010e0| 69 6e 28 61 29 0a 58 23 | 0a 58 23 20 20 20 20 20 |in(a).X#|.X# |
|000010f0| 20 23 20 53 69 6d 70 6c | 65 20 70 61 67 65 72 2f | # Simpl|e pager/|
|00001100| 66 69 6c 65 20 73 65 61 | 72 63 68 65 72 20 66 6f |file sea|rcher fo|
|00001110| 72 20 55 6e 69 78 20 73 | 79 73 74 65 6d 73 2e 20 |r Unix s|ystems. |
|00001120| 20 4d 75 73 74 20 62 65 | 20 6c 69 6e 6b 65 64 0a | Must be| linked.|
|00001130| 58 23 20 20 20 20 20 20 | 23 20 77 69 74 68 20 69 |X# |# with i|
|00001140| 74 6c 69 62 2e 69 63 6e | 20 61 6e 64 20 69 73 63 |tlib.icn| and isc|
|00001150| 72 65 65 6e 2e 69 63 6e | 2e 0a 58 23 20 20 0a 58 |reen.icn|..X# .X|
|00001160| 23 20 20 20 20 20 20 6c | 6f 63 61 6c 20 69 6e 74 |# l|ocal int|
|00001170| 65 78 74 2c 20 63 2c 20 | 73 0a 58 23 20 20 0a 58 |ext, c, |s.X# .X|
|00001180| 23 20 20 20 20 20 20 23 | 20 4f 70 65 6e 20 69 6e |# #| Open in|
|00001190| 70 75 74 20 66 69 6c 65 | 0a 58 23 20 20 20 20 20 |put file|.X# |
|000011a0| 20 69 6e 74 65 78 74 20 | 3a 3d 20 6f 70 65 6e 28 | intext |:= open(|
|000011b0| 61 5b 31 5d 2c 22 72 22 | 29 20 7c 20 7b 0a 58 23 |a[1],"r"|) | {.X#|
|000011c0| 20 20 09 77 72 69 74 65 | 28 26 65 72 72 6f 75 74 | .write|(&errout|
|000011d0| 2c 22 43 61 6e 27 74 20 | 6f 70 65 6e 20 69 6e 70 |,"Can't |open inp|
|000011e0| 75 74 20 66 69 6c 65 2e | 22 29 0a 58 23 20 20 09 |ut file.|").X# .|
|000011f0| 65 78 69 74 28 31 29 0a | 58 23 20 20 20 20 20 20 |exit(1).|X# |
|00001200| 7d 0a 58 23 20 20 0a 58 | 23 20 20 20 20 20 20 23 |}.X# .X|# #|
|00001210| 20 49 6e 69 74 69 61 6c | 69 7a 65 20 73 63 72 65 | Initial|ize scre|
|00001220| 65 6e 0a 58 23 20 20 20 | 20 20 20 63 6c 65 61 72 |en.X# | clear|
|00001230| 28 29 0a 58 23 20 20 20 | 20 20 20 70 72 69 6e 74 |().X# | print|
|00001240| 5f 73 63 72 65 65 6e 28 | 69 6e 74 65 78 74 29 20 |_screen(|intext) |
|00001250| 7c 20 65 78 69 74 28 30 | 29 0a 58 23 20 20 0a 58 || exit(0|).X# .X|
|00001260| 23 20 20 20 20 20 20 23 | 20 50 72 6f 6d 70 74 20 |# #| Prompt |
|00001270| 26 20 72 65 61 64 20 69 | 6e 70 75 74 0a 58 23 20 |& read i|nput.X# |
|00001280| 20 20 20 20 20 72 65 70 | 65 61 74 20 7b 0a 58 23 | rep|eat {.X#|
|00001290| 20 20 09 69 70 75 74 73 | 28 69 67 6f 74 6f 28 67 | .iputs|(igoto(g|
|000012a0| 65 74 76 61 6c 28 22 63 | 6d 22 29 2c 20 31 2c 20 |etval("c|m"), 1, |
|000012b0| 67 65 74 76 61 6c 28 22 | 6c 69 22 29 29 29 0a 58 |getval("|li"))).X|
|000012c0| 23 20 20 09 65 6d 70 68 | 61 73 69 7a 65 28 29 0a |# .emph|asize().|
|000012d0| 58 23 20 20 09 77 72 69 | 74 65 73 28 22 4d 6f 72 |X# .wri|tes("Mor|
|000012e0| 65 3f 20 28 79 2f 6e 20 | 6f 72 20 2f 73 65 61 72 |e? (y/n |or /sear|
|000012f0| 63 68 29 3a 22 29 0a 58 | 23 20 20 09 77 72 69 74 |ch):").X|# .writ|
|00001300| 65 5f 63 65 28 22 20 22 | 29 0a 58 23 20 20 09 63 |e_ce(" "|).X# .c|
|00001310| 61 73 65 20 63 20 3a 3d | 20 67 65 74 63 68 65 28 |ase c :=| getche(|
|00001320| 29 20 6f 66 20 7b 0a 58 | 23 20 20 09 20 20 20 20 |) of {.X|# . |
|00001330| 22 79 22 20 3a 20 70 72 | 69 6e 74 5f 73 63 72 65 |"y" : pr|int_scre|
|00001340| 65 6e 28 69 6e 74 65 78 | 74 29 20 7c 20 62 72 65 |en(intex|t) | bre|
|00001350| 61 6b 0a 58 23 20 20 09 | 20 20 20 20 22 20 22 20 |ak.X# .| " " |
|00001360| 3a 20 70 72 69 6e 74 5f | 73 63 72 65 65 6e 28 69 |: print_|screen(i|
|00001370| 6e 74 65 78 74 29 20 7c | 20 62 72 65 61 6b 0a 58 |ntext) || break.X|
|00001380| 23 20 20 09 20 20 20 20 | 22 6e 22 20 3a 20 62 72 |# . |"n" : br|
|00001390| 65 61 6b 0a 58 23 20 20 | 09 20 20 20 20 22 71 22 |eak.X# |. "q"|
|000013a0| 20 3a 20 62 72 65 61 6b | 0a 58 23 20 20 09 20 20 | : break|.X# . |
|000013b0| 20 20 22 2f 22 20 3a 20 | 7b 0a 58 23 20 20 09 09 | "/" : |{.X# ..|
|000013c0| 69 70 75 74 73 28 69 67 | 6f 74 6f 28 67 65 74 76 |iputs(ig|oto(getv|
|000013d0| 61 6c 28 22 63 6d 22 29 | 2c 20 31 2c 20 67 65 74 |al("cm")|, 1, get|
|000013e0| 76 61 6c 28 22 6c 69 22 | 29 29 29 0a 58 23 20 20 |val("li"|))).X# |
|000013f0| 09 09 65 6d 70 68 61 73 | 69 7a 65 28 29 0a 58 23 |..emphas|ize().X#|
|00001400| 20 20 09 09 77 72 69 74 | 65 73 28 22 45 6e 74 65 | ..writ|es("Ente|
|00001410| 72 20 73 65 61 72 63 68 | 20 73 74 72 69 6e 67 3a |r search| string:|
|00001420| 22 29 0a 58 23 20 20 09 | 09 77 72 69 74 65 5f 63 |").X# .|.write_c|
|00001430| 65 28 22 20 22 29 0a 58 | 23 20 20 09 09 70 61 74 |e(" ").X|# ..pat|
|00001440| 74 65 72 6e 20 3a 3d 20 | 47 65 74 4d 6f 72 65 49 |tern := |GetMoreI|
|00001450| 6e 70 75 74 28 29 0a 58 | 23 20 20 09 09 2f 70 61 |nput().X|# ../pa|
|00001460| 74 74 65 72 6e 20 7c 20 | 22 22 20 3d 3d 20 70 61 |ttern | |"" == pa|
|00001470| 74 74 65 72 6e 20 26 20 | 6e 65 78 74 0a 58 23 20 |ttern & |next.X# |
|00001480| 20 09 09 23 20 46 6f 72 | 20 6d 6f 72 65 20 63 6f | ..# For| more co|
|00001490| 6d 70 6c 65 78 20 70 61 | 74 74 65 72 6e 73 2c 20 |mplex pa|tterns, |
|000014a0| 75 73 65 20 66 69 6e 64 | 72 65 28 29 20 28 49 50 |use find|re() (IP|
|000014b0| 4c 20 66 69 6e 64 72 65 | 2e 69 63 6e 29 0a 58 23 |L findre|.icn).X#|
|000014c0| 20 20 09 09 69 66 20 6e | 6f 74 20 66 69 6e 64 28 | ..if n|ot find(|
|000014d0| 70 61 74 74 65 72 6e 2c | 20 73 20 3a 3d 20 21 69 |pattern,| s := !i|
|000014e0| 6e 74 65 78 74 29 20 74 | 68 65 6e 20 7b 0a 58 23 |ntext) t|hen {.X#|
|000014f0| 20 20 09 09 20 20 20 20 | 69 70 75 74 73 28 69 67 | .. |iputs(ig|
|00001500| 6f 74 6f 28 67 65 74 76 | 61 6c 28 22 63 6d 22 29 |oto(getv|al("cm")|
|00001510| 2c 20 31 2c 20 67 65 74 | 76 61 6c 28 22 6c 69 22 |, 1, get|val("li"|
|00001520| 29 29 29 0a 58 23 20 20 | 09 09 20 20 20 20 65 6d |))).X# |.. em|
|00001530| 70 68 61 73 69 7a 65 28 | 29 0a 58 23 20 20 09 09 |phasize(|).X# ..|
|00001540| 20 20 20 20 77 72 69 74 | 65 5f 63 65 28 22 53 74 | writ|e_ce("St|
|00001550| 72 69 6e 67 20 6e 6f 74 | 20 66 6f 75 6e 64 2e 22 |ring not| found."|
|00001560| 29 0a 58 23 20 20 09 09 | 20 20 20 20 62 72 65 61 |).X# ..| brea|
|00001570| 6b 0a 58 23 20 20 09 09 | 7d 0a 58 23 20 20 09 09 |k.X# ..|}.X# ..|
|00001580| 65 6c 73 65 20 70 72 69 | 6e 74 5f 73 63 72 65 65 |else pri|nt_scree|
|00001590| 6e 28 69 6e 74 65 78 74 | 2c 20 73 29 20 7c 20 62 |n(intext|, s) | b|
|000015a0| 72 65 61 6b 0a 58 23 20 | 20 09 20 20 20 20 7d 0a |reak.X# | . }.|
|000015b0| 58 23 20 20 09 7d 0a 58 | 23 20 20 20 20 20 20 7d |X# .}.X|# }|
|000015c0| 0a 58 23 20 20 0a 58 23 | 20 20 20 20 20 20 72 65 |.X# .X#| re|
|000015d0| 73 65 74 5f 74 74 79 28 | 29 0a 58 23 20 20 20 20 |set_tty(|).X# |
|000015e0| 20 20 77 72 69 74 65 28 | 29 0a 58 23 20 20 20 20 | write(|).X# |
|000015f0| 20 20 65 78 69 74 28 30 | 29 0a 58 23 0a 58 23 20 | exit(0|).X#.X# |
|00001600| 20 65 6e 64 0a 58 23 20 | 20 0a 58 23 20 20 70 72 | end.X# | .X# pr|
|00001610| 6f 63 65 64 75 72 65 20 | 47 65 74 4d 6f 72 65 49 |ocedure |GetMoreI|
|00001620| 6e 70 75 74 28 63 29 0a | 58 23 20 20 0a 58 23 20 |nput(c).|X# .X# |
|00001630| 20 20 20 20 20 6c 6f 63 | 61 6c 20 69 6e 70 75 74 | loc|al input|
|00001640| 5f 73 74 72 69 6e 67 0a | 58 23 20 20 20 20 20 20 |_string.|X# |
|00001650| 73 74 61 74 69 63 20 42 | 53 0a 58 23 20 20 20 20 |static B|S.X# |
|00001660| 20 20 69 6e 69 74 69 61 | 6c 20 42 53 20 3a 3d 20 | initia|l BS := |
|00001670| 67 65 74 76 61 6c 28 22 | 62 63 22 29 20 7c 20 22 |getval("|bc") | "|
|00001680| 5c 62 22 0a 58 23 20 20 | 0a 58 23 20 20 20 20 20 |\b".X# |.X# |
|00001690| 20 2f 63 20 3a 3d 20 22 | 22 0a 58 23 20 20 20 20 | /c := "|".X# |
|000016a0| 20 20 69 66 20 61 6e 79 | 28 27 5c 6e 5c 72 27 2c | if any|('\n\r',|
|000016b0| 20 63 68 72 20 3a 3d 20 | 67 65 74 63 68 28 29 29 | chr := |getch())|
|000016c0| 0a 58 23 20 20 20 20 20 | 20 74 68 65 6e 20 72 65 |.X# | then re|
|000016d0| 74 75 72 6e 20 63 0a 58 | 23 20 20 20 20 20 20 65 |turn c.X|# e|
|000016e0| 6c 73 65 20 7b 0a 58 23 | 20 20 09 63 68 72 20 3d |lse {.X#| .chr =|
|000016f0| 3d 20 42 53 20 26 20 66 | 61 69 6c 0a 58 23 20 20 |= BS & f|ail.X# |
|00001700| 09 77 72 69 74 65 73 28 | 63 68 72 29 0a 58 23 20 |.writes(|chr).X# |
|00001710| 20 09 69 6e 70 75 74 5f | 73 74 72 69 6e 67 20 3a | .input_|string :|
|00001720| 3d 20 67 65 74 73 65 28 | 63 20 7c 7c 20 63 68 72 |= getse(|c || chr|
|00001730| 29 20 7c 20 66 61 69 6c | 0a 58 23 20 20 09 69 66 |) | fail|.X# .if|
|00001740| 20 61 6e 79 28 27 5c 6e | 5c 72 27 2c 20 69 6e 70 | any('\n|\r', inp|
|00001750| 75 74 5f 73 74 72 69 6e | 67 29 0a 58 23 20 20 09 |ut_strin|g).X# .|
|00001760| 74 68 65 6e 20 66 61 69 | 6c 20 65 6c 73 65 20 28 |then fai|l else (|
|00001770| 72 65 74 75 72 6e 20 69 | 6e 70 75 74 5f 73 74 72 |return i|nput_str|
|00001780| 69 6e 67 29 0a 58 23 20 | 20 20 20 20 20 7d 0a 58 |ing).X# | }.X|
|00001790| 23 20 20 0a 58 23 20 20 | 65 6e 64 0a 58 23 20 20 |# .X# |end.X# |
|000017a0| 0a 58 23 20 20 70 72 6f | 63 65 64 75 72 65 20 70 |.X# pro|cedure p|
|000017b0| 72 69 6e 74 5f 73 63 72 | 65 65 6e 28 66 2c 73 29 |rint_scr|een(f,s)|
|000017c0| 0a 58 23 20 20 0a 58 23 | 20 20 20 20 20 20 69 66 |.X# .X#| if|
|000017d0| 20 2f 73 20 74 68 65 6e | 0a 58 23 20 20 09 62 65 | /s then|.X# .be|
|000017e0| 67 69 6e 20 3a 3d 20 31 | 0a 58 23 20 20 20 20 20 |gin := 1|.X# |
|000017f0| 20 23 20 50 72 69 6e 74 | 20 74 6f 70 20 6c 69 6e | # Print| top lin|
|00001800| 65 2c 20 69 66 20 6f 6e | 65 20 69 73 20 73 75 70 |e, if on|e is sup|
|00001810| 70 6c 69 65 64 0a 58 23 | 20 20 20 20 20 20 65 6c |plied.X#| el|
|00001820| 73 65 20 7b 0a 58 23 20 | 20 09 69 70 75 74 73 28 |se {.X# | .iputs(|
|00001830| 69 67 6f 74 6f 28 67 65 | 74 76 61 6c 28 22 63 6d |igoto(ge|tval("cm|
|00001840| 22 29 2c 20 31 2c 20 31 | 29 29 0a 58 23 20 20 09 |"), 1, 1|)).X# .|
|00001850| 77 72 69 74 65 5f 63 65 | 28 73 20 3f 20 74 61 62 |write_ce|(s ? tab|
|00001860| 28 67 65 74 76 61 6c 28 | 22 63 6f 22 29 20 7c 20 |(getval(|"co") | |
|00001870| 30 29 29 0a 58 23 20 20 | 09 62 65 67 69 6e 20 3a |0)).X# |.begin :|
|00001880| 3d 20 32 0a 58 23 20 20 | 20 20 20 20 7d 0a 58 23 |= 2.X# | }.X#|
|00001890| 20 20 0a 58 23 20 20 20 | 20 20 20 23 20 46 69 6c | .X# | # Fil|
|000018a0| 6c 20 74 68 65 20 73 63 | 72 65 65 6e 20 77 69 74 |l the sc|reen wit|
|000018b0| 68 20 6c 69 6e 65 73 20 | 66 72 6f 6d 20 66 3b 20 |h lines |from f; |
|000018c0| 63 6c 65 61 72 20 61 6e | 64 20 66 61 69 6c 20 6f |clear an|d fail o|
|000018d0| 6e 20 45 4f 46 2e 0a 58 | 23 20 20 20 20 20 20 65 |n EOF..X|# e|
|000018e0| 76 65 72 79 20 69 20 3a | 3d 20 62 65 67 69 6e 20 |very i :|= begin |
|000018f0| 74 6f 20 67 65 74 76 61 | 6c 28 22 6c 69 22 29 20 |to getva|l("li") |
|00001900| 2d 20 31 20 64 6f 20 7b | 0a 58 23 20 20 09 69 70 |- 1 do {|.X# .ip|
|00001910| 75 74 73 28 69 67 6f 74 | 6f 28 67 65 74 76 61 6c |uts(igot|o(getval|
|00001920| 28 22 63 6d 22 29 2c 20 | 31 2c 20 69 29 29 0a 58 |("cm"), |1, i)).X|
|00001930| 23 20 20 09 69 66 20 6e | 6f 74 20 77 72 69 74 65 |# .if n|ot write|
|00001940| 5f 63 65 28 72 65 61 64 | 28 66 29 20 3f 20 74 61 |_ce(read|(f) ? ta|
|00001950| 62 28 67 65 74 76 61 6c | 28 22 63 6f 22 29 20 7c |b(getval|("co") ||
|00001960| 20 30 29 29 20 74 68 65 | 6e 20 7b 0a 58 23 20 20 | 0)) the|n {.X# |
|00001970| 09 20 20 20 20 23 20 43 | 6c 65 61 72 20 72 65 6d |. # C|lear rem|
|00001980| 61 69 6e 69 6e 67 20 6c | 69 6e 65 73 20 6f 6e 20 |aining l|ines on |
|00001990| 74 68 65 20 73 63 72 65 | 65 6e 2e 0a 58 23 20 20 |the scre|en..X# |
|000019a0| 09 20 20 20 20 65 76 65 | 72 79 20 6a 20 3a 3d 20 |. eve|ry j := |
|000019b0| 69 20 74 6f 20 67 65 74 | 76 61 6c 28 22 6c 69 22 |i to get|val("li"|
|000019c0| 29 20 64 6f 20 7b 0a 58 | 23 20 20 09 09 69 70 75 |) do {.X|# ..ipu|
|000019d0| 74 73 28 69 67 6f 74 6f | 28 67 65 74 76 61 6c 28 |ts(igoto|(getval(|
|000019e0| 22 63 6d 22 29 2c 20 31 | 2c 20 6a 29 29 0a 58 23 |"cm"), 1|, j)).X#|
|000019f0| 20 20 09 09 69 70 75 74 | 73 28 67 65 74 76 61 6c | ..iput|s(getval|
|00001a00| 28 22 63 65 22 29 29 0a | 58 23 20 20 09 20 20 20 |("ce")).|X# . |
|00001a10| 20 7d 0a 58 23 20 20 09 | 20 20 20 20 69 70 75 74 | }.X# .| iput|
|00001a20| 73 28 69 67 6f 74 6f 28 | 67 65 74 76 61 6c 28 22 |s(igoto(|getval("|
|00001a30| 63 6d 22 29 2c 20 31 2c | 20 69 29 29 0a 58 23 20 |cm"), 1,| i)).X# |
|00001a40| 20 09 20 20 20 20 66 61 | 69 6c 0a 58 23 20 20 09 | . fa|il.X# .|
|00001a50| 7d 0a 58 23 20 20 20 20 | 20 20 7d 0a 58 23 20 20 |}.X# | }.X# |
|00001a60| 20 20 20 20 72 65 74 75 | 72 6e 0a 58 23 20 20 0a | retu|rn.X# .|
|00001a70| 58 23 20 20 65 6e 64 0a | 58 23 20 20 0a 58 23 20 |X# end.|X# .X# |
|00001a80| 20 70 72 6f 63 65 64 75 | 72 65 20 77 72 69 74 65 | procedu|re write|
|00001a90| 5f 63 65 28 73 29 0a 58 | 23 20 20 0a 58 23 20 20 |_ce(s).X|# .X# |
|00001aa0| 20 20 20 20 6e 6f 72 6d | 61 6c 28 29 0a 58 23 20 | norm|al().X# |
|00001ab0| 20 20 20 20 20 69 70 75 | 74 73 28 67 65 74 76 61 | ipu|ts(getva|
|00001ac0| 6c 28 22 63 65 22 29 29 | 20 7c 0a 58 23 20 20 09 |l("ce"))| |.X# .|
|00001ad0| 77 72 69 74 65 73 28 72 | 65 70 6c 28 22 20 22 2c |writes(r|epl(" ",|
|00001ae0| 67 65 74 76 61 6c 28 22 | 63 6f 22 29 20 2d 20 2a |getval("|co") - *|
|00001af0| 73 29 29 0a 58 23 20 20 | 20 20 20 20 77 72 69 74 |s)).X# | writ|
|00001b00| 65 73 28 73 29 0a 58 23 | 20 20 20 20 20 20 72 65 |es(s).X#| re|
|00001b10| 74 75 72 6e 0a 58 23 0a | 58 23 20 20 65 6e 64 0a |turn.X#.|X# end.|
|00001b20| 58 23 0a 58 23 23 23 23 | 23 23 23 23 23 23 23 23 |X#.X####|########|
|00001b30| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00001b40| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00001b50| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00001b60| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00001b70| 0a 58 23 0a 58 23 20 20 | 52 65 71 75 69 72 65 73 |.X#.X# |Requires|
|00001b80| 3a 20 55 4e 49 58 0a 58 | 23 0a 58 23 20 20 4c 69 |: UNIX.X|#.X# Li|
|00001b90| 6e 6b 73 3a 20 69 74 6c | 69 62 2e 69 63 6e 0a 58 |nks: itl|ib.icn.X|
|00001ba0| 23 0a 58 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |#.X#####|########|
|00001bb0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00001bc0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00001bd0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00001be0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 0a |########|#######.|
|00001bf0| 58 0a 58 0a 58 67 6c 6f | 62 61 6c 20 63 5f 63 63 |X.X.Xglo|bal c_cc|
|00001c00| 2c 20 63 75 72 72 65 6e | 74 5f 6d 6f 64 65 09 09 |, curren|t_mode..|
|00001c10| 23 20 77 68 61 74 20 6d | 6f 64 65 20 61 72 65 20 |# what m|ode are |
|00001c20| 77 65 20 69 6e 2c 20 72 | 61 77 20 6f 72 20 63 6f |we in, r|aw or co|
|00001c30| 6f 6b 65 64 3f 0a 58 72 | 65 63 6f 72 64 20 74 65 |oked?.Xr|ecord te|
|00001c40| 72 6d 69 6f 5f 73 74 72 | 75 63 74 28 76 69 6e 74 |rmio_str|uct(vint|
|00001c50| 72 2c 76 71 75 69 74 2c | 76 65 72 61 73 65 2c 76 |r,vquit,|verase,v|
|00001c60| 6b 69 6c 6c 29 0a 58 0a | 58 70 72 6f 63 65 64 75 |kill).X.|Xprocedu|
|00001c70| 72 65 20 67 65 74 73 65 | 28 73 29 0a 58 0a 58 20 |re getse|(s).X.X |
|00001c80| 20 20 20 23 20 67 65 74 | 73 65 28 29 20 2d 20 6c | # get|se() - l|
|00001c90| 69 6b 65 20 67 65 74 63 | 68 65 2c 20 6f 6e 6c 79 |ike getc|he, only|
|00001ca0| 20 66 6f 72 20 73 74 72 | 69 6e 67 73 20 69 6e 73 | for str|ings ins|
|00001cb0| 74 65 61 64 20 6f 66 20 | 73 69 6e 67 6c 65 20 63 |tead of |single c|
|00001cc0| 68 61 72 73 0a 58 20 20 | 20 20 23 0a 58 20 20 20 |hars.X | #.X |
|00001cd0| 20 23 20 54 68 69 73 20 | 70 72 6f 63 65 64 75 72 | # This |procedur|
|00001ce0| 65 20 2a 6d 75 73 74 2a | 20 62 65 20 75 73 65 64 |e *must*| be used|
|00001cf0| 20 69 6e 73 74 65 61 64 | 20 6f 66 20 72 65 61 64 | instead| of read|
|00001d00| 28 26 69 6e 70 75 74 29 | 20 69 66 20 67 65 74 63 |(&input)| if getc|
|00001d10| 68 0a 58 20 20 20 20 23 | 20 61 6e 64 2f 6f 72 20 |h.X #| and/or |
|00001d20| 67 65 74 63 68 65 20 61 | 72 65 20 74 6f 20 62 65 |getche a|re to be|
|00001d30| 20 75 73 65 64 2c 20 73 | 69 6e 63 65 20 74 68 65 | used, s|ince the|
|00001d40| 73 65 20 70 75 74 20 74 | 68 65 20 63 75 72 72 65 |se put t|he curre|
|00001d50| 6e 74 20 74 74 79 0a 58 | 20 20 20 20 23 20 6c 69 |nt tty.X| # li|
|00001d60| 6e 65 20 69 6e 20 72 61 | 77 20 6d 6f 64 65 2e 0a |ne in ra|w mode..|
|00001d70| 58 20 20 20 20 23 0a 58 | 20 20 20 20 23 20 4e 6f |X #.X| # No|
|00001d80| 74 65 20 74 68 61 74 20 | 74 68 65 20 62 75 66 66 |te that |the buff|
|00001d90| 65 72 20 63 61 6e 20 62 | 65 20 69 6e 69 74 69 61 |er can b|e initia|
|00001da0| 6c 69 7a 65 64 20 62 79 | 20 63 61 6c 6c 69 6e 67 |lized by| calling|
|00001db0| 20 67 65 74 73 65 20 77 | 69 74 68 20 61 0a 58 20 | getse w|ith a.X |
|00001dc0| 20 20 20 23 20 73 74 72 | 69 6e 67 20 61 72 67 75 | # str|ing argu|
|00001dd0| 6d 65 6e 74 2e 20 20 4e | 6f 74 65 20 61 6c 73 6f |ment. N|ote also|
|00001de0| 20 74 68 61 74 2c 20 61 | 73 20 67 65 74 73 65 20 | that, a|s getse |
|00001df0| 6e 6f 77 20 73 74 61 6e | 64 73 2c 20 69 74 20 77 |now stan|ds, it w|
|00001e00| 69 6c 6c 0a 58 20 20 20 | 20 23 20 66 61 69 6c 20 |ill.X | # fail |
|00001e10| 69 66 20 74 68 65 20 75 | 73 65 72 20 62 61 63 6b |if the u|ser back|
|00001e20| 73 70 61 63 65 73 20 6f | 76 65 72 20 65 76 65 72 |spaces o|ver ever|
|00001e30| 79 74 68 69 6e 67 20 74 | 68 61 74 20 68 61 73 20 |ything t|hat has |
|00001e40| 62 65 65 6e 20 69 6e 70 | 75 74 2e 0a 58 20 20 20 |been inp|ut..X |
|00001e50| 20 23 20 54 68 69 73 20 | 63 68 61 6e 67 65 20 64 | # This |change d|
|00001e60| 6f 65 73 20 6e 6f 74 20 | 63 6f 69 6e 63 69 64 65 |oes not |coincide|
|00001e70| 20 77 69 74 68 20 69 74 | 73 20 62 65 68 61 76 69 | with it|s behavi|
|00001e80| 6f 72 20 69 6e 20 70 72 | 65 76 69 6f 75 73 20 76 |or in pr|evious v|
|00001e90| 65 72 2d 0a 58 20 20 20 | 20 23 20 73 69 6f 6e 73 |er-.X | # sions|
|00001ea0| 2e 20 20 49 74 20 63 61 | 6e 20 62 65 20 63 68 61 |. It ca|n be cha|
|00001eb0| 6e 67 65 64 20 62 79 20 | 63 6f 6d 6d 65 6e 74 69 |nged by |commenti|
|00001ec0| 6e 67 20 6f 75 74 20 74 | 68 65 20 6c 69 6e 65 20 |ng out t|he line |
|00001ed0| 22 69 66 20 2a 73 20 3c | 20 31 0a 58 20 20 20 20 |"if *s <| 1.X |
|00001ee0| 23 20 74 68 65 6e 20 66 | 61 69 6c 22 20 62 65 6c |# then f|ail" bel|
|00001ef0| 6f 77 2c 20 61 6e 64 20 | 75 6e 63 6f 6d 6d 65 6e |ow, and |uncommen|
|00001f00| 74 69 6e 67 20 74 68 65 | 20 6c 69 6e 65 20 22 69 |ting the| line "i|
|00001f10| 66 20 2a 73 20 3c 20 31 | 20 74 68 65 6e 0a 58 20 |f *s < 1| then.X |
|00001f20| 20 20 20 23 20 6e 65 78 | 74 2e 22 0a 58 0a 58 20 | # nex|t.".X.X |
|00001f30| 20 20 20 6c 6f 63 61 6c | 20 63 68 72 0a 58 20 20 | local| chr.X |
|00001f40| 20 20 73 74 61 74 69 63 | 20 42 53 0a 58 20 20 20 | static| BS.X |
|00001f50| 20 69 6e 69 74 69 61 6c | 20 7b 0a 58 09 42 53 20 | initial| {.X.BS |
|00001f60| 3a 3d 20 67 65 74 76 61 | 6c 28 22 62 63 22 29 20 |:= getva|l("bc") |
|00001f70| 7c 20 22 5c 62 22 0a 58 | 09 69 66 20 6e 6f 74 20 || "\b".X|.if not |
|00001f80| 67 65 74 76 61 6c 28 22 | 62 73 22 29 20 74 68 65 |getval("|bs") the|
|00001f90| 6e 20 7b 0a 58 09 20 20 | 20 20 72 65 73 65 74 5f |n {.X. | reset_|
|00001fa0| 74 74 79 28 29 0a 58 09 | 20 20 20 20 73 74 6f 70 |tty().X.| stop|
|00001fb0| 28 22 59 6f 75 72 20 74 | 65 72 6d 69 6e 61 6c 20 |("Your t|erminal |
|00001fc0| 63 61 6e 27 74 20 62 61 | 63 6b 73 70 61 63 65 21 |can't ba|ckspace!|
|00001fd0| 22 29 0a 58 09 7d 0a 58 | 20 20 20 20 7d 0a 58 0a |").X.}.X| }.X.|
|00001fe0| 58 20 20 20 20 2f 73 20 | 3a 3d 20 22 22 0a 58 20 |X /s |:= "".X |
|00001ff0| 20 20 20 72 65 70 65 61 | 74 20 7b 0a 58 09 63 61 | repea|t {.X.ca|
|00002000| 73 65 20 63 68 72 20 3a | 3d 20 67 65 74 63 68 28 |se chr :|= getch(|
|00002010| 29 20 7c 20 66 61 69 6c | 20 6f 66 20 7b 0a 58 09 |) | fail| of {.X.|
|00002020| 20 20 20 20 22 5c 72 22 | 7c 22 5c 6e 22 20 20 20 | "\r"||"\n" |
|00002030| 20 3a 20 72 65 74 75 72 | 6e 20 73 0a 58 09 20 20 | : retur|n s.X. |
|00002040| 20 20 63 5f 63 63 2e 76 | 6b 69 6c 6c 20 20 20 3a | c_cc.v|kill :|
|00002050| 20 7b 0a 58 09 09 69 66 | 20 2a 73 20 3c 20 31 20 | {.X..if| *s < 1 |
|00002060| 74 68 65 6e 20 6e 65 78 | 74 0a 58 09 09 65 76 65 |then nex|t.X..eve|
|00002070| 72 79 20 31 20 74 6f 20 | 2a 73 20 64 6f 20 77 72 |ry 1 to |*s do wr|
|00002080| 69 74 65 73 28 42 53 29 | 0a 58 09 09 73 20 3a 3d |ites(BS)|.X..s :=|
|00002090| 20 22 22 0a 58 09 20 20 | 20 20 7d 0a 58 09 20 20 | "".X. | }.X. |
|000020a0| 20 20 63 5f 63 63 2e 76 | 65 72 61 73 65 20 20 20 | c_cc.v|erase |
|000020b0| 3a 20 7b 0a 58 09 09 23 | 20 69 66 20 2a 73 20 3c |: {.X..#| if *s <|
|000020c0| 20 31 20 74 68 65 6e 20 | 6e 65 78 74 0a 58 09 09 | 1 then |next.X..|
|000020d0| 77 72 69 74 65 73 28 42 | 53 29 20 26 20 73 20 3a |writes(B|S) & s :|
|000020e0| 3d 20 73 5b 31 3a 2d 31 | 5d 0a 58 09 09 69 66 20 |= s[1:-1|].X..if |
|000020f0| 2a 73 20 3c 20 31 20 74 | 68 65 6e 20 66 61 69 6c |*s < 1 t|hen fail|
|00002100| 0a 58 09 20 20 20 20 7d | 0a 58 09 20 20 20 20 64 |.X. }|.X. d|
|00002110| 65 66 61 75 6c 74 3a 20 | 77 72 69 74 65 73 28 63 |efault: |writes(c|
|00002120| 68 72 29 20 26 20 73 20 | 7c 7c 3a 3d 20 63 68 72 |hr) & s |||:= chr|
|00002130| 0a 58 09 7d 0a 58 20 20 | 20 20 7d 0a 58 0a 58 65 |.X.}.X | }.X.Xe|
|00002140| 6e 64 0a 58 0a 58 0a 58 | 0a 58 70 72 6f 63 65 64 |nd.X.X.X|.Xproced|
|00002150| 75 72 65 20 73 65 74 75 | 70 5f 74 74 79 28 29 0a |ure setu|p_tty().|
|00002160| 58 20 20 20 20 63 68 61 | 6e 67 65 5f 74 74 79 5f |X cha|nge_tty_|
|00002170| 6d 6f 64 65 28 22 73 65 | 74 75 70 22 29 0a 58 20 |mode("se|tup").X |
|00002180| 20 20 20 72 65 74 75 72 | 6e 0a 58 65 6e 64 0a 58 | retur|n.Xend.X|
|00002190| 0a 58 0a 58 0a 58 70 72 | 6f 63 65 64 75 72 65 20 |.X.X.Xpr|ocedure |
|000021a0| 72 65 73 65 74 5f 74 74 | 79 28 29 0a 58 0a 58 20 |reset_tt|y().X.X |
|000021b0| 20 20 20 23 20 52 65 73 | 65 74 20 28 67 6c 6f 62 | # Res|et (glob|
|000021c0| 61 6c 29 20 6d 6f 64 65 | 20 73 77 69 74 63 68 20 |al) mode| switch |
|000021d0| 74 6f 20 26 6e 75 6c 6c | 20 74 6f 20 73 68 6f 77 |to &null| to show|
|000021e0| 20 77 65 27 72 65 20 69 | 6e 20 63 6f 6f 6b 65 64 | we're i|n cooked|
|000021f0| 20 6d 6f 64 65 2e 0a 58 | 20 20 20 20 63 75 72 72 | mode..X| curr|
|00002200| 65 6e 74 5f 6d 6f 64 65 | 20 3a 3d 20 26 6e 75 6c |ent_mode| := &nul|
|00002210| 6c 0a 58 20 20 20 20 63 | 68 61 6e 67 65 5f 74 74 |l.X c|hange_tt|
|00002220| 79 5f 6d 6f 64 65 28 22 | 72 65 73 65 74 22 29 0a |y_mode("|reset").|
|00002230| 58 20 20 20 20 72 65 74 | 75 72 6e 0a 58 0a 58 65 |X ret|urn.X.Xe|
|00002240| 6e 64 0a 58 0a 58 0a 58 | 0a 58 70 72 6f 63 65 64 |nd.X.X.X|.Xproced|
|00002250| 75 72 65 20 67 65 74 63 | 68 28 29 0a 58 0a 58 20 |ure getc|h().X.X |
|00002260| 20 20 20 6c 6f 63 61 6c | 20 63 68 72 0a 58 0a 58 | local| chr.X.X|
|00002270| 20 20 20 20 23 20 49 66 | 20 74 68 65 20 67 6c 6f | # If| the glo|
|00002280| 62 61 6c 20 76 61 72 69 | 61 62 6c 65 20 63 75 72 |bal vari|able cur|
|00002290| 72 65 6e 74 5f 6d 6f 64 | 65 20 69 73 20 6e 75 6c |rent_mod|e is nul|
|000022a0| 6c 2c 20 74 68 65 6e 20 | 77 65 20 68 61 76 65 20 |l, then |we have |
|000022b0| 74 6f 0a 58 20 20 20 20 | 23 20 72 65 73 65 74 20 |to.X |# reset |
|000022c0| 74 68 65 20 74 65 72 6d | 69 6e 61 6c 20 74 6f 20 |the term|inal to |
|000022d0| 72 61 77 20 6d 6f 64 65 | 2e 0a 58 20 20 20 20 69 |raw mode|..X i|
|000022e0| 66 20 2f 63 75 72 72 65 | 6e 74 5f 6d 6f 64 65 20 |f /curre|nt_mode |
|000022f0| 3a 3d 20 31 20 74 68 65 | 6e 0a 58 09 73 65 74 75 |:= 1 the|n.X.setu|
|00002300| 70 5f 74 74 79 28 29 0a | 58 0a 58 20 20 20 20 63 |p_tty().|X.X c|
|00002310| 68 72 20 3a 3d 20 72 65 | 61 64 73 28 26 69 6e 70 |hr := re|ads(&inp|
|00002320| 75 74 29 0a 58 20 20 20 | 20 63 61 73 65 20 63 68 |ut).X | case ch|
|00002330| 72 20 6f 66 20 7b 0a 58 | 09 63 5f 63 63 2e 76 69 |r of {.X|.c_cc.vi|
|00002340| 6e 74 72 20 3a 20 72 65 | 73 65 74 5f 74 74 79 28 |ntr : re|set_tty(|
|00002350| 29 20 26 20 73 74 6f 70 | 28 29 20 20 23 20 73 68 |) & stop|() # sh|
|00002360| 6f 75 6c 64 6e 27 74 20 | 68 61 72 64 20 63 6f 64 |ouldn't |hard cod|
|00002370| 65 20 74 68 69 73 20 69 | 6e 0a 58 09 63 5f 63 63 |e this i|n.X.c_cc|
|00002380| 2e 76 71 75 69 74 20 20 | 3a 20 72 65 73 65 74 5f |.vquit |: reset_|
|00002390| 74 74 79 28 29 20 26 20 | 73 74 6f 70 28 29 0a 58 |tty() & |stop().X|
|000023a0| 09 64 65 66 61 75 6c 74 | 20 3a 20 72 65 74 75 72 |.default| : retur|
|000023b0| 6e 20 63 68 72 0a 58 20 | 20 20 20 7d 0a 58 0a 58 |n chr.X | }.X.X|
|000023c0| 65 6e 64 0a 58 0a 58 0a | 58 0a 58 70 72 6f 63 65 |end.X.X.|X.Xproce|
|000023d0| 64 75 72 65 20 67 65 74 | 63 68 65 28 29 0a 58 0a |dure get|che().X.|
|000023e0| 58 20 20 20 20 6c 6f 63 | 61 6c 20 63 68 72 0a 58 |X loc|al chr.X|
|000023f0| 0a 58 20 20 20 20 23 20 | 49 66 20 74 68 65 20 67 |.X # |If the g|
|00002400| 6c 6f 62 61 6c 20 76 61 | 72 69 61 62 6c 65 20 63 |lobal va|riable c|
|00002410| 75 72 72 65 6e 74 5f 6d | 6f 64 65 20 69 73 20 6e |urrent_m|ode is n|
|00002420| 75 6c 6c 2c 20 74 68 65 | 6e 20 77 65 20 68 61 76 |ull, the|n we hav|
|00002430| 65 20 74 6f 0a 58 20 20 | 20 20 23 20 72 65 73 65 |e to.X | # rese|
|00002440| 74 20 74 68 65 20 74 65 | 72 6d 69 6e 61 6c 20 74 |t the te|rminal t|
|00002450| 6f 20 72 61 77 20 6d 6f | 64 65 2e 0a 58 20 20 20 |o raw mo|de..X |
|00002460| 20 69 66 20 2f 63 75 72 | 72 65 6e 74 5f 6d 6f 64 | if /cur|rent_mod|
|00002470| 65 20 3a 3d 20 31 20 74 | 68 65 6e 0a 58 09 73 65 |e := 1 t|hen.X.se|
|00002480| 74 75 70 5f 74 74 79 28 | 29 0a 58 0a 58 20 20 20 |tup_tty(|).X.X |
|00002490| 20 63 68 72 20 3a 3d 20 | 72 65 61 64 73 28 26 69 | chr := |reads(&i|
|000024a0| 6e 70 75 74 29 0a 58 20 | 20 20 20 63 61 73 65 20 |nput).X | case |
|000024b0| 63 68 72 20 6f 66 20 7b | 0a 58 09 63 5f 63 63 2e |chr of {|.X.c_cc.|
|000024c0| 76 69 6e 74 72 20 20 3a | 20 72 65 73 65 74 5f 74 |vintr :| reset_t|
|000024d0| 74 79 28 29 20 26 20 73 | 74 6f 70 28 29 0a 58 09 |ty() & s|top().X.|
|000024e0| 63 5f 63 63 2e 76 71 75 | 69 74 20 20 3a 20 72 65 |c_cc.vqu|it : re|
|000024f0| 73 65 74 5f 74 74 79 28 | 29 20 26 20 73 74 6f 70 |set_tty(|) & stop|
|00002500| 28 29 0a 58 09 64 65 66 | 61 75 6c 74 20 3a 20 77 |().X.def|ault : w|
|00002510| 72 69 74 65 73 28 63 68 | 72 29 20 26 20 72 65 74 |rites(ch|r) & ret|
|00002520| 75 72 6e 20 63 68 72 0a | 58 20 20 20 20 7d 0a 58 |urn chr.|X }.X|
|00002530| 0a 58 65 6e 64 0a 58 0a | 58 0a 58 0a 58 70 72 6f |.Xend.X.|X.X.Xpro|
|00002540| 63 65 64 75 72 65 20 63 | 68 61 6e 67 65 5f 74 74 |cedure c|hange_tt|
|00002550| 79 5f 6d 6f 64 65 28 73 | 77 69 74 63 68 29 0a 58 |y_mode(s|witch).X|
|00002560| 0a 58 20 20 20 20 23 20 | 67 6c 6f 62 61 6c 20 63 |.X # |global c|
|00002570| 5f 63 63 20 20 20 28 67 | 6c 6f 62 61 6c 20 72 65 |_cc (g|lobal re|
|00002580| 63 6f 72 64 20 63 6f 6e | 74 61 69 6e 69 6e 67 20 |cord con|taining |
|00002590| 76 61 6c 75 65 73 20 66 | 6f 72 20 6b 69 6c 6c 2c |values f|or kill,|
|000025a0| 20 65 74 63 2e 20 63 68 | 61 72 73 29 0a 58 20 20 | etc. ch|ars).X |
|000025b0| 20 20 6c 6f 63 61 6c 20 | 67 65 74 5f 74 65 72 6d | local |get_term|
|000025c0| 5f 70 61 72 61 6d 73 2c | 20 69 0a 58 20 20 20 20 |_params,| i.X |
|000025d0| 73 74 61 74 69 63 20 72 | 65 73 65 74 5f 73 74 72 |static r|eset_str|
|000025e0| 69 6e 67 0a 58 20 20 20 | 20 69 6e 69 74 69 61 6c |ing.X | initial|
|000025f0| 20 7b 0a 58 09 67 65 74 | 76 61 6c 28 22 6c 69 22 | {.X.get|val("li"|
|00002600| 29 20 20 20 20 23 20 63 | 68 65 63 6b 20 74 6f 20 |) # c|heck to |
|00002610| 62 65 20 73 75 72 65 20 | 69 74 6c 69 62 20 69 73 |be sure |itlib is|
|00002620| 20 73 65 74 20 75 70 0a | 58 09 66 69 6e 64 28 22 | set up.|X.find("|
|00002630| 75 6e 69 78 22 2c 6d 61 | 70 28 26 66 65 61 74 75 |unix",ma|p(&featu|
|00002640| 72 65 73 29 29 20 7c 0a | 58 09 20 20 20 20 73 74 |res)) |.|X. st|
|00002650| 6f 70 28 22 63 68 61 6e | 67 65 5f 74 74 79 5f 6d |op("chan|ge_tty_m|
|00002660| 6f 64 65 3a 20 20 54 68 | 65 73 65 20 72 6f 75 74 |ode: Th|ese rout|
|00002670| 69 6e 65 73 20 6d 75 73 | 74 20 72 75 6e 20 75 6e |ines mus|t run un|
|00002680| 64 65 72 20 55 6e 69 78 | 2e 22 29 0a 58 09 67 65 |der Unix|.").X.ge|
|00002690| 74 5f 74 65 72 6d 5f 70 | 61 72 61 6d 73 20 3a 3d |t_term_p|arams :=|
|000026a0| 20 6f 70 65 6e 28 22 2f | 62 69 6e 2f 73 74 74 79 | open("/|bin/stty|
|000026b0| 20 2d 67 20 32 3e 26 31 | 22 2c 22 70 72 22 29 0a | -g 2>&1|","pr").|
|000026c0| 58 09 72 65 73 65 74 5f | 73 74 72 69 6e 67 20 3a |X.reset_|string :|
|000026d0| 3d 20 21 67 65 74 5f 74 | 65 72 6d 5f 70 61 72 61 |= !get_t|erm_para|
|000026e0| 6d 73 0a 58 09 63 6c 6f | 73 65 28 67 65 74 5f 74 |ms.X.clo|se(get_t|
|000026f0| 65 72 6d 5f 70 61 72 61 | 6d 73 29 0a 58 09 72 65 |erm_para|ms).X.re|
|00002700| 73 65 74 5f 73 74 72 69 | 6e 67 20 3f 20 7b 0a 58 |set_stri|ng ? {.X|
|00002710| 09 20 20 20 20 23 20 74 | 61 62 20 75 70 74 6f 20 |. # t|ab upto |
|00002720| 74 68 65 20 66 69 66 74 | 68 20 66 69 65 6c 64 20 |the fift|h field |
|00002730| 6f 66 20 74 68 65 20 6f | 75 74 70 75 74 20 6f 66 |of the o|utput of|
|00002740| 20 74 68 65 20 73 74 74 | 79 20 2d 67 20 63 6d 64 | the stt|y -g cmd|
|00002750| 0a 58 09 20 20 20 20 23 | 20 66 69 65 6c 64 73 20 |.X. #| fields |
|00002760| 6f 66 20 73 74 74 79 20 | 2d 67 20 73 65 65 6d 20 |of stty |-g seem |
|00002770| 74 6f 20 62 65 20 74 68 | 65 20 73 61 6d 65 20 61 |to be th|e same a|
|00002780| 73 20 74 68 6f 73 65 20 | 6f 66 20 74 68 65 0a 58 |s those |of the.X|
|00002790| 09 20 20 20 20 23 20 74 | 65 72 6d 69 6f 20 73 74 |. # t|ermio st|
|000027a0| 72 75 63 74 2c 20 65 78 | 63 65 70 74 20 74 68 61 |ruct, ex|cept tha|
|000027b0| 74 20 74 68 65 20 63 5f | 6c 69 6e 65 20 66 69 65 |t the c_|line fie|
|000027c0| 6c 64 20 69 73 20 6d 69 | 73 73 69 6e 67 0a 58 09 |ld is mi|ssing.X.|
|000027d0| 20 20 20 20 65 76 65 72 | 79 20 31 20 74 6f 20 34 | ever|y 1 to 4|
|000027e0| 20 64 6f 20 74 61 62 28 | 66 69 6e 64 28 22 3a 22 | do tab(|find(":"|
|000027f0| 29 2b 31 29 0a 58 09 20 | 20 20 20 63 5f 63 63 20 |)+1).X. | c_cc |
|00002800| 3a 3d 20 74 65 72 6d 69 | 6f 5f 73 74 72 75 63 74 |:= termi|o_struct|
|00002810| 28 22 5c 78 30 33 22 2c | 22 5c 78 31 43 22 2c 22 |("\x03",|"\x1C","|
|00002820| 5c 78 30 38 22 2c 22 5c | 78 31 35 22 29 0a 58 09 |\x08","\|x15").X.|
|00002830| 20 20 20 20 65 76 65 72 | 79 20 69 20 3a 3d 20 31 | ever|y i := 1|
|00002840| 20 74 6f 20 33 20 64 6f | 20 7b 0a 58 09 09 63 5f | to 3 do| {.X..c_|
|00002850| 63 63 5b 69 5d 20 3a 3d | 20 63 68 61 72 28 69 6e |cc[i] :=| char(in|
|00002860| 74 65 67 65 72 28 22 31 | 36 72 22 7c 7c 74 61 62 |teger("1|6r"||tab|
|00002870| 28 66 69 6e 64 28 22 3a | 22 29 29 29 29 0a 58 09 |(find(":|")))).X.|
|00002880| 09 6d 6f 76 65 28 31 29 | 0a 58 09 20 20 20 20 7d |.move(1)|.X. }|
|00002890| 0a 58 09 20 20 20 20 63 | 5f 63 63 5b 69 2b 31 5d |.X. c|_cc[i+1]|
|000028a0| 20 3a 3d 20 63 68 61 72 | 28 69 6e 74 65 67 65 72 | := char|(integer|
|000028b0| 28 22 31 36 72 22 7c 7c | 74 61 62 28 30 29 29 29 |("16r"|||tab(0)))|
|000028c0| 0a 58 09 7d 0a 58 20 20 | 20 20 7d 0a 58 0a 58 20 |.X.}.X | }.X.X |
|000028d0| 20 20 20 69 66 20 73 77 | 69 74 63 68 20 3d 3d 20 | if sw|itch == |
|000028e0| 22 73 65 74 75 70 22 0a | 58 20 20 20 20 74 68 65 |"setup".|X the|
|000028f0| 6e 20 73 79 73 74 65 6d | 28 22 2f 62 69 6e 2f 73 |n system|("/bin/s|
|00002900| 74 74 79 20 2d 65 63 68 | 6f 20 72 61 77 22 29 0a |tty -ech|o raw").|
|00002910| 58 20 20 20 20 65 6c 73 | 65 20 73 79 73 74 65 6d |X els|e system|
|00002920| 28 22 2f 62 69 6e 2f 73 | 74 74 79 20 22 7c 7c 72 |("/bin/s|tty "||r|
|00002930| 65 73 65 74 5f 73 74 72 | 69 6e 67 29 0a 58 0a 58 |eset_str|ing).X.X|
|00002940| 20 20 20 20 72 65 74 75 | 72 6e 0a 58 0a 58 65 6e | retu|rn.X.Xen|
|00002950| 64 0a 53 48 41 52 5f 45 | 4f 46 0a 74 72 75 65 20 |d.SHAR_E|OF.true |
|00002960| 7c 7c 20 65 63 68 6f 20 | 27 72 65 73 74 6f 72 65 ||| echo |'restore|
|00002970| 20 6f 66 20 67 65 74 63 | 68 6c 69 62 2e 69 63 6e | of getc|hlib.icn|
|00002980| 20 66 61 69 6c 65 64 27 | 0a 72 6d 20 2d 66 20 5f | failed'|.rm -f _|
|00002990| 73 68 61 72 5f 77 6e 74 | 5f 2e 74 6d 70 0a 66 69 |shar_wnt|_.tmp.fi|
|000029a0| 0a 23 20 3d 3d 3d 3d 3d | 3d 3d 3d 3d 3d 3d 3d 3d |.# =====|========|
|000029b0| 20 69 74 6c 69 62 2e 69 | 63 6e 20 3d 3d 3d 3d 3d | itlib.i|cn =====|
|000029c0| 3d 3d 3d 3d 3d 3d 3d 3d | 3d 0a 69 66 20 74 65 73 |========|=.if tes|
|000029d0| 74 20 2d 66 20 27 69 74 | 6c 69 62 2e 69 63 6e 27 |t -f 'it|lib.icn'|
|000029e0| 20 2d 61 20 58 22 24 31 | 22 20 21 3d 20 58 22 2d | -a X"$1|" != X"-|
|000029f0| 63 22 3b 20 74 68 65 6e | 0a 09 65 63 68 6f 20 27 |c"; then|..echo '|
|00002a00| 78 20 2d 20 73 6b 69 70 | 70 69 6e 67 20 69 74 6c |x - skip|ping itl|
|00002a10| 69 62 2e 69 63 6e 20 28 | 46 69 6c 65 20 61 6c 72 |ib.icn (|File alr|
|00002a20| 65 61 64 79 20 65 78 69 | 73 74 73 29 27 0a 09 72 |eady exi|sts)'..r|
|00002a30| 6d 20 2d 66 20 5f 73 68 | 61 72 5f 77 6e 74 5f 2e |m -f _sh|ar_wnt_.|
|00002a40| 74 6d 70 0a 65 6c 73 65 | 0a 3e 20 5f 73 68 61 72 |tmp.else|.> _shar|
|00002a50| 5f 77 6e 74 5f 2e 74 6d | 70 0a 65 63 68 6f 20 27 |_wnt_.tm|p.echo '|
|00002a60| 78 20 2d 20 65 78 74 72 | 61 63 74 69 6e 67 20 69 |x - extr|acting i|
|00002a70| 74 6c 69 62 2e 69 63 6e | 20 28 54 65 78 74 29 27 |tlib.icn| (Text)'|
|00002a80| 0a 73 65 64 20 27 73 2f | 5e 58 2f 2f 27 20 3c 3c |.sed 's/|^X//' <<|
|00002a90| 20 27 53 48 41 52 5f 45 | 4f 46 27 20 3e 20 27 69 | 'SHAR_E|OF' > 'i|
|00002aa0| 74 6c 69 62 2e 69 63 6e | 27 20 26 26 0a 58 23 23 |tlib.icn|' &&.X##|
|00002ab0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002ac0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002ad0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002ae0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002af0| 23 23 23 23 23 23 0a 58 | 23 20 20 20 20 0a 58 23 |######.X|# .X#|
|00002b00| 09 4e 61 6d 65 3a 09 69 | 74 6c 69 62 2e 69 63 6e |.Name:.i|tlib.icn|
|00002b10| 0a 58 23 09 0a 58 23 09 | 54 69 74 6c 65 3a 09 49 |.X#..X#.|Title:.I|
|00002b20| 63 6f 6e 20 74 65 72 6d | 6c 69 62 2d 74 79 70 65 |con term|lib-type|
|00002b30| 20 74 6f 6f 6c 73 0a 58 | 23 09 0a 58 23 09 41 75 | tools.X|#..X#.Au|
|00002b40| 74 68 6f 72 3a 09 52 69 | 63 68 61 72 64 20 4c 2e |thor:.Ri|chard L.|
|00002b50| 20 47 6f 65 72 77 69 74 | 7a 0a 58 23 0a 58 23 09 | Goerwit|z.X#.X#.|
|00002b60| 56 65 72 73 69 6f 6e 3a | 20 31 2e 32 33 0a 58 23 |Version:| 1.23.X#|
|00002b70| 0a 58 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |.X######|########|
|00002b80| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002b90| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002ba0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002bb0| 23 23 23 23 23 23 23 23 | 23 23 23 0a 58 23 0a 58 |########|###.X#.X|
|00002bc0| 23 20 20 49 20 70 6c 61 | 63 65 20 74 68 69 73 20 |# I pla|ce this |
|00002bd0| 61 6e 64 20 66 75 74 75 | 72 65 20 76 65 72 73 69 |and futu|re versi|
|00002be0| 6f 6e 73 20 6f 66 20 69 | 74 6c 69 62 20 69 6e 20 |ons of i|tlib in |
|00002bf0| 74 68 65 20 70 75 62 6c | 69 63 20 64 6f 6d 61 69 |the publ|ic domai|
|00002c00| 6e 20 2d 20 52 4c 47 0a | 58 23 0a 58 23 23 23 23 |n - RLG.|X#.X####|
|00002c10| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002c20| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002c30| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002c40| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00002c50| 23 23 23 23 23 0a 58 23 | 0a 58 23 20 20 54 68 65 |#####.X#|.X# The|
|00002c60| 20 66 6f 6c 6c 6f 77 69 | 6e 67 20 6c 69 62 72 61 | followi|ng libra|
|00002c70| 72 79 20 72 65 70 72 65 | 73 65 6e 74 73 20 61 20 |ry repre|sents a |
|00002c80| 73 65 72 69 65 73 20 6f | 66 20 72 6f 75 67 68 20 |series o|f rough |
|00002c90| 66 75 6e 63 74 69 6f 6e | 61 6c 0a 58 23 20 20 65 |function|al.X# e|
|00002ca0| 71 75 69 76 61 6c 65 6e | 74 73 20 74 6f 20 74 68 |quivalen|ts to th|
|00002cb0| 65 20 73 74 61 6e 64 61 | 72 64 20 55 6e 69 78 20 |e standa|rd Unix |
|00002cc0| 6c 6f 77 2d 6c 65 76 65 | 6c 20 74 65 72 6d 63 61 |low-leve|l termca|
|00002cd0| 70 20 72 6f 75 74 69 6e | 65 73 2e 20 20 54 68 65 |p routin|es. The|
|00002ce0| 79 0a 58 23 20 20 61 72 | 65 20 6e 6f 74 20 6d 65 |y.X# ar|e not me|
|00002cf0| 61 6e 74 20 61 73 20 65 | 78 61 63 74 20 74 65 72 |ant as e|xact ter|
|00002d00| 6d 6c 69 62 20 63 6c 6f | 6e 65 73 2e 20 20 4e 6f |mlib clo|nes. No|
|00002d10| 72 20 61 72 65 20 74 68 | 65 79 20 65 6e 68 61 6e |r are th|ey enhan|
|00002d20| 63 65 64 20 74 6f 0a 58 | 23 20 20 74 61 6b 65 20 |ced to.X|# take |
|00002d30| 63 61 72 65 20 6f 66 20 | 6d 61 67 69 63 20 63 6f |care of |magic co|
|00002d40| 6f 6b 69 65 20 74 65 72 | 6d 69 6e 61 6c 73 2c 20 |okie ter|minals, |
|00002d50| 74 65 72 6d 69 6e 61 6c | 73 20 74 68 61 74 20 75 |terminal|s that u|
|00002d60| 73 65 20 5c 44 20 69 6e | 20 74 68 65 69 72 0a 58 |se \D in| their.X|
|00002d70| 23 20 20 74 65 72 6d 63 | 61 70 20 65 6e 74 72 69 |# termc|ap entri|
|00002d80| 65 73 2c 20 6f 72 2c 20 | 69 6e 20 73 68 6f 72 74 |es, or, |in short|
|00002d90| 2c 20 61 6e 79 74 68 69 | 6e 67 20 49 20 66 65 6c |, anythi|ng I fel|
|00002da0| 74 20 77 6f 75 6c 64 20 | 6e 6f 74 20 61 66 66 65 |t would |not affe|
|00002db0| 63 74 20 6d 79 0a 58 23 | 20 20 6e 6f 72 6d 61 6c |ct my.X#| normal|
|00002dc0| 2c 20 64 61 79 2d 74 6f | 2d 64 61 79 20 77 6f 72 |, day-to|-day wor|
|00002dd0| 6b 20 77 69 74 68 20 41 | 4e 53 49 20 61 6e 64 20 |k with A|NSI and |
|00002de0| 76 74 31 30 30 20 74 65 | 72 6d 69 6e 61 6c 73 2e |vt100 te|rminals.|
|00002df0| 0a 58 23 0a 58 23 20 20 | 52 65 71 75 69 72 65 73 |.X#.X# |Requires|
|00002e00| 3a 20 20 41 20 75 6e 69 | 78 20 70 6c 61 74 66 6f |: A uni|x platfo|
|00002e10| 72 6d 20 26 20 63 6f 2d | 65 78 70 72 65 73 73 69 |rm & co-|expressi|
|00002e20| 6f 6e 73 2e 20 20 54 68 | 65 72 65 20 69 73 20 61 |ons. Th|ere is a|
|00002e30| 6e 20 4d 53 2d 44 4f 53 | 0a 58 23 20 20 76 65 72 |n MS-DOS|.X# ver|
|00002e40| 73 69 6f 6e 2c 20 69 74 | 6c 69 62 64 6f 73 2e 69 |sion, it|libdos.i|
|00002e50| 63 6e 2e 0a 58 23 0a 58 | 23 20 20 73 65 74 6e 61 |cn..X#.X|# setna|
|00002e60| 6d 65 28 74 65 72 6d 29 | 0a 58 23 09 55 73 65 20 |me(term)|.X#.Use |
|00002e70| 6f 6e 6c 79 20 69 66 20 | 79 6f 75 20 77 69 73 68 |only if |you wish|
|00002e80| 20 74 6f 20 69 6e 69 74 | 69 61 6c 69 7a 65 20 69 | to init|ialize i|
|00002e90| 74 65 72 6d 6c 69 62 20 | 66 6f 72 20 61 20 74 65 |termlib |for a te|
|00002ea0| 72 6d 69 6e 61 6c 0a 58 | 23 20 20 6f 74 68 65 72 |rminal.X|# other|
|00002eb0| 20 74 68 61 6e 20 77 68 | 61 74 20 79 6f 75 72 20 | than wh|at your |
|00002ec0| 63 75 72 72 65 6e 74 20 | 65 6e 76 69 72 6f 6e 6d |current |environm|
|00002ed0| 65 6e 74 20 73 70 65 63 | 69 66 69 65 73 2e 20 20 |ent spec|ifies. |
|00002ee0| 22 54 65 72 6d 22 20 69 | 73 20 74 68 65 0a 58 23 |"Term" i|s the.X#|
|00002ef0| 20 20 6e 61 6d 65 20 6f | 66 20 74 68 65 20 74 65 | name o|f the te|
|00002f00| 72 6d 63 61 70 20 65 6e | 74 72 79 20 74 6f 20 75 |rmcap en|try to u|
|00002f10| 73 65 2e 20 20 4e 6f 72 | 6d 61 6c 6c 79 20 74 68 |se. Nor|mally th|
|00002f20| 69 73 20 69 6e 69 74 69 | 61 6c 69 7a 61 74 69 6f |is initi|alizatio|
|00002f30| 6e 20 69 73 0a 58 23 20 | 20 64 6f 6e 65 20 61 75 |n is.X# | done au|
|00002f40| 74 6f 6d 61 74 69 63 61 | 6c 6c 79 2c 20 61 6e 64 |tomatica|lly, and|
|00002f50| 20 6e 65 65 64 20 6e 6f | 74 20 63 6f 6e 63 65 72 | need no|t concer|
|00002f60| 6e 20 74 68 65 20 75 73 | 65 72 2e 0a 58 23 0a 58 |n the us|er..X#.X|
|00002f70| 23 20 20 67 65 74 76 61 | 6c 28 69 64 29 0a 58 23 |# getva|l(id).X#|
|00002f80| 09 57 6f 72 6b 73 20 73 | 6f 6d 65 74 68 69 6e 67 |.Works s|omething|
|00002f90| 20 6c 69 6b 65 20 74 67 | 65 74 6e 75 6d 2c 20 74 | like tg|etnum, t|
|00002fa0| 67 65 74 66 6c 61 67 2c | 20 61 6e 64 20 74 67 65 |getflag,| and tge|
|00002fb0| 74 73 74 72 2e 20 20 49 | 6e 20 74 68 65 0a 58 23 |tstr. I|n the.X#|
|00002fc0| 20 20 73 70 69 72 69 74 | 20 6f 66 20 49 63 6f 6e | spirit| of Icon|
|00002fd0| 2c 20 61 6c 6c 20 74 68 | 72 65 65 20 68 61 76 65 |, all th|ree have|
|00002fe0| 20 62 65 65 6e 20 63 6f | 6c 6c 61 70 73 65 64 20 | been co|llapsed |
|00002ff0| 69 6e 74 6f 20 6f 6e 65 | 20 72 6f 75 74 69 6e 65 |into one| routine|
|00003000| 2e 0a 58 23 20 20 49 6e | 74 65 67 65 72 20 76 61 |..X# In|teger va|
|00003010| 6c 75 65 64 20 63 61 70 | 73 20 61 72 65 20 72 65 |lued cap|s are re|
|00003020| 74 75 72 6e 65 64 20 61 | 73 20 69 6e 74 65 67 65 |turned a|s intege|
|00003030| 72 73 2c 20 73 74 72 69 | 6e 67 73 20 61 73 20 73 |rs, stri|ngs as s|
|00003040| 74 72 69 6e 67 73 2c 0a | 58 23 20 20 61 6e 64 20 |trings,.|X# and |
|00003050| 66 6c 61 67 73 20 61 73 | 20 72 65 63 6f 72 64 73 |flags as| records|
|00003060| 20 28 69 66 20 61 20 66 | 6c 61 67 20 69 73 20 73 | (if a f|lag is s|
|00003070| 65 74 2c 20 74 68 65 6e | 20 74 79 70 65 28 66 6c |et, then| type(fl|
|00003080| 61 67 29 20 77 69 6c 6c | 20 72 65 74 75 72 6e 0a |ag) will| return.|
|00003090| 58 23 20 20 22 74 72 75 | 65 22 29 2e 20 20 41 62 |X# "tru|e"). Ab|
|000030a0| 73 65 6e 63 65 20 6f 66 | 20 61 20 67 69 76 65 6e |sence of| a given|
|000030b0| 20 63 61 70 61 62 69 6c | 69 74 79 20 69 73 20 73 | capabil|ity is s|
|000030c0| 69 67 6e 61 6c 6c 65 64 | 20 62 79 20 70 72 6f 63 |ignalled| by proc|
|000030d0| 65 64 75 72 65 0a 58 23 | 20 20 66 61 69 6c 75 72 |edure.X#| failur|
|000030e0| 65 2e 0a 58 23 0a 58 23 | 20 20 69 67 6f 74 6f 28 |e..X#.X#| igoto(|
|000030f0| 63 6d 2c 64 65 73 74 63 | 6f 6c 2c 64 65 73 74 6c |cm,destc|ol,destl|
|00003100| 69 6e 65 29 20 2d 20 4e | 42 3a 20 20 64 65 66 61 |ine) - N|B: defa|
|00003110| 75 6c 74 20 31 20 6f 66 | 66 73 65 74 20 28 2a 6e |ult 1 of|fset (*n|
|00003120| 6f 74 2a 20 7a 65 72 6f | 29 21 0a 58 23 09 41 6e |ot* zero|)!.X#.An|
|00003130| 61 6c 6f 67 6f 75 73 20 | 74 6f 20 74 67 6f 74 6f |alogous |to tgoto|
|00003140| 2e 20 20 22 43 6d 22 20 | 69 73 20 74 68 65 20 63 |. "Cm" |is the c|
|00003150| 75 72 73 6f 72 20 6d 6f | 76 65 6d 65 6e 74 20 63 |ursor mo|vement c|
|00003160| 6f 6d 6d 61 6e 64 20 66 | 6f 72 0a 58 23 20 20 74 |ommand f|or.X# t|
|00003170| 68 65 20 63 75 72 72 65 | 6e 74 20 74 65 72 6d 69 |he curre|nt termi|
|00003180| 6e 61 6c 2c 20 61 73 20 | 6f 62 74 61 69 6e 65 64 |nal, as |obtained|
|00003190| 20 76 69 61 20 67 65 74 | 76 61 6c 28 22 63 6d 22 | via get|val("cm"|
|000031a0| 29 2e 20 20 49 67 6f 74 | 6f 28 29 0a 58 23 20 20 |). Igot|o().X# |
|000031b0| 72 65 74 75 72 6e 73 20 | 61 20 73 74 72 69 6e 67 |returns |a string|
|000031c0| 20 77 68 69 63 68 2c 20 | 77 68 65 6e 20 6f 75 74 | which, |when out|
|000031d0| 70 75 74 20 76 69 61 20 | 69 70 75 74 73 2c 20 77 |put via |iputs, w|
|000031e0| 69 6c 6c 20 63 61 75 73 | 65 20 74 68 65 0a 58 23 |ill caus|e the.X#|
|000031f0| 20 20 63 75 72 73 6f 72 | 20 74 6f 20 6d 6f 76 65 | cursor| to move|
|00003200| 20 74 6f 20 63 6f 6c 75 | 6d 6e 20 22 64 65 73 74 | to colu|mn "dest|
|00003210| 63 6f 6c 22 20 61 6e 64 | 20 6c 69 6e 65 20 22 64 |col" and| line "d|
|00003220| 65 73 74 6c 69 6e 65 2e | 22 20 20 43 6f 6c 75 6d |estline.|" Colum|
|00003230| 6e 20 61 6e 64 0a 58 23 | 20 20 6c 69 6e 65 20 61 |n and.X#| line a|
|00003240| 72 65 20 61 6c 77 61 79 | 73 20 63 61 6c 63 75 6c |re alway|s calcul|
|00003250| 61 74 65 64 20 75 73 69 | 6e 67 20 61 20 2a 6f 6e |ated usi|ng a *on|
|00003260| 65 2a 20 6f 66 66 73 65 | 74 2e 20 20 54 68 69 73 |e* offse|t. This|
|00003270| 20 69 73 20 66 61 72 20 | 6d 6f 72 65 0a 58 23 20 | is far |more.X# |
|00003280| 20 49 63 6f 6e 69 73 68 | 20 74 68 61 6e 20 74 68 | Iconish| than th|
|00003290| 65 20 6e 6f 72 6d 61 6c | 20 7a 65 72 6f 20 6f 66 |e normal| zero of|
|000032a0| 66 73 65 74 20 75 73 65 | 64 20 62 79 20 74 67 6f |fset use|d by tgo|
|000032b0| 74 6f 2e 20 20 49 66 20 | 79 6f 75 20 77 61 6e 74 |to. If |you want|
|000032c0| 20 74 6f 0a 58 23 20 20 | 67 6f 20 74 6f 20 74 68 | to.X# |go to th|
|000032d0| 65 20 66 69 72 73 74 20 | 73 71 75 61 72 65 20 6f |e first |square o|
|000032e0| 6e 20 79 6f 75 72 20 73 | 63 72 65 65 6e 2c 20 74 |n your s|creen, t|
|000032f0| 68 65 6e 20 69 6e 63 6c | 75 64 65 20 69 6e 20 79 |hen incl|ude in y|
|00003300| 6f 75 72 20 70 72 6f 67 | 72 61 6d 0a 58 23 20 20 |our prog|ram.X# |
|00003310| 22 69 70 75 74 73 28 69 | 67 6f 74 6f 28 67 65 74 |"iputs(i|goto(get|
|00003320| 76 61 6c 28 22 63 6d 22 | 29 2c 31 2c 31 29 29 2e |val("cm"|),1,1)).|
|00003330| 22 0a 58 23 0a 58 23 20 | 20 69 70 75 74 73 28 63 |".X#.X# | iputs(c|
|00003340| 70 2c 61 66 66 63 6e 74 | 29 0a 58 23 09 45 71 75 |p,affcnt|).X#.Equ|
|00003350| 69 76 61 6c 65 6e 74 20 | 74 6f 20 74 70 75 74 73 |ivalent |to tputs|
|00003360| 2e 20 20 22 43 70 22 20 | 69 73 20 61 20 73 74 72 |. "Cp" |is a str|
|00003370| 69 6e 67 20 6f 62 74 61 | 69 6e 65 64 20 76 69 61 |ing obta|ined via|
|00003380| 20 67 65 74 76 61 6c 28 | 29 2c 0a 58 23 20 20 6f | getval(|),.X# o|
|00003390| 72 2c 20 69 6e 20 74 68 | 65 20 63 61 73 65 20 6f |r, in th|e case o|
|000033a0| 66 20 22 63 6d 2c 22 20 | 76 69 61 20 69 67 6f 74 |f "cm," |via igot|
|000033b0| 6f 28 67 65 74 76 61 6c | 28 22 63 6d 22 29 2c 78 |o(getval|("cm"),x|
|000033c0| 2c 79 29 2e 20 20 41 66 | 66 63 6e 74 20 69 73 20 |,y). Af|fcnt is |
|000033d0| 61 0a 58 23 20 20 63 6f | 75 6e 74 20 6f 66 20 61 |a.X# co|unt of a|
|000033e0| 66 66 65 63 74 65 64 20 | 6c 69 6e 65 73 2e 20 20 |ffected |lines. |
|000033f0| 49 74 20 69 73 20 6f 6e | 6c 79 20 72 65 6c 65 76 |It is on|ly relev|
|00003400| 61 6e 74 20 66 6f 72 20 | 74 65 72 6d 69 6e 61 6c |ant for |terminal|
|00003410| 73 20 77 68 69 63 68 0a | 58 23 20 20 73 70 65 63 |s which.|X# spec|
|00003420| 69 66 79 20 70 72 6f 70 | 6f 72 74 69 6f 6e 61 6c |ify prop|ortional|
|00003430| 20 28 73 74 61 72 72 65 | 64 29 20 64 65 6c 61 79 | (starre|d) delay|
|00003440| 73 20 69 6e 20 74 68 65 | 69 72 20 74 65 72 6d 63 |s in the|ir termc|
|00003450| 61 70 20 65 6e 74 72 69 | 65 73 2e 0a 58 23 0a 58 |ap entri|es..X#.X|
|00003460| 23 20 20 42 75 67 73 3a | 20 20 49 20 68 61 76 65 |# Bugs:| I have|
|00003470| 20 6e 6f 74 20 74 65 73 | 74 65 64 20 74 68 65 73 | not tes|ted thes|
|00003480| 65 20 72 6f 75 74 69 6e | 65 73 20 6f 6e 20 74 65 |e routin|es on te|
|00003490| 72 6d 69 6e 61 6c 73 20 | 74 68 61 74 20 72 65 71 |rminals |that req|
|000034a0| 75 69 72 65 0a 58 23 20 | 20 70 61 64 64 69 6e 67 |uire.X# | padding|
|000034b0| 2e 20 20 54 68 65 73 65 | 20 72 6f 75 74 69 6e 65 |. These| routine|
|000034c0| 73 20 57 49 4c 4c 20 4e | 4f 54 20 57 4f 52 4b 20 |s WILL N|OT WORK |
|000034d0| 69 66 20 79 6f 75 72 20 | 6d 61 63 68 69 6e 65 73 |if your |machines|
|000034e0| 20 73 74 74 79 20 63 6f | 6d 2d 0a 58 23 20 20 6d | stty co|m-.X# m|
|000034f0| 61 6e 64 20 68 61 73 20 | 6e 6f 20 2d 67 20 6f 70 |and has |no -g op|
|00003500| 74 69 6f 6e 20 28 74 69 | 73 6b 2c 20 74 69 73 6b |tion (ti|sk, tisk|
|00003510| 29 2e 20 20 54 68 69 73 | 20 69 6e 63 6c 75 64 65 |). This| include|
|00003520| 73 20 4e 65 58 54 20 77 | 6f 72 6b 73 74 61 2d 0a |s NeXT w|orksta-.|
|00003530| 58 23 20 20 74 69 6f 6e | 73 2c 20 61 6e 64 20 73 |X# tion|s, and s|
|00003540| 6f 6d 65 20 6f 74 68 65 | 72 73 20 74 68 61 74 20 |ome othe|rs that |
|00003550| 49 20 68 61 76 65 6e 27 | 74 20 68 61 64 20 74 69 |I haven'|t had ti|
|00003560| 6d 65 20 74 6f 20 70 69 | 6e 70 6f 69 6e 74 2e 0a |me to pi|npoint..|
|00003570| 58 23 0a 58 23 23 23 23 | 23 23 23 23 23 23 23 23 |X#.X####|########|
|00003580| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00003590| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|000035a0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|000035b0| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 0a 58 |########|######.X|
|000035c0| 23 0a 58 23 20 20 52 65 | 71 75 69 72 65 73 3a 20 |#.X# Re|quires: |
|000035d0| 55 4e 49 58 2c 20 63 6f | 2d 65 78 70 72 65 73 73 |UNIX, co|-express|
|000035e0| 69 6f 6e 73 0a 58 23 0a | 58 23 20 20 53 65 65 20 |ions.X#.|X# See |
|000035f0| 61 6c 73 6f 3a 20 69 73 | 63 72 65 65 6e 2e 69 63 |also: is|creen.ic|
|00003600| 6e 20 28 61 20 73 65 74 | 20 6f 66 20 63 6f 6d 70 |n (a set| of comp|
|00003610| 61 6e 69 6f 6e 20 75 74 | 69 6c 69 74 69 65 73 29 |anion ut|ilities)|
|00003620| 0a 58 23 0a 58 23 23 23 | 23 23 23 23 23 23 23 23 |.X#.X###|########|
|00003630| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00003640| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00003650| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 23 |########|########|
|00003660| 23 23 23 23 23 23 23 23 | 23 23 23 23 23 23 23 0a |########|#######.|
|00003670| 58 0a 58 0a 58 67 6c 6f | 62 61 6c 20 74 63 5f 74 |X.X.Xglo|bal tc_t|
|00003680| 61 62 6c 65 2c 20 74 74 | 79 5f 73 70 65 65 64 0a |able, tt|y_speed.|
|00003690| 58 72 65 63 6f 72 64 20 | 74 72 75 65 28 29 0a 58 |Xrecord |true().X|
|000036a0| 0a 58 0a 58 70 72 6f 63 | 65 64 75 72 65 20 63 68 |.X.Xproc|edure ch|
|000036b0| 65 63 6b 5f 66 65 61 74 | 75 72 65 73 28 29 0a 58 |eck_feat|ures().X|
|000036c0| 0a 58 20 20 20 20 6c 6f | 63 61 6c 20 69 6e 5f 70 |.X lo|cal in_p|
|000036d0| 61 72 61 6d 73 2c 20 6c | 69 6e 65 0a 58 20 20 20 |arams, l|ine.X |
|000036e0| 20 23 20 67 6c 6f 62 61 | 6c 20 74 74 79 5f 73 70 | # globa|l tty_sp|
|000036f0| 65 65 64 0a 58 0a 58 20 | 20 20 20 69 6e 69 74 69 |eed.X.X | initi|
|00003700| 61 6c 20 7b 0a 58 09 66 | 69 6e 64 28 22 75 6e 69 |al {.X.f|ind("uni|
|00003710| 78 22 2c 6d 61 70 28 26 | 66 65 61 74 75 72 65 73 |x",map(&|features|
|00003720| 29 29 20 7c 0a 58 09 20 | 20 20 20 65 72 28 22 63 |)) |.X. | er("c|
|00003730| 68 65 63 6b 5f 66 65 61 | 74 75 72 65 73 22 2c 22 |heck_fea|tures","|
|00003740| 75 6e 69 78 20 73 79 73 | 74 65 6d 20 72 65 71 75 |unix sys|tem requ|
|00003750| 69 72 65 64 22 2c 31 29 | 0a 58 09 66 69 6e 64 28 |ired",1)|.X.find(|
|00003760| 22 6f 2d 65 78 70 72 65 | 73 22 2c 26 66 65 61 74 |"o-expre|s",&feat|
|00003770| 75 72 65 73 29 20 7c 0a | 58 09 20 20 20 20 65 72 |ures) |.|X. er|
|00003780| 28 22 63 68 65 63 6b 5f | 66 65 61 74 75 72 65 73 |("check_|features|
|00003790| 22 2c 22 63 6f 2d 65 78 | 70 72 65 73 73 69 6f 6e |","co-ex|pression|
|000037a0| 73 20 6e 6f 74 20 69 6d | 70 6c 65 6d 65 6e 74 65 |s not im|plemente|
|000037b0| 64 20 2d 20 26 24 23 21 | 22 2c 31 29 0a 58 09 73 |d - &$#!|",1).X.s|
|000037c0| 79 73 74 65 6d 28 22 2f | 62 69 6e 2f 73 74 74 79 |ystem("/|bin/stty|
|000037d0| 20 74 61 62 73 22 29 20 | 7c 0a 58 09 20 20 20 20 | tabs") ||.X. |
|000037e0| 65 72 28 22 63 68 65 63 | 6b 5f 66 65 61 74 75 72 |er("chec|k_featur|
|000037f0| 65 73 22 2c 22 63 61 6e | 27 74 20 73 65 74 20 74 |es","can|'t set t|
|00003800| 61 62 73 20 6f 70 74 69 | 6f 6e 22 2c 31 29 0a 58 |abs opti|on",1).X|
|00003810| 20 20 20 20 7d 0a 58 0a | 58 20 20 20 20 23 20 63 | }.X.|X # c|
|00003820| 6c 75 6d 73 79 2c 20 63 | 6c 75 6d 73 79 2c 20 63 |lumsy, c|lumsy, c|
|00003830| 6c 75 6d 73 79 2c 20 61 | 6e 64 20 70 72 6f 62 61 |lumsy, a|nd proba|
|00003840| 62 6c 79 20 77 6f 6e 27 | 74 20 77 6f 72 6b 20 6f |bly won'|t work o|
|00003850| 6e 20 61 6c 6c 20 73 79 | 73 74 65 6d 73 0a 58 20 |n all sy|stems.X |
|00003860| 20 20 20 74 74 79 5f 73 | 70 65 65 64 20 3a 3d 20 | tty_s|peed := |
|00003870| 67 65 74 73 70 65 65 64 | 28 29 0a 58 20 20 20 20 |getspeed|().X |
|00003880| 72 65 74 75 72 6e 20 22 | 74 65 72 6d 20 63 68 61 |return "|term cha|
|00003890| 72 61 63 74 65 72 69 73 | 74 69 63 73 20 72 65 73 |racteris|tics res|
|000038a0| 65 74 3b 20 66 65 61 74 | 75 72 65 73 20 63 68 65 |et; feat|ures che|
|000038b0| 63 6b 20 6f 75 74 22 0a | 58 0a 58 65 6e 64 0a 58 |ck out".|X.Xend.X|
|000038c0| 0a 58 0a 58 0a 58 70 72 | 6f 63 65 64 75 72 65 20 |.X.X.Xpr|ocedure |
|000038d0| 73 65 74 6e 61 6d 65 28 | 6e 61 6d 65 29 0a 58 0a |setname(|name).X.|
|000038e0| 58 20 20 20 20 23 20 53 | 65 74 73 20 63 75 72 72 |X # S|ets curr|
|000038f0| 65 6e 74 20 74 65 72 6d | 69 6e 61 6c 20 74 79 70 |ent term|inal typ|
|00003900| 65 20 74 6f 20 22 6e 61 | 6d 65 22 20 61 6e 64 20 |e to "na|me" and |
|00003910| 62 75 69 6c 64 73 20 61 | 20 6e 65 77 20 74 65 72 |builds a| new ter|
|00003920| 6d 63 61 70 0a 58 20 20 | 20 20 23 20 63 61 70 61 |mcap.X | # capa|
|00003930| 62 69 6c 69 74 79 20 64 | 61 74 61 62 61 73 65 20 |bility d|atabase |
|00003940| 28 72 65 73 69 64 69 6e | 67 20 69 6e 20 74 63 5f |(residin|g in tc_|
|00003950| 74 61 62 6c 65 29 2e 20 | 20 46 61 69 6c 73 20 69 |table). | Fails i|
|00003960| 66 20 75 6e 61 62 6c 65 | 20 74 6f 0a 58 20 20 20 |f unable| to.X |
|00003970| 20 23 20 66 69 6e 64 20 | 61 20 74 65 72 6d 63 61 | # find |a termca|
|00003980| 70 20 65 6e 74 72 79 20 | 66 6f 72 20 74 65 72 6d |p entry |for term|
|00003990| 69 6e 61 6c 20 74 79 70 | 65 20 22 6e 61 6d 65 2e |inal typ|e "name.|
|000039a0| 22 20 20 49 66 20 79 6f | 75 20 77 61 6e 74 20 69 |" If yo|u want i|
|000039b0| 74 0a 58 20 20 20 20 23 | 20 74 6f 20 74 65 72 6d |t.X #| to term|
|000039c0| 69 6e 61 74 65 20 77 69 | 74 68 20 61 6e 20 65 72 |inate wi|th an er|
|000039d0| 72 6f 72 20 6d 65 73 73 | 61 67 65 20 75 6e 64 65 |ror mess|age unde|
|000039e0| 72 20 74 68 65 73 65 20 | 63 69 72 63 75 6d 73 74 |r these |circumst|
|000039f0| 61 6e 63 65 73 2c 0a 58 | 20 20 20 20 23 20 63 6f |ances,.X| # co|
|00003a00| 6d 6d 65 6e 74 20 6f 75 | 74 20 22 7c 20 66 61 69 |mment ou|t "| fai|
|00003a10| 6c 22 20 62 65 6c 6f 77 | 2c 20 61 6e 64 20 75 6e |l" below|, and un|
|00003a20| 63 6f 6d 6d 65 6e 74 20 | 74 68 65 20 65 72 28 29 |comment |the er()|
|00003a30| 20 6c 69 6e 65 2e 0a 58 | 0a 58 20 20 20 20 23 74 | line..X|.X #t|
|00003a40| 63 5f 74 61 62 6c 65 20 | 69 73 20 67 6c 6f 62 61 |c_table |is globa|
|00003a50| 6c 0a 58 20 20 20 20 0a | 58 20 20 20 20 63 68 65 |l.X .|X che|
|00003a60| 63 6b 5f 66 65 61 74 75 | 72 65 73 28 29 0a 58 0a |ck_featu|res().X.|
|00003a70| 58 20 20 20 20 74 63 5f | 74 61 62 6c 65 20 3a 3d |X tc_|table :=|
|00003a80| 20 74 61 62 6c 65 28 29 | 0a 58 20 20 20 20 74 63 | table()|.X tc|
|00003a90| 5f 74 61 62 6c 65 20 3a | 3d 20 6d 61 6b 65 74 63 |_table :|= maketc|
|00003aa0| 5f 74 61 62 6c 65 28 67 | 65 74 65 6e 74 72 79 28 |_table(g|etentry(|
|00003ab0| 6e 61 6d 65 29 29 20 7c | 20 66 61 69 6c 0a 58 20 |name)) || fail.X |
|00003ac0| 20 20 20 23 20 65 72 28 | 22 73 65 74 6e 61 6d 65 | # er(|"setname|
|00003ad0| 22 2c 22 6e 6f 20 74 65 | 72 6d 63 61 70 20 65 6e |","no te|rmcap en|
|00003ae0| 74 72 79 20 66 6f 75 6e | 64 20 66 6f 72 20 22 7c |try foun|d for "||
|00003af0| 7c 6e 61 6d 65 2c 33 29 | 0a 58 20 20 20 20 72 65 ||name,3)|.X re|
|00003b00| 74 75 72 6e 20 22 73 75 | 63 63 65 73 73 66 75 6c |turn "su|ccessful|
|00003b10| 6c 79 20 72 65 73 65 74 | 20 66 6f 72 20 74 65 72 |ly reset| for ter|
|00003b20| 6d 69 6e 61 6c 20 22 20 | 7c 7c 20 6e 61 6d 65 0a |minal " ||| name.|
|00003b30| 58 0a 58 65 6e 64 0a 58 | 0a 58 0a 58 0a 58 70 72 |X.Xend.X|.X.X.Xpr|
|00003b40| 6f 63 65 64 75 72 65 20 | 67 65 74 6e 61 6d 65 28 |ocedure |getname(|
|00003b50| 29 0a 58 0a 58 20 20 20 | 20 23 20 47 65 74 6e 61 |).X.X | # Getna|
|00003b60| 6d 65 28 29 20 66 69 72 | 73 74 20 63 68 65 63 6b |me() fir|st check|
|00003b70| 73 20 74 6f 20 62 65 20 | 73 75 72 65 20 77 65 27 |s to be |sure we'|
|00003b80| 72 65 20 72 75 6e 6e 69 | 6e 67 20 75 6e 64 65 72 |re runni|ng under|
|00003b90| 20 55 6e 69 78 2c 20 61 | 6e 64 2c 0a 58 20 20 20 | Unix, a|nd,.X |
|00003ba0| 20 23 20 69 66 20 73 6f | 2c 20 74 72 69 65 73 20 | # if so|, tries |
|00003bb0| 74 6f 20 66 69 67 75 72 | 65 20 6f 75 74 20 77 68 |to figur|e out wh|
|00003bc0| 61 74 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 74 |at the c|urrent t|
|00003bd0| 65 72 6d 69 6e 61 6c 20 | 74 79 70 65 20 69 73 2c |erminal |type is,|
|00003be0| 0a 58 20 20 20 20 23 20 | 63 68 65 63 6b 69 6e 67 |.X # |checking|
|00003bf0| 20 73 75 63 63 65 73 73 | 69 76 65 6c 79 20 74 68 | success|ively th|
|00003c00| 65 20 76 61 6c 75 65 20 | 6f 66 20 74 68 65 20 65 |e value |of the e|
|00003c10| 6e 76 69 72 6f 6e 6d 65 | 6e 74 20 76 61 72 69 61 |nvironme|nt varia|
|00003c20| 62 6c 65 0a 58 20 20 20 | 20 23 20 54 45 52 4d 2c |ble.X | # TERM,|
|00003c30| 20 61 6e 64 20 74 68 65 | 6e 20 74 68 65 20 6f 75 | and the|n the ou|
|00003c40| 74 70 75 74 20 6f 66 20 | 22 74 73 65 74 20 2d 22 |tput of |"tset -"|
|00003c50| 2e 20 20 54 65 72 6d 69 | 6e 61 74 65 73 20 77 69 |. Termi|nates wi|
|00003c60| 74 68 20 61 6e 20 65 72 | 72 6f 72 0a 58 20 20 20 |th an er|ror.X |
|00003c70| 20 23 20 6d 65 73 73 61 | 67 65 20 69 66 20 74 68 | # messa|ge if th|
|00003c80| 65 20 74 65 72 6d 69 6e | 61 6c 20 74 79 70 65 20 |e termin|al type |
|00003c90| 63 61 6e 6e 6f 74 20 62 | 65 20 61 73 63 65 72 74 |cannot b|e ascert|
|00003ca0| 61 69 6e 65 64 2e 0a 58 | 0a 58 20 20 20 20 6c 6f |ained..X|.X lo|
|00003cb0| 63 61 6c 20 74 65 72 6d | 2c 20 74 73 65 74 5f 6f |cal term|, tset_o|
|00003cc0| 75 74 70 75 74 0a 58 0a | 58 20 20 20 20 63 68 65 |utput.X.|X che|
|00003cd0| 63 6b 5f 66 65 61 74 75 | 72 65 73 28 29 0a 58 0a |ck_featu|res().X.|
|00003ce0| 58 20 20 20 20 69 66 20 | 6e 6f 74 20 28 74 65 72 |X if |not (ter|
|00003cf0| 6d 20 3a 3d 20 67 65 74 | 65 6e 76 28 22 54 45 52 |m := get|env("TER|
|00003d00| 4d 22 29 29 20 74 68 65 | 6e 20 7b 0a 58 09 74 73 |M")) the|n {.X.ts|
|00003d10| 65 74 5f 6f 75 74 70 75 | 74 20 3a 3d 20 6f 70 65 |et_outpu|t := ope|
|00003d20| 6e 28 22 2f 62 69 6e 2f | 74 73 65 74 20 2d 22 2c |n("/bin/|tset -",|
|00003d30| 22 70 72 22 29 20 7c 0a | 58 09 20 20 20 20 65 72 |"pr") |.|X. er|
|00003d40| 28 22 67 65 74 6e 61 6d | 65 22 2c 22 63 61 6e 27 |("getnam|e","can'|
|00003d50| 74 20 66 69 6e 64 20 74 | 73 65 74 20 63 6f 6d 6d |t find t|set comm|
|00003d60| 61 6e 64 22 2c 31 29 0a | 58 09 74 65 72 6d 20 3a |and",1).|X.term :|
|00003d70| 3d 20 21 74 73 65 74 5f | 6f 75 74 70 75 74 0a 58 |= !tset_|output.X|
|00003d80| 09 63 6c 6f 73 65 28 74 | 73 65 74 5f 6f 75 74 70 |.close(t|set_outp|
|00003d90| 75 74 29 0a 58 20 20 20 | 20 7d 0a 58 20 20 20 20 |ut).X | }.X |
|00003da0| 72 65 74 75 72 6e 20 5c | 74 65 72 6d 20 7c 0a 58 |return \|term |.X|
|00003db0| 09 65 72 28 22 67 65 74 | 6e 61 6d 65 22 2c 22 63 |.er("get|name","c|
|00003dc0| 61 6e 27 74 20 73 65 65 | 6d 20 74 6f 20 64 65 74 |an't see|m to det|
|00003dd0| 65 72 6d 69 6e 65 20 79 | 6f 75 72 20 74 65 72 6d |ermine y|our term|
|00003de0| 69 6e 61 6c 20 74 79 70 | 65 22 2c 31 29 0a 58 0a |inal typ|e",1).X.|
|00003df0| 58 65 6e 64 0a 58 0a 58 | 0a 58 0a 58 70 72 6f 63 |Xend.X.X|.X.Xproc|
|00003e00| 65 64 75 72 65 20 65 72 | 28 66 75 6e 63 2c 6d 73 |edure er|(func,ms|
|00003e10| 67 2c 65 72 72 6e 75 6d | 29 0a 58 0a 58 20 20 20 |g,errnum|).X.X |
|00003e20| 20 23 20 73 68 6f 72 74 | 20 65 72 72 6f 72 20 70 | # short| error p|
|00003e30| 72 6f 63 65 73 73 69 6e | 67 20 75 74 69 6c 69 74 |rocessin|g utilit|
|00003e40| 79 0a 58 20 20 20 20 77 | 72 69 74 65 28 26 65 72 |y.X w|rite(&er|
|00003e50| 72 6f 75 74 2c 66 75 6e | 63 2c 22 3a 20 20 22 2c |rout,fun|c,": ",|
|00003e60| 6d 73 67 29 0a 58 20 20 | 20 20 65 78 69 74 28 65 |msg).X | exit(e|
|00003e70| 72 72 6e 75 6d 29 0a 58 | 0a 58 65 6e 64 0a 58 0a |rrnum).X|.Xend.X.|
|00003e80| 58 0a 58 0a 58 70 72 6f | 63 65 64 75 72 65 20 67 |X.X.Xpro|cedure g|
|00003e90| 65 74 65 6e 74 72 79 28 | 6e 61 6d 65 2c 20 74 65 |etentry(|name, te|
|00003ea0| 72 6d 63 61 70 5f 73 74 | 72 69 6e 67 29 0a 58 0a |rmcap_st|ring).X.|
|00003eb0| 58 20 20 20 20 23 20 22 | 4e 61 6d 65 22 20 64 65 |X # "|Name" de|
|00003ec0| 73 69 67 6e 61 74 65 73 | 20 74 68 65 20 63 75 72 |signates| the cur|
|00003ed0| 72 65 6e 74 20 74 65 72 | 6d 69 6e 61 6c 20 74 79 |rent ter|minal ty|
|00003ee0| 70 65 2e 20 20 47 65 74 | 65 6e 74 72 79 28 29 20 |pe. Get|entry() |
|00003ef0| 73 63 61 6e 73 0a 58 20 | 20 20 20 23 20 74 68 65 |scans.X | # the|
|00003f00| 20 63 75 72 72 65 6e 74 | 20 65 6e 76 69 72 6f 6e | current| environ|
|00003f10| 6d 65 6e 74 20 66 6f 72 | 20 74 68 65 20 76 61 72 |ment for| the var|
|00003f20| 69 61 62 6c 65 20 54 45 | 52 4d 43 41 50 2e 20 20 |iable TE|RMCAP. |
|00003f30| 49 66 20 74 68 65 0a 58 | 20 20 20 20 23 20 54 45 |If the.X| # TE|
|00003f40| 52 4d 43 41 50 20 73 74 | 72 69 6e 67 20 72 65 70 |RMCAP st|ring rep|
|00003f50| 72 65 73 65 6e 74 73 20 | 61 20 74 65 72 6d 63 61 |resents |a termca|
|00003f60| 70 20 65 6e 74 72 79 20 | 66 6f 72 20 61 20 74 65 |p entry |for a te|
|00003f70| 72 6d 69 6e 61 6c 20 6f | 66 20 74 79 70 65 0a 58 |rminal o|f type.X|
|00003f80| 20 20 20 20 23 20 22 6e | 61 6d 65 2c 22 20 74 68 | # "n|ame," th|
|00003f90| 65 6e 20 67 65 74 65 6e | 74 72 79 28 29 20 72 65 |en geten|try() re|
|00003fa0| 74 75 72 6e 73 20 74 68 | 65 20 54 45 52 4d 43 41 |turns th|e TERMCA|
|00003fb0| 50 20 73 74 72 69 6e 67 | 2e 20 20 4f 74 68 65 72 |P string|. Other|
|00003fc0| 77 69 73 65 2c 0a 58 20 | 20 20 20 23 20 67 65 74 |wise,.X | # get|
|00003fd0| 65 6e 74 72 79 28 29 20 | 77 69 6c 6c 20 63 68 65 |entry() |will che|
|00003fe0| 63 6b 20 74 6f 20 73 65 | 65 20 69 66 20 54 45 52 |ck to se|e if TER|
|00003ff0| 4d 43 41 50 20 69 73 20 | 61 20 66 69 6c 65 20 6e |MCAP is |a file n|
|00004000| 61 6d 65 2e 20 20 49 66 | 20 73 6f 2c 0a 58 20 20 |ame. If| so,.X |
|00004010| 20 20 23 20 67 65 74 65 | 6e 74 72 79 28 29 20 77 | # gete|ntry() w|
|00004020| 69 6c 6c 20 73 63 61 6e | 20 74 68 61 74 20 66 69 |ill scan| that fi|
|00004030| 6c 65 20 66 6f 72 20 61 | 6e 20 65 6e 74 72 79 20 |le for a|n entry |
|00004040| 63 6f 72 72 65 73 70 6f | 6e 64 69 6e 67 20 74 6f |correspo|nding to|
|00004050| 0a 58 20 20 20 20 23 20 | 22 6e 61 6d 65 2e 22 20 |.X # |"name." |
|00004060| 20 49 66 20 74 68 65 20 | 54 45 52 4d 43 41 50 20 | If the |TERMCAP |
|00004070| 73 74 72 69 6e 67 20 64 | 6f 65 73 20 6e 6f 74 20 |string d|oes not |
|00004080| 64 65 73 69 67 6e 61 74 | 65 20 61 20 66 69 6c 65 |designat|e a file|
|00004090| 6e 61 6d 65 2c 0a 58 20 | 20 20 20 23 20 67 65 74 |name,.X | # get|
|000040a0| 65 6e 74 72 79 28 29 20 | 77 69 6c 6c 20 73 63 61 |entry() |will sca|
|000040b0| 6e 20 2f 65 74 63 2f 74 | 65 72 6d 63 61 70 20 66 |n /etc/t|ermcap f|
|000040c0| 6f 72 20 74 68 65 20 63 | 6f 72 72 65 63 74 20 65 |or the c|orrect e|
|000040d0| 6e 74 72 79 2e 0a 58 20 | 20 20 20 23 20 57 68 61 |ntry..X | # Wha|
|000040e0| 74 65 76 65 72 20 74 68 | 65 20 69 6e 70 75 74 20 |tever th|e input |
|000040f0| 66 69 6c 65 2c 20 69 66 | 20 61 6e 20 65 6e 74 72 |file, if| an entr|
|00004100| 79 20 66 6f 72 20 74 65 | 72 6d 69 6e 61 6c 20 22 |y for te|rminal "|
|00004110| 6e 61 6d 65 22 20 69 73 | 0a 58 20 20 20 20 23 20 |name" is|.X # |
|00004120| 66 6f 75 6e 64 2c 20 67 | 65 74 65 6e 74 72 79 28 |found, g|etentry(|
|00004130| 29 20 72 65 74 75 72 6e | 73 20 74 68 61 74 20 65 |) return|s that e|
|00004140| 6e 74 72 79 2e 20 20 4f | 74 68 65 72 77 69 73 65 |ntry. O|therwise|
|00004150| 2c 20 67 65 74 65 6e 74 | 72 79 28 29 0a 58 20 20 |, getent|ry().X |
|00004160| 20 20 23 20 66 61 69 6c | 73 2e 0a 58 0a 58 20 20 | # fail|s..X.X |
|00004170| 20 20 6c 6f 63 61 6c 20 | 66 2c 20 67 65 74 6c 69 | local |f, getli|
|00004180| 6e 65 2c 20 6c 69 6e 65 | 2c 20 6e 6d 2c 20 65 6e |ne, line|, nm, en|
|00004190| 74 31 2c 20 65 6e 74 32 | 0a 58 0a 58 20 20 20 20 |t1, ent2|.X.X |
|000041a0| 23 20 59 6f 75 20 63 61 | 6e 20 66 6f 72 63 65 20 |# You ca|n force |
|000041b0| 67 65 74 65 6e 74 72 79 | 28 29 20 74 6f 20 75 73 |getentry|() to us|
|000041c0| 65 20 61 20 73 70 65 63 | 69 66 69 63 20 74 65 72 |e a spec|ific ter|
|000041d0| 6d 63 61 70 20 66 69 6c | 65 20 62 79 20 63 61 6c |mcap fil|e by cal|
|000041e0| 2d 0a 58 20 20 20 20 23 | 20 6c 69 6e 67 20 69 74 |-.X #| ling it|
|000041f0| 20 77 69 74 68 20 61 20 | 73 65 63 6f 6e 64 20 61 | with a |second a|
|00004200| 72 67 75 6d 65 6e 74 20 | 2d 20 74 68 65 20 6e 61 |rgument |- the na|
|00004210| 6d 65 20 6f 66 20 74 68 | 65 20 74 65 72 6d 63 61 |me of th|e termca|
|00004220| 70 20 66 69 6c 65 0a 58 | 20 20 20 20 23 20 74 6f |p file.X| # to|
|00004230| 20 75 73 65 20 69 6e 73 | 74 65 61 64 20 6f 66 20 | use ins|tead of |
|00004240| 74 68 65 20 72 65 67 75 | 6c 61 72 20 6f 6e 65 2c |the regu|lar one,|
|00004250| 20 6f 72 20 74 68 65 20 | 6f 6e 65 20 73 70 65 63 | or the |one spec|
|00004260| 69 66 69 65 64 20 69 6e | 20 74 68 65 0a 58 20 20 |ified in| the.X |
|00004270| 20 20 23 20 74 65 72 6d | 63 61 70 20 65 6e 76 69 | # term|cap envi|
|00004280| 72 6f 6e 6d 65 6e 74 20 | 76 61 72 69 61 62 6c 65 |ronment |variable|
|00004290| 2e 0a 58 20 20 20 20 2f | 74 65 72 6d 63 61 70 5f |..X /|termcap_|
|000042a0| 73 74 72 69 6e 67 20 3a | 3d 20 67 65 74 65 6e 76 |string :|= getenv|
|000042b0| 28 22 54 45 52 4d 43 41 | 50 22 29 0a 58 0a 58 20 |("TERMCA|P").X.X |
|000042c0| 20 20 20 69 66 20 5c 74 | 65 72 6d 63 61 70 5f 73 | if \t|ermcap_s|
|000042d0| 74 72 69 6e 67 20 3f 20 | 28 6e 6f 74 20 6d 61 74 |tring ? |(not mat|
|000042e0| 63 68 28 22 2f 22 29 2c | 20 70 6f 73 28 30 29 20 |ch("/"),| pos(0) |
|000042f0| 7c 20 74 61 62 28 66 69 | 6e 64 28 22 7c 22 29 2b || tab(fi|nd("|")+|
|00004300| 31 29 2c 20 3d 6e 61 6d | 65 29 0a 58 20 20 20 20 |1), =nam|e).X |
|00004310| 74 68 65 6e 20 72 65 74 | 75 72 6e 20 74 65 72 6d |then ret|urn term|
|00004320| 63 61 70 5f 73 74 72 69 | 6e 67 0a 58 20 20 20 20 |cap_stri|ng.X |
|00004330| 65 6c 73 65 20 7b 0a 58 | 0a 58 09 23 20 54 68 65 |else {.X|.X.# The|
|00004340| 20 6c 6f 67 69 63 20 68 | 65 72 65 20 70 72 6f 62 | logic h|ere prob|
|00004350| 61 62 6c 79 20 69 73 6e | 27 74 20 63 6c 65 61 72 |ably isn|'t clear|
|00004360| 2e 20 20 54 68 65 20 69 | 64 65 61 20 69 73 20 74 |. The i|dea is t|
|00004370| 6f 20 74 72 79 20 74 6f | 20 75 73 65 0a 58 09 23 |o try to| use.X.#|
|00004380| 20 74 68 65 20 74 65 72 | 6d 63 61 70 20 65 6e 76 | the ter|mcap env|
|00004390| 69 72 6f 6e 6d 65 6e 74 | 20 76 61 72 69 61 62 6c |ironment| variabl|
|000043a0| 65 20 73 75 63 63 65 73 | 73 69 76 65 6c 79 20 61 |e succes|sively a|
|000043b0| 73 20 31 29 20 61 20 74 | 65 72 6d 63 61 70 20 65 |s 1) a t|ermcap e|
|000043c0| 6e 2d 0a 58 09 23 20 74 | 72 79 20 61 6e 64 20 74 |n-.X.# t|ry and t|
|000043d0| 68 65 6e 20 32 29 20 61 | 73 20 61 20 74 65 72 6d |hen 2) a|s a term|
|000043e0| 63 61 70 20 66 69 6c 65 | 2e 20 20 49 66 20 6e 65 |cap file|. If ne|
|000043f0| 69 74 68 65 72 20 77 6f | 72 6b 73 2c 20 33 29 20 |ither wo|rks, 3) |
|00004400| 67 6f 20 74 6f 0a 58 09 | 23 20 74 68 65 20 2f 65 |go to.X.|# the /e|
|00004410| 74 63 2f 74 65 72 6d 63 | 61 70 20 66 69 6c 65 2e |tc/termc|ap file.|
|00004420| 20 20 54 68 65 20 65 6c | 73 65 20 63 6c 61 75 73 | The el|se claus|
|00004430| 65 20 68 65 72 65 20 64 | 6f 65 73 20 32 20 61 6e |e here d|oes 2 an|
|00004440| 64 2c 20 69 66 20 6e 65 | 2d 0a 58 09 23 20 63 65 |d, if ne|-.X.# ce|
|00004450| 73 73 61 72 79 2c 20 33 | 2e 20 20 54 68 65 20 22 |ssary, 3|. The "|
|00004460| 5c 74 65 72 6d 63 61 70 | 5f 73 74 72 69 6e 67 20 |\termcap|_string |
|00004470| 3f 20 28 6e 6f 74 20 6d | 61 74 63 68 2e 2e 2e 22 |? (not m|atch..."|
|00004480| 20 65 78 70 72 65 73 73 | 69 6f 6e 0a 58 09 23 20 | express|ion.X.# |
|00004490| 68 61 6e 64 6c 65 73 20 | 31 2e 0a 58 0a 58 09 69 |handles |1..X.X.i|
|000044a0| 66 20 66 69 6e 64 28 22 | 2f 22 2c 5c 74 65 72 6d |f find("|/",\term|
|000044b0| 63 61 70 5f 73 74 72 69 | 6e 67 29 0a 58 09 74 68 |cap_stri|ng).X.th|
|000044c0| 65 6e 20 66 20 3a 3d 20 | 6f 70 65 6e 28 74 65 72 |en f := |open(ter|
|000044d0| 6d 63 61 70 5f 73 74 72 | 69 6e 67 29 0a 58 09 2f |mcap_str|ing).X./|
|000044e0| 66 20 3a 3d 20 6f 70 65 | 6e 28 22 2f 65 74 63 2f |f := ope|n("/etc/|
|000044f0| 74 65 72 6d 63 61 70 22 | 29 20 7c 0a 58 09 20 20 |termcap"|) |.X. |
|00004500| 20 20 65 72 28 22 67 65 | 74 65 6e 74 72 79 22 2c | er("ge|tentry",|
|00004510| 22 49 20 63 61 6e 27 74 | 20 61 63 63 65 73 73 20 |"I can't| access |
|00004520| 79 6f 75 72 20 2f 65 74 | 63 2f 74 65 72 6d 63 61 |your /et|c/termca|
|00004530| 70 20 66 69 6c 65 22 2c | 31 29 0a 58 0a 58 09 67 |p file",|1).X.X.g|
|00004540| 65 74 6c 69 6e 65 20 3a | 3d 20 63 72 65 61 74 65 |etline :|= create|
|00004550| 20 72 65 61 64 5f 66 69 | 6c 65 28 66 29 0a 58 20 | read_fi|le(f).X |
|00004560| 20 20 20 0a 58 09 77 68 | 69 6c 65 20 6c 69 6e 65 | .X.wh|ile line|
|00004570| 20 3a 3d 20 40 67 65 74 | 6c 69 6e 65 20 64 6f 20 | := @get|line do |
|00004580| 7b 0a 58 09 20 20 20 20 | 69 66 20 6c 69 6e 65 20 |{.X. |if line |
|00004590| 3f 20 28 70 6f 73 28 31 | 29 20 7c 20 74 61 62 28 |? (pos(1|) | tab(|
|000045a0| 66 69 6e 64 28 22 7c 22 | 29 2b 31 29 2c 20 3d 6e |find("|"|)+1), =n|
|000045b0| 61 6d 65 2c 20 61 6e 79 | 28 27 3a 7c 27 29 29 20 |ame, any|(':|')) |
|000045c0| 74 68 65 6e 20 7b 0a 58 | 09 09 65 6e 74 72 79 20 |then {.X|..entry |
|000045d0| 3a 3d 20 22 22 0a 58 09 | 09 77 68 69 6c 65 20 28 |:= "".X.|.while (|
|000045e0| 5c 6c 69 6e 65 20 7c 20 | 40 67 65 74 6c 69 6e 65 |\line | |@getline|
|000045f0| 29 20 3f 20 7b 0a 58 09 | 09 20 20 20 20 69 66 20 |) ? {.X.|. if |
|00004600| 65 6e 74 72 79 20 7c 7c | 3a 3d 20 31 28 74 61 62 |entry |||:= 1(tab|
|00004610| 28 66 69 6e 64 28 22 3a | 22 29 2b 31 29 2c 20 70 |(find(":|")+1), p|
|00004620| 6f 73 28 30 29 29 0a 58 | 09 09 20 20 20 20 74 68 |os(0)).X|.. th|
|00004630| 65 6e 20 7b 0a 58 09 09 | 09 63 6c 6f 73 65 28 66 |en {.X..|.close(f|
|00004640| 29 0a 58 09 09 09 23 20 | 69 66 20 65 6e 74 72 79 |).X...# |if entry|
|00004650| 20 65 6e 64 73 20 69 6e | 20 74 63 3d 20 74 68 65 | ends in| tc= the|
|00004660| 6e 20 61 64 64 20 69 6e | 20 74 68 65 20 6e 61 6d |n add in| the nam|
|00004670| 65 64 20 74 63 20 65 6e | 74 72 79 0a 58 09 09 09 |ed tc en|try.X...|
|00004680| 65 6e 74 72 79 20 3f 3a | 3d 20 74 61 62 28 66 69 |entry ?:|= tab(fi|
|00004690| 6e 64 28 22 74 63 3d 22 | 29 29 20 7c 7c 0a 58 09 |nd("tc="|)) ||.X.|
|000046a0| 09 09 20 20 20 20 23 20 | 72 65 63 75 72 73 69 76 |.. # |recursiv|
|000046b0| 65 6c 79 20 66 65 74 63 | 68 20 74 68 65 20 6e 65 |ely fetc|h the ne|
|000046c0| 77 20 74 65 72 6d 63 61 | 70 20 65 6e 74 72 79 0a |w termca|p entry.|
|000046d0| 58 09 09 09 20 20 20 20 | 28 6d 6f 76 65 28 33 29 |X... |(move(3)|
|000046e0| 2c 20 67 65 74 65 6e 74 | 72 79 28 74 61 62 28 66 |, getent|ry(tab(f|
|000046f0| 69 6e 64 28 22 3a 22 29 | 29 29 20 3f 0a 58 09 09 |ind(":")|)) ?.X..|
|00004700| 09 20 20 20 20 20 20 20 | 20 23 20 72 65 6d 6f 76 |. | # remov|
|00004710| 65 20 74 68 65 20 6e 61 | 6d 65 20 66 69 65 6c 64 |e the na|me field|
|00004720| 20 66 72 6f 6d 20 74 68 | 65 20 6e 65 77 20 65 6e | from th|e new en|
|00004730| 74 72 79 0a 58 09 09 09 | 20 20 20 20 20 09 28 74 |try.X...| .(t|
|00004740| 61 62 28 66 69 6e 64 28 | 22 3a 22 29 2b 31 29 2c |ab(find(|":")+1),|
|00004750| 20 74 61 62 28 30 29 29 | 29 0a 58 09 09 09 72 65 | tab(0))|).X...re|
|00004760| 74 75 72 6e 20 65 6e 74 | 72 79 0a 58 09 09 20 20 |turn ent|ry.X.. |
|00004770| 20 20 7d 0a 58 09 09 20 | 20 20 20 65 6c 73 65 20 | }.X.. | else |
|00004780| 7b 0a 58 09 09 09 5c 6c | 69 6e 65 20 3a 3d 20 26 |{.X...\l|ine := &|
|00004790| 6e 75 6c 6c 20 23 20 6d | 75 73 74 20 70 72 65 63 |null # m|ust prec|
|000047a0| 65 64 65 20 74 68 65 20 | 6e 65 78 74 20 6c 69 6e |ede the |next lin|
|000047b0| 65 0a 58 09 09 09 65 6e | 74 72 79 20 7c 7c 3a 3d |e.X...en|try ||:=|
|000047c0| 20 74 72 69 6d 28 74 72 | 69 6d 28 74 61 62 28 30 | trim(tr|im(tab(0|
|000047d0| 29 2c 27 5c 5c 27 29 2c | 27 3a 27 29 0a 58 09 09 |),'\\'),|':').X..|
|000047e0| 20 20 20 20 7d 0a 58 09 | 09 7d 0a 58 09 20 20 20 | }.X.|.}.X. |
|000047f0| 20 7d 0a 58 09 7d 0a 58 | 20 20 20 20 7d 0a 58 0a | }.X.}.X| }.X.|
|00004800| 58 20 20 20 20 63 6c 6f | 73 65 28 66 29 0a 58 20 |X clo|se(f).X |
|00004810| 20 20 20 65 72 28 22 67 | 65 74 65 6e 74 72 79 22 | er("g|etentry"|
|00004820| 2c 22 63 61 6e 27 74 20 | 66 69 6e 64 20 61 6e 64 |,"can't |find and|
|00004830| 2f 6f 72 20 70 72 6f 63 | 65 73 73 20 79 6f 75 72 |/or proc|ess your|
|00004840| 20 74 65 72 6d 63 61 70 | 20 65 6e 74 72 79 22 2c | termcap| entry",|
|00004850| 33 29 0a 58 20 0a 58 65 | 6e 64 0a 58 0a 58 0a 58 |3).X .Xe|nd.X.X.X|
|00004860| 0a 58 70 72 6f 63 65 64 | 75 72 65 20 72 65 61 64 |.Xproced|ure read|
|00004870| 5f 66 69 6c 65 28 66 29 | 0a 58 0a 58 20 20 20 20 |_file(f)|.X.X |
|00004880| 23 20 53 75 73 70 65 6e | 64 73 20 61 6c 6c 20 6e |# Suspen|ds all n|
|00004890| 6f 6e 20 23 2d 69 6e 69 | 74 69 61 6c 20 6c 69 6e |on #-ini|tial lin|
|000048a0| 65 73 20 69 6e 20 74 68 | 65 20 66 69 6c 65 20 66 |es in th|e file f|
|000048b0| 2e 0a 58 20 20 20 20 23 | 20 52 65 6d 6f 76 65 73 |..X #| Removes|
|000048c0| 20 6c 65 61 64 69 6e 67 | 20 74 61 62 73 20 61 6e | leading| tabs an|
|000048d0| 64 20 73 70 61 63 65 73 | 20 66 72 6f 6d 20 6c 69 |d spaces| from li|
|000048e0| 6e 65 73 20 62 65 66 6f | 72 65 20 73 75 73 70 65 |nes befo|re suspe|
|000048f0| 6e 64 69 6e 67 0a 58 20 | 20 20 20 23 20 74 68 65 |nding.X | # the|
|00004900| 6d 2e 0a 58 0a 58 20 20 | 20 20 6c 6f 63 61 6c 20 |m..X.X | local |
|00004910| 6c 69 6e 65 0a 58 0a 58 | 20 20 20 20 5c 66 20 7c |line.X.X| \f ||
|00004920| 20 65 72 28 22 72 65 61 | 64 5f 74 63 61 70 5f 66 | er("rea|d_tcap_f|
|00004930| 69 6c 65 22 2c 22 6e 6f | 20 76 61 6c 69 64 20 74 |ile","no| valid t|
|00004940| 65 72 6d 63 61 70 20 66 | 69 6c 65 20 66 6f 75 6e |ermcap f|ile foun|
|00004950| 64 22 2c 33 29 0a 58 20 | 20 20 20 77 68 69 6c 65 |d",3).X | while|
|00004960| 20 6c 69 6e 65 20 3a 3d | 20 72 65 61 64 28 66 29 | line :=| read(f)|
|00004970| 20 64 6f 20 7b 0a 58 09 | 6d 61 74 63 68 28 22 23 | do {.X.|match("#|
|00004980| 22 2c 6c 69 6e 65 29 20 | 26 20 6e 65 78 74 0a 58 |",line) |& next.X|
|00004990| 09 6c 69 6e 65 20 3f 3a | 3d 20 28 74 61 62 28 6d |.line ?:|= (tab(m|
|000049a0| 61 6e 79 28 27 5c 74 20 | 27 29 29 20 7c 20 26 6e |any('\t |')) | &n|
|000049b0| 75 6c 6c 2c 20 74 61 62 | 28 30 29 29 0a 58 09 73 |ull, tab|(0)).X.s|
|000049c0| 75 73 70 65 6e 64 20 6c | 69 6e 65 0a 58 20 20 20 |uspend l|ine.X |
|000049d0| 20 7d 0a 58 0a 58 20 20 | 20 20 66 61 69 6c 0a 58 | }.X.X | fail.X|
|000049e0| 0a 58 65 6e 64 0a 58 0a | 58 0a 58 0a 58 70 72 6f |.Xend.X.|X.X.Xpro|
|000049f0| 63 65 64 75 72 65 20 6d | 61 6b 65 74 63 5f 74 61 |cedure m|aketc_ta|
|00004a00| 62 6c 65 28 65 6e 74 72 | 79 29 0a 58 0a 58 20 20 |ble(entr|y).X.X |
|00004a10| 20 20 23 20 4d 61 6b 65 | 74 63 5f 74 61 62 6c 65 | # Make|tc_table|
|00004a20| 28 73 29 20 28 77 68 65 | 72 65 20 73 20 69 73 20 |(s) (whe|re s is |
|00004a30| 61 20 76 61 6c 69 64 20 | 74 65 72 6d 63 61 70 20 |a valid |termcap |
|00004a40| 65 6e 74 72 79 20 66 6f | 72 20 73 6f 6d 65 0a 58 |entry fo|r some.X|
|00004a50| 20 20 20 20 23 20 74 65 | 72 6d 69 6e 61 6c 2d 74 | # te|rminal-t|
|00004a60| 79 70 65 29 3a 20 52 65 | 74 75 72 6e 73 20 61 20 |ype): Re|turns a |
|00004a70| 74 61 62 6c 65 20 69 6e | 20 77 68 69 63 68 20 74 |table in| which t|
|00004a80| 68 65 20 6b 65 79 73 20 | 61 72 65 20 74 65 72 6d |he keys |are term|
|00004a90| 63 61 70 0a 58 20 20 20 | 20 23 20 63 61 70 61 62 |cap.X | # capab|
|00004aa0| 69 6c 69 74 79 20 64 65 | 73 69 67 6e 61 74 6f 72 |ility de|signator|
|00004ab0| 73 2c 20 61 6e 64 20 74 | 68 65 20 76 61 6c 75 65 |s, and t|he value|
|00004ac0| 73 20 61 72 65 20 74 68 | 65 20 65 6e 74 72 69 65 |s are th|e entrie|
|00004ad0| 73 20 69 6e 0a 58 20 20 | 20 20 23 20 22 65 6e 74 |s in.X | # "ent|
|00004ae0| 72 79 22 20 66 6f 72 20 | 74 68 6f 73 65 20 64 65 |ry" for |those de|
|00004af0| 73 69 67 6e 61 74 6f 72 | 73 2e 0a 58 0a 58 20 20 |signator|s..X.X |
|00004b00| 20 20 6c 6f 63 61 6c 20 | 6b 2c 20 76 0a 58 0a 58 | local |k, v.X.X|
|00004b10| 20 20 20 20 2f 65 6e 74 | 72 79 20 26 20 65 72 28 | /ent|ry & er(|
|00004b20| 22 6d 61 6b 65 74 63 5f | 74 61 62 6c 65 22 2c 22 |"maketc_|table","|
|00004b30| 6e 6f 20 65 6e 74 72 79 | 20 67 69 76 65 6e 22 2c |no entry| given",|
|00004b40| 38 29 0a 58 20 20 20 20 | 69 66 20 65 6e 74 72 79 |8).X |if entry|
|00004b50| 5b 2d 31 5d 20 7e 3d 3d | 20 22 3a 22 20 74 68 65 |[-1] ~==| ":" the|
|00004b60| 6e 20 65 6e 74 72 79 20 | 7c 7c 3a 3d 20 22 3a 22 |n entry |||:= ":"|
|00004b70| 0a 58 20 20 20 20 0a 58 | 20 20 20 20 2f 74 63 5f |.X .X| /tc_|
|00004b80| 74 61 62 6c 65 20 3a 3d | 20 74 61 62 6c 65 28 29 |table :=| table()|
|00004b90| 0a 58 0a 58 20 20 20 20 | 65 6e 74 72 79 20 3f 20 |.X.X |entry ? |
|00004ba0| 7b 0a 58 0a 58 09 74 61 | 62 28 66 69 6e 64 28 22 |{.X.X.ta|b(find("|
|00004bb0| 3a 22 29 2b 31 29 09 23 | 20 74 61 62 20 70 61 73 |:")+1).#| tab pas|
|00004bc0| 74 20 69 6e 69 74 69 61 | 6c 20 28 6e 61 6d 65 29 |t initia|l (name)|
|00004bd0| 20 66 69 65 6c 64 0a 58 | 0a 58 09 77 68 69 6c 65 | field.X|.X.while|
|00004be0| 20 74 61 62 28 28 66 69 | 6e 64 28 22 3a 22 29 2b | tab((fi|nd(":")+|
|00004bf0| 31 29 20 5c 20 31 29 20 | 3f 20 7b 0a 58 09 20 20 |1) \ 1) |? {.X. |
|00004c00| 20 20 26 73 75 62 6a 65 | 63 74 20 3d 3d 20 22 22 | &subje|ct == ""|
|00004c10| 20 26 20 6e 65 78 74 0a | 58 09 20 20 20 20 69 66 | & next.|X. if|
|00004c20| 20 6b 20 3a 3d 20 31 28 | 6d 6f 76 65 28 32 29 2c | k := 1(|move(2),|
|00004c30| 20 3d 22 3d 22 29 0a 58 | 09 20 20 20 20 74 68 65 | ="=").X|. the|
|00004c40| 6e 20 74 63 5f 74 61 62 | 6c 65 5b 6b 5d 20 3a 3d |n tc_tab|le[k] :=|
|00004c50| 20 44 65 63 6f 64 65 28 | 74 61 62 28 66 69 6e 64 | Decode(|tab(find|
|00004c60| 28 22 3a 22 29 29 29 0a | 58 09 20 20 20 20 65 6c |(":"))).|X. el|
|00004c70| 73 65 20 69 66 20 6b 20 | 3a 3d 20 31 28 6d 6f 76 |se if k |:= 1(mov|
|00004c80| 65 28 32 29 2c 20 3d 22 | 23 22 29 0a 58 09 20 20 |e(2), ="|#").X. |
|00004c90| 20 20 74 68 65 6e 20 74 | 63 5f 74 61 62 6c 65 5b | then t|c_table[|
|00004ca0| 6b 5d 20 3a 3d 20 69 6e | 74 65 67 65 72 28 74 61 |k] := in|teger(ta|
|00004cb0| 62 28 66 69 6e 64 28 22 | 3a 22 29 29 29 0a 58 09 |b(find("|:"))).X.|
|00004cc0| 20 20 20 20 65 6c 73 65 | 20 69 66 20 6b 20 3a 3d | else| if k :=|
|00004cd0| 20 31 28 74 61 62 28 66 | 69 6e 64 28 22 3a 22 29 | 1(tab(f|ind(":")|
|00004ce0| 29 2c 20 70 6f 73 28 2d | 31 29 29 0a 58 09 20 20 |), pos(-|1)).X. |
|00004cf0| 20 20 74 68 65 6e 20 74 | 63 5f 74 61 62 6c 65 5b | then t|c_table[|
|00004d00| 6b 5d 20 3a 3d 20 74 72 | 75 65 28 29 0a 58 09 20 |k] := tr|ue().X. |
|00004d10| 20 20 20 65 6c 73 65 20 | 65 72 28 22 6d 61 6b 65 | else |er("make|
|00004d20| 74 63 5f 74 61 62 6c 65 | 22 2c 20 22 79 6f 75 72 |tc_table|", "your|
|00004d30| 20 74 65 72 6d 63 61 70 | 20 66 69 6c 65 20 68 61 | termcap| file ha|
|00004d40| 73 20 61 20 62 61 64 20 | 65 6e 74 72 79 22 2c 33 |s a bad |entry",3|
|00004d50| 29 0a 58 09 7d 0a 58 20 | 20 20 20 7d 0a 58 0a 58 |).X.}.X | }.X.X|
|00004d60| 20 20 20 20 72 65 74 75 | 72 6e 20 74 63 5f 74 61 | retu|rn tc_ta|
|00004d70| 62 6c 65 0a 58 0a 58 65 | 6e 64 0a 58 0a 58 0a 58 |ble.X.Xe|nd.X.X.X|
|00004d80| 0a 58 70 72 6f 63 65 64 | 75 72 65 20 67 65 74 76 |.Xproced|ure getv|
|00004d90| 61 6c 28 69 64 29 0a 58 | 0a 58 20 20 20 20 2f 74 |al(id).X|.X /t|
|00004da0| 63 5f 74 61 62 6c 65 20 | 3a 3d 20 6d 61 6b 65 74 |c_table |:= maket|
|00004db0| 63 5f 74 61 62 6c 65 28 | 67 65 74 65 6e 74 72 79 |c_table(|getentry|
|00004dc0| 28 67 65 74 6e 61 6d 65 | 28 29 29 29 20 7c 0a 58 |(getname|())) |.X|
|00004dd0| 09 65 72 28 22 67 65 74 | 76 61 6c 22 2c 22 63 61 |.er("get|val","ca|
|00004de0| 6e 27 74 20 6d 61 6b 65 | 20 61 20 74 61 62 6c 65 |n't make| a table|
|00004df0| 20 66 6f 72 20 79 6f 75 | 72 20 74 65 72 6d 69 6e | for you|r termin|
|00004e00| 61 6c 22 2c 34 29 0a 58 | 0a 58 20 20 20 20 72 65 |al",4).X|.X re|
|00004e10| 74 75 72 6e 20 5c 74 63 | 5f 74 61 62 6c 65 5b 69 |turn \tc|_table[i|
|00004e20| 64 5d 20 7c 20 66 61 69 | 6c 0a 58 09 23 20 65 72 |d] | fai|l.X.# er|
|00004e30| 28 22 67 65 74 76 61 6c | 22 2c 22 74 68 65 20 63 |("getval|","the c|
|00004e40| 75 72 72 65 6e 74 20 74 | 65 72 6d 69 6e 61 6c 20 |urrent t|erminal |
|00004e50| 64 6f 65 73 6e 27 74 20 | 73 75 70 70 6f 72 74 20 |doesn't |support |
|00004e60| 22 7c 7c 69 64 2c 37 29 | 0a 53 48 41 52 5f 45 4f |"||id,7)|.SHAR_EO|
|00004e70| 46 0a 74 72 75 65 20 7c | 7c 20 65 63 68 6f 20 27 |F.true ||| echo '|
|00004e80| 72 65 73 74 6f 72 65 20 | 6f 66 20 69 74 6c 69 62 |restore |of itlib|
|00004e90| 2e 69 63 6e 20 66 61 69 | 6c 65 64 27 0a 66 69 0a |.icn fai|led'.fi.|
|00004ea0| 65 63 68 6f 20 27 45 6e | 64 20 6f 66 20 20 70 61 |echo 'En|d of pa|
|00004eb0| 72 74 20 31 27 0a 65 63 | 68 6f 20 27 46 69 6c 65 |rt 1'.ec|ho 'File|
|00004ec0| 20 69 74 6c 69 62 2e 69 | 63 6e 20 69 73 20 63 6f | itlib.i|cn is co|
|00004ed0| 6e 74 69 6e 75 65 64 20 | 69 6e 20 70 61 72 74 20 |ntinued |in part |
|00004ee0| 32 27 0a 65 63 68 6f 20 | 32 20 3e 20 5f 73 68 61 |2'.echo |2 > _sha|
|00004ef0| 72 5f 73 65 71 5f 2e 74 | 6d 70 0a 65 78 69 74 20 |r_seq_.t|mp.exit |
|00004f00| 30 0a | |0. | |
+--------+-------------------------+-------------------------+--------+--------+