home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / xtexcad1 / part01 < prev    next >
Encoding:
Text File  |  1992-04-20  |  50.8 KB  |  1,909 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  3. From: Fritz Haubensak <hsk@informatik.uni-wuerzburg.de>
  4. Subject: v17i065: TeXcad (X) version 1.2, Part01/10
  5. Message-ID: <csx-17i065-xtexcad-1.2@uunet.UU.NET>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Nntp-Posting-Host: fascet
  9. Organization: Molecular Simulations, Inc.
  10. Date: Tue, 21 Apr 1992 13:06:41 GMT
  11. Approved: dcmartin@msi.com
  12. Lines: 1895
  13.  
  14. Submitted-by: Fritz Haubensak <hsk@informatik.uni-wuerzburg.de>
  15. Posting-number: Volume 17, Issue 65
  16. Archive-name: xtexcad-1.2/part01
  17.  
  18. xtexcad is a drawing tool to produce LaTeX picture environments.
  19. It is a re-implementation to run under X of the well known TeXcad
  20. distributed with emTeX.
  21.  
  22. xtexcad was developed by Klaus Zitzmann of Koblenz University,
  23. zitzmann@infko.uni-koblenz.de; please direct any questions
  24. concerning the programm to him.
  25.  
  26. Regards, Fritz
  27. -- 
  28. Friedrich Haubensak  hsk@infko.uni-koblenz.de |
  29.               ...!uunet!mcsun!unido!infko!hsk |  Science is true !
  30. FB Informatik, Uni Koblenz,                   |
  31. Rheinau 3-4, D-5400 Koblenz, Germany          |    Don't be misled by facts.
  32.  
  33. #!/bin/sh
  34. # This is a shell archive (produced by shar 3.50)
  35. # To extract the files from this archive, save it to a file, remove
  36. # everything above the "!/bin/sh" line above, and type "sh file_name".
  37. #
  38. # made 04/21/1992 13:03 UTC by dcmartin@fascet
  39. # Source directory /home/fascet/dcmartin/csx/src/xtexcad/texcad12
  40. #
  41. # existing files will NOT be overwritten unless -c is specified
  42. #
  43. # This is part 1 of a multipart archive                                    
  44. # do not concatenate these parts, unpack them in order with /bin/sh        
  45. #
  46. # This shar contains:
  47. # length  mode       name
  48. # ------ ---------- ------------------------------------------
  49. #    887 -rw-r--r-- Imakefile
  50. #  10984 -rw-r--r-- Makefile
  51. #    683 -rw-r--r-- Makefile.std
  52. #   3363 -rw-r--r-- README
  53. #     18 -rw-r--r-- Xtexcad.ad
  54. #  16682 -rw-r--r-- ereignis.c
  55. #   1281 -rw-r--r-- ereignis.h
  56. #    476 -rw-r--r-- extdef.h
  57. #  36818 -rw-r--r-- file_sel.c
  58. #   1046 -rw-r--r-- file_sel.h
  59. # 134559 -rw-r--r-- graphics.c
  60. #   3541 -rw-r--r-- graphics.h
  61. #  36048 -rw-r--r-- io_trans.c
  62. #   1526 -rw-r--r-- io_trans.h
  63. #  37008 -rw-r--r-- oberfl.c
  64. #   4292 -rw-r--r-- oberfl.h
  65. #    116 -rw-r--r-- patchlevel.h
  66. #  85301 -rw-r--r-- pickedit.c
  67. #   1800 -rw-r--r-- pickedit.h
  68. #  65217 -rw-r--r-- pics.h
  69. #     20 -rwxr-xr-x texcad
  70. #  10421 -rw-r--r-- texcad12.man
  71. #    700 -rw-r--r-- x_stuff.h
  72. #   1731 -rw-r--r-- yyscan.h
  73. #   6312 -rw-r--r-- yyscan.l
  74. #
  75. if test -r _shar_seq_.tmp; then
  76.     echo 'Must unpack archives in sequence!'
  77.     echo Please unpack part `cat _shar_seq_.tmp` next
  78.     exit 1
  79. fi
  80. # ============= Imakefile ==============
  81. if test -f 'Imakefile' -a X"$1" != X"-c"; then
  82.     echo 'x - skipping Imakefile (File already exists)'
  83.     rm -f _shar_wnt_.tmp
  84. else
  85. > _shar_wnt_.tmp
  86. echo 'x - extracting Imakefile (Text)'
  87. sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' &&
  88. /* xtexcad 1.2 - Imakefile */
  89. /* K.Zitzmann 2/92 */
  90. /* If your version of the gcc is NOT able to link with shared libraries */
  91. /* you can use the cc to reduce the size of the code. */
  92. /* ( in this case you have to link the gnu-lib explicitly ) */
  93. X
  94. #ifdef BandAidCompiler
  95. #include BandAidCompiler
  96. #endif
  97. X
  98. X        DEFINES = -I../server
  99. X        DEPLIBS = XawClientDepLibs
  100. LOCAL_LIBRARIES = XawClientLibs
  101. X  SYS_LIBRARIES = -lm -ll
  102. X           SRCS = oberfl.c ereignis.c file_sel.c pickedit.c graphics.c yyscan.l io_trans.c 
  103. X           SRCS = SRCS extdef.h pics.h x_stuff.h oberfl.h ereignis.h file_sel.h pickedit.h
  104. X           SRCS = SRCS graphics.h yyscan.h io_trans.h
  105. X           OBJS = oberfl.o ereignis.o file_sel.o pickedit.o graphics.o yyscan.o io_trans.o
  106. X
  107. /* overrides -O option */
  108. X
  109. X    CDEBUGFLAGS = -w 
  110. X         CC = gcc
  111. X         
  112. X
  113. X
  114. ComplexProgramTarget(xtexcad)
  115. InstallAppDefaults(Xtexcad)
  116. SHAR_EOF
  117. chmod 0644 Imakefile ||
  118. echo 'restore of Imakefile failed'
  119. Wc_c="`wc -c < 'Imakefile'`"
  120. test 887 -eq "$Wc_c" ||
  121.     echo 'Imakefile: original size 887, current size' "$Wc_c"
  122. rm -f _shar_wnt_.tmp
  123. fi
  124. # ============= Makefile ==============
  125. if test -f 'Makefile' -a X"$1" != X"-c"; then
  126.     echo 'x - skipping Makefile (File already exists)'
  127.     rm -f _shar_wnt_.tmp
  128. else
  129. > _shar_wnt_.tmp
  130. echo 'x - extracting Makefile (Text)'
  131. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  132. # Makefile generated by imake - do not edit!
  133. # $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  134. #
  135. # The cpp used on this machine replaces all newlines and multiple tabs and
  136. # spaces in a macro expansion with a single space.  Imake tries to compensate
  137. # for this, but is not always successful.
  138. #
  139. X
  140. # -------------------------------------------------------------------------
  141. # Makefile generated from "Imake.tmpl" and <Imakefile>
  142. # $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  143. #
  144. # Platform-specific parameters may be set in the appropriate <vendor>.cf
  145. # configuration files.  Site-specific parameters should be set in the file
  146. # site.def.  Full rebuilds are recommended if any parameters are changed.
  147. #
  148. # If your C preprocessor does not define any unique symbols, you will need
  149. # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  150. # "make World" the first time).
  151. #
  152. X
  153. # -------------------------------------------------------------------------
  154. # site-specific configuration parameters that need to come before
  155. # the platform-specific parameters - edit site.def to change
  156. X
  157. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  158. X
  159. # -------------------------------------------------------------------------
  160. # platform-specific configuration parameters - edit sun.cf to change
  161. X
  162. # platform:  $XConsortium: sun.cf,v 1.68 91/07/30 11:34:39 rws Exp $
  163. X
  164. # operating system:  SunOS 4.1.1
  165. X
  166. # $XConsortium: sunLib.rules,v 1.6 91/03/24 17:55:58 rws Exp $
  167. X
  168. # -------------------------------------------------------------------------
  169. # site-specific configuration parameters that go after
  170. # the platform-specific parameters - edit site.def to change
  171. X
  172. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  173. X
  174. X            SHELL = /bin/sh
  175. X
  176. X              TOP = .
  177. X      CURRENT_DIR = .
  178. X
  179. X               AR = ar clq
  180. X  BOOTSTRAPCFLAGS =
  181. X               CC = cc
  182. X               AS = as
  183. X
  184. X         COMPRESS = compress
  185. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  186. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  187. X          INSTALL = install
  188. X               LD = ld
  189. X             LINT = lint
  190. X      LINTLIBFLAG = -C
  191. X         LINTOPTS = -axz
  192. X               LN = ln -s
  193. X             MAKE = make
  194. X               MV = mv
  195. X               CP = cp
  196. X
  197. X           RANLIB = ranlib
  198. X  RANLIBINSTFLAGS =
  199. X
  200. X               RM = rm -f
  201. X            TROFF = psroff
  202. X         MSMACROS = -ms
  203. X              TBL = tbl
  204. X              EQN = eqn
  205. X     STD_INCLUDES =
  206. X  STD_CPP_DEFINES =
  207. X      STD_DEFINES =
  208. X EXTRA_LOAD_FLAGS =
  209. X  EXTRA_LIBRARIES =
  210. X             TAGS = ctags
  211. X
  212. X    SHAREDCODEDEF = -DSHAREDCODE
  213. X         SHLIBDEF = -DSUNSHLIB
  214. X
  215. X    PROTO_DEFINES =
  216. X
  217. X     INSTPGMFLAGS =
  218. X
  219. X     INSTBINFLAGS = -m 0755
  220. X     INSTUIDFLAGS = -m 4755
  221. X     INSTLIBFLAGS = -m 0644
  222. X     INSTINCFLAGS = -m 0444
  223. X     INSTMANFLAGS = -m 0444
  224. X     INSTDATFLAGS = -m 0444
  225. X    INSTKMEMFLAGS = -m 4755
  226. X
  227. X      PROJECTROOT = /usr/X11/R5
  228. X
  229. X     TOP_INCLUDES = -I$(INCROOT)
  230. X
  231. X      CDEBUGFLAGS = -O
  232. X        CCOPTIONS = -pipe
  233. X
  234. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  235. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  236. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  237. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  238. X
  239. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  240. X
  241. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  242. X
  243. X   LDCOMBINEFLAGS = -X -r
  244. X      DEPENDFLAGS =
  245. X
  246. X        MACROFILE = sun.cf
  247. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  248. X
  249. X    IMAKE_DEFINES =
  250. X
  251. X         IRULESRC = $(CONFIGDIR)
  252. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  253. X
  254. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  255. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  256. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  257. X
  258. # -------------------------------------------------------------------------
  259. # X Window System Build Parameters
  260. # $XConsortium: Project.tmpl,v 1.138 91/09/10 09:02:12 rws Exp $
  261. X
  262. # -------------------------------------------------------------------------
  263. # X Window System make variables; this need to be coordinated with rules
  264. X
  265. X          PATHSEP = /
  266. X        USRLIBDIR = /usr/X11/R5/lib
  267. X           BINDIR = /usr/X11/R5/bin
  268. X          INCROOT = /usr/X11/R5/include
  269. X     BUILDINCROOT = $(TOP)
  270. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  271. X      BUILDINCTOP = ..
  272. X           INCDIR = $(INCROOT)/X11
  273. X           ADMDIR = /usr/adm
  274. X           LIBDIR = $(USRLIBDIR)/X11
  275. X        CONFIGDIR = $(LIBDIR)/config
  276. X       LINTLIBDIR = $(USRLIBDIR)/lint
  277. X
  278. X          FONTDIR = $(LIBDIR)/fonts
  279. X         XINITDIR = $(LIBDIR)/xinit
  280. X           XDMDIR = $(LIBDIR)/xdm
  281. X           TWMDIR = $(LIBDIR)/twm
  282. X          MANPATH = /usr/X11/R5/man
  283. X    MANSOURCEPATH = $(MANPATH)/man
  284. X        MANSUFFIX = n
  285. X     LIBMANSUFFIX = 3
  286. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  287. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  288. X           NLSDIR = $(LIBDIR)/nls
  289. X        PEXAPIDIR = $(LIBDIR)/PEX
  290. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  291. X       FONTCFLAGS = -t
  292. X
  293. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  294. X
  295. X            IMAKE = imake
  296. X           DEPEND = makedepend
  297. X              RGB = rgb
  298. X
  299. X            FONTC = bdftopcf
  300. X
  301. X        MKFONTDIR = mkfontdir
  302. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier
  303. X
  304. X        CONFIGSRC = $(TOP)/config
  305. X       DOCUTILSRC = $(TOP)/doc/util
  306. X        CLIENTSRC = $(TOP)/clients
  307. X          DEMOSRC = $(TOP)/demos
  308. X           LIBSRC = $(TOP)/lib
  309. X          FONTSRC = $(TOP)/fonts
  310. X       INCLUDESRC = $(TOP)/X11
  311. X        SERVERSRC = $(TOP)/server
  312. X          UTILSRC = $(TOP)/util
  313. X        SCRIPTSRC = $(UTILSRC)/scripts
  314. X       EXAMPLESRC = $(TOP)/examples
  315. X       CONTRIBSRC = $(TOP)/../contrib
  316. X           DOCSRC = $(TOP)/doc
  317. X           RGBSRC = $(TOP)/rgb
  318. X        DEPENDSRC = $(UTILSRC)/makedepend
  319. X         IMAKESRC = $(CONFIGSRC)
  320. X         XAUTHSRC = $(LIBSRC)/Xau
  321. X          XLIBSRC = $(LIBSRC)/X
  322. X           XMUSRC = $(LIBSRC)/Xmu
  323. X       TOOLKITSRC = $(LIBSRC)/Xt
  324. X       AWIDGETSRC = $(LIBSRC)/Xaw
  325. X       OLDXLIBSRC = $(LIBSRC)/oldX
  326. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  327. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  328. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  329. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  330. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  331. X         FSLIBSRC = $(FONTSRC)/lib/fs
  332. X    FONTSERVERSRC = $(FONTSRC)/server
  333. X     EXTENSIONSRC = $(TOP)/extensions
  334. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  335. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  336. X
  337. # $XConsortium: sunLib.tmpl,v 1.11 91/07/31 11:32:08 rws Exp $
  338. X
  339. SHLIBLDFLAGS = -assert pure-text
  340. PICFLAGS = -pic
  341. X
  342. X  DEPEXTENSIONLIB =
  343. X     EXTENSIONLIB = -lXext
  344. X
  345. X          DEPXLIB = $(DEPEXTENSIONLIB)
  346. X             XLIB = $(EXTENSIONLIB) -lX11
  347. X
  348. X        DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV)
  349. X           XMULIB = -lXmu
  350. X
  351. X       DEPOLDXLIB =
  352. X          OLDXLIB = -loldX
  353. X
  354. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV)
  355. X         XTOOLLIB = -lXt
  356. X
  357. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV)
  358. X           XAWLIB = -lXaw
  359. X
  360. X        DEPXILIB =
  361. X           XILIB = -lXi
  362. X
  363. X        SOXLIBREV = 4.10
  364. X          SOXTREV = 4.10
  365. X         SOXAWREV = 5.0
  366. X        SOOLDXREV = 4.10
  367. X         SOXMUREV = 4.10
  368. X        SOXEXTREV = 4.10
  369. X      SOXINPUTREV = 4.10
  370. X
  371. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  372. X         XAUTHLIB =  -lXau
  373. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  374. X         XDMCPLIB =  -lXdmcp
  375. X
  376. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  377. X           PHIGSLIB =  -lphigs
  378. X
  379. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  380. X          XBSDLIB =  -lXbsd
  381. X
  382. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  383. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  384. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  385. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  386. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  387. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  388. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  389. X
  390. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  391. X
  392. X         DEPLIBS1 = $(DEPLIBS)
  393. X         DEPLIBS2 = $(DEPLIBS)
  394. X         DEPLIBS3 = $(DEPLIBS)
  395. X
  396. # -------------------------------------------------------------------------
  397. # Imake rules for building libraries, programs, scripts, and data files
  398. # rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  399. X
  400. # -------------------------------------------------------------------------
  401. # start of Imakefile
  402. X
  403. X        DEFINES = -I../server
  404. X        DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  405. LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
  406. X  SYS_LIBRARIES = -lm -ll
  407. X           SRCS = oberfl.c ereignis.c file_sel.c pickedit.c graphics.c yyscan.l io_trans.c
  408. X           SRCS = SRCS extdef.h pics.h x_stuff.h oberfl.h ereignis.h file_sel.h pickedit.h
  409. X           SRCS = SRCS graphics.h yyscan.h io_trans.h
  410. X           OBJS = oberfl.o ereignis.o file_sel.o pickedit.o graphics.o yyscan.o io_trans.o
  411. X
  412. X    CDEBUGFLAGS = -w
  413. X         CC = gcc
  414. X
  415. X PROGRAM = xtexcad
  416. X
  417. all:: xtexcad
  418. X
  419. xtexcad: $(OBJS) $(DEPLIBS)
  420. X    $(RM) $@
  421. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
  422. X
  423. saber_xtexcad:: $(SRCS)
  424. X    # load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  425. X
  426. osaber_xtexcad:: $(OBJS)
  427. X    # load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  428. X
  429. install:: xtexcad
  430. X    @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \
  431. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi
  432. X    $(INSTALL) -c $(INSTPGMFLAGS)  xtexcad $(DESTDIR)$(BINDIR)
  433. X
  434. install.man:: xtexcad.man
  435. X    @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \
  436. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi
  437. X    $(INSTALL) -c $(INSTMANFLAGS) xtexcad.man $(DESTDIR)$(MANDIR)/xtexcad.$(MANSUFFIX)
  438. X
  439. depend::
  440. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  441. X
  442. lint:
  443. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  444. lint1:
  445. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  446. X
  447. clean::
  448. X    $(RM) $(PROGRAM)
  449. X
  450. install:: Xtexcad.ad
  451. X    @if [ -d $(DESTDIR)$(XAPPLOADDIR) ]; then set +x; \
  452. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(XAPPLOADDIR)); fi
  453. X    $(INSTALL) -c $(INSTAPPFLAGS) Xtexcad.ad $(DESTDIR)$(XAPPLOADDIR)/Xtexcad
  454. X
  455. # -------------------------------------------------------------------------
  456. # common rules for all Makefiles - do not edit
  457. X
  458. emptyrule::
  459. X
  460. clean::
  461. X    $(RM_CMD) "#"*
  462. X
  463. Makefile::
  464. X    -@if [ -f Makefile ]; then set -x; \
  465. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  466. X    else exit 0; fi
  467. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  468. X
  469. tags::
  470. X    $(TAGS) -w *.[ch]
  471. X    $(TAGS) -xw *.[ch] > TAGS
  472. X
  473. saber:
  474. X    # load $(ALLDEFINES) $(SRCS)
  475. X
  476. osaber:
  477. X    # load $(ALLDEFINES) $(OBJS)
  478. X
  479. # -------------------------------------------------------------------------
  480. # empty rules for directories that do not have SUBDIRS - do not edit
  481. X
  482. install::
  483. X    @echo "install in $(CURRENT_DIR) done"
  484. X
  485. install.man::
  486. X    @echo "install.man in $(CURRENT_DIR) done"
  487. X
  488. Makefiles::
  489. X
  490. includes::
  491. X
  492. # -------------------------------------------------------------------------
  493. # dependencies generated by makedepend
  494. X
  495. SHAR_EOF
  496. chmod 0644 Makefile ||
  497. echo 'restore of Makefile failed'
  498. Wc_c="`wc -c < 'Makefile'`"
  499. test 10984 -eq "$Wc_c" ||
  500.     echo 'Makefile: original size 10984, current size' "$Wc_c"
  501. rm -f _shar_wnt_.tmp
  502. fi
  503. # ============= Makefile.std ==============
  504. if test -f 'Makefile.std' -a X"$1" != X"-c"; then
  505.     echo 'x - skipping Makefile.std (File already exists)'
  506.     rm -f _shar_wnt_.tmp
  507. else
  508. > _shar_wnt_.tmp
  509. echo 'x - extracting Makefile.std (Text)'
  510. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.std' &&
  511. CC= gcc
  512. #CFLAGS= -g -w
  513. CFLAGS= # -w
  514. X
  515. cad: oberfl.o ereignis.o file_sel.o pickedit.o graphics.o yyscan.o io_trans.o 
  516. X    $(CC) -s -o xtexcad\
  517. X        oberfl.o ereignis.o file_sel.o pickedit.o\
  518. X        graphics.o io_trans.o yyscan.o\
  519. X        -lXaw -lXmu -lXt -lXext -lX11 -lm -ll
  520. X
  521. ereignis.o: ereignis.h ereignis.c pics.h extdef.h oberfl.h
  522. X
  523. file_sel.o: file_sel.h file_sel.c extdef.h 
  524. X
  525. pickedit.o: pickedit.h pickedit.c extdef.h 
  526. X
  527. graphics.o: graphics.h graphics.c extdef.h 
  528. X
  529. io_trans.o: io_trans.h io_trans.c extdef.h 
  530. X
  531. oberfl.o: oberfl.c oberfl.h x_stuff.h extdef.h pics.h
  532. X
  533. yyscan.c:  yyscan.l
  534. X    lex -t yyscan.l > yyscan.c
  535. X
  536. yyscan.o: yyscan.h yyscan.c extdef.h
  537. X
  538. clean:
  539. X    rm -f *.o xtexcad core *% yyscan.c
  540. SHAR_EOF
  541. chmod 0644 Makefile.std ||
  542. echo 'restore of Makefile.std failed'
  543. Wc_c="`wc -c < 'Makefile.std'`"
  544. test 683 -eq "$Wc_c" ||
  545.     echo 'Makefile.std: original size 683, current size' "$Wc_c"
  546. rm -f _shar_wnt_.tmp
  547. fi
  548. # ============= README ==============
  549. if test -f 'README' -a X"$1" != X"-c"; then
  550.     echo 'x - skipping README (File already exists)'
  551.     rm -f _shar_wnt_.tmp
  552. else
  553. > _shar_wnt_.tmp
  554. echo 'x - extracting README (Text)'
  555. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  556. This is a drawing tool to produce LaTeX picture environments.
  557. X
  558. This is an X11 (re)implementation of the well known TeXcad
  559. distributed with emTeX.
  560. X
  561. X
  562. TeXcad 1.2 is distributed with the following files:
  563. X
  564. -rw-r--r--  1 uni-koblenz      887 Apr 10 17:29 Imakefile
  565. -rw-r--r--  1 uni-koblenz      683 Apr 10 16:21 Makefile.std
  566. -rw-r--r--  1 uni-koblenz     3363 Apr 10 17:48 README
  567. -rw-r--r--  1 uni-koblenz       18 Jan 20 15:33 Xtexcad.ad
  568. -rw-r--r--  1 uni-koblenz    16682 Mar  5 10:45 ereignis.c
  569. -rw-r--r--  1 uni-koblenz     1281 Mar  5 10:45 ereignis.h
  570. -rw-r--r--  1 uni-koblenz      475 Mar  5 10:45 extdef.h
  571. -rw-r--r--  1 uni-koblenz    36818 Mar  5 10:45 file_sel.c
  572. -rw-r--r--  1 uni-koblenz     1046 Mar  5 10:45 file_sel.h
  573. -rw-r--r--  1 uni-koblenz   134559 Mar  5 10:45 graphics.c
  574. -rw-r--r--  1 uni-koblenz     3540 Mar  5 10:45 graphics.h
  575. -rw-r--r--  1 uni-koblenz    36047 Mar  5 10:45 io_trans.c
  576. -rw-r--r--  1 uni-koblenz     1526 Mar  5 10:45 io_trans.h
  577. -rw-r--r--  1 uni-koblenz    37008 Apr 10 15:40 oberfl.c
  578. -rw-r--r--  1 uni-koblenz     4292 Mar  5 10:45 oberfl.h
  579. -rw-r--r--  1 uni-koblenz      116 Jan 27 14:33 patchlevel.h
  580. -rw-r--r--  1 uni-koblenz    85301 Mar  5 10:45 pickedit.c
  581. -rw-r--r--  1 uni-koblenz     1799 Mar  5 10:45 pickedit.h
  582. -rw-r--r--  1 uni-koblenz    65217 Mar  5 10:45 pics.h
  583. -rwxr-xr-x  1 uni-koblenz       20 Mar  5 10:45 texcad*
  584. -rw-r--r--  1 uni-koblenz    10421 Apr 10 16:48 texcad12.man
  585. -rw-r--r--  1 uni-koblenz      700 Mar  5 10:45 x_stuff.h
  586. -rw-r--r--  1 uni-koblenz     1731 Mar  5 10:45 yyscan.h
  587. -rw-r--r--  1 uni-koblenz     6312 Mar  5 10:45 yyscan.l
  588. X
  589. X
  590. X     Imakefile            
  591. X     Makefile.std            % my old makefile        
  592. X     
  593. X     ereignis.c                % event distribution...
  594. X     ereignis.h
  595. X     
  596. X     graphics.c                % the main graphic functions
  597. X     graphics.h
  598. X     
  599. X     file_sel.c                % the file selector box
  600. X     file_sel.h
  601. X     
  602. X     io_trans.c                % the i/o functions
  603. X     io_trans.h
  604. X     
  605. X     oberfl.c                % void main()
  606. X     oberfl.h
  607. X     
  608. X     pickedit.c                %
  609. X     pickedit.h
  610. X     
  611. X     yyscan.l                % lex scanner definition
  612. X     yyscan.h
  613. X     
  614. X     extdef.h                % external functions
  615. X     pics.h                % icons, about sign and pictures
  616. X     x_stuff.h                % what TeXcad requires from X
  617. X     
  618. X     texcad12.man            % program description (TeX format)
  619. X     
  620. X     Xtexcad.ad             % the resources for TeXcad
  621. X
  622. X
  623. X
  624. On my system 'make -f Makefile.std cad' compiles and links the whole
  625. thing.
  626. X
  627. You should use the GNU ANSI-C Compiler.
  628. I've successfully compiled TeXcad with gcc 2.0 on Sun3 and Sun4 under
  629. SunOS 4.1.1 and on DG AViiON 200 under DG/UX 4.31 and with gcc 1.40
  630. on NeXT.
  631. X
  632. Patches for Data General DGUX are done by J. Marenda (marked with /* JM */)
  633. X
  634. X
  635. !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
  636. !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
  637. !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
  638. X
  639. general hint:
  640. X
  641. Please don't use the -O optimization option on 680x0 architectures like SUN3
  642. or NeXT.  The gcc produces incorrect code which leads to crashes (here:
  643. segmentation fault within the XLib) !!!
  644. Optimization on SUN4 works properly.
  645. X
  646. !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
  647. !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
  648. !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
  649. SHAR_EOF
  650. chmod 0644 README ||
  651. echo 'restore of README failed'
  652. Wc_c="`wc -c < 'README'`"
  653. test 3363 -eq "$Wc_c" ||
  654.     echo 'README: original size 3363, current size' "$Wc_c"
  655. rm -f _shar_wnt_.tmp
  656. fi
  657. # ============= Xtexcad.ad ==============
  658. if test -f 'Xtexcad.ad' -a X"$1" != X"-c"; then
  659.     echo 'x - skipping Xtexcad.ad (File already exists)'
  660.     rm -f _shar_wnt_.tmp
  661. else
  662. > _shar_wnt_.tmp
  663. echo 'x - extracting Xtexcad.ad (Text)'
  664. sed 's/^X//' << 'SHAR_EOF' > 'Xtexcad.ad' &&
  665. XXtexcad*Font:6x13
  666. SHAR_EOF
  667. chmod 0644 Xtexcad.ad ||
  668. echo 'restore of Xtexcad.ad failed'
  669. Wc_c="`wc -c < 'Xtexcad.ad'`"
  670. test 18 -eq "$Wc_c" ||
  671.     echo 'Xtexcad.ad: original size 18, current size' "$Wc_c"
  672. rm -f _shar_wnt_.tmp
  673. fi
  674. # ============= ereignis.c ==============
  675. if test -f 'ereignis.c' -a X"$1" != X"-c"; then
  676.     echo 'x - skipping ereignis.c (File already exists)'
  677.     rm -f _shar_wnt_.tmp
  678. else
  679. > _shar_wnt_.tmp
  680. echo 'x - extracting ereignis.c (Text)'
  681. sed 's/^X//' << 'SHAR_EOF' > 'ereignis.c' &&
  682. /* xtexcad  V1.2 - graphic editor for LaTeX */
  683. /* 1991 by K.Zitzmann */
  684. /* ereignis.c */
  685. X
  686. #include "x_stuff.h"
  687. #include "ereignis.h"
  688. #include "file_sel.h"
  689. #include "oberfl.h"
  690. #include "graphics.h"
  691. #include "io_trans.h"
  692. #include <math.h>
  693. #include "pics.h"
  694. #include "pickedit.h"
  695. X
  696. /* used by the cross-hair-pointer */
  697. int             h_cross = -999;
  698. int             v_cross = -999;
  699. X
  700. X
  701. X
  702. X
  703. void
  704. about_handler()
  705. {
  706. X    /* displays additional information about this program, like */
  707. X    /* the copyright,author etc. */
  708. X
  709. X    Display        *disp;
  710. X    Window          win;
  711. X    Widget          child, child2, box;
  712. X    XtTranslations  trans_table;
  713. X    char            destination[80] = "<LeaveNotify>: XtMenuPopdown()";
  714. X    Position        x, y, x_rel, y_rel;
  715. X    char            ss[200];
  716. X
  717. X    strcpy(ss,titlename);
  718. X    strcat(ss," -  SHAREWARE-Utility For The Development\nOf Portable LaTeX-Graphics.\n\n");
  719. X    strcat(ss,"    Last Change: 1/1992\n");
  720. X
  721. X    
  722. X    about = XtCreatePopupShell("About...", transientShellWidgetClass, canvas, NULL,0);
  723. X
  724. X
  725. X    n = 0;
  726. X    XtSetArg(args[n], XtNborderWidth, 0);
  727. X    n++;
  728. X    box = XtCreateManagedWidget("abt1", boxWidgetClass, about, args, n);
  729. X
  730. X    n = 0;
  731. X    disp = XtDisplay(toplevel);
  732. X    win = XtWindow(toplevel);
  733. X    about_map = XCreateBitmapFromData(disp, win, texcad_bits, texcad_width, texcad_height);
  734. X    XtSetArg(args[n], XtNborderWidth, 0);
  735. X    n++;
  736. X    XtSetArg(args[n], XtNjustify, XtJustifyCenter);
  737. X    n++;
  738. X    XtSetArg(args[n], XtNbitmap, about_map);
  739. X    n++;
  740. X    XtSetArg(args[n], XtNwidth, 2 * texcad_width);
  741. X    n++;
  742. X    
  743. X    child = XtCreateManagedWidget("abt2", labelWidgetClass, box, args, n);
  744. X
  745. X    n = 0;
  746. X    XtSetArg(args[n], XtNheight, texcad_height);
  747. X    n++;
  748. X    XtSetArg(args[n], XtNborderWidth, 0);
  749. X    n++;
  750. X    XtSetArg(args[n], XtNwidth, 2 * texcad_width);
  751. X    n++;
  752. X    
  753. X    child2 = XtCreateManagedWidget(ss, labelWidgetClass, box, args, n);
  754. X
  755. X
  756. X
  757. X    /* Override Translation Manager */
  758. X
  759. X    trans_table = XtParseTranslationTable(destination);
  760. X    XtOverrideTranslations(about, trans_table);
  761. X
  762. X
  763. X    /* setting the widget-position */
  764. X    n = 0;
  765. X    XtSetArg(args[n], XtNx, &x_rel);
  766. X    n++;
  767. X    XtSetArg(args[n], XtNy, &y_rel);
  768. X    n++;
  769. X    XtGetValues(canvas, args, n);    /* get the relative coordinates of
  770. X                     * widget: canvas */
  771. X    XtTranslateCoords(canvas, x_rel, y_rel, &x, &y);
  772. X    n = 0;
  773. X    XtSetArg(args[n], XtNx, x + cmd_btn_width + 3 * new_section);
  774. X    n++;
  775. X    XtSetArg(args[n], XtNy, y + 2 * cmd_btn_height);
  776. X    n++;
  777. X    XtSetValues(about, args, n);
  778. X
  779. X
  780. X
  781. X
  782. X    XtPopup(about, XtGrabExclusive);
  783. X
  784. X
  785. X
  786. }
  787. X
  788. X
  789. X
  790. X
  791. void
  792. draw_coords(Widget cmd, caddr_t hi, caddr_t call_data)
  793. {
  794. X    /* displays the absolute and relative coordinates of the pointer. */
  795. X    /* Furthermore it handles the cross-wire */
  796. X
  797. X    Display        *disp = XtDisplay(coordinates);
  798. X    Window          win = XtWindow(coordinates);
  799. X    Display        *disp2 = XtDisplay(pboard);
  800. X    Window          win2 = XtWindow(pboard);
  801. X    int             x, y, h, v;
  802. X    float           a, b;
  803. X    unsigned int    mask;
  804. X    char            s1[13];
  805. X    char            s2[13];
  806. X
  807. X
  808. X
  809. X
  810. X
  811. X    snapPointerPosition(&x, &y, &mask);
  812. X
  813. X    if ((h_cross != x) || (v_cross != y))
  814. X    {    /* redraw */
  815. X        if (zoomed == True)
  816. X        {
  817. X            a = x;
  818. X            b = y;
  819. X            zoomed2real(&a, &b);
  820. X            h = (int) a;
  821. X            v = (int) b;
  822. X            if (h < 0)
  823. X                h = 0;
  824. X            if (v < 0)
  825. X                v = 0;
  826. X            if (x < 1)
  827. X                sprintf(s1, "X=000,%3.3i", h);
  828. X            else
  829. X                sprintf(s1, "X=%3.3i,%3.3i", x, h);
  830. X            if (y < 1)
  831. X                sprintf(s2, "Y=000,%3.3i", v);
  832. X            else
  833. X                sprintf(s2, "Y=%3.3i,%3.3i", y, v);
  834. X        } else
  835. X        {
  836. X            if (x < 1)
  837. X                strcpy(s1, "X=---,000");
  838. X            else
  839. X                sprintf(s1, "X=---,%3.3i", x);
  840. X            if (y < 1)
  841. X                strcpy(s2, "Y=---,000");
  842. X            else
  843. X                sprintf(s2, "Y=---,%3.3i", y);
  844. X        }
  845. X
  846. X        XClearArea(disp, win, 15, 11, 70, 30, False);
  847. X        
  848. /* JM */
  849. X        
  850. X        if (black_white_patch)
  851. X            XSetFunction(disp, gc, GXand);
  852. X        else
  853. X            XSetFunction(disp, gc, GXor);
  854. X
  855. X        XDrawString(disp, win, gc, 3, 12, "  rel abs", 9);
  856. X        XDrawString(disp, win, gc, 3, 24, s1, 9);
  857. X        XDrawString(disp, win, gc, 3, 36, s2, 9);
  858. X
  859. /* JM */    if (black_white_patch)
  860. X            XSetFunction(disp, gc, GXequiv);
  861. X        else
  862. X            XSetFunction(disp, gc, GXxor);
  863. X
  864. X        /* cross */
  865. X
  866. X        if (cross == True)
  867. X        {
  868. X            XDrawLine(disp2, win2, gc, x, 0, x, y_A4_max);
  869. X            XDrawLine(disp2, win2, gc, 0, y, x_A4_max, y);
  870. X
  871. X
  872. X            /* delete old */
  873. X            if (h_cross != -999)
  874. X            {
  875. X                XDrawLine(disp2, win2, gc, h_cross, 0, h_cross, y_A4_max);
  876. X                XDrawLine(disp2, win2, gc, 0, v_cross, x_A4_max, v_cross);
  877. X            }
  878. X        }    /* cross==True */
  879. X    }    /* redraw */
  880. X    h_cross = x;
  881. X    v_cross = y;
  882. X
  883. X
  884. }
  885. X
  886. X
  887. void
  888. ruler_on()
  889. {
  890. X    /* enable ruler */
  891. X
  892. X    char            s[3];
  893. X    int             x, y, step = 4;
  894. X    Display        *disp = XtDisplay(pboard);
  895. X    Window          win = XtWindow(pboard);
  896. X    Boolean         first = True;
  897. X    int             adjust;
  898. X    float           hor = 1, ver = 1;
  899. X    int             zahl;
  900. X
  901. X
  902. X    for (x = step; x < x_A4_max; x += step)
  903. X    {
  904. X        if ((x % 16) == 0)
  905. X            XDrawLine(disp, win, gc, x, y_A4_max, x, y_A4_max - 4);
  906. X        else if ((x % 40) == 0)
  907. X        {
  908. X            XDrawLine(disp, win, gc, x, y_A4_max, x, y_A4_max - 7);
  909. X            if (first == True)
  910. X                first = False;    /* don't draw the first one */
  911. X            else
  912. X            {
  913. X                if (zoomed == True)
  914. X                {
  915. X                    hor = (float) x;
  916. X                    zoomed2real(&hor, &ver);
  917. X                    zahl = (int) (hor + 0.5);
  918. X                } else
  919. X                    zahl = x;
  920. X                sprintf(s, "%i", (int) (zahl));
  921. X                if (strlen(s) == 2)
  922. X                    adjust = 10;
  923. X                else
  924. X                    adjust = 13;
  925. X                XDrawString(disp, win, gc, x - adjust, y_A4_max - 10, s, strlen(s));
  926. X            }
  927. X        } else
  928. X            XDrawLine(disp, win, gc, x, y_A4_max, x, y_A4_max - 2);
  929. X    }
  930. X
  931. X    for (y = y_A4_max - step; y > 0; y -= step)
  932. X    {
  933. X        if ((y % 16) == 0)
  934. X            XDrawLine(disp, win, gc, 0, y, 4, y);
  935. X        else if ((y % 40) == 0)
  936. X        {
  937. X            XDrawLine(disp, win, gc, 0, y, 7, y);
  938. X            if (zoomed == True)
  939. X            {
  940. X                ver = (float) y;
  941. X                zoomed2real(&hor, &ver);
  942. X                zahl = (int) (ver + 0.5);
  943. X            } else
  944. X                zahl = y;
  945. X            sprintf(s, "%i", (int) (zahl));
  946. X            XDrawString(disp, win, gc, 10, y + 4, s, strlen(s));
  947. X        } else
  948. X            XDrawLine(disp, win, gc, 0, y, 2, y);
  949. X    }
  950. }
  951. X
  952. X
  953. X
  954. void
  955. ruler_switch(Widget w, char c, caddr_t call_data)
  956. {
  957. X    /* called by the settings menu (callback) */
  958. X    /* toggles the use of the ruler */
  959. X
  960. X    if (ruler == True)
  961. X        ruler = False;
  962. X    else
  963. X        ruler = True;
  964. X
  965. X    ruler_on();
  966. }
  967. X
  968. X
  969. void
  970. cross_switch(Widget w, char c, caddr_t call_data)
  971. {
  972. X    /* toggles the use of the cross-hair */
  973. X
  974. X    Display        *disp = XtDisplay(pboard);
  975. X    Window          win = XtWindow(pboard);
  976. X    unsigned int    mask;
  977. X    if (cross == True)
  978. X        cross = False;    /* redraw cross-cursor */
  979. X
  980. X
  981. X    else
  982. X    {
  983. X        cross = True;
  984. X        /* draw it */
  985. X        snapPointerPosition(&h_cross, &v_cross, &mask);
  986. X    }
  987. X
  988. X    XDrawLine(disp, win, gc, h_cross, 0, h_cross, y_A4_max);
  989. X    XDrawLine(disp, win, gc, 0, v_cross, x_A4_max, v_cross);
  990. X
  991. X
  992. }
  993. X
  994. X
  995. void
  996. automatic_refresh(Widget w, caddr_t client_data, caddr_t call_data)
  997. {
  998. X    if (refr_auto == True)
  999. X        refr_auto = False;
  1000. X    else
  1001. X        refr_auto = True;
  1002. }
  1003. X
  1004. X
  1005. void
  1006. full_dina4(Widget w, caddr_t client_data, caddr_t call_data)
  1007. {
  1008. X    if (dina4 == True)
  1009. X        dina4 = False;
  1010. X    else
  1011. X        dina4 = True;
  1012. }
  1013. X
  1014. X
  1015. void
  1016. l_length_switch(Widget w, caddr_t client_data, caddr_t call_data)
  1017. {
  1018. X    if (line_length == 0)
  1019. X        line_length = 10;
  1020. X    else
  1021. X        line_length = 0;
  1022. }
  1023. X
  1024. void
  1025. aus_raster(Widget w, char c, caddr_t call_data)
  1026. {
  1027. X    /* toggles the use of a raster */
  1028. X    /* realizes raster height/width input */
  1029. X
  1030. X    XtAppContext    app_context;    /* Applikationcontext */
  1031. X    XEvent          event;
  1032. X    Position        x, y, x_rel, y_rel;
  1033. X    int             h, v;
  1034. X    unsigned int    mask;
  1035. X
  1036. X
  1037. X
  1038. X
  1039. X    if (raster == False)
  1040. X    {
  1041. X        XtPopdown(radio_up);
  1042. X        PointerPosition(&h, &v, &mask);
  1043. X        /* setting position of widget */
  1044. X        n = 0;
  1045. X        XtSetArg(args[n], XtNx, &x_rel);
  1046. X        n++;
  1047. X        XtSetArg(args[n], XtNy, &y_rel);
  1048. X        n++;
  1049. X        XtGetValues(canvas, args, n);
  1050. X        /* get the relative coordinates of widget: canvas */
  1051. X        XtTranslateCoords(canvas, x_rel, y_rel, &x, &y);
  1052. X        n = 0;
  1053. X        XtSetArg(args[n], XtNx, x + cmd_btn_width + 2 * new_section);
  1054. X        n++;
  1055. X        XtSetArg(args[n], XtNy, y + 4 * cmd_btn_height);
  1056. X        n++;
  1057. X        XtSetValues(raster_up, args, n);
  1058. X        /* position set ! */
  1059. X
  1060. X        /* query raster-height */
  1061. X        XtPopup(raster_up, XtGrabExclusive);
  1062. X
  1063. X        app_context = XtWidgetToApplicationContext(raster_up);
  1064. X
  1065. X        visible = True;
  1066. X
  1067. X        while (visible)
  1068. X        {
  1069. X            XtAppNextEvent(app_context, &event);
  1070. X            XtDispatchEvent(&event);
  1071. X
  1072. X        }
  1073. X
  1074. X    } else
  1075. X        raster = False;
  1076. X
  1077. }
  1078. X
  1079. void
  1080. raster_on()
  1081. {
  1082. X    /* display raster */
  1083. X
  1084. X    Display        *disp = XtDisplay(pboard);
  1085. X    Window          win = XtWindow(pboard);
  1086. X    int             x, y, x_disp, y_disp, zoom=(zoomed==True) ? 10 : 1;
  1087. X    float           h = 1, v = 1;    /* dummy init */
  1088. X    int         cross_len=3;
  1089. X    int        cross_space;
  1090. X    char        d_list[2];
  1091. X
  1092. X
  1093. X    /* enable raster display on pboard */
  1094. X
  1095. X    y = rast_height; 
  1096. X    x = rast_height;
  1097. X
  1098. X    if (zoomed==True)
  1099. X    {
  1100. X        d_list[0] = (char)cross_len;
  1101. X        d_list[1] = (char)10;
  1102. X        XSetLineAttributes(disp, copy_gc, 0, LineOnOffDash, CapButt, JoinMiter);
  1103. X    }
  1104. X    else
  1105. X    {
  1106. X        cross_space=rast_height-cross_len; 
  1107. X    
  1108. X        d_list[0]=(char)cross_len;
  1109. X        d_list[1]=(char)cross_space;
  1110. X    }
  1111. X
  1112. X
  1113. X        XSetDashes(disp,copy_gc,0,d_list,2);
  1114. X
  1115. X
  1116. X
  1117. X    for (; (x <= 600 - rast_height); x += rast_height)
  1118. X    {
  1119. X        if (zoomed == True)
  1120. X        {
  1121. X            h = (float) x;
  1122. X            real2zoomed(&h, &v);
  1123. X            x_disp = (int) h;
  1124. X        } else
  1125. X            x_disp = x;
  1126. X
  1127. X        XDrawLine(disp, win, copy_gc, x_disp, rast_height-(int)(cross_len/2), x_disp, 840 - (int)(cross_len/2));
  1128. X    }
  1129. X
  1130. X
  1131. X
  1132. X    for (; (y <= 840 - rast_height); y += rast_height)
  1133. X    {
  1134. X        if (zoomed == True)
  1135. X        {
  1136. X            v = (float) y;
  1137. X            real2zoomed(&h, &v);
  1138. X            y_disp = (int) v;
  1139. X        } else
  1140. X            y_disp = y;
  1141. X
  1142. X        XDrawLine(disp, win, copy_gc, rast_height-(int)(cross_len/2), y_disp, 600 - (int)(cross_len/2), y_disp);
  1143. X
  1144. X    }
  1145. X
  1146. X
  1147. }
  1148. X
  1149. X
  1150. void
  1151. raster_off()
  1152. {
  1153. X
  1154. X    /* disable raster display on pboard */
  1155. X
  1156. X    raster_on();
  1157. X
  1158. X
  1159. X
  1160. }
  1161. X
  1162. X
  1163. void
  1164. get_number()
  1165. {
  1166. X    /* raster-stuff */
  1167. X    int             j=0,i=0;
  1168. X    char        zahl[10],un[2];
  1169. X    Boolean        unknown=False;
  1170. X    float         num=0.0;
  1171. X    char        out[300];
  1172. X
  1173. X    raster = True;
  1174. X    ulen=1.0; /* standard unitlength */
  1175. X    unit=1; /* standard: points */
  1176. X
  1177. X    /* set new raster-height/width or default value */
  1178. X
  1179. X    /* scan the input ! */
  1180. X    zahl[0]='\0';
  1181. X
  1182. X    while( ( (isdigit(chain[i])) || (chain[i]=='.') ) && (i<=strlen(chain)) )
  1183. X    {
  1184. X        zahl[i]=chain[i];
  1185. X        i++;
  1186. X        zahl[i]='\0';
  1187. X    }
  1188. X
  1189. X    /* the number is in zahl */
  1190. X
  1191. X    num=(zahl[0]!='\0') ? atof(zahl) : 0.0;
  1192. X
  1193. X    /* get the unit - take 'pt' if none is specified */
  1194. X
  1195. X    while(i<=strlen(chain) && j<=2)
  1196. X    {
  1197. X        if (isalpha(chain[i])) un[j++]=chain[i];
  1198. X        i++;
  1199. X    }
  1200. X    
  1201. X    if ((toupper(un[0]))=='I') unit=2; /* Inch */
  1202. X    else
  1203. X    if ((toupper(un[0]))=='C') unit=3; /* Cm */
  1204. X    else
  1205. X    if ((toupper(un[0]))=='M') unit=4; /* Mm */
  1206. X    else
  1207. X    if ((toupper(un[0]))=='P') /* Pica or Point */
  1208. X    {
  1209. X        if ((toupper(un[1]))=='T') unit=1; /* point */
  1210. X        else 
  1211. X        if ((toupper(un[1]))=='C') unit=5; /* pica */
  1212. X        else unknown=True;
  1213. X    } else unknown=True;
  1214. X    
  1215. X    if (unknown==True) /* unit not recognized */
  1216. X        unit=1; /* default-unit = points */
  1217. X    
  1218. X    if (num!=0.0) rast_height=(int)compute_length(num);
  1219. X        else rast_height=40; /* standard raster */
  1220. X
  1221. X    if (rast_height<4)
  1222. X    {
  1223. X        num=-1.0;
  1224. X        rast_height=40;
  1225. X    }
  1226. X    
  1227. X    visible = False;
  1228. X
  1229. X    XtPopdown(raster_up);
  1230. X
  1231. X    out[0]='\0';
  1232. X
  1233. X    if ( (num==0.0) && (unknown==True) )
  1234. X        strcat(out,"ERROR !!!\n - Unit not recognized\n - No value specified\n\nInvoking standard
  1235. raster...\n");
  1236. X    else if (unknown==True) strcat(out,"ERROR !!!\n - Unit not recognized\n\nTaking POINTS now !\n");
  1237. X    else if (num==0.0) strcat(out,"ERROR !!!\n - No valid value !\nInvoking standard raster...\n");
  1238. X    
  1239. X
  1240. X
  1241. X    if (num==-1.0) strcat(out,"Sorry - raster too small !\nInvoking standard raster...\n");
  1242. X
  1243. X
  1244. X    if (out[0]!='\0') leave_pick(out);
  1245. X
  1246. X
  1247. X    
  1248. X
  1249. }
  1250. X
  1251. X
  1252. X
  1253. void
  1254. snap_on(Widget w, caddr_t client_data, caddr_t call_data)
  1255. {
  1256. X    /* enable snap function for LaTeX-Graph-File */
  1257. X
  1258. X    if (snap == False)
  1259. X        snap = True;
  1260. X    else
  1261. X        snap = False;
  1262. X
  1263. }
  1264. X
  1265. X
  1266. X
  1267. void
  1268. slopes(Widget w, caddr_t client_data, caddr_t call_data)
  1269. {
  1270. X    /* toggles the use of finit/infinite slopes */
  1271. X
  1272. X    if (steigung == False)
  1273. X    {
  1274. X        steigung = True;
  1275. X        /* all slopes allowed */
  1276. X        line_slope = 0;
  1277. X        arrow_slope = 0;
  1278. X    } else
  1279. X    {
  1280. X        steigung = False;
  1281. X        line_slope = slope_line;
  1282. X        arrow_slope = slope_arrow;
  1283. X    }
  1284. X
  1285. }
  1286. X
  1287. void
  1288. diams(Widget w, caddr_t client_data, caddr_t call_data)
  1289. {
  1290. X    /* toggles the use of unlimited diameters */
  1291. X    if (durchmesser == False)
  1292. X    {
  1293. X        durchmesser = True;
  1294. X        circle_diameter[0] = -1;
  1295. X        disc_diameter[0] = -1;
  1296. X    } else
  1297. X    {
  1298. X        durchmesser = False;
  1299. X        circle_diameter[0] = 1;
  1300. X        disc_diameter[0] = 1;
  1301. X    }
  1302. }
  1303. X
  1304. X
  1305. void
  1306. load_handler()
  1307. {
  1308. X    /* read a LaTeX-file from the medium */
  1309. X
  1310. X    char            title[] = "Load object";
  1311. X    char            pattern[] = "*.tex";
  1312. X    char           *name;
  1313. X    Position        x, y, x_rel, y_rel;
  1314. X
  1315. X
  1316. X    n = 0;
  1317. X    XtSetArg(args[n], XtNx, &x_rel);
  1318. X    n++;
  1319. X    XtSetArg(args[n], XtNy, &y_rel);
  1320. X    n++;
  1321. X    XtGetValues(canvas, args, n);    /* get the relative coordinates of
  1322. X                     * widget: canvas */
  1323. X
  1324. X    XtTranslateCoords(canvas, x_rel, y_rel, &x, &y);
  1325. X        
  1326. X    centerpopup(canvas,fileselector);
  1327. X    name =
  1328. X        file_select(pattern, title);
  1329. X
  1330. X    if (name != NULL)
  1331. X    {
  1332. X        perform_erase();    /* clear data-base */
  1333. X        load_it(name);
  1334. X    }
  1335. }
  1336. X
  1337. X
  1338. X
  1339. X
  1340. void
  1341. trans_handler()
  1342. {
  1343. X    /* translate the objects to pure LaTeX-code */
  1344. X
  1345. X    char            title[] = "Save object";
  1346. X    char            pattern[] = "*.tex";
  1347. X    char           *name;
  1348. X    Position        x, y, x_rel, y_rel;
  1349. X    if (
  1350. X        disc_start == NULL &&
  1351. X        kreis_start == NULL &&
  1352. X        filledBox_start == NULL &&
  1353. X        oval_start == NULL &&
  1354. X        strich_start == NULL &&
  1355. X        pfeil_start == NULL &&
  1356. X        framedBox_start == NULL &&
  1357. X        dashedBox_start == NULL &&
  1358. X        bezier_start == NULL &&
  1359. X        message_start == NULL)
  1360. X    {
  1361. X        leave_pick("SAVE:\n\nThere are no objects !");
  1362. X        return;
  1363. X    }
  1364. X    n = 0;
  1365. X    XtSetArg(args[n], XtNx, &x_rel);
  1366. X    n++;
  1367. X    XtSetArg(args[n], XtNy, &y_rel);
  1368. X    n++;
  1369. X    XtGetValues(canvas, args, n);    /* get the relative coordinates of
  1370. X                     * widget: canvas */
  1371. X
  1372. X    XtTranslateCoords(canvas, x_rel, y_rel, &x, &y);
  1373. X
  1374. X    centerpopup(canvas,fileselector);
  1375. X    name =
  1376. X        file_select(pattern, title);
  1377. X
  1378. X    if (name != NULL)
  1379. X        trans_it(name);
  1380. X
  1381. }
  1382. X
  1383. void
  1384. general_purpose_handler(Widget cmd, caddr_t id, caddr_t call_data)
  1385. {
  1386. X    /* distributes all other incoming events */
  1387. X
  1388. X    int             i;
  1389. X    char            txt[100];
  1390. X    XtTranslations  trans_table;
  1391. X    char            destination[80] = "<EnterWindow> : set_TM_btn1_first() \n\
  1392. X               <LeaveWindow> : left()";
  1393. X    static XtActionsRec actions[80] = {{"set_TM_btn1_first", set_TM_btn1_first},
  1394. X    {"left", left}};
  1395. X
  1396. X
  1397. X    XtAddActions(actions, XtNumber(actions));
  1398. X    trans_table = XtParseTranslationTable(destination);
  1399. X    XtOverrideTranslations(pboard, trans_table);
  1400. X
  1401. X    /* set the new current action code */
  1402. X    graph_action = (char) id;
  1403. X
  1404. X    strcpy(txt, titlename);
  1405. X    strcat(txt, "  :  ");
  1406. X
  1407. X    switch (graph_action)
  1408. X    {
  1409. X    case 'L':
  1410. X        strcat(txt, "#### Line ####");
  1411. X        headline(toplevel, txt);
  1412. X        break;
  1413. X
  1414. X    case 'V':
  1415. X        strcat(txt, "#### Vector ####");
  1416. X        headline(toplevel, txt);
  1417. X        break;
  1418. X
  1419. X    case 'Z':
  1420. X        strcat(txt, "#### Area Zoom ####");
  1421. X        headline(toplevel, txt);
  1422. X        break;
  1423. X
  1424. X    case 'T':
  1425. X        strcat(txt, "#### Text ####");
  1426. X        headline(toplevel, txt);
  1427. X        break;
  1428. X
  1429. X    case 'N':
  1430. X        strcat(txt, "#### Box --> framed ####");
  1431. X        headline(toplevel, txt);
  1432. X        break;
  1433. X
  1434. X    case 'D':
  1435. X        strcat(txt, "#### Box --> dashed ####");
  1436. X        headline(toplevel, txt);
  1437. X        break;
  1438. X
  1439. X    case 'F':
  1440. X        strcat(txt, "#### Box --> filled ####");
  1441. X        headline(toplevel, txt);
  1442. X        break;
  1443. X
  1444. X    case 'C':
  1445. X        strcat(txt, "#### Circle --> normal ####");
  1446. X        headline(toplevel, txt);
  1447. X        break;
  1448. X
  1449. X    case 'O':
  1450. X        strcat(txt, "#### Circle --> oval ####");
  1451. X        headline(toplevel, txt);
  1452. X        break;
  1453. X
  1454. X    case 'B':
  1455. X        strcat(txt, "#### Circle --> filled ####");
  1456. X        headline(toplevel, txt);
  1457. X        break;
  1458. X
  1459. X    case 'A':
  1460. X        strcat(txt, "#### Erase --> erasing the entire database ####");
  1461. X        headline(toplevel, txt);
  1462. X        query_ask_erase();
  1463. X        if (txtpos[0] == 'j')
  1464. X            perform_erase();
  1465. X        XtUninstallTranslations(pboard);
  1466. X        left();
  1467. X        break;
  1468. X
  1469. X    case 'G':
  1470. X        if ( (i=sorry_msg())==-1 ) break;
  1471. X        strcat(txt, "#### Erase --> pick the desired object ####");
  1472. X        headline(toplevel, txt);
  1473. X        break;
  1474. X
  1475. X    case 'P':
  1476. X        if ( (i=sorry_msg())==-1 ) break;
  1477. X        strcat(txt, "#### Pick object ####");
  1478. X        headline(toplevel, txt);
  1479. X        break;
  1480. X
  1481. X    case 'Y':
  1482. X        if ( (i=sorry_msg())==-1 ) break;
  1483. X        strcat(txt, "#### Pick object to copy ####");
  1484. X        headline(toplevel, txt);
  1485. X        break;
  1486. X
  1487. X    case 'I':
  1488. X        strcat(txt, "#### Bezier ####");
  1489. X        headline(toplevel, txt);
  1490. X        break;
  1491. X
  1492. X    default:
  1493. X        break;
  1494. X    }    /* switch */
  1495. }
  1496. X
  1497. X
  1498. X
  1499. X
  1500. X
  1501. void
  1502. quit_handler(Widget cmd, caddr_t client_data, caddr_t call_data)
  1503. {
  1504. X    XFreePixmap(XtDisplay(pboard), about_map);
  1505. X    perform_erase();    /* clear data-base */
  1506. X    exit(0);
  1507. }
  1508. X
  1509. X
  1510. void
  1511. options(Widget w, caddr_t client_data, caddr_t call_data)
  1512. {
  1513. X    /* puts the settings-menu to the right position */
  1514. X
  1515. X    Position        x, y, x_rel, y_rel;
  1516. X    n = 0;
  1517. X    XtSetArg(args[n], XtNx, &x_rel);
  1518. X    n++;
  1519. X    XtSetArg(args[n], XtNy, &y_rel);
  1520. X    n++;
  1521. X
  1522. X    /* get the relative coordinates of widget: canvas */
  1523. X    XtGetValues(canvas, args, n);
  1524. X
  1525. X    XtTranslateCoords(canvas, x_rel, y_rel, &x, &y);
  1526. X
  1527. X    n = 0;
  1528. X    XtSetArg(args[n], XtNx, x + cmd_btn_width + 2 * new_section);
  1529. X    n++;
  1530. X    XtSetArg(args[n], XtNy, y + 9 * cmd_btn_height);
  1531. X    n++;
  1532. X    XtSetValues(radio_up, args, n);
  1533. X
  1534. X    XtPopupSpringLoaded(radio_up);
  1535. }
  1536. X
  1537. X
  1538. void
  1539. answer(Widget w, char c, caddr_t call_data)
  1540. {
  1541. X    txtpos[0] = c;
  1542. X    XtPopdown(ask_up);
  1543. X    visible = False;
  1544. X
  1545. }
  1546. SHAR_EOF
  1547. chmod 0644 ereignis.c ||
  1548. echo 'restore of ereignis.c failed'
  1549. Wc_c="`wc -c < 'ereignis.c'`"
  1550. test 16682 -eq "$Wc_c" ||
  1551.     echo 'ereignis.c: original size 16682, current size' "$Wc_c"
  1552. rm -f _shar_wnt_.tmp
  1553. fi
  1554. # ============= ereignis.h ==============
  1555. if test -f 'ereignis.h' -a X"$1" != X"-c"; then
  1556.     echo 'x - skipping ereignis.h (File already exists)'
  1557.     rm -f _shar_wnt_.tmp
  1558. else
  1559. > _shar_wnt_.tmp
  1560. echo 'x - extracting ereignis.h (Text)'
  1561. sed 's/^X//' << 'SHAR_EOF' > 'ereignis.h' &&
  1562. /* xtexcad  V1.2 - graphic editor for LaTeX */
  1563. /* 1991 by K.Zitzmann */
  1564. /* header-file ereignis.h */
  1565. X
  1566. X
  1567. X
  1568. #ifndef EREIGNISH
  1569. #define EREIGNISH
  1570. X
  1571. X
  1572. X
  1573. X
  1574. X
  1575. /* prototypes */
  1576. X
  1577. X
  1578. X
  1579. X
  1580. X void load_handler(void);
  1581. X void trans_handler(void);
  1582. X void about_handler(void);
  1583. X void quit_handler(Widget cmd, caddr_t client_data, caddr_t call_data);
  1584. X void options(Widget w, caddr_t client_data, caddr_t call_data);
  1585. X void raster_on(void);
  1586. X void raster_off(void);
  1587. X void snap_on(Widget w, caddr_t client_data, caddr_t call_data);
  1588. X void general_purpose_handler(Widget w, caddr_t client_data, caddr_t call_data);
  1589. X void aus_raster(Widget w, char c, caddr_t call_data);
  1590. X void slopes(Widget w, caddr_t c, caddr_t call_data);
  1591. X void diams(Widget w, caddr_t c, caddr_t call_data);
  1592. X void answer(Widget w, char c, caddr_t call_data);
  1593. X void get_number(void);
  1594. X void automatic_refresh(Widget w, caddr_t client_data, caddr_t call_data);
  1595. X void full_dina4(Widget w, caddr_t client_data, caddr_t call_data);
  1596. X void draw_coords(Widget cmd, caddr_t, caddr_t call_data);
  1597. X void ruler_on(void);
  1598. X void ruler_switch(Widget w, char c, caddr_t call_data);
  1599. X void cross_switch(Widget w, char c, caddr_t call_data);
  1600. X void l_length_switch(Widget w, caddr_t client_data, caddr_t call_data);
  1601. X
  1602. X
  1603. extern int h_cross;
  1604. extern int v_cross;
  1605. X
  1606. X
  1607. X
  1608. #endif
  1609. X
  1610. X
  1611. X
  1612. X
  1613. X
  1614. SHAR_EOF
  1615. chmod 0644 ereignis.h ||
  1616. echo 'restore of ereignis.h failed'
  1617. Wc_c="`wc -c < 'ereignis.h'`"
  1618. test 1281 -eq "$Wc_c" ||
  1619.     echo 'ereignis.h: original size 1281, current size' "$Wc_c"
  1620. rm -f _shar_wnt_.tmp
  1621. fi
  1622. # ============= extdef.h ==============
  1623. if test -f 'extdef.h' -a X"$1" != X"-c"; then
  1624.     echo 'x - skipping extdef.h (File already exists)'
  1625.     rm -f _shar_wnt_.tmp
  1626. else
  1627. > _shar_wnt_.tmp
  1628. echo 'x - extracting extdef.h (Text)'
  1629. sed 's/^X//' << 'SHAR_EOF' > 'extdef.h' &&
  1630. /* xtexcad  V1.2 - graphic editor for LaTeX */
  1631. /* 1991 by K.Zitzmann */
  1632. /* header-file extdef.h */
  1633. X
  1634. X
  1635. #ifndef EXTERNALH
  1636. #define EXTERNALH
  1637. X
  1638. #ifndef DGUX
  1639. extern double atof(char *txt);
  1640. #endif
  1641. extern double sqrt(double x);
  1642. extern int abs(int x);
  1643. extern double fabs(double x);
  1644. extern double acos(double x);
  1645. extern double sin(double x);
  1646. extern char *malloc(int l);
  1647. extern char *getenv(char *s);           
  1648. extern int chdir();                     
  1649. X
  1650. /* to be continued... */
  1651. X
  1652. X
  1653. #endif
  1654. SHAR_EOF
  1655. chmod 0644 extdef.h ||
  1656. echo 'restore of extdef.h failed'
  1657. Wc_c="`wc -c < 'extdef.h'`"
  1658. test 476 -eq "$Wc_c" ||
  1659.     echo 'extdef.h: original size 476, current size' "$Wc_c"
  1660. rm -f _shar_wnt_.tmp
  1661. fi
  1662. # ============= file_sel.c ==============
  1663. if test -f 'file_sel.c' -a X"$1" != X"-c"; then
  1664.     echo 'x - skipping file_sel.c (File already exists)'
  1665.     rm -f _shar_wnt_.tmp
  1666. else
  1667. > _shar_wnt_.tmp
  1668. echo 'x - extracting file_sel.c (Text)'
  1669. sed 's/^X//' << 'SHAR_EOF' > 'file_sel.c' &&
  1670. /* xtexcad  V1.2 - graphic editor for LaTeX */
  1671. /* 1991 by K.Zitzmann */
  1672. /* file_sel.c */
  1673. X
  1674. X
  1675. #define MAXPATH LAENGE+LAENGE2   /* Laenge mit Pfad */ 
  1676. #define LAENGE 21                /* Laenge Dateiname */
  1677. #define WEITE 150                /* Breite des Directoryfensters */
  1678. #define LAENGE2 50               /* Laenge Pfadname */
  1679. #define HOEHE 300                /* Hoehe des Directoryfensters */
  1680. #define ABSTAND 8                /* Abstand zwischen den einzelnen Widgets */
  1681. #define DEFAULT_X 300            /* Vorgabe fuer X Koordinate */
  1682. #define DEFAULT_Y 300            /* Vorgabe fuer Y Koordinate */
  1683. X
  1684. #include <strings.h>
  1685. #include <sys/types.h>
  1686. #include <sys/param.h>
  1687. #include <sys/dir.h>
  1688. #include <sys/stat.h>
  1689. #include <X11/IntrinsicP.h>
  1690. #include <X11/Shell.h>
  1691. #include <X11/ShellP.h>
  1692. #include <X11/Xaw/Viewport.h>
  1693. #include <X11/Xaw/DialogP.h>
  1694. /* R4: */
  1695. /* #include <X11/Xaw/AsciiSrc.h> */
  1696. /* R5 */
  1697. #include <X11/Xaw/AsciiText.h>
  1698. X
  1699. #include <X11/Xaw/Text.h>
  1700. X
  1701. #include "extdef.h"
  1702. #include "x_stuff.h"
  1703. #include "file_sel.h"
  1704. X
  1705. X
  1706. static char *filename;                    /* Pointer auf Filename */
  1707. static Widget file_s;                     /* Popupshell fuer Fileselectbox */
  1708. static Widget list_direct,                /* Directoryeintraege im Fenster */
  1709. X          titel_zeile;                /*Label fuer angezeigte Titelzeile */
  1710. X
  1711. static DialogWidget path,                 /* Dialog fuer Ausgabe Path */
  1712. X            text,                 /* Eingabe Filename DialogWidget */
  1713. X            patt_t;               /* Labelfeld Ausgabe des Patterns */
  1714. X
  1715. static char _default[LAENGE];             /* String zum Loeschen des Labels */
  1716. static char _default2[LAENGE2];           /* String zum Loesch Titel,Path */
  1717. static char patt_global[LAENGE];          /* Pattern als globale Variable */
  1718. static int init_called=0;                 /* Widgets korrekt mit INIT_FILE_ */
  1719. X                      /* SELECT initialisiert */
  1720. X
  1721. /* Pointer werden global benoetigt um Speicher beim Verlassen der Fileselect-*/
  1722. /* box wieder freigegeben werden kann */
  1723. static String *Liste;                     /* Liste der bearbeiteten Strings */
  1724. static char *Inhalt;                      /* Listeninhalt */ 
  1725. X
  1726. static char *getcwd(buf,size)
  1727. char *buf;
  1728. int size;
  1729. {
  1730. char pathname[MAXPATHLEN];
  1731. X
  1732. getwd(pathname);
  1733. pathname[size-1] = '\0';
  1734. strncpy(buf,pathname,size);
  1735. }
  1736. X
  1737. /*****************************************************************************/
  1738. /* Funktion ueberprueft, ob uebergebener Name ein Directory oder eine Datei  */
  1739. /* ist.                                                                      */
  1740. /*                                                                           */
  1741. /* Aufruf: Is_direct(name);                                                  */
  1742. /*                                                                           */
  1743. /* Parameter: char *name; Name der Datei, die als Directory getestet werden  */
  1744. /*                        soll.                                              */
  1745. /* Rueckgabe: int;  0 Uebergebener Name war kein Directory, oder Name war    */
  1746. /*                    ueberhaupt kein Eintrag in dem aktuellen Directory, der*/
  1747. /*                    opendir() zu oeffnen war.                              */
  1748. /*                  1 Uebergebener Name war Directory                        */
  1749. /*****************************************************************************/
  1750. int Is_direct(name)
  1751. X    char *name;
  1752. {
  1753. X    struct stat buf;
  1754. X
  1755. X    stat(name,&buf);         
  1756. X     
  1757. X    if(buf.st_mode & S_IFDIR)
  1758. X        return(1);              
  1759. X    else
  1760. X        return(0);
  1761. }
  1762. X
  1763. /*****************************************************************************/
  1764. /* Funktion zaehlt Eintrage im aktuellen Verzeichnis, die zum Pattern passen */
  1765. /* oder ein Directoryeintrag sind.                                           */
  1766. /*                                                                           */
  1767. /* Aufruf: count_eintraege();                                                */
  1768. /*                                                                           */
  1769. /* Parameter: keine;                                                         */
  1770. /* Rueckgabe: short; Anzahl der Eintraege im Directory, die der Bedingung    */
  1771. /*                   genuegt haben.                                          */
  1772. /*****************************************************************************/
  1773. short count_eintraege()
  1774. {
  1775. X   DIR *dirp;                      /* offenes Directory */
  1776. X   struct direct *datei;           /* gelesenener Directoryeintrag */
  1777. X   short counter=0;                
  1778. X
  1779. X   dirp = opendir(".");
  1780. X   while((datei = readdir(dirp)) != NULL)
  1781. X     if((match(datei->d_name,patt_global)) || (Is_direct(datei->d_name)))
  1782. X     counter ++;
  1783. X
  1784. X   closedir(dirp);
  1785. X   return(counter);
  1786. }
  1787. X  
  1788. /*****************************************************************************/
  1789. /* Funktion ueberprueft, ob uebergeneber String zu dem uebergebenen Pattern  */
  1790. /* passt.                                                                    */
  1791. /*                                                                           */
  1792. /* Aufruf: match(string,pattern);                                            */
  1793. /*                                                                           */
  1794. /* Parameter: char *string; String, der uenerprueft werden soll              */
  1795. /*            char *pattern; Pattern mit dem der Striong verglichen wird     */
  1796. /* Rueckgabe: 0 String passt nicht zu dem uebergebenen Pattern               */
  1797. /*            1 String passt zu dem ubergebenen Pattern                      */
  1798. /*****************************************************************************/
  1799. int match(sstring,pattern)
  1800. char *sstring,*pattern;
  1801. {
  1802. X     char *st,*pa;
  1803. X     int lst=0,lpa=0,ist=1,ipa=1;
  1804. X
  1805. X     st=sstring; while (*st++) lst++; st=sstring; /* Laenge berechnen */
  1806. X     pa=pattern;while (*pa++) lpa++; pa=pattern;/* Laenge berechnen */
  1807. X     if (!(lst*lpa)) return(0);     /* Ein String war leer */
  1808. X
  1809. X     while(1)
  1810. X      {
  1811. X      if (*pa == '?')
  1812. X           {
  1813. X           if (ist>lst) return(0);
  1814. X           ++ist; ++st; ++ipa; ++pa;
  1815. X           if ((ist>lst) && (ipa>lpa)) return(1);
  1816. X           if (ipa>lpa) return(0);
  1817. X           continue;
  1818. X           }
  1819. X      if (*pa == '*')
  1820. X           {
  1821. X           if (ipa == lpa) return(1);
  1822. X           ++ipa; ++pa;
  1823. X           if (ist > lst) continue;
  1824. X           do
  1825. X            {
  1826. X            if (match(st,pa)) return(1);
  1827. X            ++ist; ++st;
  1828. X            } while (ist <= lst);
  1829. X           return(0);
  1830. X           }
  1831. X      if ((ist > lst) || (!(*st++ == *pa++))) return(0);
  1832. X      ++ipa;
  1833. X      if ((++ist > lst) && (ipa > lpa)) return(1);
  1834. X      } /* von while */
  1835. } /* von match */
  1836. X
  1837. /*****************************************************************************/
  1838. /* Funktion erstellt aus allen passenden Eintraegen im Directory eine Liste, */
  1839. /* die an das Listwidget uebergeben werden kann.                             */
  1840. /*                                                                           */
  1841. /* Aufruf: directory_erstellen(anzahl);                                      */
  1842. /*                                                                           */
  1843. /* Parameter: short anzahl; anzahl der Eintraege, die in die Liste eingefuegt*/
  1844. /*                          werden, um Speicher zu allocieren.               */
  1845. /* Rueckgabe: String *; Pointer auf den Listenkopf                           */
  1846. /*****************************************************************************/
  1847. String *directory_erstellen(short anzahl)
  1848. X {
  1849. X   static char *offset;            /* Naechste freie Speicherstelle */
  1850. X   static DIR *dirp2;              /* offenes Directory */
  1851. X   struct direct *datei;           /* Struktur um Dateinamen zu ermitteln */
  1852. X   short i=0;                      /* Zaehler */                     
  1853. X   char f_name[LAENGE];            /* Filename in passender Laenge */
  1854. X   char *eintrag;                  /* Rueckgabe des geprueften Eintrages */
  1855. X   String *Liste2;                 /* Liste der bearbeiteten Strings */
  1856. X   char *Inhalt2;                  /* Listeninhalt */ 
  1857. X   short directory_typ;            /* Eintrag ist Directory */
  1858. X   char *stelle;                   /* temp Pointer */
  1859. X
  1860. X   /* neuen Speicher suchen */
  1861. X   Liste2 = (String *)malloc((anzahl+2)*sizeof(Liste));
  1862. X   Inhalt2 = offset = (char *)malloc((anzahl+1)*(LAENGE+1)*sizeof(char));
  1863. X
  1864. X   /* aktuelles Verzeichnis oeffnen */
  1865. X   dirp2 = opendir(".");
  1866. X
  1867. X   directory_typ = 0;
  1868. X    
  1869. X   /* Directoryeintraege in Liste uebernehmen */
  1870. X   i = 0;
  1871. X   while((datei = readdir(dirp2)) != NULL)
  1872. X     /* Eintrag ueberpruefen mit match-Funktion und ueberpruefen ob Direct. */
  1873. X     if((directory_typ = Is_direct(datei->d_name)) ||
  1874. X       (match(datei->d_name,patt_global)))
  1875. X         {
  1876. X     sprintf(f_name,"%-20.20s",datei->d_name);
  1877. X
  1878. X     /* falls Namen zu lang letzte Stelle mit Stern ausgeben */
  1879. X     if((stelle=index(f_name,' ')) == NULL)  
  1880. X       {
  1881. X       f_name[LAENGE] = '\0';
  1882. X       f_name[LAENGE-1] = '*';
  1883. X       }
  1884. X     if(directory_typ)  /* Directorys wird zur Kennung ein / angehangen */
  1885. X       {
  1886. X         /* nachfolgende Blanks abschneiden */
  1887. X         if((stelle=index(f_name,' ')) != NULL)  
  1888. X           *stelle = '/';
  1889. X         else 
  1890. X           {
  1891. X           f_name[LAENGE-1] = '/';
  1892. X           f_name[LAENGE-2] = '*';
  1893. X           }
  1894. X       }
  1895. X     strcpy(offset,f_name);              /* Stringinhalt uebernehmen */
  1896. X     Liste2[i] = (char *)offset;         /* String in Liste anfuegen */
  1897. SHAR_EOF
  1898. true || echo 'restore of file_sel.c failed'
  1899. fi
  1900. echo 'End of  part 1'
  1901. echo 'File file_sel.c is continued in part 2'
  1902. echo 2 > _shar_seq_.tmp
  1903. exit 0
  1904. -- 
  1905. --
  1906. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1907. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1908. Sunnyvale, California 94086            at&t: 408/522-9236
  1909.