~ubuntu-branches/ubuntu/quantal/texmacs/quantal

« back to all changes in this revision

Viewing changes to plugins/texgraph/bin/tm_texgraph

  • Committer: Bazaar Package Importer
  • Author(s): Atsuhito KOHDA, Kamaraju Kusumanchi, kohda
  • Date: 2009-04-26 19:35:14 UTC
  • mfrom: (1.1.10 upstream) (4.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090426193514-9yo3oggdslgdls4b
Tags: 1:1.0.7.2-1
[Kamaraju Kusumanchi <kamaraju@gmail.com>]
* New upstream release
* texmacs crashes if /usr/share/texmacs/TeXmacs/misc/pixmaps/unknown.ps
  is not present. Do not remove it. (Closes: #484073, #497021)
* update patches 03_mupad.dpatch, 04_axiom.dpatch, 11-desktop-file.dpatch
* fix the mime problem in gnome. Thanks to Andrea Gamba for the fix.
[kohda]
* Refined a fix for the mime problem in gnome a bit.
* Try to fix /bin/sh problem (debian/fixsh) but it is not complete fix yet.
* Try to fix hard coded settings for ipa fonts(patches/09_ipa.dpatch), 
  especially for Debian where no ipa fonts exist yet.
* Fixed obsolete Build-Depends: changed libltdl3-dev to 
  libltdl-dev | libltdl7-dev (the latter for Ubuntu?)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#==============================================================================
 
3
# MODULE     : tm_texgraph
 
4
# VERSION    : 0.04
 
5
# DESCRIPTION: A simple TeXmacs interface for TeXgraph
 
6
# BY         : Emmanuel Corcelle (corcelle at gmail dot com)
 
7
#------------------------------------------------------------------------------
 
8
# Based on   : A simple PSTricks interface for TeXmacs 
 
9
# COPYRIGHT  : (C) 2004 Nicolas Ratier (nicolas DOT ratier AT lpmo DOT edu))
 
10
#------------------------------------------------------------------------------
 
11
# COPYRIGHT  : (C) TeXgraph by Patrick Fradin (pfradin at tuxfamily point org) (http://texgraph.tuxfamily.org/)
 
12
#------------------------------------------------------------------------------
 
13
# tm_texgraph 
 
14
# ========== 
 
15
# bash script for interfacing TeXgraph from TeXmacs
 
16
# needs option --texmacs for compatibility with TeXmacs interface convention and user information
 
17
#
 
18
# usage within TeXmacs:
 
19
# =====================
 
20
# write texgraph-commands within the input line, use as many commands as necessary, 
 
21
# divide them by the "," chararacter, because the ENTER key terminates the input and sends it to TeXgraph.
 
22
# output is the graph made via TeXgraphCmd, latex, and dvips -E mode.
 
23
#
 
24
# Temporary file are made in ~/.TeXmacs/system/tmp
 
25
#------------------------------------------------------------------------------
 
26
# This software falls under the GNU general public license and comes WITHOUT
 
27
# ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
 
28
# If you don't have this file, write to the Free Software Foundation, Inc.,
 
29
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
30
#==============================================================================
 
31
 
 
32
if [ "$1" != "--texmacs" ]
 
33
then
 
34
        echo tm_texgraph. This script should be started only from TeXmacs.
 
35
        exit
 
36
fi      
 
37
 
 
38
# control characters
 
39
tmp=`echo DATA_BEGIN=X DATA_END=Y DATA_ESCAPE=Z | tr "XYZ" "\002\005\027" `
 
40
eval $tmp
 
41
 
 
42
# defining temporary files directory and make it if it doesn't exist
 
43
TEMP_DIR=~/.TeXmacs/system/tmp
 
44
if [ -d $TEMP_DIR ]
 
45
then
 
46
        cd $TEMP_DIR
 
47
else    
 
48
        mkdir -p $TEMP_DIR
 
49
        cd $TEMP_DIR
 
50
fi
 
51
 
 
52
# defining primary temp file name
 
53
TEMP_FILE=texgraphtmp
 
54
        
 
55
# startup banner
 
56
echo -n $DATA_BEGIN
 
57
echo verbatim:TeXmacs interface to TeXgraph.
 
58
echo To write LaTeX code inside labels, use \\\\ instead of \\. 
 
59
echo For example, write $\\\\pi$ instead of $\\pi$
 
60
echo -n $DATA_END
 
61
 
 
62
# prompt-input-texgraph-output loop
 
63
while [ 1 ]; do
 
64
        # prompt
 
65
        echo -n $DATA_BEGIN
 
66
        echo -n channel:prompt
 
67
        echo -n $DATA_END 
 
68
        echo -n TeXgraph'] '
 
69
        echo -n $DATA_END 
 
70
         
 
71
        # read a line from stdin
 
72
        read input
 
73
 
 
74
        # begin creation of TeX file
 
75
        echo -E "\documentclass{article}" >  $TEMP_FILE.tex
 
76
        echo -E "\usepackage{texgraph}"    >> $TEMP_FILE.tex
 
77
        echo -E "\pagestyle{empty}"       >> $TEMP_FILE.tex
 
78
        echo -E "\begin{document}"        >> $TEMP_FILE.tex
 
79
        echo -E "\begin{texgraph}[export=epsc]" >> $TEMP_FILE.tex
 
80
        echo -E "HideStyle:=dashed,"      >> $TEMP_FILE.tex
 
81
        echo -E "Marges(0.25,0.25,0.25,0.25),"      >> $TEMP_FILE.tex
 
82
        # other commands to initialize the graph can be included here
 
83
 
 
84
        # copy TeXgraph in latex file
 
85
        echo -E $input | tr  "~" "\n" | cat >> $TEMP_FILE.tex
 
86
 
 
87
        # finish TeX file
 
88
        echo -E "\end{texgraph}" >> $TEMP_FILE.tex
 
89
        echo -E "\end{document}" >> $TEMP_FILE.tex
 
90
 
 
91
        # compile with latex, transform to .eps and cat .eps to TeXmacs.
 
92
        latex --shell-escape --interaction=nonstopmode --draftmode $TEMP_FILE.tex 1> /dev/null 2> tmp_log
 
93
        if [ -s texgraphtmp1.eps ]
 
94
        then
 
95
                echo -n $DATA_BEGIN                             
 
96
                echo -n verbatim:
 
97
                echo -n $DATA_BEGIN
 
98
                echo -n ps:
 
99
                cat texgraphtmp1.eps
 
100
                echo -n $DATA_END
 
101
                echo -ne "\n"
 
102
                rm $TEMP_FILE.* texgraphtmp1.* tmp*
 
103
        else
 
104
                echo -n $DATA_BEGIN
 
105
                echo -n verbatim:
 
106
                cat texgraphtmp1.log
 
107
                echo -n $DATA_BEGIN
 
108
                echo -n ps:
 
109
                echo -n $DATA_END
 
110
                echo -ne "\n"
 
111
                rm $TEMP_FILE.*  texgraphtmp1.* tmp*    
 
112
        fi
 
113
done