texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Generic Latex plugin


From: Bas Spitters
Subject: Re: [Texmacs-dev] Generic Latex plugin
Date: Wed, 3 Aug 2005 17:20:16 +0200
User-agent: KMail/1.7.2

On Wednesday 03 August 2005 14:05, Alvaro Tejero Cantero wrote:
> However I can still think of one really necessary feature for
> graphics-oriented sessions. 
[snip]
> What do you think?

I had something similar in mind. I think this would be a nice feature, but I 
don't know how difficult it is to implement.

> PS. Bas, yur tm-gentex.sh didn't make it through some mail filtering
> systems that discard executable extensions. Maybe if you want we can put
> it in a http server, or just copy it inline in the message.

#!/bin/sh
#==============================================================================
# MODULE     : tm_gentex
# VERSION    : 0.1
# DESCRIPTION: A simple Generic LaTeX interface for TeXmacs
# COPYRIGHT  : (C) 2005 Bas Spitters
#               (Based on the XYpic plugin)
#------------------------------------------------------------------------------
# Usage within TeXmacs:
#   + write LaTeX-commands in multi-line separate by SHIFT-ENTER,
#   + then ENTER key terminates the input and sends it to latex.
# Informations:
#   + Output is the 2D graphic made via latex , and dvips -E mode.
#   + Temporary file are made in ~/.TeXmacs/system/tmp.
#------------------------------------------------------------------------------
# This software falls under the GNU general public license and comes WITHOUT
# ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more 
details.
# If you don't have this file, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#==============================================================================

# The first argument is --texmacs
NAME=$2
BANNER=$3
PLUGIN_PROMPT=$4
TEXTOP=$5
TEXBOTTOM=$6
# option --texmacs
# for compatibility with TeXmacs interface convention and user information
if [ "$1" != "--texmacs" ]
then
        echo tm_$NAME. This script should be started only from TeXmacs.
        exit
fi

# Control characters
tmp=`echo DATA_BEGIN=X DATA_END=Y DATA_ESCAPE=Z | tr "XYZ" "\002\005\027" `
eval $tmp

# Defining temporary files directory and make it if it doesn't exist
TEMP_DIR=~/.TeXmacs/system/tmp
if [ -d $TEMP_DIR ]
then
        cd $TEMP_DIR
else
        mkdir -p $TEMP_DIR
        cd $TEMP_DIR
fi

# Defining temporary file name
TEMP_FILE=TMP$NAME

# Startup banner
echo -n $DATA_BEGIN
echo verbatim: $BANNER

# Prompt-input-diag-output loop
while [ 1 ]; do
        # Prompt
        echo -n $DATA_BEGIN
        echo -n channel:prompt
        echo -n $DATA_END
        echo -n $PLUGIN_PROMPT
        echo -n $DATA_END

        # Read a line from stdin
        read -r input

        # Begin creation of LaTeX file
        echo -E $TEXTOP        > $TEMP_FILE.tex

        # Copy Diagrams command in LaTeX file
        echo -E $input | tr  "~" "\n" | cat >> $TEMP_FILE.tex

        # Finish LaTeX file
        echo -E $TEXBOTTOM     >> $TEMP_FILE.tex

        # Compile with latex, transform to .eps and cat .eps to TeXmacs.
        latex --interaction=nonstopmode  $TEMP_FILE.tex > /dev/null
        dvips -q -f -E $TEMP_FILE.dvi -o $TEMP_FILE.eps > /dev/null
        echo -n $DATA_BEGIN
        echo -n verbatim:
        echo -n $DATA_BEGIN
        echo -n ps:
        cat $TEMP_FILE.eps
        echo -n $DATA_END
        echo -ne "\n"
        rm $TEMP_FILE.*
done





reply via email to

[Prev in Thread] Current Thread [Next in Thread]