home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2389 < prev    next >
Internet Message Format  |  1990-12-28  |  8KB

  1. From: goer@ellis.uchicago.edu (Richard L. Goerwitz)
  2. Newsgroups: alt.sources
  3. Subject: itlib part 3 of 3
  4. Message-ID: <1990Dec21.055811.22641@midway.uchicago.edu>
  5. Date: 21 Dec 90 05:58:11 GMT
  6.  
  7.  
  8. ---- Cut Here and feed the following to sh ----
  9. #!/bin/sh
  10. # this is itlib.03 (part 3 of a multipart archive)
  11. # do not concatenate these parts, unpack them in order with /bin/sh
  12. # file itlibdos.icn continued
  13. #
  14. if test ! -r _shar_seq_.tmp; then
  15.     echo 'Please unpack part 1 first!'
  16.     exit 1
  17. fi
  18. (read Scheck
  19.  if test "$Scheck" != 3; then
  20.     echo Please unpack part "$Scheck" next!
  21.     exit 1
  22.  else
  23.     exit 0
  24.  fi
  25. ) < _shar_seq_.tmp || exit 1
  26. if test ! -f _shar_wnt_.tmp; then
  27.     echo 'x - still skipping itlibdos.icn'
  28. else
  29. echo 'x - continuing file itlibdos.icn'
  30. sed 's/^X//' << 'SHAR_EOF' >> 'itlibdos.icn' &&
  31. X            then {
  32. X            close(f)
  33. X            # if entry ends in tc= then add in the named tc entry
  34. X            entry ?:= tab(find("tc=")) ||
  35. X                # recursively fetch the new termcap entry
  36. X                (move(3), getentry(tab(find(":"))) ?
  37. X                    # remove the name field from the new entry
  38. X                     (tab(find(":")+1), tab(0)))
  39. X            return entry
  40. X            }
  41. X            else {
  42. X            \line := &null # must precede the next line
  43. X            entry ||:= trim(trim(tab(0),'\\'),':')
  44. X            }
  45. X        }
  46. X        }
  47. X    }
  48. X    }
  49. X
  50. X    close(f)
  51. X    er("getentry","can't find and/or process your termcap entry",3)
  52. Xend
  53. X
  54. X
  55. X
  56. Xprocedure read_file(f)
  57. X
  58. X    # Suspends all non #-initial lines in the file f.
  59. X    # Removes leading tabs and spaces from lines before suspending
  60. X    # them.
  61. X
  62. X    local line
  63. X
  64. X    \f | er("read_tcap_file","no valid termcap file found",3)
  65. X    while line := read(f) do {
  66. X    match("#",line) & next
  67. X    line ?:= (tab(many('\t ')) | &null, tab(0))
  68. X    suspend line
  69. X    }
  70. X
  71. X    fail
  72. X
  73. Xend
  74. X
  75. X
  76. X
  77. Xprocedure maketc_table(entry)
  78. X
  79. X    # Maketc_table(s) (where s is a valid termcap entry for some
  80. X    # terminal-type): Returns a table in which the keys are termcap
  81. X    # capability designators, and the values are the entries in
  82. X    # "entry" for those designators.
  83. X
  84. X    local k, v
  85. X
  86. X    /entry & er("maketc_table","no entry given",8)
  87. X    if entry[-1] ~== ":" then entry ||:= ":"
  88. X    
  89. X    tc_table := table()
  90. X
  91. X    entry ? {
  92. X
  93. X    tab(find(":")+1)    # tab past initial (name) field
  94. X
  95. X    while tab((find(":")+1) \ 1) ? {
  96. X
  97. X        &subject == "" & next
  98. X        if k := 1(move(2), ="=")
  99. X        then tc_table[k] := Decode(tab(find(":")))
  100. X        else if k := 1(move(2), ="#")
  101. X        then tc_table[k] := integer(tab(find(":")))
  102. X        else if k := 1(tab(find(":")), pos(-1))
  103. X        then tc_table[k] := true()
  104. X        else er("maketc_table", "your termcap file has a bad entry",3)
  105. X    }
  106. X    }
  107. X
  108. X    return tc_table
  109. X
  110. Xend
  111. X
  112. X
  113. X
  114. Xprocedure getval(id)
  115. X
  116. X    /tc_table := maketc_table(getentry(getname())) |
  117. X    er("getval","can't make a table for your terminal",4)
  118. X
  119. X    return \tc_table[id] | fail
  120. X    # er("getval","the current terminal doesn't support "||id,7)
  121. X
  122. Xend
  123. X
  124. X
  125. X
  126. Xprocedure Decode(s)
  127. X
  128. X    # Does things like turn ^ plus a letter into a genuine control
  129. X    # character.
  130. X
  131. X    new_s := ""
  132. X
  133. X    s ? {
  134. X    while new_s ||:= tab(upto('\\^')) do {
  135. X        chr := move(1)
  136. X        if chr == "\\" then {
  137. X        new_s ||:= {
  138. X            case chr2 := move(1) of {
  139. X            "\\" : "\\"
  140. X            "^"  : "^"
  141. X            "E"  : "\e"
  142. X            "b"  : "\b"
  143. X            "f"  : "\f"
  144. X            "n"  : "\n"
  145. X            "r"  : "\r"
  146. X            "t"  : "\t"
  147. X            default : {
  148. X                if any(&digits,chr2) then {
  149. X                char(integer("8r"||chr2||move(2 to 0 by -1))) |
  150. X                    er("Decode","bad termcap entry",3)
  151. X                }
  152. X               else chr2
  153. X            }
  154. X            }
  155. X        }
  156. X        }
  157. X        else new_s ||:= char(ord(map(move(1),&lcase,&ucase)) - 64)
  158. X    }
  159. X    new_s ||:= tab(0)
  160. X    }
  161. X
  162. X    return new_s
  163. X
  164. Xend
  165. X
  166. X
  167. X
  168. Xprocedure igoto(cm,col,line)
  169. X
  170. X    local colline, range, increment, str, outstr, chr, x, y
  171. X
  172. X    if col > (tc_table["co"]) | line > (tc_table["li"]) then {
  173. X    colline := string(\col) || "," || string(\line) | string(\col|line)
  174. X    range := "(" || tc_table["co"]-1 || "," || tc_table["li"]-1 || ")"
  175. X    er("igoto",colline || " out of range " || (\range|""),9)
  176. X    } 
  177. X
  178. X    # Use the Iconish 1;1 upper left corner & not the C-ish 0 offsets
  179. X    increment := -1
  180. X    outstr := ""
  181. X    
  182. X    cm ? {
  183. X    while outstr ||:= tab(find("%")) do {
  184. X        tab(match("%"))
  185. X        chr := move(1)
  186. X        if case chr of {
  187. X        "." :  outstr ||:= char(line + increment)
  188. X        "+" :  outstr ||:= char(line + ord(move(1)) + increment)
  189. X        "d" :  {
  190. X            str := string(line + increment)
  191. X            outstr ||:= right(str, integer(tab(any('23'))), "0") | str
  192. X        }
  193. X        }
  194. X        then line :=: col
  195. X        else {
  196. X        case chr of {
  197. X            "n" :  line := ixor(line,96) & col := ixor(col,96)
  198. X            "i" :  increment := 0
  199. X            "r" :  line :=: col
  200. X            "%" :  outstr ||:= "%"
  201. X            "B" :  line := ior(ishift(line / 10, 4), line % 10)
  202. X            ">" :  {
  203. X            x := move(1); y := move(1)
  204. X            line > ord(x) & line +:= ord(y)
  205. X            &null
  206. X            }
  207. X        } | er("goto","bad termcap entry",5)
  208. X        }
  209. X    }
  210. X    return outstr || tab(0)
  211. X    }
  212. X
  213. Xend
  214. X
  215. X
  216. X
  217. Xprocedure iputs(cp, affcnt)
  218. X
  219. X    # Writes cp to the screen.  Use this instead of writes() for
  220. X    # compatibility with the Unix version (which will need to send
  221. X    # null padding in some cases).  Iputs() also does a useful type
  222. X    # check.
  223. X
  224. X    static num_chars
  225. X    initial num_chars := &digits ++ '.'
  226. X
  227. X    type(cp) == "string" |
  228. X    er("iputs","you can't iputs() a non-string value!",10)
  229. X
  230. X    cp ? {
  231. X    if tab(many(num_chars)) & ="*" then
  232. X        stop("iputs:  MS-DOS termcap files shouldn't specify padding.")
  233. X    writes(tab(0))
  234. X    }
  235. X
  236. X    return
  237. X
  238. Xend
  239. SHAR_EOF
  240. echo 'File itlibdos.icn is complete' &&
  241. true || echo 'restore of itlibdos.icn failed'
  242. rm -f _shar_wnt_.tmp
  243. fi
  244. # ============= termcap.dos ==============
  245. if test -f 'termcap.dos' -a X"$1" != X"-c"; then
  246.     echo 'x - skipping termcap.dos (File already exists)'
  247.     rm -f _shar_wnt_.tmp
  248. else
  249. > _shar_wnt_.tmp
  250. echo 'x - extracting termcap.dos (Text)'
  251. sed 's/^X//' << 'SHAR_EOF' > 'termcap.dos' &&
  252. Xansi|color|ansi-color|ibm|ibmpc|ANSI.SYS color:\
  253. X    :co#80:li#24:bs:pt:bl=^G:le=^H:do=^J:\
  254. X    :cl=\E[H\E[2J:ce=\E[K:\
  255. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  256. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  257. X    :ti=\E[0;44m:te=\E[0m:\
  258. X    :so=\E[1;35;44m:se=\E[0;44m:\
  259. X    :us=\E[1;31;44m:ue=\E[0;44m:\
  260. X    :mb=\E[5m:md=\E[1m:me=\E[0;44m:
  261. Xmono|ansi-mono|ANSI.SYS:\
  262. X    :co#80:li#24:bs:pt:bl=^G:le=^H:do=^J:\
  263. X    :cl=\E[H\E[2J:ce=\E[K:\
  264. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  265. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  266. X    :so=\E[1m:se=\E[m:us=\E[4m:ue=\E[m:\
  267. X    :mb=\E[5m:md=\E[1m:me=\E[m:
  268. Xnnansi-mono|NNANSI.SYS:\
  269. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  270. X    :cl=\E[2J:cd=\E[J:ce=\E[K:\
  271. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  272. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  273. X    :so=\E[1m:se=\E[2m:\
  274. X    :us=\E[4m:ue=\E[24m:\
  275. X    :mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:me=\E[m:\
  276. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  277. Xnnansi|nnansi-color|NNANSI.SYS color:\
  278. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  279. X    :cl=\E[2J:cd=\E[J:ce=\E[K:\
  280. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  281. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  282. X    :ti=\E[0;44m:te=\E[0m:\
  283. X    :so=\E[1;35;44m:se=\E[2;37m:\
  284. X    :us=\E[4m:ue=\E[24m:\
  285. X    :mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:me=\E[0;44m:\
  286. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  287. Xnansi-mono|zansi-mono|N/ZANSI.SYS:\
  288. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  289. X    :cl=\E[2J:ce=\E[K:\
  290. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  291. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  292. X    :ti=\E[0m:te=\E[0m:\
  293. X    :so=\E[1;35m:se=\E[0m:\
  294. X    :us=\E[1;31m:ue=\E[0m:\
  295. X    :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:\
  296. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  297. Xnansi|zansi|nansi-color|zansi-color|N/ZANSI.SYS color:\
  298. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  299. X    :cl=\E[2J:ce=\E[K:\
  300. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  301. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  302. X    :ti=\E[0;44m:te=\E[0m:\
  303. X    :so=\E[1;35;44m:se=\E[0;44m:\
  304. X    :us=\E[1;31;44m:ue=\E[0;44m:\
  305. X    :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[0;44m:\
  306. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  307. XAX|ANSI X3.64|full ANSI X3.64 (1977) standard:\
  308. X    :co#80:li#24:bs:pt:am:mi:bl=^G:le=^H:\
  309. X    :cl=\E[2J:ce=\E[K:cd=\E[J:\
  310. X    :ho=\E[H:cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:\
  311. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  312. X    :UP=\E[%dA:DO=\E[%dB:LE=\E[%dC:RI=\E[%dD:\
  313. X    :so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\
  314. X    :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:as=^N:ae=^O:\
  315. X    :ku=\E[A:kd=\E[B:kl=\E[C:kr=\E[D:kb=^H:\
  316. X    :kn#4:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\
  317. X    :im=\E[4h:ei=\E[4l:al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:sf=\ED:sr=\EM:
  318. SHAR_EOF
  319. true || echo 'restore of termcap.dos failed'
  320. rm -f _shar_wnt_.tmp
  321. fi
  322. rm -f _shar_seq_.tmp
  323. echo You have unpacked the last part
  324. exit 0
  325.