From: Adam Dickmeiss Date: Mon, 26 Jun 1995 10:20:19 +0000 (+0000) Subject: ir-tk works like wish. X-Git-Tag: IRTCL.1.4~244 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=3d56e4348edb6d14f0875ca86ae2301636f87158;p=ir-tcl-moved-to-github.git ir-tk works like wish. --- diff --git a/CHANGELOG b/CHANGELOG index fa3be03..ba510d9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -$Id: CHANGELOG,v 1.1 1995-06-25 10:24:58 adam Exp $ +$Id: CHANGELOG,v 1.2 1995-06-26 10:20:19 adam Exp $ 06/19/95 Release of ir-tcl-1.0b ------------------------------------------------------ @@ -21,3 +21,9 @@ $Id: CHANGELOG,v 1.1 1995-06-25 10:24:58 adam Exp $ 06/22/95 Preferred record syntax can be specified by the user in client.tcl. +06/26/95 ir-tk doesn't read client.tcl when no options are given. Instead + it works like wish. The demonstrating client is named 'irclient' + when installed in the directory with executables. +------------------------------------------------------ +06/26/95 Release of ir-tcl-1.0b1 + diff --git a/Makefile.in b/Makefile.in index 5aacd02..5252448 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,7 +2,7 @@ # (c) Index Data 1995 # See the file LICENSE for details. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile.in,v 1.6 1995-06-25 10:24:59 adam Exp $ +# $Id: Makefile.in,v 1.7 1995-06-26 10:20:20 adam Exp $ SHELL=/bin/sh # IrTcl Version @@ -54,8 +54,8 @@ O=ir-tcl.o marc.o all: ir-tk ir-tcl -ir-tk: libirtcl.a tkmain.o - $(CC) $(CFLAGS) tkmain.o -o ir-tk libirtcl.a $(YAZLIB) $(TKLIB) \ +ir-tk: libirtcl.a tkinit.o + $(CC) $(CFLAGS) tkinit.o -o ir-tk libirtcl.a $(YAZLIB) $(TKLIB) \ $(TCLLIB) $(XLIB) $(LIBS) ir-tcl: libirtcl.a tclmain.o @@ -77,12 +77,15 @@ install: ir-tcl $(INSTALL_PROGRAM) ir-tcl $(BINDIR) $(INSTALL_DATA) libirtcl.a $(LIBDIR) $(INSTALL_DATA) ir-tcl.h $(INCDIR) - $(INSTALL_DATA) LICENSE clientrc.tcl $(IRTCLDIR) - sed "s,^set libdir LIBDIR,set libdir $(IRTCLDIR)," client.bak - if [ -f ir-tk ]; then $(INSTALL_PROGRAM) ir-tk $(BINDIR) - $(INSTALL_DATA) client.bak $(IRTCLDIR)/client.tcl - $(INSTALL_DATA) formats/*.tcl $(IRTCLDIR)/formats - $(INSTALL_DATA) bitmaps/book? $(IRTCLDIR)/bitmaps + if [ -f ir-tk ]; then \ + $(INSTALL_PROGRAM) ir-tk $(BINDIR); \ + echo "#! $(BINDIR)/ir-tk -f" >head.bak; \ + cat head.bak client.tcl| sed "s,^set libdir LIBDIR,set libdir $(IRTCLDIR)," >client.bak; \ + $(INSTALL_PROGRAM) client.bak $(BINDIR)/irclient; \ + $(INSTALL_DATA) LICENSE clientrc.tcl $(IRTCLDIR); \ + $(INSTALL_DATA) formats/*.tcl $(IRTCLDIR)/formats; \ + $(INSTALL_DATA) bitmaps/book? $(IRTCLDIR)/bitmaps; \ + fi; clean: rm -f *.[oa] ir-tk ir-tcl core gmon.out mon.out *.bak config.cache @@ -108,5 +111,5 @@ distribution: .c.o: $(CC) -c $(CFLAGS) $(DEFS) $< -$(O) tkmain.o tclmain.o: ir-tcl.h ir-tclp.h +$(O) tkinit.o tclmain.o: ir-tcl.h ir-tclp.h diff --git a/doc/ir-tcl.sgml b/doc/ir-tcl.sgml index aba6909..bef13c1 100644 --- a/doc/ir-tcl.sgml +++ b/doc/ir-tcl.sgml @@ -1,13 +1,13 @@
IrTcl User's Guide and Reference <author>Index Data, <tt/info@index.ping.dk/ -<date>$Revision: 1.9 $ +<date>$Revision: 1.10 $ <abstract> This document describes IrTcl — an information retrieval toolkit for Tcl and Tk that provides access to the Z39.50/SR protocol. @@ -40,8 +40,8 @@ See [ref 2] for more information about the XTI/mOSI implementation. <itemize> <item> A simple command line shell — useful for testing purposes. -<item> A system which operates within the Tk environment which -makes it very easy to implement GUI clients. +<item> A simple command line shell which operates within the Tk + environment — makes it very easy to implement GUI clients. </itemize> <sect>Compilation and installation @@ -101,32 +101,36 @@ $ make install Summary of files installed (the names refer to the Makefile variables): <descrip> -<tag><tt>ir-tk</tt></tag> The Tk client. Installed in <tt>BINDIR</tt> — -defaults to <tt>/usr/local/bin</tt>. When ir-tk starts it reads -<tt>client.tcl</tt>. If the files doesn't exist in the current -directory it tries to read it from <tt>IRTCLDIR</tt> - defaults -to <tt>/usr/local/lib/irtcl</tt>. -<tag><tt>ir-tcl</tt></tag> The Tcl client. Installed in <tt>BINDIR</tt> — -defaults to <tt>/usr/local/bin</tt>. +<tag><tt>ir-tk</tt></tag> The <sf/IrTcl/ shell for Tk. + Installed in <tt>BINDIR</tt> — defaults to + <tt>/usr/local/bin</tt>. <tt>ir-tk</tt> works like + <tt>wish</tt> &mdash without arguments it reads commands from stdin. + A source file may be specified by option <tt>-f</tt>. <tt>ir-tk</tt> + accept the same set of options as <tt>wish</tt>. +<tag><tt>ir-tcl</tt></tag> The <sf/IrTcl/ shell for Tcl. Installed in + <tt>BINDIR</tt> — defaults to <tt>/usr/local/bin</tt>. +<tag><tt>client.tcl</tt></tag> A graphical client for <tt>ir-tk</tt>. + The client is installed as an executable script called <tt>irclient</tt> in + <tt>BINDIR</tt>. This client needs a number of files, bitmaps, etc. + The client looks for the files in the current directory &mdash if + this fails it tries to look in the directory <tt>IRTCLDIR</tt> + — defaults to <tt>/usr/local/lib/irtcl</tt>. <tag><tt>libirtcl.a</tt></tag> The <sf/IrTcl/ library. -Installed in <tt>LIBDIR</tt> — defaults to <tt>/usr/local/lib</tt>. + Installed in <tt>LIBDIR</tt> — defaults to <tt>/usr/local/lib</tt>. <tag><tt>ir-tcl.h</tt></tag> The <sf/IrTcl/ header file. -Installed in <tt>INCDIR</tt> — defaults to <tt>/usr/local/include</tt>. -<tag><tt>client.tcl</tt></tag> A graphical client written in TK. -Installed in <tt>IRTCLDIR</tt> — defaults to -<tt>/usr/local/lib/irtcl</tt>. + Installed in <tt>INCDIR</tt> — defaults to <tt>/usr/local/include</tt>. <tag><tt>clientrc.tcl</tt></tag> A setup file with definitions -of target and queries. Read and updated by <tt>client.tcl</tt>. Installed -in <tt>IRTCLDIR</tt> — defaults to <tt>/usr/local/lib/irtcl</tt>. + of target and queries. Read and updated by <tt>client.tcl</tt>. Installed + in <tt>IRTCLDIR</tt> — defaults to <tt>/usr/local/lib/irtcl</tt>. <tag><tt>formats/*</tt></tag> Display format files written -in Tk. Read by <tt>client.tcl</tt>. Installed -in <tt>IRTCLDIR</tt> — defaults to <tt>/usr/local/lib/irtcl</tt>. + in Tk. Read by <tt>client.tcl</tt>. Installed + in <tt>IRTCLDIR</tt> — defaults to <tt>/usr/local/lib/irtcl</tt>. <tag><tt>bitmaps/*</tt></tag> Various bitmap files. Read by -<tt>client.tcl</tt>. Installed -in <tt>IRTCLDIR</tt> — defaults to <tt>/usr/local/lib/irtcl</tt>. + <tt>client.tcl</tt>. Installed + in <tt>IRTCLDIR</tt> — defaults to <tt>/usr/local/lib/irtcl</tt>. <tag><tt>LICENSE</tt></tag> LICENSE file. Read by -<tt>client.tcl</tt>. Installed -in <tt>IRTCLDIR</tt> — defaults to <tt>/usr/local/lib/irtcl</tt>. + <tt>client.tcl</tt>. Installed + in <tt>IRTCLDIR</tt> — defaults to <tt>/usr/local/lib/irtcl</tt>. </descrip> <sect1>ir-tcl @@ -143,14 +147,12 @@ as a script. <sect1>ir-tk <p> -<tt>ir-tk</tt> is a program which basically waits for X events and -socket events (assocated with Z39.50/SR targets). <tt>ir-tk</tt> normally -tries to evaluate the file named <tt>client.tcl</tt> when it -starts. However, this behaviour may be changed by specifying another -filename with the <tt>-file</tt> option. - -The enclosed script <tt>client.tcl</tt> is a graphical client which -demonstates an example of a user interface for the Z39.50/SR protocols. +<tt>ir-tk</tt> is a program that works like <tt>wish</tt> except that +<tt>ir-tk</tt> include the new set of commands. + +The enclosed script <tt>client.tcl</tt> for <tt>ir-tk</tt> +is a graphical client which demonstates an example of a user interface +for the Z39.50/SR protocols. At first the script was relatively small but it has grown since the beginning. At present it is about 3000 lines. @@ -977,9 +979,9 @@ record. <sect1>SUTRS +<p> In <sf/IrTcl/ a SUTRS record is treated as one single string. To retrieve -a SUTRS string at a given index, the <tt>getSutrs</tt> should be used. -The <tt>getSutrs</tt> is immediately followed by a index. +a SUTRS record use the <tt>getSutrs</tt> followed by an index. <sect>Scan diff --git a/tclmain.c b/tclmain.c index e17cd1e..4277b1a 100644 --- a/tclmain.c +++ b/tclmain.c @@ -5,7 +5,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: tclmain.c,v $ - * Revision 1.8 1995-06-21 15:16:44 adam + * Revision 1.9 1995-06-26 10:20:20 adam + * ir-tk works like wish. + * + * Revision 1.8 1995/06/21 15:16:44 adam * More work on configuration. * * Revision 1.7 1995/06/21 11:04:54 adam @@ -90,11 +93,34 @@ int main (int argc, char **argv) exit (1); tcl_mainloop (interp, 0); } - else + else if (isatty(0)) { + Tcl_SetVar (interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); tcl_mainloop (interp, 1); } + else + { + Tcl_DString command; + char input_buf[1024]; + int count; + + printf ("xx\n"); + Tcl_DStringInit (&command); + while (fgets (input_buf, 1024, stdin)) + { + count = strlen(input_buf); + Tcl_DStringAppend (&command, input_buf, count); + if (Tcl_CommandComplete (Tcl_DStringValue (&command))) + { + int code = Tcl_Eval (interp, Tcl_DStringValue (&command)); + Tcl_DStringFree (&command); + if (code) + printf ("Error: %s\n", interp->result); + } + } + tcl_mainloop (interp, 0); + } exit (0); } @@ -112,7 +138,7 @@ void tcl_mainloop (Tcl_Interp *interp, int interactive) if (interactive) { Tcl_DStringInit (&command); - printf ("[TCL]"); fflush (stdout); + printf ("%% "); fflush (stdout); } while (1) { @@ -169,8 +195,8 @@ void tcl_mainloop (Tcl_Interp *interp, int interactive) } if (interactive && FD_ISSET(0, &fdset_tcl_r)) { - char input_buf[256]; - int count = read (0, input_buf, 256); + char input_buf[1024]; + int count = read (0, input_buf, 1024); if (count <= 0) exit (0); @@ -180,10 +206,10 @@ void tcl_mainloop (Tcl_Interp *interp, int interactive) int code = Tcl_Eval (interp, Tcl_DStringValue (&command)); Tcl_DStringFree (&command); if (code) - printf ("[ERR:%s]\n", interp->result); + printf ("Error: %s\n", interp->result); else - printf ("[RES:%s]\n", interp->result); - printf ("[TCL]"); fflush (stdout); + printf ("%s", interp->result); + printf ("%% "); fflush (stdout); } } }