2001-10-09 15:20:10 +00:00
|
|
|
/* This file is part of
|
2002-03-21 21:21:28 +00:00
|
|
|
* ======================================================
|
2001-10-09 15:20:10 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file ControlTexinfo.C
|
|
|
|
* \author Herbert Voss <voss@lyx.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlTexinfo.h"
|
2001-10-09 15:20:10 +00:00
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "gettext.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "helper_funcs.h"
|
|
|
|
|
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
2001-10-09 15:20:10 +00:00
|
|
|
#include "support/filetools.h" // FileSearch
|
2002-02-18 19:13:48 +00:00
|
|
|
#include "support/systemcall.h"
|
2001-10-09 15:20:10 +00:00
|
|
|
#include "support/path.h"
|
2001-10-10 16:45:05 +00:00
|
|
|
#include "support/lstrings.h"
|
2001-10-09 15:20:10 +00:00
|
|
|
|
2001-10-10 16:45:05 +00:00
|
|
|
extern string user_lyxdir; // home of *Files.lst
|
2001-10-09 15:20:10 +00:00
|
|
|
|
2002-02-16 18:34:30 +00:00
|
|
|
|
2001-10-09 15:20:10 +00:00
|
|
|
ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
|
2002-01-16 14:47:58 +00:00
|
|
|
: ControlDialogBI(lv, d)
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-10-09 15:20:10 +00:00
|
|
|
|
2002-02-16 18:34:30 +00:00
|
|
|
|
2001-10-09 15:20:10 +00:00
|
|
|
// build filelists of all availabe bst/cls/sty-files. done through
|
|
|
|
// kpsewhich and an external script, saved in *Files.lst
|
2001-10-10 16:45:05 +00:00
|
|
|
void ControlTexinfo::rescanStyles() const
|
2001-10-09 15:20:10 +00:00
|
|
|
{
|
|
|
|
// Run rescan in user lyx directory
|
|
|
|
Path p(user_lyxdir);
|
2002-02-18 19:13:48 +00:00
|
|
|
Systemcall one;
|
|
|
|
one.startscript(Systemcall::Wait,
|
2001-10-10 16:45:05 +00:00
|
|
|
LibFileSearch("scripts", "TeXFiles.sh"));
|
2001-10-09 15:20:10 +00:00
|
|
|
p.pop();
|
|
|
|
}
|
|
|
|
|
2001-10-10 16:45:05 +00:00
|
|
|
|
|
|
|
void ControlTexinfo::runTexhash() const
|
2001-10-09 15:20:10 +00:00
|
|
|
{
|
|
|
|
// Run texhash in user lyx directory
|
|
|
|
Path p(user_lyxdir);
|
|
|
|
|
|
|
|
//path to texhash through system
|
2002-02-18 19:13:48 +00:00
|
|
|
Systemcall one;
|
|
|
|
one.startscript(Systemcall::Wait, "texhash");
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-10-09 15:20:10 +00:00
|
|
|
p.pop();
|
2002-03-21 21:21:28 +00:00
|
|
|
// Alert::alert(_("texhash run!"),
|
2001-10-09 15:20:10 +00:00
|
|
|
// _("rebuilding of the TeX-tree could only be successfull"),
|
|
|
|
// _("if you have had user-write-permissions to the tex-dir."));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-10 16:45:05 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
string const sortEntries(string & str_in)
|
|
|
|
{
|
|
|
|
std::vector<string> dbase = getVectorFromString(str_in,"\n");
|
2002-03-21 21:21:28 +00:00
|
|
|
std::sort(dbase.begin(), dbase.end()); // sort entries
|
|
|
|
std::vector<string>::iterator p =
|
|
|
|
std::unique(dbase.begin(), dbase.end()); // compact
|
|
|
|
dbase.erase(p, dbase.end()); // shrink
|
2001-10-10 16:45:05 +00:00
|
|
|
return getStringFromVector(dbase,"\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
} //namespace anon
|
|
|
|
|
|
|
|
|
|
|
|
string const
|
|
|
|
ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const
|
|
|
|
{
|
|
|
|
static string const bstFilename("bstFiles.lst");
|
|
|
|
static string const clsFilename("clsFiles.lst");
|
|
|
|
static string const styFilename("styFiles.lst");
|
|
|
|
|
|
|
|
string filename;
|
|
|
|
switch (type) {
|
2002-03-21 21:21:28 +00:00
|
|
|
case bst:
|
2001-10-10 16:45:05 +00:00
|
|
|
filename = bstFilename;
|
|
|
|
break;
|
|
|
|
case cls:
|
|
|
|
filename = clsFilename;
|
|
|
|
break;
|
|
|
|
case sty:
|
2001-10-12 08:15:47 +00:00
|
|
|
filename = styFilename;
|
2001-10-10 16:45:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
string fileContents = GetFileContents(LibFileSearch(string(),filename));
|
|
|
|
// everything ok?
|
|
|
|
if (!fileContents.empty()) {
|
|
|
|
if (withFullPath)
|
|
|
|
return(sortEntries(fileContents));
|
|
|
|
else {
|
|
|
|
int Entries = 1;
|
|
|
|
string dummy = OnlyFilename(token(fileContents,'\n',1));
|
|
|
|
string contents = dummy;
|
|
|
|
do {
|
|
|
|
dummy = OnlyFilename(token(fileContents,'\n',++Entries));
|
|
|
|
contents += ("\n"+dummy);
|
|
|
|
} while (!dummy.empty());
|
|
|
|
return(sortEntries(contents));
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
return _("Missing filelist. try Rescan");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControlTexinfo::viewFile(string const filename) const
|
2001-10-09 15:20:10 +00:00
|
|
|
{
|
|
|
|
lv_.getDialogs()->showFile(filename);
|
|
|
|
}
|