summaryrefslogtreecommitdiff
path: root/ipl/gprocs/autopost.icn
blob: 138814b3951bbb73132040e8d923ccb29a55092e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
############################################################################
#
#	File:     autopost.icn
#
#	Subject:  Procedures to activate PostScript recorder
#
#	Author:   Gregg M. Townsend
#
#	Date:     October 11, 1994
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#   These procedures, when linked with an unsuspecting Icon program,
#   cause psrecord (q.v) to begin recording PostScript commands when
#   an X window is opened.  This is done by overloading the built-in
#   "open" function.
#
#   The results of this may or may not be usable depending on how the
#   original program is coded.  Psrecord cannot emulate all the X calls
#   and works best with programs designed for it.
#
#   "stop" and "exit" are also overloaded to try and terminate the
#   PostScript file properly.  Other program exit paths, notably a
#   return from the main procedure, are not caught.
#
############################################################################
#
#  Links:  psrecord
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################

link psrecord

invocable "open", "stop", "exit"

procedure open(args[])
   local f
   static realfunc
   initial realfunc := proc("open", 0)

   f := (realfunc ! args) | fail
   if args[2] ? upto('gx') then
      PSEnable(f)
   return f
end

procedure stop(args[])
   local f
   static realfunc
   initial realfunc := proc("stop", 0)

   PSDone()
   return realfunc ! args
end

procedure exit(args[])
   local f
   static realfunc
   initial realfunc := proc("exit", 0)

   PSDone()
   return realfunc ! args
end