Hi everyone.

I fixed the last patch to integrate Noweb import into LyX. I also went
ahead and updated all the internationalization files to the best of my
ability. Once again, please check my work.

Here is the updated patch (sorry it's so huge).

You'll need to ``cvs add'' src/ImportNoweb.h and src/ImportNoweb.C if
you decide to apply this.

                            ---Kayvan

-- 
Kayvan Aghaiepour Sylvan   | Proud husband of       | Father to
Sylvan Associates, Inc.    | Laura Isabella Sylvan  | Katherine Yelena (8/8/89)
http://www.isp.net/~kayvan |                        | Robin Gregory (2/28/92)
 

lyx.diffs.gz

// -*- C++ -*-
/* This file is part of
 * ======================================================
 * 
 *           LyX, The Document Processor
 *
 *           Copyright (C) 1995-1999 The LyX Team.
 *
 *           This file is Copyright (C) 1999
 *           Kayvan A. Sylvan
 *
 *======================================================
 */

#ifndef _IMPORTNOWEB_H
#define _IMPORTNOWEB_H

#ifdef __GNUG__
#pragma interface
#endif

#include "LString.h"

class Buffer;

///
class ImportNoweb {
public:
        /**
          file = name and path of the noweb file to import
          */
        ImportNoweb(LString const & file) : file(file) {};
        
        /** Imports the document.
          Return 0 if fail.
          */
        Buffer * run();
private:
        ///
        LString file;
        ///
        LString documentclass();
        static const int BUFSIZE = 512;
};

#endif
/* This file is part of
 * ======================================================
 * 
 *           LyX, The Document Processor         
 *           Copyright (C) 1995 Matthias Ettrich
 *           Copyright (C) 1995-1999 The LyX Team.
 *
 *           This file is Copyright (C) 1999
 *           Kayvan A. Sylvan
 *
 *======================================================
 */

#include <config.h>

#ifdef __GNUG__
#pragma implementation
#endif

#include "ImportNoweb.h"
#include "lyxrc.h"
#include "syscall.h"
#include "filetools.h"
#include "bufferlist.h"

extern LyXRC * lyxrc;
extern BufferList bufferlist;

//      $Id$

#if !defined(lint) && !defined(WITH_WARNINGS)
static char vcid[] = "$Id$";
#endif /* lint */

/*
 * Implementation the ImportNoweb methods.
 */

Buffer * ImportNoweb::run()
{
        // run reLyX -n
        LString tmp = lyxrc->relyx_command + " -n -c " +
                                        documentclass() + " -f " + file;
        Systemcalls one;
        Buffer * buf = 0;
        int result= one.Startscript(Systemcalls::System, tmp);
        if (result==0) {
                LString filename = file + ".lyx";
                // File was generated without problems. Load it.
                buf = bufferlist.loadLyXFile(filename);
        }
        return buf;
}

// Provide the literate documentclass by parsing the file.
//
LString ImportNoweb::documentclass()
{
        LString result = "literate-article"; // Default

        FilePtr inputfile(file, FilePtr::read); 
        if (!inputfile()) return "nofile"; // Should not happen!

        char buf[BUFSIZE], *p, *q;

        while(!feof(inputfile())) {
                (void)fgets(buf, BUFSIZE, inputfile());
                if (p = strstr(buf, "\\documentclass")) {
                        while ((*p) && (*p != '{'))
                                p++;
                        q = p++;
                        while ((*q) && (*q != '}'))
                                q++;
                        *q = '\0';
                        result = p;
                        result = "literate-" + result;
                }
        }

        return result;
}

Reply via email to