home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-19 | 34.7 KB | 1,151 lines |
- Newsgroups: comp.sources.misc
- From: goer@midway.uchicago.edu (Richard L. Goerwitz)
- Subject: v23i067: quranref - Holy Qur'an word and passage based retrievals, Part01/08
- Message-ID: <csm-v23i067=quranref.212044@sparky.IMD.Sterling.COM>
- X-Md4-Signature: 750eeae3f5ebb7092a4730e97c859c57
- Date: Sat, 19 Oct 1991 02:22:04 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: goer@midway.uchicago.edu (Richard L. Goerwitz)
- Posting-number: Volume 23, Issue 67
- Archive-name: quranref/part01
- Environment: Icon
-
- Program: Quranref (built on top of Bibleref, a Bible concordance
- program archived on cs.arizona.edu [icon/contrib/bible-
- ref-2.1.tar.Z])
-
- Requires: Icon version 8, a working, up-to-date Icon Program Library
- (Icon ftp-able from cs.arizona.edu [icon/interpreter])
- and M. H. Shakir's translation of the Holy Qur'an, as
- archived by Cary Maguire on princeton.edu (pub/Quran.tar.Z).
-
- This package, Quranref, offers simple tools for word and
- passage-based access to M. H. Shakir's translation of the Holy Qur'an.
- Quranref is quick, and fairly easy to install (assuming you possess
- the machine readable text, a sufficiently powerful machine, and know a
- little about Icon). It will also run with stock terminals - even
- nasty old ones that leave magic cookies on your screen. Quranref
- will, however, put a bit of a dent in your mass storage resources.
- Your 900k or so Qur'an text will get block Huffman encoded, which will
- bring it down to about 500k. The freed space, however, will be
- gobbled up immediately by some 500k of auxiliary files, and by the
- 180k executable (more if you compile, rather than interpret). In-core
- requirements for the executable start at about 300k, and go up from
- there (if your searches are complex enough, you could easily eat up a
- megabyte or two). In brief: Quranref enjoys dining on your memory
- resources. Once set up, though, it can operate with fairly minimal
- impact on the CPU.
- With Quranref, you can perform most of the more basic,
- low-level functions commercial browsing packages offer (and perhaps a
- few not found in some of the commercial Qur'an study packages). You
- can, for example,
-
- - retrieve any passage by section:verse number
- - move forward or backward relative to the retrieved passage
- - search the entire Qur'an for words and/or word-patterns
- - search for word co-occurrences (or the absence thereof)
- - save passages and/or passage-lists for use with an editor
-
- Although this program is hardly the product of any major research
- effort :-), it should prove sophisticated enough for casual use. Its
- main fault right now is that it relies on a newly scanned text which
- is positively rife with errors. The high number of errors is nothing
- unusual for a text put into machine readable form by current OCR
- technology, so no insult is intended to the people who rendered us
- this great service. It is merely a fact about the current
- distribution that should be noted before attempting any serious
- research.
-
- Richard L. Goerwitz <uunet!midway.uchicago.edu!goer>
-
- ---- Cut Here and feed the following to sh ----
- #!/bin/sh
- # This is a shell archive (produced by shar 3.49)
- # To extract the files from this archive, save it to a file, remove
- # everything above the "!/bin/sh" line above, and type "sh file_name".
- #
- # made 09/29/1991 18:35 UTC by richard@zenu
- # Source directory /u/richard/Quranref/src
- #
- # existing files will NOT be overwritten unless -c is specified
- # This format requires very little intelligence at unshar time.
- # "if test", "cat", "rm", "echo", "true", and "sed" may be needed.
- #
- # This is part 1 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 6503 -rw-r--r-- bibleref.src
- # 3343 -r--r--r-- ref2bmap.icn
- # 3613 -r--r--r-- name2num.icn
- # 2889 -r--r--r-- convertb.icn
- # 14079 -r--r--r-- listutil.icn
- # 7564 -r--r--r-- passutil.icn
- # 2816 -r--r--r-- readfile.icn
- # 6533 -r--r--r-- srchutil.icn
- # 456 -r--r--r-- version.icn
- # 5988 -r--r--r-- complete.icn
- # 744 -r--r--r-- ipause.icn
- # 1205 -r--r--r-- inbits.icn
- # 4314 -r--r--r-- rewrap.icn
- # 20980 -r--r--r-- findre.icn
- # 7644 -r--r--r-- huffcode.icn
- # 1855 -r--r--r-- binsrch.icn
- # 5545 -r--r--r-- bmp2text.icn
- # 3560 -r--r--r-- initfile.icn
- # 7084 -r--r--r-- retrieve.icn
- # 7273 -r--r--r-- indexutl.icn
- # 6810 -r--r--r-- retrops.icn
- # 6627 -r--r--r-- whatnext.icn
- # 18055 -r--r--r-- iolib.icn
- # 6945 -r--r--r-- iscreen.icn
- # 5064 -r--r--r-- qur2rtv.icn
- # 21093 -r--r--r-- makeind.icn
- # 2423 -r--r--r-- gettokens.icn
- # 5587 -r--r--r-- Makefile.dist
- # 20638 -rw-r--r-- README
- # 15736 -rw-r--r-- README.rtv
- # 3067 -r--r--r-- outbits.icn
- #
- if test -r _shar_seq_.tmp; then
- echo 'Must unpack archives in sequence!'
- echo Please unpack part `cat _shar_seq_.tmp` next
- exit 1
- fi
- # ============= bibleref.src ==============
- if test -f 'bibleref.src' -a X"$1" != X"-c"; then
- echo 'x - skipping bibleref.src (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting bibleref.src (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'bibleref.src' &&
- X############################################################################
- X#
- X# Name: bibleref.icn
- X#
- X# Title: Bible Reference Finder
- X#
- X# Author: Richard L. Goerwitz
- X#
- X# Version: 1.22
- X#
- X############################################################################
- X#
- X# This program helps the user locate and browse passages from the
- X# PD-SIG King James or CCAT Revised Standard Version of the Bible.
- X# Startup syntax is
- X#
- X# bibleref [-f filename] [-v]
- X#
- X# where filename is the name of the indexed Bible text you wish to
- X# peruse. Because the KJV/RSV filename is hard-coded into the program,
- X# you need not supply the -f argument. It is available, though,
- X# just in case you have indexed another biblical file, and wish to
- X# use that instead.
- X#
- X# If bibleref is called with a -v argument, it prints the version
- X# number and patchlevel, then exits.
- X#
- X# This particular file contains only the basic command loop, some
- X# initialization routines, and some basic clearing/prompting/reading
- X# utilities. The other integral file is listutil.icn, which contains
- X# all of the basic list and passage display routines.
- X#
- X############################################################################
- X#
- X# Requires: UNIX, fully updated & installed Icon Program Library
- X#
- X############################################################################
- X#
- X# Links: ./ref2bmap.icn ./name2num.icn ./convertb.icn ./complete.icn
- X# ./binsrch.icn ./bmp2text.icn ./initfile.icn ./retrieve.icn
- X# ./indexutl.icn ./retrops.icn ./whatnext.icn ./iolib.icn
- X# ./iscreen.icn ./listutil.icn ./rewrap.icn ./passutil.icn
- X# ./srchutil.icn ./readfile (and probably others I've forgotten)
- X#
- X# Until incorporated into Icon, also link: ./ipause.icn
- X#
- X# See also: kjv2rtv.icn, makeind.icn, retrieve.icn, iolib.icn
- X#
- X############################################################################
- X
- Xglobal kjv_filename, lists
- Xrecord lst(l,pos,old_n,s,long)
- X
- X
- Xprocedure main(a)
- X
- X local option_table, filename, prompt, intext, first, result
- X # global lists
- X initial {
- X lists := []
- X checkout_features()
- X option_table := getopts(a, "f:v")
- X if \option_table["v"] then abort("Bibleref", _version(), 0)
- X kjv_filename := \option_table["f"] | "/usr/local/lib/bibleref/kjv.rtv"
- X initialize_screen()
- X message("Initializing offset file...")
- X initfile(kjv_filename) |
- X quit("main","can't locate "||kjv_filename,1)
- X }
- X
- X # Setup initial prompt.
- X prompt := "Enter passage, or f to find a word (q to quit): "
- X
- X # Read user input.
- X while intext := snarf_input(prompt) do {
- X
- X trim(intext,'\t ') ? {
- X
- X # See if the user has just input a passage reference.
- X # If so, then display it...
- X if display_passage(intext) then
- X result := "yes"
- X
- X # ...otherwise, see if his/her input matches any of the
- X # following commands:
- X else {
- X first := move(1) | "c"
- X case first of {
- X "!" : push_shell() & initialize_screen()
- X "c" : initialize_screen() # c = clear
- X "d" : display_list() # d = display (a list)
- X "f" : { # f = find a word
- X if search_database() # insert new list into "lists"
- X then display_list() # stores it as a record (lst)
- X }
- X "l" : show_lists() # l = list all lists
- X "q" : { # q = quit program
- X if pos(0) & "y" == snarf_input("Really quit? (y/n) ")
- X then break
- X }
- X "r" : readfile() & display_list()# r = read file from disk
- X default : { # input error
- X err_message("Unrecognized passage or command.")
- X next
- X }
- X }
- X }
- X # If we have any tangible search results, or else have viewed
- X # a passage, then alter the prompt to reflect the full range
- X # of options.
- X \result | *\lists > 0 &
- X prompt := "Enter passage, or !/c/d/f/l/q/r: "
- X }
- X }
- X
- X # Clear, say goodbye, and exit with zero status.
- X initialize_screen()
- X message("Thanks for using Bibleref.")
- X write(); exit(0)
- X
- Xend
- X
- X
- Xprocedure initialize_screen()
- X
- X #
- X # Initialize screen
- X #
- X local msg, short_message
- X
- X pos(0) | {
- X err_message("Garbage characters after \"c\" command.")
- X fail
- X }
- X
- X msg := "\"Bibleref\" - a Bible browser by Richard Goerwitz"
- X short_message := "\"Bibleref,\" by RG"
- X
- X clear()
- X status_line(msg, short_message, "c") &
- X return
- X
- Xend
- X
- X
- Xprocedure snarf_input(prompt)
- X
- X #
- X # Read user input after displaying a prompt.
- X #
- X local command
- X # global commands
- X
- X /prompt := "Please input: "
- X message(prompt)
- X return read() | ""
- X
- Xend
- X
- X
- Xprocedure err_message(msg)
- X
- X #
- X # Display error message for 1 second; erase.
- X #
- X /msg := "Error."
- X message(msg)
- X ipause(700) # until Icon gets a sleep function
- X message("")
- X return
- X
- Xend
- X
- X
- Xprocedure status_message(msg)
- X
- X #
- X # Display some status message on the highlighted status line.
- X #
- X status_line(msg) &
- X return
- X
- Xend
- X
- X
- Xprocedure checkout_features()
- X
- X #
- X # Check to see if we have the necessary terminal & OS features.
- X #
- X local capname
- X
- X every capname := ("li","co","ce") do {
- X getval(capname) | {
- X quit("check_features",
- X "terminal lacks "||capname||" capability", 2)
- X }
- X }
- X find("UNIX",&features) |
- X quit("check_features", "OS unsupported", 1)
- X return
- X
- Xend
- X
- X
- Xprocedure quit(s1, s2, i)
- X
- X #
- X # Move cursor to bottom screen line & abort, sending the message
- X # s1: s2 to the user, and exiting with status i.
- X #
- X iputs(igoto(getval("cm"), 1, getval("li")))
- X iputs(getval("ce"))
- X abort(s1, s2, i)
- X
- Xend
- X
- X
- Xprocedure getopts(arg,optstring)
- X
- X #
- X # Get opts. Based on Bob Alexander & Gregg Townsend's IPL
- X # options procedure.
- X #
- X local x,i,c,otab,flist,o,p
- X
- X /optstring := string(&letters)
- X otab := table()
- X flist := []
- X while x := get(arg) do {
- X x ? {
- X if ="-" & not pos(0) then {
- X if ="-" & pos(0) then break
- X while c := move(1) do
- X if i := find(c,optstring) + 1 then
- X otab[c] :=
- X if any(':+.',o := optstring[i]) then {
- X p := "" ~== tab(0) | get(arg) |
- X quit("getopts", "No parameter following -"||c, 1)
- X case o of {
- X ":": p
- X "+": integer(p) |
- X quit("getopts", "-"||c||" needs numeric", 1)
- X ".": real(p) |
- X quit("getopts", "-"||c||" needs numeric", 1)
- X }
- X }
- X else 1
- X else quit("getopts","Unrecognized option: -"||c, 1)
- X }
- X else put(flist,x)
- X }
- X }
- X while push(arg,pull(flist))
- X return otab
- X
- Xend
- SHAR_EOF
- true || echo 'restore of bibleref.src failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= ref2bmap.icn ==============
- if test -f 'ref2bmap.icn' -a X"$1" != X"-c"; then
- echo 'x - skipping ref2bmap.icn (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ref2bmap.icn (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ref2bmap.icn' &&
- X############################################################################
- X#
- X# Name: ref2bmap.icn
- X#
- X# Title: convert English reference to a bitmap
- X#
- X# Author: Richard L. Goerwitz
- X#
- X# Version: 1.15
- X#
- X############################################################################
- X#
- X# Converts an English reference (e.g. "Ex 4:2" for the Bible; "4:2"
- X# for the Quran) to a bitmap suitable for retrieval via
- X# bitmap_2_text(bitmap, filename). Syntax:
- X#
- X# ref_2_bitmap(english_ref, filename)
- X#
- X# fails if the requested conversion can't be performed on account of
- X# a misspelling. Aborts if the file whose name is given as arg 2
- X# does not have a transparently [book:]chapter:verse organization
- X# (i.e. IS.no must = 2 or 3).
- X#
- X############################################################################
- X#
- X# Links: complete.icn, ./initfile.icn ./name2num.icn
- X#
- X############################################################################
- X
- X# Declared in indexutl.icn.
- X# record is(FS, s_len, len, no, is_case_sensitive)
- X# global IS
- X
- X# Declared in initfile.icn.
- X# global filestats
- X# record Fs(ind_filename,bmp_filename,lim_filename, IS, ofs_table,all_bitmaps)
- X
- X
- Xprocedure ref_2_bitmap(s, filename)
- X
- X local bitmap, bookname, book_numeric, field, no
- X
- X # Check for sloppy programming.
- X /filename & abort("ref_2_bitmap","you called me without a filename",54)
- X
- X # If necessary, initialize stats for the current file.
- X #
- X if /filestats | /filestats[filename]
- X then initfile(filename) # see initfile.icn
- X IS := filestats[filename].IS
- X 1 < IS.no < 4 | abort("ref_2_bitmap","oops; IS.no is not = (2|3)",51)
- X
- X # IS.len = the number of bits needed to hold an integer
- X # representation of a single field in filename
- X # IS.no = number of fields in bitmaps for filename
- X # s = English Bible reference (e.g. Gen 8:10)
- X # no = number of fields minus one
- X
- X no := IS.no
- X bookname := ""
- X bitmap := 0
- X
- X s ? {
- X
- X if IS.no = 3 then {
- X no -:= 1
- X # Find book name, convert it to an integer.
- X bookname ||:= tab(any('1234')) | {
- X (="first", "1") |
- X (="second", "2") |
- X (="third", "3") |
- X (="fourth", "4")
- X }
- X tab(many(' '))
- X bookname ||:= trim(tab(many(&letters ++ ' '))) | fail
- X # Fail if the user gives us just a single letter...
- X *bookname > 1 | fail
- X # ...otherwise, convert book name into the correct value for
- X # for this file, and fit it into a proper-length bit field.
- X book_numeric := name2num(bookname) | fail
- X bitmap := ior(bitmap, ishift(book_numeric, no * IS.len)) | fail
- X }
- X
- X # Get book and verse fields. Add them, shifted appropriately,
- X # to bitmap.
- X while tab(upto(&digits)) do {
- X no -:= 1
- X # If no goes below 0 then we have too many fields for the
- X # file named in arg 2.
- X no >= 0 | fail
- X # If you prefer to abort with an error, uncomment this.
- X # no >= 0 | abort("ref_2_bitmap", "impossible reference",52)
- X bitmap := ior(bitmap, ishift(tab(many(&digits)), no * IS.len))
- X }
- X }
- X
- X # If the current no is not 0, then we have either too many or too
- X # few fields. This check can be disabled, to allow for dummy
- X # specifications (e.g. in a biblicat test, Exod would imply all of
- X # the book of Exodus).
- X no = 0 | fail
- X
- X return bitmap
- X
- Xend
- SHAR_EOF
- true || echo 'restore of ref2bmap.icn failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= name2num.icn ==============
- if test -f 'name2num.icn' -a X"$1" != X"-c"; then
- echo 'x - skipping name2num.icn (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting name2num.icn (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'name2num.icn' &&
- X############################################################################
- X#
- X# Name: name2num.icn
- X#
- X# Title: convert English book name to an integer
- X#
- X# Author: Richard L. Goerwitz
- X#
- X# Version: 1.8
- X#
- X############################################################################
- X#
- X# Used by ref_2_bitmap(), convertr(), etc.
- X#
- X############################################################################
- X
- X
- Xprocedure name2num(s)
- X
- X # Map English book names or abbreviations to numeric values.
- X
- X local n, b_name, tmp_names, i, nameset
- X static names, abbrevtbl
- X initial {
- X
- X names := ["genesis", "exodus", "leviticus", "numbers",
- X "deuteronomy", "joshua", "judges", "ruth",
- X "1samuel", "2samuel", "1kings", "2kings",
- X "1chronicles", "2chronicles", "ezra",
- X "nehemiah", "esther", "job", "psalms",
- X "proverbs", "ecclesiastes", "canticles",
- X "isaiah", "jeremiah", "lamentations", "ezekiel",
- X "daniel", "hosea", "joel", "amos", "obadiah",
- X "jonah", "micah", "nahum", "habakkuk",
- X "zephaniah", "haggai", "zechariah", "malachi",
- X "matthew", "mark", "luke", "john", "acts",
- X "romans", "1corinthians", "2corinthians",
- X "galations", "ephesians", "philippians",
- X "colossians", "1thessalonians",
- X "2thessalonians", "1timothy", "2timothy",
- X "titus", "philemon", "hebrews", "james",
- X "1peter", "2peter", "1john", "2john", "3john",
- X "jude", "revelation",
- X
- X "gen", "exod", "lev", "num", "deut", "josh",
- X "judg", "ruth", "1sam", "2sam", "1kgs", "2kgs",
- X "1chr", "2chr", "ezra", "neh", "esth", "job",
- X "pss", "prov", "qoh", "cant", "isa", "jer",
- X "lam", "ezek", "dan", "hos", "joel", "amos",
- X "obad", "jonah", "mic", "nahum", "hab", "zeph",
- X "hag", "zech", "mal", "mat", "mark", "luke",
- X "john", "acts", "rom", "1cor", "2cor", "gal",
- X "eph", "phil", "col", "1thess", "2thess",
- X "1tim", "2tim", "titus", "phlm", "heb", "jas",
- X "1pet", "2pet", "1john", "2john", "3john",
- X "jude", "rev",
- X
- X "dt", "jdg", "jg", "rth", "sa1", "sa2", "ki1",
- X "ki2", "ch1", "ch2", "jl", "mt", "mk", "lk",
- X "jn", "co1", "co2", "th1", "th2", "ti1", "ti2",
- X "phm", "pe1", "pe2", "jo1", "jo2", "jo3", "1jn",
- X "2jn", "3jn",
- X
- X "1esdras", "2esdras", "tobit", "judith",
- X "additions to esther", "wisdom of solomon",
- X "sirach prologue", "sirach", "baruch", "letter _
- X of jeremiah", "prayer of azariah", "susanna",
- X "bel and the dragon", "prayer of manasseh",
- X "1maccabees", "2maccabees", "3maccabees",
- X "4maccabees",
- X
- X "1esdr", "2esdr", "tob", "jdt", "addesth",
- X "wis", "sirp", "sir", "bar", "letjer", "prazar",
- X "suz", "bel", "prman", "1macc", "2macc",
- X "3macc", "4macc",
- X
- X "song of songs", "solomon", "song of solomon",
- X
- X "3ezra", "4ezra", "3esdras", "4esdras",
- X "adesth", "ecclesiasticus", "ecclus", "epjer",
- X "epistle of jeremiah", "s of 3 y", "s. of 3 y.",
- X "manasseh"]
- X
- X abbrevtbl := table()
- X tmp_names := copy(names)
- X every i := (1 to 66) | (1 to 66) |
- X 5|7|7|8|9|10|11|12|13|14|29|40|41|42|43|46|
- X 47|52|53|54|55|57|60|61|62|63|64|62|63|64|
- X (67 to 84) | (67 to 84) | 22|22|22|
- X 67|68|67|68|71|74|74|76|76|77|77|80
- X do {
- X insert(abbrevtbl, get(tmp_names), i)
- X }
- X }
- X
- X nameset := set()
- X every insert(nameset, complete(map(s), names))
- X case *nameset of {
- X 0 : fail
- X 1 : return abbrevtbl[!nameset]
- X default : suspend abbrevtbl[!sort(nameset)]
- X }
- X
- Xend
- SHAR_EOF
- true || echo 'restore of name2num.icn failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= convertb.icn ==============
- if test -f 'convertb.icn' -a X"$1" != X"-c"; then
- echo 'x - skipping convertb.icn (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting convertb.icn (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'convertb.icn' &&
- X############################################################################
- X#
- X# Name: convertb.icn
- X#
- X# Title: convert 3-field book,chap,verse bitmap into a human-
- X# readable book chapter:verse reference
- X#
- X# Author: Richard L. Goerwitz
- X#
- X# Version: 1.7
- X#
- X############################################################################
- X#
- X# Links: complete.icn ./initfile.icn
- X#
- X############################################################################
- X
- X# Declared in indexutl.icn.
- X# record is(FS, s_len, len, no, is_case_sensitive)
- X# global IS
- X
- X# Declared in initfile.icn.
- X# global filestats
- X# record Fs(ind_filename,bmp_filename,lim_filename, IS, ofs_table,all_bitmaps)
- X
- Xprocedure convertb(bitmap, filename)
- X
- X local no, reference, field_mask
- X
- X # Check for sloppy programming.
- X /filename & abort("convertb","you called me without a filename",70)
- X
- X # If necessary, initialize stats for the current file.
- X #
- X if /filestats | /filestats[filename]
- X then initfile(filename) # see initfile.icn
- X IS := filestats[filename].IS
- X 1 < IS.no < 4 | abort("convertb", "can't handle IS.no < 2 or > 3", 71)
- X
- X # IS.len = the number of bits needed to hold an integer
- X # representation of a single field in filename
- X # IS.no = number of fields in bitmaps for filename
- X
- X no := IS.no-1
- X field_mask := 2^(IS.len)-1
- X
- X if IS.no = 3 then {
- X # No need for mask here; add it just in case.
- X reference := Num2Name(
- X iand(field_mask, ishift(bitmap, -(no*IS.len))), "kjv.rtv") |
- X abort("convertb", "can't convert first field", 52)
- X no -:= 1
- X }
- X else reference := ""
- X
- X reference ||:= " " || iand(field_mask, ishift(bitmap, -(no*IS.len)))
- X no -:= 1
- X reference ||:= ":" || iand(field_mask, ishift(bitmap, -(no*IS.len)))
- X
- X return reference
- X
- Xend
- X
- X
- X
- Xprocedure Num2Name(i)
- X
- X # Map English book names or abbreviations to numeric values.
- X
- X local names, n
- X static num_table
- X initial {
- X names := [ "Gen", "Exod", "Lev", "Num", "Deut", "Josh",
- X "Judg", "Ruth", "1Sam", "2Sam", "1Kgs", "2Kgs",
- X "1Chr", "2Chr", "Ezra", "Neh", "Esth", "Job",
- X "Pss", "Prov", "Qoh", "Cant", "Isa", "Jer",
- X "Lam", "Ezek", "Dan", "Hos", "Joel", "Amos",
- X "Obad", "Jonah", "Mic", "Nahum", "Hab", "Zeph",
- X "Hag", "Zech", "Mal", "Mat", "Mark", "Luke",
- X "John", "Acts", "Rom", "1Cor", "2Cor", "Gal",
- X "Eph", "Phil", "Col", "1Thess", "2Thess",
- X "1Tim", "2Tim", "Titus", "Phlm", "Heb", "Jas",
- X "1Pet", "2Pet", "1John", "2John", "3John",
- X "Jude", "Rev", "1Esdr", "2Esdr", "Tob", "Jdt",
- X "Addest", "Wis", "Sirp", "Sir", "Bar", "Letjer",
- X "Prazar", "Suz", "Bel", "Prman", "1Macc",
- X "2Macc", "3Macc", "4Macc"]
- X
- X num_table := table()
- X every n := 1 to 84 do
- X insert(num_table, n, get(names))
- X }
- X
- X return num_table[i]
- X
- Xend
- SHAR_EOF
- true || echo 'restore of convertb.icn failed'
- rm -f _shar_wnt_.tmp
- fi
- # ============= listutil.icn ==============
- if test -f 'listutil.icn' -a X"$1" != X"-c"; then
- echo 'x - skipping listutil.icn (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting listutil.icn (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'listutil.icn' &&
- X############################################################################
- X#
- X# Name: 1.26
- X#
- X# Title: bibleref list display utilities
- X#
- X# Author: Richard L. Goerwitz
- X#
- X# Version: listutil.icn
- X#
- X############################################################################
- X#
- X# Contains:
- X#
- X# display_list(), which displays all passages in a given bitmap
- X# list by calling listlist(), which converts the bitmaps to
- X# human-readable format, and writes them to the screen
- X#
- X# listlist(), on which see above,
- X#
- X# writelist(), which writes a bitmap list in human readable form
- X# to a file.
- X#
- X############################################################################
- X#
- X# Links: uses push_shell(), which is in ./passutil.icn
- X#
- X############################################################################
- X
- X# Declared in bibleref.icn. l is the list itself, pos is the viewer's
- X# last position in the list. old_n is the last passage in the list that
- X# was viewed. s is a brief indication of the search string used to gen-
- X# erate the list.
- X# record lst(l,pos,old_n,s,long)
- X
- Xglobal _subscripts # get around unreachable coexpression bug
- X
- Xprocedure display_list()
- X
- X #
- X # Display a retrieved "hit list."
- X #
- X local passage, subscr
- X
- X #
- X # We're in the midst of a scanning expression in the main
- X # command loop. If the "d" command was given with no arguments,
- X # then default to the last list retrieved.
- X #
- X if pos(0) then {
- X subscr := (0 ~= *lists) | {
- X err_message("No lists have been created yet.")
- X fail
- X }
- X }
- X #
- X # If we are not at pos(0) then we are to go to a specific list
- X # in the list history.
- X #
- X else {
- X if not {
- X tab(upto('-+' ++ &digits)) &
- X subscr := integer(tab(many('-+' ++ &digits))) &
- X pos(0)
- X }
- X # If we don't have an integer, then the user has screwed
- X # up somehow.
- X then {
- X err_message("Garbage characters after \"d\" command.")
- X fail
- X }
- X # Check to be sure the subscript give is in range.
- X lists[subscr] | {
- X err_message("There is no list number "||subscr||".")
- X fail
- X }
- X }
- X
- X #
- X # While listlist gives us a valid passage reference, display it.
- X # When it returns &null or fails, quit.
- X #
- X repeat {
- X
- X # Display the list (defaults above to the last list in the list
- X # history). Use listlist(). Arg 1 is the lst record, which
- X # contains a list and a position to start viewing that list at.
- X # The second arg to listlist tells the user the length of the
- X # list. The last arg specifies how many display columns we can
- X # eat up before truncating.
- X passage :=
- X listlist(
- X lists[subscr],
- X "length = "||*lists[subscr].l||"; "||
- X "search string = "||lists[subscr].s,
- X getval("co")-10
- X ) | fail
- X if /passage then return
- X else display_passage(passage)
- X }
- X
- Xend
- X
- X
- X
- Xprocedure listlist(lst_rec, msg, width)
- X
- X local l, i, ss, j, n, ref, prompt, rsp, rsp2
- X static lines
- X initial lines := getval("li")-3
- X
- X # "l" is a record of type lst, containing the list to print
- X # "msg" is the message to put on the status line
- X # "width" gives the length to which lines in l are truncated
- X # "offset" gives the starting offset in l at which to begin
- X # printing (default 0).
- X
- X l := lst_rec.l
- X
- X repeat {
- X i := 0
- X while *l >= (ss := lst_rec.pos + (lines > (i +:= 1))) do {
- X iputs(igoto(getval("cm"), 1, i))
- X normal(); iputs(getval("ce"))
- X writes(" ", left(ss||".",7))
- X ref := convertb(l[ss], kjv_filename)
- X if \lst_rec.long then
- X ref ||:= ": " || bitmap_2_text(l[ss], kjv_filename)
- X if ss = \lst_rec.old_n then {
- X # Boldface last viewed passage from this list.
- X boldface(); writes(ref[1:\width|0])
- X normal()
- X } else writes(ref[1:\width|0])
- X }
- X
- X # If we haven't reached the end of the displayable screen,
- X # then clear lines until we reach it...
- X if i-1 ~= lines+1 then {
- X every j := i to lines do {
- X iputs(igoto(getval("cm"), 1, j))
- X normal(); iputs(getval("ce"))
- X }
- X }
- X # Display message on status line.
- X status_line("-- " || \msg || " --" | "", "", "c")
- X
- X # If we're to the end of the screen, and there's still more to
- X # display, then...
- X if *l > lines-1 & (lst_rec.pos+i) ~= (*l+1) then {
- X rsp :=
- X snarf_input("Press !/a/b/c/m/n/p/s/v/w (q = quit viewing): ")
- X case map(rsp) of {
- X "" : lst_rec.pos := (*l > (lst_rec.pos+1))
- X "!" : push_shell()
- X "/" : lst_rec.pos := search_list(lst_rec,rsp,lines)
- X "?" : lst_rec.pos := search_list(lst_rec,rsp,lines)
- X "a" : write_list(l, "append")
- X "b" : lst_rec.pos := (0 < lst_rec.pos-lines+1) | 0
- X "c" : next
- X "l" : lst_rec.long := { if /lst_rec.long then 1 else &null }
- X "m" : lst_rec.pos := (*l > (lst_rec.pos+i-1))
- X "n" : {
- X n := \lst_rec.old_n+1 | {
- X err_message("Type \"v\" to set the current passage.")
- X next
- X }
- X if 0 < n <= *l then {
- X if not (lst_rec.pos < n < lst_rec.pos+lines)
- X then lst_rec.pos := (0 < n-2) | n-1
- X lst_rec.old_n := n & (return l[n])
- X } else err_message("Out of range.")
- X }
- X "p" : {
- X n := \lst_rec.old_n-1 | {
- X err_message("Type \"v\" to set the current passage.")
- X next
- X }
- X if 0 < n <= *l then {
- X if not (lst_rec.pos < n < lst_rec.pos+lines)
- X then lst_rec.pos := (0 < n-2) | n-1
- X lst_rec.old_n := n & (return l[n])
- X } else err_message("Out of range.")
- X }
- X "q" : break
- X "s" : {
- X l := (lst_rec.l := sort(lst_rec.l))
- X lst_rec.old_n := &null
- X }
- X "v" : {
- X rsp2 := snarf_input("View which passage: ")
- X rsp2 == "q" & next
- X rsp2 == "" & rsp2 := lst_rec.old_n
- X if n := integer(rsp2) then {
- X if 0 < n <= *l then {
- X if not (lst_rec.pos < n < lst_rec.pos+lines)
- X then lst_rec.pos := (0 < n-2) | n-1
- X lst_rec.old_n := n
- X return l[n]
- X } else err_message("Out of range.")
- X } else err_message("Invalid passage number.")
- X }
- X "w" : write_list(l)
- X default : {
- X if rsp ? {
- X lst_rec.pos :=
- X search_list(lst_rec,tab(any('?/')),lines)
- X }
- X then next
- X else {
- X if n := integer(rsp)-1 then {
- X if 0 <= n < *l
- X then lst_rec.pos := n
- X else err_message("Out of range.")
- X } else {
- X err_message("Invalid command.")
- X }
- X }
- X }
- X }
- X }
- X # ...otherwise, we've displayed everything.
- X else {
- X prompt := "c/n/p/s/v/w (q to go to previous menu): "
- X if *l <= lines
- X then rsp:= snarf_input("Press !/a/" || prompt) | next
- X else rsp := snarf_input("Press !/a/b/" || prompt) | next
- X case map(rsp) of {
- X "!" : push_shell()
- X "/" : lst_rec.pos := search_list(lst_rec,rsp,lines)
- X "?" : lst_rec.pos := search_list(lst_rec,rsp,lines)
- X "a" : write_list(l,"append")
- X "b" : lst_rec.pos := (0 < lst_rec.pos-lines+1) | 0
- X "c"|"" : next
- X "l" : lst_rec.long := { if /lst_rec.long then 1 else &null }
- X "m" : next # no more to display; just stay were we are
- X "n" : {
- X n := \lst_rec.old_n+1 | {
- X err_message("No passage viewed yet from this list.")
- X next
- X }
- X if 0 < n <= *l then {
- X if not (lst_rec.pos < n < lst_rec.pos+lines)
- X then lst_rec.pos := (0 < n-2) | n-1
- X lst_rec.old_n := n & (return l[n])
- X } else err_message("Out of range.")
- X }
- X "p" : {
- X n := \lst_rec.old_n-1 | {
- X err_message("No passage viewed yet from this list.")
- X next
- X }
- X if 0 < n <= *l then {
- X if not (lst_rec.pos < n < lst_rec.pos+lines)
- X then lst_rec.pos := (0 < n-2) | n-1
- X lst_rec.old_n := n & (return l[n])
- X } else err_message("Out of range.")
- X }
- X "q" : break
- X "s" : {
- X l := (lst_rec.l := sort(lst_rec.l))
- X lst_rec.old_n := &null
- X }
- X "v" : {
- X rsp2 := snarf_input("View which passage: ")
- X rsp2 == "q" & next
- X rsp2 == "" & rsp2 := lst_rec.old_n
- X if n := integer(rsp2) then {
- X if 0 < n <= *l then {
- X if not (lst_rec.pos < n < lst_rec.pos+lines)
- X then lst_rec.pos := (0 < n-2) | n-1
- X lst_rec.old_n := n
- X return l[n]
- X } else err_message("Out of range.")
- X } else err_message("Invalid passage number.")
- X }
- X "w" : write_list(l)
- X default : {
- X if rsp ? {
- X lst_rec.pos :=
- X search_list(lst_rec,tab(any('?/')),lines)
- X }
- X then next
- X else {
- X if n := integer(rsp)-1 then {
- X if 0 <= n < *l
- X then lst_rec.pos := n
- X else err_message("Out of range.")
- X } else {
- X err_message("Invalid command.")
- X }
- X }
- X }
- X }
- X }
- X }
- X return
- X
- Xend
- X
- X
- X
- Xprocedure write_list(l, switch)
- X
- X #
- X # Used for writing the contents of a displayed list to a file.
- X #
- X local fname, outtext, i, firstchar
- X
- X # Get straight whether we are appending or clobbering.
- X (\switch := "a") | (switch := "w")
- X
- X until \outtext do {
- X fname := snarf_input("Enter filename (! for shell; q to quit): ")
- X fname ? {
- X firstchar := move(1) | ""
- X case firstchar of {
- X "" : fail
- X "!" : push_shell() & initialize_screen()
- X "q" : pos(0) & fail
- X default : {
- X outtext := open(fname, switch) | {
- X case switch of {
- X "a" : err_message("Can't append to "|| fname ||".")
- X "w" : err_message("Can't write to "|| fname ||".")
- X default : quit("write_passage","internal error",80)
- X }
- X }
- X }
- X }
- X }
- X }
- X message("Writing...")
- X every i := 1 to *l do
- X write(outtext, " ", left(i||".",7), convertb(l[i], kjv_filename))
- X close(outtext)
- X message("Done.")
- X return
- X
- Xend
- X
- X
- X
- Xprocedure show_lists()
- X
- X #
- X # Display stats for all generated lists. So far the only routine
- X # that can generate lists is search_database(). Every time it
- X # generates a list, it inserts that list into the global list,
- X # lists (declared and initialized in bibleref.icn).
- X #
- X local expanded_list, i, result
- X
- X #
- X # We're in the midst of a scanning expression in the main
- X # command loop. If the "l" command was given with no arguments,
- X # then default to the last list retrieved.
- X #
- X if not pos(0) then {
- X err_message("Garbage characters after \"l\" command.")
- X fail
- X }
- X *lists = 0 & {
- X err_message("No lists in memory.")
- X fail
- X }
- X
- X repeat {
- X result :=
- X listlistS(lists, "list of viewable lists", getval("co")-10) | fail
- X if /result
- X then return
- X else result ? display_list()
- X }
- X
- Xend
- X
- X
- X
- Xprocedure listlistS(all_lists, msg, width)
- X
- X local l, offset, i, ss, j, prompt, rsp, rsp2
- X static lines, last_viewed
- X initial lines := getval("li")-3
- X
- X # "all_lists" is a list of records of type lst
- X # "msg" is the message to put on the status line
- X # "width" gives the length to which lines in l are truncated
- X
- X l := all_lists
- X
- X offset := 0
- X repeat {
- X i := 0
- X while *l >= (ss := offset + (lines > (i +:= 1))) do {
- X iputs(igoto(getval("cm"), 1, i))
- X normal(); iputs(getval("ce"))
- X writes(" ", left(ss||".",5))
- X writes("length = " || *l[i].l || ", search pattern = " || l[i].s)
- X }
- X
- X # If we haven't reached the end of the displayable screen,
- SHAR_EOF
- true || echo 'restore of listutil.icn failed'
- fi
- echo 'End of part 1'
- echo 'File listutil.icn is continued in part 2'
- echo 2 > _shar_seq_.tmp
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-